mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-24 16:28:23 -05:00
os_sleep: Use nanosleep for POSIX versions 2008 and higher
uClibc-ng optionally disabled deprecated POSIX functions like usleep, causing compilation failures. This switches to nanosleep while retaining support for older libcs that do not support nanosleep. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
a69742c2f8
commit
39042d7f7c
@ -25,10 +25,16 @@
|
||||
|
||||
void os_sleep(os_time_t sec, os_time_t usec)
|
||||
{
|
||||
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
|
||||
const struct timespec req = { sec, usec * 1000 };
|
||||
|
||||
nanosleep(&req, NULL);
|
||||
#else
|
||||
if (sec)
|
||||
sleep(sec);
|
||||
if (usec)
|
||||
usleep(usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,10 +49,16 @@ struct os_alloc_trace {
|
||||
|
||||
void os_sleep(os_time_t sec, os_time_t usec)
|
||||
{
|
||||
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
|
||||
const struct timespec req = { sec, usec * 1000 };
|
||||
|
||||
nanosleep(&req, NULL);
|
||||
#else
|
||||
if (sec)
|
||||
sleep(sec);
|
||||
if (usec)
|
||||
usleep(usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user