Пример #1
0
int
__lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
{
  if (*adapt_count > 0)
    {
      goto use_lock;
    }

  for (int i = aconf.try_tbegin; i > 0; i--)
    {
      if (__libc_tbegin (0))
	{
	  if (*lock == 0)
	    return 0;
	  /* Lock was busy.  Fall back to normal locking.  */
	  __libc_tabort (_ABORT_LOCK_BUSY);
	}
      else
	{
	  /* A persistent failure indicates that a retry will probably
	     result in another failure.  Use normal locking now and
	     for the next couple of calls.  */
	  if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
	    {
	      if (aconf.skip_lock_internal_abort > 0)
		*adapt_count = aconf.skip_lock_internal_abort;
	      goto use_lock;
	    }
	}
     }

  /* Fall back to locks for a bit if retries have been exhausted */
  if (aconf.try_tbegin > 0 && aconf.skip_lock_out_of_tbegin_retries > 0)
    *adapt_count = aconf.skip_lock_out_of_tbegin_retries;

use_lock:
  return LLL_LOCK ((*lock), pshared);
}
Пример #2
0
long failure_code(void)
{
	return __builtin_get_texasru() >> 24;
}