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/sysdeps | |
parent | 1448f3244714a9dabb5240ec18b094f100887d5c (diff) | |
download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.xz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'nptl/sysdeps')
19 files changed, 44 insertions, 44 deletions
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c index 2a9a723ddb..93f93eebd4 100644 --- a/nptl/sysdeps/pthread/createthread.c +++ b/nptl/sysdeps/pthread/createthread.c @@ -56,7 +56,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, PREPARE_CREATE; #endif - if (__builtin_expect (stopped != 0, 0)) + if (__glibc_unlikely (stopped != 0)) /* We make sure the thread does not run far by forcing it to get a lock. We lock it here too so that the new thread cannot continue until we tell it to. */ @@ -75,7 +75,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, int rc = ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags, pd, &pd->tid, TLS_VALUE, &pd->tid); - if (__builtin_expect (rc == -1, 0)) + if (__glibc_unlikely (rc == -1)) { atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second. */ @@ -93,7 +93,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, } /* Now we have the possibility to set scheduling parameters etc. */ - if (__builtin_expect (stopped != 0, 0)) + if (__glibc_unlikely (stopped != 0)) { INTERNAL_SYSCALL_DECL (err); int res = 0; @@ -104,7 +104,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid, attr->cpusetsize, attr->cpuset); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) { /* The operation failed. We have to kill the thread. First send it the cancellation signal. */ @@ -129,7 +129,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, res = INTERNAL_SYSCALL (sched_setscheduler, err, 3, pd->tid, pd->schedpolicy, &pd->schedparam); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) goto err_out; } } @@ -183,7 +183,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, | CLONE_CHILD_CLEARTID | CLONE_SYSVSEM | 0); - if (__builtin_expect (THREAD_GETMEM (THREAD_SELF, report_events), 0)) + if (__glibc_unlikely (THREAD_GETMEM (THREAD_SELF, report_events))) { /* The parent thread is supposed to report events. Check whether the TD_CREATE event is needed, too. */ diff --git a/nptl/sysdeps/pthread/setxid.h b/nptl/sysdeps/pthread/setxid.h index 65a1ce7bf9..76c88e0feb 100644 --- a/nptl/sysdeps/pthread/setxid.h +++ b/nptl/sysdeps/pthread/setxid.h @@ -48,7 +48,7 @@ ({ \ extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\ int __result; \ - if (__builtin_expect (__nptl_setxid != NULL, 0)) \ + if (__glibc_unlikely (__nptl_setxid != NULL)) \ { \ struct xid_command __cmd; \ __cmd.syscall_no = __NR_##name; \ diff --git a/nptl/sysdeps/pthread/timer_create.c b/nptl/sysdeps/pthread/timer_create.c index 359a770c05..461d28e353 100644 --- a/nptl/sysdeps/pthread/timer_create.c +++ b/nptl/sysdeps/pthread/timer_create.c @@ -68,7 +68,7 @@ timer_create (clock_id, evp, timerid) pthread_mutex_lock (&__timer_mutex); newtimer = __timer_alloc (); - if (__builtin_expect (newtimer == NULL, 0)) + if (__glibc_unlikely (newtimer == NULL)) { __set_errno (EAGAIN); goto unlock_bail; @@ -123,7 +123,7 @@ timer_create (clock_id, evp, timerid) thread = __timer_thread_alloc (&newtimer->attr, clock_id); /* Out of luck; no threads are available. */ - if (__builtin_expect (thread == NULL, 0)) + if (__glibc_unlikely (thread == NULL)) { __set_errno (EAGAIN); goto unlock_bail; diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c index cb94ea6c21..9d7bdc5b90 100644 --- a/nptl/sysdeps/pthread/unwind-forcedunwind.c +++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c @@ -42,7 +42,7 @@ pthread_cancel_init (void) void *getcfa; void *handle; - if (__builtin_expect (libgcc_s_handle != NULL, 1)) + if (__glibc_likely (libgcc_s_handle != NULL)) { /* Force gcc to reload all values. */ asm volatile ("" ::: "memory"); @@ -93,7 +93,7 @@ __unwind_freeres (void) void _Unwind_Resume (struct _Unwind_Exception *exc) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -109,7 +109,7 @@ __gcc_personality_v0 (int version, _Unwind_Action actions, struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -125,7 +125,7 @@ _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, void *stop_argument) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -140,7 +140,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); diff --git a/nptl/sysdeps/unix/sysv/linux/getpid.c b/nptl/sysdeps/unix/sysv/linux/getpid.c index f806f2ff87..937b1d4e11 100644 --- a/nptl/sysdeps/unix/sysv/linux/getpid.c +++ b/nptl/sysdeps/unix/sysv/linux/getpid.c @@ -27,10 +27,10 @@ static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval); static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval) { - if (__builtin_expect (oldval == 0, 1)) + if (__glibc_likely (oldval == 0)) { pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid); - if (__builtin_expect (selftid != 0, 1)) + if (__glibc_likely (selftid != 0)) return selftid; } @@ -53,7 +53,7 @@ __getpid (void) pid_t result = INTERNAL_SYSCALL (getpid, err, 0); #else pid_t result = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (result <= 0, 0)) + if (__glibc_unlikely (result <= 0)) result = really_getpid (result); #endif return result; diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c index 5c9ada18a0..c894b1ecda 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c @@ -35,7 +35,7 @@ __lll_robust_lock_wait (int *futex, int private) do { - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) return oldval; int newval = oldval | FUTEX_WAITERS; @@ -72,7 +72,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ - if (__builtin_expect (abstime->tv_sec < 0, 0)) + if (__glibc_unlikely (abstime->tv_sec < 0)) return ETIMEDOUT; do @@ -100,7 +100,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, #endif /* Wait. */ - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) return oldval; int newval = oldval | FUTEX_WAITERS; diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c index 0d20919667..3138ad2c3c 100644 --- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c +++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c @@ -266,7 +266,7 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) /* If we cannot create the netlink socket we cannot provide SIGEV_THREAD support. */ - if (__builtin_expect (netlink_socket == -1, 0)) + if (__glibc_unlikely (netlink_socket == -1)) { __set_errno (ENOSYS); return -1; @@ -299,7 +299,7 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) int retval = INLINE_SYSCALL (mq_notify, 2, mqdes, &se); /* If it failed, free the allocated memory. */ - if (__builtin_expect (retval != 0, 0)) + if (__glibc_unlikely (retval != 0)) free (data.attr); return retval; diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index fe856708a4..ab92c3fc8f 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -306,7 +306,7 @@ extern int __lll_robust_timedlock_wait ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val > 1, 0)) \ + if (__glibc_unlikely (__val > 1)) \ lll_futex_wake (__futex, 1, private); \ })) @@ -314,7 +314,7 @@ extern int __lll_robust_timedlock_wait ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__val & FUTEX_WAITERS)) \ lll_futex_wake (__futex, 1, private); \ })) diff --git a/nptl/sysdeps/unix/sysv/linux/pt-raise.c b/nptl/sysdeps/unix/sysv/linux/pt-raise.c index 68059db8db..74762b749b 100644 --- a/nptl/sysdeps/unix/sysv/linux/pt-raise.c +++ b/nptl/sysdeps/unix/sysv/linux/pt-raise.c @@ -31,7 +31,7 @@ raise (sig) fork function temporarily invalidated the PID field. Adjust for that. */ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (pid < 0, 0)) + if (__glibc_unlikely (pid < 0)) pid = -pid; return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid), diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c index 43e5c02b37..f8957ae17c 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c @@ -40,7 +40,7 @@ __pthread_kill (threadid, signo) if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */ pid_t tid = atomic_forced_read (pd->tid); - if (__builtin_expect (tid <= 0, 0)) + if (__glibc_unlikely (tid <= 0)) /* Not a valid thread handle. */ return ESRCH; diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c index 288d73f8c8..874cf4b578 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c @@ -61,7 +61,7 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize, INTERNAL_SYSCALL_DECL (err); int res; - if (__builtin_expect (__kernel_cpumask_size == 0, 0)) + if (__glibc_unlikely (__kernel_cpumask_size == 0)) { res = __determine_cpumask_size (pd->tid); if (res != 0) diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c index 9c3e73cdea..8dee3a69d2 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c @@ -44,7 +44,7 @@ pthread_sigqueue (threadid, signo, value) if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */ pid_t tid = atomic_forced_read (pd->tid); - if (__builtin_expect (tid <= 0, 0)) + if (__glibc_unlikely (tid <= 0)) /* Not a valid thread handle. */ return ESRCH; diff --git a/nptl/sysdeps/unix/sysv/linux/raise.c b/nptl/sysdeps/unix/sysv/linux/raise.c index 321d9c3543..67c9b1f23e 100644 --- a/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/nptl/sysdeps/unix/sysv/linux/raise.c @@ -50,7 +50,7 @@ raise (sig) /* raise is an async-safe function. It could be called while the fork/vfork function temporarily invalidated the PID field. Adjust for that. */ - if (__builtin_expect (pid <= 0, 0)) + if (__glibc_unlikely (pid <= 0)) pid = (pid & INT_MAX) == 0 ? selftid : -pid; return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h index 80dc90543b..864dcbccc0 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h @@ -233,7 +233,7 @@ static inline void __attribute__ ((always_inline)) __lll_lock (int *futex, int private) { - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 1, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 1, 0))) { if (__builtin_constant_p (private) && private == LLL_PRIVATE) __lll_lock_wait_private (futex); @@ -260,7 +260,7 @@ static inline void __attribute__ ((always_inline)) __lll_cond_lock (int *futex, int private) { - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 2, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 2, 0))) __lll_lock_wait (futex, private); } #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) @@ -278,7 +278,7 @@ __attribute__ ((always_inline)) __lll_timedlock (int *futex, const struct timespec *abstime, int private) { int result = 0; - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 1, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 1, 0))) result = __lll_timedlock_wait (futex, abstime, private); return result; } @@ -307,7 +307,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, int *__futexp = (futex); \ \ lll_compare_and_swap (__futexp, __oldval, __newval, "slr %2,%2"); \ - if (__builtin_expect (__oldval > 1, 0)) \ + if (__glibc_unlikely (__oldval > 1)) \ lll_futex_wake (__futexp, 1, private); \ }) #define lll_unlock(futex, private) __lll_unlock(&(futex), private) @@ -320,7 +320,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, int *__futexp = (futex); \ \ lll_compare_and_swap (__futexp, __oldval, __newval, "slr %2,%2"); \ - if (__builtin_expect (__oldval & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__oldval & FUTEX_WAITERS)) \ lll_futex_wake (__futexp, 1, private); \ }) #define lll_robust_unlock(futex, private) \ diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h index d851d74542..d4ed7a9bd7 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h @@ -223,7 +223,7 @@ __lll_lock (int *futex, int private) { int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0); - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) { if (__builtin_constant_p (private) && private == LLL_PRIVATE) __lll_lock_wait_private (futex); @@ -251,7 +251,7 @@ __lll_cond_lock (int *futex, int private) { int val = atomic_compare_and_exchange_val_24_acq (futex, 2, 0); - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) __lll_lock_wait (futex, private); } #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) @@ -272,7 +272,7 @@ __lll_timedlock (int *futex, const struct timespec *abstime, int private) int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0); int result = 0; - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) result = __lll_timedlock_wait (futex, abstime, private); return result; } @@ -296,7 +296,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_24_rel (__futex, 0); \ - if (__builtin_expect (__val > 1, 0)) \ + if (__glibc_unlikely (__val > 1)) \ lll_futex_wake (__futex, 1, private); \ })) @@ -304,7 +304,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__val & FUTEX_WAITERS)) \ lll_futex_wake (__futex, 1, private); \ })) diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c index 4ce7871fbd..2221a27e22 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c @@ -33,7 +33,7 @@ pthread_barrier_destroy (barrier) lll_lock (ibarrier->b.lock, private); - if (__builtin_expect (ibarrier->b.left == ibarrier->b.init_count, 1)) + if (__glibc_likely (ibarrier->b.left == ibarrier->b.init_count)) /* The barrier is not used anymore. */ result = 0; else diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c index 9bc7a05333..6af686361d 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c @@ -28,7 +28,7 @@ pthread_barrier_init (barrier, attr, count) { union sparc_pthread_barrier *ibarrier; - if (__builtin_expect (count == 0, 0)) + if (__glibc_unlikely (count == 0)) return EINVAL; struct pthread_barrierattr *iattr = (struct pthread_barrierattr *) attr; diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c index d415366f4c..cbefdc4823 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c @@ -32,7 +32,7 @@ __new_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; @@ -66,7 +66,7 @@ __old_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c index e46eef426c..7624f2cdb2 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c @@ -50,7 +50,7 @@ __timer_create_old (clockid_t clock_id, struct sigevent *evp, int *timerid) break; } - if (__builtin_expect (i == OLD_TIMER_MAX, 0)) + if (__glibc_unlikely (i == OLD_TIMER_MAX)) { /* No free slot. */ (void) __timer_delete_new (newp); |