Changeset 1971 for features/performance/src/sleep.h
- Timestamp:
- 04/09/08 15:37:35 (9 months ago)
- Files:
-
- 1 modified
-
features/performance/src/sleep.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
features/performance/src/sleep.h
r1970 r1971 57 57 58 58 static inline void 59 nanosleep_sleep(struct time valnap)59 nanosleep_sleep(struct timespec nap) 60 60 { 61 struct timespec ts; 62 TIMEVAL_TO_TIMESPEC(&nap, &ts); 63 nanosleep(&ts, NULL); 61 nanosleep(&nap, NULL); 64 62 } 65 63 … … 70 68 */ 71 69 static inline void 72 gettimeofday_sleep(struct time valnap)70 gettimeofday_sleep(struct timespec nap) 73 71 { 74 struct timeval now, sleep_until ;72 struct timeval now, sleep_until, nap_for; 75 73 gettimeofday(&now, NULL); 76 timeradd(&now, &nap, &sleep_until); 74 TIMESPEC_TO_TIMEVAL(&nap_for, &nap); 75 timeradd(&now, &nap_for, &sleep_until); 77 76 78 77 do { … … 87 86 88 87 88 /* 89 * Not sure if this is any better then a gettimeofday() loop, but 90 * in order to find out, nap needs to be a timespec (nanosec precision) 91 */ 89 92 static inline void 90 absolute_time_sleep(struct time valnap)93 absolute_time_sleep(struct timespec nap) 91 94 { 92 95 AbsoluteTime sleep_until, naptime, time_left; 96 Nanoseconds nanosec; 93 97 94 naptime = DurationToAbsolute(TIMEVAL_TO_MICROSEC(&nap)); 98 nanosec = UInt64ToUnsignedWide(TIMESPEC_TO_NANOSEC(&nap)); 99 naptime = NanosecondsToAbsolute(nanosec); 95 100 96 101 sleep_until = AddAbsoluteToAbsolute(UpTime(), naptime); 97 102 98 103 do { 99 104 time_left = SubAbsoluteFromAbsolute(sleep_until, UpTime()); … … 112 117 */ 113 118 static inline void 114 select_sleep(const struct time valnap)119 select_sleep(const struct timespec nap) 115 120 { 116 121 struct timeval timeout; 117 122 118 timeout.tv_sec = nap.tv_sec; 119 timeout.tv_usec = nap.tv_usec; 123 TIMESPEC_TO_TIMEVAL(&timeout, &nap); 120 124 121 125 if (select(0, NULL, NULL, NULL, &timeout) < 0) … … 137 141 138 142 static inline void 139 ioport_sleep(const struct time valnap)143 ioport_sleep(const struct timespec nap) 140 144 { 145 struct timeval nap_for; 141 146 u_int32_t usec; 142 147 time_t i; 148 149 TIMESPEC_TO_TIMEVAL(&nap_for, &nap); 143 150 144 151 /* … … 146 153 * use slower 64bit integers or worry about integer overflows. 147 154 */ 148 for (i = 0; i < nap .tv_sec; i ++) {149 usec = SEC_TO_MICROSEC(nap .tv_sec);155 for (i = 0; i < nap_for.tv_sec; i ++) { 156 usec = SEC_TO_MICROSEC(nap_for.tv_sec); 150 157 while (usec > 0) { 151 158 usec --; … … 155 162 156 163 /* process the usec */ 157 usec = nap.tv_ usec;164 usec = nap.tv_nsec / 1000; 158 165 usec --; /* fudge factor for all the above */ 159 166 while (usec > 0) {
