Changeset 24 for trunk/kHlp
- Timestamp:
- Feb 8, 2009, 2:58:54 PM (17 years ago)
- Location:
- trunk/kHlp
- Files:
-
- 2 added
- 2 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 -
trunk/kHlp/Makefile.kmk
r5 r24 65 65 Generic/kHlpInt2Ascii.c \ 66 66 \ 67 67 Generic/kHlpGetEnvUZ.c \ 68 68 \ 69 69 Generic/kHlpGetExt.c \ … … 78 78 Bare/kHlpBareProcess.c \ 79 79 Bare/kHlpBareThread.c \ 80 81 kHlpBareStatic_SOURCES.darwin = \ 82 Bare/kHlpSys-darwin.c 80 83 81 84 # … … 99 102 Generic/kHlpInt2Ascii.c \ 100 103 \ 101 104 Generic/kHlpGetEnvUZ.c \ 102 105 \ 103 106 Generic/kHlpGetExt.c \ … … 111 114 CRT/kHlpCRTString.cpp \ 112 115 116 kHlpCRTStatic_SOURCES.darwin = \ 117 Bare/kHlpSys-darwin.c 118 113 119 114 120 # Generate the rules
Note:
See TracChangeset
for help on using the changeset viewer.