diff options
Diffstat (limited to 'nptl/sysdeps/unix')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.c | 4 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/sem_timedwait.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/lowlevelmutex.c | 1 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/s390/lowlevelmutex.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/s390/sem_timedwait.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/sem_wait.c | 58 |
8 files changed, 66 insertions, 7 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.c b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.c index 651fb88598..1a1a2e1b23 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.c +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.c @@ -29,7 +29,7 @@ lll_unlock_wake_cb (futex) { int oldval; int val = *futex; - + do oldval = val; while ((val = lll_compare_and_swap (futex, oldval, 0)) != oldval); @@ -55,7 +55,7 @@ ___lll_timedwait_tid (ptid, abstime) { /* Get current time. */ struct timeval tv; - gettimeofday (&tv, NULL); + __gettimeofday (&tv, NULL); /* Determine relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c index 7ab67ca56c..bf6f5f3846 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c @@ -62,7 +62,7 @@ ___lll_mutex_timedlock (futex, abstime, newval) { /* Get the current time. */ struct timeval tv; - gettimeofday (&tv, NULL); + __gettimeofday (&tv, NULL); /* Compute relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/sem_timedwait.c b/nptl/sysdeps/unix/sysv/linux/ia64/sem_timedwait.c index b271217c41..881e6e20f7 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/sem_timedwait.c +++ b/nptl/sysdeps/unix/sysv/linux/ia64/sem_timedwait.c @@ -47,7 +47,7 @@ sem_timedwait (sem, abstime) /* Get the current time. */ struct timeval tv; - (void) gettimeofday(&tv, NULL); + (void) __gettimeofday(&tv, NULL); /* Compute the relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelmutex.c b/nptl/sysdeps/unix/sysv/linux/lowlevelmutex.c new file mode 100644 index 0000000000..7c594e3470 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelmutex.c @@ -0,0 +1 @@ +/* Nothing needed here in fact. */ diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.c b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.c index f98e163ae1..60c39d01b5 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.c +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.c @@ -72,7 +72,7 @@ ___lll_timedwait_tid (ptid, abstime) { /* Get current time. */ struct timeval tv; - gettimeofday (&tv, NULL); + __gettimeofday (&tv, NULL); /* Determine relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevelmutex.c b/nptl/sysdeps/unix/sysv/linux/s390/lowlevelmutex.c index 3f1889bc77..d4d91db5ce 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevelmutex.c +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevelmutex.c @@ -56,7 +56,7 @@ ___lll_mutex_timedlock (futex, abstime, newval) { /* Get the current time. */ struct timeval tv; - gettimeofday (&tv, NULL); + __gettimeofday (&tv, NULL); /* Compute relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/s390/sem_timedwait.c b/nptl/sysdeps/unix/sysv/linux/s390/sem_timedwait.c index d2ef2ceb30..42433dec74 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/sem_timedwait.c +++ b/nptl/sysdeps/unix/sysv/linux/s390/sem_timedwait.c @@ -51,7 +51,7 @@ sem_timedwait (sem, abstime) /* Get the current time. */ struct timeval tv; - (void) gettimeofday (&tv, NULL); + (void) __gettimeofday (&tv, NULL); /* Compute the relative timeout. */ struct timespec rt; diff --git a/nptl/sysdeps/unix/sysv/linux/sem_wait.c b/nptl/sysdeps/unix/sysv/linux/sem_wait.c new file mode 100644 index 0000000000..0e50067cf6 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/sem_wait.c @@ -0,0 +1,58 @@ +/* sem_wait -- wait on a semaphore. Generic futex-using version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Mackerras <paulus@au.ibm.com>, 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; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <sysdep.h> +#include <lowlevellock.h> +#include <internaltypes.h> +#include <semaphore.h> + +#include <shlib-compat.h> + + +int +__new_sem_wait (sem_t *sem) +{ + int *futex = (int *) sem; + int val; + int err; + + do + { + if (*futex > 0) + { + val = __lll_dec_if_positive (futex); + if (val > 0) + return 0; + } + + err = lll_futex_wait (futex, 0); + } + while (err == 0 || err == -EWOULDBLOCK); + + __set_errno (-err); + return -1; +} + +versioned_symbol (libpthread, __new_sem_wait, sem_wait, GLIBC_2_1); +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) +strong_alias (__new_sem_wait, __old_sem_wait) +compat_symbol (libpthread, __old_sem_wait, sem_wait, GLIBC_2_0); +#endif |