mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-26 06:50:07 +00:00
Remove __ASSUME_POSIX_TIMERS.
This commit is contained in:
parent
4b4f2771c2
commit
93a78ac437
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
|||||||
|
2012-08-16 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/kernel-features.h
|
||||||
|
(__ASSUME_POSIX_TIMERS): Remove.
|
||||||
|
* sysdeps/unix/sysv/linux/clock_getcpuclockid.c
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* sysdeps/unix/sysv/linux/clock_getres.c [__ASSUME_POSIX_TIMERS]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* sysdeps/unix/sysv/linux/clock_gettime.c [__ASSUME_POSIX_TIMERS]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* sysdeps/unix/sysv/linux/clock_nanosleep.c
|
||||||
|
[__ASSUME_POSIX_TIMERS]: Make code unconditional.
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* sysdeps/unix/sysv/linux/clock_settime.c [__ASSUME_POSIX_TIMERS]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
[__ASSUME_POSIX_CPU_TIMERS <= 0 && __NR_clock_settime]
|
||||||
|
(__libc_missing_posix_timers): Remove.
|
||||||
|
|
||||||
2012-08-15 Roland McGrath <roland@hack.frob.com>
|
2012-08-15 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
* elf/dl-load.c (_dl_map_object_from_fd) [SHARED]: Conditionalize
|
* elf/dl-load.c (_dl_map_object_from_fd) [SHARED]: Conditionalize
|
||||||
|
@ -1,3 +1,42 @@
|
|||||||
|
2012-08-16 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* pthread_cond_timedwait.c (__pthread_cond_timedwait)
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* pthread_condattr_setclock.c (pthread_condattr_setclock)
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
|
||||||
|
(__pthread_cond_timedwait) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
|
||||||
|
(__pthread_cond_timedwait) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_create.c [__NR_timer_create]: Make
|
||||||
|
code unconditional.
|
||||||
|
[!__NR-timer_create]: Remove conditional code.
|
||||||
|
(timer_create) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_delete.c [__NR_timer_delete]: Make
|
||||||
|
code unconditional.
|
||||||
|
[!__NR_timer_delete]: Remove conditional code.
|
||||||
|
(timer_delete) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_getoverr.c
|
||||||
|
[__NR_timer_getoverrun]: Make code unconditional.
|
||||||
|
[!__NR_timer_getoverrun]: Remove conditional code.
|
||||||
|
(timer_getoverrun) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_gettime.c [__NR_timer_gettime]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__NR_timer_gettime]: Remove conditional code.
|
||||||
|
(timer_gettime) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_routines.c [__NR_timer_create]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__ASSUME_POSIX_TIMERS]: Remove conditional code.
|
||||||
|
* sysdeps/unix/sysv/linux/timer_settime.c [__NR_timer_settime]:
|
||||||
|
Make code unconditional.
|
||||||
|
[!__NR_timer_settime]: Remove conditional code.
|
||||||
|
(timer_settime) [!__ASSUME_POSIX_TIMERS]: Likewise.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
|
||||||
|
(__pthread_cond_timedwait) [!__ASSUME_POSIX_TIMERS]: Remove
|
||||||
|
conditional code.
|
||||||
|
|
||||||
2012-08-15 Tom de Vries <vries@codesourcery.com>
|
2012-08-15 Tom de Vries <vries@codesourcery.com>
|
||||||
Maxim Kuvyrkov <maxim@codesourcery.com>
|
Maxim Kuvyrkov <maxim@codesourcery.com>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003,2004,2007,2010,2011 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
|
Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
|
||||||
|
|
||||||
@ -113,23 +113,9 @@ __pthread_cond_timedwait (cond, mutex, abstime)
|
|||||||
(cond->__data.__nwaiters
|
(cond->__data.__nwaiters
|
||||||
& ((1 << COND_NWAITERS_SHIFT) - 1)),
|
& ((1 << COND_NWAITERS_SHIFT) - 1)),
|
||||||
&rt);
|
&rt);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
/* Convert the absolute timeout value to a relative timeout. */
|
||||||
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0))
|
rt.tv_sec = abstime->tv_sec - rt.tv_sec;
|
||||||
{
|
rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
|
||||||
struct timeval tv;
|
|
||||||
(void) gettimeofday (&tv, NULL);
|
|
||||||
|
|
||||||
/* Convert the absolute timeout value to a relative timeout. */
|
|
||||||
rt.tv_sec = abstime->tv_sec - tv.tv_sec;
|
|
||||||
rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
/* Convert the absolute timeout value to a relative timeout. */
|
|
||||||
rt.tv_sec = abstime->tv_sec - rt.tv_sec;
|
|
||||||
rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
/* Get the current time. So far we support only one clock. */
|
/* Get the current time. So far we support only one clock. */
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -30,32 +30,8 @@ pthread_condattr_setclock (attr, clock_id)
|
|||||||
pthread_condattr_t *attr;
|
pthread_condattr_t *attr;
|
||||||
clockid_t clock_id;
|
clockid_t clock_id;
|
||||||
{
|
{
|
||||||
/* Only a few clocks are allowed. CLOCK_REALTIME is always allowed.
|
/* Only a few clocks are allowed. */
|
||||||
CLOCK_MONOTONIC only if the kernel has the necessary support. */
|
if (clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_REALTIME)
|
||||||
if (clock_id == CLOCK_MONOTONIC)
|
|
||||||
{
|
|
||||||
#ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
# ifdef __NR_clock_getres
|
|
||||||
/* Check whether the clock is available. */
|
|
||||||
static int avail;
|
|
||||||
|
|
||||||
if (avail == 0)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
int val;
|
|
||||||
val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
|
|
||||||
avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avail < 0)
|
|
||||||
# endif
|
|
||||||
/* Not available. */
|
|
||||||
return EINVAL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (clock_id != CLOCK_REALTIME)
|
|
||||||
/* If more clocks are allowed some day the storing of the clock ID
|
/* If more clocks are allowed some day the storing of the clock ID
|
||||||
in the pthread_cond_t structure needs to be adjusted. */
|
in the pthread_cond_t structure needs to be adjusted. */
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -122,10 +122,6 @@ __pthread_cond_timedwait:
|
|||||||
leal 4(%esp), %ecx
|
leal 4(%esp), %ecx
|
||||||
movl $__NR_clock_gettime, %eax
|
movl $__NR_clock_gettime, %eax
|
||||||
ENTER_KERNEL
|
ENTER_KERNEL
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
cmpl $-ENOSYS, %eax
|
|
||||||
je 19f
|
|
||||||
# endif
|
|
||||||
movl %edx, %ebx
|
movl %edx, %ebx
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
/* Compute relative timeout. */
|
||||||
@ -482,30 +478,6 @@ __pthread_cond_timedwait:
|
|||||||
call __lll_unlock_wake
|
call __lll_unlock_wake
|
||||||
jmp 11b
|
jmp 11b
|
||||||
|
|
||||||
#if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
|
|
||||||
/* clock_gettime not available. */
|
|
||||||
19: leal 4(%esp), %ebx
|
|
||||||
xorl %ecx, %ecx
|
|
||||||
movl $__NR_gettimeofday, %eax
|
|
||||||
ENTER_KERNEL
|
|
||||||
movl %edx, %ebx
|
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
|
||||||
movl 8(%esp), %eax
|
|
||||||
movl $1000, %edx
|
|
||||||
mul %edx /* Milli seconds to nano seconds. */
|
|
||||||
movl (%ebp), %ecx
|
|
||||||
movl 4(%ebp), %edx
|
|
||||||
subl 4(%esp), %ecx
|
|
||||||
subl %eax, %edx
|
|
||||||
jns 20f
|
|
||||||
addl $1000000000, %edx
|
|
||||||
subl $1, %ecx
|
|
||||||
20: testl %ecx, %ecx
|
|
||||||
movl $-ETIMEDOUT, %esi
|
|
||||||
js 6b
|
|
||||||
jmp 21b
|
|
||||||
#endif
|
|
||||||
.size __pthread_cond_timedwait, .-__pthread_cond_timedwait
|
.size __pthread_cond_timedwait, .-__pthread_cond_timedwait
|
||||||
versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
|
versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
|
||||||
GLIBC_2_3_2)
|
GLIBC_2_3_2)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* pthread_getcpuclockid -- Get POSIX clockid_t for a pthread_t. Linux version
|
/* pthread_getcpuclockid -- Get POSIX clockid_t for a pthread_t. Linux version
|
||||||
Copyright (C) 2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
|
Copyright (C) 2000-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -27,9 +27,6 @@
|
|||||||
#if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
#if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
||||||
int __libc_missing_posix_cpu_timers attribute_hidden;
|
int __libc_missing_posix_cpu_timers attribute_hidden;
|
||||||
#endif
|
#endif
|
||||||
#if !(__ASSUME_POSIX_TIMERS > 0)
|
|
||||||
int __libc_missing_posix_timers attribute_hidden;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pthread_getcpuclockid (threadid, clockid)
|
pthread_getcpuclockid (threadid, clockid)
|
||||||
@ -51,10 +48,6 @@ pthread_getcpuclockid (threadid, clockid)
|
|||||||
const clockid_t tidclock = MAKE_THREAD_CPUCLOCK (pd->tid, CPUCLOCK_SCHED);
|
const clockid_t tidclock = MAKE_THREAD_CPUCLOCK (pd->tid, CPUCLOCK_SCHED);
|
||||||
|
|
||||||
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
||||||
# if !(__ASSUME_POSIX_TIMERS > 0)
|
|
||||||
if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers)
|
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
|
||||||
# endif
|
|
||||||
if (!__libc_missing_posix_cpu_timers)
|
if (!__libc_missing_posix_cpu_timers)
|
||||||
{
|
{
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
@ -67,21 +60,12 @@ pthread_getcpuclockid (threadid, clockid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
||||||
# if !(__ASSUME_POSIX_TIMERS > 0)
|
if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
|
||||||
if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
|
|
||||||
{
|
{
|
||||||
/* The kernel doesn't support these calls at all. */
|
/* The kernel doesn't support these clocks at all. */
|
||||||
__libc_missing_posix_timers = 1;
|
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
__libc_missing_posix_cpu_timers = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif
|
|
||||||
if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
|
|
||||||
{
|
|
||||||
/* The kernel doesn't support these clocks at all. */
|
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return INTERNAL_SYSCALL_ERRNO (r, err);
|
return INTERNAL_SYSCALL_ERRNO (r, err);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
@ -158,10 +158,6 @@ __pthread_cond_timedwait:
|
|||||||
mov.w .L__NR_clock_gettime, r3
|
mov.w .L__NR_clock_gettime, r3
|
||||||
trapa #0x12
|
trapa #0x12
|
||||||
SYSCALL_INST_PAD
|
SYSCALL_INST_PAD
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
cmp/eq #-ENOSYS, r0
|
|
||||||
bt 19f
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
/* Compute relative timeout. */
|
||||||
mov.l @r13, r2
|
mov.l @r13, r2
|
||||||
@ -172,24 +168,6 @@ __pthread_cond_timedwait:
|
|||||||
.L__NR_clock_gettime:
|
.L__NR_clock_gettime:
|
||||||
.word __NR_clock_gettime
|
.word __NR_clock_gettime
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
19:
|
|
||||||
mov r15, r4
|
|
||||||
add #16, r4
|
|
||||||
mov #0, r5
|
|
||||||
mov #__NR_gettimeofday, r3
|
|
||||||
trapa #0x12
|
|
||||||
SYSCALL_INST_PAD
|
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
|
||||||
mov.l @(20,r15), r0
|
|
||||||
mov.w .L1k, r1
|
|
||||||
dmulu.l r0, r1 /* Micro seconds to nano seconds. */
|
|
||||||
mov.l @r13, r2
|
|
||||||
mov.l @(4,r13), r3
|
|
||||||
mov.l @(16,r15), r0
|
|
||||||
sts macl, r1
|
|
||||||
#endif
|
|
||||||
0:
|
0:
|
||||||
#else
|
#else
|
||||||
mov r15, r4
|
mov r15, r4
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003,2004, 2007, 2009 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -30,21 +30,9 @@
|
|||||||
#include "kernel-posix-cpu-timers.h"
|
#include "kernel-posix-cpu-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_create
|
#ifdef timer_create_alias
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
# define timer_create timer_create_alias
|
||||||
static int compat_timer_create (clockid_t clock_id, struct sigevent *evp,
|
#endif
|
||||||
timer_t *timerid);
|
|
||||||
# define timer_create static compat_timer_create
|
|
||||||
# include <nptl/sysdeps/pthread/timer_create.c>
|
|
||||||
# undef timer_create
|
|
||||||
|
|
||||||
/* Nonzero if the system calls are not available. */
|
|
||||||
int __no_posix_timers attribute_hidden;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef timer_create_alias
|
|
||||||
# define timer_create timer_create_alias
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -53,190 +41,140 @@ timer_create (clock_id, evp, timerid)
|
|||||||
struct sigevent *evp;
|
struct sigevent *evp;
|
||||||
timer_t *timerid;
|
timer_t *timerid;
|
||||||
{
|
{
|
||||||
# undef timer_create
|
#undef timer_create
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
{
|
||||||
if (__no_posix_timers >= 0)
|
clockid_t syscall_clockid = (clock_id == CLOCK_PROCESS_CPUTIME_ID
|
||||||
# endif
|
? MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
|
||||||
{
|
: clock_id == CLOCK_THREAD_CPUTIME_ID
|
||||||
clockid_t syscall_clockid = (clock_id == CLOCK_PROCESS_CPUTIME_ID
|
? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
|
||||||
? MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
|
: clock_id);
|
||||||
: clock_id == CLOCK_THREAD_CPUTIME_ID
|
|
||||||
? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
|
|
||||||
: clock_id);
|
|
||||||
|
|
||||||
/* If the user wants notification via a thread we need to handle
|
/* If the user wants notification via a thread we need to handle
|
||||||
this special. */
|
this special. */
|
||||||
if (evp == NULL
|
if (evp == NULL
|
||||||
|| __builtin_expect (evp->sigev_notify != SIGEV_THREAD, 1))
|
|| __builtin_expect (evp->sigev_notify != SIGEV_THREAD, 1))
|
||||||
{
|
{
|
||||||
struct sigevent local_evp;
|
struct sigevent local_evp;
|
||||||
|
|
||||||
/* We avoid allocating too much memory by basically
|
/* We avoid allocating too much memory by basically
|
||||||
using struct timer as a derived class with the
|
using struct timer as a derived class with the
|
||||||
first two elements being in the superclass. We only
|
first two elements being in the superclass. We only
|
||||||
need these two elements here. */
|
need these two elements here. */
|
||||||
struct timer *newp = (struct timer *) malloc (offsetof (struct timer,
|
struct timer *newp = (struct timer *) malloc (offsetof (struct timer,
|
||||||
thrfunc));
|
thrfunc));
|
||||||
if (newp == NULL)
|
if (newp == NULL)
|
||||||
/* No more memory. */
|
/* No more memory. */
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (evp == NULL)
|
||||||
|
{
|
||||||
|
/* The kernel has to pass up the timer ID which is a
|
||||||
|
userlevel object. Therefore we cannot leave it up to
|
||||||
|
the kernel to determine it. */
|
||||||
|
local_evp.sigev_notify = SIGEV_SIGNAL;
|
||||||
|
local_evp.sigev_signo = SIGALRM;
|
||||||
|
local_evp.sigev_value.sival_ptr = newp;
|
||||||
|
|
||||||
|
evp = &local_evp;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel_timer_t ktimerid;
|
||||||
|
int retval = INLINE_SYSCALL (timer_create, 3, syscall_clockid, evp,
|
||||||
|
&ktimerid);
|
||||||
|
|
||||||
|
if (retval != -1)
|
||||||
|
{
|
||||||
|
newp->sigev_notify = (evp != NULL
|
||||||
|
? evp->sigev_notify : SIGEV_SIGNAL);
|
||||||
|
newp->ktimerid = ktimerid;
|
||||||
|
|
||||||
|
*timerid = (timer_t) newp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Cannot allocate the timer, fail. */
|
||||||
|
free (newp);
|
||||||
|
retval = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Create the helper thread. */
|
||||||
|
pthread_once (&__helper_once, __start_helper_thread);
|
||||||
|
if (__helper_tid == 0)
|
||||||
|
{
|
||||||
|
/* No resources to start the helper thread. */
|
||||||
|
__set_errno (EAGAIN);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (evp == NULL)
|
struct timer *newp;
|
||||||
{
|
newp = (struct timer *) malloc (sizeof (struct timer));
|
||||||
/* The kernel has to pass up the timer ID which is a
|
if (newp == NULL)
|
||||||
userlevel object. Therefore we cannot leave it up to
|
return -1;
|
||||||
the kernel to determine it. */
|
|
||||||
local_evp.sigev_notify = SIGEV_SIGNAL;
|
|
||||||
local_evp.sigev_signo = SIGALRM;
|
|
||||||
local_evp.sigev_value.sival_ptr = newp;
|
|
||||||
|
|
||||||
evp = &local_evp;
|
/* Copy the thread parameters the user provided. */
|
||||||
}
|
newp->sival = evp->sigev_value;
|
||||||
|
newp->thrfunc = evp->sigev_notify_function;
|
||||||
|
newp->sigev_notify = SIGEV_THREAD;
|
||||||
|
|
||||||
kernel_timer_t ktimerid;
|
/* We cannot simply copy the thread attributes since the
|
||||||
int retval = INLINE_SYSCALL (timer_create, 3, syscall_clockid, evp,
|
implementation might keep internal information for
|
||||||
&ktimerid);
|
each instance. */
|
||||||
|
(void) pthread_attr_init (&newp->attr);
|
||||||
|
if (evp->sigev_notify_attributes != NULL)
|
||||||
|
{
|
||||||
|
struct pthread_attr *nattr;
|
||||||
|
struct pthread_attr *oattr;
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
nattr = (struct pthread_attr *) &newp->attr;
|
||||||
if (retval != -1 || errno != ENOSYS)
|
oattr = (struct pthread_attr *) evp->sigev_notify_attributes;
|
||||||
# endif
|
|
||||||
{
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (retval != -1)
|
nattr->schedparam = oattr->schedparam;
|
||||||
{
|
nattr->schedpolicy = oattr->schedpolicy;
|
||||||
newp->sigev_notify = (evp != NULL
|
nattr->flags = oattr->flags;
|
||||||
? evp->sigev_notify : SIGEV_SIGNAL);
|
nattr->guardsize = oattr->guardsize;
|
||||||
newp->ktimerid = ktimerid;
|
nattr->stackaddr = oattr->stackaddr;
|
||||||
|
nattr->stacksize = oattr->stacksize;
|
||||||
|
}
|
||||||
|
|
||||||
*timerid = (timer_t) newp;
|
/* In any case set the detach flag. */
|
||||||
}
|
(void) pthread_attr_setdetachstate (&newp->attr,
|
||||||
else
|
PTHREAD_CREATE_DETACHED);
|
||||||
{
|
|
||||||
/* Cannot allocate the timer, fail. */
|
|
||||||
free (newp);
|
|
||||||
retval = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
/* Create the event structure for the kernel timer. */
|
||||||
}
|
struct sigevent sev =
|
||||||
|
{ .sigev_value.sival_ptr = newp,
|
||||||
|
.sigev_signo = SIGTIMER,
|
||||||
|
.sigev_notify = SIGEV_SIGNAL | SIGEV_THREAD_ID,
|
||||||
|
._sigev_un = { ._pad = { [0] = __helper_tid } } };
|
||||||
|
|
||||||
free (newp);
|
/* Create the timer. */
|
||||||
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
|
int res;
|
||||||
|
res = INTERNAL_SYSCALL (timer_create, err, 3,
|
||||||
|
syscall_clockid, &sev, &newp->ktimerid);
|
||||||
|
if (! INTERNAL_SYSCALL_ERROR_P (res, err))
|
||||||
|
{
|
||||||
|
/* Add to the queue of active timers with thread
|
||||||
|
delivery. */
|
||||||
|
pthread_mutex_lock (&__active_timer_sigev_thread_lock);
|
||||||
|
newp->next = __active_timer_sigev_thread;
|
||||||
|
__active_timer_sigev_thread = newp;
|
||||||
|
pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
*timerid = (timer_t) newp;
|
||||||
/* When we come here the syscall does not exist. Make sure we
|
return 0;
|
||||||
do not try to use it again. */
|
}
|
||||||
__no_posix_timers = -1;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
/* Make sure we have the necessary kernel support. */
|
|
||||||
if (__no_posix_timers == 0)
|
|
||||||
{
|
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
struct timespec ts;
|
|
||||||
int res;
|
|
||||||
res = INTERNAL_SYSCALL (clock_getres, err, 2,
|
|
||||||
CLOCK_REALTIME, &ts);
|
|
||||||
__no_posix_timers = (INTERNAL_SYSCALL_ERROR_P (res, err)
|
|
||||||
? -1 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__no_posix_timers > 0)
|
/* Free the resources. */
|
||||||
# endif
|
free (newp);
|
||||||
{
|
|
||||||
/* Create the helper thread. */
|
|
||||||
pthread_once (&__helper_once, __start_helper_thread);
|
|
||||||
if (__helper_tid == 0)
|
|
||||||
{
|
|
||||||
/* No resources to start the helper thread. */
|
|
||||||
__set_errno (EAGAIN);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timer *newp;
|
__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
|
||||||
newp = (struct timer *) malloc (sizeof (struct timer));
|
|
||||||
if (newp == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Copy the thread parameters the user provided. */
|
return -1;
|
||||||
newp->sival = evp->sigev_value;
|
}
|
||||||
newp->thrfunc = evp->sigev_notify_function;
|
}
|
||||||
newp->sigev_notify = SIGEV_THREAD;
|
|
||||||
|
|
||||||
/* We cannot simply copy the thread attributes since the
|
|
||||||
implementation might keep internal information for
|
|
||||||
each instance. */
|
|
||||||
(void) pthread_attr_init (&newp->attr);
|
|
||||||
if (evp->sigev_notify_attributes != NULL)
|
|
||||||
{
|
|
||||||
struct pthread_attr *nattr;
|
|
||||||
struct pthread_attr *oattr;
|
|
||||||
|
|
||||||
nattr = (struct pthread_attr *) &newp->attr;
|
|
||||||
oattr = (struct pthread_attr *) evp->sigev_notify_attributes;
|
|
||||||
|
|
||||||
nattr->schedparam = oattr->schedparam;
|
|
||||||
nattr->schedpolicy = oattr->schedpolicy;
|
|
||||||
nattr->flags = oattr->flags;
|
|
||||||
nattr->guardsize = oattr->guardsize;
|
|
||||||
nattr->stackaddr = oattr->stackaddr;
|
|
||||||
nattr->stacksize = oattr->stacksize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In any case set the detach flag. */
|
|
||||||
(void) pthread_attr_setdetachstate (&newp->attr,
|
|
||||||
PTHREAD_CREATE_DETACHED);
|
|
||||||
|
|
||||||
/* Create the event structure for the kernel timer. */
|
|
||||||
struct sigevent sev =
|
|
||||||
{ .sigev_value.sival_ptr = newp,
|
|
||||||
.sigev_signo = SIGTIMER,
|
|
||||||
.sigev_notify = SIGEV_SIGNAL | SIGEV_THREAD_ID,
|
|
||||||
._sigev_un = { ._pad = { [0] = __helper_tid } } };
|
|
||||||
|
|
||||||
/* Create the timer. */
|
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
int res;
|
|
||||||
res = INTERNAL_SYSCALL (timer_create, err, 3,
|
|
||||||
syscall_clockid, &sev, &newp->ktimerid);
|
|
||||||
if (! INTERNAL_SYSCALL_ERROR_P (res, err))
|
|
||||||
{
|
|
||||||
/* Add to the queue of active timers with thread
|
|
||||||
delivery. */
|
|
||||||
pthread_mutex_lock (&__active_timer_sigev_thread_lock);
|
|
||||||
newp->next = __active_timer_sigev_thread;
|
|
||||||
__active_timer_sigev_thread = newp;
|
|
||||||
pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
|
|
||||||
|
|
||||||
*timerid = (timer_t) newp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the resources. */
|
|
||||||
free (newp);
|
|
||||||
|
|
||||||
__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
/* Compatibility code. */
|
|
||||||
return compat_timer_create (clock_id, evp, timerid);
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef timer_create_alias
|
|
||||||
# define timer_create timer_create_alias
|
|
||||||
# endif
|
|
||||||
/* The new system calls are not available. Use the userlevel
|
|
||||||
implementation. */
|
|
||||||
# include <nptl/sysdeps/pthread/timer_create.c>
|
|
||||||
#endif
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -24,91 +24,51 @@
|
|||||||
#include "kernel-posix-timers.h"
|
#include "kernel-posix-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_delete
|
#ifdef timer_delete_alias
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
# define timer_delete timer_delete_alias
|
||||||
static int compat_timer_delete (timer_t timerid);
|
#endif
|
||||||
# define timer_delete static compat_timer_delete
|
|
||||||
# include <nptl/sysdeps/pthread/timer_delete.c>
|
|
||||||
# undef timer_delete
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef timer_delete_alias
|
|
||||||
# define timer_delete timer_delete_alias
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
timer_delete (timerid)
|
timer_delete (timerid)
|
||||||
timer_t timerid;
|
timer_t timerid;
|
||||||
{
|
{
|
||||||
# undef timer_delete
|
#undef timer_delete
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
struct timer *kt = (struct timer *) timerid;
|
||||||
if (__no_posix_timers >= 0)
|
|
||||||
# endif
|
/* Delete the kernel timer object. */
|
||||||
|
int res = INLINE_SYSCALL (timer_delete, 1, kt->ktimerid);
|
||||||
|
|
||||||
|
if (res == 0)
|
||||||
{
|
{
|
||||||
struct timer *kt = (struct timer *) timerid;
|
if (kt->sigev_notify == SIGEV_THREAD)
|
||||||
|
|
||||||
/* Delete the kernel timer object. */
|
|
||||||
int res = INLINE_SYSCALL (timer_delete, 1, kt->ktimerid);
|
|
||||||
|
|
||||||
if (res == 0)
|
|
||||||
{
|
{
|
||||||
if (kt->sigev_notify == SIGEV_THREAD)
|
/* Remove the timer from the list. */
|
||||||
|
pthread_mutex_lock (&__active_timer_sigev_thread_lock);
|
||||||
|
if (__active_timer_sigev_thread == kt)
|
||||||
|
__active_timer_sigev_thread = kt->next;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Remove the timer from the list. */
|
struct timer *prevp = __active_timer_sigev_thread;
|
||||||
pthread_mutex_lock (&__active_timer_sigev_thread_lock);
|
while (prevp->next != NULL)
|
||||||
if (__active_timer_sigev_thread == kt)
|
if (prevp->next == kt)
|
||||||
__active_timer_sigev_thread = kt->next;
|
{
|
||||||
else
|
prevp->next = kt->next;
|
||||||
{
|
break;
|
||||||
struct timer *prevp = __active_timer_sigev_thread;
|
}
|
||||||
while (prevp->next != NULL)
|
else
|
||||||
if (prevp->next == kt)
|
prevp = prevp->next;
|
||||||
{
|
|
||||||
prevp->next = kt->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
prevp = prevp->next;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
|
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
/* We know the syscall support is available. */
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Free the memory. */
|
|
||||||
(void) free (kt);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The kernel timer is not known or something else bad happened.
|
/* Free the memory. */
|
||||||
Return the error. */
|
(void) free (kt);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
if (errno != ENOSYS)
|
|
||||||
{
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
return -1;
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
}
|
|
||||||
|
|
||||||
__no_posix_timers = -1;
|
return 0;
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
/* The kernel timer is not known or something else bad happened.
|
||||||
return compat_timer_delete (timerid);
|
Return the error. */
|
||||||
# endif
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef timer_delete_alias
|
|
||||||
# define timer_delete timer_delete_alias
|
|
||||||
# endif
|
|
||||||
/* The new system calls are not available. Use the userlevel
|
|
||||||
implementation. */
|
|
||||||
# include <nptl/sysdeps/pthread/timer_delete.c>
|
|
||||||
#endif
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -23,58 +23,20 @@
|
|||||||
#include "kernel-posix-timers.h"
|
#include "kernel-posix-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_getoverrun
|
#ifdef timer_getoverrun_alias
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
# define timer_getoverrun timer_getoverrun_alias
|
||||||
static int compat_timer_getoverrun (timer_t timerid);
|
#endif
|
||||||
# define timer_getoverrun static compat_timer_getoverrun
|
|
||||||
# include <nptl/sysdeps/pthread/timer_getoverr.c>
|
|
||||||
# undef timer_getoverrun
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef timer_getoverrun_alias
|
|
||||||
# define timer_getoverrun timer_getoverrun_alias
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
timer_getoverrun (timerid)
|
timer_getoverrun (timerid)
|
||||||
timer_t timerid;
|
timer_t timerid;
|
||||||
{
|
{
|
||||||
# undef timer_getoverrun
|
#undef timer_getoverrun
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
struct timer *kt = (struct timer *) timerid;
|
||||||
if (__no_posix_timers >= 0)
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
struct timer *kt = (struct timer *) timerid;
|
|
||||||
|
|
||||||
/* Get the information from the kernel. */
|
/* Get the information from the kernel. */
|
||||||
int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid);
|
int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid);
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
return res;
|
||||||
if (res != -1 || errno != ENOSYS)
|
|
||||||
{
|
|
||||||
/* We know the syscall support is available. */
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
return res;
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
__no_posix_timers = -1;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
return compat_timer_getoverrun (timerid);
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef timer_getoverrun_alias
|
|
||||||
# define timer_getoverrun timer_getoverrun_alias
|
|
||||||
# endif
|
|
||||||
/* The new system calls are not available. Use the userlevel
|
|
||||||
implementation. */
|
|
||||||
# include <nptl/sysdeps/pthread/timer_getoverr.c>
|
|
||||||
#endif
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -24,17 +24,9 @@
|
|||||||
#include "kernel-posix-timers.h"
|
#include "kernel-posix-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_gettime
|
#ifdef timer_gettime_alias
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
# define timer_gettime timer_gettime_alias
|
||||||
static int compat_timer_gettime (timer_t timerid, struct itimerspec *value);
|
#endif
|
||||||
# define timer_gettime static compat_timer_gettime
|
|
||||||
# include <nptl/sysdeps/pthread/timer_gettime.c>
|
|
||||||
# undef timer_gettime
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef timer_gettime_alias
|
|
||||||
# define timer_gettime timer_gettime_alias
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -42,41 +34,11 @@ timer_gettime (timerid, value)
|
|||||||
timer_t timerid;
|
timer_t timerid;
|
||||||
struct itimerspec *value;
|
struct itimerspec *value;
|
||||||
{
|
{
|
||||||
# undef timer_gettime
|
#undef timer_gettime
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
struct timer *kt = (struct timer *) timerid;
|
||||||
if (__no_posix_timers >= 0)
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
struct timer *kt = (struct timer *) timerid;
|
|
||||||
|
|
||||||
/* Delete the kernel timer object. */
|
/* Delete the kernel timer object. */
|
||||||
int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value);
|
int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value);
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
return res;
|
||||||
if (res != -1 || errno != ENOSYS)
|
|
||||||
{
|
|
||||||
/* We know the syscall support is available. */
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
return res;
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
__no_posix_timers = -1;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
return compat_timer_gettime (timerid, value);
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef timer_gettime_alias
|
|
||||||
# define timer_gettime timer_gettime_alias
|
|
||||||
# endif
|
|
||||||
/* The new system calls are not available. Use the userlevel
|
|
||||||
implementation. */
|
|
||||||
# include <nptl/sysdeps/pthread/timer_gettime.c>
|
|
||||||
#endif
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003-2007, 2011 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ struct thread_start_data
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_create
|
|
||||||
/* Helper thread to call the user-provided function. */
|
/* Helper thread to call the user-provided function. */
|
||||||
static void *
|
static void *
|
||||||
timer_sigev_thread (void *arg)
|
timer_sigev_thread (void *arg)
|
||||||
@ -196,8 +195,3 @@ __start_helper_thread (void)
|
|||||||
be created. */
|
be created. */
|
||||||
pthread_atfork (NULL, NULL, reset_helper_control);
|
pthread_atfork (NULL, NULL, reset_helper_control);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
# include <nptl/sysdeps/pthread/timer_routines.c>
|
|
||||||
#endif
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||||
|
|
||||||
@ -24,19 +24,9 @@
|
|||||||
#include "kernel-posix-timers.h"
|
#include "kernel-posix-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __NR_timer_settime
|
#ifdef timer_settime_alias
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
# define timer_settime timer_settime_alias
|
||||||
static int compat_timer_settime (timer_t timerid, int flags,
|
#endif
|
||||||
const struct itimerspec *value,
|
|
||||||
struct itimerspec *ovalue);
|
|
||||||
# define timer_settime static compat_timer_settime
|
|
||||||
# include <nptl/sysdeps/pthread/timer_settime.c>
|
|
||||||
# undef timer_settime
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef timer_settime_alias
|
|
||||||
# define timer_settime timer_settime_alias
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -46,42 +36,12 @@ timer_settime (timerid, flags, value, ovalue)
|
|||||||
const struct itimerspec *value;
|
const struct itimerspec *value;
|
||||||
struct itimerspec *ovalue;
|
struct itimerspec *ovalue;
|
||||||
{
|
{
|
||||||
# undef timer_settime
|
#undef timer_settime
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
struct timer *kt = (struct timer *) timerid;
|
||||||
if (__no_posix_timers >= 0)
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
struct timer *kt = (struct timer *) timerid;
|
|
||||||
|
|
||||||
/* Delete the kernel timer object. */
|
/* Delete the kernel timer object. */
|
||||||
int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
|
int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
|
||||||
value, ovalue);
|
value, ovalue);
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
return res;
|
||||||
if (res != -1 || errno != ENOSYS)
|
|
||||||
{
|
|
||||||
/* We know the syscall support is available. */
|
|
||||||
__no_posix_timers = 1;
|
|
||||||
# endif
|
|
||||||
return res;
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
__no_posix_timers = -1;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
return compat_timer_settime (timerid, flags, value, ovalue);
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef timer_settime_alias
|
|
||||||
# define timer_settime timer_settime_alias
|
|
||||||
# endif
|
|
||||||
/* The new system calls are not available. Use the userlevel
|
|
||||||
implementation. */
|
|
||||||
# include <nptl/sysdeps/pthread/timer_settime.c>
|
|
||||||
#endif
|
|
||||||
|
@ -457,10 +457,6 @@ __pthread_cond_timedwait:
|
|||||||
movl $__NR_clock_gettime, %eax
|
movl $__NR_clock_gettime, %eax
|
||||||
syscall
|
syscall
|
||||||
# endif
|
# endif
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
|
||||||
cmpq $-ENOSYS, %rax
|
|
||||||
je 19f
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
/* Compute relative timeout. */
|
||||||
movq (%r13), %rcx
|
movq (%r13), %rcx
|
||||||
@ -604,32 +600,6 @@ __pthread_cond_timedwait:
|
|||||||
subq $cond_lock, %rdi
|
subq $cond_lock, %rdi
|
||||||
# endif
|
# endif
|
||||||
jmp 6b
|
jmp 6b
|
||||||
|
|
||||||
# if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
|
|
||||||
/* clock_gettime not available. */
|
|
||||||
19: leaq 32(%rsp), %rdi
|
|
||||||
xorl %esi, %esi
|
|
||||||
/* This call works because we directly jump to a system call entry
|
|
||||||
which preserves all the registers. */
|
|
||||||
call JUMPTARGET(__gettimeofday)
|
|
||||||
|
|
||||||
/* Compute relative timeout. */
|
|
||||||
movq 40(%rsp), %rax
|
|
||||||
movl $1000, %edx
|
|
||||||
mul %rdx /* Milli seconds to nano seconds. */
|
|
||||||
movq (%r13), %rcx
|
|
||||||
movq 8(%r13), %rdx
|
|
||||||
subq 32(%rsp), %rcx
|
|
||||||
subq %rax, %rdx
|
|
||||||
jns 20f
|
|
||||||
addq $1000000000, %rdx
|
|
||||||
decq %rcx
|
|
||||||
20: testq %rcx, %rcx
|
|
||||||
movq 8(%rsp), %rdi
|
|
||||||
movq $-ETIMEDOUT, %r14
|
|
||||||
js 6b
|
|
||||||
jmp 21b
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
.size __pthread_cond_timedwait, .-__pthread_cond_timedwait
|
.size __pthread_cond_timedwait, .-__pthread_cond_timedwait
|
||||||
versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
|
versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* clock_getcpuclockid -- Get a clockid_t for process CPU time. Linux version.
|
/* 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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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)
|
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
||||||
extern int __libc_missing_posix_cpu_timers attribute_hidden;
|
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)
|
if (!__libc_missing_posix_cpu_timers)
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
@ -53,33 +48,24 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if !(__ASSUME_POSIX_TIMERS > 0)
|
if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
|
||||||
if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
|
|
||||||
{
|
{
|
||||||
/* The kernel doesn't support these calls at all. */
|
# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
|
||||||
__libc_missing_posix_timers = 1;
|
if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
|| 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
|
else
|
||||||
# endif
|
return INTERNAL_SYSCALL_ERRNO (r, err);
|
||||||
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
|
|
||||||
# endif
|
|
||||||
/* The clock_getres system call checked the PID for us. */
|
|
||||||
return ESRCH;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return INTERNAL_SYSCALL_ERRNO (r, err);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* clock_getres -- Get the resolution of a POSIX clockid_t. Linux version.
|
/* 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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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); \
|
retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); \
|
||||||
break
|
break
|
||||||
|
|
||||||
#ifdef __ASSUME_POSIX_TIMERS
|
/* The REALTIME and MONOTONIC clock are definitely supported in the
|
||||||
|
kernel. */
|
||||||
/* This means the REALTIME and MONOTONIC clock are definitely
|
#define SYSDEP_GETRES \
|
||||||
supported in the kernel. */
|
|
||||||
# define SYSDEP_GETRES \
|
|
||||||
SYSDEP_GETRES_CPUTIME \
|
SYSDEP_GETRES_CPUTIME \
|
||||||
case CLOCK_REALTIME: \
|
case CLOCK_REALTIME: \
|
||||||
case CLOCK_MONOTONIC: \
|
case CLOCK_MONOTONIC: \
|
||||||
@ -48,57 +46,6 @@
|
|||||||
case CLOCK_MONOTONIC_COARSE: \
|
case CLOCK_MONOTONIC_COARSE: \
|
||||||
SYSCALL_GETRES
|
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
|
#ifdef __NR_clock_getres
|
||||||
/* We handled the REALTIME clock here. */
|
/* We handled the REALTIME clock here. */
|
||||||
# define HANDLED_REALTIME 1
|
# define HANDLED_REALTIME 1
|
||||||
@ -126,26 +73,15 @@ maybe_syscall_getres_cpu (clockid_t clock_id, struct timespec *res)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
if (e == EINVAL)
|
||||||
if (e == ENOSYS)
|
|
||||||
{
|
{
|
||||||
__libc_missing_posix_timers = 1;
|
/* Check whether the kernel supports CPU clocks at all.
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
If not, record it for the future. */
|
||||||
e = EINVAL;
|
r = INTERNAL_VSYSCALL (clock_getres, err, 2,
|
||||||
}
|
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
||||||
else
|
NULL);
|
||||||
# endif
|
if (INTERNAL_SYSCALL_ERROR_P (r, err))
|
||||||
{
|
__libc_missing_posix_cpu_timers = 1;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* clock_gettime -- Get current time from a POSIX clockid_t. Linux version.
|
/* 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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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)
|
INTERNAL_VSYSCALL (clock_gettime, err, 2, id, tp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ASSUME_POSIX_TIMERS
|
/* The REALTIME and MONOTONIC clock are definitely supported in the
|
||||||
|
kernel. */
|
||||||
/* This means the REALTIME and MONOTONIC clock are definitely
|
#define SYSDEP_GETTIME \
|
||||||
supported in the kernel. */
|
|
||||||
# define SYSDEP_GETTIME \
|
|
||||||
SYSDEP_GETTIME_CPUTIME; \
|
SYSDEP_GETTIME_CPUTIME; \
|
||||||
case CLOCK_REALTIME: \
|
case CLOCK_REALTIME: \
|
||||||
case CLOCK_MONOTONIC: \
|
case CLOCK_MONOTONIC: \
|
||||||
retval = SYSCALL_GETTIME (clock_id, tp); \
|
retval = SYSCALL_GETTIME (clock_id, tp); \
|
||||||
break
|
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
|
#ifdef __NR_clock_gettime
|
||||||
/* We handled the REALTIME clock here. */
|
/* We handled the REALTIME clock here. */
|
||||||
# define HANDLED_REALTIME 1
|
# define HANDLED_REALTIME 1
|
||||||
@ -131,34 +78,23 @@ maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
if (e == EINVAL)
|
||||||
if (e == ENOSYS)
|
|
||||||
{
|
{
|
||||||
__libc_missing_posix_timers = 1;
|
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
|
||||||
e = EINVAL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
if (e == EINVAL)
|
|
||||||
{
|
|
||||||
# ifdef HAVE_CLOCK_GETRES_VSYSCALL
|
# ifdef HAVE_CLOCK_GETRES_VSYSCALL
|
||||||
/* Check whether the kernel supports CPU clocks at all.
|
/* Check whether the kernel supports CPU clocks at all.
|
||||||
If not, record it for the future. */
|
If not, record it for the future. */
|
||||||
r = INTERNAL_VSYSCALL (clock_getres, err, 2,
|
r = INTERNAL_VSYSCALL (clock_getres, err, 2,
|
||||||
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
||||||
NULL);
|
NULL);
|
||||||
# else
|
# else
|
||||||
/* Check whether the kernel supports CPU clocks at all.
|
/* Check whether the kernel supports CPU clocks at all.
|
||||||
If not, record it for the future. */
|
If not, record it for the future. */
|
||||||
r = INTERNAL_SYSCALL (clock_getres, err, 2,
|
r = INTERNAL_SYSCALL (clock_getres, err, 2,
|
||||||
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
||||||
NULL);
|
NULL);
|
||||||
# endif
|
# endif
|
||||||
if (INTERNAL_SYSCALL_ERROR_P (r, err))
|
if (INTERNAL_SYSCALL_ERROR_P (r, err))
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
__libc_missing_posix_cpu_timers = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -23,7 +23,6 @@
|
|||||||
#include "kernel-posix-cpu-timers.h"
|
#include "kernel-posix-cpu-timers.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __ASSUME_POSIX_TIMERS
|
|
||||||
/* We can simply use the syscall. The CPU clocks are not supported
|
/* We can simply use the syscall. The CPU clocks are not supported
|
||||||
with this function. */
|
with this function. */
|
||||||
int
|
int
|
||||||
@ -53,43 +52,3 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
|
|||||||
return (INTERNAL_SYSCALL_ERROR_P (r, err)
|
return (INTERNAL_SYSCALL_ERROR_P (r, err)
|
||||||
? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
|
? 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
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __ASSUME_POSIX_CPU_TIMERS <= 0 && defined __NR_clock_settime
|
#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;
|
extern int __libc_missing_posix_cpu_timers attribute_hidden;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -48,26 +47,15 @@ maybe_syscall_settime_cpu (clockid_t clock_id, const struct timespec *tp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
e = INTERNAL_SYSCALL_ERRNO (r, err);
|
||||||
# ifndef __ASSUME_POSIX_TIMERS
|
if (e == EINVAL)
|
||||||
if (e == ENOSYS)
|
|
||||||
{
|
{
|
||||||
__libc_missing_posix_timers = 1;
|
/* Check whether the kernel supports CPU clocks at all.
|
||||||
__libc_missing_posix_cpu_timers = 1;
|
If not, record it for the future. */
|
||||||
e = EINVAL;
|
r = INTERNAL_VSYSCALL (clock_getres, err, 2,
|
||||||
}
|
MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
|
||||||
else
|
NULL);
|
||||||
# endif
|
if (INTERNAL_SYSCALL_ERROR_P (r, err))
|
||||||
{
|
__libc_missing_posix_cpu_timers = 1;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,53 +64,11 @@ maybe_syscall_settime_cpu (clockid_t clock_id, const struct timespec *tp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __ASSUME_POSIX_TIMERS
|
/* The REALTIME clock is definitely supported in the kernel. */
|
||||||
/* This means the REALTIME clock is definitely supported in the
|
#define SYSDEP_SETTIME \
|
||||||
kernel. */
|
|
||||||
# define SYSDEP_SETTIME \
|
|
||||||
case CLOCK_REALTIME: \
|
case CLOCK_REALTIME: \
|
||||||
retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \
|
retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \
|
||||||
break
|
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
|
#ifdef __NR_clock_settime
|
||||||
/* We handled the REALTIME clock here. */
|
/* We handled the REALTIME clock here. */
|
||||||
|
@ -92,10 +92,6 @@
|
|||||||
# define __ASSUME_MMAP2_SYSCALL 1
|
# define __ASSUME_MMAP2_SYSCALL 1
|
||||||
#endif
|
#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. */
|
/* Beginning with 2.6.12 the clock and timer supports CPU clocks. */
|
||||||
#define __ASSUME_POSIX_CPU_TIMERS 1
|
#define __ASSUME_POSIX_CPU_TIMERS 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user