summaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2007-11-20 16:23:24 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-07 23:05:35 +0200
commite16179334211cd7e2877197140b06b83e2f03733 (patch)
tree25ffab176418a96477e2e95cfc5540f839bfec22 /sysdeps/generic
parent426e7e7edf67380ec5afc9791a9541b0f8e2c452 (diff)
parent0697fd051821d7b44b3c9ab2face57438e1a764a (diff)
2007-11-20 Neal H. Walfield <neal@gnu.org>
Merge changes from mainline Hurd. Update L4 bits to compile with those changes. * sysdeps/l4/pt-block.c (__pthread_block): Call l4_receive, not L4_Receive. * sysdeps/l4/pt-create-np.c (pthread_create_from_l4_tid_np): Don't pass TID to __pthread_create_internal. Emit a warning. * sysdeps/l4/pt-stack-alloc.c (allocate_page): Remove function. (__pthread_stack_alloc): Don't require that STACKSIZE is equal to __pthread_stacksize. Call mmap. * sysdeps/l4/pt-thread-halt.c (__pthread_thread_halt): Take additional argument, need_dealloc. Call __pthread_dealloc. Stop the thread. * sysdeps/l4/hurd/pt-sysdep.c (init_routine): When calling __pthread_create_internal, don't pass the tid. * tests/test-1.c (main): Use pthread_mutex_init, not PTHREAD_MUTEX_INITIALIZER. * pthread/pt-alloc.c: Don't include <bits/atomic.h>. Include <atomic.h>. (__pthread_free_threads): Make it an atomicptr_t, not an __atomicptr_t. (__pthread_alloc): Don't use __atomicptr_compare_and_swap, use atomic_compare_and_exchange_val_acq. * pthread/pt-create.c: Don't include <bits/atomic.h>. Include <atomic.h>. (__pthread_total): Make it an atomic_fast32_t, not an __atomic_t. (__pthread_create_internal): Use atomic_increment and atomic_decrement, not __atomic_inc and __atomic_dec. * pthread/pt-dealloc.c: Don't include <bits/atomic.h>. Include <atomic.h>. (__pthread_free_threads): Make it an atomicptr_t, not an __atomicptr_t. (__pthread_dealloc): Use atomic_compare_and_exchange_val_acq, not __atomicptr_compare_and_swap. * pthread/pt-exit.c: Don't include <bits/atomic.h>. Include <atomic.h>. (pthread_exit): Use atomic_decrement_and_test, not __atomic_dec_and_test. * pthread/pt-internal.h: Don't include <bits/atomic.h>. Include <atomic.h>. (__pthread_total): Make it an atomic_fast32_t, not an __atomic_t. * sysdeps/powerpc/bits/atomic.h: Remove file. * sysdeps/ia32/bits/atomic.h: Likewise.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/bits/condition.h2
-rw-r--r--sysdeps/generic/bits/mutex.h75
-rw-r--r--sysdeps/generic/bits/pthread.h2
-rw-r--r--sysdeps/generic/bits/rwlock.h31
-rw-r--r--sysdeps/generic/bits/semaphore.h43
-rw-r--r--sysdeps/generic/pt-barrier-init.c16
-rw-r--r--sysdeps/generic/pt-cond-init.c17
-rw-r--r--sysdeps/generic/pt-cond-timedwait.c9
-rw-r--r--sysdeps/generic/pt-mutex-destroy.c2
-rw-r--r--sysdeps/generic/pt-mutex-init.c6
-rw-r--r--sysdeps/generic/pt-mutex-lock.c4
-rw-r--r--sysdeps/generic/pt-mutex-timedlock.c19
-rw-r--r--sysdeps/generic/pt-mutex-trylock.c15
-rw-r--r--sysdeps/generic/pt-mutex-unlock.c4
-rw-r--r--sysdeps/generic/pt-rwlock-destroy.c2
-rw-r--r--sysdeps/generic/pt-rwlock-init.c20
-rw-r--r--sysdeps/generic/pt-rwlock-rdlock.c4
-rw-r--r--sysdeps/generic/pt-rwlock-timedrdlock.c19
-rw-r--r--sysdeps/generic/pt-rwlock-timedwrlock.c19
-rw-r--r--sysdeps/generic/pt-setschedparam.c4
-rw-r--r--sysdeps/generic/sem-close.c32
-rw-r--r--sysdeps/generic/sem-destroy.c38
-rw-r--r--sysdeps/generic/sem-getvalue.c33
-rw-r--r--sysdeps/generic/sem-init.c46
-rw-r--r--sysdeps/generic/sem-open.c32
-rw-r--r--sysdeps/generic/sem-post.c62
-rw-r--r--sysdeps/generic/sem-timedwait.c92
-rw-r--r--sysdeps/generic/sem-trywait.c42
-rw-r--r--sysdeps/generic/sem-unlink.c32
-rw-r--r--sysdeps/generic/sem-wait.c32
30 files changed, 593 insertions, 161 deletions
diff --git a/sysdeps/generic/bits/condition.h b/sysdeps/generic/bits/condition.h
index a194b05..f3b09be 100644
--- a/sysdeps/generic/bits/condition.h
+++ b/sysdeps/generic/bits/condition.h
@@ -1,5 +1,5 @@
/* Condition type. Generic version.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h
index ecbcff8..1aaf80e 100644
--- a/sysdeps/generic/bits/mutex.h
+++ b/sysdeps/generic/bits/mutex.h
@@ -1,5 +1,5 @@
/* Mutex type. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,8 +52,7 @@ struct __pthread_mutex
/* Initializer for a mutex. N.B. this also happens to be compatible
with the cthread mutex initializer. */
# define __PTHREAD_MUTEX_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, \
- NULL, 0, 0 }
+ { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
# endif
#endif /* Not __pthread_mutex_defined. */
@@ -63,76 +62,6 @@ struct __pthread_mutex
#include <errno.h>
#include <stddef.h>
-#ifdef __USE_EXTERN_INLINES
-
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
-# endif
-
-_EXTERN_INLINE int
-pthread_mutex_init (struct __pthread_mutex *__mutex,
- const pthread_mutexattr_t *attr)
-{
- extern int _pthread_mutex_init (struct __pthread_mutex *,
- const pthread_mutexattr_t *);
-
- if (attr)
- return _pthread_mutex_init (__mutex, attr);
-
- *__mutex = (struct __pthread_mutex) __PTHREAD_MUTEX_INITIALIZER;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_mutex_destroy (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_destroy (struct __pthread_mutex *);
-
- if (__mutex->attr || __mutex->data)
- return _pthread_mutex_destroy (__mutex);
-
- return 0;
-}
-
-_EXTERN_INLINE int
-__pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_lock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL
- && __pthread_spin_trylock (&__mutex->__held) == 0)
- return 0;
-
- return _pthread_mutex_lock (__mutex);
-}
-
-extern inline int
-__pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_trylock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL)
- return __pthread_spin_trylock (&__mutex->__held);
-
- return _pthread_mutex_trylock (__mutex);
-}
-
-extern inline int
-pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_lock (__mutex);
-}
-
-extern inline int
-pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_trylock (__mutex);
-}
-
-#endif /* Use extern inlines. */
-
#endif
#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/bits/pthread.h b/sysdeps/generic/bits/pthread.h
index 740325d..3f9df13 100644
--- a/sysdeps/generic/bits/pthread.h
+++ b/sysdeps/generic/bits/pthread.h
@@ -24,7 +24,7 @@ typedef int pthread_t;
/* Return true if __T1 and __T2 both name the same thread. Otherwise,
false. */
-extern inline int
+extern __inline int
pthread_equal (pthread_t __t1, pthread_t __t2)
{
return __t1 == __t2;
diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h
index d089b0c..696f9c2 100644
--- a/sysdeps/generic/bits/rwlock.h
+++ b/sysdeps/generic/bits/rwlock.h
@@ -1,5 +1,5 @@
/* rwlock type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,34 +40,7 @@ struct __pthread_rwlock
/* Initializer for a rwlock. */
#define __PTHREAD_RWLOCK_INITIALIZER \
- ((struct __pthread_rwlock) \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 })
+ { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
-_EXTERN_INLINE int
-pthread_rwlock_init (struct __pthread_rwlock *__rwlock,
- const struct __pthread_rwlockattr *__attr)
-{
- extern int _pthread_rwlock_init (struct __pthread_rwlock *,
- const struct __pthread_rwlockattr *);
-
- if (__attr)
- return _pthread_rwlock_init (__rwlock, __attr);
-
- *__rwlock = __PTHREAD_RWLOCK_INITIALIZER;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_rwlock_destroy (struct __pthread_rwlock *__rwlock)
-{
- extern int _pthread_rwlock_destroy (struct __pthread_rwlock *);
-
- if (__rwlock->__attr
- || __rwlock->__data)
- return _pthread_rwlock_destroy (__rwlock);
-
- return 0;
-}
-
#endif /* bits/rwlock.h */
diff --git a/sysdeps/generic/bits/semaphore.h b/sysdeps/generic/bits/semaphore.h
new file mode 100644
index 0000000..b53f47e
--- /dev/null
+++ b/sysdeps/generic/bits/semaphore.h
@@ -0,0 +1,43 @@
+/* Semaphore type. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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. */
+
+#ifndef _BITS_SEMAPHORE_H
+#define _BITS_SEMAPHORE_H 1
+
+#ifndef _SEMAPHORE_H
+#error Never include <bits/semaphore.h> directly.
+#endif
+
+#include <pthread.h>
+
+/* User visible part of a semaphore. */
+struct __semaphore
+ {
+ __pthread_spinlock_t __lock;
+ struct __pthread *__queue;
+ int __pshared;
+ int __value;
+ void *__data;
+ };
+
+/* Initializer for a semaphore. */
+#define __SEMAPHORE_INITIALIZER(pshared, value) \
+ { __SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
+
+#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/pt-barrier-init.c b/sysdeps/generic/pt-barrier-init.c
index 57911d5..c42b3bb 100644
--- a/sysdeps/generic/pt-barrier-init.c
+++ b/sysdeps/generic/pt-barrier-init.c
@@ -1,5 +1,5 @@
/* pthread_barrier_init. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,8 +28,6 @@ pthread_barrier_init (pthread_barrier_t *barrier,
const pthread_barrierattr_t *attr,
unsigned count)
{
- assert (attr->pshared == PTHREAD_PROCESS_PRIVATE);
-
if (count == 0)
return EINVAL;
@@ -39,5 +37,17 @@ pthread_barrier_init (pthread_barrier_t *barrier,
barrier->pending = count;
barrier->count = count;
+ if (! attr
+ || memcmp (attr, &__pthread_default_barrierattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ barrier->attr = malloc (sizeof *attr);
+ if (! barrier->attr)
+ return ENOMEM;
+
+ *barrier->attr = *attr;
return 0;
}
diff --git a/sysdeps/generic/pt-cond-init.c b/sysdeps/generic/pt-cond-init.c
index a01a94b..b9e9fb7 100644
--- a/sysdeps/generic/pt-cond-init.c
+++ b/sysdeps/generic/pt-cond-init.c
@@ -19,6 +19,7 @@
#include <pthread.h>
#include <assert.h>
+#include <string.h>
#include <pt-internal.h>
@@ -26,9 +27,19 @@ int
pthread_cond_init (pthread_cond_t *cond,
const pthread_condattr_t *attr)
{
- if (attr)
- assert (attr->pshared == PTHREAD_PROCESS_PRIVATE);
+ *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER;
- *cond = (struct __pthread_cond) __PTHREAD_COND_INITIALIZER;
+ if (! attr
+ || memcmp (attr, &__pthread_default_condattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ cond->__attr = malloc (sizeof *attr);
+ if (! cond->__attr)
+ return ENOMEM;
+
+ *cond->__attr = *attr;
return 0;
}
diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c
index 4abeb71..c10bdb3 100644
--- a/sysdeps/generic/pt-cond-timedwait.c
+++ b/sysdeps/generic/pt-cond-timedwait.c
@@ -1,5 +1,5 @@
/* Wait on a condition. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -58,6 +58,9 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
__pthread_mutex_lock (mutex);
}
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
struct __pthread *self = _pthread_self ();
/* Add ourselves to the list of waiters. */
@@ -74,8 +77,6 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
if (abstime)
{
- error_t err;
-
err = __pthread_timedblock (self, abstime);
if (err)
/* We timed out. We may need to disconnect ourself from the
@@ -91,8 +92,6 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
if (self->prevp)
__pthread_dequeue (self);
__pthread_spin_unlock (&mutex->__lock);
-
- return err;
}
}
else
diff --git a/sysdeps/generic/pt-mutex-destroy.c b/sysdeps/generic/pt-mutex-destroy.c
index d9fb59c..72faefe 100644
--- a/sysdeps/generic/pt-mutex-destroy.c
+++ b/sysdeps/generic/pt-mutex-destroy.c
@@ -32,4 +32,4 @@ _pthread_mutex_destroy (pthread_mutex_t *mutex)
return 0;
}
-weak_alias (_pthread_mutex_destroy, pthread_mutex_destroy);
+strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy);
diff --git a/sysdeps/generic/pt-mutex-init.c b/sysdeps/generic/pt-mutex-init.c
index 100f485..da1781b 100644
--- a/sysdeps/generic/pt-mutex-init.c
+++ b/sysdeps/generic/pt-mutex-init.c
@@ -1,5 +1,5 @@
/* Initialize a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@ int
_pthread_mutex_init (pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr)
{
- *mutex = (struct __pthread_mutex) __PTHREAD_MUTEX_INITIALIZER;
+ *mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER;
if (! attr
|| memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr) == 0))
@@ -45,4 +45,4 @@ _pthread_mutex_init (pthread_mutex_t *mutex,
return 0;
}
-weak_alias (_pthread_mutex_init, pthread_mutex_init);
+strong_alias (_pthread_mutex_init, pthread_mutex_init);
diff --git a/sysdeps/generic/pt-mutex-lock.c b/sysdeps/generic/pt-mutex-lock.c
index 58d3827..60fc55a 100644
--- a/sysdeps/generic/pt-mutex-lock.c
+++ b/sysdeps/generic/pt-mutex-lock.c
@@ -33,5 +33,5 @@ __pthread_mutex_lock (struct __pthread_mutex *mutex)
return __pthread_mutex_timedlock_internal (mutex, 0);
}
-weak_alias (__pthread_mutex_lock, _pthread_mutex_lock);
-weak_alias (__pthread_mutex_lock, pthread_mutex_lock);
+strong_alias (__pthread_mutex_lock, _pthread_mutex_lock);
+strong_alias (__pthread_mutex_lock, pthread_mutex_lock);
diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c
index 3603986..5e222bd 100644
--- a/sysdeps/generic/pt-mutex-timedlock.c
+++ b/sysdeps/generic/pt-mutex-timedlock.c
@@ -1,5 +1,5 @@
/* Lock a mutex with a timeout. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,13 +24,6 @@
#define LOSE do { * (int *) 0 = 0; } while (1)
-int
-pthread_mutex_timedlock (struct __pthread_mutex *mutex,
- const struct timespec *abstime)
-{
- return __pthread_mutex_timedlock_internal (mutex, abstime);
-}
-
/* Try to lock MUTEX, block until *ABSTIME if it is already held. As
a GNU extension, if TIMESPEC is NULL then wait forever. */
int
@@ -96,6 +89,9 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
}
}
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
/* Add ourselves to the queue. */
__pthread_enqueue (&mutex->__queue, self);
__pthread_spin_unlock (&mutex->__lock);
@@ -146,3 +142,10 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
return 0;
}
+
+int
+pthread_mutex_timedlock (struct __pthread_mutex *mutex,
+ const struct timespec *abstime)
+{
+ return __pthread_mutex_timedlock_internal (mutex, abstime);
+}
diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c
index b3c3fe3..d56f6e1 100644
--- a/sysdeps/generic/pt-mutex-trylock.c
+++ b/sysdeps/generic/pt-mutex-trylock.c
@@ -1,5 +1,5 @@
/* Try to Lock a mutex. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
#define LOSE do { * (int *) 0 = 0; } while (1)
-/* Lock MUTEX, block if we can't get it. */
+/* Lock MUTEX, return EBUSY if we can't get it. */
int
__pthread_mutex_trylock (struct __pthread_mutex *mutex)
{
@@ -65,8 +65,9 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
break;
case PTHREAD_MUTEX_ERRORCHECK:
- if (mutex->owner == self)
- err = EDEADLK;
+ /* We could check if MUTEX->OWNER is SELF, however, POSIX
+ does not permit pthread_mutex_trylock to return EDEADLK
+ instead of EBUSY, only pthread_mutex_lock. */
break;
case PTHREAD_MUTEX_RECURSIVE:
@@ -82,8 +83,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
}
}
+ __pthread_spin_unlock (&mutex->__lock);
+
return err;
}
-weak_alias (__pthread_mutex_trylock, _pthread_mutex_trylock);
-weak_alias (__pthread_mutex_trylock, pthread_mutex_trylock);
+strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock);
+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock);
diff --git a/sysdeps/generic/pt-mutex-unlock.c b/sysdeps/generic/pt-mutex-unlock.c
index bbbe2b8..2f719d3 100644
--- a/sysdeps/generic/pt-mutex-unlock.c
+++ b/sysdeps/generic/pt-mutex-unlock.c
@@ -78,5 +78,5 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
return 0;
}
-weak_alias (__pthread_mutex_unlock, _pthread_mutex_unlock);
-weak_alias (__pthread_mutex_unlock, pthread_mutex_unlock);
+strong_alias (__pthread_mutex_unlock, _pthread_mutex_unlock);
+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock);
diff --git a/sysdeps/generic/pt-rwlock-destroy.c b/sysdeps/generic/pt-rwlock-destroy.c
index f63c84d..034d930 100644
--- a/sysdeps/generic/pt-rwlock-destroy.c
+++ b/sysdeps/generic/pt-rwlock-destroy.c
@@ -26,4 +26,4 @@ _pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
return 0;
}
-weak_alias (_pthread_rwlock_destroy, pthread_rwlock_destroy);
+strong_alias (_pthread_rwlock_destroy, pthread_rwlock_destroy);
diff --git a/sysdeps/generic/pt-rwlock-init.c b/sysdeps/generic/pt-rwlock-init.c
index 8fe8764..8aa495e 100644
--- a/sysdeps/generic/pt-rwlock-init.c
+++ b/sysdeps/generic/pt-rwlock-init.c
@@ -1,5 +1,5 @@
/* Initialize a rwlock. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,14 +18,28 @@
Boston, MA 02111-1307, USA. */
#include <pthread.h>
+#include <string.h>
#include <pt-internal.h>
int
_pthread_rwlock_init (pthread_rwlock_t *rwlock,
const pthread_rwlockattr_t *attr)
{
- *rwlock = __PTHREAD_RWLOCK_INITIALIZER;
+ *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ rwlock->__attr = malloc (sizeof *attr);
+ if (! rwlock->__attr)
+ return ENOMEM;
+
+ *rwlock->__attr = *attr;
return 0;
}
-weak_alias (_pthread_rwlock_init, pthread_rwlock_init);
+strong_alias (_pthread_rwlock_init, pthread_rwlock_init);
diff --git a/sysdeps/generic/pt-rwlock-rdlock.c b/sysdeps/generic/pt-rwlock-rdlock.c
index d060c38..480cf48 100644
--- a/sysdeps/generic/pt-rwlock-rdlock.c
+++ b/sysdeps/generic/pt-rwlock-rdlock.c
@@ -1,5 +1,5 @@
/* Acquire a rwlock for reading. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
#include <pt-internal.h>
/* Implemented in pt-rwlock-timedrdlock.c. */
-extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *mutex,
+extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock,
const struct timespec *abstime);
/* Acquire RWLOCK for reading, block if we can't get it. */
diff --git a/sysdeps/generic/pt-rwlock-timedrdlock.c b/sysdeps/generic/pt-rwlock-timedrdlock.c
index 85cb946..ba610fa 100644
--- a/sysdeps/generic/pt-rwlock-timedrdlock.c
+++ b/sysdeps/generic/pt-rwlock-timedrdlock.c
@@ -1,5 +1,5 @@
/* Acquire a rwlock for reading. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,13 +22,6 @@
#include <pt-internal.h>
-int
-pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock,
- const struct timespec *abstime)
-{
- return __pthread_rwlock_timedrdlock_internal (rwlock, abstime);
-}
-
/* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if
it is already held. As a GNU extension, if TIMESPEC is NULL then
wait forever. */
@@ -66,6 +59,9 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock,
/* Better be blocked by a writer. */
assert (rwlock->readers == 0);
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
self = _pthread_self ();
/* Add ourself to the queue. */
@@ -108,3 +104,10 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock,
return 0;
}
+
+int
+pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedrdlock_internal (rwlock, abstime);
+}
diff --git a/sysdeps/generic/pt-rwlock-timedwrlock.c b/sysdeps/generic/pt-rwlock-timedwrlock.c
index edf6413..04eab51 100644
--- a/sysdeps/generic/pt-rwlock-timedwrlock.c
+++ b/sysdeps/generic/pt-rwlock-timedwrlock.c
@@ -1,5 +1,5 @@
/* Acquire a rwlock for writing. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,13 +22,6 @@
#include <pt-internal.h>
-int
-pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
- const struct timespec *abstime)
-{
- return __pthread_rwlock_timedwrlock_internal (rwlock, abstime);
-}
-
/* Acquire RWLOCK for writing blocking until *ABSTIME if we cannot get
it. As a special GNU extension, if ABSTIME is NULL then the wait
shall not time out. */
@@ -52,6 +45,9 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
/* The lock is busy. */
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
self = _pthread_self ();
/* Add ourselves to the queue. */
@@ -90,3 +86,10 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
return 0;
}
+
+int
+pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedwrlock_internal (rwlock, abstime);
+}
diff --git a/sysdeps/generic/pt-setschedparam.c b/sysdeps/generic/pt-setschedparam.c
index 6b624a3..a70b079 100644
--- a/sysdeps/generic/pt-setschedparam.c
+++ b/sysdeps/generic/pt-setschedparam.c
@@ -1,5 +1,5 @@
/* Set the scheduling parameters for a thread. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
#include <pt-internal.h>
int
-pthread_setschedparam (pthread_t thread, int *policy,
+pthread_setschedparam (pthread_t thread, int policy,
const struct sched_param *param)
{
return ENOSYS;
diff --git a/sysdeps/generic/sem-close.c b/sysdeps/generic/sem-close.c
new file mode 100644
index 0000000..9f48032
--- /dev/null
+++ b/sysdeps/generic/sem-close.c
@@ -0,0 +1,32 @@
+/* Close a named semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_close (sem_t *sem)
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+strong_alias (__sem_close, sem_close);
diff --git a/sysdeps/generic/sem-destroy.c b/sysdeps/generic/sem-destroy.c
new file mode 100644
index 0000000..985f4ad
--- /dev/null
+++ b/sysdeps/generic/sem-destroy.c
@@ -0,0 +1,38 @@
+/* Destroy a semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_destroy (sem_t *sem)
+{
+ if (sem->__queue)
+ /* There are threads waiting on *SEM. */
+ {
+ errno = EBUSY;
+ return -1;
+ }
+
+ return 0;
+}
+
+strong_alias (__sem_destroy, sem_destroy);
diff --git a/sysdeps/generic/sem-getvalue.c b/sysdeps/generic/sem-getvalue.c
new file mode 100644
index 0000000..8e418e3
--- /dev/null
+++ b/sysdeps/generic/sem-getvalue.c
@@ -0,0 +1,33 @@
+/* Get the value of a semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <pt-internal.h>
+
+int
+__sem_getvalue (sem_t *restrict sem, int *restrict value)
+{
+ __pthread_spin_lock (&sem->__lock);
+ *value = sem->__value;
+ __pthread_spin_unlock (&sem->__lock);
+
+ return 0;
+}
+
+strong_alias (__sem_getvalue, sem_getvalue);
diff --git a/sysdeps/generic/sem-init.c b/sysdeps/generic/sem-init.c
new file mode 100644
index 0000000..6c6d79e
--- /dev/null
+++ b/sysdeps/generic/sem-init.c
@@ -0,0 +1,46 @@
+/* Initialize a semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_init (sem_t *sem, int pshared, unsigned value)
+{
+ if (pshared != 0)
+ {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+#ifdef SEM_VALUE_MAX
+ if (value > SEM_VALUE_MAX)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+#endif
+
+ *sem = (sem_t) __SEMAPHORE_INITIALIZER (pshared, value);
+ return 0;
+}
+
+strong_alias (__sem_init, sem_init);
diff --git a/sysdeps/generic/sem-open.c b/sysdeps/generic/sem-open.c
new file mode 100644
index 0000000..9eb13aa
--- /dev/null
+++ b/sysdeps/generic/sem-open.c
@@ -0,0 +1,32 @@
+/* Open a named semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+sem_t *
+__sem_open (const char *name, int open_flags, ...)
+{
+ errno = EOPNOTSUPP;
+ return SEM_FAILED;
+}
+
+strong_alias (__sem_open, sem_open);
diff --git a/sysdeps/generic/sem-post.c b/sysdeps/generic/sem-post.c
new file mode 100644
index 0000000..0e20ea7
--- /dev/null
+++ b/sysdeps/generic/sem-post.c
@@ -0,0 +1,62 @@
+/* Post a semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__sem_post (sem_t *sem)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Do a quick up. */
+ {
+ assert (! sem->__queue);
+ sem->__value ++;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ if (! sem->__queue)
+ /* No one waiting. */
+ {
+ sem->__value = 1;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ /* Wake someone up. */
+
+ /* First dequeue someone. */
+ wakeup = sem->__queue;
+ __pthread_dequeue (wakeup);
+
+ /* Then drop the lock and transfer control. */
+ __pthread_spin_unlock (&sem->__lock);
+
+ __pthread_wakeup (wakeup);
+
+ return 0;
+}
+
+strong_alias (__sem_post, sem_post);
diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c
new file mode 100644
index 0000000..d01bfdb
--- /dev/null
+++ b/sysdeps/generic/sem-timedwait.c
@@ -0,0 +1,92 @@
+/* Wait on a semaphore with a timeout. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <error.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__sem_timedwait_internal (sem_t *restrict sem,
+ const struct timespec *restrict timeout)
+{
+ struct __pthread *self;
+
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Successful down. */
+ {
+ sem->__value --;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ if (timeout && (timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Add ourselves to the queue. */
+ self = _pthread_self ();
+
+ __pthread_enqueue (&sem->__queue, self);
+ __pthread_spin_unlock (&sem->__lock);
+
+ /* Block the thread. */
+ if (timeout)
+ {
+ error_t err;
+
+ err = __pthread_timedblock (self, timeout);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&sem->__lock);
+ if (self->prevp)
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&sem->__lock);
+
+ errno = err;
+ return -1;
+ }
+ }
+ else
+ __pthread_block (self);
+
+ return 0;
+}
+
+int
+__sem_timedwait (sem_t *restrict sem,
+ const struct timespec *restrict timeout)
+{
+ return __sem_timedwait_internal (sem, timeout);
+}
+
+strong_alias (__sem_timedwait, sem_timedwait);
diff --git a/sysdeps/generic/sem-trywait.c b/sysdeps/generic/sem-trywait.c
new file mode 100644
index 0000000..199f317
--- /dev/null
+++ b/sysdeps/generic/sem-trywait.c
@@ -0,0 +1,42 @@
+/* Lock a semaphore if it does not require blocking. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_trywait (sem_t *sem)
+{
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Successful down. */
+ {
+ sem->__value --;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+ __pthread_spin_unlock (&sem->__lock);
+
+ errno = EAGAIN;
+ return -1;
+}
+
+strong_alias (__sem_trywait, sem_trywait);
diff --git a/sysdeps/generic/sem-unlink.c b/sysdeps/generic/sem-unlink.c
new file mode 100644
index 0000000..519f4f7
--- /dev/null
+++ b/sysdeps/generic/sem-unlink.c
@@ -0,0 +1,32 @@
+/* Unlink a named semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_unlink (const char *name)
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+strong_alias (__sem_unlink, sem_unlink);
diff --git a/sysdeps/generic/sem-wait.c b/sysdeps/generic/sem-wait.c
new file mode 100644
index 0000000..50752f3
--- /dev/null
+++ b/sysdeps/generic/sem-wait.c
@@ -0,0 +1,32 @@
+/* Wait on a semaphore. Generic version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library 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 <semaphore.h>
+#include <pt-internal.h>
+
+extern int __sem_timedwait_internal (sem_t *restrict sem,
+ const struct timespec *restrict timeout);
+
+int
+__sem_wait (sem_t *sem)
+{
+ return __sem_timedwait_internal (sem, 0);
+}
+
+strong_alias (__sem_wait, sem_wait);