summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/clock_nanosleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/clock_nanosleep.c')
-rw-r--r--sysdeps/unix/sysv/linux/clock_nanosleep.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 2a3dd411a1..7645262cee 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,9 +17,11 @@
02111-1307 USA. */
#include <time.h>
+#include <errno.h>
#include <sysdep-cancel.h>
-#include "kernel-features.h"
+#include <kernel-features.h>
+#include "kernel-posix-cpu-timers.h"
#ifdef __ASSUME_POSIX_TIMERS
@@ -32,6 +34,11 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
INTERNAL_SYSCALL_DECL (err);
int r;
+ if (clock_id == CLOCK_THREAD_CPUTIME_ID)
+ return EINVAL;
+ if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
+ clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);
+
if (SINGLE_THREAD_P)
r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem);
else
@@ -58,12 +65,20 @@ extern int __libc_missing_posix_timers attribute_hidden;
# define SYSDEP_NANOSLEEP \
if (!__libc_missing_posix_timers) \
{ \
+ clockid_t syscall_clockid; \
INTERNAL_SYSCALL_DECL (err); \
\
+ if (clock_id == CLOCK_THREAD_CPUTIME_ID) \
+ return EINVAL; \
+ if (clock_id == CLOCK_PROCESS_CPUTIME_ID) \
+ syscall_clockid = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); \
+ else \
+ syscall_clockid = clock_id; \
+ \
int oldstate = LIBC_CANCEL_ASYNC (); \
\
- int r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, \
- req, rem); \
+ int r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, \
+ syscall_clockid, flags, req, rem); \
\
LIBC_CANCEL_RESET (oldstate); \
\