1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

nptl: Refactor thrd_sleep in terms of clock_nanosleep

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Adhemerval Zanella
2019-11-05 21:52:48 +00:00
parent 3537ecb49c
commit 807edded25

View File

@ -24,16 +24,13 @@
int int
thrd_sleep (const struct timespec* time_point, struct timespec* remaining) thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
{ {
INTERNAL_SYSCALL_DECL (err); int ret = __clock_nanosleep (CLOCK_REALTIME, 0, time_point, remaining);
int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, err, time_point, remaining);
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
{
/* C11 states thrd_sleep function returns -1 if it has been interrupted /* C11 states thrd_sleep function returns -1 if it has been interrupted
by a signal, or a negative value if it fails. */ by a signal, or a negative value if it fails. */
ret = INTERNAL_SYSCALL_ERRNO (ret, err); switch (ret)
if (ret == EINTR) {
return -1; case 0: return 0;
return -2; case EINTR: return -1;
default: return -2;
} }
return 0;
} }