for namespace-safety with thrd_sleep, this requires an alias, which is also added. this eliminates all but one direct call point for nanosleep syscalls, and arranges that 64-bit time_t conversion logic will only need to exist in one file rather than three. as a bonus, clock_nanosleep with CLOCK_REALTIME and empty flags is now implemented as SYS_nanosleep, thereby working on older kernels that may lack POSIX clocks functionality.
15 lines
331 B
C
15 lines
331 B
C
#include <threads.h>
|
|
#include <time.h>
|
|
#include <errno.h>
|
|
#include "syscall.h"
|
|
|
|
int thrd_sleep(const struct timespec *req, struct timespec *rem)
|
|
{
|
|
int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem);
|
|
switch (ret) {
|
|
case 0: return 0;
|
|
case -EINTR: return -1; /* value specified by C11 */
|
|
default: return -2;
|
|
}
|
|
}
|