Selaa lähdekoodia

libc: switch several users to unlikely()

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 11 vuotta sitten
vanhempi
commit
d1e5115772

+ 1 - 1
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;				\

+ 1 - 1
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;				\

+ 2 - 2
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
 		))
 	{

+ 4 - 4
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
 		))
 	{

+ 2 - 4
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; 						    \
 	}								    \

+ 3 - 3
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 ()

+ 1 - 1
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)
 

+ 2 - 2
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);		      \