diff options
author | peter <peter@FreeBSD.org> | 1997-05-17 11:40:58 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-05-17 11:40:58 +0000 |
commit | 01e3d5c705d7984f822cc8fd215d9da6c468d568 (patch) | |
tree | 221e25c74bcebcdba5bcaed641b6a934055e0e4a /lib/libc/gen/usleep.c | |
parent | eebddce2d991040a4e2617d137784fd14de84964 (diff) | |
download | FreeBSD-src-01e3d5c705d7984f822cc8fd215d9da6c468d568.zip FreeBSD-src-01e3d5c705d7984f822cc8fd215d9da6c468d568.tar.gz |
Allow conditional use (add -DUSE_NANOSLEEP) to CFLAGS of nanosleep() for
the backend of sleep(3) and usleep(3). It's off by default until the
problem is fixed.
Diffstat (limited to 'lib/libc/gen/usleep.c')
-rw-r--r-- | lib/libc/gen/usleep.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 9aece6f..b5effd4 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -41,7 +41,9 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; #ifdef _THREAD_SAFE #include <pthread.h> #include "pthread_private.h" -#else +#endif + +#if !defined(_THREAD_SAFE) && !defined(USE_NANOSLEEP) #define TICK 10000 /* system clock resolution in microseconds */ #define USPS 1000000 /* number of microseconds in a second */ @@ -49,6 +51,12 @@ static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 static int ringring; + +static void +sleephandler() +{ + ringring = 1; +} #endif @@ -57,13 +65,13 @@ usleep(useconds) unsigned int useconds; { #ifdef _THREAD_SAFE - struct timespec time_to_sleep; + struct timespec time_to_sleep; - if (useconds) { - time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; - time_to_sleep.tv_sec = useconds / 1000000; - nanosleep(&time_to_sleep,NULL); - } + if (useconds) { + time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; + time_to_sleep.tv_sec = useconds / 1000000; + nanosleep(&time_to_sleep, NULL); + } #else register struct itimerval *itp; struct itimerval itv, oitv; @@ -106,11 +114,3 @@ usleep(useconds) (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); #endif } - -#ifndef _THREAD_SAFE -static void -sleephandler() -{ - ringring = 1; -} -#endif |