# HG changeset patch # User diego # Date 1055327997 0 # Node ID 24145d6b5883e96cd46d05509a1bba25cb3e4ab7 # Parent e79162f480873c46a87d0151c991e5c14f8763ff obsoleted by timer-darwin.c diff -r e79162f48087 -r 24145d6b5883 osdep/timer-macosx.c --- a/osdep/timer-macosx.c Wed Jun 11 02:28:13 2003 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Semi-precise timer routines using CoreFoundation - * - * (C) 2003 Dan Christiansen - * - * Released into the public domain. - */ - -#include -#include -#include -#include -#include "../config.h" - -#ifdef MACOSX -# include -#endif - -/* Rather than using CF timers, we simply store the absolute time - * CFAbsoluteTime == double */ -static CFAbsoluteTime relative_time; - -int usec_sleep(int usec_delay) -{ - CFRunLoopRunInMode(kCFRunLoopDefaultMode, usec_delay / 1000000.0, false); -} - - -// Returns current time in microseconds -unsigned int GetTimer(){ - return (unsigned int)(CFAbsoluteTimeGetCurrent() * 1000000); -} - -// Returns current time in milliseconds -unsigned int GetTimerMS(){ - return (unsigned int)(CFAbsoluteTimeGetCurrent() * 1000); -} - -// Returns time spent between now and last call in seconds -float GetRelativeTime(){ - CFAbsoluteTime last_time = relative_time; - relative_time = CFAbsoluteTimeGetCurrent(); - return (float)(relative_time - last_time); -} - -// Initialize timer, must be called at least once at start -void InitTimer(){ - GetRelativeTime(); -} - -#if 0 -int main() { - int i; - - for (i = 0; i < 20; i++) { - printf("CF relative time:\t%f\n", GetRelativeTime()); - usec_sleep(1000000); - printf("usleep relative time:\t%f\n", GetRelativeTime()); - usleep(1000000); - } -} -#endif - -