Changeset 2064
- Timestamp:
- Jun 23, 2005, 8:02:57 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/misc/sysctl_os2.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2063 r2064 39 39 #include <sys/time.h> 40 40 #include <InnoTekLIBC/FastInfoBlocks.h> 41 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC 42 #include <InnoTekLIBC/logstrict.h> 41 43 #define _KERNEL 42 44 #include <sys/sysctl.h> … … 55 57 if (!tv.tv_sec) 56 58 { 59 /* 60 * Use the highres timer to estimate the wrap-arounds. 61 * Then use that with the millisecond timer to get a 62 * stable number. 63 */ 64 unsigned cWraps = 0; 57 65 union 58 66 { … … 62 70 ULONG ul; 63 71 FS_VAR_SAVE_LOAD(); 64 65 /* Try the highres timer first. */66 72 if ( !DosTmrQueryFreq(&ul) 67 73 && !DosTmrQueryTime(&u.qw)) 68 74 { 69 gettimeofday(&tv, NULL);70 tv.tv_sec -= u.ull / ul;71 75 long double lrd = u.ull; 72 lrd *= 1000 000;76 lrd *= 1000; 73 77 lrd /= ul; 74 ul = (ULONG)lrd; 75 tv.tv_usec -= ul % 1000000; 76 } 77 else 78 { 79 /* Use the millisecond counter. */ 80 gettimeofday(&tv, NULL); 81 ul = fibGetMsCount(); 82 unsigned u = (ul % 1000) * 1000; 83 tv.tv_usec -= u; 84 tv.tv_sec -= ul / 1000; 78 unsigned long long ull = 0x100000000ULL; 79 cWraps = lrd / ull; 85 80 } 86 81 FS_RESTORE(); 87 if (tv.tv_usec < 0) 82 83 gettimeofday(&tv, NULL); 84 gettimeofday(&tv, NULL); 85 ul = fibGetMsCount(); 86 unsigned cSecs = (ul % 1000) * 1000; 87 tv.tv_usec -= cSecs; 88 tv.tv_sec -= ul / 1000; 89 for (;;) 88 90 { 89 tv.tv_sec--; 90 tv.tv_usec += 1000000; 91 if (tv.tv_usec < 0) 92 { 93 tv.tv_sec--; 94 tv.tv_usec += 1000000; 95 } 96 if (cWraps-- <= 0) 97 break; 98 tv.tv_sec -= 4294967; 99 tv.tv_usec -= 296000; 91 100 } 101 LIBC_ASSERT(tv.tv_sec > 0); 102 LIBC_ASSERT(tv.tv_usec >= 0 && tv.tv_usec < 1000000); 92 103 } 93 104 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.