aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-09-22 21:30:25 +0000
committerUlrich Drepper <drepper@redhat.com>2003-09-22 21:30:25 +0000
commit39358e8b2bbf78b3ee50027abcd12837473b5f9f (patch)
treec579eb3fe367bd09bf4c07e9dfa6060c1f3bb79c /nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
parentc0df57e1ce270466be342d9998f72633764b22dc (diff)
downloadglibc-39358e8b2bbf78b3ee50027abcd12837473b5f9f.tar
glibc-39358e8b2bbf78b3ee50027abcd12837473b5f9f.tar.gz
glibc-39358e8b2bbf78b3ee50027abcd12837473b5f9f.tar.bz2
glibc-39358e8b2bbf78b3ee50027abcd12837473b5f9f.zip
Update.
2003-09-22 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait): Use lll_futex_timed_wait instead of lll_futex_wait. * sysdeps/unix/sysv/linux/s390/lowlevellock.c: Removed. * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c: Removed. * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c: Removed. * sysdeps/unix/sysv/linux/s390/libc-lowlevelmutex.c: Removed. * sysdeps/unix/sysv/linux/s390/sem_trywait.c: Removed. * sysdeps/unix/sysv/linux/s390/sem_wait.c: Removed. * sysdeps/unix/sysv/linux/s390/sem_post.c: Removed. * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: Removed. * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include atomic.h. Completely revamp the locking macros. No distinction between normal and mutex locking anymore. * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__lll_lock_wait, __lll_lock_timedwait): Fix prototypes. * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_lock_wait, __lll_lock_timedwait): Likewise. (lll_mutex_lock, lll_mutex_cond_lock): Use _val instead of _bool macros, add __builtin_expect. (lll_mutex_timedlock): Likewise. Fix return value. * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/i386/i586/libc-lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/i386/i586/lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/i386/i686/libc-lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/i386/i686/lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/x86_64/libc-lowlevelmutex.S: Removed. * sysdeps/unix/sysv/linux/lowlevelmutex.c: Removed. * sysdeps/unix/sysv/linux/libc-lowlevelmutex.c: Removed.
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h113
1 files changed, 25 insertions, 88 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
index a51826ab84..5751206dd9 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
@@ -23,6 +23,7 @@
#include <time.h>
#include <sys/param.h>
#include <bits/pthreadtypes.h>
+#include <atomic.h>
#define SYS_futex 238
#define FUTEX_WAIT 0
@@ -126,19 +127,14 @@ __lll_mutex_trylock (int *futex)
#define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex))
-extern void ___lll_mutex_lock (int *, int) attribute_hidden;
-
+extern void __lll_lock_wait (int *futex) attribute_hidden;
static inline void
__attribute__ ((always_inline))
__lll_mutex_lock (int *futex)
{
- int oldval;
- int newval;
-
- lll_compare_and_swap (futex, oldval, newval, "lr %2,%1; ahi %2,1");
- if (oldval > 0)
- ___lll_mutex_lock (futex, newval);
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ __lll_lock_wait (futex);
}
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
@@ -146,32 +142,21 @@ static inline void
__attribute__ ((always_inline))
__lll_mutex_cond_lock (int *futex)
{
- int oldval;
- int newval;
-
- lll_compare_and_swap (futex, oldval, newval, "lr %2,%1; ahi %2,2");
- if (oldval > 0)
- ___lll_mutex_lock (futex, newval);
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex);
}
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
-
-extern int ___lll_mutex_timedlock (int *, const struct timespec *, int)
- attribute_hidden;
-
+extern int __lll_timedlock_wait
+ (int *futex, const struct timespec *) attribute_hidden;
static inline int
__attribute__ ((always_inline))
__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
{
- int oldval;
- int newval;
int result = 0;
-
- lll_compare_and_swap (futex, oldval, newval, "lr %2,%1; ahi %2,1");
- if (oldval > 0)
- result = ___lll_mutex_timedlock (futex, abstime, newval);
-
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime);
return result;
}
#define lll_mutex_timedlock(futex, abstime) \
@@ -208,15 +193,19 @@ __lll_mutex_unlock_force (int *futex)
/* We have a separate internal lock implementation which is not tied
- to binary compatibility. */
+ to binary compatibility. We can use the lll_mutex_*. */
/* Type for lock object. */
typedef int lll_lock_t;
/* Initializers for lock. */
-#define LLL_LOCK_INITIALIZER (1)
-#define LLL_LOCK_INITIALIZER_LOCKED (0)
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+#define lll_trylock(futex) lll_mutex_trylock (futex)
+#define lll_lock(futex) lll_mutex_lock (futex)
+#define lll_unlock(futex) lll_mutex_unlock (futex)
+#define lll_islocked(futex) lll_mutex_islocked (futex)
extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
@@ -226,54 +215,6 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
<0 - taken by more users */
-static inline int
-__attribute__ ((always_inline))
-__lll_trylock (int *futex)
-{
- unsigned int old;
-
- __asm __volatile ("cs %0,%3,%1"
- : "=d" (old), "=Q" (*futex)
- : "0" (1), "d" (0), "m" (*futex) : "cc" );
- return old != 1;
-}
-#define lll_trylock(futex) __lll_trylock (&(futex))
-
-
-extern void ___lll_lock (int *, int) attribute_hidden;
-
-static inline void
-__attribute__ ((always_inline))
-__lll_lock (int *futex)
-{
- int oldval;
- int newval;
-
- lll_compare_and_swap (futex, oldval, newval, "lr %2,%1; ahi %2,-1");
- if (newval < 0)
- ___lll_lock (futex, newval);
-}
-#define lll_lock(futex) __lll_lock (&(futex))
-
-
-static inline void
-__attribute__ ((always_inline))
-__lll_unlock (int *futex)
-{
- int oldval;
- int newval;
-
- lll_compare_and_swap (futex, oldval, newval, "lhi %2,1");
- if (oldval < 0)
- lll_futex_wake (futex, 1);
-}
-#define lll_unlock(futex) __lll_unlock(&(futex))
-
-
-#define lll_islocked(futex) \
- (futex != 1)
-
-
/* The kernel notifies a process with uses CLONE_CLEARTID via futex
wakeup when the clone terminates. The memory location contains the
thread ID while the clone is running and is reset to zero
@@ -289,20 +230,16 @@ __lll_wait_tid (int *ptid)
}
#define lll_wait_tid(tid) __lll_wait_tid(&(tid))
-
-extern int ___lll_timedwait_tid (int *, const struct timespec *)
+extern int __lll_timedwait_tid (int *, const struct timespec *)
attribute_hidden;
-static inline int
-__attribute__ ((always_inline))
-__lll_timedwait_tid (int *ptid, const struct timespec *abstime)
-{
- if (*ptid == 0)
- return 0;
-
- return ___lll_timedwait_tid (ptid, abstime);
-}
-#define lll_timedwait_tid(tid, abstime) __lll_timedwait_tid (&(tid), abstime)
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
/* Conditional variable handling. */