View | Details | Raw Unified | Return to bug 21083
Collapse All | Expand All

(-)nptl/pthread_mutex_timedlock.c.orig (-18 / +18 lines)
Lines 224-229 pthread_mutex_timedlock (pthread_mutex_t Link Here
224
	  if (__glibc_unlikely (abstime->tv_sec < 0))
224
	  if (__glibc_unlikely (abstime->tv_sec < 0))
225
	    return ETIMEDOUT;
225
	    return ETIMEDOUT;
226
226
227
	  /* We cannot acquire the mutex nor has its owner died.  Thus, try
228
	     to block using futexes.  Set FUTEX_WAITERS if necessary so that
229
	     other threads are aware that there are potentially threads
230
	     blocked on the futex.  Restart if oldval changed in the
231
	     meantime.  */
232
	  if ((oldval & FUTEX_WAITERS) == 0)
233
	    {
234
	      if (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock,
235
							oldval | FUTEX_WAITERS,
236
							oldval)
237
		  != 0)
238
		{
239
		  oldval = mutex->__data.__lock;
240
		  continue;
241
		}
242
	      oldval |= FUTEX_WAITERS;
243
	    }
244
227
#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME   || !defined lll_futex_timed_wait_bitset)
245
#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME   || !defined lll_futex_timed_wait_bitset)
228
	  struct timeval tv;
246
	  struct timeval tv;
229
	  struct timespec rt;
247
	  struct timespec rt;
Lines 245-268 pthread_mutex_timedlock (pthread_mutex_t Link Here
245
	    return ETIMEDOUT;
263
	    return ETIMEDOUT;
246
#endif
264
#endif
247
265
248
	  /* We cannot acquire the mutex nor has its owner died.  Thus, try
249
	     to block using futexes.  Set FUTEX_WAITERS if necessary so that
250
	     other threads are aware that there are potentially threads
251
	     blocked on the futex.  Restart if oldval changed in the
252
	     meantime.  */
253
	  if ((oldval & FUTEX_WAITERS) == 0)
254
	    {
255
	      if (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock,
256
							oldval | FUTEX_WAITERS,
257
							oldval)
258
		  != 0)
259
		{
260
		  oldval = mutex->__data.__lock;
261
		  continue;
262
		}
263
	      oldval |= FUTEX_WAITERS;
264
	    }
265
266
	  /* It is now possible that we share the FUTEX_WAITERS flag with
266
	  /* It is now possible that we share the FUTEX_WAITERS flag with
267
	     another thread; therefore, update assume_other_futex_waiters so
267
	     another thread; therefore, update assume_other_futex_waiters so
268
	     that we do not forget about this when handling other cases
268
	     that we do not forget about this when handling other cases

Return to bug 21083