Changeset 24 in kStuff for trunk/kHlp/Bare
- Timestamp:
- Feb 8, 2009 1:58:54 PM (16 years ago)
- Location:
- trunk/kHlp/Bare
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kHlp/Bare/kHlpBareThread.c
r2 r24 37 37 38 38 #if K_OS == K_OS_DARWIN 39 # include <mach/mach_time.h> 39 40 40 41 #elif K_OS == K_OS_LINUX … … 59 60 { 60 61 #if K_OS == K_OS_DARWIN 61 /** @todo mach_wait_until, see gen/nanosleep.c. */ 62 usleep(cMillies * 1000); 62 static struct mach_timebase_info s_Info; 63 static KBOOL s_fNanoseconds = K_UNKNOWN; 64 KU64 uNow = mach_absolute_time(); 65 KU64 uDeadline; 66 KU64 uPeriod; 67 68 if (s_fNanoseconds == K_UNKNOWN) 69 { 70 if (mach_timebase_info(&s_Info)) 71 s_fNanoseconds = K_TRUE; /* the easy way out */ 72 else if (s_Info.denom == s_Info.numer) 73 s_fNanoseconds = K_TRUE; 74 else 75 s_fNanoseconds = K_FALSE; 76 } 77 78 uPeriod = (KU64)cMillies * 1000 * 1000; 79 if (!s_fNanoseconds) 80 uPeriod = (double)uPeriod * s_Info.denom / s_Info.numer; /* Use double to avoid 32-bit trouble. */ 81 uDeadline = uNow + uPeriod; 82 mach_wait_until(uDeadline); 63 83 64 84 #elif K_OS == K_OS_LINUX
Note:
See TracChangeset
for help on using the changeset viewer.