diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-03-26 09:41:23 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-03-26 09:41:23 +0000 |
commit | f064e4c5d7267be7d81429255026817b14858255 (patch) | |
tree | 204faab81de31c5788325aa8ec071f5ee145cd39 /nptl | |
parent | bdb6126c2dbe02dddbec6bc827ab91b3a639fda6 (diff) | |
download | glibc-f064e4c5d7267be7d81429255026817b14858255.tar.gz glibc-f064e4c5d7267be7d81429255026817b14858255.tar.xz glibc-f064e4c5d7267be7d81429255026817b14858255.zip |
Update.
2003-03-26 Ulrich Drepper <drepper@redhat.com> * abilist/librt.abilist: Add new timer interfaces for 64-bit archs.
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/ChangeLog | 5 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/timer_create.c | 68 |
2 files changed, 45 insertions, 28 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e912bcaeac..0fd99d580b 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,8 @@ +2003-03-26 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/unix/sysv/linux/timer_create.c (timer_create): If EVP == + NULL provide default definition to syscall. + 2003-03-25 Roland McGrath <roland@redhat.com> * sysdeps/pthread/posix-timer.h (TIMER_MAX): Define if not defined. diff --git a/nptl/sysdeps/unix/sysv/linux/timer_create.c b/nptl/sysdeps/unix/sysv/linux/timer_create.c index 637d925168..9e6b53ef37 100644 --- a/nptl/sysdeps/unix/sysv/linux/timer_create.c +++ b/nptl/sysdeps/unix/sysv/linux/timer_create.c @@ -60,6 +60,30 @@ timer_create (clock_id, evp, timerid) if (evp == NULL || __builtin_expect (evp->sigev_notify != SIGEV_THREAD, 1)) { + struct sigevent local_evp; + + /* 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. */ + struct timer *newp = (struct timer *) malloc (offsetof (struct timer, + thrfunc)); + if (newp == NULL) + /* 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, clock_id, evp, &ktimerid); @@ -70,43 +94,31 @@ timer_create (clock_id, evp, timerid) { # ifndef __ASSUME_POSIX_TIMERS __no_posix_timers = 1; -#endif +# 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; - } + 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; } + + free (newp); } else { -#ifndef __ASSUME_POSIX_TIMERS +# ifndef __ASSUME_POSIX_TIMERS /* Make sure we have the necessary kernel support. */ if (__no_posix_timers == 0) { @@ -118,7 +130,7 @@ timer_create (clock_id, evp, timerid) } if (__no_posix_timers > 0) -#endif +# endif { sigset_t ss; sigemptyset (&ss); |