diff options
| author | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 14:45:42 +0100 |
|---|---|---|
| committer | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 15:07:12 +0100 |
| commit | a1ffb40e32741f992c743e7b16c061fefa3747ac (patch) | |
| tree | 246a29a87b26cfd5d07b17070f85eb3785018de9 /nptl | |
| parent | 1448f3244714a9dabb5240ec18b094f100887d5c (diff) | |
| download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.xz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip | |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'nptl')
54 files changed, 202 insertions, 129 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 474a473bf8..f7241c51e4 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,76 @@ +2014-02-10 Ondřej Bílka <neleai@seznam.cz> + + * allocatestack.c (queue_stack, allocate_stack, + __deallocate_stack, __reclaim_stacks): Use glibc_likely instead + __builtin_expect. + * cancellation.c (__pthread_enable_asynccancel, + __pthread_disable_asynccancel): Likewise. + * cleanup_defer.c (__pthread_register_cancel_defer, + __pthread_unregister_cancel_restore): Likewise. + * cleanup_defer_compat.c (_pthread_cleanup_push_defer, + _pthread_cleanup_pop_restore): Likewise. + * cond-perf.c (main): Likewise. + * nptl-init.c (sigcancel_handler, sighandler_setxid): Likewise. + * perf.c (get_clockfreq): Likewise. + * pthread_barrier_destroy.c (pthread_barrier_destroy): Likewise. + * pthread_barrier_init.c (pthread_barrier_init): Likewise. + * pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise. + * pthread_cond_wait.c (__pthread_cond_wait): Likewise. + * pthread_create.c (__free_tcb, start_thread, __pthread_create_2_1): + Likewise. + * pthread_getattr_np.c (pthread_getattr_np): Likewise. + * pthread_getspecific.c (__pthread_getspecific): Likewise. + * pthread_join.c (pthread_join): Likewise. + * pthread_key_delete.c (pthread_key_delete): Likewise. + * pthread_mutex_init.c (__pthread_mutex_init): Likewise. + * pthread_mutex_lock.c (__pthread_mutex_lock, + __pthread_mutex_lock_full): Likewise. + * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise. + * pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise. + * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise. + * pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Likewise. + * pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock): Likewise. + * pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock): Likewise. + * pthread_rwlock_tryrdlock.c (__pthread_rwlock_tryrdlock): Likewise. + * pthread_setcancelstate.c (__pthread_setcancelstate): Likewise. + * pthread_setcanceltype.c (__pthread_setcanceltype): Likewise. + * pthread_setschedprio.c (pthread_setschedprio): Likewise. + * pthread_setspecific.c (__pthread_setspecific): Likewise. + * sem_init.c (__new_sem_init): Likewise. + * sem_open.c (__where_is_shmfs): Likewise. + * sigaction.c: Likewise. + * sockperf.c (get_clockfreq): Likewise. + * sysdeps/pthread/createthread.c (do_clone, create_thread): Likewise. + * sysdeps/pthread/setxid.h: Likewise. + * sysdeps/pthread/timer_create.c (timer_create): Likewise. + * sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init, + __unwind_freeres, _Unwind_Resume, __gcc_personality_v0, + _Unwind_ForcedUnwind): Likewise. + * sysdeps/unix/sysv/linux/getpid.c (__getpid): Likewise. + * sysdeps/unix/sysv/linux/lowlevelrobustlock.c + (__lll_robust_lock_wait, __lll_robust_timedlock_wait): Likewise. + * sysdeps/unix/sysv/linux/mq_notify.c (mq_notify): Likewise. + * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise. + * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise. + * sysdeps/unix/sysv/linux/pthread_setaffinity.c + (__pthread_setaffinity_new): Likewise. + * sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue): + Likewise. + * sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/s390/lowlevellock.h (__lll_robust_trylock, + __lll_robust_lock, __lll_cond_lock, __lll_robust_timedlock): Likewise. + * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_lock, + __lll_cond_lock, __lll_timedlock, __lll_robust_timedlock): Likewise. + * sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c + (pthread_barrier_destroy): Likewise. + * sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c + (pthread_barrier_init): Likewise. + * sysdeps/unix/sysv/linux/sparc/sem_init.c (__new_sem_init): Likewise. + * sysdeps/unix/sysv/linux/x86_64/timer_create.c (__timer_create_old): + Likewise. + * unwind.c (unwind_stop): Likewise. + 2014-02-08 Mike Frysinger <vapier@gentoo.org> * sem_open.c (__where_is_shmfs): Compare f.f_type to RAMFS_MAGIC too. diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 13eca47cf2..1e22f7da90 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -306,7 +306,7 @@ queue_stack (struct pthread *stack) stack_list_add (&stack->list, &stack_cache); stack_cache_actsize += stack->stackblock_size; - if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0)) + if (__glibc_unlikely (stack_cache_actsize > stack_cache_maxsize)) __free_stacks (stack_cache_maxsize); } @@ -368,7 +368,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, } /* Get memory for the stack. */ - if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0)) + if (__glibc_unlikely (attr->flags & ATTR_FLAG_STACKADDR)) { uintptr_t adj; @@ -504,7 +504,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, mem = mmap (NULL, size, prot, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); - if (__builtin_expect (mem == MAP_FAILED, 0)) + if (__glibc_unlikely (mem == MAP_FAILED)) return errno; /* SIZE is guaranteed to be greater than zero. @@ -525,7 +525,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* Make sure the coloring offsets does not disturb the alignment of the TCB and static TLS block. */ - if (__builtin_expect ((coloring & __static_tls_align_m1) != 0, 0)) + if (__glibc_unlikely ((coloring & __static_tls_align_m1) != 0)) coloring = (((coloring + __static_tls_align_m1) & ~(__static_tls_align_m1)) & ~pagesize_m1); @@ -629,7 +629,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, } /* Create or resize the guard area if necessary. */ - if (__builtin_expect (guardsize > pd->guardsize, 0)) + if (__glibc_unlikely (guardsize > pd->guardsize)) { #ifdef NEED_SEPARATE_REGISTER_STACK char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1); @@ -752,7 +752,7 @@ __deallocate_stack (struct pthread *pd) not reset the 'used' flag in the 'tid' field. This is done by the kernel. If no thread has been created yet this field is still zero. */ - if (__builtin_expect (! pd->user_stack, 1)) + if (__glibc_likely (! pd->user_stack)) (void) queue_stack (pd); else /* Free the memory associated with the ELF TLS. */ @@ -916,7 +916,7 @@ __reclaim_stacks (void) INIT_LIST_HEAD (&stack_used); INIT_LIST_HEAD (&__stack_user); - if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0)) + if (__glibc_unlikely (THREAD_GETMEM (self, user_stack))) list_add (&self->list, &__stack_user); else list_add (&self->list, &stack_used); diff --git a/nptl/cancellation.c b/nptl/cancellation.c index bddea1f3fa..aaf102dd0f 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -40,7 +40,7 @@ __pthread_enable_asynccancel (void) int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) { if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) { @@ -79,7 +79,7 @@ __pthread_disable_asynccancel (int oldtype) int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) break; /* Prepare the next round. */ diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c index 4049497155..a8fc40304e 100644 --- a/nptl/cleanup_defer.c +++ b/nptl/cleanup_defer.c @@ -34,14 +34,14 @@ __pthread_register_cancel_defer (__pthread_unwind_buf_t *buf) int cancelhandling = THREAD_GETMEM (self, cancelhandling); /* Disable asynchronous cancellation for now. */ - if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0)) + if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK)) while (1) { int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, cancelhandling & ~CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; @@ -78,7 +78,7 @@ __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf) cancelhandling | CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; diff --git a/nptl/cleanup_defer_compat.c b/nptl/cleanup_defer_compat.c index b57fd4e285..9c52f5fc53 100644 --- a/nptl/cleanup_defer_compat.c +++ b/nptl/cleanup_defer_compat.c @@ -34,14 +34,14 @@ _pthread_cleanup_push_defer (buffer, routine, arg) int cancelhandling = THREAD_GETMEM (self, cancelhandling); /* Disable asynchronous cancellation for now. */ - if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0)) + if (__glibc_unlikely |
