Changes in uspace/lib/libc/generic/time.c [22e6802:c61d34b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/time.c
r22e6802 rc61d34b 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #include <sys/time.h> … … 40 40 #include <unistd.h> 41 41 #include <atomic.h> 42 #include <futex.h> 42 43 #include <sysinfo.h> 43 44 #include <ipc/services.h> 44 #include <libc.h>45 45 46 46 #include <sysinfo.h> … … 189 189 190 190 /** Wait unconditionally for specified number of microseconds */ 191 int usleep(useconds_t usec) 192 { 193 (void) __SYSCALL1(SYS_THREAD_USLEEP, usec); 191 int usleep(unsigned long usec) 192 { 193 atomic_t futex = FUTEX_INITIALIZER; 194 195 futex_initialize(&futex, 0); 196 futex_down_timeout(&futex, usec, 0); 194 197 return 0; 195 198 } 196 199 197 200 /** Wait unconditionally for specified number of seconds */ 198 unsigned int sleep(unsigned int sec) 199 { 201 unsigned int sleep(unsigned int seconds) 202 { 203 atomic_t futex = FUTEX_INITIALIZER; 204 205 futex_initialize(&futex, 0); 206 200 207 /* Sleep in 1000 second steps to support 201 208 full argument range */ 202 while (sec > 0) {203 unsigned int period = (sec > 1000) ? 1000 : sec;209 while (seconds > 0) { 210 unsigned int period = (seconds > 1000) ? 1000 : seconds; 204 211 205 usleep(period * 1000000);206 sec -= period;212 futex_down_timeout(&futex, period * 1000000, 0); 213 seconds -= period; 207 214 } 208 215 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.