From 09402f5bc1d87787c84dbf75d41777c87b1ce40e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 25 Mar 2003 20:41:26 +0000 Subject: Update. 2003-03-25 Ulrich Drepper * csu/tst-atomic.c: Adjust tests to what atomic_add_negative and atomic_add_zero were supposed to do. * include/atomic.h: Adjust atomic_add_negative and atomic_add_zero to x86 behavior. * sysdeps/generic/bits/typesizes.h (__TIMER_T_TYPE): Define as void*. This matches the new timer implementation. * sysdeps/unix/sysv/linux/bits/siginfo.h (struct siginfo): Adjust timer info for what the kernel provides these days. (struct sigevent): Add _tid field. Define SIGEV_THREAD_ID. * Versions.def (librt): Add GLIBC_2.3.3. * abilist/libpthread.abilist: Update for nptl. --- nptl/ChangeLog | 60 ++++++ nptl/cleanup.c | 3 - nptl/cleanup_defer.c | 3 - nptl/init.c | 10 + nptl/sysdeps/i386/pthreaddef.h | 5 +- nptl/sysdeps/ia64/pthreaddef.h | 3 - nptl/sysdeps/powerpc/pthreaddef.h | 3 - nptl/sysdeps/pthread/posix-timer.h | 7 +- nptl/sysdeps/pthread/pthread_sigmask.c | 35 ++- nptl/sysdeps/pthread/sigaction.c | 7 +- nptl/sysdeps/s390/pthreaddef.h | 3 - nptl/sysdeps/sh/pthreaddef.h | 3 - nptl/sysdeps/unix/sysv/linux/allocrtsig.c | 4 +- nptl/sysdeps/unix/sysv/linux/bits/local_lim.h | 3 - nptl/sysdeps/unix/sysv/linux/ia64/Versions | 7 + nptl/sysdeps/unix/sysv/linux/ia64/timer_create.c | 1 + nptl/sysdeps/unix/sysv/linux/ia64/timer_delete.c | 1 + nptl/sysdeps/unix/sysv/linux/ia64/timer_getoverr.c | 1 + nptl/sysdeps/unix/sysv/linux/ia64/timer_gettime.c | 1 + nptl/sysdeps/unix/sysv/linux/ia64/timer_settime.c | 1 + nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h | 62 ++++++ .../unix/sysv/linux/powerpc/powerpc64/Versions | 7 + .../sysv/linux/powerpc/powerpc64/timer_create.c | 1 + .../sysv/linux/powerpc/powerpc64/timer_delete.c | 1 + .../sysv/linux/powerpc/powerpc64/timer_getoverr.c | 1 + .../sysv/linux/powerpc/powerpc64/timer_gettime.c | 1 + .../sysv/linux/powerpc/powerpc64/timer_settime.c | 1 + nptl/sysdeps/unix/sysv/linux/pthread_kill.c | 2 +- nptl/sysdeps/unix/sysv/linux/s390/s390-64/Versions | 7 + .../unix/sysv/linux/s390/s390-64/timer_create.c | 1 + .../unix/sysv/linux/s390/s390-64/timer_delete.c | 1 + .../unix/sysv/linux/s390/s390-64/timer_getoverr.c | 1 + .../unix/sysv/linux/s390/s390-64/timer_gettime.c | 1 + .../unix/sysv/linux/s390/s390-64/timer_settime.c | 1 + nptl/sysdeps/unix/sysv/linux/timer_create.c | 235 +++++++++++++++++++++ nptl/sysdeps/unix/sysv/linux/timer_delete.c | 94 +++++++++ nptl/sysdeps/unix/sysv/linux/timer_getoverr.c | 80 +++++++ nptl/sysdeps/unix/sysv/linux/timer_gettime.c | 82 +++++++ nptl/sysdeps/unix/sysv/linux/timer_routines.c | 81 +++++++ nptl/sysdeps/unix/sysv/linux/timer_settime.c | 85 ++++++++ nptl/sysdeps/unix/sysv/linux/x86_64/Versions | 7 + nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h | 46 ++++ nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c | 66 ++++++ nptl/sysdeps/unix/sysv/linux/x86_64/timer_delete.c | 45 ++++ .../unix/sysv/linux/x86_64/timer_getoverr.c | 39 ++++ .../sysdeps/unix/sysv/linux/x86_64/timer_gettime.c | 38 ++++ .../sysdeps/unix/sysv/linux/x86_64/timer_settime.c | 40 ++++ nptl/sysdeps/x86_64/pthreaddef.h | 3 - 48 files changed, 1149 insertions(+), 41 deletions(-) create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/Versions create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/timer_create.c create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/timer_delete.c create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/timer_getoverr.c create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/timer_gettime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/ia64/timer_settime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/Versions create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_create.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_delete.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_getoverr.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_gettime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_routines.c create mode 100644 nptl/sysdeps/unix/sysv/linux/timer_settime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/Versions create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/timer_delete.c create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/timer_gettime.c create mode 100644 nptl/sysdeps/unix/sysv/linux/x86_64/timer_settime.c (limited to 'nptl') diff --git a/nptl/ChangeLog b/nptl/ChangeLog index fe24582..3138047 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,63 @@ +2003-03-25 Ulrich Drepper + + * pthreadP.h: Define SIGCANCEL and SIGTIMER. + * sysdeps/i386/pthreaddef.h: Remove SIGCANCEL definition. + * sysdeps/ia64/pthreaddef.h: Likewise. + * sysdeps/powerpc/pthreaddef.h: Likewise. + * sysdeps/s390/pthreaddef.h: Likewise. + * sysdeps/sh/pthreaddef.h: Likewise. + * sysdeps/x86_64/pthreaddef.h: Likewise. + * init.c (__pthread_initialize_minimal): Block SIGTIMER. + * sysdeps/pthread/sigaction.c: Also prevent SIGTIMER handler from + being changed. + * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Make sure + SIGTIMER is not unblocked. + * sysdeps/unix/sysv/linux/allocrtsig.c (current_rtmin): One more + RT signal taken. + * sysdeps/unix/sysv/linux/pthread_kill.c: Do not allow SIGTIMER to + be send. + * sysdeps/pthread/posix-timer.h (timer_id2ptr, timer_ptr2id): Just + pass pointer through as ID. + * sysdeps/unix/sysv/linux/bits/local_lim.h (TIMER_MAX): Removed. + * sysdeps/unix/sysv/linux/kernel-posix-timers.h: New file. + * sysdeps/unix/sysv/linux/timer_create.c: New file. + * sysdeps/unix/sysv/linux/timer_delete.c: New file. + * sysdeps/unix/sysv/linux/timer_getoverr.c: New file. + * sysdeps/unix/sysv/linux/timer_gettime.c: New file. + * sysdeps/unix/sysv/linux/timer_routines.c: New file. + * sysdeps/unix/sysv/linux/timer_settime.c: New file. + * sysdeps/unix/sysv/linux/ia64/Versions: New file. + * sysdeps/unix/sysv/linux/ia64/timer_create.c: New file. + * sysdeps/unix/sysv/linux/ia64/timer_delete.c: New file. + * sysdeps/unix/sysv/linux/ia64/timer_getoverr.c: New file. + * sysdeps/unix/sysv/linux/ia64/timer_gettime.c: New file. + * sysdeps/unix/sysv/linux/ia64/timer_settime.c: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/Versions: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c: New file. + * sysdeps/unix/sysv/linux/x86_64/Versions: New file. + * sysdeps/unix/sysv/linux/x86_64/compat-timer.h: New file. + * sysdeps/unix/sysv/linux/x86_64/timer_create.c: New file. + * sysdeps/unix/sysv/linux/x86_64/timer_delete.c: New file. + * sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c: New file. + * sysdeps/unix/sysv/linux/x86_64/timer_gettime.c: New file. + * sysdeps/unix/sysv/linux/x86_64/timer_settime.c: New file. + + * pthreadP.h: Remove FRAME_LEFT definition. + * cleanup.c (_pthread_cleanup_push): Don't check for reference to + already left frame. Programs which have this problem are not POSIX + compliant. + * cleanup_defer.c (_pthread_cleanup_push_defer): Likewise. + 2003-03-24 Ulrich Drepper * sysdeps/pthread/tst-timer.c: Check return values of the diff --git a/nptl/cleanup.c b/nptl/cleanup.c index fd372b6..a25b397 100644 --- a/nptl/cleanup.c +++ b/nptl/cleanup.c @@ -33,9 +33,6 @@ _pthread_cleanup_push (buffer, routine, arg) buffer->__arg = arg; buffer->__prev = THREAD_GETMEM (self, cleanup); - if (buffer->__prev != NULL && FRAME_LEFT (buffer, buffer->__prev)) - buffer->__prev = NULL; - THREAD_SETMEM (self, cleanup, buffer); } strong_alias (_pthread_cleanup_push, __pthread_cleanup_push) diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c index b72553b..5d6ed03 100644 --- a/nptl/cleanup_defer.c +++ b/nptl/cleanup_defer.c @@ -33,9 +33,6 @@ _pthread_cleanup_push_defer (buffer, routine, arg) buffer->__arg = arg; buffer->__prev = THREAD_GETMEM (self, cleanup); - if (buffer->__prev != NULL && FRAME_LEFT (buffer, buffer->__prev)) - buffer->__prev = NULL; - int cancelhandling = THREAD_GETMEM (self, cancelhandling); /* Disable asynchronous cancellation for now. */ diff --git a/nptl/init.c b/nptl/init.c index 4237c6e..2c85d87 100644 --- a/nptl/init.c +++ b/nptl/init.c @@ -225,6 +225,16 @@ __pthread_initialize_minimal_internal (void) NULL, _NSIG / 8); + /* The kernel supported POSIX timer handling needs a signal to implement + SIGEV_THREAD. We block the signal everywhere but we have to make + sure it is not ignored. The signal is a realtime signal so using + the default handler is fine (this handler is already selected). */ + __sigdelset (&sa.sa_mask, SIGCANCEL); + __sigaddset (&sa.sa_mask, SIGTIMER); + (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &sa.sa_mask, + NULL, _NSIG / 8); + + /* Determine the default allowed stack size. This is the size used in case the user does not specify one. */ struct rlimit limit; diff --git a/nptl/sysdeps/i386/pthreaddef.h b/nptl/sysdeps/i386/pthreaddef.h index 1fe9455..43b771c 100644 --- a/nptl/sysdeps/i386/pthreaddef.h +++ b/nptl/sysdeps/i386/pthreaddef.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -30,9 +30,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 16 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) diff --git a/nptl/sysdeps/ia64/pthreaddef.h b/nptl/sysdeps/ia64/pthreaddef.h index 8fc58e0..f2539e2 100644 --- a/nptl/sysdeps/ia64/pthreaddef.h +++ b/nptl/sysdeps/ia64/pthreaddef.h @@ -31,9 +31,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 16 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __stack_pointer diff --git a/nptl/sysdeps/powerpc/pthreaddef.h b/nptl/sysdeps/powerpc/pthreaddef.h index b28d0be..342c15c 100644 --- a/nptl/sysdeps/powerpc/pthreaddef.h +++ b/nptl/sysdeps/powerpc/pthreaddef.h @@ -29,9 +29,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 16 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) diff --git a/nptl/sysdeps/pthread/posix-timer.h b/nptl/sysdeps/pthread/posix-timer.h index 6710291..bc0c57f 100644 --- a/nptl/sysdeps/pthread/posix-timer.h +++ b/nptl/sysdeps/pthread/posix-timer.h @@ -1,5 +1,5 @@ /* Definitions for POSIX timer implementation on top of LinuxThreads. - Copyright (C) 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Kaz Kylheku . @@ -94,6 +94,7 @@ extern struct thread_node __timer_signal_thread_tclk; /* Return pointer to timer structure corresponding to ID. */ +#if 0 static inline struct timer_node * timer_id2ptr (timer_t timerid) { @@ -109,6 +110,10 @@ timer_ptr2id (struct timer_node *timer) { return timer - __timer_array; } +#else +# define timer_id2ptr(timerid) ((struct timed_node *) timerid) +# define timer_ptr2id(timerid) ((void *) timerid) +#endif /* Check whether timer is valid; global mutex must be held. */ static inline int diff --git a/nptl/sysdeps/pthread/pthread_sigmask.c b/nptl/sysdeps/pthread/pthread_sigmask.c index 4114e0b..df6ac64 100644 --- a/nptl/sysdeps/pthread/pthread_sigmask.c +++ b/nptl/sysdeps/pthread/pthread_sigmask.c @@ -32,13 +32,36 @@ pthread_sigmask (how, newmask, oldmask) sigset_t local_newmask; /* The only thing we have to make sure here is that SIGCANCEL is not - blocked. */ - if (newmask != NULL - && __builtin_expect (__sigismember (newmask, SIGCANCEL), 0)) + blocked and that SIGTIMER is not unblocked. */ + if (newmask != NULL) { - local_newmask = *newmask; - sigdelset (&local_newmask, SIGCANCEL); - newmask = &local_newmask; + if (__builtin_expect (__sigismember (newmask, SIGCANCEL), 0)) + { + local_newmask = *newmask; + __sigdelset (&local_newmask, SIGCANCEL); + newmask = &local_newmask; + } + + if (__builtin_expect (__sigismember (newmask, SIGTIMER), 0)) + { + if (how == SIG_UNBLOCK) + { + if (newmask != &local_newmask) + local_newmask = *newmask; + __sigdelset (&local_newmask, SIGTIMER); + newmask = &local_newmask; + } + } + else + { + if (how == SIG_SETMASK) + { + if (newmask != &local_newmask) + local_newmask = *newmask; + __sigaddset (&local_newmask, SIGTIMER); + newmask = &local_newmask; + } + } } #ifdef INTERNAL_SYSCALL diff --git a/nptl/sysdeps/pthread/sigaction.c b/nptl/sysdeps/pthread/sigaction.c index e3554dd..d69abf0 100644 --- a/nptl/sysdeps/pthread/sigaction.c +++ b/nptl/sysdeps/pthread/sigaction.c @@ -22,9 +22,10 @@ exact file anyway. */ #ifndef LIBC_SIGACTION +#include + /* We use the libc implementation but we tell it to not allow - SIGCANCEL to be handled. */ -# define SIGCANCEL __SIGRTMIN + SIGCANCEL or SIGTIMER to be handled. */ # define LIBC_SIGACTION 1 # include @@ -35,7 +36,7 @@ __sigaction (sig, act, oact) const struct sigaction *act; struct sigaction *oact; { - if (sig == SIGCANCEL) + if (sig == SIGCANCEL || sig == SIGTIMER) { __set_errno (EINVAL); return -1; diff --git a/nptl/sysdeps/s390/pthreaddef.h b/nptl/sysdeps/s390/pthreaddef.h index ff044a3..6569e2a 100644 --- a/nptl/sysdeps/s390/pthreaddef.h +++ b/nptl/sysdeps/s390/pthreaddef.h @@ -29,9 +29,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 16 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) diff --git a/nptl/sysdeps/sh/pthreaddef.h b/nptl/sysdeps/sh/pthreaddef.h index c66e838..70c6a85 100644 --- a/nptl/sysdeps/sh/pthreaddef.h +++ b/nptl/sysdeps/sh/pthreaddef.h @@ -30,9 +30,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 8 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) diff --git a/nptl/sysdeps/unix/sysv/linux/allocrtsig.c b/nptl/sysdeps/unix/sysv/linux/allocrtsig.c index e3622c6..2654169 100644 --- a/nptl/sysdeps/unix/sysv/linux/allocrtsig.c +++ b/nptl/sysdeps/unix/sysv/linux/allocrtsig.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -20,7 +20,7 @@ #include -static int current_rtmin = __SIGRTMIN + 1; +static int current_rtmin = __SIGRTMIN + 2; static int current_rtmax = __SIGRTMAX; diff --git a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h index 90564cb..7f44549 100644 --- a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h +++ b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h @@ -73,9 +73,6 @@ /* Minimum size for a thread. We are free to choose a reasonable value. */ #define PTHREAD_STACK_MIN 16384 -/* Maximum number of POSIX timers available. */ -#define TIMER_MAX 256 - /* Maximum number of timer expiration overruns. */ #define DELAYTIMER_MAX 2147483647 diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/Versions b/nptl/sysdeps/unix/sysv/linux/ia64/Versions new file mode 100644 index 0000000..3b111dd --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/Versions @@ -0,0 +1,7 @@ +librt { + GLIBC_2.3.3 { + # Changed timer_t. + timer_create; timer_delete; timer_getoverrun; timer_gettime; + timer_settime; + } +} diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/ia64/timer_create.c new file mode 100644 index 0000000..172223a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/timer_create.c @@ -0,0 +1 @@ +#include "../x86_64/timer_create.c" diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/timer_delete.c b/nptl/sysdeps/unix/sysv/linux/ia64/timer_delete.c new file mode 100644 index 0000000..537516e --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/timer_delete.c @@ -0,0 +1 @@ +#include "../x86_64/timer_delete.c" diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/timer_getoverr.c b/nptl/sysdeps/unix/sysv/linux/ia64/timer_getoverr.c new file mode 100644 index 0000000..3f21a73 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/timer_getoverr.c @@ -0,0 +1 @@ +#include "../x86_64/timer_getoverr.c" diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/timer_gettime.c b/nptl/sysdeps/unix/sysv/linux/ia64/timer_gettime.c new file mode 100644 index 0000000..a50143a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/timer_gettime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_gettime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/timer_settime.c b/nptl/sysdeps/unix/sysv/linux/ia64/timer_settime.c new file mode 100644 index 0000000..37baeff --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/ia64/timer_settime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_settime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h b/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h new file mode 100644 index 0000000..6e7e029 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h @@ -0,0 +1,62 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + + +/* Nonzero if the system calls are not available. */ +extern int __no_posix_timers attribute_hidden; + +/* Helper function to implement SIGEV_THREAD. */ +extern void *__timer_helper_thread (void *arg) attribute_hidden; + + +/* Type of timers in the kernel. */ +typedef int kernel_timer_t; + + +/* Internal representation of timer. */ +struct timer +{ + /* Notification mechanism. */ + int sigev_notify; + + /* Timer ID returned by the kernel. */ + kernel_timer_t ktimerid; + + /* All new elements must be added after ktimerid. And if the thrfunc + element is not the third element anymore the memory allocation in + timer_create needs to be changed. */ + + /* Parameters for the thread to be started for SIGEV_THREAD. */ + void (*thrfunc) (sigval_t); + sigval_t sival; + pthread_attr_t attr; + + /* Id of the helper thread. */ + pthread_t th; + + /* Barrier used for synchronization. */ + pthread_barrier_t bar; +}; + +/* This is the signal the kernel will send to the helper thread. */ +#define TIMER_SIG 40 /* some RT signal */ diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions new file mode 100644 index 0000000..3b111dd --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions @@ -0,0 +1,7 @@ +librt { + GLIBC_2.3.3 { + # Changed timer_t. + timer_create; timer_delete; timer_getoverrun; timer_gettime; + timer_settime; + } +} diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c new file mode 100644 index 0000000..172223a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c @@ -0,0 +1 @@ +#include "../x86_64/timer_create.c" diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c new file mode 100644 index 0000000..537516e --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c @@ -0,0 +1 @@ +#include "../x86_64/timer_delete.c" diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c new file mode 100644 index 0000000..3f21a73 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c @@ -0,0 +1 @@ +#include "../x86_64/timer_getoverr.c" diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c new file mode 100644 index 0000000..a50143a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_gettime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c new file mode 100644 index 0000000..37baeff --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_settime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c index a35a3f0..8da195a 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c @@ -37,7 +37,7 @@ __pthread_kill (threadid, signo) return ESRCH; /* Disallow sending the signal we use for cancellation. */ - if (signo == SIGCANCEL) + if (signo == SIGCANCEL || signo == SIGTIMER) return EINVAL; /* We have a special syscall to do the work. */ diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/Versions b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/Versions new file mode 100644 index 0000000..3b111dd --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/Versions @@ -0,0 +1,7 @@ +librt { + GLIBC_2.3.3 { + # Changed timer_t. + timer_create; timer_delete; timer_getoverrun; timer_gettime; + timer_settime; + } +} diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c new file mode 100644 index 0000000..172223a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c @@ -0,0 +1 @@ +#include "../x86_64/timer_create.c" diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c new file mode 100644 index 0000000..537516e --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c @@ -0,0 +1 @@ +#include "../x86_64/timer_delete.c" diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c new file mode 100644 index 0000000..3f21a73 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c @@ -0,0 +1 @@ +#include "../x86_64/timer_getoverr.c" diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c new file mode 100644 index 0000000..a50143a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_gettime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c new file mode 100644 index 0000000..37baeff --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c @@ -0,0 +1 @@ +#include "../x86_64/timer_settime.c" diff --git a/nptl/sysdeps/unix/sysv/linux/timer_create.c b/nptl/sysdeps/unix/sysv/linux/timer_create.c new file mode 100644 index 0000000..637d925 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_create.c @@ -0,0 +1,235 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_create +# ifndef __ASSUME_POSIX_TIMERS +# define timer_create static compat_timer_create +# include +# 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 +timer_create (clock_id, evp, timerid) + clockid_t clock_id; + struct sigevent *evp; + timer_t *timerid; +{ +# undef timer_create +# ifndef __ASSUME_POSIX_TIMERS + if (__no_posix_timers >= 0) +# endif + { + /* If the user wants notification via a thread we need to handle + this special. */ + if (evp == NULL + || __builtin_expect (evp->sigev_notify != SIGEV_THREAD, 1)) + { + kernel_timer_t ktimerid; + int retval = INLINE_SYSCALL (timer_create, 3, clock_id, evp, + &ktimerid); + +# ifndef __ASSUME_POSIX_TIMERS + if (retval != -1 || errno != ENOSYS) +# endif + { +# ifndef __ASSUME_POSIX_TIMERS + __no_posix_timers = 1; +#endif + + if (retval != -1) + { + struct timer *newp; + + /* We avoid allocating too much memory by basically + using struct timer as a derived class with the + first two elements being in the superclass. We only + need these two elements here. */ + newp = (struct timer *) malloc (offsetof (struct timer, + thrfunc)); + if (newp != NULL) + { + newp->sigev_notify = (evp != NULL + ? evp->sigev_notify + : SIGEV_SIGNAL); + newp->ktimerid = ktimerid; + + *timerid = (timer_t) newp; + } + else + { + /* No memory. Free the kernel timer. */ + INTERNAL_SYSCALL_DECL (err); + (void) INTERNAL_SYSCALL (timer_delete, err, 1, ktimerid); + + retval = -1; + } + } + + return retval; + } + } + 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 = INTERNAL_SYSCALL (clock_getres, err, 1, &ts); + __no_posix_timers = (INTERNAL_SYSCALL_ERROR_P (res, err) + ? -1 : 1); + } + + if (__no_posix_timers > 0) +#endif + { + sigset_t ss; + sigemptyset (&ss); + sigaddset (&ss, TIMER_SIG); + pthread_sigmask (SIG_BLOCK, &ss, NULL); + struct timer *newp; + + newp = (struct timer *) malloc (sizeof (struct timer)); + if (newp == NULL) + return -1; + + /* Copy the thread parameters the user provided. */ + newp->sival = evp->sigev_value; + newp->thrfunc = evp->sigev_notify_function; + + /* 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); + + /* Set up the barrier for sychronization. */ + (void) pthread_barrier_init (&newp->bar, NULL, 2); + + /* The helper thread needs only very little resources + and should go away automatically when canceled. */ + pthread_attr_t attr; + (void) pthread_attr_init (&attr); + (void) pthread_attr_setdetachstate (&attr, + PTHREAD_CREATE_DETACHED); + (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); + + /* Create the helper thread for this timer. */ + int res = pthread_create (&newp->th, &attr, + __timer_helper_thread, newp); + if (res != 0) + goto err_out; + + /* No need for the attribute anymore. */ + (void) pthread_attr_destroy (&attr); + + /* Create the event structure for the kernel timer. */ + struct sigevent sev; + sev.sigev_value.sival_ptr = newp; + sev.sigev_signo = TIMER_SIG; + sev.sigev_notify = SIGEV_SIGNAL | SIGEV_THREAD_ID; + /* This is the thread ID of the helper thread. */ + sev._sigev_un._pad[0] = ((struct pthread *) newp->th)->tid; + + /* Wait until the helper thread is set up. */ + (void) pthread_barrier_wait (&newp->bar); + + /* No need for the barrier anymore. */ + (void) pthread_barrier_destroy (&newp->bar); + + /* Create the timer. */ + INTERNAL_SYSCALL_DECL (err); + res = INTERNAL_SYSCALL (timer_create, err, 3, clock_id, &sev, + &newp->ktimerid); + if (! INTERNAL_SYSCALL_ERROR_P (res, err)) + { + *timerid = (timer_t) newp; + return 0; + } + + /* Something went wrong. Kill the thread. */ + pthread_cancel (newp->th); + /* Free the resources. */ + res = INTERNAL_SYSCALL_ERRNO (res, err); + err_out: + free (newp); + __set_errno (res); + return -1; + } + } + +# ifndef __ASSUME_POSIX_TIMERS + /* When we come here the syscall does not exist. Make sure we + do not try to use it again. */ + __no_posix_timers = -1; +# endif + } + +# 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 +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/timer_delete.c b/nptl/sysdeps/unix/sysv/linux/timer_delete.c new file mode 100644 index 0000000..cf63364 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_delete.c @@ -0,0 +1,94 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_delete +# ifndef __ASSUME_POSIX_TIMERS +# define timer_delete static compat_timer_delete +# include +# undef timer_delete +# endif + +# ifdef timer_delete_alias +# define timer_delete timer_delete_alias +# endif + + +int +timer_delete (timerid) + timer_t timerid; +{ +# undef timer_delete +# ifndef __ASSUME_POSIX_TIMERS + if (__no_posix_timers >= 0) +# endif + { + struct timer *kt = (struct timer *) timerid; + + /* Delete the kernel timer object. */ + int res = INLINE_SYSCALL (timer_delete, 1, kt->ktimerid); + + if (res == 0) + { +# ifndef __ASSUME_POSIX_TIMERS + /* We know the syscall support is available. */ + __no_posix_timers = 1; +# endif + + /* We have to get rid of the helper thread if we created one. */ + if (kt->sigev_notify == SIGEV_THREAD) + (void) pthread_cancel (kt->th); + + /* Free the memory. */ + (void) free (kt); + + return 0; + } + + /* The kernel timer is not known or something else bad happened. + Return the error. */ +# ifndef __ASSUME_POSIX_TIMERS + if (errno != ENOSYS) +# endif + return -1; + +# ifndef __ASSUME_POSIX_TIMERS + __no_posix_timers = -1; +# endif + } + +# ifndef __ASSUME_POSIX_TIMERS + return compat_timer_delete (timerid); +# endif +} +#else +# ifdef timer_delete_alias +# define timer_delete timer_delete_alias +# endif +/* The new system calls are not available. Use the userlevel + implementation. */ +# include +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c b/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c new file mode 100644 index 0000000..40b485f --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c @@ -0,0 +1,80 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_getoverrun +# ifndef __ASSUME_POSIX_TIMERS +# define timer_getoverrun static compat_timer_getoverrun +# include +# undef timer_getoverrun +# endif + +# ifdef timer_getoverrun_alias +# define timer_getoverrun timer_getoverrun_alias +# endif + + +int +timer_getoverrun (timerid) + timer_t timerid; +{ +# undef timer_getoverrun +# ifndef __ASSUME_POSIX_TIMERS + if (__no_posix_timers == 0) +# endif + { + struct timer *kt = (struct timer *) timerid; + + /* Get the information from the kernel. */ + int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid); + +# ifndef __ASSUME_POSIX_TIMERS + 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 +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/timer_gettime.c b/nptl/sysdeps/unix/sysv/linux/timer_gettime.c new file mode 100644 index 0000000..6da1571 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_gettime.c @@ -0,0 +1,82 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_gettime +# ifndef __ASSUME_POSIX_TIMERS +# define timer_gettime static compat_timer_gettime +# include +# undef timer_gettime +# endif + +# ifdef timer_gettime_alias +# define timer_gettime timer_gettime_alias +# endif + + +int +timer_gettime (timerid, value) + timer_t timerid; + struct itimerspec *value; +{ +# undef timer_gettime +# ifndef __ASSUME_POSIX_TIMERS + if (__no_posix_timers == 0) +# endif + { + struct timer *kt = (struct timer *) timerid; + + /* Delete the kernel timer object. */ + int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value); + +# ifndef __ASSUME_POSIX_TIMERS + 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 +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/nptl/sysdeps/unix/sysv/linux/timer_routines.c new file mode 100644 index 0000000..3f69aa6 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_routines.c @@ -0,0 +1,81 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_create +/* Helper thread to call the user-provided function. */ +static void * +timer_sigev_thread (void *arg) +{ + struct timer *tk = (struct timer *) arg; + + /* Call the user-provided function. */ + tk->thrfunc (tk->sival); + + return NULL; +} + + +/* Helper function to support starting threads for SIGEV_THREAD. */ +void * +attribute_hidden +__timer_helper_thread (void *arg) +{ + /* Block all signals. */ + sigset_t ss; + + sigfillset (&ss); + (void) pthread_sigmask (SIG_BLOCK, &ss, NULL); + + struct timer *tk = (struct timer *) arg; + + /* Synchronize with the parent. */ + (void) pthread_barrier_wait (&tk->bar); + + /* We will only wait for the signal the kernel will send. */ + sigemptyset (&ss); + sigaddset (&ss, TIMER_SIG); + + /* Endless loop of waiting for signals. The loop is only ended when + the thread is canceled. */ + while (1) + { + siginfo_t si; + + if (sigwaitinfo (&ss, &si) > 0 && si.si_timerid == tk->ktimerid) + { + /* That the signal we are waiting for. */ + pthread_t th; + (void) pthread_create (&th, &tk->attr, timer_sigev_thread, arg); + } + } +} + +#endif + +#ifndef __ASSUME_POSIX_TIMERS +# include +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/timer_settime.c b/nptl/sysdeps/unix/sysv/linux/timer_settime.c new file mode 100644 index 0000000..7fc837c --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/timer_settime.c @@ -0,0 +1,85 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include +#include +#include "kernel-posix-timers.h" + + +#ifdef __NR_timer_settime +# ifndef __ASSUME_POSIX_TIMERS +# define timer_settime static compat_timer_settime +# include +# undef timer_settime +# endif + +# ifdef timer_settime_alias +# define timer_settime timer_settime_alias +# endif + + +int +timer_settime (timerid, flags, value, ovalue) + timer_t timerid; + int flags; + const struct itimerspec *value; + struct itimerspec *ovalue; +{ +# undef timer_settime +# ifndef __ASSUME_POSIX_TIMERS + if (__no_posix_timers == 0) +# endif + { + struct timer *kt = (struct timer *) timerid; + + /* Delete the kernel timer object. */ + int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags, + value, ovalue); + +# ifndef __ASSUME_POSIX_TIMERS + 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 +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/Versions b/nptl/sysdeps/unix/sysv/linux/x86_64/Versions new file mode 100644 index 0000000..3b111dd --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/Versions @@ -0,0 +1,7 @@ +librt { + GLIBC_2.3.3 { + # Changed timer_t. + timer_create; timer_delete; timer_getoverrun; timer_gettime; + timer_settime; + } +} diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h b/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h new file mode 100644 index 0000000..02485da --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#define OLD_TIMER_MAX 256 + +extern timer_t __compat_timer_list[OLD_TIMER_MAX] attribute_hidden; + + +extern int __timer_create_new (clockid_t clock_id, struct sigevent *evp, + timer_t *timerid); +extern int __timer_delete_new (timer_t timerid); +extern int __timer_getoverrun_new (timer_t timerid); +extern int __timer_gettime_new (timer_t timerid, struct itimerspec *value); +extern int __timer_settime_new (timer_t timerid, int flags, + const struct itimerspec *value, + struct itimerspec *ovalue); + + +extern int __timer_create_old (clockid_t clock_id, struct sigevent *evp, + int *timerid); +extern int __timer_delete_old (int timerid); +extern int __timer_getoverrun_old (int timerid); +extern int __timer_gettime_old (int timerid, struct itimerspec *value); +extern int __timer_settime_old (int timerid, int flags, + const struct itimerspec *value, + struct itimerspec *ovalue); diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c new file mode 100644 index 0000000..1849f72 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c @@ -0,0 +1,66 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include "compat-timer.h" +#include + + +#define timer_create_alias __timer_create_new +#include "../timer_create.c" + +#undef timer_create +versioned_symbol (librt, __timer_create_new, timer_create, GLIBC_2_3_3); + + +#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +timer_t __compat_timer_list[OLD_TIMER_MAX] attribute_hidden; + + +int +__timer_create_old (clockid_t clock_id, struct sigevent *evp, int *timerid) +{ + timer_t newp; + + int res = __timer_create_new (clock_id, evp, &newp); + if (res == 0) + { + int i; + for (i = 0; i < OLD_TIMER_MAX; ++i) + if (__compat_timer_list[i] == NULL + && ! atomic_compare_and_exchange_bool_acq (&__compat_timer_list[i], + newp, NULL)) + { + *timerid = i; + break; + } + + if (__builtin_expect (i == OLD_TIMER_MAX, 0)) + { + /* No free slot. */ + (void) __timer_delete_new (newp); + __set_errno (EINVAL); + res = -1; + } + } + + return res; +} +compat_symbol (librt, __timer_create_old, timer_create, GLIBC_2_2); +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_delete.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_delete.c new file mode 100644 index 0000000..6e0d9d0 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_delete.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include "compat-timer.h" + + +#define timer_delete_alias __timer_delete_new +#include "../timer_delete.c" + +#undef timer_delete +versioned_symbol (librt, __timer_delete_new, timer_delete, GLIBC_2_3_3); + + +#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +int +__timer_delete_old (int timerid) +{ + int res = __timer_delete_new (__compat_timer_list[timerid]); + + if (res == 0) + /* Successful timer deletion, now free the index. We only need to + store a word and that better be atomic. */ + __compat_timer_list[timerid] = NULL; + + return res; +} +compat_symbol (librt, __timer_delete_old, timer_delete, GLIBC_2_2); +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c new file mode 100644 index 0000000..d75636c --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include "compat-timer.h" + + +#define timer_getoverrun_alias __timer_getoverrun_new +#include "../timer_getoverr.c" + +#undef timer_getoverrun +versioned_symbol (librt, __timer_getoverrun_new, timer_getoverrun, + GLIBC_2_3_3); + + +#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +int +__timer_getoverrun_old (int timerid) +{ + return __timer_getoverrun_new (__compat_timer_list[timerid]); +} +compat_symbol (librt, __timer_getoverrun_old, timer_getoverrun, GLIBC_2_2); +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_gettime.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_gettime.c new file mode 100644 index 0000000..1f1253a --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_gettime.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include "compat-timer.h" + + +#define timer_gettime_alias __timer_gettime_new +#include "../timer_gettime.c" + +#undef timer_gettime +versioned_symbol (librt, __timer_gettime_new, timer_gettime, GLIBC_2_3_3); + + +#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +int +__timer_gettime_old (int timerid, struct itimerspec *value) +{ + return __timer_gettime_new (__compat_timer_list[timerid], value); +} +compat_symbol (librt, __timer_gettime_old, timer_gettime, GLIBC_2_2); +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_settime.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_settime.c new file mode 100644 index 0000000..4c945ec --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_settime.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include "compat-timer.h" + + +#define timer_settime_alias __timer_settime_new +#include "../timer_settime.c" + +#undef timer_settime +versioned_symbol (librt, __timer_settime_new, timer_settime, GLIBC_2_3_3); + + +#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) +int +__timer_settime_old (int timerid, int flags, const struct itimerspec *value, + struct itimerspec *ovalue) +{ + return __timer_settime_new (__compat_timer_list[timerid], flags, + value, ovalue); +} +compat_symbol (librt, __timer_settime_old, timer_settime, GLIBC_2_2); +#endif diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h index 8fe6100..90a67f1 100644 --- a/nptl/sysdeps/x86_64/pthreaddef.h +++ b/nptl/sysdeps/x86_64/pthreaddef.h @@ -30,9 +30,6 @@ /* Alignment requirement for TCB. */ #define TCB_ALIGNMENT 16 -/* The signal used for asynchronous cancelation. */ -#define SIGCANCEL __SIGRTMIN - /* Location of current stack frame. The frame pointer is not usable. */ #define CURRENT_STACK_FRAME \ -- cgit v1.1