summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/clock_nanosleep.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /sysdeps/unix/sysv/linux/clock_nanosleep.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
2.5-18.1
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); \
\