|
|
c6d234 |
commit 65810f0ef05e8c9e333f17a44e77808b163ca298
|
|
|
c6d234 |
Author: Torvald Riegel <triegel@redhat.com>
|
|
|
c6d234 |
Date: Thu Dec 22 10:20:43 2016 +0100
|
|
|
c6d234 |
|
|
|
c6d234 |
robust mutexes: Fix broken x86 assembly by removing it
|
|
|
c6d234 |
|
|
|
c6d234 |
lll_robust_unlock on i386 and x86_64 first sets the futex word to
|
|
|
c6d234 |
FUTEX_WAITERS|0 before calling __lll_unlock_wake, which will set the
|
|
|
c6d234 |
futex word to 0. If the thread is killed between these steps, then the
|
|
|
c6d234 |
futex word will be FUTEX_WAITERS|0, and the kernel (at least current
|
|
|
c6d234 |
upstream) will not set it to FUTEX_OWNER_DIED|FUTEX_WAITERS because 0 is
|
|
|
c6d234 |
not equal to the TID of the crashed thread.
|
|
|
c6d234 |
|
|
|
c6d234 |
The lll_robust_lock assembly code on i386 and x86_64 is not prepared to
|
|
|
c6d234 |
deal with this case because the fastpath tries to only CAS 0 to TID and
|
|
|
c6d234 |
not FUTEX_WAITERS|0 to TID; the slowpath simply waits until it can CAS 0
|
|
|
c6d234 |
to TID or the futex_word has the FUTEX_OWNER_DIED bit set.
|
|
|
c6d234 |
|
|
|
c6d234 |
This issue is fixed by removing the custom x86 assembly code and using
|
|
|
c6d234 |
the generic C code instead. However, instead of adding more duplicate
|
|
|
c6d234 |
code to the custom x86 lowlevellock.h, the code of the lll_robust* functions
|
|
|
c6d234 |
is inlined into the single call sites that exist for each of these functions
|
|
|
c6d234 |
in the pthread_mutex_* functions. The robust mutex paths in the latter
|
|
|
c6d234 |
have been slightly reorganized to make them simpler.
|
|
|
c6d234 |
|
|
|
c6d234 |
This patch is meant to be easy to backport, so C11-style atomics are not
|
|
|
c6d234 |
used.
|
|
|
c6d234 |
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/Makefile
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/Makefile
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/Makefile
|
|
|
c6d234 |
@@ -100,7 +100,7 @@ libpthread-routines = nptl-init vars eve
|
|
|
c6d234 |
cleanup_defer_compat unwind \
|
|
|
c6d234 |
pt-longjmp pt-cleanup\
|
|
|
c6d234 |
cancellation \
|
|
|
c6d234 |
- lowlevellock lowlevelrobustlock \
|
|
|
c6d234 |
+ lowlevellock \
|
|
|
c6d234 |
pt-vfork \
|
|
|
c6d234 |
ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
|
|
|
c6d234 |
ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/pthread_mutex_lock.c
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/pthread_mutex_lock.c
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/pthread_mutex_lock.c
|
|
|
c6d234 |
@@ -34,14 +34,14 @@
|
|
|
c6d234 |
#define lll_trylock_elision(a,t) lll_trylock(a)
|
|
|
c6d234 |
#endif
|
|
|
c6d234 |
|
|
|
c6d234 |
+/* Some of the following definitions differ when pthread_mutex_cond_lock.c
|
|
|
c6d234 |
+ includes this file. */
|
|
|
c6d234 |
#ifndef LLL_MUTEX_LOCK
|
|
|
c6d234 |
# define LLL_MUTEX_LOCK(mutex) \
|
|
|
c6d234 |
lll_lock ((mutex)->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex))
|
|
|
c6d234 |
# define LLL_MUTEX_TRYLOCK(mutex) \
|
|
|
c6d234 |
lll_trylock ((mutex)->__data.__lock)
|
|
|
c6d234 |
-# define LLL_ROBUST_MUTEX_LOCK(mutex, id) \
|
|
|
c6d234 |
- lll_robust_lock ((mutex)->__data.__lock, id, \
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex))
|
|
|
c6d234 |
+# define LLL_ROBUST_MUTEX_LOCK_MODIFIER 0
|
|
|
c6d234 |
# define LLL_MUTEX_LOCK_ELISION(mutex) \
|
|
|
c6d234 |
lll_lock_elision ((mutex)->__data.__lock, (mutex)->__data.__elision, \
|
|
|
c6d234 |
PTHREAD_MUTEX_PSHARED (mutex))
|
|
|
c6d234 |
@@ -186,11 +186,21 @@ __pthread_mutex_lock_full (pthread_mutex
|
|
|
c6d234 |
/* This is set to FUTEX_WAITERS iff we might have shared the
|
|
|
c6d234 |
FUTEX_WAITERS flag with other threads, and therefore need to keep it
|
|
|
c6d234 |
set to avoid lost wake-ups. We have the same requirement in the
|
|
|
c6d234 |
- simple mutex algorithm. */
|
|
|
c6d234 |
- unsigned int assume_other_futex_waiters = 0;
|
|
|
c6d234 |
- do
|
|
|
c6d234 |
+ simple mutex algorithm.
|
|
|
c6d234 |
+ We start with value zero for a normal mutex, and FUTEX_WAITERS if we
|
|
|
c6d234 |
+ are building the special case mutexes for use from within condition
|
|
|
c6d234 |
+ variables. */
|
|
|
c6d234 |
+ unsigned int assume_other_futex_waiters = LLL_ROBUST_MUTEX_LOCK_MODIFIER;
|
|
|
c6d234 |
+ while (1)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
- again:
|
|
|
c6d234 |
+ /* Try to acquire the lock through a CAS from 0 (not acquired) to
|
|
|
c6d234 |
+ our TID | assume_other_futex_waiters. */
|
|
|
c6d234 |
+ if (__glibc_likely ((oldval == 0)
|
|
|
c6d234 |
+ && (atomic_compare_and_exchange_bool_acq
|
|
|
c6d234 |
+ (&mutex->__data.__lock,
|
|
|
c6d234 |
+ id | assume_other_futex_waiters, 0) == 0)))
|
|
|
c6d234 |
+ break;
|
|
|
c6d234 |
+
|
|
|
c6d234 |
if ((oldval & FUTEX_OWNER_DIED) != 0)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
/* The previous owner died. Try locking the mutex. */
|
|
|
c6d234 |
@@ -210,7 +220,7 @@ __pthread_mutex_lock_full (pthread_mutex
|
|
|
c6d234 |
if (newval != oldval)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
oldval = newval;
|
|
|
c6d234 |
- goto again;
|
|
|
c6d234 |
+ continue;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
|
|
|
c6d234 |
/* We got the mutex. */
|
|
|
c6d234 |
@@ -261,24 +271,47 @@ __pthread_mutex_lock_full (pthread_mutex
|
|
|
c6d234 |
}
|
|
|
c6d234 |
}
|
|
|
c6d234 |
|
|
|
c6d234 |
- oldval = LLL_ROBUST_MUTEX_LOCK (mutex,
|
|
|
c6d234 |
- id | assume_other_futex_waiters);
|
|
|
c6d234 |
- /* See above. We set FUTEX_WAITERS and might have shared this flag
|
|
|
c6d234 |
- with other threads; thus, we need to preserve it. */
|
|
|
c6d234 |
- assume_other_futex_waiters = FUTEX_WAITERS;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- if (__builtin_expect (mutex->__data.__owner
|
|
|
c6d234 |
- == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
|
|
|
c6d234 |
+ /* We cannot acquire the mutex nor has its owner died. Thus, try
|
|
|
c6d234 |
+ to block using futexes. Set FUTEX_WAITERS if necessary so that
|
|
|
c6d234 |
+ other threads are aware that there are potentially threads
|
|
|
c6d234 |
+ blocked on the futex. Restart if oldval changed in the
|
|
|
c6d234 |
+ meantime. */
|
|
|
c6d234 |
+ if ((oldval & FUTEX_WAITERS) == 0)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
- /* This mutex is now not recoverable. */
|
|
|
c6d234 |
- mutex->__data.__count = 0;
|
|
|
c6d234 |
- lll_unlock (mutex->__data.__lock,
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
- THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
|
|
|
c6d234 |
- return ENOTRECOVERABLE;
|
|
|
c6d234 |
+ if (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock,
|
|
|
c6d234 |
+ oldval | FUTEX_WAITERS,
|
|
|
c6d234 |
+ oldval)
|
|
|
c6d234 |
+ != 0)
|
|
|
c6d234 |
+ {
|
|
|
c6d234 |
+ oldval = mutex->__data.__lock;
|
|
|
c6d234 |
+ continue;
|
|
|
c6d234 |
+ }
|
|
|
c6d234 |
+ oldval |= FUTEX_WAITERS;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* It is now possible that we share the FUTEX_WAITERS flag with
|
|
|
c6d234 |
+ another thread; therefore, update assume_other_futex_waiters so
|
|
|
c6d234 |
+ that we do not forget about this when handling other cases
|
|
|
c6d234 |
+ above and thus do not cause lost wake-ups. */
|
|
|
c6d234 |
+ assume_other_futex_waiters |= FUTEX_WAITERS;
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* Block using the futex and reload current lock value. */
|
|
|
c6d234 |
+ lll_futex_wait (&mutex->__data.__lock, oldval,
|
|
|
c6d234 |
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
+ oldval = mutex->__data.__lock;
|
|
|
c6d234 |
+ }
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* We have acquired the mutex; check if it is still consistent. */
|
|
|
c6d234 |
+ if (__builtin_expect (mutex->__data.__owner
|
|
|
c6d234 |
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
|
|
|
c6d234 |
+ {
|
|
|
c6d234 |
+ /* This mutex is now not recoverable. */
|
|
|
c6d234 |
+ mutex->__data.__count = 0;
|
|
|
c6d234 |
+ int private = PTHREAD_ROBUST_MUTEX_PSHARED (mutex);
|
|
|
c6d234 |
+ lll_unlock (mutex->__data.__lock, private);
|
|
|
c6d234 |
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
|
|
|
c6d234 |
+ return ENOTRECOVERABLE;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
- while ((oldval & FUTEX_OWNER_DIED) != 0);
|
|
|
c6d234 |
|
|
|
c6d234 |
mutex->__data.__count = 1;
|
|
|
c6d234 |
ENQUEUE_MUTEX (mutex);
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/pthread_mutex_timedlock.c
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/pthread_mutex_timedlock.c
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/pthread_mutex_timedlock.c
|
|
|
c6d234 |
@@ -147,9 +147,16 @@ pthread_mutex_timedlock (pthread_mutex_t
|
|
|
c6d234 |
set to avoid lost wake-ups. We have the same requirement in the
|
|
|
c6d234 |
simple mutex algorithm. */
|
|
|
c6d234 |
unsigned int assume_other_futex_waiters = 0;
|
|
|
c6d234 |
- do
|
|
|
c6d234 |
+ while (1)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
- again:
|
|
|
c6d234 |
+ /* Try to acquire the lock through a CAS from 0 (not acquired) to
|
|
|
c6d234 |
+ our TID | assume_other_futex_waiters. */
|
|
|
c6d234 |
+ if (__glibc_likely ((oldval == 0)
|
|
|
c6d234 |
+ && (atomic_compare_and_exchange_bool_acq
|
|
|
c6d234 |
+ (&mutex->__data.__lock,
|
|
|
c6d234 |
+ id | assume_other_futex_waiters, 0) == 0)))
|
|
|
c6d234 |
+ break;
|
|
|
c6d234 |
+
|
|
|
c6d234 |
if ((oldval & FUTEX_OWNER_DIED) != 0)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
/* The previous owner died. Try locking the mutex. */
|
|
|
c6d234 |
@@ -162,7 +169,7 @@ pthread_mutex_timedlock (pthread_mutex_t
|
|
|
c6d234 |
if (newval != oldval)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
oldval = newval;
|
|
|
c6d234 |
- goto again;
|
|
|
c6d234 |
+ continue;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
|
|
|
c6d234 |
/* We got the mutex. */
|
|
|
c6d234 |
@@ -209,30 +216,87 @@ pthread_mutex_timedlock (pthread_mutex_t
|
|
|
c6d234 |
}
|
|
|
c6d234 |
}
|
|
|
c6d234 |
|
|
|
c6d234 |
- result = lll_robust_timedlock (mutex->__data.__lock, abstime,
|
|
|
c6d234 |
- id | assume_other_futex_waiters,
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
- /* See above. We set FUTEX_WAITERS and might have shared this flag
|
|
|
c6d234 |
- with other threads; thus, we need to preserve it. */
|
|
|
c6d234 |
- assume_other_futex_waiters = FUTEX_WAITERS;
|
|
|
c6d234 |
+ /* We are about to block; check whether the timeout is invalid. */
|
|
|
c6d234 |
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
|
|
|
c6d234 |
+ return EINVAL;
|
|
|
c6d234 |
+ /* Work around the fact that the kernel rejects negative timeout
|
|
|
c6d234 |
+ values despite them being valid. */
|
|
|
c6d234 |
+ if (__glibc_unlikely (abstime->tv_sec < 0))
|
|
|
c6d234 |
+ return ETIMEDOUT;
|
|
|
c6d234 |
+#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \
|
|
|
c6d234 |
+ || !defined lll_futex_timed_wait_bitset)
|
|
|
c6d234 |
+ struct timeval tv;
|
|
|
c6d234 |
+ struct timespec rt;
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* Get the current time. */
|
|
|
c6d234 |
+ (void) __gettimeofday (&tv, NULL);
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* Compute relative timeout. */
|
|
|
c6d234 |
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
|
|
|
c6d234 |
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
|
|
|
c6d234 |
+ if (rt.tv_nsec < 0)
|
|
|
c6d234 |
+ {
|
|
|
c6d234 |
+ rt.tv_nsec += 1000000000;
|
|
|
c6d234 |
+ --rt.tv_sec;
|
|
|
c6d234 |
+ }
|
|
|
c6d234 |
|
|
|
c6d234 |
- if (__builtin_expect (mutex->__data.__owner
|
|
|
c6d234 |
- == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
|
|
|
c6d234 |
+ /* Already timed out? */
|
|
|
c6d234 |
+ if (rt.tv_sec < 0)
|
|
|
c6d234 |
+ return ETIMEDOUT;
|
|
|
c6d234 |
+#endif
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* We cannot acquire the mutex nor has its owner died. Thus, try
|
|
|
c6d234 |
+ to block using futexes. Set FUTEX_WAITERS if necessary so that
|
|
|
c6d234 |
+ other threads are aware that there are potentially threads
|
|
|
c6d234 |
+ blocked on the futex. Restart if oldval changed in the
|
|
|
c6d234 |
+ meantime. */
|
|
|
c6d234 |
+ if ((oldval & FUTEX_WAITERS) == 0)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
- /* This mutex is now not recoverable. */
|
|
|
c6d234 |
- mutex->__data.__count = 0;
|
|
|
c6d234 |
- lll_unlock (mutex->__data.__lock,
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
- THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
|
|
|
c6d234 |
- return ENOTRECOVERABLE;
|
|
|
c6d234 |
+ if (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock,
|
|
|
c6d234 |
+ oldval | FUTEX_WAITERS,
|
|
|
c6d234 |
+ oldval)
|
|
|
c6d234 |
+ != 0)
|
|
|
c6d234 |
+ {
|
|
|
c6d234 |
+ oldval = mutex->__data.__lock;
|
|
|
c6d234 |
+ continue;
|
|
|
c6d234 |
+ }
|
|
|
c6d234 |
+ oldval |= FUTEX_WAITERS;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
|
|
|
c6d234 |
- if (result == ETIMEDOUT || result == EINVAL)
|
|
|
c6d234 |
- goto out;
|
|
|
c6d234 |
+ /* It is now possible that we share the FUTEX_WAITERS flag with
|
|
|
c6d234 |
+ another thread; therefore, update assume_other_futex_waiters so
|
|
|
c6d234 |
+ that we do not forget about this when handling other cases
|
|
|
c6d234 |
+ above and thus do not cause lost wake-ups. */
|
|
|
c6d234 |
+ assume_other_futex_waiters |= FUTEX_WAITERS;
|
|
|
c6d234 |
+
|
|
|
c6d234 |
+ /* Block using the futex. */
|
|
|
c6d234 |
+#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \
|
|
|
c6d234 |
+ || !defined lll_futex_timed_wait_bitset)
|
|
|
c6d234 |
+ lll_futex_timed wait (&mutex->__data.__lock, oldval,
|
|
|
c6d234 |
+ &rt, PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
+#else
|
|
|
c6d234 |
+ int err = lll_futex_timed_wait_bitset (&mutex->__data.__lock,
|
|
|
c6d234 |
+ oldval, abstime, FUTEX_CLOCK_REALTIME,
|
|
|
c6d234 |
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
+ /* The futex call timed out. */
|
|
|
c6d234 |
+ if (err == -ETIMEDOUT)
|
|
|
c6d234 |
+ return -err;
|
|
|
c6d234 |
+#endif
|
|
|
c6d234 |
+ /* Reload current lock value. */
|
|
|
c6d234 |
+ oldval = mutex->__data.__lock;
|
|
|
c6d234 |
+ }
|
|
|
c6d234 |
|
|
|
c6d234 |
- oldval = result;
|
|
|
c6d234 |
+ /* We have acquired the mutex; check if it is still consistent. */
|
|
|
c6d234 |
+ if (__builtin_expect (mutex->__data.__owner
|
|
|
c6d234 |
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
|
|
|
c6d234 |
+ {
|
|
|
c6d234 |
+ /* This mutex is now not recoverable. */
|
|
|
c6d234 |
+ mutex->__data.__count = 0;
|
|
|
c6d234 |
+ int private = PTHREAD_ROBUST_MUTEX_PSHARED (mutex);
|
|
|
c6d234 |
+ lll_unlock (mutex->__data.__lock, private);
|
|
|
c6d234 |
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
|
|
|
c6d234 |
+ return ENOTRECOVERABLE;
|
|
|
c6d234 |
}
|
|
|
c6d234 |
- while ((oldval & FUTEX_OWNER_DIED) != 0);
|
|
|
c6d234 |
|
|
|
c6d234 |
mutex->__data.__count = 1;
|
|
|
c6d234 |
ENQUEUE_MUTEX (mutex);
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/pthread_mutex_unlock.c
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/pthread_mutex_unlock.c
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/pthread_mutex_unlock.c
|
|
|
c6d234 |
@@ -96,6 +96,7 @@ internal_function
|
|
|
c6d234 |
__pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
|
|
|
c6d234 |
{
|
|
|
c6d234 |
int newowner = 0;
|
|
|
c6d234 |
+ int private;
|
|
|
c6d234 |
|
|
|
c6d234 |
switch (PTHREAD_MUTEX_TYPE (mutex))
|
|
|
c6d234 |
{
|
|
|
c6d234 |
@@ -149,9 +150,14 @@ __pthread_mutex_unlock_full (pthread_mut
|
|
|
c6d234 |
/* One less user. */
|
|
|
c6d234 |
--mutex->__data.__nusers;
|
|
|
c6d234 |
|
|
|
c6d234 |
- /* Unlock. */
|
|
|
c6d234 |
- lll_robust_unlock (mutex->__data.__lock,
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
+ /* Unlock by setting the lock to 0 (not acquired); if the lock had
|
|
|
c6d234 |
+ FUTEX_WAITERS set previously, then wake any waiters.
|
|
|
c6d234 |
+ The unlock operation must be the last access to the mutex to not
|
|
|
c6d234 |
+ violate the mutex destruction requirements (see __lll_unlock). */
|
|
|
c6d234 |
+ private = PTHREAD_ROBUST_MUTEX_PSHARED (mutex);
|
|
|
c6d234 |
+ if (__glibc_unlikely ((atomic_exchange_rel (&mutex->__data.__lock, 0)
|
|
|
c6d234 |
+ & FUTEX_WAITERS) != 0))
|
|
|
c6d234 |
+ lll_futex_wake (&mutex->__data.__lock, 1, private);
|
|
|
c6d234 |
|
|
|
c6d234 |
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
|
|
|
c6d234 |
break;
|
|
|
c6d234 |
@@ -233,9 +239,9 @@ __pthread_mutex_unlock_full (pthread_mut
|
|
|
c6d234 |
tid)))
|
|
|
c6d234 |
{
|
|
|
c6d234 |
int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
|
|
|
c6d234 |
- int private = (robust
|
|
|
c6d234 |
- ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
|
|
|
c6d234 |
- : PTHREAD_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
+ private = (robust
|
|
|
c6d234 |
+ ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
|
|
|
c6d234 |
+ : PTHREAD_MUTEX_PSHARED (mutex));
|
|
|
c6d234 |
INTERNAL_SYSCALL_DECL (__err);
|
|
|
c6d234 |
INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
|
|
|
c6d234 |
__lll_private_flag (FUTEX_UNLOCK_PI, private));
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,232 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include <sysdep.h>
|
|
|
c6d234 |
-#include <pthread-errnos.h>
|
|
|
c6d234 |
-#include <lowlevellock.h>
|
|
|
c6d234 |
-#include <lowlevelrobustlock.h>
|
|
|
c6d234 |
-#include <kernel-features.h>
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .text
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#define FUTEX_WAITERS 0x80000000
|
|
|
c6d234 |
-#define FUTEX_OWNER_DIED 0x40000000
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
|
|
|
c6d234 |
-#else
|
|
|
c6d234 |
-# if FUTEX_WAIT == 0
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $FUTEX_PRIVATE_FLAG, reg ; \
|
|
|
c6d234 |
- andl %gs:PRIVATE_FUTEX, reg
|
|
|
c6d234 |
-# else
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $FUTEX_PRIVATE_FLAG, reg ; \
|
|
|
c6d234 |
- andl %gs:PRIVATE_FUTEX, reg ; \
|
|
|
c6d234 |
- orl $FUTEX_WAIT, reg
|
|
|
c6d234 |
-# endif
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_lock_wait
|
|
|
c6d234 |
- .type __lll_robust_lock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_lock_wait
|
|
|
c6d234 |
- .align 16
|
|
|
c6d234 |
-__lll_robust_lock_wait:
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
- pushl %edx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- pushl %ebx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- pushl %esi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_offset(%edx, -8)
|
|
|
c6d234 |
- cfi_offset(%ebx, -12)
|
|
|
c6d234 |
- cfi_offset(%esi, -16)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %edx, %ebx
|
|
|
c6d234 |
- xorl %esi, %esi /* No timeout. */
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (%ecx)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-4: movl %eax, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- testl $FUTEX_OWNER_DIED, %eax
|
|
|
c6d234 |
- jnz 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpl %edx, %eax /* NB: %edx == 2 */
|
|
|
c6d234 |
- je 1f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%ebx)
|
|
|
c6d234 |
- jnz 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1: movl $SYS_futex, %eax
|
|
|
c6d234 |
- ENTER_KERNEL
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl (%ebx), %eax
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2: test %eax, %eax
|
|
|
c6d234 |
- jne 4b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %gs:TID, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%ebx)
|
|
|
c6d234 |
- jnz 4b
|
|
|
c6d234 |
- /* NB: %eax == 0 */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3: popl %esi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%esi)
|
|
|
c6d234 |
- popl %ebx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%ebx)
|
|
|
c6d234 |
- popl %edx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%edx)
|
|
|
c6d234 |
- ret
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .type __lll_robust_timedlock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .align 16
|
|
|
c6d234 |
-__lll_robust_timedlock_wait:
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
- /* Check for a valid timeout value. */
|
|
|
c6d234 |
- cmpl $1000000000, 4(%edx)
|
|
|
c6d234 |
- jae 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- pushl %edi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- pushl %esi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- pushl %ebx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- pushl %ebp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_offset(%edi, -8)
|
|
|
c6d234 |
- cfi_offset(%esi, -12)
|
|
|
c6d234 |
- cfi_offset(%ebx, -16)
|
|
|
c6d234 |
- cfi_offset(%ebp, -20)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Stack frame for the timespec and timeval structs. */
|
|
|
c6d234 |
- subl $12, %esp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(12)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %ecx, %ebp
|
|
|
c6d234 |
- movl %edx, %edi
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1: movl %eax, 8(%esp)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Get current time. */
|
|
|
c6d234 |
- movl %esp, %ebx
|
|
|
c6d234 |
- xorl %ecx, %ecx
|
|
|
c6d234 |
- movl $__NR_gettimeofday, %eax
|
|
|
c6d234 |
- ENTER_KERNEL
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Compute relative timeout. */
|
|
|
c6d234 |
- movl 4(%esp), %eax
|
|
|
c6d234 |
- movl $1000, %edx
|
|
|
c6d234 |
- mul %edx /* Milli seconds to nano seconds. */
|
|
|
c6d234 |
- movl (%edi), %ecx
|
|
|
c6d234 |
- movl 4(%edi), %edx
|
|
|
c6d234 |
- subl (%esp), %ecx
|
|
|
c6d234 |
- subl %eax, %edx
|
|
|
c6d234 |
- jns 4f
|
|
|
c6d234 |
- addl $1000000000, %edx
|
|
|
c6d234 |
- subl $1, %ecx
|
|
|
c6d234 |
-4: testl %ecx, %ecx
|
|
|
c6d234 |
- js 8f /* Time is already up. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Store relative timeout. */
|
|
|
c6d234 |
- movl %ecx, (%esp)
|
|
|
c6d234 |
- movl %edx, 4(%esp)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %ebp, %ebx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl 8(%esp), %edx
|
|
|
c6d234 |
- movl %edx, %eax
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- testl $FUTEX_OWNER_DIED, %eax
|
|
|
c6d234 |
- jnz 6f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpl %eax, %edx
|
|
|
c6d234 |
- je 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%ebx)
|
|
|
c6d234 |
- movl $0, %ecx /* Must use mov to avoid changing cc. */
|
|
|
c6d234 |
- jnz 5f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2:
|
|
|
c6d234 |
- /* Futex call. */
|
|
|
c6d234 |
- movl %esp, %esi
|
|
|
c6d234 |
- movl 20(%esp), %ecx
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (%ecx)
|
|
|
c6d234 |
- movl $SYS_futex, %eax
|
|
|
c6d234 |
- ENTER_KERNEL
|
|
|
c6d234 |
- movl %eax, %ecx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl (%ebx), %eax
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-5: testl %eax, %eax
|
|
|
c6d234 |
- jne 7f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %gs:TID, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%ebx)
|
|
|
c6d234 |
- jnz 7f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-6: addl $12, %esp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-12)
|
|
|
c6d234 |
- popl %ebp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%ebp)
|
|
|
c6d234 |
- popl %ebx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%ebx)
|
|
|
c6d234 |
- popl %esi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%esi)
|
|
|
c6d234 |
- popl %edi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-4)
|
|
|
c6d234 |
- cfi_restore(%edi)
|
|
|
c6d234 |
- ret
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3: movl $EINVAL, %eax
|
|
|
c6d234 |
- ret
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(28)
|
|
|
c6d234 |
- cfi_offset(%edi, -8)
|
|
|
c6d234 |
- cfi_offset(%esi, -12)
|
|
|
c6d234 |
- cfi_offset(%ebx, -16)
|
|
|
c6d234 |
- cfi_offset(%ebp, -20)
|
|
|
c6d234 |
- /* Check whether the time expired. */
|
|
|
c6d234 |
-7: cmpl $-ETIMEDOUT, %ecx
|
|
|
c6d234 |
- jne 1b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-8: movl $ETIMEDOUT, %eax
|
|
|
c6d234 |
- jmp 6b
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,19 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include "../i486/lowlevelrobustlock.S"
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,19 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include "../i486/lowlevelrobustlock.S"
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
|
|
|
c6d234 |
@@ -338,27 +338,6 @@ LLL_STUB_UNWIND_INFO_END
|
|
|
c6d234 |
} \
|
|
|
c6d234 |
})
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_lock(futex, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
|
|
|
c6d234 |
- "jnz _L_robust_lock_%=\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_lock_%=,@function\n" \
|
|
|
c6d234 |
- "_L_robust_lock_%=:\n" \
|
|
|
c6d234 |
- "1:\tleal %2, %%edx\n" \
|
|
|
c6d234 |
- "0:\tmovl %7, %%ecx\n" \
|
|
|
c6d234 |
- "2:\tcall __lll_robust_lock_wait\n" \
|
|
|
c6d234 |
- "3:\tjmp 18f\n" \
|
|
|
c6d234 |
- "4:\t.size _L_robust_lock_%=, 4b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_4 \
|
|
|
c6d234 |
- "18:" \
|
|
|
c6d234 |
- : "=a" (result), "=c" (ignore1), "=m" (futex), \
|
|
|
c6d234 |
- "=&d" (ignore2) \
|
|
|
c6d234 |
- : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\
|
|
|
c6d234 |
- : "memory"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
|
|
|
c6d234 |
/* Special version of lll_lock which causes the unlock function to
|
|
|
c6d234 |
always wakeup waiters. */
|
|
|
c6d234 |
@@ -384,30 +363,6 @@ LLL_STUB_UNWIND_INFO_END
|
|
|
c6d234 |
: "memory"); \
|
|
|
c6d234 |
})
|
|
|
c6d234 |
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#define lll_robust_cond_lock(futex, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
|
|
|
c6d234 |
- "jnz _L_robust_cond_lock_%=\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_cond_lock_%=,@function\n" \
|
|
|
c6d234 |
- "_L_robust_cond_lock_%=:\n" \
|
|
|
c6d234 |
- "1:\tleal %2, %%edx\n" \
|
|
|
c6d234 |
- "0:\tmovl %7, %%ecx\n" \
|
|
|
c6d234 |
- "2:\tcall __lll_robust_lock_wait\n" \
|
|
|
c6d234 |
- "3:\tjmp 18f\n" \
|
|
|
c6d234 |
- "4:\t.size _L_robust_cond_lock_%=, 4b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_4 \
|
|
|
c6d234 |
- "18:" \
|
|
|
c6d234 |
- : "=a" (result), "=c" (ignore1), "=m" (futex), \
|
|
|
c6d234 |
- "=&d" (ignore2) \
|
|
|
c6d234 |
- : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex), \
|
|
|
c6d234 |
- "g" ((int) (private)) \
|
|
|
c6d234 |
- : "memory"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#define lll_timedlock(futex, timeout, private) \
|
|
|
c6d234 |
({ int result, ignore1, ignore2, ignore3; \
|
|
|
c6d234 |
__asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
|
|
|
c6d234 |
@@ -437,28 +392,6 @@ extern int __lll_timedlock_elision (int
|
|
|
c6d234 |
#define lll_timedlock_elision(futex, adapt_count, timeout, private) \
|
|
|
c6d234 |
__lll_timedlock_elision(&(futex), &(adapt_count), timeout, private)
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_timedlock(futex, timeout, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2, ignore3; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
|
|
|
c6d234 |
- "jnz _L_robust_timedlock_%=\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_timedlock_%=,@function\n" \
|
|
|
c6d234 |
- "_L_robust_timedlock_%=:\n" \
|
|
|
c6d234 |
- "1:\tleal %3, %%ecx\n" \
|
|
|
c6d234 |
- "0:\tmovl %8, %%edx\n" \
|
|
|
c6d234 |
- "2:\tcall __lll_robust_timedlock_wait\n" \
|
|
|
c6d234 |
- "3:\tjmp 18f\n" \
|
|
|
c6d234 |
- "4:\t.size _L_robust_timedlock_%=, 4b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_4 \
|
|
|
c6d234 |
- "18:" \
|
|
|
c6d234 |
- : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
|
|
|
c6d234 |
- "=m" (futex), "=S" (ignore3) \
|
|
|
c6d234 |
- : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
|
|
|
c6d234 |
- "4" ((int) (private)) \
|
|
|
c6d234 |
- : "memory"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#if !IS_IN (libc) || defined UP
|
|
|
c6d234 |
# define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t"
|
|
|
c6d234 |
#else
|
|
|
c6d234 |
@@ -510,29 +443,6 @@ extern int __lll_timedlock_elision (int
|
|
|
c6d234 |
} \
|
|
|
c6d234 |
})
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_unlock(futex, private) \
|
|
|
c6d234 |
- (void) \
|
|
|
c6d234 |
- ({ int ignore, ignore2; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "andl %3, %0\n\t" \
|
|
|
c6d234 |
- "jne _L_robust_unlock_%=\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_unlock_%=,@function\n" \
|
|
|
c6d234 |
- "_L_robust_unlock_%=:\n\t" \
|
|
|
c6d234 |
- "1:\tleal %0, %%eax\n" \
|
|
|
c6d234 |
- "0:\tmovl %5, %%ecx\n" \
|
|
|
c6d234 |
- "2:\tcall __lll_unlock_wake\n" \
|
|
|
c6d234 |
- "3:\tjmp 18f\n" \
|
|
|
c6d234 |
- "4:\t.size _L_robust_unlock_%=, 4b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_4 \
|
|
|
c6d234 |
- "18:" \
|
|
|
c6d234 |
- : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
|
|
|
c6d234 |
- : "i" (FUTEX_WAITERS), "m" (futex), \
|
|
|
c6d234 |
- "g" ((int) (private)) \
|
|
|
c6d234 |
- : "memory"); \
|
|
|
c6d234 |
- })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#define lll_robust_dead(futex, private) \
|
|
|
c6d234 |
(void) \
|
|
|
c6d234 |
({ int __ignore; \
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,127 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2006-2012 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include <errno.h>
|
|
|
c6d234 |
-#include <sysdep.h>
|
|
|
c6d234 |
-#include <lowlevellock.h>
|
|
|
c6d234 |
-#include <sys/time.h>
|
|
|
c6d234 |
-#include <pthreadP.h>
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-int
|
|
|
c6d234 |
-__lll_robust_lock_wait (int *futex, int private)
|
|
|
c6d234 |
-{
|
|
|
c6d234 |
- int oldval = *futex;
|
|
|
c6d234 |
- int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* If the futex changed meanwhile try locking again. */
|
|
|
c6d234 |
- if (oldval == 0)
|
|
|
c6d234 |
- goto try;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- do
|
|
|
c6d234 |
- {
|
|
|
c6d234 |
- if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
|
|
c6d234 |
- return oldval;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- int newval = oldval | FUTEX_WAITERS;
|
|
|
c6d234 |
- if (oldval != newval
|
|
|
c6d234 |
- && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
|
|
|
c6d234 |
- continue;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- lll_futex_wait (futex, newval, private);
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- try:
|
|
|
c6d234 |
- ;
|
|
|
c6d234 |
- }
|
|
|
c6d234 |
- while ((oldval = atomic_compare_and_exchange_val_acq (futex,
|
|
|
c6d234 |
- tid | FUTEX_WAITERS,
|
|
|
c6d234 |
- 0)) != 0);
|
|
|
c6d234 |
- return 0;
|
|
|
c6d234 |
-}
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-int
|
|
|
c6d234 |
-__lll_robust_timedlock_wait (int *futex, const struct timespec *abstime,
|
|
|
c6d234 |
- int private)
|
|
|
c6d234 |
-{
|
|
|
c6d234 |
- /* Reject invalid timeouts. */
|
|
|
c6d234 |
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
|
|
|
c6d234 |
- return EINVAL;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- int tid = THREAD_GETMEM (THREAD_SELF, tid);
|
|
|
c6d234 |
- int oldval = *futex;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* If the futex changed meanwhile try locking again. */
|
|
|
c6d234 |
- if (oldval == 0)
|
|
|
c6d234 |
- goto try;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Work around the fact that the kernel rejects negative timeout values
|
|
|
c6d234 |
- despite them being valid. */
|
|
|
c6d234 |
- if (__builtin_expect (abstime->tv_sec < 0, 0))
|
|
|
c6d234 |
- return ETIMEDOUT;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- do
|
|
|
c6d234 |
- {
|
|
|
c6d234 |
-#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \
|
|
|
c6d234 |
- || !defined lll_futex_timed_wait_bitset)
|
|
|
c6d234 |
- struct timeval tv;
|
|
|
c6d234 |
- struct timespec rt;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Get the current time. */
|
|
|
c6d234 |
- (void) __gettimeofday (&tv, NULL);
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Compute relative timeout. */
|
|
|
c6d234 |
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
|
|
|
c6d234 |
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
|
|
|
c6d234 |
- if (rt.tv_nsec < 0)
|
|
|
c6d234 |
- {
|
|
|
c6d234 |
- rt.tv_nsec += 1000000000;
|
|
|
c6d234 |
- --rt.tv_sec;
|
|
|
c6d234 |
- }
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Already timed out? */
|
|
|
c6d234 |
- if (rt.tv_sec < 0)
|
|
|
c6d234 |
- return ETIMEDOUT;
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Wait. */
|
|
|
c6d234 |
- if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
|
|
|
c6d234 |
- return oldval;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- int newval = oldval | FUTEX_WAITERS;
|
|
|
c6d234 |
- if (oldval != newval
|
|
|
c6d234 |
- && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
|
|
|
c6d234 |
- continue;
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \
|
|
|
c6d234 |
- || !defined lll_futex_timed_wait_bitset)
|
|
|
c6d234 |
- lll_futex_timed_wait (futex, newval, &rt, private);
|
|
|
c6d234 |
-#else
|
|
|
c6d234 |
- lll_futex_timed_wait_bitset (futex, newval, abstime,
|
|
|
c6d234 |
- FUTEX_CLOCK_REALTIME, private);
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- try:
|
|
|
c6d234 |
- ;
|
|
|
c6d234 |
- }
|
|
|
c6d234 |
- while ((oldval = atomic_compare_and_exchange_val_acq (futex,
|
|
|
c6d234 |
- tid | FUTEX_WAITERS,
|
|
|
c6d234 |
- 0)) != 0);
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- return 0;
|
|
|
c6d234 |
-}
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,6 +0,0 @@
|
|
|
c6d234 |
-#include <stddef.h>
|
|
|
c6d234 |
-#include <pthreadP.h>
|
|
|
c6d234 |
-
|
|
|
c6d234 |
---
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-TID offsetof (struct pthread, tid)
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
|
|
|
c6d234 |
@@ -11,9 +11,9 @@
|
|
|
c6d234 |
lll_cond_trylock ((mutex)->__data.__lock)
|
|
|
c6d234 |
#define LLL_MUTEX_TRYLOCK_ELISION(mutex) LLL_MUTEX_TRYLOCK(mutex)
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define LLL_ROBUST_MUTEX_LOCK(mutex, id) \
|
|
|
c6d234 |
- lll_robust_cond_lock ((mutex)->__data.__lock, id, \
|
|
|
c6d234 |
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex))
|
|
|
c6d234 |
+/* We need to assume that there are other threads blocked on the futex.
|
|
|
c6d234 |
+ See __pthread_mutex_lock_full for further details. */
|
|
|
c6d234 |
+#define LLL_ROBUST_MUTEX_LOCK_MODIFIER FUTEX_WAITERS
|
|
|
c6d234 |
#define __pthread_mutex_lock internal_function __pthread_mutex_cond_lock
|
|
|
c6d234 |
#define __pthread_mutex_lock_full __pthread_mutex_cond_lock_full
|
|
|
c6d234 |
#define NO_INCR
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
|
|
|
c6d234 |
@@ -349,28 +349,6 @@ LLL_STUB_UNWIND_INFO_END
|
|
|
c6d234 |
: "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
}) \
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_lock(futex, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
|
|
|
c6d234 |
- "jnz 1f\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_lock_%=, @function\n" \
|
|
|
c6d234 |
- "_L_robust_lock_%=:\n" \
|
|
|
c6d234 |
- "1:\tlea %2, %%" RDI_LP "\n" \
|
|
|
c6d234 |
- "2:\tsub $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "3:\tcallq __lll_robust_lock_wait\n" \
|
|
|
c6d234 |
- "4:\tadd $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "5:\tjmp 24f\n" \
|
|
|
c6d234 |
- "6:\t.size _L_robust_lock_%=, 6b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_5 \
|
|
|
c6d234 |
- "24:" \
|
|
|
c6d234 |
- : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
|
|
|
c6d234 |
- "=a" (result) \
|
|
|
c6d234 |
- : "1" (id), "m" (futex), "3" (0), "0" (private) \
|
|
|
c6d234 |
- : "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#define lll_cond_lock(futex, private) \
|
|
|
c6d234 |
(void) \
|
|
|
c6d234 |
({ int ignore1, ignore2, ignore3; \
|
|
|
c6d234 |
@@ -394,29 +372,6 @@ LLL_STUB_UNWIND_INFO_END
|
|
|
c6d234 |
: "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
})
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_cond_lock(futex, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
|
|
|
c6d234 |
- "jnz 1f\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_cond_lock_%=, @function\n" \
|
|
|
c6d234 |
- "_L_robust_cond_lock_%=:\n" \
|
|
|
c6d234 |
- "1:\tlea %2, %%" RDI_LP "\n" \
|
|
|
c6d234 |
- "2:\tsub $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "3:\tcallq __lll_robust_lock_wait\n" \
|
|
|
c6d234 |
- "4:\tadd $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "5:\tjmp 24f\n" \
|
|
|
c6d234 |
- "6:\t.size _L_robust_cond_lock_%=, 6b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_5 \
|
|
|
c6d234 |
- "24:" \
|
|
|
c6d234 |
- : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
|
|
|
c6d234 |
- "=a" (result) \
|
|
|
c6d234 |
- : "1" (id | FUTEX_WAITERS), "m" (futex), "3" (0), \
|
|
|
c6d234 |
- "0" (private) \
|
|
|
c6d234 |
- : "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#define lll_timedlock(futex, timeout, private) \
|
|
|
c6d234 |
({ int result, ignore1, ignore2, ignore3; \
|
|
|
c6d234 |
__asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
|
|
|
c6d234 |
@@ -448,30 +403,6 @@ extern int __lll_timedlock_elision (int
|
|
|
c6d234 |
#define lll_timedlock_elision(futex, adapt_count, timeout, private) \
|
|
|
c6d234 |
__lll_timedlock_elision(&(futex), &(adapt_count), timeout, private)
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_timedlock(futex, timeout, id, private) \
|
|
|
c6d234 |
- ({ int result, ignore1, ignore2, ignore3; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
|
|
|
c6d234 |
- "jnz 1f\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_timedlock_%=, @function\n" \
|
|
|
c6d234 |
- "_L_robust_timedlock_%=:\n" \
|
|
|
c6d234 |
- "1:\tlea %4, %%" RDI_LP "\n" \
|
|
|
c6d234 |
- "0:\tmov %8, %%" RDX_LP "\n" \
|
|
|
c6d234 |
- "2:\tsub $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "3:\tcallq __lll_robust_timedlock_wait\n" \
|
|
|
c6d234 |
- "4:\tadd $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "5:\tjmp 24f\n" \
|
|
|
c6d234 |
- "6:\t.size _L_robust_timedlock_%=, 6b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_6 \
|
|
|
c6d234 |
- "24:" \
|
|
|
c6d234 |
- : "=a" (result), "=D" (ignore1), "=S" (ignore2), \
|
|
|
c6d234 |
- "=&d" (ignore3), "=m" (futex) \
|
|
|
c6d234 |
- : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
|
|
|
c6d234 |
- "2" (private) \
|
|
|
c6d234 |
- : "memory", "cx", "cc", "r10", "r11"); \
|
|
|
c6d234 |
- result; })
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#if !IS_IN (libc) || defined UP
|
|
|
c6d234 |
# define __lll_unlock_asm_start LOCK_INSTR "decl %0\n\t" \
|
|
|
c6d234 |
"jne 1f\n\t"
|
|
|
c6d234 |
@@ -524,31 +455,6 @@ extern int __lll_timedlock_elision (int
|
|
|
c6d234 |
: "ax", "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
})
|
|
|
c6d234 |
|
|
|
c6d234 |
-#define lll_robust_unlock(futex, private) \
|
|
|
c6d234 |
- do \
|
|
|
c6d234 |
- { \
|
|
|
c6d234 |
- int ignore; \
|
|
|
c6d234 |
- __asm __volatile (LOCK_INSTR "andl %2, %0\n\t" \
|
|
|
c6d234 |
- "jne 1f\n\t" \
|
|
|
c6d234 |
- ".subsection 1\n\t" \
|
|
|
c6d234 |
- ".type _L_robust_unlock_%=, @function\n" \
|
|
|
c6d234 |
- "_L_robust_unlock_%=:\n" \
|
|
|
c6d234 |
- "1:\tlea %0, %%" RDI_LP "\n" \
|
|
|
c6d234 |
- "2:\tsub $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "3:\tcallq __lll_unlock_wake\n" \
|
|
|
c6d234 |
- "4:\tadd $128, %%" RSP_LP "\n" \
|
|
|
c6d234 |
- "5:\tjmp 24f\n" \
|
|
|
c6d234 |
- "6:\t.size _L_robust_unlock_%=, 6b-1b\n\t" \
|
|
|
c6d234 |
- ".previous\n" \
|
|
|
c6d234 |
- LLL_STUB_UNWIND_INFO_5 \
|
|
|
c6d234 |
- "24:" \
|
|
|
c6d234 |
- : "=m" (futex), "=&D" (ignore) \
|
|
|
c6d234 |
- : "i" (FUTEX_WAITERS), "m" (futex), \
|
|
|
c6d234 |
- "S" (private) \
|
|
|
c6d234 |
- : "ax", "cx", "r11", "cc", "memory"); \
|
|
|
c6d234 |
- } \
|
|
|
c6d234 |
- while (0)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
#define lll_robust_dead(futex, private) \
|
|
|
c6d234 |
do \
|
|
|
c6d234 |
{ \
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,306 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2002, 2011=2007, 2009, 2010 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include <sysdep.h>
|
|
|
c6d234 |
-#include <pthread-errnos.h>
|
|
|
c6d234 |
-#include <lowlevellock.h>
|
|
|
c6d234 |
-#include <lowlevelrobustlock.h>
|
|
|
c6d234 |
-#include <kernel-features.h>
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .text
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#define FUTEX_WAITERS 0x80000000
|
|
|
c6d234 |
-#define FUTEX_OWNER_DIED 0x40000000
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT_ABS(reg) \
|
|
|
c6d234 |
- xorl $(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
|
|
|
c6d234 |
-#else
|
|
|
c6d234 |
-# if FUTEX_WAIT == 0
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $FUTEX_PRIVATE_FLAG, reg ; \
|
|
|
c6d234 |
- andl %fs:PRIVATE_FUTEX, reg
|
|
|
c6d234 |
-# else
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg) \
|
|
|
c6d234 |
- xorl $FUTEX_PRIVATE_FLAG, reg ; \
|
|
|
c6d234 |
- andl %fs:PRIVATE_FUTEX, reg ; \
|
|
|
c6d234 |
- orl $FUTEX_WAIT, reg
|
|
|
c6d234 |
-# endif
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT_ABS(reg) \
|
|
|
c6d234 |
- xorl $FUTEX_PRIVATE_FLAG, reg ; \
|
|
|
c6d234 |
- andl %fs:PRIVATE_FUTEX, reg ; \
|
|
|
c6d234 |
- orl $FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_lock_wait
|
|
|
c6d234 |
- .type __lll_robust_lock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_lock_wait
|
|
|
c6d234 |
- .align 16
|
|
|
c6d234 |
-__lll_robust_lock_wait:
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
- pushq %r10
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- pushq %rdx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- cfi_offset(%r10, -16)
|
|
|
c6d234 |
- cfi_offset(%rdx, -24)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- xorq %r10, %r10 /* No timeout. */
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (%esi)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-4: movl %eax, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- testl $FUTEX_OWNER_DIED, %eax
|
|
|
c6d234 |
- jnz 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpl %edx, %eax
|
|
|
c6d234 |
- je 1f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%rdi)
|
|
|
c6d234 |
- jnz 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1: movl $SYS_futex, %eax
|
|
|
c6d234 |
- syscall
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl (%rdi), %eax
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2: testl %eax, %eax
|
|
|
c6d234 |
- jne 4b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %fs:TID, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%rdi)
|
|
|
c6d234 |
- jnz 4b
|
|
|
c6d234 |
- /* NB: %rax == 0 */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3: popq %rdx
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%rdx)
|
|
|
c6d234 |
- popq %r10
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r10)
|
|
|
c6d234 |
- retq
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .type __lll_robust_timedlock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .align 16
|
|
|
c6d234 |
-__lll_robust_timedlock_wait:
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
-# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
|
|
|
c6d234 |
-# ifdef PIC
|
|
|
c6d234 |
- cmpl $0, __have_futex_clock_realtime(%rip)
|
|
|
c6d234 |
-# else
|
|
|
c6d234 |
- cmpl $0, __have_futex_clock_realtime
|
|
|
c6d234 |
-# endif
|
|
|
c6d234 |
- je .Lreltmo
|
|
|
c6d234 |
-# endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpq $0, (%rdx)
|
|
|
c6d234 |
- js 7f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- pushq %r9
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- cfi_rel_offset(%r9, 0)
|
|
|
c6d234 |
- movq %rdx, %r10
|
|
|
c6d234 |
- movl $0xffffffff, %r9d
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT_ABS (%esi)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1: testl $FUTEX_OWNER_DIED, %eax
|
|
|
c6d234 |
- jnz 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %eax, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpl %eax, %edx
|
|
|
c6d234 |
- je 5f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%rdi)
|
|
|
c6d234 |
- movq $0, %rcx /* Must use mov to avoid changing cc. */
|
|
|
c6d234 |
- jnz 6f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-5: movl $SYS_futex, %eax
|
|
|
c6d234 |
- syscall
|
|
|
c6d234 |
- movl %eax, %ecx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl (%rdi), %eax
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-6: testl %eax, %eax
|
|
|
c6d234 |
- jne 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %fs:TID, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%rdi)
|
|
|
c6d234 |
- jnz 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3: popq %r9
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r9)
|
|
|
c6d234 |
- retq
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- cfi_rel_offset(%r9, 0)
|
|
|
c6d234 |
- /* Check whether the time expired. */
|
|
|
c6d234 |
-2: cmpl $-ETIMEDOUT, %ecx
|
|
|
c6d234 |
- je 4f
|
|
|
c6d234 |
- cmpl $-EINVAL, %ecx
|
|
|
c6d234 |
- jne 1b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-4: movl %ecx, %eax
|
|
|
c6d234 |
- negl %eax
|
|
|
c6d234 |
- jmp 3b
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r9)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-7: movl $ETIMEDOUT, %eax
|
|
|
c6d234 |
- retq
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
|
|
|
c6d234 |
-.Lreltmo:
|
|
|
c6d234 |
- /* Check for a valid timeout value. */
|
|
|
c6d234 |
- cmpq $1000000000, 8(%rdx)
|
|
|
c6d234 |
- jae 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- pushq %r8
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- pushq %r9
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- pushq %r12
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- pushq %r13
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
- cfi_offset(%r8, -16)
|
|
|
c6d234 |
- cfi_offset(%r9, -24)
|
|
|
c6d234 |
- cfi_offset(%r12, -32)
|
|
|
c6d234 |
- cfi_offset(%r13, -40)
|
|
|
c6d234 |
- pushq %rsi
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Stack frame for the timespec and timeval structs. */
|
|
|
c6d234 |
- subq $32, %rsp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(32)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movq %rdi, %r12
|
|
|
c6d234 |
- movq %rdx, %r13
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1: movq %rax, 16(%rsp)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Get current time. */
|
|
|
c6d234 |
- movq %rsp, %rdi
|
|
|
c6d234 |
- xorl %esi, %esi
|
|
|
c6d234 |
- /* This call works because we directly jump to a system call entry
|
|
|
c6d234 |
- which preserves all the registers. */
|
|
|
c6d234 |
- call JUMPTARGET(__gettimeofday)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Compute relative timeout. */
|
|
|
c6d234 |
- movq 8(%rsp), %rax
|
|
|
c6d234 |
- movl $1000, %edi
|
|
|
c6d234 |
- mul %rdi /* Milli seconds to nano seconds. */
|
|
|
c6d234 |
- movq (%r13), %rdi
|
|
|
c6d234 |
- movq 8(%r13), %rsi
|
|
|
c6d234 |
- subq (%rsp), %rdi
|
|
|
c6d234 |
- subq %rax, %rsi
|
|
|
c6d234 |
- jns 4f
|
|
|
c6d234 |
- addq $1000000000, %rsi
|
|
|
c6d234 |
- decq %rdi
|
|
|
c6d234 |
-4: testq %rdi, %rdi
|
|
|
c6d234 |
- js 8f /* Time is already up. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Futex call. */
|
|
|
c6d234 |
- movq %rdi, (%rsp) /* Store relative timeout. */
|
|
|
c6d234 |
- movq %rsi, 8(%rsp)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movq 16(%rsp), %rdx
|
|
|
c6d234 |
- movl %edx, %eax
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- testl $FUTEX_OWNER_DIED, %eax
|
|
|
c6d234 |
- jnz 6f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cmpl %eax, %edx
|
|
|
c6d234 |
- je 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%r12)
|
|
|
c6d234 |
- movq $0, %rcx /* Must use mov to avoid changing cc. */
|
|
|
c6d234 |
- jnz 5f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2: movq %rsp, %r10
|
|
|
c6d234 |
- movl 32(%rsp), %esi
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (%esi)
|
|
|
c6d234 |
- movq %r12, %rdi
|
|
|
c6d234 |
- movl $SYS_futex, %eax
|
|
|
c6d234 |
- syscall
|
|
|
c6d234 |
- movq %rax, %rcx
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl (%r12), %eax
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-5: testl %eax, %eax
|
|
|
c6d234 |
- jne 7f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- movl %fs:TID, %edx
|
|
|
c6d234 |
- orl $FUTEX_WAITERS, %edx
|
|
|
c6d234 |
- LOCK
|
|
|
c6d234 |
- cmpxchgl %edx, (%r12)
|
|
|
c6d234 |
- jnz 7f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-6: addq $40, %rsp
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-40)
|
|
|
c6d234 |
- popq %r13
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r13)
|
|
|
c6d234 |
- popq %r12
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r12)
|
|
|
c6d234 |
- popq %r9
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r9)
|
|
|
c6d234 |
- popq %r8
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(-8)
|
|
|
c6d234 |
- cfi_restore(%r8)
|
|
|
c6d234 |
- retq
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3: movl $EINVAL, %eax
|
|
|
c6d234 |
- retq
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(72)
|
|
|
c6d234 |
- cfi_offset(%r8, -16)
|
|
|
c6d234 |
- cfi_offset(%r9, -24)
|
|
|
c6d234 |
- cfi_offset(%r12, -32)
|
|
|
c6d234 |
- cfi_offset(%r13, -40)
|
|
|
c6d234 |
- /* Check whether the time expired. */
|
|
|
c6d234 |
-7: cmpl $-ETIMEDOUT, %ecx
|
|
|
c6d234 |
- jne 1b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-8: movl $ETIMEDOUT, %eax
|
|
|
c6d234 |
- jmp 6b
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
|
|
|
c6d234 |
+++ /dev/null
|
|
|
c6d234 |
@@ -1,278 +0,0 @@
|
|
|
c6d234 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
c6d234 |
- This file is part of the GNU C Library.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
c6d234 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
c6d234 |
- License as published by the Free Software Foundation; either
|
|
|
c6d234 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c6d234 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c6d234 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c6d234 |
- Lesser General Public License for more details.
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
c6d234 |
- License along with the GNU C Library; if not, see
|
|
|
c6d234 |
- <http://www.gnu.org/licenses/>. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#include <sysdep.h>
|
|
|
c6d234 |
-#include <pthread-errnos.h>
|
|
|
c6d234 |
-#include <lowlevellock.h>
|
|
|
c6d234 |
-#include <lowlevelrobustlock.h>
|
|
|
c6d234 |
-#include <kernel-features.h>
|
|
|
c6d234 |
-#include "lowlevel-atomic.h"
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .text
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#define FUTEX_WAITERS 0x80000000
|
|
|
c6d234 |
-#define FUTEX_OWNER_DIED 0x40000000
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
|
|
|
c6d234 |
- mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \
|
|
|
c6d234 |
- extu.b tmp, tmp; \
|
|
|
c6d234 |
- xor tmp, reg
|
|
|
c6d234 |
-#else
|
|
|
c6d234 |
-# if FUTEX_WAIT == 0
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
|
|
|
c6d234 |
- stc gbr, tmp ; \
|
|
|
c6d234 |
- mov.w 99f, tmp2 ; \
|
|
|
c6d234 |
- add tmp2, tmp ; \
|
|
|
c6d234 |
- mov.l @tmp, tmp2 ; \
|
|
|
c6d234 |
- bra 98f ; \
|
|
|
c6d234 |
- mov #FUTEX_PRIVATE_FLAG, tmp ; \
|
|
|
c6d234 |
-99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
|
|
|
c6d234 |
-98: extu.b tmp, tmp ; \
|
|
|
c6d234 |
- xor tmp, reg ; \
|
|
|
c6d234 |
- and tmp2, reg
|
|
|
c6d234 |
-# else
|
|
|
c6d234 |
-# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
|
|
|
c6d234 |
- stc gbr, tmp ; \
|
|
|
c6d234 |
- mov.w 99f, tmp2 ; \
|
|
|
c6d234 |
- add tmp2, tmp ; \
|
|
|
c6d234 |
- mov.l @tmp, tmp2 ; \
|
|
|
c6d234 |
- bra 98f ; \
|
|
|
c6d234 |
- mov #FUTEX_PRIVATE_FLAG, tmp ; \
|
|
|
c6d234 |
-99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
|
|
|
c6d234 |
-98: extu.b tmp, tmp ; \
|
|
|
c6d234 |
- xor tmp, reg ; \
|
|
|
c6d234 |
- and tmp2, reg ; \
|
|
|
c6d234 |
- mov #FUTEX_WAIT, tmp ; \
|
|
|
c6d234 |
- or tmp, reg
|
|
|
c6d234 |
-# endif
|
|
|
c6d234 |
-#endif
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_lock_wait
|
|
|
c6d234 |
- .type __lll_robust_lock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_lock_wait
|
|
|
c6d234 |
- .align 5
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
-__lll_robust_lock_wait:
|
|
|
c6d234 |
- mov.l r8, @-r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_rel_offset (r8, 0)
|
|
|
c6d234 |
- mov r5, r8
|
|
|
c6d234 |
- mov #0, r7 /* No timeout. */
|
|
|
c6d234 |
- mov r6, r5
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (r5, r0, r1)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-4:
|
|
|
c6d234 |
- mov r4, r6
|
|
|
c6d234 |
- mov.l .L_FUTEX_WAITERS, r0
|
|
|
c6d234 |
- or r0, r6
|
|
|
c6d234 |
- shlr r0 /* r0 = FUTEX_OWNER_DIED */
|
|
|
c6d234 |
- tst r0, r4
|
|
|
c6d234 |
- bf/s 3f
|
|
|
c6d234 |
- cmp/eq r4, r6
|
|
|
c6d234 |
- bt 1f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- CMPXCHG (r4, @r8, r6, r2)
|
|
|
c6d234 |
- bf 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1:
|
|
|
c6d234 |
- mov r8, r4
|
|
|
c6d234 |
- mov #SYS_futex, r3
|
|
|
c6d234 |
- extu.b r3, r3
|
|
|
c6d234 |
- trapa #0x14
|
|
|
c6d234 |
- SYSCALL_INST_PAD
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- mov.l @r8, r2
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2:
|
|
|
c6d234 |
- tst r2, r2
|
|
|
c6d234 |
- bf/s 4b
|
|
|
c6d234 |
- mov r2, r4
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- stc gbr, r1
|
|
|
c6d234 |
- mov.w .Ltidoff, r2
|
|
|
c6d234 |
- add r2, r1
|
|
|
c6d234 |
- mov.l @r1, r6
|
|
|
c6d234 |
- mov #0, r3
|
|
|
c6d234 |
- CMPXCHG (r3, @r8, r6, r4)
|
|
|
c6d234 |
- bf 4b
|
|
|
c6d234 |
- mov #0, r4
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-3:
|
|
|
c6d234 |
- mov.l @r15+, r8
|
|
|
c6d234 |
- cfi_adjust_cfa_offset (-4)
|
|
|
c6d234 |
- cfi_restore (r8)
|
|
|
c6d234 |
- ret
|
|
|
c6d234 |
- mov r4, r0
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .align 2
|
|
|
c6d234 |
-.L_FUTEX_WAITERS:
|
|
|
c6d234 |
- .long FUTEX_WAITERS
|
|
|
c6d234 |
-.Ltidoff:
|
|
|
c6d234 |
- .word TID - TLS_PRE_TCB_SIZE
|
|
|
c6d234 |
- .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- .globl __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .type __lll_robust_timedlock_wait,@function
|
|
|
c6d234 |
- .hidden __lll_robust_timedlock_wait
|
|
|
c6d234 |
- .align 5
|
|
|
c6d234 |
- cfi_startproc
|
|
|
c6d234 |
-__lll_robust_timedlock_wait:
|
|
|
c6d234 |
- /* Check for a valid timeout value. */
|
|
|
c6d234 |
- mov.l @(4,r6), r1
|
|
|
c6d234 |
- mov.l .L1g, r0
|
|
|
c6d234 |
- cmp/hs r0, r1
|
|
|
c6d234 |
- bt 3f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cfi_remember_state
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- mov.l r11, @-r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_rel_offset (r11, 0)
|
|
|
c6d234 |
- mov.l r10, @-r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_rel_offset (r10, 0)
|
|
|
c6d234 |
- mov.l r9, @-r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_rel_offset (r9, 0)
|
|
|
c6d234 |
- mov.l r8, @-r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(4)
|
|
|
c6d234 |
- cfi_rel_offset (r8, 0)
|
|
|
c6d234 |
- mov r7, r11
|
|
|
c6d234 |
- mov r4, r10
|
|
|
c6d234 |
- mov r6, r9
|
|
|
c6d234 |
- mov r5, r8
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Stack frame for the timespec and timeval structs. */
|
|
|
c6d234 |
- add #-8, r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset(8)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-1:
|
|
|
c6d234 |
- /* Get current time. */
|
|
|
c6d234 |
- mov r15, r4
|
|
|
c6d234 |
- mov #0, r5
|
|
|
c6d234 |
- mov #__NR_gettimeofday, r3
|
|
|
c6d234 |
- trapa #0x12
|
|
|
c6d234 |
- SYSCALL_INST_PAD
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- /* Compute relative timeout. */
|
|
|
c6d234 |
- mov.l @(4,r15), r0
|
|
|
c6d234 |
- mov.w .L1k, r1
|
|
|
c6d234 |
- dmulu.l r0, r1 /* Micro seconds to nano seconds. */
|
|
|
c6d234 |
- mov.l @r9, r2
|
|
|
c6d234 |
- mov.l @(4,r9), r3
|
|
|
c6d234 |
- mov.l @r15, r0
|
|
|
c6d234 |
- sts macl, r1
|
|
|
c6d234 |
- sub r0, r2
|
|
|
c6d234 |
- clrt
|
|
|
c6d234 |
- subc r1, r3
|
|
|
c6d234 |
- bf 4f
|
|
|
c6d234 |
- mov.l .L1g, r1
|
|
|
c6d234 |
- add r1, r3
|
|
|
c6d234 |
- add #-1, r2
|
|
|
c6d234 |
-4:
|
|
|
c6d234 |
- cmp/pz r2
|
|
|
c6d234 |
- bf 8f /* Time is already up. */
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- mov.l r2, @r15 /* Store relative timeout. */
|
|
|
c6d234 |
- mov.l r3, @(4,r15)
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- mov r10, r6
|
|
|
c6d234 |
- mov.l .L_FUTEX_WAITERS2, r0
|
|
|
c6d234 |
- or r0, r6
|
|
|
c6d234 |
- shlr r0 /* r0 = FUTEX_OWNER_DIED */
|
|
|
c6d234 |
- tst r0, r4
|
|
|
c6d234 |
- bf/s 6f
|
|
|
c6d234 |
- cmp/eq r4, r6
|
|
|
c6d234 |
- bt 2f
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- CMPXCHG (r4, @r8, r6, r2)
|
|
|
c6d234 |
- bf/s 5f
|
|
|
c6d234 |
- mov #0, r5
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-2:
|
|
|
c6d234 |
- mov r8, r4
|
|
|
c6d234 |
- mov r11, r5
|
|
|
c6d234 |
- LOAD_FUTEX_WAIT (r5, r0, r1)
|
|
|
c6d234 |
- mov r10, r6
|
|
|
c6d234 |
- mov r15, r7
|
|
|
c6d234 |
- mov #SYS_futex, r3
|
|
|
c6d234 |
- extu.b r3, r3
|
|
|
c6d234 |
- trapa #0x14
|
|
|
c6d234 |
- SYSCALL_INST_PAD
|
|
|
c6d234 |
- mov r0, r5
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- mov.l @r8, r2
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-5:
|
|
|
c6d234 |
- tst r2, r2
|
|
|
c6d234 |
- bf/s 7f
|
|
|
c6d234 |
- mov r2, r10
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- stc gbr, r1
|
|
|
c6d234 |
- mov.w .Ltidoff2, r2
|
|
|
c6d234 |
- add r2, r1
|
|
|
c6d234 |
- mov.l @r1, r4
|
|
|
c6d234 |
- mov #0, r3
|
|
|
c6d234 |
- CMPXCHG (r3, @r8, r4, r10)
|
|
|
c6d234 |
- bf 7f
|
|
|
c6d234 |
- mov #0, r0
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-6:
|
|
|
c6d234 |
- cfi_remember_state
|
|
|
c6d234 |
- add #8, r15
|
|
|
c6d234 |
- cfi_adjust_cfa_offset (-8)
|
|
|
c6d234 |
- mov.l @r15+, r8
|
|
|
c6d234 |
- cfi_adjust_cfa_offset (-4)
|
|
|
c6d234 |
- cfi_restore (r8)
|
|
|
c6d234 |
- mov.l @r15+, r9
|
|
|
c6d234 |
- cfi_adjust_cfa_offset (-4)
|
|
|
c6d234 |
- cfi_restore (r9)
|
|
|
c6d234 |
- mov.l @r15+, r10
|
|
|
c6d234 |
- cfi_adjust_cfa_offset (-4)
|
|
|
c6d234 |
- cfi_restore (r10)
|
|
|
c6d234 |
- rts
|
|
|
c6d234 |
- mov.l @r15+, r11
|
|
|
c6d234 |
- /* Omit CFI for restore in delay slot. */
|
|
|
c6d234 |
- cfi_restore_state
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-7:
|
|
|
c6d234 |
- /* Check whether the time expired. */
|
|
|
c6d234 |
- mov #-ETIMEDOUT, r1
|
|
|
c6d234 |
- cmp/eq r5, r1
|
|
|
c6d234 |
- bf 1b
|
|
|
c6d234 |
-
|
|
|
c6d234 |
-8:
|
|
|
c6d234 |
- bra 6b
|
|
|
c6d234 |
- mov #ETIMEDOUT, r0
|
|
|
c6d234 |
-
|
|
|
c6d234 |
- cfi_restore_state
|
|
|
c6d234 |
-3:
|
|
|
c6d234 |
- rts
|
|
|
c6d234 |
- mov #EINVAL, r0
|
|
|
c6d234 |
- cfi_endproc
|
|
|
c6d234 |
- .align 2
|
|
|
c6d234 |
-.L_FUTEX_WAITERS2:
|
|
|
c6d234 |
- .long FUTEX_WAITERS
|
|
|
c6d234 |
-.L1g:
|
|
|
c6d234 |
- .long 1000000000
|
|
|
c6d234 |
-.Ltidoff2:
|
|
|
c6d234 |
- .word TID - TLS_PRE_TCB_SIZE
|
|
|
c6d234 |
-.L1k:
|
|
|
c6d234 |
- .word 1000
|
|
|
c6d234 |
- .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
|
|
|
c6d234 |
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/Makefile
|
|
|
c6d234 |
===================================================================
|
|
|
c6d234 |
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/Makefile
|
|
|
c6d234 |
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/Makefile
|
|
|
c6d234 |
@@ -24,7 +24,7 @@ libpthread-sysdep_routines += pt-fork pt
|
|
|
c6d234 |
|
|
|
c6d234 |
gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \
|
|
|
c6d234 |
lowlevelbarrier.sym unwindbuf.sym \
|
|
|
c6d234 |
- lowlevelrobustlock.sym pthread-pi-defines.sym
|
|
|
c6d234 |
+ pthread-pi-defines.sym
|
|
|
c6d234 |
endif
|
|
|
c6d234 |
|
|
|
c6d234 |
ifeq ($(subdir),posix)
|