[git commit] libc: switch several users to unlikely()

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Mar 14 21:49:25 UTC 2013


commit: http://git.uclibc.org/uClibc/commit/?id=d1e51157725a4defd46c298ce1026d0f5d48da3c
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/sysdeps/linux/arm/sysdep.h               |    2 +-
 libc/sysdeps/linux/c6x/bits/syscalls.h        |    2 +-
 libc/sysdeps/linux/common/__rt_sigtimedwait.c |    4 ++--
 libc/sysdeps/linux/common/sigprocmask.c       |    8 ++++----
 libc/sysdeps/linux/frv/bits/syscalls.h        |    6 ++----
 libc/sysdeps/linux/ia64/bits/atomic.h         |    6 +++---
 libc/sysdeps/linux/powerpc/bits/syscalls.h    |    2 +-
 libc/sysdeps/linux/sparc/bits/atomic.h        |    4 ++--
 8 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h
index 467f291..d4a86d3 100644
--- a/libc/sysdeps/linux/arm/sysdep.h
+++ b/libc/sysdeps/linux/arm/sysdep.h
@@ -253,7 +253,7 @@ __local_syscall_error:						\
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)					\
   ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ), 0))	\
+     if (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, )))	\
        {									\
 	 __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, ));		\
 	 _inline_sys_result = (unsigned int) -1;				\
diff --git a/libc/sysdeps/linux/c6x/bits/syscalls.h b/libc/sysdeps/linux/c6x/bits/syscalls.h
index 1bebb00..70b708d 100644
--- a/libc/sysdeps/linux/c6x/bits/syscalls.h
+++ b/libc/sysdeps/linux/c6x/bits/syscalls.h
@@ -37,7 +37,7 @@
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				\
   ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ), 0))	\
+     if (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, )))	\
        {								\
 	 __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, ));		\
 	 _inline_sys_result = (unsigned int) -1;				\
diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
index b45f5df..422a952 100644
--- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c
+++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
@@ -28,9 +28,9 @@ int __NC(sigtimedwait)(const sigset_t *set, siginfo_t *info,
 # ifdef SIGCANCEL
 	sigset_t tmpset;
 
-	if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+	if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
 #  ifdef SIGSETXID
-		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+		|| unlikely (__sigismember (set, SIGSETXID))
 #  endif
 		))
 	{
diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c
index 6eaf5fb..efe440f 100644
--- a/libc/sysdeps/linux/common/sigprocmask.c
+++ b/libc/sysdeps/linux/common/sigprocmask.c
@@ -35,9 +35,9 @@ int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
 	 * The only thing we have to make sure here is that SIGCANCEL and
 	 * SIGSETXID are not blocked.
 	 */
-	if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+	if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
 # ifdef SIGSETXID
-		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+		|| unlikely (__sigismember (set, SIGSETXID))
 # endif
 		))
 	{
@@ -70,9 +70,9 @@ int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
 	 * The only thing we have to make sure here is that SIGCANCEL and
 	 * SIGSETXID are not blocked.
 	 */
-	if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+	if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
 # ifdef SIGSETXID
-		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+		|| unlikely (__sigismember (set, SIGSETXID))
 # endif
 		))
 	{
diff --git a/libc/sysdeps/linux/frv/bits/syscalls.h b/libc/sysdeps/linux/frv/bits/syscalls.h
index eea3050..b1f5320 100644
--- a/libc/sysdeps/linux/frv/bits/syscalls.h
+++ b/libc/sysdeps/linux/frv/bits/syscalls.h
@@ -15,8 +15,7 @@
 # define __syscall_return(type, res) \
 do { \
         unsigned long __sr2 = (res);		    			    \
-	if (__builtin_expect ((unsigned long)(__sr2)			    \
-			      >= (unsigned long)(-4095), 0)) {		    \
+	if (unlikely ((unsigned long)(__sr2) >= (unsigned long)(-4095))) {  \
 		extern int __syscall_error (int);			    \
 		return (type) __syscall_error (__sr2);		    	    \
 	}								    \
@@ -26,8 +25,7 @@ do { \
 # define __syscall_return(type, res) \
 do { \
         unsigned long __sr2 = (res);		    			    \
-	if (__builtin_expect ((unsigned long)(__sr2)			    \
-			      >= (unsigned long)(-4095), 0)) {		    \
+	if (unlikely ((unsigned long)(__sr2) >= (unsigned long)(-4095))) {  \
 		__set_errno (-__sr2);				    	    \
 		__sr2 = -1; 						    \
 	}								    \
diff --git a/libc/sysdeps/linux/ia64/bits/atomic.h b/libc/sysdeps/linux/ia64/bits/atomic.h
index d719f0e..1b6ee2b 100644
--- a/libc/sysdeps/linux/ia64/bits/atomic.h
+++ b/libc/sysdeps/linux/ia64/bits/atomic.h
@@ -91,12 +91,12 @@ typedef uintmax_t uatomic_max_t;
      do									      \
        {								      \
 	 __oldval = __val;						      \
-	 if (__builtin_expect (__val <= 0, 0))				      \
+	 if (unlikely (__val <= 0))					      \
 	   break;							      \
 	 __val = atomic_compare_and_exchange_val_acq (__memp,	__oldval - 1, \
 						      __oldval);	      \
        }								      \
-     while (__builtin_expect (__val != __oldval, 0));			      \
+     while (unlikely (__val != __oldval));				      \
      __oldval; })
 
 #define atomic_bit_test_set(mem, bit) \
@@ -112,7 +112,7 @@ typedef uintmax_t uatomic_max_t;
 						      __oldval | __mask,      \
 						      __oldval);	      \
        }								      \
-     while (__builtin_expect (__val != __oldval, 0));			      \
+     while (unlikely (__val != __oldval));				      \
      __oldval & __mask; })
 
 #define atomic_full_barrier() __sync_synchronize ()
diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h
index 026bbf2..c52d5dd 100644
--- a/libc/sysdeps/linux/powerpc/bits/syscalls.h
+++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h
@@ -167,7 +167,7 @@
   }) \
 )
 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
+  ((void) (val), unlikely ((err) & (1 << 28)))
 
 # define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
 
diff --git a/libc/sysdeps/linux/sparc/bits/atomic.h b/libc/sysdeps/linux/sparc/bits/atomic.h
index 7c2caba..4941c03 100644
--- a/libc/sysdeps/linux/sparc/bits/atomic.h
+++ b/libc/sysdeps/linux/sparc/bits/atomic.h
@@ -289,11 +289,11 @@ volatile unsigned char __sparc32_atomic_locks[64]
 	 __typeof (*(mem)) __acev_wval = (newval);		      \
 	 do							      \
 	   __acev_wret = *__acev_wmemp;				      \
-	 while (__builtin_expect				      \
+	 while (unlikely					      \
 		  (__v9_compare_and_exchange_val_32_acq (__acev_wmemp,\
 							 __acev_wval, \
 							 __acev_wret) \
-		   != __acev_wret, 0));				      \
+		   != __acev_wret));				      \
        }							      \
      else							      \
        __acev_wret = __v7_exchange_acq (mem, newval);		      \


More information about the uClibc-cvs mailing list