2016-06-03 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ * nptl/pthreadP.h (prio_inherit_missing): Change name to
+ __prio_inherit_missing.
+ (USE_REQUEUE_PI): Remove define.
+ (use_requeue_pi): New function.
+ * nptl/pthread_cond_broadcast.c [__ASSUME_REQUEUE_PI]
+ (__pthread_cond_broadcast): Remove ifdef.
+ (USE_REQUEUE_PI): Change to use_requeue_pi.
+ * nptl/pthread_cond_signal.c [__ASSUME_REQUEUE_PI]
+ (__pthread_cond_signal): Remove ifdef.
+ (USE_REQUEUE_PI): Change to use_requeue_pi.
+ * nptl/pthread_cond_timedwait.c [__ASSUME_REQUEUE_PI]
+ (__pthread_cond_timedwait): Remove ifdef.
+ (USE_REQUEUE_PI): Change to use_requeue_pi.
+ ( nptl/pthread_cond_wait.c [__ASSUME_REQUEUE_PI]
+ (__pthread_cond_wait): Remove ifdef.
+ (USE_REQUEUE_PI): Change to use_requeue_pi.
+ * nptl/pthread_mutex_init.c (prio_inherit_missing): Remove 'static'
+ qualifier and change name to __prio_inherit_missing.
+
* nptl/nptl-init.c [__ASSUME_SET_ROBUST_LIST]
(__set_robust_list_avail): Remove define.
[__NR_set_robust_list] (__pthread_initialize_minimal_internal):
# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
#endif
+extern bool __prio_inherit_missing (void);
+
/* Test if the mutex is suitable for the FUTEX_WAIT_REQUEUE_PI operation. */
-#if (defined lll_futex_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
-# define USE_REQUEUE_PI(mut) \
- ((mut) && (mut) != (void *) ~0l \
- && (((mut)->__data.__kind \
- & (PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP)) \
- == PTHREAD_MUTEX_PRIO_INHERIT_NP))
-#else
-# define USE_REQUEUE_PI(mut) 0
+static inline bool
+use_requeue_pi (pthread_mutex_t *mut)
+{
+#ifndef __ASSUME_REQUEUE_PI
+ if (__prio_inherit_missing ())
+ return false;
#endif
+ return (mut) &&
+ (mut) != (void *) ~0l &&
+ (((mut)->__data.__kind
+ & (PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP)) ==
+ PTHREAD_MUTEX_PRIO_INHERIT_NP);
+}
/* Returns 0 if POL is a valid scheduling policy. */
static inline int
|| PTHREAD_MUTEX_PSHARED (mut) & PTHREAD_MUTEX_PSHARED_BIT)
goto wake_all;
-#if (defined lll_futex_cmp_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
- if (USE_REQUEUE_PI (mut))
+#ifdef lll_futex_cmp_requeue_pi
+ if (use_requeue_pi (mut))
{
if (lll_futex_cmp_requeue_pi (&cond->__data.__futex, 1, INT_MAX,
&mut->__data.__lock, futex_val,
++cond->__data.__wakeup_seq;
++cond->__data.__futex;
-#if (defined lll_futex_cmp_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_cmp_requeue_pi
pthread_mutex_t *mut = cond->__data.__mutex;
- if (USE_REQUEUE_PI (mut)
+ if (use_requeue_pi (mut)
/* This can only really fail with a ENOSYS, since nobody can modify
futex while we have the cond_lock. */
&& lll_futex_cmp_requeue_pi (&cond->__data.__futex, 1, 0,
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
-#if (defined lll_futex_timed_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_timed_wait_requeue_pi
int pi_flag = 0;
#endif
/* REQUEUE_PI was implemented after FUTEX_CLOCK_REALTIME, so it is sufficient
to check just the former. */
-#if (defined lll_futex_timed_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_timed_wait_requeue_pi
/* If pi_flag remained 1 then it means that we had the lock and the mutex
but a spurious waker raced ahead of us. Give back the mutex before
going into wait again. */
__pthread_mutex_cond_lock_adjust (mutex);
__pthread_mutex_unlock_usercnt (mutex, 0);
}
- pi_flag = USE_REQUEUE_PI (mutex);
+ pi_flag = use_requeue_pi (mutex);
if (pi_flag)
{
__pthread_cleanup_pop (&buffer, 0);
/* Get the mutex before returning. */
-#if (defined lll_futex_timed_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_timed_wait_requeue_pi
if (pi_flag)
{
__pthread_mutex_cond_lock_adjust (mutex);
/* Get the mutex before returning unless asynchronous cancellation
is in effect. We don't try to get the mutex if we already own it. */
- if (!(USE_REQUEUE_PI (cbuffer->mutex))
+ if (!(use_requeue_pi (cbuffer->mutex))
|| ((cbuffer->mutex->__data.__lock & FUTEX_TID_MASK)
!= THREAD_GETMEM (THREAD_SELF, tid)))
{
int pshared = (cond->__data.__mutex == (void *) ~0l)
? LLL_SHARED : LLL_PRIVATE;
-#if (defined lll_futex_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_wait_requeue_pi
int pi_flag = 0;
#endif
/* Enable asynchronous cancellation. Required by the standard. */
cbuffer.oldtype = __pthread_enable_asynccancel ();
-#if (defined lll_futex_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_wait_requeue_pi
/* If pi_flag remained 1 then it means that we had the lock and the mutex
but a spurious waker raced ahead of us. Give back the mutex before
going into wait again. */
__pthread_mutex_cond_lock_adjust (mutex);
__pthread_mutex_unlock_usercnt (mutex, 0);
}
- pi_flag = USE_REQUEUE_PI (mutex);
+ pi_flag = use_requeue_pi (mutex);
if (pi_flag)
{
__pthread_cleanup_pop (&buffer, 0);
/* Get the mutex before returning. Not needed for PI. */
-#if (defined lll_futex_wait_requeue_pi \
- && defined __ASSUME_REQUEUE_PI)
+#ifdef lll_futex_wait_requeue_pi
if (pi_flag)
{
__pthread_mutex_cond_lock_adjust (mutex);
};
-static bool
-prio_inherit_missing (void)
+bool
+attribute_hidden
+__prio_inherit_missing (void)
{
#ifdef __NR_futex
static int tpi_supported;
break;
case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
- if (__glibc_unlikely (prio_inherit_missing ()))
+ if (__glibc_unlikely (__prio_inherit_missing ()))
return ENOTSUP;
break;