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 /sysdeps | |
parent | Fix previous commit. (diff) | |
download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.bz2 glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'sysdeps')
121 files changed, 341 insertions, 341 deletions
diff --git a/sysdeps/gnu/unwind-resume.c b/sysdeps/gnu/unwind-resume.c index 8963bf6deb..c7d6870731 100644 --- a/sysdeps/gnu/unwind-resume.c +++ b/sysdeps/gnu/unwind-resume.c @@ -46,7 +46,7 @@ init (void) void _Unwind_Resume (struct _Unwind_Exception *exc) { - if (__builtin_expect (libgcc_s_resume == NULL, 0)) + if (__glibc_unlikely (libgcc_s_resume == NULL)) init (); libgcc_s_resume (exc); } @@ -57,7 +57,7 @@ __gcc_personality_v0 (int version, _Unwind_Action actions, struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_personality == NULL, 0)) + if (__glibc_unlikely (libgcc_s_personality == NULL)) init (); return libgcc_s_personality (version, actions, exception_class, ue_header, context); diff --git a/sysdeps/i386/dl-irel.h b/sysdeps/i386/dl-irel.h index 6eb3495f88..4cf81ee207 100644 --- a/sysdeps/i386/dl-irel.h +++ b/sysdeps/i386/dl-irel.h @@ -39,7 +39,7 @@ elf_irel (const Elf32_Rel *reloc) Elf32_Addr *const reloc_addr = (void *) reloc->r_offset; const unsigned long int r_type = ELF32_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_386_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_386_IRELATIVE)) { Elf32_Addr value = elf_ifunc_invoke(*reloc_addr); *reloc_addr = value; diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 917550c64f..368bee2164 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -123,7 +123,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) to intercept the calls to collect information. In this case we don't store the address in the GOT so that all future calls also end in this function. */ - if (__builtin_expect (profile, 0)) + if (__glibc_unlikely (profile)) { got[2] = (Elf32_Addr) &_dl_runtime_profile; @@ -308,7 +308,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); # if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_386_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_386_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; @@ -325,7 +325,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, *reloc_addr += map->l_addr; } # ifndef RTLD_BOOTSTRAP - else if (__builtin_expect (r_type == R_386_NONE, 0)) + else if (__glibc_unlikely (r_type == R_386_NONE)) return; # endif else @@ -660,7 +660,7 @@ elf_machine_lazy_rel (struct link_map *map, Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); /* Check for unexpected PLT reloc type. */ - if (__builtin_expect (r_type == R_386_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_386_JMP_SLOT)) { if (__builtin_expect (map->l_mach.plt, 0) == 0) *reloc_addr += l_addr; @@ -668,7 +668,7 @@ elf_machine_lazy_rel (struct link_map *map, *reloc_addr = (map->l_mach.plt + (((Elf32_Addr) reloc_addr) - map->l_mach.gotplt) * 4); } - else if (__builtin_expect (r_type == R_386_TLS_DESC, 1)) + else if (__glibc_likely (r_type == R_386_TLS_DESC)) { struct tlsdesc volatile * __attribute__((__unused__)) td = (struct tlsdesc volatile *)reloc_addr; @@ -715,10 +715,10 @@ elf_machine_lazy_rel (struct link_map *map, # endif } } - else if (__builtin_expect (r_type == R_386_IRELATIVE, 0)) + else if (__glibc_unlikely (r_type == R_386_IRELATIVE)) { Elf32_Addr value = map->l_addr + *reloc_addr; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = ((Elf32_Addr (*) (void)) value) (); *reloc_addr = value; } @@ -736,9 +736,9 @@ elf_machine_lazy_rela (struct link_map *map, { Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_386_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_386_JMP_SLOT)) ; - else if (__builtin_expect (r_type == R_386_TLS_DESC, 1)) + else if (__glibc_likely (r_type == R_386_TLS_DESC)) { struct tlsdesc volatile * __attribute__((__unused__)) td = (struct tlsdesc volatile *)reloc_addr; @@ -746,10 +746,10 @@ elf_machine_lazy_rela (struct link_map *map, td->arg = (void*)reloc; td->entry = _dl_tlsdesc_resolve_rela; } - else if (__builtin_expect (r_type == R_386_IRELATIVE, 0)) + else if (__glibc_unlikely (r_type == R_386_IRELATIVE)) { Elf32_Addr value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = ((Elf32_Addr (*) (void)) value) (); *reloc_addr = value; } diff --git a/sysdeps/ieee754/dbl-64/e_atanh.c b/sysdeps/ieee754/dbl-64/e_atanh.c index 21bb9908d1..0f96743390 100644 --- a/sysdeps/ieee754/dbl-64/e_atanh.c +++ b/sysdeps/ieee754/dbl-64/e_atanh.c @@ -48,7 +48,7 @@ __ieee754_atanh (double x) double t; if (isless (xa, 0.5)) { - if (__builtin_expect (xa < 0x1.0p-28, 0)) + if (__glibc_unlikely (xa < 0x1.0p-28)) { math_force_eval (huge + x); return x; @@ -57,7 +57,7 @@ __ieee754_atanh (double x) t = xa + xa; t = 0.5 * __log1p (t + t * xa / (1.0 - xa)); } - else if (__builtin_expect (isless (xa, 1.0), 1)) + else if (__glibc_likely (isless (xa, 1.0))) t = 0.5 * __log1p ((xa + xa) / (1.0 - xa)); else { diff --git a/sysdeps/ieee754/dbl-64/e_exp2.c b/sysdeps/ieee754/dbl-64/e_exp2.c index 10e23e2218..588fbfdee8 100644 --- a/sysdeps/ieee754/dbl-64/e_exp2.c +++ b/sysdeps/ieee754/dbl-64/e_exp2.c @@ -43,10 +43,10 @@ __ieee754_exp2 (double x) static const double lomark = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1); /* Check for usual case. */ - if (__builtin_expect (isless (x, himark), 1)) + if (__glibc_likely (isless (x, himark))) { /* Exceptional cases: */ - if (__builtin_expect (!isgreaterequal (x, lomark), 0)) + if (__glibc_unlikely (!isgreaterequal (x, lomark))) { if (__isinf (x)) /* e^-inf == 0, with no error. */ diff --git a/sysdeps/ieee754/dbl-64/e_fmod.c b/sysdeps/ieee754/dbl-64/e_fmod.c index c83c2aedb2..e82b302200 100644 --- a/sysdeps/ieee754/dbl-64/e_fmod.c +++ b/sysdeps/ieee754/dbl-64/e_fmod.c @@ -45,7 +45,7 @@ __ieee754_fmod (double x, double y) } /* determine ix = ilogb(x) */ - if (__builtin_expect (hx < 0x00100000, 0)) /* subnormal x */ + if (__glibc_unlikely (hx < 0x00100000)) /* subnormal x */ { if (hx == 0) { @@ -62,7 +62,7 @@ __ieee754_fmod (double x, double y) ix = (hx >> 20) - 1023; /* determine iy = ilogb(y) */ - if (__builtin_expect (hy < 0x00100000, 0)) /* subnormal y */ + if (__glibc_unlikely (hy < 0x00100000)) /* subnormal y */ { if (hy == 0) { @@ -79,7 +79,7 @@ __ieee754_fmod (double x, double y) iy = (hy >> 20) - 1023; /* set up {hx,lx}, {hy,ly} and align y to x */ - if (__builtin_expect (ix >= -1022, 1)) + if (__glibc_likely (ix >= -1022)) hx = 0x00100000 | (0x000fffff & hx); else /* subnormal x, shift x to normal */ { @@ -95,7 +95,7 @@ __ieee754_fmod (double x, double y) lx = 0; } } - if (__builtin_expect (iy >= -1022, 1)) + if (__glibc_likely (iy >= -1022)) hy = 0x00100000 | (0x000fffff & hy); else /* subnormal y, shift y to normal */ { @@ -144,7 +144,7 @@ __ieee754_fmod (double x, double y) hx = hx + hx + (lx >> 31); lx = lx + lx; iy -= 1; } - if (__builtin_expect (iy >= -1022, 1)) /* normalize output */ + if (__glibc_likely (iy >= -1022)) /* normalize output */ { hx = ((hx - 0x00100000) | ((iy + 1023) << 20)); INSERT_WORDS (x, hx | sx, lx); diff --git a/sysdeps/ieee754/dbl-64/e_gamma_r.c b/sysdeps/ieee754/dbl-64/e_gamma_r.c index 1c427556bc..a35a9e5608 100644 --- a/sysdeps/ieee754/dbl-64/e_gamma_r.c +++ b/sysdeps/ieee754/dbl-64/e_gamma_r.c @@ -122,7 +122,7 @@ __ieee754_gamma_r (double x, int *signgamp) EXTRACT_WORDS (hx, lx, x); - if (__builtin_expect (((hx & 0x7fffffff) | lx) == 0, 0)) + if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0)) { /* Return value for x == 0 is Inf with divide by zero exception. */ *signgamp = 0; @@ -135,13 +135,13 @@ __ieee754_gamma_r (double x, int *signgamp) *signgamp = 0; return (x - x) / (x - x); } - if (__builtin_expect ((unsigned int) hx == 0xfff00000 && lx == 0, 0)) + if (__glibc_unlikely ((unsigned int) hx == 0xfff00000 && lx == 0)) { /* x == -Inf. According to ISO this is NaN. */ *signgamp = 0; return x - x; } - if (__builtin_expect ((hx & 0x7ff00000) == 0x7ff00000, 0)) + if (__glibc_unlikely ((hx & 0x7ff00000) == 0x7ff00000)) { /* Positive infinity (return positive infinity) or NaN (return NaN). */ diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c index 88242bc4f6..5cbfcbeb48 100644 --- a/sysdeps/ieee754/dbl-64/e_hypot.c +++ b/sysdeps/ieee754/dbl-64/e_hypot.c @@ -70,7 +70,7 @@ __ieee754_hypot (double x, double y) return a + b; } /* x/y > 2**60 */ k = 0; - if (__builtin_expect (ha > 0x5f300000, 0)) /* a>2**500 */ + if (__glibc_unlikely (ha > 0x5f300000)) /* a>2**500 */ { if (ha >= 0x7ff00000) /* Inf or NaN */ { diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c index ab754c6ee0..bc7ca0609f 100644 --- a/sysdeps/ieee754/dbl-64/e_j1.c +++ b/sysdeps/ieee754/dbl-64/e_j1.c @@ -89,7 +89,7 @@ __ieee754_j1 (double x) GET_HIGH_WORD (hx, x); ix = hx & 0x7fffffff; - if (__builtin_expect (ix >= 0x7ff00000, 0)) + if (__glibc_unlikely (ix >= 0x7ff00000)) return one / x; y = fabs (x); if (ix >= 0x40000000) /* |x| >= 2.0 */ @@ -121,7 +121,7 @@ __ieee754_j1 (double x) else return z; } - if (__builtin_expect (ix < 0x3e400000, 0)) /* |x|<2**-27 */ + if (__glibc_unlikely (ix < 0x3e400000)) /* |x|<2**-27 */ { if (huge + x > one) return 0.5 * x; /* inexact if x!=0 necessary */ @@ -163,12 +163,12 @@ __ieee754_y1 (double x) EXTRACT_WORDS (hx, lx, x); ix = 0x7fffffff & hx; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ - if (__builtin_expect (ix >= 0x7ff00000, 0)) + if (__glibc_unlikely (ix >= 0x7ff00000)) return one / (x + x * x); - if (__builtin_expect ((ix | lx) == 0, 0)) + if (__glibc_unlikely ((ix | lx) == 0)) return -HUGE_VAL + x; /* -inf and overflow exception. */; - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return zero / (zero * x); if (ix >= 0x40000000) /* |x| >= 2.0 */ { @@ -203,7 +203,7 @@ __ieee754_y1 (double x) } return z; } - if (__builtin_expect (ix <= 0x3c900000, 0)) /* x < 2**-54 */ + if (__glibc_unlikely (ix <= 0x3c900000)) /* x < 2**-54 */ { return (-tpi / x); } diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c index f48e43a0d9..236878ba1d 100644 --- a/sysdeps/ieee754/dbl-64/e_jn.c +++ b/sysdeps/ieee754/dbl-64/e_jn.c @@ -60,7 +60,7 @@ __ieee754_jn (int n, double x) EXTRACT_WORDS (hx, lx, x); ix = 0x7fffffff & hx; /* if J(n,NaN) is NaN */ - if (__builtin_expect ((ix | ((u_int32_t) (lx | -lx)) >> 31) > 0x7ff00000, 0)) + if (__glibc_unlikely ((ix | ((u_int32_t) (lx | -lx)) >> 31) > 0x7ff00000)) return x + x; if (n < 0) { @@ -74,7 +74,7 @@ __ieee754_jn (int n, double x) return (__ieee754_j1 (x)); sgn = (n & 1) & (hx >> 31); /* even n -- 0, odd n -- sign(x) */ x = fabs (x); - if (__builtin_expect ((ix | lx) == 0 || ix >= 0x7ff00000, 0)) + if (__glibc_unlikely ((ix | lx) == 0 || ix >= 0x7ff00000)) /* if x is 0 or inf */ b = zero; else if ((double) n <= x) @@ -253,12 +253,12 @@ __ieee754_yn (int n, double x) EXTRACT_WORDS (hx, lx, x); ix = 0x7fffffff & hx; /* if Y(n,NaN) is NaN */ - if (__builtin_expect ((ix | ((u_int32_t) (lx | -lx)) >> 31) > 0x7ff00000, 0)) + if (__glibc_unlikely ((ix | ((u_int32_t) (lx | -lx)) >> 31) > 0x7ff00000)) return x + x; - if (__builtin_expect ((ix | lx) == 0, 0)) + if (__glibc_unlikely ((ix | lx) == 0)) return -HUGE_VAL + x; /* -inf and overflow exception. */; - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return zero / (zero * x); sign = 1; if (n < 0) @@ -270,7 +270,7 @@ __ieee754_yn (int n, double x) return (__ieee754_y0 (x)); if (n == 1) return (sign * __ieee754_y1 (x)); - if (__builtin_expect (ix == 0x7ff00000, 0)) + if (__glibc_unlikely (ix == 0x7ff00000)) return zero; if (ix >= 0x52D00000) /* x > 2**302 */ { /* (x >> n**2) diff --git a/sysdeps/ieee754/dbl-64/e_log.c b/sysdeps/ieee754/dbl-64/e_log.c index 0b2889cb3b..05d318b786 100644 --- a/sysdeps/ieee754/dbl-64/e_log.c +++ b/sysdeps/ieee754/dbl-64/e_log.c @@ -77,23 +77,23 @@ __ieee754_log (double x) ux = num.i[HIGH_HALF]; dx = num.i[LOW_HALF]; n = 0; - if (__builtin_expect (ux < 0x00100000, 0)) + if (__glibc_unlikely (ux < 0x00100000)) { - if (__builtin_expect (((ux & 0x7fffffff) | dx) == 0, 0)) + if (__glibc_unlikely (((ux & 0x7fffffff) | dx) == 0)) return MHALF / 0.0; /* return -INF */ - if (__builtin_expect (ux < 0, 0)) + if (__glibc_unlikely (ux < 0)) return (x - x) / 0.0; /* return NaN */ n -= 54; x *= two54.d; /* scale x */ num.d = x; } - if (__builtin_expect (ux >= 0x7ff00000, 0)) + if (__glibc_unlikely (ux >= 0x7ff00000)) return x + x; /* INF or NaN */ /* Regular values of x */ w = x - 1; - if (__builtin_expect (ABS (w) > U03, 1)) + if (__glibc_likely (ABS (w) > U03)) goto case_03; /*--- Stage I, the case abs(x-1) < 0.03 */ diff --git a/sysdeps/ieee754/dbl-64/e_log10.c b/sysdeps/ieee754/dbl-64/e_log10.c index c3d465a4a9..8548ee3942 100644 --- a/sysdeps/ieee754/dbl-64/e_log10.c +++ b/sysdeps/ieee754/dbl-64/e_log10.c @@ -63,15 +63,15 @@ __ieee754_log10 (double x) k = 0; if (hx < 0x00100000) { /* x < 2**-1022 */ - if (__builtin_expect (((hx & 0x7fffffff) | lx) == 0, 0)) + if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0)) return -two54 / (x - x); /* log(+-0)=-inf */ - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return (x - x) / (x - x); /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ GET_HIGH_WORD (hx, x); } - if (__builtin_expect (hx >= 0x7ff00000, 0)) + if (__glibc_unlikely (hx >= 0x7ff00000)) return x + x; k += (hx >> 20) - 1023; i = ((u_int32_t) k & 0x80000000) >> 31; diff --git a/sysdeps/ieee754/dbl-64/e_log2.c b/sysdeps/ieee754/dbl-64/e_log2.c index 890a4a2bd0..997d7cefc8 100644 --- a/sysdeps/ieee754/dbl-64/e_log2.c +++ b/sysdeps/ieee754/dbl-64/e_log2.c @@ -81,15 +81,15 @@ __ieee754_log2 (double x) k = 0; if (hx < 0x00100000) { /* x < 2**-1022 */ - if (__builtin_expect (((hx & 0x7fffffff) | lx) == 0, 0)) + if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0)) return -two54 / (x - x); /* log(+-0)=-inf */ - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return (x - x) / (x - x); /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ GET_HIGH_WORD (hx, x); } - if (__builtin_expect (hx >= 0x7ff00000, 0)) + if (__glibc_unlikely (hx >= 0x7ff00000)) return x + x; k += (hx >> 20) - 1023; hx &= 0x000fffff; diff --git a/sysdeps/ieee754/dbl-64/e_sinh.c b/sysdeps/ieee754/dbl-64/e_sinh.c index 851b510aaa..4ff28bf85d 100644 --- a/sysdeps/ieee754/dbl-64/e_sinh.c +++ b/sysdeps/ieee754/dbl-64/e_sinh.c @@ -49,7 +49,7 @@ __ieee754_sinh (double x) ix = jx & 0x7fffffff; /* x is INF or NaN */ - if (__builtin_expect (ix >= 0x7ff00000, 0)) + if (__glibc_unlikely (ix >= 0x7ff00000)) return x + x; h = 0.5; @@ -58,7 +58,7 @@ __ieee754_sinh (double x) /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ if (ix < 0x40360000) /* |x|<22 */ { - if (__builtin_expect (ix < 0x3e300000, 0)) /* |x|<2**-28 */ + if (__glibc_unlikely (ix < 0x3e300000)) /* |x|<2**-28 */ if (shuge + x > one) return x; /* sinh(tiny) = tiny with inexact */ diff --git a/sysdeps/ieee754/dbl-64/s_asinh.c b/sysdeps/ieee754/dbl-64/s_asinh.c index 5500746848..a33758d3c9 100644 --- a/sysdeps/ieee754/dbl-64/s_asinh.c +++ b/sysdeps/ieee754/dbl-64/s_asinh.c @@ -36,12 +36,12 @@ __asinh (double x) int32_t hx, ix; GET_HIGH_WORD (hx, x); ix = hx & 0x7fffffff; - if (__builtin_expect (ix < 0x3e300000, 0)) /* |x|<2**-28 */ + if (__glibc_unlikely (ix < 0x3e300000)) /* |x|<2**-28 */ { if (huge + x > one) return x; /* return x inexact except 0 */ } - if (__builtin_expect (ix > 0x41b00000, 0)) /* |x| > 2**28 */ + if (__glibc_unlikely (ix > 0x41b00000)) /* |x| > 2**28 */ { if (ix >= 0x7ff00000) return x + x; /* x is inf or NaN */ diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c index cfaa22d184..389acd4cde 100644 --- a/sysdeps/ieee754/dbl-64/s_fma.c +++ b/sysdeps/ieee754/dbl-64/s_fma.c @@ -174,7 +174,7 @@ __fma (double x, double y, double z) } /* Ensure correct sign of exact 0 + 0. */ - if (__builtin_expect ((x == 0 || y == 0) && z == 0, 0)) + if (__glibc_unlikely ((x == 0 || y == 0) && z == 0)) return x * y + z; fenv_t env; @@ -216,7 +216,7 @@ __fma (double x, double y, double z) /* Perform m2 + a2 addition with round to odd. */ u.d = a2 + m2; - if (__builtin_expect (adjust < 0, 0)) + if (__glibc_unlikely (adjust < 0)) { if ((u.ieee.mantissa1 & 1) == 0) u.ieee.mantissa1 |= libc_fetestexcept (FE_INEXACT) != 0; @@ -228,14 +228,14 @@ __fma (double x, double y, double z) /* Reset rounding mode and test for inexact simultaneously. */ int j = libc_feupdateenv_test (&env, FE_INEXACT) != 0; - if (__builtin_expect (adjust == 0, 1)) + if (__glibc_likely (adjust == 0)) { if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff) u.ieee.mantissa1 |= j; /* Result is a1 + u.d. */ return a1 + u.d; } - else if (__builtin_expect (adjust > 0, 1)) + else if (__glibc_likely (adjust > 0)) { if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff) u.ieee.mantissa1 |= j; diff --git a/sysdeps/ieee754/dbl-64/s_log1p.c b/sysdeps/ieee754/dbl-64/s_log1p.c index ea1dc6ca76..fd4dce5f23 100644 --- a/sysdeps/ieee754/dbl-64/s_log1p.c +++ b/sysdeps/ieee754/dbl-64/s_log1p.c @@ -107,14 +107,14 @@ __log1p (double x) k = 1; if (hx < 0x3FDA827A) /* x < 0.41422 */ { - if (__builtin_expect (ax >= 0x3ff00000, 0)) /* x <= -1.0 */ + if (__glibc_unlikely (ax >= 0x3ff00000)) /* x <= -1.0 */ { if (x == -1.0) return -two54 / (x - x); /* log1p(-1)=+inf */ else return (x - x) / (x - x); /* log1p(x<-1)=NaN */ } - if (__builtin_expect (ax < 0x3e200000, 0)) /* |x| < 2**-29 */ + if (__glibc_unlikely (ax < 0x3e200000)) /* |x| < 2**-29 */ { math_force_eval (two54 + x); /* raise inexact */ if (ax < 0x3c900000) /* |x| < 2**-54 */ @@ -127,7 +127,7 @@ __log1p (double x) k = 0; f = x; hu = 1; } /* -0.2929<x<0.41422 */ } - else if (__builtin_expect (hx >= 0x7ff00000, 0)) + else if (__glibc_unlikely (hx >= 0x7ff00000)) return x + x; if (k != 0) { diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c index c065826dd2..7a6c49abf5 100644 --- a/sysdeps/ieee754/dbl-64/s_logb.c +++ b/sysdeps/ieee754/dbl-64/s_logb.c @@ -30,7 +30,7 @@ __logb (double x) return -1.0 / fabs (x); if (ix >= 0x7ff00000) return x * x; - if (__builtin_expect ((rix = ix >> 20) == 0, 0)) + if (__glibc_unlikely ((rix = ix >> 20) == 0)) { /* POSIX specifies that denormal number is treated as though it were normalized. */ diff --git a/sysdeps/ieee754/dbl-64/s_modf.c b/sysdeps/ieee754/dbl-64/s_modf.c index 1dce6381ae..0a1e13008f 100644 --- a/sysdeps/ieee754/dbl-64/s_modf.c +++ b/sysdeps/ieee754/dbl-64/s_modf.c @@ -54,7 +54,7 @@ __modf (double x, double *iptr) } } } - else if (__builtin_expect (j0 > 51, 0)) /* no fraction part */ + else if (__glibc_unlikely (j0 > 51)) /* no fraction part */ { *iptr = x * one; /* We must handle NaNs separately. */ diff --git a/sysdeps/ieee754/dbl-64/s_scalbln.c b/sysdeps/ieee754/dbl-64/s_scalbln.c index 6402927d23..874b98e4cf 100644 --- a/sysdeps/ieee754/dbl-64/s_scalbln.c +++ b/sysdeps/ieee754/dbl-64/s_scalbln.c @@ -31,7 +31,7 @@ __scalbln (double x, long int n) int32_t k, hx, lx; EXTRACT_WORDS (hx, lx, x); k = (hx & 0x7ff00000) >> 20; /* extract exponent */ - if (__builtin_expect (k == 0, 0)) /* 0 or subnormal x */ + if (__glibc_unlikely (k == 0)) /* 0 or subnormal x */ { if ((lx | (hx & 0x7fffffff)) == 0) return x; /* +-0 */ @@ -39,16 +39,16 @@ __scalbln (double x, long int n) GET_HIGH_WORD (hx, x); k = ((hx & 0x7ff00000) >> 20) - 54; } - if (__builtin_expect (k == 0x7ff, 0)) + if (__glibc_unlikely (k == 0x7ff)) return x + x; /* NaN or Inf */ - if (__builtin_expect (n < -50000, 0)) + if (__glibc_unlikely (n < -50000)) return tiny * __copysign (tiny, x); /*underflow*/ - if (__builtin_expect (n > 50000 || k + n > 0x7fe, 0)) + if (__glibc_unlikely (n > 50000 || k + n > 0x7fe)) return huge * __copysign (huge, x); /* overflow */ /* Now k and n are bounded we know that k = k+n does not overflow. */ k = k + n; - if (__builtin_expect (k > 0, 1)) /* normal result */ + if (__glibc_likely (k > 0)) /* normal result */ { SET_HIGH_WORD (x, (hx & 0x800fffff) | (k << 20)); return x; } diff --git a/sysdeps/ieee754/dbl-64/s_scalbn.c b/sysdeps/ieee754/dbl-64/s_scalbn.c index 6e7d5ad217..0f58034df5 100644 --- a/sysdeps/ieee754/dbl-64/s_scalbn.c +++ b/sysdeps/ieee754/dbl-64/s_scalbn.c @@ -31,7 +31,7 @@ __scalbn (double x, int n) int32_t k, hx, lx; EXTRACT_WORDS (hx, lx, x); k = (hx & 0x7ff00000) >> 20; /* extract exponent */ - if (__builtin_expect (k == 0, 0)) /* 0 or subnormal x */ + if (__glibc_unlikely (k == 0)) /* 0 or subnormal x */ { if ((lx | (hx & 0x7fffffff)) == 0) return x; /* +-0 */ @@ -39,16 +39,16 @@ __scalbn (double x, int n) GET_HIGH_WORD (hx, x); k = ((hx & 0x7ff00000) >> 20) - 54; } - if (__builtin_expect (k == 0x7ff, 0)) + if (__glibc_unlikely (k == 0x7ff)) return x + x; /* NaN or Inf */ - if (__builtin_expect (n < -50000, 0)) + if (__glibc_unlikely (n < -50000)) return tiny * __copysign (tiny, x); /*underflow*/ - if (__builtin_expect (n > 50000 || k + n > 0x7fe, 0)) + if (__glibc_unlikely (n > 50000 || k + n > 0x7fe)) return huge * __copysign (huge, x); /* overflow */ /* Now k and n are bounded we know that k = k+n does not overflow. */ k = k + n; - if (__builtin_expect (k > 0, 1)) /* normal result */ + if (__glibc_likely (k > 0)) /* normal result */ { SET_HIGH_WORD (x, (hx & 0x800fffff) | (k << 20)); return x; } diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c index 26268f2498..ccccdaf106 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c @@ -39,7 +39,7 @@ __ieee754_acosh (double x) if (hx > INT64_C (0x4000000000000000)) { - if (__builtin_expect (hx >= INT64_C (0x41b0000000000000), 0)) + if (__glibc_unlikely (hx >= INT64_C (0x41b0000000000000))) { /* x > 2**28 */ if (hx >= INT64_C (0x7ff0000000000000)) @@ -53,13 +53,13 @@ __ieee754_acosh (double x) double t = x * x; return __ieee754_log (2.0 * x - one / (x + __ieee754_sqrt (t - one))); } - else if (__builtin_expect (hx > INT64_C (0x3ff0000000000000), 1)) + else if (__glibc_likely (hx > INT64_C (0x3ff0000000000000))) { /* 1<x<2 */ double t = x - one; return __log1p (t + __ieee754_sqrt (2.0 * t + t * t)); } - else if (__builtin_expect (hx == INT64_C (0x3ff0000000000000), 1)) + else if (__glibc_likely (hx == INT64_C (0x3ff0000000000000))) return 0.0; /* acosh(1) = 0 */ else /* x < 1 */ return (x - x) / (x - x); diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c index dcb7b58a1b..4f5a81669e 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c @@ -64,16 +64,16 @@ __ieee754_log10 (double x) k = 0; if (hx < INT64_C(0x0010000000000000)) { /* x < 2**-1022 */ - if (__builtin_expect ((hx & UINT64_C(0x7fffffffffffffff)) == 0, 0)) + if (__glibc_unlikely ((hx & UINT64_C(0x7fffffffffffffff)) == 0)) return -two54 / (x - x); /* log(+-0)=-inf */ - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return (x - x) / (x - x); /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ EXTRACT_WORDS64 (hx, x); } /* scale up resulted in a NaN number */ - if (__builtin_expect (hx >= UINT64_C(0x7ff0000000000000), 0)) + if (__glibc_unlikely (hx >= UINT64_C(0x7ff0000000000000))) return x + x; k += (hx >> 52) - 1023; i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63; diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c index 6dc7b7d217..5ccb78cf03 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c @@ -80,15 +80,15 @@ __ieee754_log2 (double x) k = 0; if (hx < INT64_C(0x0010000000000000)) { /* x < 2**-1022 */ - if (__builtin_expect ((hx & UINT64_C(0x7fffffffffffffff)) == 0, 0)) + if (__glibc_unlikely ((hx & UINT64_C(0x7fffffffffffffff)) == 0)) return -two54 / (x - x); /* log(+-0)=-inf */ - if (__builtin_expect (hx < 0, 0)) + if (__glibc_unlikely (hx < 0)) return (x - x) / (x - x); /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ EXTRACT_WORDS64 (hx, x); } - if (__builtin_expect (hx >= UINT64_C(0x7ff0000000000000), 0)) + if (__glibc_unlikely (hx >= UINT64_C(0x7ff0000000000000))) return x + x; k += (hx >> 52) - 1023; hx &= UINT64_C(0x000fffffffffffff); diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c index d03e33ee1f..f2d980d9e0 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c @@ -39,11 +39,11 @@ __frexp (double x, int *eptr) int32_t ex = 0x7ff & (ix >> 52); int e = 0; - if (__builtin_expect (ex != 0x7ff && x != 0.0, 1)) + if (__glibc_likely (ex != 0x7ff && x != 0.0)) { /* Not zero and finite. */ e = ex - 1022; - if (__builtin_expect (ex == 0, 0)) + if (__glibc_unlikely (ex == 0)) { /* Subnormal. */ x *= 0x1p54; diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c index e51c849592..1970ce922e 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c @@ -34,7 +34,7 @@ __logb (double x) ex = ix >> 52; if (ex == 0x7ff) return x * x; - if (__builtin_expect (ex == 0, 0)) + if (__glibc_unlikely (ex == 0)) { int m = __builtin_clzll (ix); ex -= m - 12; diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c index b22503f5c7..06b9242a86 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c @@ -40,7 +40,7 @@ __remquo (double x, double y, int *quo) hx &= UINT64_C(0x7fffffffffffffff); /* Purge off exception values. */ - if (__builtin_expect (hy == 0, 0)) + if (__glibc_unlikely (hy == 0)) return (x * y) / (x * y); /* y = 0 */ if (__builtin_expect (hx >= UINT64_C(0x7ff0000000000000) /* x not finite */ || hy > UINT64_C(0x7ff0000000000000), 0))/* y is NaN */ @@ -49,7 +49,7 @@ __remquo (double x, double y, int *quo) if (hy <= UINT64_C(0x7fbfffffffffffff)) x = __ieee754_fmod (x, 8 * y); /* now x < 8y */ - if (__builtin_expect (hx == hy, 0)) + if (__glibc_unlikely (hx == hy)) { *quo = qs ? -1 : 1; return zero * x; diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c index 684858c065..8b86b81b00 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c @@ -32,7 +32,7 @@ __round (double x) EXTRACT_WORDS64 (i0, x); j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; - if (__builtin_expect (j0 < 52, 1)) + if (__glibc_likely (j0 < 52)) { if (j0 < 0) { diff --git a/sysdeps/ieee754/flt-32/e_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c index dbd3fe4be2..da4fa4dc0b 100644 --- a/sysdeps/ieee754/flt-32/e_atanhf.c +++ b/sysdeps/ieee754/flt-32/e_atanhf.c @@ -48,7 +48,7 @@ __ieee754_atanhf (float x) float t; if (isless (xa, 0.5f)) { - if (__builtin_expect (xa < 0x1.0p-28f, 0)) + if (__glibc_unlikely (xa < 0x1.0p-28f)) { math_force_eval (huge + x); return x; @@ -57,7 +57,7 @@ __ieee754_atanhf (float x) t = xa + xa; t = 0.5f * __log1pf (t + t * xa / (1.0f - xa)); } - else if (__builtin_expect (isless (xa, 1.0f), 1)) + else if (__glibc_likely (isless (xa, 1.0f))) t = 0.5f * __log1pf ((xa + xa) / (1.0f - xa)); else { diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c index e8da51a42c..7b72587e9d 100644 --- a/sysdeps/ieee754/flt-32/e_gammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c @@ -114,7 +114,7 @@ __ieee754_gammaf_r (float x, int *signgamp) GET_FLOAT_WORD (hx, x); - if (__builtin_expect ((hx & 0x7fffffff) == 0, 0)) + if (__glibc_unlikely ((hx & 0x7fffffff) == 0)) { /* Return value for x == 0 is Inf with divide by zero exception. */ *signgamp = 0; @@ -127,13 +127,13 @@ __ieee754_gammaf_r (float x, int *signgamp) *signgamp = 0; return (x - x) / (x - x); } - if (__builtin_expect (hx == 0xff800000, 0)) + if (__glibc_unlikely (hx == 0xff800000)) { /* x == -Inf. According to ISO this is NaN. */ *signgamp = 0; return x - x; } - if (__builtin_expect ((hx & 0x7f800000) == 0x7f800000, 0)) + if (__glibc_unlikely ((hx & 0x7f800000) == 0x7f800000)) { /* Positive infinity (return positive infinity) or NaN (return NaN). */ diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c index 011adbb2b7..ba0267ebcb 100644 --- a/sysdeps/ieee754/flt-32/s_logbf.c +++ b/sysdeps/ieee754/flt-32/s_logbf.c @@ -27,7 +27,7 @@ __logbf (float x) return (float) -1.0 / fabsf (x); if (ix >= 0x7f800000) return x * x; - if (__builtin_expect ((rix = ix >> 23) == 0, 0)) + if (__glibc_unlikely ((rix = ix >> 23) == 0)) { /* POSIX specifies that denormal number is treated as though it were normalized. */ diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c index 48b63ab51d..1d5f27b7b6 100644 --- a/sysdeps/ieee754/ldbl-128/s_fmal.c +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c @@ -178,7 +178,7 @@ __fmal (long double x, long double y, long double z) } /* Ensure correct sign of exact 0 + 0. */ - if (__builtin_expect ((x == 0 || y == 0) && z == 0, 0)) + if (__glibc_unlikely ((x == 0 || y == 0) && z == 0)) return x * y + z; fenv_t env; @@ -220,7 +220,7 @@ __fmal (long double x, long double y, long double z) /* Perform m2 + a2 addition with round to odd. */ u.d = a2 + m2; - if (__builtin_expect (adjust == 0, 1)) + if (__glibc_likely (adjust == 0)) { if ((u.ieee.mantissa3 & 1) == 0 && u.ieee.exponent != 0x7fff) u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0; @@ -228,7 +228,7 @@ __fmal (long double x, long double y, long double z) /* Result is a1 + u.d. */ return a1 + u.d; } - else if (__builtin_expect (adjust > 0, 1)) + else if (__glibc_likely (adjust > 0)) { if ((u.ieee.mantissa3 & 1) == 0 && u.ieee.exponent != 0x7fff) u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0; diff --git a/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c b/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c index a140fb322d..205097d38f 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c @@ -48,7 +48,7 @@ __ieee754_fmodl (long double x, long double y) (hx>=0x7ff0000000000000LL)|| /* y=0,or x not finite */ (hy>0x7ff0000000000000LL),0)) /* or y is NaN */ return (x*y)/(x*y); - if (__builtin_expect (hx <= hy, 0)) + if (__glibc_unlikely (hx <= hy)) { /* If |x| < |y| return x. */ if (hx < hy) @@ -83,7 +83,7 @@ __ieee754_fmodl (long double x, long double y) ldbl_extract_mantissa(&hx, &lx, &ix, x); ldbl_extract_mantissa(&hy, &ly, &iy, y); - if (__builtin_expect (ix == -IEEE754_DOUBLE_BIAS, 0)) + if (__glibc_unlikely (ix == -IEEE754_DOUBLE_BIAS)) { /* subnormal x, shift x to normal. */ while ((hx & (1LL << 48)) == 0) @@ -94,7 +94,7 @@ __ieee754_fmodl (long double x, long double y) } } - if (__builtin_expect (iy == -IEEE754_DOUBLE_BIAS, 0)) + if (__glibc_unlikely (iy == -IEEE754_DOUBLE_BIAS)) { /* subnormal y, shift y to normal. */ while ((hy & (1LL << 48)) == 0) diff --git a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h index 1b6e27a9ff..051352f9f7 100644 --- a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h +++ b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h @@ -215,14 +215,14 @@ ldbl_nearbyint (double a) { double two52 = 0x1p52; - if (__builtin_expect ((__builtin_fabs (a) < two52), 1)) + if (__glibc_likely ((__builtin_fabs (a) < two52))) { - if (__builtin_expect ((a > 0.0), 1)) + if (__glibc_likely ((a > 0.0))) { a += two52; a -= two52; } - else if (__builtin_expect ((a < 0.0), 1)) + else if (__glibc_likely ((a < 0.0))) { a = two52 - a; a = -(a - two52); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c index 345f3905d6..86996bff3d 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c @@ -45,7 +45,7 @@ __llrintl (long double x) { save_round = __fegetround (); - if (__builtin_expect ((xh == -(double) (-__LONG_LONG_MAX__ - 1)), 0)) + if (__glibc_unlikely ((xh == -(double) (-__LONG_LONG_MAX__ - 1)))) { /* When XH is 9223372036854775808.0, converting to long long will overflow, resulting in an invalid operation. However, XL might @@ -72,7 +72,7 @@ __llrintl (long double x) res = hi + lo; /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi). */ - if (__builtin_expect (((~(hi ^ lo) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0))) goto overflow; xh -= lo; @@ -114,7 +114,7 @@ __llrintl (long double x) break; } - if (__builtin_expect (((~(hi ^ (res - hi)) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0))) goto overflow; return res; diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c index 4a6e2d5f83..dd84074cf7 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c @@ -41,7 +41,7 @@ __llroundl (long double x) #endif ) { - if (__builtin_expect ((xh == -(double) (-__LONG_LONG_MAX__ - 1)), 0)) + if (__glibc_unlikely ((xh == -(double) (-__LONG_LONG_MAX__ - 1)))) { /* When XH is 9223372036854775808.0, converting to long long will overflow, resulting in an invalid operation. However, XL might @@ -68,7 +68,7 @@ __llroundl (long double x) res = hi + lo; /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi). */ - if (__builtin_expect (((~(hi ^ lo) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0))) goto overflow; xh -= lo; @@ -94,7 +94,7 @@ __llroundl (long double x) res -= 1; } - if (__builtin_expect (((~(hi ^ (res - hi)) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0))) goto overflow; return res; diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c index da8d71bdec..dbd3478e63 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c @@ -36,7 +36,7 @@ __logbl (long double x) return -1.0 / fabs (x); if (hx >= 0x7ff0000000000000LL) return x * x; - if (__builtin_expect ((rhx = hx >> 52) == 0, 0)) + if (__glibc_unlikely ((rhx = hx >> 52) == 0)) { /* POSIX specifies that denormal number is treated as though it were normalized. */ diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c index 56c3a81cd3..2b47c52a06 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c @@ -59,7 +59,7 @@ __lrintl (long double x) hi = llhi; xh -= hi; #else - if (__builtin_expect ((xh == -(double) (-__LONG_MAX__ - 1)), 0)) + if (__glibc_unlikely ((xh == -(double) (-__LONG_MAX__ - 1)))) { /* When XH is 9223372036854775808.0, converting to long long will overflow, resulting in an invalid operation. However, XL might @@ -87,7 +87,7 @@ __lrintl (long double x) res = hi + lo; /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi). */ - if (__builtin_expect (((~(hi ^ lo) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0))) goto overflow; xh -= lo; @@ -129,7 +129,7 @@ __lrintl (long double x) break; } - if (__builtin_expect (((~(hi ^ (res - hi)) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0))) goto overflow; return res; diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c index 107778df3e..27b72e2ad1 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c @@ -55,7 +55,7 @@ __lroundl (long double x) hi = llhi; xh -= hi; #else - if (__builtin_expect ((xh == -(double) (-__LONG_MAX__ - 1)), 0)) + if (__glibc_unlikely ((xh == -(double) (-__LONG_MAX__ - 1)))) { /* When XH is 9223372036854775808.0, converting to long long will overflow, resulting in an invalid operation. However, XL might @@ -83,7 +83,7 @@ __lroundl (long double x) res = hi + lo; /* This is just sign(hi) == sign(lo) && sign(res) != sign(hi). */ - if (__builtin_expect (((~(hi ^ lo) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0))) goto overflow; xh -= lo; @@ -109,7 +109,7 @@ __lroundl (long double x) res -= 1; } - if (__builtin_expect (((~(hi ^ (res - hi)) & (res ^ hi)) < 0), 0)) + if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0))) goto overflow; return res; diff --git a/sysdeps/ieee754/ldbl-96/e_gammal_r.c b/sysdeps/ieee754/ldbl-96/e_gammal_r.c index 477c3a61d3..2832f417c9 100644 --- a/sysdeps/ieee754/ldbl-96/e_gammal_r.c +++ b/sysdeps/ieee754/ldbl-96/e_gammal_r.c @@ -119,19 +119,19 @@ __ieee754_gammal_r (long double x, int *signgamp) GET_LDOUBLE_WORDS (es, hx, lx, x); - if (__builtin_expect (((es & 0x7fff) | hx | lx) == 0, 0)) + if (__glibc_unlikely (((es & 0x7fff) | hx | lx) == 0)) { /* Return value for x == 0 is Inf with divide by zero exception. */ *signgamp = 0; return 1.0 / x; } - if (__builtin_expect (es == 0xffffffff && ((hx & 0x7fffffff) | lx) == 0, 0)) + if (__glibc_unlikely (es == 0xffffffff && ((hx & 0x7fffffff) | lx) == 0)) { /* x == -Inf. According to ISO this is NaN. */ *signgamp = 0; return x - x; } - if (__builtin_expect ((es & 0x7fff) == 0x7fff, 0)) + if (__glibc_unlikely ((es & 0x7fff) == 0x7fff)) { /* Positive infinity (return positive infinity) or NaN (return NaN). */ diff --git a/sysdeps/ieee754/ldbl-96/e_j0l.c b/sysdeps/ieee754/ldbl-96/e_j0l.c index 3939259d81..56f48f1ab9 100644 --- a/sysdeps/ieee754/ldbl-96/e_j0l.c +++ b/sysdeps/ieee754/ldbl-96/e_j0l.c @@ -112,7 +112,7 @@ __ieee754_j0l (long double x) GET_LDOUBLE_EXP (se, x); ix = se & 0x7fff; - if (__builtin_expect (ix >= 0x7fff, 0)) + if (__glibc_unlikely (ix >= 0x7fff)) return one / (x * x); x = fabsl (x); if (ix >= 0x4000) /* |x| >= 2.0 */ @@ -132,7 +132,7 @@ __ieee754_j0l (long double x) * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) */ - if (__builtin_expect (ix > 0x4080, 0)) /* 2^129 */ + if (__glibc_unlikely (ix > 0x4080)) /* 2^129 */ z = (invsqrtpi * cc) / __ieee754_sqrtl (x); else { @@ -142,7 +142,7 @@ __ieee754_j0l (long double x) } return z; } - if (__builtin_expect (ix < 0x3fef, 0)) /* |x| < 2**-16 */ + if (__glibc_unlikely (ix < 0x3fef)) /* |x| < 2**-16 */ { /* raise inexact if x != 0 */ math_force_eval (huge + x); @@ -199,11 +199,11 @@ __ieee754_y0l (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ - if (__builtin_expect (se & 0x8000, 0)) + if (__glibc_unlikely (se & 0x8000)) return zero / (zero * x); - if (__builtin_expect (ix >= 0x7fff, 0)) + if (__glibc_unlikely (ix >= 0x7fff)) return one / (x + x * x); - if (__builtin_expect ((i0 | i1) == 0, 0)) + if (__glibc_unlikely ((i0 | i1) == 0)) return -HUGE_VALL + x; /* -inf and overflow exception. */ if (ix >= 0x4000) { /* |x| >= 2.0 */ @@ -234,7 +234,7 @@ __ieee754_y0l (long double x) else ss = z / cc; } - if (__builtin_expect (ix > 0x4080, 0)) /* 1e39 */ + if (__glibc_unlikely (ix > 0x4080)) /* 1e39 */ z = (invsqrtpi * ss) / __ieee754_sqrtl (x); else { @@ -244,7 +244,7 @@ __ieee754_y0l (long double x) } return z; } - if (__builtin_expect (ix <= 0x3fde, 0)) /* x < 2^-33 */ + if (__glibc_unlikely (ix <= 0x3fde)) /* x < 2^-33 */ { z = -7.380429510868722527629822444004602747322E-2L + tpi * __ieee754_logl (x); diff --git a/sysdeps/ieee754/ldbl-96/e_j1l.c b/sysdeps/ieee754/ldbl-96/e_j1l.c index 4c13018aea..5c0a2e1992 100644 --- a/sysdeps/ieee754/ldbl-96/e_j1l.c +++ b/sysdeps/ieee754/ldbl-96/e_j1l.c @@ -114,7 +114,7 @@ __ieee754_j1l (long double x) GET_LDOUBLE_EXP (se, x); ix = se & 0x7fff; - if (__builtin_expect (ix >= 0x7fff, 0)) + if (__glibc_unlikely (ix >= 0x7fff)) return one / x; y = fabsl (x); if (ix >= 0x4000) @@ -134,7 +134,7 @@ __ieee754_j1l (long double x) * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ - if (__builtin_expect (ix > 0x4080, 0)) + if (__glibc_unlikely (ix > 0x4080)) z = (invsqrtpi * cc) / __ieee754_sqrtl (y); else { @@ -147,7 +147,7 @@ __ieee754_j1l (long double x) else return z; } - if (__builtin_expect (ix < 0x3fde, 0)) /* |x| < 2^-33 */ + if (__glibc_unlikely (ix < 0x3fde)) /* |x| < 2^-33 */ { if (huge + x > one) return 0.5 * x; /* inexact if x!=0 necessary */ @@ -192,11 +192,11 @@ __ieee754_y1l (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ - if (__builtin_expect (se & 0x8000, 0)) + if (__glibc_unlikely (se & 0x8000)) return zero / (zero * x); - if (__builtin_expect (ix >= 0x7fff, 0)) + if (__glibc_unlikely (ix >= 0x7fff)) return one / (x + x * x); - if (__builtin_expect ((i0 | i1) == 0, 0)) + if (__glibc_unlikely ((i0 | i1) == 0)) return -HUGE_VALL + x; /* -inf and overflow exception. */ if (ix >= 0x4000) { /* |x| >= 2.0 */ @@ -222,7 +222,7 @@ __ieee754_y1l (long double x) * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ - if (__builtin_expect (ix > 0x4080, 0)) + if (__glibc_unlikely (ix > 0x4080)) z = (invsqrtpi * ss) / __ieee754_sqrtl (x); else { @@ -232,7 +232,7 @@ __ieee754_y1l (long double x) } return z; } - if (__builtin_expect (ix <= 0x3fbe, 0)) + if (__glibc_unlikely (ix <= 0x3fbe)) { /* x < 2**-65 */ return (-tpi / x); } diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c index fa8e27efec..11d097c271 100644 --- a/sysdeps/ieee754/ldbl-96/e_jnl.c +++ b/sysdeps/ieee754/ldbl-96/e_jnl.c @@ -81,7 +81,7 @@ __ieee754_jnl (int n, long double x) ix = se & 0x7fff; /* if J(n,NaN) is NaN */ - if (__builtin_expect ((ix == 0x7fff) && ((i0 & 0x7fffffff) != 0), 0)) + if (__glibc_unlikely ((ix == 0x7fff) && ((i0 & 0x7fffffff) != 0))) return x + x; if (n < 0) { @@ -95,7 +95,7 @@ __ieee754_jnl (int n, long double x) return (__ieee754_j1l (x)); sgn = (n & 1) & (se >> 15); /* even n -- 0, odd n -- sign(x) */ x = fabsl (x); - if (__builtin_expect ((ix | i0 | i1) == 0 || ix >= 0x7fff, 0)) + if (__glibc_unlikely ((ix | i0 | i1) == 0 || ix >= 0x7fff)) /* if x is 0 or inf */ b = zero; else if ((long double) n <= x) @@ -316,7 +316,7 @@ __ieee754_ynl (int n, long double x) return (__ieee754_y0l (x)); if (n == 1) return (sign * __ieee754_y1l (x)); - if (__builtin_expect (ix == 0x7fff, 0)) + if (__glibc_unlikely (ix == 0x7fff)) return zero; if (ix >= 0x412D) { /* x > 2**302 */ diff --git a/sysdeps/ieee754/ldbl-96/s_fma.c b/sysdeps/ieee754/ldbl-96/s_fma.c index fde2811040..354be4eae9 100644 --- a/sysdeps/ieee754/ldbl-96/s_fma.c +++ b/sysdeps/ieee754/ldbl-96/s_fma.c @@ -29,7 +29,7 @@ double __fma (double x, double y, double z) { - if (__builtin_expect (isinf (z), 0)) + if (__glibc_unlikely (isinf (z))) { /* If z is Inf, but x and y are finite, the result should be z rather than NaN. */ @@ -39,7 +39,7 @@ __fma (double x, double y, double z) } /* Ensure correct sign of exact 0 + 0. */ - if (__builtin_expect ((x == 0 || y == 0) && z == 0, 0)) + if (__glibc_unlikely ((x == 0 || y == 0) && z == 0)) return x * y + z; fenv_t env; diff --git a/sysdeps/ieee754/ldbl-96/s_fmal.c b/sysdeps/ieee754/ldbl-96/s_fmal.c index 0564321354..4983eda9c6 100644 --- a/sysdeps/ieee754/ldbl-96/s_fmal.c +++ b/sysdeps/ieee754/ldbl-96/s_fmal.c @@ -176,7 +176,7 @@ __fmal (long double x, long double y, long double z) } /* Ensure correct sign of exact 0 + 0. */ - if (__builtin_expect ((x == 0 || y == 0) && z == 0, 0)) + if (__glibc_unlikely ((x == 0 || y == 0) && z == 0)) return x * y + z; fenv_t env; @@ -218,7 +218,7 @@ __fmal (long double x, long double y, long double z) /* Perform m2 + a2 addition with round to odd. */ u.d = a2 + m2; - if (__builtin_expect (adjust == 0, 1)) + if (__glibc_likely (adjust == 0)) { if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7fff) u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0; @@ -226,7 +226,7 @@ __fmal (long double x, long double y, long double z) /* Result is a1 + u.d. */ return a1 + u.d; } - else if (__builtin_expect (adjust > 0, 1)) + else if (__glibc_likely (adjust > 0)) { if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7fff) u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0; diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c index 27f264bb16..0bb1399e97 100644 --- a/sysdeps/posix/clock_getres.c +++ b/sysdeps/posix/clock_getres.c @@ -30,7 +30,7 @@ static long int nsec; /* Clock frequency of the processor. */ static int hp_timing_getres (struct timespec *res) { - if (__builtin_expect (nsec == 0, 0)) + if (__glibc_unlikely (nsec == 0)) { hp_timing_t freq; @@ -39,7 +39,7 @@ hp_timing_getres (struct timespec *res) code against multiple execution since all of them should lead to the same result. */ freq = __get_clockfreq (); - if (__builtin_expect (freq == 0, 0)) + if (__glibc_unlikely (freq == 0)) /* Something went wrong. */ return -1; @@ -60,7 +60,7 @@ realtime_getres (struct timespec *res) { long int clk_tck = sysconf (_SC_CLK_TCK); - if (__builtin_expect (clk_tck != -1, 1)) + if (__glibc_likely (clk_tck != -1)) { /* This implementation assumes that the realtime clock has a resolution higher than 1 second. This is the case for any diff --git a/sysdeps/posix/fdopendir.c b/sysdeps/posix/fdopendir.c index d8c6ec0513..4071996dcd 100644 --- a/sysdeps/posix/fdopendir.c +++ b/sysdeps/posix/fdopendir.c @@ -31,7 +31,7 @@ __fdopendir (int fd) if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0) return NULL; - if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0)) + if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) { __set_errno (ENOTDIR); return NULL; @@ -39,9 +39,9 @@ __fdopendir (int fd) /* Make sure the descriptor allows for reading. */ int flags = __fcntl (fd, F_GETFL); - if (__builtin_expect (flags == -1, 0)) + if (__glibc_unlikely (flags == -1)) return NULL; - if (__builtin_expect ((flags & O_ACCMODE) == O_WRONLY, 0)) + if (__glibc_unlikely ((flags & O_ACCMODE) == O_WRONLY)) { __set_errno (EINVAL); return NULL; diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 8218237af2..e1a399b3ca 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -471,7 +471,7 @@ gaih_inet (const char *name, const struct gaih_service *service, bool malloc_namebuf = false; char *namebuf = (char *) name; - if (__builtin_expect (scope_delim != NULL, 0)) + if (__glibc_unlikely (scope_delim != NULL)) { if (malloc_name) *scope_delim = '\0'; @@ -2608,7 +2608,7 @@ getaddrinfo (const char *name, const char *service, the information. */ struct sort_result_combo src = { .results = results, .nresults = nresults }; - if (__builtin_expect (gaiconf_reload_flag_ever_set, 0)) + if (__glibc_unlikely (gaiconf_reload_flag_ever_set)) { __libc_lock_define_initialized (static, lock); diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c index e366701bd4..2740b3ac29 100644 --- a/sysdeps/posix/opendir.c +++ b/sysdeps/posix/opendir.c @@ -110,7 +110,7 @@ __opendirat (int dfd, const char *name) performed on, say, a tape device might have undesirable effects. */ if (__builtin_expect (__xstat64 (_STAT_VER, name, &statbuf), 0) < 0) return NULL; - if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0)) + if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) { __set_errno (ENOTDIR); return NULL; @@ -139,7 +139,7 @@ __opendirat (int dfd, const char *name) the `stat' call. */ if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0) goto lose; - if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0)) + if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) { __set_errno (ENOTDIR); lose: diff --git a/sysdeps/posix/sleep.c b/sysdeps/posix/sleep.c index 4a72c275b3..d8b19099fd 100644 --- a/sysdeps/posix/sleep.c +++ b/sysdeps/posix/sleep.c @@ -33,7 +33,7 @@ unsigned int __sleep (unsigned int seconds) { /* This is not necessary but some buggy programs depend on it. */ - if (__builtin_expect (seconds == 0, 0)) + if (__glibc_unlikely (seconds == 0)) { #ifdef CANCELLATION_P CANCELLATION_P (THREAD_SELF); diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index 1f86549df3..d21c0ccf00 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -113,7 +113,7 @@ # include <hp-timing.h> # if HP_TIMING_AVAIL # define RANDOM_BITS(Var) \ - if (__builtin_expect (value == UINT64_C (0), 0)) \ + if (__glibc_unlikely (value == UINT64_C (0))) \ { \ /* If this is the first time this function is used initialize \ the variable we accumulate the value in to some somewhat \ diff --git a/sysdeps/powerpc/powerpc32/dl-irel.h b/sysdeps/powerpc/powerpc32/dl-irel.h index 16b786b72f..9d6f56a37c 100644 --- a/sysdeps/powerpc/powerpc32/dl-irel.h +++ b/sysdeps/powerpc/powerpc32/dl-irel.h @@ -39,7 +39,7 @@ elf_irela (const Elf32_Rela *reloc) { unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_PPC_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_PPC_IRELATIVE)) { Elf32_Addr *const reloc_addr = (void *) reloc->r_offset; Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend); diff --git a/sysdeps/powerpc/powerpc32/dl-machine.c b/sysdeps/powerpc/powerpc32/dl-machine.c index 4b77966e77..7ef1e3b4a6 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.c +++ b/sysdeps/powerpc/powerpc32/dl-machine.c @@ -442,19 +442,19 @@ __process_machine_rela (struct link_map *map, break; case R_PPC_ADDR24: - if (__builtin_expect (finaladdr > 0x01fffffc && finaladdr < 0xfe000000, 0)) + if (__glibc_unlikely (finaladdr > 0x01fffffc && finaladdr < 0xfe000000)) _dl_reloc_overflow (map, "R_PPC_ADDR24", reloc_addr, refsym); *reloc_addr = (*reloc_addr & 0xfc000003) | (finaladdr & 0x3fffffc); break; case R_PPC_ADDR16: - if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0)) + if (__glibc_unlikely (finaladdr > 0x7fff && finaladdr < 0xffff8000)) _dl_reloc_overflow (map, "R_PPC_ADDR16", reloc_addr, refsym); *(Elf32_Half*) reloc_addr = finaladdr; break; case R_PPC_UADDR16: - if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0)) + if (__glibc_unlikely (finaladdr > 0x7fff && finaladdr < 0xffff8000)) _dl_reloc_overflow (map, "R_PPC_UADDR16", reloc_addr, refsym); ((union unaligned *) reloc_addr)->u2 = finaladdr; break; @@ -474,7 +474,7 @@ __process_machine_rela (struct link_map *map, case R_PPC_ADDR14: case R_PPC_ADDR14_BRTAKEN: case R_PPC_ADDR14_BRNTAKEN: - if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0)) + if (__glibc_unlikely (finaladdr > 0x7fff && finaladdr < 0xffff8000)) _dl_reloc_overflow (map, "R_PPC_ADDR14", reloc_addr, refsym); *reloc_addr = (*reloc_addr & 0xffff0003) | (finaladdr & 0xfffc); if (rinfo != R_PPC_ADDR14) @@ -578,7 +578,7 @@ __process_machine_rela (struct link_map *map, inline void do_reloc16 (const char *r_name, Elf32_Addr value) { - if (__builtin_expect (value > 0x7fff && value < 0xffff8000, 0)) + if (__glibc_unlikely (value > 0x7fff && value < 0xffff8000)) _dl_reloc_overflow (map, r_name, reloc_addr, refsym); *(Elf32_Half *) reloc_addr = value; } diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h index 96d08c5d36..23b610fbf1 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.h +++ b/sysdeps/powerpc/powerpc32/dl-machine.h @@ -177,7 +177,7 @@ elf_machine_runtime_setup (struct link_map *map, extern void _dl_runtime_resolve (void); extern void _dl_prof_resolve (void); - if (__builtin_expect (!profile, 1)) + if (__glibc_likely (!profile)) dlrr = _dl_runtime_resolve; else { @@ -287,7 +287,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, return; } - if (__builtin_expect (r_type == R_PPC_NONE, 0)) + if (__glibc_unlikely (r_type == R_PPC_NONE)) return; /* binutils on ppc32 includes st_value in r_addend for relocations diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h index 8f834ce63b..ae9e1b696c 100644 --- a/sysdeps/powerpc/powerpc64/dl-irel.h +++ b/sysdeps/powerpc/powerpc64/dl-irel.h @@ -40,13 +40,13 @@ elf_irela (const Elf64_Rela *reloc) { unsigned int r_type = ELF64_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_PPC64_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_PPC64_IRELATIVE)) { Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend); *reloc_addr = value; } - else if (__builtin_expect (r_type == R_PPC64_JMP_IREL, 1)) + else if (__glibc_likely (r_type == R_PPC64_JMP_IREL)) { Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend); diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index dd44df5fa6..bc99183570 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -655,7 +655,7 @@ elf_machine_rela (struct link_map *map, return; } - if (__builtin_expect (r_type == R_PPC64_NONE, 0)) + if (__glibc_unlikely (r_type == R_PPC64_NONE)) return; /* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt @@ -680,13 +680,13 @@ elf_machine_rela (struct link_map *map, return; case R_PPC64_IRELATIVE: - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = resolve_ifunc (value, map, sym_map); *reloc_addr = value; return; case R_PPC64_JMP_IREL: - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = resolve_ifunc (value, map, sym_map); /* Fall thru */ case R_PPC64_JMP_SLOT: diff --git a/sysdeps/pthread/aio_notify.c b/sysdeps/pthread/aio_notify.c index 302f1a785b..2202572973 100644 --- a/sysdeps/pthread/aio_notify.c +++ b/sysdeps/pthread/aio_notify.c @@ -57,7 +57,7 @@ __aio_notify_only (struct sigevent *sigev) int result = 0; /* Send the signal to notify about finished processing of the request. */ - if (__builtin_expect (sigev->sigev_notify == SIGEV_THREAD, 0)) + if (__glibc_unlikely (sigev->sigev_notify == SIGEV_THREAD)) { /* We have to start a thread. */ pthread_t tid; diff --git a/sysdeps/pthread/aio_suspend.c b/sysdeps/pthread/aio_suspend.c index b8f8a5b22a..e7b43ba5ac 100644 --- a/sysdeps/pthread/aio_suspend.c +++ b/sysdeps/pthread/aio_suspend.c @@ -110,7 +110,7 @@ aio_suspend (list, nent, timeout) int nent; const struct timespec *timeout; { - if (__builtin_expect (nent < 0, 0)) + if (__glibc_unlikely (nent < 0)) { __set_errno (EINVAL); return -1; @@ -229,7 +229,7 @@ aio_suspend (list, nent, timeout) #ifndef DONT_NEED_AIO_MISC_COND /* Release the conditional variable. */ - if (__builtin_expect (pthread_cond_destroy (&cond) != 0, 0)) + if (__glibc_unlikely (pthread_cond_destroy (&cond) != 0)) /* This must never happen. */ abort (); #endif diff --git a/sysdeps/s390/dl-irel.h b/sysdeps/s390/dl-irel.h index 82d5e4c4a1..401ee1c0c2 100644 --- a/sysdeps/s390/dl-irel.h +++ b/sysdeps/s390/dl-irel.h @@ -40,7 +40,7 @@ elf_irela (const ElfW(Rela) *reloc) ElfW(Addr) *const reloc_addr = (void *) reloc->r_offset; const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); - if (__builtin_expect (r_type == R_390_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_390_IRELATIVE)) { ElfW(Addr) value = elf_ifunc_invoke(reloc->r_addend); *reloc_addr = value; diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h index 928581ed49..4fd2745801 100644 --- a/sysdeps/s390/s390-32/dl-machine.h +++ b/sysdeps/s390/s390-32/dl-machine.h @@ -114,7 +114,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) to intercept the calls to collect information. In this case we don't store the address in the GOT so that all future calls also end in this function. */ - if (__builtin_expect (profile, 0)) + if (__glibc_unlikely (profile)) { got[2] = (Elf32_Addr) &_dl_runtime_profile; @@ -277,7 +277,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_390_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_390_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; @@ -295,7 +295,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, } else #endif - if (__builtin_expect (r_type == R_390_NONE, 0)) + if (__glibc_unlikely (r_type == R_390_NONE)) return; else { @@ -316,7 +316,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, { case R_390_IRELATIVE: value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = elf_ifunc_invoke (value); *reloc_addr = value; break; @@ -448,7 +448,7 @@ elf_machine_lazy_rel (struct link_map *map, Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); /* Check for unexpected PLT reloc type. */ - if (__builtin_expect (r_type == R_390_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_390_JMP_SLOT)) { if (__builtin_expect (map->l_mach.plt, 0) == 0) *reloc_addr += l_addr; @@ -457,10 +457,10 @@ elf_machine_lazy_rel (struct link_map *map, map->l_mach.plt + (((Elf32_Addr) reloc_addr) - map->l_mach.gotplt) * 8; } - else if (__builtin_expect (r_type == R_390_IRELATIVE, 1)) + else if (__glibc_likely (r_type == R_390_IRELATIVE)) { Elf32_Addr value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = elf_ifunc_invoke (value); *reloc_addr = value; } diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index e919223c6a..2f3716987c 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -103,7 +103,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) to intercept the calls to collect information. In this case we don't store the address in the GOT so that all future calls also end in this function. */ - if (__builtin_expect (profile, 0)) + if (__glibc_unlikely (profile)) { got[2] = (Elf64_Addr) &_dl_runtime_profile; @@ -255,7 +255,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, const unsigned int r_type = ELF64_R_TYPE (reloc->r_info); #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_390_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_390_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; @@ -273,7 +273,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, } else #endif - if (__builtin_expect (r_type == R_390_NONE, 0)) + if (__glibc_unlikely (r_type == R_390_NONE)) return; else { @@ -294,7 +294,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, { case R_390_IRELATIVE: value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = elf_ifunc_invoke (value); *reloc_addr = value; break; @@ -432,7 +432,7 @@ elf_machine_lazy_rel (struct link_map *map, Elf64_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF64_R_TYPE (reloc->r_info); /* Check for unexpected PLT reloc type. */ - if (__builtin_expect (r_type == R_390_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_390_JMP_SLOT)) { if (__builtin_expect (map->l_mach.plt, 0) == 0) *reloc_addr += l_addr; @@ -441,10 +441,10 @@ elf_machine_lazy_rel (struct link_map *map, map->l_mach.plt + (((Elf64_Addr) reloc_addr) - map->l_mach.gotplt) * 4; } - else if (__builtin_expect (r_type == R_390_IRELATIVE, 1)) + else if (__glibc_likely (r_type == R_390_IRELATIVE)) { Elf64_Addr value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = elf_ifunc_invoke (value); *reloc_addr = value; } diff --git a/sysdeps/s390/s390-64/utf16-utf32-z9.c b/sysdeps/s390/s390-64/utf16-utf32-z9.c index f7d9e07957..11a098fa99 100644 --- a/sysdeps/s390/s390-64/utf16-utf32-z9.c +++ b/sysdeps/s390/s390-64/utf16-utf32-z9.c @@ -54,7 +54,7 @@ if (dir == to_utf16) \ { \ /* Emit the UTF-16 Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 2 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put16u (outbuf, BOM_UTF16); \ @@ -63,7 +63,7 @@ else \ { \ /* Emit the UTF-32 Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 4 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 4 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put32u (outbuf, BOM_UTF32); \ @@ -236,13 +236,13 @@ gconv_end (struct __gconv_step *data) { \ /* An isolated low-surrogate was found. This has to be \ considered ill-formed. */ \ - if (__builtin_expect (u1 >= 0xdc00, 0)) \ + if (__glibc_unlikely (u1 >= 0xdc00)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ } \ /* It's a surrogate character. At least the first word says \ it is. */ \ - if (__builtin_expect (inptr + 4 > inend, 0)) \ + if (__glibc_unlikely (inptr + 4 > inend)) \ { \ /* We don't have enough input for another complete input \ character. */ \ @@ -306,7 +306,7 @@ gconv_end (struct __gconv_step *data) uint16_t out; \ \ /* Generate a surrogate character. */ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c index 863677455c..74754211c1 100644 --- a/sysdeps/s390/s390-64/utf8-utf16-z9.c +++ b/sysdeps/s390/s390-64/utf8-utf16-z9.c @@ -50,7 +50,7 @@ && data->__invocation_counter == 0) \ { \ /* Emit the UTF-16 Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 2 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put16u (outbuf, BOM_UTF16); \ @@ -197,7 +197,7 @@ gconv_end (struct __gconv_step *data) if ((inptr[i] & 0xc0) != 0x80) \ break; \ \ - if (__builtin_expect (inptr + i == inend, 1)) \ + if (__glibc_likely (inptr + i == inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -210,7 +210,7 @@ gconv_end (struct __gconv_step *data) /* Next input byte. */ \ uint16_t ch = *inptr; \ \ - if (__builtin_expect (ch < 0x80, 1)) \ + if (__glibc_likely (ch < 0x80)) \ { \ /* One byte sequence. */ \ ++inptr; \ @@ -228,13 +228,13 @@ gconv_end (struct __gconv_step *data) cnt = 2; \ ch &= 0x1f; \ } \ - else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \ + else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ { \ /* We expect three bytes. */ \ cnt = 3; \ ch &= 0x0f; \ } \ - else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \ + else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ { \ /* We expect four bytes. */ \ cnt = 4; \ @@ -255,7 +255,7 @@ gconv_end (struct __gconv_step *data) STANDARD_FROM_LOOP_ERR_HANDLER (i); \ } \ \ - if (__builtin_expect (inptr + cnt > inend, 0)) \ + if (__glibc_unlikely (inptr + cnt > inend)) \ { \ /* We don't have enough input. But before we report \ that check that all the bytes are correct. */ \ @@ -263,7 +263,7 @@ gconv_end (struct __gconv_step *data) if ((inptr[i] & 0xc0) != 0x80) \ break; \ \ - if (__builtin_expect (inptr + i == inend, 1)) \ + if (__glibc_likely (inptr + i == inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -278,7 +278,7 @@ gconv_end (struct __gconv_step *data) low) are needed. */ \ uint16_t zabcd, high, low; \ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -368,7 +368,7 @@ gconv_end (struct __gconv_step *data) \ uint16_t c = get16 (inptr); \ \ - if (__builtin_expect (c <= 0x007f, 1)) \ + if (__glibc_likely (c <= 0x007f)) \ { \ /* Single byte UTF-8 char. */ \ *outptr = c & 0xff; \ @@ -378,7 +378,7 @@ gconv_end (struct __gconv_step *data) { \ /* Two byte UTF-8 char. */ \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -397,7 +397,7 @@ gconv_end (struct __gconv_step *data) { \ /* Three byte UTF-8 char. */ \ \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -419,14 +419,14 @@ gconv_end (struct __gconv_step *data) /* Four byte UTF-8 char. */ \ uint16_t low, uvwxy; \ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ break; \ } \ inptr += 2; \ - if (__builtin_expect (inptr + 2 > inend, 0)) \ + if (__glibc_unlikely (inptr + 2 > inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ diff --git a/sysdeps/s390/s390-64/utf8-utf32-z9.c b/sysdeps/s390/s390-64/utf8-utf32-z9.c index 5120837037..cb74f34075 100644 --- a/sysdeps/s390/s390-64/utf8-utf32-z9.c +++ b/sysdeps/s390/s390-64/utf8-utf32-z9.c @@ -52,7 +52,7 @@ && data->__invocation_counter == 0) \ { \ /* Emit the Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 4 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 4 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put32u (outbuf, BOM); \ @@ -201,7 +201,7 @@ gconv_end (struct __gconv_step *data) if ((inptr[i] & 0xc0) != 0x80) \ break; \ \ - if (__builtin_expect (inptr + i == inend, 1)) \ + if (__glibc_likely (inptr + i == inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -214,7 +214,7 @@ gconv_end (struct __gconv_step *data) /* Next input byte. */ \ uint32_t ch = *inptr; \ \ - if (__builtin_expect (ch < 0x80, 1)) \ + if (__glibc_likely (ch < 0x80)) \ { \ /* One byte sequence. */ \ ++inptr; \ @@ -232,25 +232,25 @@ gconv_end (struct __gconv_step *data) cnt = 2; \ ch &= 0x1f; \ } \ - else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \ + else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ { \ /* We expect three bytes. */ \ cnt = 3; \ ch &= 0x0f; \ } \ - else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \ + else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ { \ /* We expect four bytes. */ \ cnt = 4; \ ch &= 0x07; \ } \ - else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \ + else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \ { \ /* We expect five bytes. */ \ cnt = 5; \ ch &= 0x03; \ } \ - else if (__builtin_expect ((ch & 0xfe) == 0xfc, 1)) \ + else if (__glibc_likely ((ch & 0xfe) == 0xfc)) \ { \ /* We expect six bytes. */ \ cnt = 6; \ @@ -271,7 +271,7 @@ gconv_end (struct __gconv_step *data) STANDARD_FROM_LOOP_ERR_HANDLER (i); \ } \ \ - if (__builtin_expect (inptr + cnt > inend, 0)) \ + if (__glibc_unlikely (inptr + cnt > inend)) \ { \ /* We don't have enough input. But before we report \ that check that all the bytes are correct. */ \ @@ -279,7 +279,7 @@ gconv_end (struct __gconv_step *data) if ((inptr[i] & 0xc0) != 0x80) \ break; \ \ - if (__builtin_expect (inptr + i == inend, 1)) \ + if (__glibc_likely (inptr + i == inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -338,19 +338,19 @@ gconv_end (struct __gconv_step *data) cnt = 2; \ ch &= 0x1f; \ } \ - else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \ + else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \ { \ /* We expect three bytes. */ \ cnt = 3; \ ch &= 0x0f; \ } \ - else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \ + else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \ { \ /* We expect four bytes. */ \ cnt = 4; \ ch &= 0x07; \ } \ - else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \ + else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \ { \ /* We expect five bytes. */ \ cnt = 5; \ @@ -431,7 +431,7 @@ gconv_end (struct __gconv_step *data) \ uint32_t wc = *((const uint32_t *) inptr); \ \ - if (__builtin_expect (wc <= 0x7f, 1)) \ + if (__glibc_likely (wc <= 0x7f)) \ { \ /* Single UTF-8 char. */ \ *outptr = (uint8_t)wc; \ @@ -440,7 +440,7 @@ gconv_end (struct __gconv_step *data) else if (wc <= 0x7ff) \ { \ /* Two UTF-8 chars. */ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -458,7 +458,7 @@ gconv_end (struct __gconv_step *data) else if (wc <= 0xffff) \ { \ /* Three UTF-8 chars. */ \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -478,7 +478,7 @@ gconv_end (struct __gconv_step *data) else if (wc <= 0x10ffff) \ { \ /* Four UTF-8 chars. */ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ /* Overflow in the output buffer. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 5e5fd6cc79..4f3db89ed3 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -291,7 +291,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, } \ } - if (__builtin_expect (r_type == R_SH_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_SH_RELATIVE)) { #ifndef RTLD_BOOTSTRAP if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */ @@ -310,7 +310,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, } } #ifndef RTLD_BOOTSTRAP - else if (__builtin_expect (r_type == R_SH_NONE, 0)) + else if (__glibc_unlikely (r_type == R_SH_NONE)) return; #endif else diff --git a/sysdeps/sparc/sparc32/dl-irel.h b/sysdeps/sparc/sparc32/dl-irel.h index 03441ec4a5..5b61e0a24e 100644 --- a/sysdeps/sparc/sparc32/dl-irel.h +++ b/sysdeps/sparc/sparc32/dl-irel.h @@ -40,13 +40,13 @@ elf_irela (const Elf32_Rela *reloc) { unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_SPARC_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_SPARC_IRELATIVE)) { Elf32_Addr *const reloc_addr = (void *) reloc->r_offset; Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend); *reloc_addr = value; } - else if (__builtin_expect (r_type == R_SPARC_JMP_IREL, 1)) + else if (__glibc_likely (r_type == R_SPARC_JMP_IREL)) { Elf32_Addr *const reloc_addr = (void *) reloc->r_offset; Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend); diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index 91b125dd7a..e7d31b40b6 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -350,17 +350,17 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, weak_extern (_dl_rtld_map); #endif - if (__builtin_expect (r_type == R_SPARC_NONE, 0)) + if (__glibc_unlikely (r_type == R_SPARC_NONE)) return; - if (__builtin_expect (r_type == R_SPARC_SIZE32, 0)) + if (__glibc_unlikely (r_type == R_SPARC_SIZE32)) { *reloc_addr = sym->st_size + reloc->r_addend; return; } #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_SPARC_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_SPARC_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC if (map != &_dl_rtld_map) /* Already done in rtld itself. */ @@ -549,12 +549,12 @@ elf_machine_lazy_rel (struct link_map *map, Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_SPARC_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_SPARC_JMP_SLOT)) ; else if (r_type == R_SPARC_JMP_IREL) { Elf32_Addr value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = ((Elf32_Addr (*) (int)) value) (GLRO(dl_hwcap)); sparc_fixup_plt (reloc, reloc_addr, value, 1, 1); } diff --git a/sysdeps/sparc/sparc64/dl-irel.h b/sysdeps/sparc/sparc64/dl-irel.h index 85b36cd066..9aae20a40d 100644 --- a/sysdeps/sparc/sparc64/dl-irel.h +++ b/sysdeps/sparc/sparc64/dl-irel.h @@ -40,13 +40,13 @@ elf_irela (const Elf64_Rela *reloc) { unsigned int r_type = (reloc->r_info & 0xff); - if (__builtin_expect (r_type == R_SPARC_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_SPARC_IRELATIVE)) { Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend); *reloc_addr = value; } - else if (__builtin_expect (r_type == R_SPARC_JMP_IREL, 1)) + else if (__glibc_likely (r_type == R_SPARC_JMP_IREL)) { Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend); diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index b285402257..ef4ad4ce9e 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -377,17 +377,17 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, weak_extern (_dl_rtld_map); #endif - if (__builtin_expect (r_type == R_SPARC_NONE, 0)) + if (__glibc_unlikely (r_type == R_SPARC_NONE)) return; - if (__builtin_expect (r_type == R_SPARC_SIZE64, 0)) + if (__glibc_unlikely (r_type == R_SPARC_SIZE64)) { *reloc_addr = sym->st_size + reloc->r_addend; return; } #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_SPARC_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_SPARC_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC if (map != &_dl_rtld_map) /* Already done in rtld itself. */ @@ -652,13 +652,13 @@ elf_machine_lazy_rel (struct link_map *map, Elf64_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); const unsigned int r_type = ELF64_R_TYPE (reloc->r_info); - if (__builtin_expect (r_type == R_SPARC_JMP_SLOT, 1)) + if (__glibc_likely (r_type == R_SPARC_JMP_SLOT)) ; else if (r_type == R_SPARC_JMP_IREL || r_type == R_SPARC_IRELATIVE) { Elf64_Addr value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = ((Elf64_Addr (*) (int)) value) (GLRO(dl_hwcap)); if (r_type == R_SPARC_JMP_IREL) { diff --git a/sysdeps/sparc/sparc64/dl-plt.h b/sysdeps/sparc/sparc64/dl-plt.h index be1927b303..82bc18601d 100644 --- a/sysdeps/sparc/sparc64/dl-plt.h +++ b/sysdeps/sparc/sparc64/dl-plt.h @@ -115,7 +115,7 @@ sparc64_fixup_plt (struct link_map *map, const Elf64_Rela *reloc, /* ??? Some tricks can be stolen from the sparc64 egcs backend constant formation code I wrote. -DaveM */ - if (__builtin_expect (high32 & 0x3ff, 0)) + if (__glibc_unlikely (high32 & 0x3ff)) { /* sethi %hh(value), %g1 sethi %lm(value), %g5 diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c index 4a1e5b61c6..d4ca697444 100644 --- a/sysdeps/unix/clock_gettime.c +++ b/sysdeps/unix/clock_gettime.c @@ -41,14 +41,14 @@ hp_timing_gettime (clockid_t clock_id, struct timespec *tp) { hp_timing_t tsc; - if (__builtin_expect (freq == 0, 0)) + if (__glibc_unlikely (freq == 0)) { /* This can only happen if we haven't initialized the `freq' variable yet. Do this now. We don't have to protect this code against multiple execution since all of them should lead to the same result. */ freq = __get_clockfreq (); - if (__builtin_expect (freq == 0, 0)) + if (__glibc_unlikely (freq == 0)) /* Something went wrong. */ return -1; } diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c index f3c67ef8c9..7ce6dfc1f2 100644 --- a/sysdeps/unix/clock_settime.c +++ b/sysdeps/unix/clock_settime.c @@ -43,14 +43,14 @@ hp_timing_settime (clockid_t clock_id, const struct timespec *tp) /* First thing is to get the current time. */ HP_TIMING_NOW (tsc); - if (__builtin_expect (freq == 0, 0)) + if (__glibc_unlikely (freq == 0)) { /* This can only happen if we haven't initialized the `freq' variable yet. Do this now. We don't have to protect this code against multiple execution since all of them should lead to the same result. */ freq = __get_clockfreq (); - if (__builtin_expect (freq == 0, 0)) + if (__glibc_unlikely (freq == 0)) /* Something went wrong. */ return -1; } diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c index 602dfb623a..c4f067f036 100644 --- a/sysdeps/unix/grantpt.c +++ b/sysdeps/unix/grantpt.c @@ -108,7 +108,7 @@ grantpt (int fd) char *buf = _buf; struct stat64 st; - if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf), &st), 0)) + if (__glibc_unlikely (pts_name (fd, &buf, sizeof (_buf), &st))) { int save_errno = errno; @@ -136,7 +136,7 @@ grantpt (int fd) } static int tty_gid = -1; - if (__builtin_expect (tty_gid == -1, 0)) + if (__glibc_unlikely (tty_gid == -1)) { char *grtmpbuf; struct group grbuf; diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c index 0e2113434a..019e96b677 100644 --- a/sysdeps/unix/sysv/linux/accept4.c +++ b/sysdeps/unix/sysv/linux/accept4.c @@ -52,7 +52,7 @@ static int have_accept4; int accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) { - if (__builtin_expect (have_accept4 >= 0, 1)) + if (__glibc_likely (have_accept4 >= 0)) { int ret = __internal_accept4 (fd, addr, addr_len, flags); /* The kernel returns -EINVAL for unknown socket operations. diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 45d4680645..be49911eeb 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -83,7 +83,7 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) #if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ again: #endif - if (__builtin_expect (ADJTIMEX (&tntx) < 0, 0)) + if (__glibc_unlikely (ADJTIMEX (&tntx) < 0)) { #if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ) diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index dd333b4a94..5c8e75affc 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -331,7 +331,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, { int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if (__builtin_expect (fd >= 0, 1)) + if (__glibc_likely (fd >= 0)) { struct sockaddr_nl nladdr; memset (&nladdr, '\0', sizeof (nladdr)); diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h index 6608e6adb3..af1343822f 100644 --- a/sysdeps/unix/sysv/linux/dl-osinfo.h +++ b/sysdeps/unix/sysv/linux/dl-osinfo.h @@ -33,7 +33,7 @@ if the library is not compiled to run on all kernels. */ \ \ int version = _dl_discover_osversion (); \ - if (__builtin_expect (version >= 0, 1)) \ + if (__glibc_likely (version >= 0)) \ { \ if (__builtin_expect (GLRO(dl_osversion) == 0, 1) \ || GLRO(dl_osversion) > version) \ @@ -58,7 +58,7 @@ _dl_setup_stack_chk_guard (void *dl_random) } ret; #ifndef __ASSUME_AT_RANDOM - if (__builtin_expect (dl_random == NULL, 0)) + if (__glibc_unlikely (dl_random == NULL)) { const size_t filllen = sizeof (ret.bytes) - 1; ret.num = 0; diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index 06abac278d..c00f431a45 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -71,7 +71,7 @@ faccessat (fd, file, mode, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -102,7 +102,7 @@ faccessat (fd, file, mode, flag) # endif result = INTERNAL_SYSCALL (access, err, 2, file, mode); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index 803988d88c..4d3e43e371 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -70,7 +70,7 @@ fchmodat (fd, file, mode, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -100,7 +100,7 @@ fchmodat (fd, file, mode, flag) # endif result = INTERNAL_SYSCALL (chmod, err, 2, file, mode); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/fchownat.c b/sysdeps/unix/sysv/linux/fchownat.c index b0329cd2c2..196b8005c3 100644 --- a/sysdeps/unix/sysv/linux/fchownat.c +++ b/sysdeps/unix/sysv/linux/fchownat.c @@ -65,7 +65,7 @@ fchownat (fd, file, owner, group, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -93,7 +93,7 @@ fchownat (fd, file, owner, group, flag) else result = INTERNAL_SYSCALL (chown, err, 3, file, owner, group); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/futimesat.c b/sysdeps/unix/sysv/linux/futimesat.c index ce7290e0f3..89ea20b121 100644 --- a/sysdeps/unix/sysv/linux/futimesat.c +++ b/sysdeps/unix/sysv/linux/futimesat.c @@ -75,7 +75,7 @@ futimesat (fd, file, tvp) else if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -100,7 +100,7 @@ futimesat (fd, file, tvp) # ifdef __NR_utimes result = INTERNAL_SYSCALL (utimes, err, 2, file, tvp); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) return result; # ifndef __ASSUME_UTIMES @@ -126,7 +126,7 @@ futimesat (fd, file, tvp) times = NULL; result = INTERNAL_SYSCALL (utime, err, 2, file, times); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) return result; fail: diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c index 9acbf36a9b..1ec0922350 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c +++ b/sysdeps/unix/sysv/linux/fxstatat.c @@ -84,7 +84,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -114,7 +114,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) result = INTERNAL_SYSCALL (stat, err, 2, file, (struct kernel_stat *) st); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) return result; } #ifdef STAT_IS_KERNEL_STAT @@ -129,7 +129,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) else result = INTERNAL_SYSCALL (stat, err, 2, file, &kst); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) return __xstat_conv (vers, &kst, st); #endif diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index b6195c877a..24bd51bf46 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -33,7 +33,7 @@ int __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) { - if (__builtin_expect (vers != _STAT_VER_LINUX, 0)) + if (__glibc_unlikely (vers != _STAT_VER_LINUX)) { __set_errno (EINVAL); return -1; @@ -76,7 +76,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -101,7 +101,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) result = INTERNAL_SYSCALL (lstat64, err, 2, file, st); else result = INTERNAL_SYSCALL (stat64, err, 2, file, st); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) { # if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0 if (st->__st_ino != (__ino_t) st->st_ino) diff --git a/sysdeps/unix/sysv/linux/i386/fallocate.c b/sysdeps/unix/sysv/linux/i386/fallocate.c index 00fc6f3b76..3a4299ee29 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate.c @@ -40,7 +40,7 @@ fallocate (int fd, int mode, __off_t offset, __off_t len) LIBC_CANCEL_RESET (oldtype); } - if (__builtin_expect (err, 0)) + if (__glibc_unlikely (err)) { __set_errno (err); err = -1; diff --git a/sysdeps/unix/sysv/linux/i386/fallocate64.c b/sysdeps/unix/sysv/linux/i386/fallocate64.c index 14c304877d..d69021b633 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate64.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate64.c @@ -40,7 +40,7 @@ fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) LIBC_CANCEL_RESET (oldtype); } - if (__builtin_expect (err, 0)) + if (__glibc_unlikely (err)) { __set_errno (err); err = -1; diff --git a/sysdeps/unix/sysv/linux/i386/fchownat.c b/sysdeps/unix/sysv/linux/i386/fchownat.c index 7726bb6f72..5c2359c8b5 100644 --- a/sysdeps/unix/sysv/linux/i386/fchownat.c +++ b/sysdeps/unix/sysv/linux/i386/fchownat.c @@ -61,7 +61,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -89,7 +89,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) else result = INTERNAL_SYSCALL (chown32, err, 3, file, owner, group); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); return -1; diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c index 4180947dca..8fdbbb81f5 100644 --- a/sysdeps/unix/sysv/linux/i386/fxstatat.c +++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c @@ -66,7 +66,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) #endif #ifndef __ASSUME_ATFCTS - if (__builtin_expect (flag & ~AT_SYMLINK_NOFOLLOW, 0)) + if (__glibc_unlikely (flag & ~AT_SYMLINK_NOFOLLOW)) { __set_errno (EINVAL); return -1; @@ -77,7 +77,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -113,11 +113,11 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) result = INTERNAL_SYSCALL (lstat64, err, 2, file, &st64); else result = INTERNAL_SYSCALL (stat64, err, 2, file, &st64); - if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result, err))) return __xstat32_conv (vers, &st64, st); out: - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c index 9555c26580..024d4d0108 100644 --- a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c @@ -40,7 +40,7 @@ __get_clockfreq (void) return result; fd = __open ("/proc/cpuinfo", O_RDONLY); - if (__builtin_expect (fd != -1, 1)) + if (__glibc_likely (fd != -1)) { /* XXX AFAIK the /proc filesystem can generate "files" only up to a size of 4096 bytes. */ @@ -52,7 +52,7 @@ __get_clockfreq (void) { char *mhz = memmem (buf, n, "cpu MHz", 7); - if (__builtin_expect (mhz != NULL, 1)) + if (__glibc_likely (mhz != NULL)) { char *endp = buf + n; int seen_decpoint = 0; diff --git a/sysdeps/unix/sysv/linux/i386/posix_fallocate.c b/sysdeps/unix/sysv/linux/i386/posix_fallocate.c index bcadf8ddfb..f532898e5b 100644 --- a/sysdeps/unix/sysv/linux/i386/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/i386/posix_fallocate.c @@ -36,7 +36,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) { #ifdef __NR_fallocate # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) + if (__glibc_likely (__have_fallocate >= 0)) # endif { int res = __call_fallocate (fd, 0, offset, len); @@ -44,7 +44,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) return 0; # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (res == ENOSYS, 0)) + if (__glibc_unlikely (res == ENOSYS)) __have_fallocate = -1; else # endif diff --git a/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c b/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c index 4fa61e8110..1aa1fcf316 100644 --- a/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c @@ -38,7 +38,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) + if (__glibc_likely (__have_fallocate >= 0)) # endif { int res = __call_fallocate (fd, 0, offset, len); @@ -47,7 +47,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) return 0; # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (res == ENOSYS, 0)) + if (__glibc_unlikely (res == ENOSYS)) __have_fallocate = -1; else # endif diff --git a/sysdeps/unix/sysv/linux/i386/scandir64.c b/sysdeps/unix/sysv/linux/i386/scandir64.c index 90abe32a2b..2782eeb04e 100644 --- a/sysdeps/unix/sysv/linux/i386/scandir64.c +++ b/sysdeps/unix/sysv/linux/i386/scandir64.c @@ -85,7 +85,7 @@ __old_scandir64 (dir, namelist, select, cmp) /* Ignore errors from select or readdir */ __set_errno (0); - if (__builtin_expect (c.cnt == vsize, 0)) + if (__glibc_unlikely (c.cnt == vsize)) { struct __old_dirent64 **new; if (vsize == 0) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 01888e9ce4..54f87c9f71 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -310,7 +310,7 @@ asm (".L__X'%ebx = 1\n\t" #define INLINE_SYSCALL(name, nr, args...) \ ({ \ unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \ resultvar = 0xffffffff; \ diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 7b8867100f..d83e8f8e84 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -175,7 +175,7 @@ __netlink_request (struct netlink_handle *h, int type) if (nladdr.nl_pid != 0) continue; - if (__builtin_expect (msg.msg_flags & MSG_TRUNC, 0)) + if (__glibc_unlikely (msg.msg_flags & MSG_TRUNC)) goto out_fail; size_t count = 0; @@ -459,7 +459,7 @@ getifaddrs_internal (struct ifaddrs **ifap) kernel. */ ifa_index = map_newlink (ifim->ifi_index - 1, ifas, map_newlink_data, newlink); - if (__builtin_expect (ifa_index == -1, 0)) + if (__glibc_unlikely (ifa_index == -1)) { try_again: result = -EAGAIN; @@ -552,7 +552,7 @@ getifaddrs_internal (struct ifaddrs **ifap) ifa_index = newlink + newaddr_idx; int idx = map_newlink (ifam->ifa_index - 1, ifas, map_newlink_data, newlink); - if (__builtin_expect (idx == -1, 0)) + if (__glibc_unlikely (idx == -1)) goto try_again; ifas[ifa_index].ifa.ifa_flags = ifas[idx].ifa.ifa_flags; if (ifa_index > 0) @@ -737,7 +737,7 @@ getifaddrs_internal (struct ifaddrs **ifap) { int idx = map_newlink (ifam->ifa_index - 1, ifas, map_newlink_data, newlink); - if (__builtin_expect (idx == -1, 0)) + if (__glibc_unlikely (idx == -1)) goto try_again; ifas[ifa_index].ifa.ifa_name = ifas[idx].ifa.ifa_name; } diff --git a/sysdeps/unix/sysv/linux/linkat.c b/sysdeps/unix/sysv/linux/linkat.c index ad09be64b3..29cefb8192 100644 --- a/sysdeps/unix/sysv/linux/linkat.c +++ b/sysdeps/unix/sysv/linux/linkat.c @@ -65,7 +65,7 @@ linkat (fromfd, from, tofd, to, flags) if (fromfd != AT_FDCWD && from[0] != '/') { size_t filelen = strlen (from); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -108,7 +108,7 @@ linkat (fromfd, from, tofd, to, flags) result = INTERNAL_SYSCALL (link, err, 2, from, to); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno_2 (INTERNAL_SYSCALL_ERRNO (result, err), tofd, bufto, fromfd, buffrom); diff --git a/sysdeps/unix/sysv/linux/mkdirat.c b/sysdeps/unix/sysv/linux/mkdirat.c index 72d69c58f3..77099f3533 100644 --- a/sysdeps/unix/sysv/linux/mkdirat.c +++ b/sysdeps/unix/sysv/linux/mkdirat.c @@ -56,7 +56,7 @@ mkdirat (fd, file, mode) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -80,7 +80,7 @@ mkdirat (fd, file, mode) INTERNAL_SYSCALL_DECL (err); res = INTERNAL_SYSCALL (mkdir, err, 2, file, mode); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); res = -1; diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index e16e4184fd..c5f12d8a7b 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -36,7 +36,7 @@ mq_unlink (const char *name) /* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret, err))) { ret = INTERNAL_SYSCALL_ERRNO (ret, err); if (ret == EPERM) diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index 9bb8acec1f..2cf233b8de 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -108,7 +108,7 @@ OPENAT_NOT_CANCEL (fd, file, oflag, mode) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -132,7 +132,7 @@ OPENAT_NOT_CANCEL (fd, file, oflag, mode) res = INTERNAL_SYSCALL (open, err, 3, file, oflag, mode); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); res = -1; diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c index 477f9f8574..cb75ffc1fa 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -34,7 +34,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) { #ifdef __NR_fallocate # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) + if (__glibc_likely (__have_fallocate >= 0)) # endif { INTERNAL_SYSCALL_DECL (err); @@ -46,7 +46,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) return 0; # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS)) __have_fallocate = -1; else # endif diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 73983aed5b..4f5881b96c 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -36,7 +36,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) + if (__glibc_likely (__have_fallocate >= 0)) # endif { INTERNAL_SYSCALL_DECL (err); @@ -50,7 +50,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) return 0; # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS)) __have_fallocate = -1; else # endif diff --git a/sysdeps/unix/sysv/linux/powerpc/fchownat.c b/sysdeps/unix/sysv/linux/powerpc/fchownat.c index 61e0a4dc56..4e3767a6a0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/fchownat.c +++ b/sysdeps/unix/sysv/linux/powerpc/fchownat.c @@ -65,7 +65,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -93,7 +93,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) else result = INTERNAL_SYSCALL (chown, err, 3, file, owner, group); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); return -1; diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c index 0a6aa81fb0..8b37943863 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -49,7 +49,7 @@ __get_clockfreq (void) { int fd = __open ("/proc/cpuinfo", O_RDONLY); - if (__builtin_expect (fd != -1, 1)) + if (__glibc_likely (fd != -1)) { /* The timebase will be in the 1st 1024 bytes for systems with up to 8 processors. If the first read returns less then 1024 @@ -87,7 +87,7 @@ __get_clockfreq (void) { char *mhz = memmem (buf, n, "timebase", 7); - if (__builtin_expect (mhz != NULL, 1)) + if (__glibc_likely (mhz != NULL)) { char *endp = buf + n; diff --git a/sysdeps/unix/sysv/linux/readlinkat.c b/sysdeps/unix/sysv/linux/readlinkat.c index 8fbbd414ac..7d096d3c36 100644 --- a/sysdeps/unix/sysv/linux/readlinkat.c +++ b/sysdeps/unix/sysv/linux/readlinkat.c @@ -58,7 +58,7 @@ readlinkat (fd, path, buf, len) if (fd != AT_FDCWD && path[0] != '/') { size_t pathlen = strlen (path); - if (__builtin_expect (pathlen == 0, 0)) + if (__glibc_unlikely (pathlen == 0)) { __set_errno (ENOENT); return -1; @@ -83,7 +83,7 @@ readlinkat (fd, path, buf, len) result = INTERNAL_SYSCALL (readlink, err, 3, path, buf, len); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, pathbuf); result = -1; diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index bcb9a6cf5c..04ff42ee72 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -53,7 +53,7 @@ int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, const struct timespec *tmo) { - if (__builtin_expect (have_recvmmsg >= 0, 1)) + if (__glibc_likely (have_recvmmsg >= 0)) { int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo); /* The kernel returns -EINVAL for unknown socket operations. diff --git a/sysdeps/unix/sysv/linux/renameat.c b/sysdeps/unix/sysv/linux/renameat.c index 8addae2d57..dbc4c75c01 100644 --- a/sysdeps/unix/sysv/linux/renameat.c +++ b/sysdeps/unix/sysv/linux/renameat.c @@ -134,7 +134,7 @@ renameat (oldfd, old, newfd, new) if (oldfd != AT_FDCWD && old[0] != '/') { size_t filelen = strlen (old); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -159,7 +159,7 @@ renameat (oldfd, old, newfd, new) if (newfd != AT_FDCWD && new[0] != '/') { size_t filelen = strlen (new); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -183,7 +183,7 @@ renameat (oldfd, old, newfd, new) result = INTERNAL_SYSCALL (rename, err, 2, old, new); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno_2 (INTERNAL_SYSCALL_ERRNO (result, err), newfd, bufnew, oldfd, bufold); diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h index fa7c8c50e5..1c6191b261 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h @@ -182,7 +182,7 @@ #define INLINE_SYSCALL(name, nr, args...) \ ({ \ unsigned int _ret = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_ret, ), 0)) \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \ _ret = 0xffffffff; \ diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h index 020cd9ad45..91fc275585 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h @@ -188,7 +188,7 @@ #define INLINE_SYSCALL(name, nr, args...) \ ({ \ long _ret = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_ret, ), 0)) \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \ _ret = -1; \ diff --git a/sysdeps/unix/sysv/linux/sched_setaffinity.c b/sysdeps/unix/sysv/linux/sched_setaffinity.c index 77345338ef..1f8ebba9fc 100644 --- a/sysdeps/unix/sysv/linux/sched_setaffinity.c +++ b/sysdeps/unix/sysv/linux/sched_setaffinity.c @@ -32,7 +32,7 @@ static size_t __kernel_cpumask_size; int __sched_setaffinity_new (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset) { - if (__builtin_expect (__kernel_cpumask_size == 0, 0)) + if (__glibc_unlikely (__kernel_cpumask_size == 0)) { INTERNAL_SYSCALL_DECL (err); int res; diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c index 598ff40d75..f8494be044 100644 --- a/sysdeps/unix/sysv/linux/sendmmsg.c +++ b/sysdeps/unix/sysv/linux/sendmmsg.c @@ -52,7 +52,7 @@ static int have_sendmmsg; int __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) { - if (__builtin_expect (have_sendmmsg >= 0, 1)) + if (__glibc_likely (have_sendmmsg >= 0)) { int ret = __internal_sendmmsg (fd, vmessages, vlen, flags); /* The kernel returns -EINVAL for unknown socket operations. diff --git a/sysdeps/unix/sysv/linux/shm_open.c b/sysdeps/unix/sysv/linux/shm_open.c index fef8fd531a..cec6fdbd0c 100644 --- a/sysdeps/unix/sysv/linux/shm_open.c +++ b/sysdeps/unix/sysv/linux/shm_open.c @@ -75,10 +75,10 @@ where_is_shmfs (void) /* OK, do it the hard way. Look through the /proc/mounts file and if this does not exist through /etc/fstab to find the mount point. */ fp = __setmntent ("/proc/mounts", "r"); - if (__builtin_expect (fp == NULL, 0)) + if (__glibc_unlikely (fp == NULL)) { fp = __setmntent (_PATH_MNTTAB, "r"); - if (__builtin_expect (fp == NULL, 0)) + if (__glibc_unlikely (fp == NULL)) /* There is nothing we can do. Blind guesses are not helpful. */ return; } @@ -208,7 +208,7 @@ shm_open (const char *name, int oflag, mode_t mode) } #endif } - else if (__builtin_expect (errno == EISDIR, 0)) + else if (__glibc_unlikely (errno == EISDIR)) /* It might be better to fold this error with EINVAL since directory names are just another example for unsuitable shared object names and the standard does not mention EISDIR. */ diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c index 46b731e0a7..3b352c68bc 100644 --- a/sysdeps/unix/sysv/linux/sleep.c +++ b/sysdeps/unix/sysv/linux/sleep.c @@ -47,7 +47,7 @@ __sleep (unsigned int seconds) unsigned int result; /* This is not necessary but some buggy programs depend on this. */ - if (__builtin_expect (seconds == 0, 0)) + if (__glibc_unlikely (seconds == 0)) { #ifdef CANCELLATION_P CANCELLATION_P (THREAD_SELF); diff --git a/sysdeps/unix/sysv/linux/symlinkat.c b/sysdeps/unix/sysv/linux/symlinkat.c index ae9bb359ad..0c5ed3f5f9 100644 --- a/sysdeps/unix/sysv/linux/symlinkat.c +++ b/sysdeps/unix/sysv/linux/symlinkat.c @@ -56,7 +56,7 @@ symlinkat (from, tofd, to) if (tofd != AT_FDCWD && to[0] != '/') { size_t tolen = strlen (to); - if (__builtin_expect (tolen == 0, 0)) + if (__glibc_unlikely (tolen == 0)) { __set_errno (ENOENT); return -1; @@ -81,7 +81,7 @@ symlinkat (from, tofd, to) result = INTERNAL_SYSCALL (symlink, err, 2, from, to); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), tofd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c index a739100e37..d759f7a417 100644 --- a/sysdeps/unix/sysv/linux/tcgetattr.c +++ b/sysdeps/unix/sysv/linux/tcgetattr.c @@ -39,7 +39,7 @@ __tcgetattr (fd, termios_p) retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); - if (__builtin_expect (retval == 0, 1)) + if (__glibc_likely (retval == 0)) { termios_p->c_iflag = k_termios.c_iflag; termios_p->c_oflag = k_termios.c_oflag; diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 8d808ce373..d257d25977 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -127,7 +127,7 @@ ttyname (int fd) /* isatty check, tcgetattr is used because it sets the correct errno (EBADF resp. ENOTTY) on error. */ - if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0)) + if (__glibc_unlikely (__tcgetattr (fd, &term) < 0)) return NULL; if (__fxstat64 (_STAT_VER, fd, &st) < 0) @@ -148,7 +148,7 @@ ttyname (int fd) } ssize_t len = __readlink (procname, ttyname_buf, buflen); - if (__builtin_expect (len != -1, 1)) + if (__glibc_likely (len != -1)) { if ((size_t) len >= buflen) return NULL; diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c index a03d012f8d..6ce85db33b 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c +++ b/sysdeps/unix/sysv/linux/ttyname_r.c @@ -118,7 +118,7 @@ __ttyname_r (int fd, char *buf, size_t buflen) /* isatty check, tcgetattr is used because it sets the correct errno (EBADF resp. ENOTTY) on error. */ struct termios term; - if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0)) + if (__glibc_unlikely (__tcgetattr (fd, &term) < 0)) return errno; if (__fxstat64 (_STAT_VER, fd, &st) < 0) @@ -128,13 +128,13 @@ __ttyname_r (int fd, char *buf, size_t buflen) *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; ssize_t ret = __readlink (procname, buf, buflen - 1); - if (__builtin_expect (ret == -1 && errno == ENAMETOOLONG, 0)) + if (__glibc_unlikely (ret == -1 && errno == ENAMETOOLONG)) { __set_errno (ERANGE); return ERANGE; } - if (__builtin_expect (ret != -1, 1)) + if (__glibc_likely (ret != -1)) { #define UNREACHABLE_LEN strlen ("(unreachable)") if (ret > UNREACHABLE_LEN diff --git a/sysdeps/unix/sysv/linux/unlinkat.c b/sysdeps/unix/sysv/linux/unlinkat.c index 0925d85800..6366c867e1 100644 --- a/sysdeps/unix/sysv/linux/unlinkat.c +++ b/sysdeps/unix/sysv/linux/unlinkat.c @@ -63,7 +63,7 @@ unlinkat (fd, file, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -91,7 +91,7 @@ unlinkat (fd, file, flag) else result = INTERNAL_SYSCALL (unlink, err, 1, file); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); result = -1; diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c index 29f0e540d1..5aec8af39c 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c +++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c @@ -70,7 +70,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; @@ -98,7 +98,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) else res = INTERNAL_SYSCALL (stat, err, 2, file, st); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) { __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); res = -1; diff --git a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c index 8f3b521ed7..84e42a1f0a 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c @@ -34,7 +34,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) { #ifdef __NR_fallocate # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (__have_fallocate >= 0, 1)) + if (__glibc_likely (__have_fallocate >= 0)) # endif { INTERNAL_SYSCALL_DECL (err); @@ -50,7 +50,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) return 0; # ifndef __ASSUME_FALLOCATE - if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS)) __have_fallocate = -1; else # endif diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 4a9a9d90bc..f52690feeb 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -193,7 +193,7 @@ # define INLINE_SYSCALL(name, nr, args...) \ ({ \ unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \ resultvar = (unsigned long int) -1; \ @@ -207,7 +207,7 @@ # define INLINE_SYSCALL_TYPES(name, nr, args...) \ ({ \ unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \ + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \ resultvar = (unsigned long int) -1; \ diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c index 62e47e1eed..9e3643f71b 100644 --- a/sysdeps/unix/sysv/linux/xmknodat.c +++ b/sysdeps/unix/sysv/linux/xmknodat.c @@ -70,7 +70,7 @@ __xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); - if (__builtin_expect (filelen == 0, 0)) + if (__glibc_unlikely (filelen == 0)) { __set_errno (ENOENT); return -1; diff --git a/sysdeps/x86_64/dl-irel.h b/sysdeps/x86_64/dl-irel.h index 1249fe823f..f0f2f4b4e8 100644 --- a/sysdeps/x86_64/dl-irel.h +++ b/sysdeps/x86_64/dl-irel.h @@ -39,7 +39,7 @@ elf_irela (const ElfW(Rela) *reloc) ElfW(Addr) *const reloc_addr = (void *) reloc->r_offset; const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); - if (__builtin_expect (r_type == R_X86_64_IRELATIVE, 1)) + if (__glibc_likely (r_type == R_X86_64_IRELATIVE)) { ElfW(Addr) value = elf_ifunc_invoke(reloc->r_addend); *reloc_addr = value; diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 504c95f320..8df04a96ca 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -92,7 +92,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) to intercept the calls to collect information. In this case we don't store the address in the GOT so that all future calls also end in this function. */ - if (__builtin_expect (profile, 0)) + if (__glibc_unlikely (profile)) { *(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_profile; @@ -241,7 +241,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); # if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC - if (__builtin_expect (r_type == R_X86_64_RELATIVE, 0)) + if (__glibc_unlikely (r_type == R_X86_64_RELATIVE)) { # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; @@ -262,11 +262,11 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, # if !defined RTLD_BOOTSTRAP /* l_addr + r_addend may be > 0xffffffff and R_X86_64_RELATIVE64 relocation updates the whole 64-bit entry. */ - if (__builtin_expect (r_type == R_X86_64_RELATIVE64, 0)) + if (__glibc_unlikely (r_type == R_X86_64_RELATIVE64)) *(Elf64_Addr *) reloc_addr = (Elf64_Addr) map->l_addr + reloc->r_addend; else # endif - if (__builtin_expect (r_type == R_X86_64_NONE, 0)) + if (__glibc_unlikely (r_type == R_X86_64_NONE)) return; else { @@ -419,7 +419,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, *(unsigned int *) reloc_addr = value; const char *fmt; - if (__builtin_expect (value > UINT_MAX, 0)) + if (__glibc_unlikely (value > UINT_MAX)) { const char *strtab; @@ -438,7 +438,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, case R_X86_64_PC32: value += reloc->r_addend - (ElfW(Addr)) reloc_addr; *(unsigned int *) reloc_addr = value; - if (__builtin_expect (value != (int) value, 0)) + if (__glibc_unlikely (value != (int) value)) { fmt = "\ %s: Symbol `%s' causes overflow in R_X86_64_PC32 relocation\n"; @@ -484,7 +484,7 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc, #if !defined RTLD_BOOTSTRAP /* l_addr + r_addend may be > 0xffffffff and R_X86_64_RELATIVE64 relocation updates the whole 64-bit entry. */ - if (__builtin_expect (ELFW(R_TYPE) (reloc->r_info) == R_X86_64_RELATIVE64, 0)) + if (__glibc_unlikely (ELFW(R_TYPE) (reloc->r_info) == R_X86_64_RELATIVE64)) *(Elf64_Addr *) reloc_addr = (Elf64_Addr) l_addr + reloc->r_addend; else #endif @@ -504,7 +504,7 @@ elf_machine_lazy_rel (struct link_map *map, const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); /* Check for unexpected PLT reloc type. */ - if (__builtin_expect (r_type == R_X86_64_JUMP_SLOT, 1)) + if (__glibc_likely (r_type == R_X86_64_JUMP_SLOT)) { if (__builtin_expect (map->l_mach.plt, 0) == 0) *reloc_addr += l_addr; @@ -513,7 +513,7 @@ elf_machine_lazy_rel (struct link_map *map, map->l_mach.plt + (((ElfW(Addr)) reloc_addr) - map->l_mach.gotplt) * 2; } - else if (__builtin_expect (r_type == R_X86_64_TLSDESC, 1)) + else if (__glibc_likely (r_type == R_X86_64_TLSDESC)) { struct tlsdesc volatile * __attribute__((__unused__)) td = (struct tlsdesc volatile *)reloc_addr; @@ -522,10 +522,10 @@ elf_machine_lazy_rel (struct link_map *map, td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)]) + map->l_addr); } - else if (__builtin_expect (r_type == R_X86_64_IRELATIVE, 0)) + else if (__glibc_unlikely (r_type == R_X86_64_IRELATIVE)) { ElfW(Addr) value = map->l_addr + reloc->r_addend; - if (__builtin_expect (!skip_ifunc, 1)) + if (__glibc_likely (!skip_ifunc)) value = ((ElfW(Addr) (*) (void)) value) (); *reloc_addr = value; } |