diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_getcpuclockid.c | 46 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_getres.c | 88 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_gettime.c | 98 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_nanosleep.c | 43 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_settime.c | 74 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 4 |
6 files changed, 56 insertions, 297 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c index c6ff466712..1cfdf3489b 100644 --- a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c +++ b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c @@ -1,5 +1,5 @@ /* clock_getcpuclockid -- Get a clockid_t for process CPU time. Linux version. - Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2004-2012 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 @@ -37,11 +37,6 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id) # if !(__ASSUME_POSIX_CPU_TIMERS > 0) extern int __libc_missing_posix_cpu_timers attribute_hidden; -# if !(__ASSUME_POSIX_TIMERS > 0) - extern int __libc_missing_posix_timers attribute_hidden; - if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers) - __libc_missing_posix_cpu_timers = 1; -# endif if (!__libc_missing_posix_cpu_timers) # endif { @@ -53,33 +48,24 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id) return 0; } -# if !(__ASSUME_POSIX_TIMERS > 0) - if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS) + if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL) { - /* The kernel doesn't support these calls at all. */ - __libc_missing_posix_timers = 1; - __libc_missing_posix_cpu_timers = 1; - } - else -# endif - if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL) - { # if !(__ASSUME_POSIX_CPU_TIMERS > 0) - if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) - || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL - (clock_getres, err, 2, - MAKE_PROCESS_CPUCLOCK - (0, CPUCLOCK_SCHED), NULL), - err)) - /* The kernel doesn't support these clocks at all. */ - __libc_missing_posix_cpu_timers = 1; - else + if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) + || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL + (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK + (0, CPUCLOCK_SCHED), NULL), + err)) + /* The kernel doesn't support these clocks at all. */ + __libc_missing_posix_cpu_timers = 1; + else # endif - /* The clock_getres system call checked the PID for us. */ - return ESRCH; - } - else - return INTERNAL_SYSCALL_ERRNO (r, err); + /* The clock_getres system call checked the PID for us. */ + return ESRCH; + } + else + return INTERNAL_SYSCALL_ERRNO (r, err); } #endif diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index e7e3138543..2bada33b40 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -1,5 +1,5 @@ /* clock_getres -- Get the resolution of a POSIX clockid_t. Linux version. - Copyright (C) 2003,2004,2005,2006,2008,2010 Free Software Foundation, Inc. + Copyright (C) 2003-2012 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 @@ -35,11 +35,9 @@ retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); \ break -#ifdef __ASSUME_POSIX_TIMERS - -/* This means the REALTIME and MONOTONIC clock are definitely - supported in the kernel. */ -# define SYSDEP_GETRES \ +/* The REALTIME and MONOTONIC clock are definitely supported in the + kernel. */ +#define SYSDEP_GETRES \ SYSDEP_GETRES_CPUTIME \ case CLOCK_REALTIME: \ case CLOCK_MONOTONIC: \ @@ -48,57 +46,6 @@ case CLOCK_MONOTONIC_COARSE: \ SYSCALL_GETRES -# define __libc_missing_posix_timers 0 -#elif defined __NR_clock_getres -/* Is the syscall known to exist? */ -extern int __libc_missing_posix_timers attribute_hidden; - -static inline int -maybe_syscall_getres (clockid_t clock_id, struct timespec *res) -{ - int e = EINVAL; - - if (!__libc_missing_posix_timers) - { - INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_VSYSCALL (clock_getres, err, 2, clock_id, res); - if (!INTERNAL_SYSCALL_ERROR_P (r, err)) - return 0; - - e = INTERNAL_SYSCALL_ERRNO (r, err); - if (e == ENOSYS) - { - __libc_missing_posix_timers = 1; - e = EINVAL; - } - } - - return e; -} - -/* The REALTIME and MONOTONIC clock might be available. Try the - syscall first. */ -# define SYSDEP_GETRES \ - SYSDEP_GETRES_CPUTIME \ - case CLOCK_REALTIME: \ - case CLOCK_MONOTONIC: \ - case CLOCK_MONOTONIC_RAW: \ - case CLOCK_REALTIME_COARSE: \ - case CLOCK_MONOTONIC_COARSE: \ - retval = maybe_syscall_getres (clock_id, res); \ - if (retval == 0) \ - break; \ - /* Fallback code. */ \ - if (retval == EINVAL && clock_id == CLOCK_REALTIME) \ - retval = realtime_getres (res); \ - else \ - { \ - __set_errno (retval); \ - retval = -1; \ - } \ - break; -#endif - #ifdef __NR_clock_getres /* We handled the REALTIME clock here. */ # define HANDLED_REALTIME 1 @@ -126,26 +73,15 @@ maybe_syscall_getres_cpu (clockid_t clock_id, struct timespec *res) return 0; e = INTERNAL_SYSCALL_ERRNO (r, err); -# ifndef __ASSUME_POSIX_TIMERS - if (e == ENOSYS) - { - __libc_missing_posix_timers = 1; - __libc_missing_posix_cpu_timers = 1; - e = EINVAL; - } - else -# endif + if (e == EINVAL) { - if (e == EINVAL) - { - /* Check whether the kernel supports CPU clocks at all. - If not, record it for the future. */ - r = INTERNAL_VSYSCALL (clock_getres, err, 2, - MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), - NULL); - if (INTERNAL_SYSCALL_ERROR_P (r, err)) - __libc_missing_posix_cpu_timers = 1; - } + /* Check whether the kernel supports CPU clocks at all. + If not, record it for the future. */ + r = INTERNAL_VSYSCALL (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), + NULL); + if (INTERNAL_SYSCALL_ERROR_P (r, err)) + __libc_missing_posix_cpu_timers = 1; } } diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index 446fbb66f6..e333d8d9e8 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -1,5 +1,5 @@ /* clock_gettime -- Get current time from a POSIX clockid_t. Linux version. - Copyright (C) 2003,2004,2005,2006,2007,2010,2011 Free Software Foundation, Inc. + Copyright (C) 2003-2012 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 @@ -40,68 +40,15 @@ INTERNAL_VSYSCALL (clock_gettime, err, 2, id, tp) #endif -#ifdef __ASSUME_POSIX_TIMERS - -/* This means the REALTIME and MONOTONIC clock are definitely - supported in the kernel. */ -# define SYSDEP_GETTIME \ +/* The REALTIME and MONOTONIC clock are definitely supported in the + kernel. */ +#define SYSDEP_GETTIME \ SYSDEP_GETTIME_CPUTIME; \ case CLOCK_REALTIME: \ case CLOCK_MONOTONIC: \ retval = SYSCALL_GETTIME (clock_id, tp); \ break -# define __libc_missing_posix_timers 0 -#elif defined __NR_clock_gettime -/* Is the syscall known to exist? */ -int __libc_missing_posix_timers attribute_hidden; - -static inline int -maybe_syscall_gettime (clockid_t clock_id, struct timespec *tp) -{ - int e = EINVAL; - - if (!__libc_missing_posix_timers) - { - INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_GETTIME (clock_id, tp); - if (!INTERNAL_SYSCALL_ERROR_P (r, err)) - return 0; - - e = INTERNAL_SYSCALL_ERRNO (r, err); - if (e == ENOSYS) - { - __libc_missing_posix_timers = 1; - e = EINVAL; - } - } - - return e; -} - -/* The REALTIME and MONOTONIC clock might be available. Try the - syscall first. */ -# define SYSDEP_GETTIME \ - SYSDEP_GETTIME_CPUTIME; \ - case CLOCK_REALTIME: \ - case CLOCK_MONOTONIC: \ - case CLOCK_MONOTONIC_RAW: \ - case CLOCK_REALTIME_COARSE: \ - case CLOCK_MONOTONIC_COARSE: \ - retval = maybe_syscall_gettime (clock_id, tp); \ - if (retval == 0) \ - break; \ - /* Fallback code. */ \ - if (retval == EINVAL && clock_id == CLOCK_REALTIME) \ - retval = realtime_gettime (tp); \ - else \ - { \ - __set_errno (retval); \ - retval = -1; \ - } \ - break -#endif - #ifdef __NR_clock_gettime /* We handled the REALTIME clock here. */ # define HANDLED_REALTIME 1 @@ -131,34 +78,23 @@ maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp) return 0; e = INTERNAL_SYSCALL_ERRNO (r, err); -# ifndef __ASSUME_POSIX_TIMERS - if (e == ENOSYS) - { - __libc_missing_posix_timers = 1; - __libc_missing_posix_cpu_timers = 1; - e = EINVAL; - } - else -# endif + if (e == EINVAL) { - if (e == EINVAL) - { # ifdef HAVE_CLOCK_GETRES_VSYSCALL - /* Check whether the kernel supports CPU clocks at all. - If not, record it for the future. */ - r = INTERNAL_VSYSCALL (clock_getres, err, 2, - MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), - NULL); + /* Check whether the kernel supports CPU clocks at all. + If not, record it for the future. */ + r = INTERNAL_VSYSCALL (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), + NULL); # else - /* Check whether the kernel supports CPU clocks at all. - If not, record it for the future. */ - r = INTERNAL_SYSCALL (clock_getres, err, 2, - MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), - NULL); + /* Check whether the kernel supports CPU clocks at all. + If not, record it for the future. */ + r = INTERNAL_SYSCALL (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), + NULL); # endif - if (INTERNAL_SYSCALL_ERROR_P (r, err)) - __libc_missing_posix_cpu_timers = 1; - } + if (INTERNAL_SYSCALL_ERROR_P (r, err)) + __libc_missing_posix_cpu_timers = 1; } } diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index e003ba21e6..110296363a 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2003-2012 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 @@ -23,7 +23,6 @@ #include "kernel-posix-cpu-timers.h" -#ifdef __ASSUME_POSIX_TIMERS /* We can simply use the syscall. The CPU clocks are not supported with this function. */ int @@ -53,43 +52,3 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, return (INTERNAL_SYSCALL_ERROR_P (r, err) ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); } - -#else -# ifdef __NR_clock_nanosleep -/* Is the syscall known to exist? */ -extern int __libc_missing_posix_timers attribute_hidden; - -/* The REALTIME and MONOTONIC clock might be available. Try the - syscall first. */ -# 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, \ - syscall_clockid, flags, req, rem); \ - \ - LIBC_CANCEL_RESET (oldstate); \ - \ - if (!INTERNAL_SYSCALL_ERROR_P (r, err)) \ - return 0; \ - \ - if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS) \ - return INTERNAL_SYSCALL_ERRNO (r, err); \ - \ - __libc_missing_posix_timers = 1; \ - } -# endif - -# include <sysdeps/unix/clock_nanosleep.c> -#endif diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index 8cf3209803..f75ceca249 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -32,7 +32,6 @@ #endif #if __ASSUME_POSIX_CPU_TIMERS <= 0 && defined __NR_clock_settime -extern int __libc_missing_posix_timers attribute_hidden; extern int __libc_missing_posix_cpu_timers attribute_hidden; static int @@ -48,26 +47,15 @@ maybe_syscall_settime_cpu (clockid_t clock_id, const struct timespec *tp) return 0; e = INTERNAL_SYSCALL_ERRNO (r, err); -# ifndef __ASSUME_POSIX_TIMERS - if (e == ENOSYS) + if (e == EINVAL) { - __libc_missing_posix_timers = 1; - __libc_missing_posix_cpu_timers = 1; - e = EINVAL; - } - else -# endif - { - if (e == EINVAL) - { - /* Check whether the kernel supports CPU clocks at all. - If not, record it for the future. */ - r = INTERNAL_VSYSCALL (clock_getres, err, 2, - MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), - NULL); - if (INTERNAL_SYSCALL_ERROR_P (r, err)) - __libc_missing_posix_cpu_timers = 1; - } + /* Check whether the kernel supports CPU clocks at all. + If not, record it for the future. */ + r = INTERNAL_VSYSCALL (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), + NULL); + if (INTERNAL_SYSCALL_ERROR_P (r, err)) + __libc_missing_posix_cpu_timers = 1; } } @@ -76,53 +64,11 @@ maybe_syscall_settime_cpu (clockid_t clock_id, const struct timespec *tp) #endif -#ifdef __ASSUME_POSIX_TIMERS -/* This means the REALTIME clock is definitely supported in the - kernel. */ -# define SYSDEP_SETTIME \ +/* The REALTIME clock is definitely supported in the kernel. */ +#define SYSDEP_SETTIME \ case CLOCK_REALTIME: \ retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \ break -#elif defined __NR_clock_settime -/* Is the syscall known to exist? */ -extern int __libc_missing_posix_timers attribute_hidden; - -/* The REALTIME clock might be available. Try the syscall first. */ -# define SYSDEP_SETTIME \ - case CLOCK_REALTIME: \ - case CLOCK_REALTIME_COARSE: \ - { \ - int e = EINVAL; \ - \ - if (!__libc_missing_posix_timers) \ - { \ - INTERNAL_SYSCALL_DECL (err); \ - int r = INTERNAL_SYSCALL (clock_settime, err, 2, clock_id, tp); \ - if (!INTERNAL_SYSCALL_ERROR_P (r, err)) \ - { \ - retval = 0; \ - break; \ - } \ - \ - e = INTERNAL_SYSCALL_ERRNO (r, err); \ - if (e == ENOSYS) \ - { \ - __libc_missing_posix_timers = 1; \ - e = EINVAL; \ - } \ - } \ - \ - /* Fallback code. */ \ - if (e == EINVAL && clock_id == CLOCK_REALTIME) \ - HANDLE_REALTIME; \ - else \ - { \ - __set_errno (e); \ - retval = -1; \ - } \ - } \ - break -#endif #ifdef __NR_clock_settime /* We handled the REALTIME clock here. */ diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 0aa01c95ba..6b0eb95c52 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -92,10 +92,6 @@ # define __ASSUME_MMAP2_SYSCALL 1 #endif -/* Beginning with 2.5.63 support for realtime and monotonic clocks and - timers based on them is available. */ -#define __ASSUME_POSIX_TIMERS 1 - /* Beginning with 2.6.12 the clock and timer supports CPU clocks. */ #define __ASSUME_POSIX_CPU_TIMERS 1 |