1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| | #include <time.h>
#include <errno.h>
#include "syscall.h"
#include "libc.h"
#include "threads.h"
/* Roughly __syscall already returns the right thing: 0 if all went
well or a negative error indication, otherwise. */
int thrd_sleep(const struct timespec *req, struct timespec *rem)
{
int ret = __syscall(SYS_nanosleep, req, rem);
switch (ret) {
case 0:
return 0;
/* error described by POSIX: */
/* EINTR The nanosleep() function was interrupted by a signal. */
/* The C11 wording is: */
/* -1 if it has been interrupted by a signal */
case -EINTR:
return -1;
/* EINVAL: described by POSIX */
/* EFAULT: described for linux */
default:
return -2;
}
}
|