diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-09-05 13:14:33 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-09-05 13:14:33 -0400 |
commit | 109715ee229b0ddff1d0d2585f910bb4fd49a61c (patch) | |
tree | 8b56448c4ab988d1e195be808b54a727d636ae39 /nptl/sysdeps/unix/sysv/linux/sem_wait.c | |
parent | d88ae4184b822a3ec50a06985e14667dfd6afdbe (diff) | |
parent | 15c95c5d1a6c5481258e9b1f36dfe12e15a56570 (diff) | |
download | glibc-109715ee229b0ddff1d0d2585f910bb4fd49a61c.tar.gz |
Merge branch 'master' of ssh://sourceware.org/git/glibc
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/sem_wait.c')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/sem_wait.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/sem_wait.c b/nptl/sysdeps/unix/sysv/linux/sem_wait.c index 20e2b481df..602c38246f 100644 --- a/nptl/sysdeps/unix/sysv/linux/sem_wait.c +++ b/nptl/sysdeps/unix/sysv/linux/sem_wait.c @@ -37,6 +37,20 @@ __sem_wait_cleanup (void *arg) atomic_decrement (&isem->nwaiters); } +/* This is in a seperate function in order to make sure gcc + puts the call site into an exception region, and thus the + cleanups get properly run. */ +static int +__attribute__ ((noinline)) +do_futex_wait (struct new_sem *isem) +{ + int err, oldtype = __pthread_enable_asynccancel (); + + err = lll_futex_wait (&isem->value, 0, isem->private ^ FUTEX_PRIVATE_FLAG); + + __pthread_disable_asynccancel (oldtype); + return err; +} int __new_sem_wait (sem_t *sem) @@ -53,15 +67,7 @@ __new_sem_wait (sem_t *sem) while (1) { - /* Enable asynchronous cancellation. Required by the standard. */ - int oldtype = __pthread_enable_asynccancel (); - - err = lll_futex_wait (&isem->value, 0, - isem->private ^ FUTEX_PRIVATE_FLAG); - - /* Disable asynchronous cancellation. */ - __pthread_disable_asynccancel (oldtype); - + err = do_futex_wait(isem); if (err != 0 && err != -EWOULDBLOCK) { __set_errno (-err); |