From a1ffb40e32741f992c743e7b16c061fefa3747ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20B=C3=ADlka?= Date: Mon, 10 Feb 2014 14:45:42 +0100 Subject: [PATCH] Use glibc_likely instead __builtin_expect. --- ChangeLog | 496 +++++++++++++++++++++ assert/assert.c | 2 +- benchtests/bench-memmem.c | 2 +- catgets/open_catalog.c | 4 +- csu/libc-start.c | 8 +- debug/confstr_chk.c | 2 +- debug/fread_chk.c | 2 +- debug/fread_u_chk.c | 2 +- debug/getgroups_chk.c | 4 +- debug/mbsnrtowcs_chk.c | 2 +- debug/mbsrtowcs_chk.c | 2 +- debug/mbstowcs_chk.c | 2 +- debug/memcpy_chk.c | 2 +- debug/memmove_chk.c | 2 +- debug/mempcpy_chk.c | 2 +- debug/memset_chk.c | 2 +- debug/stpcpy_chk.c | 2 +- debug/strcat_chk.c | 4 +- debug/strcpy_chk.c | 2 +- debug/strncat_chk.c | 14 +- debug/vsnprintf_chk.c | 2 +- debug/vswprintf_chk.c | 4 +- debug/wcpcpy_chk.c | 2 +- debug/wcpncpy_chk.c | 2 +- debug/wcscat_chk.c | 4 +- debug/wcscpy_chk.c | 4 +- debug/wcsncat_chk.c | 14 +- debug/wcsncpy_chk.c | 2 +- debug/wcsnrtombs_chk.c | 2 +- debug/wcsrtombs_chk.c | 2 +- debug/wcstombs_chk.c | 2 +- debug/wmemcpy_chk.c | 2 +- debug/wmemmove_chk.c | 2 +- debug/wmempcpy_chk.c | 2 +- debug/wmemset_chk.c | 2 +- dirent/scandirat.c | 2 +- dlfcn/dladdr.c | 2 +- dlfcn/dladdr1.c | 2 +- dlfcn/dlclose.c | 2 +- dlfcn/dlerror.c | 2 +- dlfcn/dlinfo.c | 2 +- dlfcn/dlmopen.c | 4 +- dlfcn/dlopen.c | 2 +- dlfcn/dlopenold.c | 2 +- dlfcn/dlsym.c | 2 +- dlfcn/dlvsym.c | 2 +- elf/dl-cache.c | 4 +- elf/dl-close.c | 18 +- elf/dl-conflict.c | 2 +- elf/dl-deps.c | 12 +- elf/dl-dst.h | 2 +- elf/dl-fini.c | 10 +- elf/dl-fptr.c | 2 +- elf/dl-hwcaps.c | 2 +- elf/dl-init.c | 6 +- elf/dl-libc.c | 6 +- elf/dl-load.c | 50 +-- elf/dl-lookup.c | 28 +- elf/dl-minimal.c | 2 +- elf/dl-open.c | 30 +- elf/dl-reloc.c | 6 +- elf/dl-runtime.c | 4 +- elf/dl-sym.c | 8 +- elf/dl-tls.c | 16 +- elf/dl-version.c | 10 +- elf/dl-writev.h | 2 +- elf/ldconfig.c | 4 +- elf/rtld.c | 40 +- elf/setup-vdso.h | 2 +- grp/compat-initgroups.c | 2 +- grp/fgetgrent.c | 2 +- grp/initgroups.c | 4 +- grp/putgrent.c | 2 +- hesiod/nss_hesiod/hesiod-grp.c | 2 +- hurd/hurdinit.c | 2 +- iconv/gconv_cache.c | 2 +- iconv/gconv_close.c | 2 +- iconv/gconv_open.c | 4 +- iconv/gconv_simple.c | 58 +-- iconv/iconv.c | 2 +- iconv/iconv_close.c | 2 +- iconv/loop.c | 4 +- iconv/skeleton.c | 18 +- iconvdata/8bit-gap.c | 2 +- iconvdata/ansi_x3.110.c | 2 +- iconvdata/big5.c | 4 +- iconvdata/big5hkscs.c | 18 +- iconvdata/cp1255.c | 10 +- iconvdata/cp1258.c | 8 +- iconvdata/cp932.c | 4 +- iconvdata/euc-cn.c | 6 +- iconvdata/euc-jisx0213.c | 24 +- iconvdata/euc-jp-ms.c | 12 +- iconvdata/euc-jp.c | 8 +- iconvdata/euc-kr.c | 6 +- iconvdata/gb18030.c | 4 +- iconvdata/gbbig5.c | 14 +- iconvdata/gbgbk.c | 10 +- iconvdata/gbk.c | 2 +- iconvdata/ibm1364.c | 16 +- iconvdata/ibm930.c | 14 +- iconvdata/ibm932.c | 10 +- iconvdata/ibm933.c | 14 +- iconvdata/ibm935.c | 14 +- iconvdata/ibm937.c | 14 +- iconvdata/ibm939.c | 14 +- iconvdata/ibm943.c | 10 +- iconvdata/iso-2022-cn-ext.c | 2 +- iconvdata/iso-2022-cn.c | 16 +- iconvdata/iso-2022-jp-3.c | 40 +- iconvdata/iso-2022-jp.c | 44 +- iconvdata/iso-2022-kr.c | 12 +- iconvdata/iso646.c | 2 +- iconvdata/iso8859-1.c | 2 +- iconvdata/iso_11548-1.c | 2 +- iconvdata/iso_6937-2.c | 6 +- iconvdata/iso_6937.c | 8 +- iconvdata/johab.c | 12 +- iconvdata/shift_jisx0213.c | 20 +- iconvdata/sjis.c | 8 +- iconvdata/t.61.c | 4 +- iconvdata/tcvn5712-1.c | 6 +- iconvdata/tscii.c | 44 +- iconvdata/uhc.c | 12 +- iconvdata/unicode.c | 8 +- iconvdata/utf-16.c | 22 +- iconvdata/utf-32.c | 10 +- iconvdata/utf-7.c | 12 +- include/atomic.h | 2 +- inet/inet6_option.c | 2 +- intl/bindtextdom.c | 18 +- intl/dcigettext.c | 20 +- intl/loadmsgcat.c | 4 +- intl/localealias.c | 4 +- libio/filedoalloc.c | 2 +- libio/fileops.c | 10 +- libio/fmemopen.c | 4 +- libio/iofgets.c | 2 +- libio/iofgets_u.c | 2 +- libio/iofgetws.c | 2 +- libio/iofgetws_u.c | 2 +- libio/iogetdelim.c | 2 +- libio/wfileops.c | 12 +- locale/findlocale.c | 4 +- locale/loadarchive.c | 8 +- locale/loadlocale.c | 10 +- locale/setlocale.c | 2 +- login/programs/pt_chown.c | 2 +- malloc/arena.c | 8 +- malloc/malloc.c | 14 +- malloc/memusage.c | 24 +- math/e_exp2l.c | 2 +- math/e_scalb.c | 6 +- math/e_scalbf.c | 6 +- math/e_scalbl.c | 6 +- math/s_catan.c | 4 +- math/s_catanf.c | 4 +- math/s_catanh.c | 4 +- math/s_catanhf.c | 4 +- math/s_catanhl.c | 4 +- math/s_catanl.c | 4 +- math/s_ccosh.c | 10 +- math/s_ccoshf.c | 12 +- math/s_ccoshl.c | 12 +- math/s_cexp.c | 12 +- math/s_cexpf.c | 12 +- math/s_cexpl.c | 12 +- math/s_clog.c | 4 +- math/s_clog10.c | 4 +- math/s_clog10f.c | 4 +- math/s_clog10l.c | 4 +- math/s_clogf.c | 4 +- math/s_clogl.c | 4 +- math/s_csin.c | 8 +- math/s_csinf.c | 8 +- math/s_csinh.c | 10 +- math/s_csinhf.c | 12 +- math/s_csinhl.c | 12 +- math/s_csinl.c | 8 +- math/s_csqrt.c | 6 +- math/s_csqrtf.c | 6 +- math/s_csqrtl.c | 6 +- math/s_ctan.c | 4 +- math/s_ctanf.c | 4 +- math/s_ctanh.c | 4 +- math/s_ctanhf.c | 4 +- math/s_ctanhl.c | 4 +- math/s_ctanl.c | 4 +- math/w_pow.c | 2 +- math/w_powf.c | 2 +- math/w_powl.c | 2 +- math/w_scalb.c | 2 +- math/w_scalbf.c | 2 +- math/w_scalbl.c | 2 +- misc/error.c | 2 +- misc/pselect.c | 2 +- nis/nis_call.c | 2 +- nis/nis_callback.c | 10 +- nis/nis_creategroup.c | 2 +- nis/nis_domain_of_r.c | 2 +- nis/nis_findserv.c | 4 +- nis/nis_getservlist.c | 12 +- nis/nis_lookup.c | 4 +- nis/nis_subr.c | 14 +- nis/nis_table.c | 18 +- nis/nis_xdr.c | 2 +- nis/nss_compat/compat-grp.c | 12 +- nis/nss_compat/compat-initgroups.c | 6 +- nis/nss_compat/compat-pwd.c | 12 +- nis/nss_compat/compat-spwd.c | 8 +- nis/nss_nis/nis-alias.c | 16 +- nis/nss_nis/nis-ethers.c | 16 +- nis/nss_nis/nis-grp.c | 24 +- nis/nss_nis/nis-hosts.c | 34 +- nis/nss_nis/nis-initgroups.c | 8 +- nis/nss_nis/nis-netgrp.c | 6 +- nis/nss_nis/nis-network.c | 24 +- nis/nss_nis/nis-proto.c | 16 +- nis/nss_nis/nis-publickey.c | 4 +- nis/nss_nis/nis-pwd.c | 30 +- nis/nss_nis/nis-rpc.c | 18 +- nis/nss_nis/nis-service.c | 30 +- nis/nss_nis/nis-spwd.c | 12 +- nis/nss_nisplus/nisplus-alias.c | 4 +- nis/nss_nisplus/nisplus-ethers.c | 8 +- nis/nss_nisplus/nisplus-grp.c | 10 +- nis/nss_nisplus/nisplus-hosts.c | 8 +- nis/nss_nisplus/nisplus-initgroups.c | 4 +- nis/nss_nisplus/nisplus-network.c | 4 +- nis/nss_nisplus/nisplus-proto.c | 4 +- nis/nss_nisplus/nisplus-pwd.c | 10 +- nis/nss_nisplus/nisplus-rpc.c | 2 +- nis/nss_nisplus/nisplus-service.c | 10 +- nis/nss_nisplus/nisplus-spwd.c | 6 +- nis/ypclnt.c | 8 +- nptl/ChangeLog | 73 +++ nptl/allocatestack.c | 14 +- nptl/cancellation.c | 4 +- nptl/cleanup_defer.c | 6 +- nptl/cleanup_defer_compat.c | 6 +- nptl/cond-perf.c | 2 +- nptl/nptl-init.c | 4 +- nptl/perf.c | 4 +- nptl/pthread_barrier_destroy.c | 2 +- nptl/pthread_barrier_init.c | 2 +- nptl/pthread_cond_timedwait.c | 6 +- nptl/pthread_cond_wait.c | 2 +- nptl/pthread_create.c | 18 +- nptl/pthread_getattr_np.c | 2 +- nptl/pthread_getspecific.c | 4 +- nptl/pthread_join.c | 2 +- nptl/pthread_key_delete.c | 2 +- nptl/pthread_mutex_init.c | 4 +- nptl/pthread_mutex_lock.c | 20 +- nptl/pthread_mutex_timedlock.c | 16 +- nptl/pthread_mutex_trylock.c | 14 +- nptl/pthread_mutex_unlock.c | 2 +- nptl/pthread_rwlock_rdlock.c | 4 +- nptl/pthread_rwlock_timedrdlock.c | 2 +- nptl/pthread_rwlock_timedwrlock.c | 2 +- nptl/pthread_rwlock_tryrdlock.c | 2 +- nptl/pthread_setcancelstate.c | 2 +- nptl/pthread_setcanceltype.c | 2 +- nptl/pthread_setschedprio.c | 2 +- nptl/pthread_setspecific.c | 2 +- nptl/sem_init.c | 4 +- nptl/sem_open.c | 4 +- nptl/sigaction.c | 2 +- nptl/sockperf.c | 4 +- nptl/sysdeps/pthread/createthread.c | 12 +- nptl/sysdeps/pthread/setxid.h | 2 +- nptl/sysdeps/pthread/timer_create.c | 4 +- nptl/sysdeps/pthread/unwind-forcedunwind.c | 10 +- nptl/sysdeps/unix/sysv/linux/getpid.c | 6 +- nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c | 6 +- nptl/sysdeps/unix/sysv/linux/mq_notify.c | 4 +- .../sysdeps/unix/sysv/linux/powerpc/lowlevellock.h | 4 +- nptl/sysdeps/unix/sysv/linux/pt-raise.c | 2 +- nptl/sysdeps/unix/sysv/linux/pthread_kill.c | 2 +- nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c | 2 +- nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c | 2 +- nptl/sysdeps/unix/sysv/linux/raise.c | 2 +- nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h | 10 +- nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h | 10 +- .../sysv/linux/sparc/pthread_barrier_destroy.c | 2 +- .../unix/sysv/linux/sparc/pthread_barrier_init.c | 2 +- nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c | 4 +- nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c | 2 +- nptl/unwind.c | 2 +- nscd/aicache.c | 4 +- nscd/cache.c | 16 +- nscd/connections.c | 20 +- nscd/grpcache.c | 4 +- nscd/hstcache.c | 4 +- nscd/initgrcache.c | 4 +- nscd/mem.c | 12 +- nscd/netgroupcache.c | 8 +- nscd/nscd-client.h | 4 +- nscd/nscd_getai.c | 4 +- nscd/nscd_getgr_r.c | 12 +- nscd/nscd_gethst_r.c | 6 +- nscd/nscd_getpw_r.c | 8 +- nscd/nscd_getserv_r.c | 4 +- nscd/nscd_helper.c | 18 +- nscd/nscd_initgroups.c | 2 +- nscd/nscd_netgroup.c | 4 +- nscd/pwdcache.c | 4 +- nscd/selinux.c | 2 +- nscd/servicescache.c | 4 +- nss/nss_files/files-XXX.c | 2 +- posix/fnmatch.c | 16 +- posix/getopt.c | 2 +- posix/glob.c | 42 +- posix/wordexp.c | 2 +- resolv/nss_dns/dns-host.c | 44 +- resolv/nss_dns/dns-network.c | 2 +- resolv/res_init.c | 2 +- resolv/res_mkquery.c | 4 +- resolv/res_query.c | 2 +- resolv/res_send.c | 36 +- stdio-common/_i18n_number.h | 2 +- stdio-common/perror.c | 2 +- stdio-common/printf_fp.c | 8 +- stdio-common/tmpnam.c | 2 +- stdio-common/vfscanf.c | 74 +-- stdlib/cxa_finalize.c | 2 +- stdlib/cxa_thread_atexit_impl.c | 2 +- stdlib/drand48-iter.c | 2 +- stdlib/putenv.c | 2 +- stdlib/setenv.c | 6 +- stdlib/strtod_l.c | 12 +- stdlib/strtol_l.c | 8 +- string/memmem.c | 2 +- string/strerror.c | 2 +- string/strnlen.c | 2 +- string/test-memmem.c | 2 +- sunrpc/clnt_udp.c | 2 +- sunrpc/pm_getport.c | 4 +- sysdeps/gnu/unwind-resume.c | 4 +- sysdeps/i386/dl-irel.h | 2 +- sysdeps/i386/dl-machine.h | 22 +- sysdeps/ieee754/dbl-64/e_atanh.c | 4 +- sysdeps/ieee754/dbl-64/e_exp2.c | 4 +- sysdeps/ieee754/dbl-64/e_fmod.c | 10 +- sysdeps/ieee754/dbl-64/e_gamma_r.c | 6 +- sysdeps/ieee754/dbl-64/e_hypot.c | 2 +- sysdeps/ieee754/dbl-64/e_j1.c | 12 +- sysdeps/ieee754/dbl-64/e_jn.c | 12 +- sysdeps/ieee754/dbl-64/e_log.c | 10 +- sysdeps/ieee754/dbl-64/e_log10.c | 6 +- sysdeps/ieee754/dbl-64/e_log2.c | 6 +- sysdeps/ieee754/dbl-64/e_sinh.c | 4 +- sysdeps/ieee754/dbl-64/s_asinh.c | 4 +- sysdeps/ieee754/dbl-64/s_fma.c | 8 +- sysdeps/ieee754/dbl-64/s_log1p.c | 6 +- sysdeps/ieee754/dbl-64/s_logb.c | 2 +- sysdeps/ieee754/dbl-64/s_modf.c | 2 +- sysdeps/ieee754/dbl-64/s_scalbln.c | 10 +- sysdeps/ieee754/dbl-64/s_scalbn.c | 10 +- sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c | 6 +- sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c | 6 +- sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c | 6 +- sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c | 4 +- sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c | 2 +- sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c | 4 +- sysdeps/ieee754/dbl-64/wordsize-64/s_round.c | 2 +- sysdeps/ieee754/flt-32/e_atanhf.c | 4 +- sysdeps/ieee754/flt-32/e_gammaf_r.c | 6 +- sysdeps/ieee754/flt-32/s_logbf.c | 2 +- sysdeps/ieee754/ldbl-128/s_fmal.c | 6 +- sysdeps/ieee754/ldbl-128ibm/e_fmodl.c | 6 +- sysdeps/ieee754/ldbl-128ibm/math_ldbl.h | 6 +- sysdeps/ieee754/ldbl-128ibm/s_llrintl.c | 6 +- sysdeps/ieee754/ldbl-128ibm/s_llroundl.c | 6 +- sysdeps/ieee754/ldbl-128ibm/s_logbl.c | 2 +- sysdeps/ieee754/ldbl-128ibm/s_lrintl.c | 6 +- sysdeps/ieee754/ldbl-128ibm/s_lroundl.c | 6 +- sysdeps/ieee754/ldbl-96/e_gammal_r.c | 6 +- sysdeps/ieee754/ldbl-96/e_j0l.c | 16 +- sysdeps/ieee754/ldbl-96/e_j1l.c | 16 +- sysdeps/ieee754/ldbl-96/e_jnl.c | 6 +- sysdeps/ieee754/ldbl-96/s_fma.c | 4 +- sysdeps/ieee754/ldbl-96/s_fmal.c | 6 +- sysdeps/posix/clock_getres.c | 6 +- sysdeps/posix/fdopendir.c | 6 +- sysdeps/posix/getaddrinfo.c | 4 +- sysdeps/posix/opendir.c | 4 +- sysdeps/posix/sleep.c | 2 +- sysdeps/posix/tempname.c | 2 +- sysdeps/powerpc/powerpc32/dl-irel.h | 2 +- sysdeps/powerpc/powerpc32/dl-machine.c | 10 +- sysdeps/powerpc/powerpc32/dl-machine.h | 4 +- sysdeps/powerpc/powerpc64/dl-irel.h | 4 +- sysdeps/powerpc/powerpc64/dl-machine.h | 6 +- sysdeps/pthread/aio_notify.c | 2 +- sysdeps/pthread/aio_suspend.c | 4 +- sysdeps/s390/dl-irel.h | 2 +- sysdeps/s390/s390-32/dl-machine.h | 14 +- sysdeps/s390/s390-64/dl-machine.h | 14 +- sysdeps/s390/s390-64/utf16-utf32-z9.c | 10 +- sysdeps/s390/s390-64/utf8-utf16-z9.c | 26 +- sysdeps/s390/s390-64/utf8-utf32-z9.c | 32 +- sysdeps/sh/dl-machine.h | 4 +- sysdeps/sparc/sparc32/dl-irel.h | 4 +- sysdeps/sparc/sparc32/dl-machine.h | 10 +- sysdeps/sparc/sparc64/dl-irel.h | 4 +- sysdeps/sparc/sparc64/dl-machine.h | 10 +- sysdeps/sparc/sparc64/dl-plt.h | 2 +- sysdeps/unix/clock_gettime.c | 4 +- sysdeps/unix/clock_settime.c | 4 +- sysdeps/unix/grantpt.c | 4 +- sysdeps/unix/sysv/linux/accept4.c | 2 +- sysdeps/unix/sysv/linux/adjtime.c | 2 +- sysdeps/unix/sysv/linux/check_pf.c | 2 +- sysdeps/unix/sysv/linux/dl-osinfo.h | 4 +- sysdeps/unix/sysv/linux/faccessat.c | 4 +- sysdeps/unix/sysv/linux/fchmodat.c | 4 +- sysdeps/unix/sysv/linux/fchownat.c | 4 +- sysdeps/unix/sysv/linux/futimesat.c | 6 +- sysdeps/unix/sysv/linux/fxstatat.c | 6 +- sysdeps/unix/sysv/linux/fxstatat64.c | 6 +- sysdeps/unix/sysv/linux/i386/fallocate.c | 2 +- sysdeps/unix/sysv/linux/i386/fallocate64.c | 2 +- sysdeps/unix/sysv/linux/i386/fchownat.c | 4 +- sysdeps/unix/sysv/linux/i386/fxstatat.c | 8 +- sysdeps/unix/sysv/linux/i386/get_clockfreq.c | 4 +- sysdeps/unix/sysv/linux/i386/posix_fallocate.c | 4 +- sysdeps/unix/sysv/linux/i386/posix_fallocate64.c | 4 +- sysdeps/unix/sysv/linux/i386/scandir64.c | 2 +- sysdeps/unix/sysv/linux/i386/sysdep.h | 2 +- sysdeps/unix/sysv/linux/ifaddrs.c | 8 +- sysdeps/unix/sysv/linux/linkat.c | 4 +- sysdeps/unix/sysv/linux/mkdirat.c | 4 +- sysdeps/unix/sysv/linux/mq_unlink.c | 2 +- sysdeps/unix/sysv/linux/openat.c | 4 +- sysdeps/unix/sysv/linux/posix_fallocate.c | 4 +- sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 +- sysdeps/unix/sysv/linux/powerpc/fchownat.c | 4 +- sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c | 4 +- sysdeps/unix/sysv/linux/readlinkat.c | 4 +- sysdeps/unix/sysv/linux/recvmmsg.c | 2 +- sysdeps/unix/sysv/linux/renameat.c | 6 +- sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h | 2 +- sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 2 +- sysdeps/unix/sysv/linux/sched_setaffinity.c | 2 +- sysdeps/unix/sysv/linux/sendmmsg.c | 2 +- sysdeps/unix/sysv/linux/shm_open.c | 6 +- sysdeps/unix/sysv/linux/sleep.c | 2 +- sysdeps/unix/sysv/linux/symlinkat.c | 4 +- sysdeps/unix/sysv/linux/tcgetattr.c | 2 +- sysdeps/unix/sysv/linux/ttyname.c | 4 +- sysdeps/unix/sysv/linux/ttyname_r.c | 6 +- sysdeps/unix/sysv/linux/unlinkat.c | 4 +- sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c | 4 +- .../unix/sysv/linux/wordsize-64/posix_fallocate.c | 4 +- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 4 +- sysdeps/unix/sysv/linux/xmknodat.c | 2 +- sysdeps/x86_64/dl-irel.h | 2 +- sysdeps/x86_64/dl-machine.h | 22 +- time/asctime.c | 2 +- time/tzfile.c | 36 +- time/tzset.c | 12 +- wcsmbs/mbrtoc16.c | 2 +- wcsmbs/mbrtowc.c | 2 +- wcsmbs/wcsmbsload.c | 2 +- wcsmbs/wcsmbsload.h | 4 +- 466 files changed, 2224 insertions(+), 1655 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf1b17d..eadce52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,501 @@ 2014-02-10 Ondřej Bílka + * assert/assert.c (__assert_fail_base): Use glibc_likely instead __builtin_expect. + * benchtests/bench-memmem.c (simple_memmem): Likewise. + * catgets/open_catalog.c (__open_catalog): Likewise. + * csu/libc-start.c (LIBC_START_MAIN): Likewise. + * debug/confstr_chk.c: Likewise. + * debug/fread_chk.c (__fread_chk): Likewise. + * debug/fread_u_chk.c (__fread_unlocked_chk): Likewise. + * debug/getgroups_chk.c: Likewise. + * debug/mbsnrtowcs_chk.c: Likewise. + * debug/mbsrtowcs_chk.c: Likewise. + * debug/mbstowcs_chk.c: Likewise. + * debug/memcpy_chk.c: Likewise. + * debug/memmove_chk.c: Likewise. + * debug/mempcpy_chk.c: Likewise. + * debug/memset_chk.c: Likewise. + * debug/stpcpy_chk.c (__stpcpy_chk): Likewise. + * debug/strcat_chk.c (__strcat_chk): Likewise. + * debug/strcpy_chk.c (__strcpy_chk): Likewise. + * debug/strncat_chk.c (__strncat_chk): Likewise. + * debug/vsnprintf_chk.c (___vsnprintf_chk): Likewise. + * debug/vswprintf_chk.c (__vswprintf_chk): Likewise. + * debug/wcpcpy_chk.c (__wcpcpy_chk): Likewise. + * debug/wcpncpy_chk.c: Likewise. + * debug/wcscat_chk.c (__wcscat_chk): Likewise. + * debug/wcscpy_chk.c (__wcscpy_chk): Likewise. + * debug/wcsncat_chk.c (__wcsncat_chk): Likewise. + * debug/wcsncpy_chk.c: Likewise. + * debug/wcsnrtombs_chk.c: Likewise. + * debug/wcsrtombs_chk.c: Likewise. + * debug/wcstombs_chk.c: Likewise. + * debug/wmemcpy_chk.c: Likewise. + * debug/wmemmove_chk.c: Likewise. + * debug/wmempcpy_chk.c: Likewise. + * debug/wmemset_chk.c: Likewise. + * dirent/scandirat.c (SCANDIRAT): Likewise. + * dlfcn/dladdr1.c (dladdr1): Likewise. + * dlfcn/dladdr.c (dladdr): Likewise. + * dlfcn/dlclose.c (dlclose_doit): Likewise. + * dlfcn/dlerror.c (__dlerror): Likewise. + * dlfcn/dlinfo.c (dlinfo_doit): Likewise. + * dlfcn/dlmopen.c (dlmopen_doit): Likewise. + * dlfcn/dlopen.c (dlopen_doit): Likewise. + * dlfcn/dlopenold.c (__dlopen_nocheck): Likewise. + * dlfcn/dlsym.c (dlsym_doit): Likewise. + * dlfcn/dlvsym.c (dlvsym_doit): Likewise. + * elf/dl-cache.c (_dl_load_cache_lookup): Likewise. + * elf/dl-close.c (remove_slotinfo, _dl_close_worker, _dl_close): + Likewise. + * elf/dl-conflict.c: Likewise. + * elf/dl-deps.c (_dl_build_local_scope, _dl_map_object_deps): Likewise. + * elf/dl-dst.h: Likewise. + * elf/dl-fini.c (_dl_sort_fini, _dl_fini): Likewise. + * elf/dl-fptr.c (_dl_make_fptr): Likewise. + * elf/dl-hwcaps.c (_dl_important_hwcaps): Likewise. + * elf/dl-init.c (call_init, _dl_init): Likewise. + * elf/dl-libc.c (__libc_dlopen_mode, __libc_dlsym): Likewise. + * elf/dl-load.c (_dl_dst_substitute, fillin_rpath, _dl_init_paths, + _dl_map_object_from_fd, open_verify, open_path, + _dl_map_object): Likewise. + * elf/dl-lookup.c (do_lookup_x, add_dependency, _dl_lookup_symbol_x): + Likewise. + * elf/dl-minimal.c (__libc_memalign): Likewise. + * elf/dl-open.c (add_to_global, dl_open_worker, _dl_open): Likewise. + * elf/dl-reloc.c (_dl_relocate_object): Likewise. + * elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Likewise. + * elf/dl-sym.c (do_sym): Likewise. + * elf/dl-tls.c (tls_get_addr_tail, update_get_addr, __tls_get_addr, + _dl_tls_get_addr_soft): Likewise. + * elf/dl-version.c (match_symbol, _dl_check_map_versions): Likewise. + * elf/dl-writev.h (_dl_writev): Likewise. + * elf/ldconfig.c (search_dir): Likewise. + * elf/rtld.c (_dl_start_final, _dl_start, init_tls, do_preload, + dl_main): Likewise. + * elf/setup-vdso.h (setup_vdso): Likewise. + * grp/compat-initgroups.c (compat_call): Likewise. + * grp/fgetgrent.c (fgetgrent): Likewise. + * grp/initgroups.c (getgrouplist, initgroups): Likewise. + * grp/putgrent.c (putgrent): Likewise. + * hesiod/nss_hesiod/hesiod-grp.c (_nss_hesiod_initgroups_dyn): + Likewise. + * hurd/hurdinit.c: Likewise. + * iconvdata/8bit-gap.c (struct): Likewise. + * iconvdata/ansi_x3.110.c : Likewise. + * iconvdata/big5.c : Likewise. + * iconvdata/big5hkscs.c : Likewise. + * iconvdata/cp1255.c: Likewise. + * iconvdata/cp1258.c : Likewise. + * iconvdata/cp932.c : Likewise. + * iconvdata/euc-cn.c: Likewise. + * iconvdata/euc-jisx0213.c : Likewise. + * iconvdata/euc-jp.c: Likewise. + * iconvdata/euc-jp-ms.c : Likewise. + * iconvdata/euc-kr.c (euckr_from_ucs4): Likewise. + * iconvdata/gb18030.c : Likewise. + * iconvdata/gbbig5.c (const): Likewise. + * iconvdata/gbgbk.c: Likewise. + * iconvdata/gbk.c : Likewise. + * iconvdata/ibm1364.c : Likewise. + * iconvdata/ibm930.c : Likewise. + * iconvdata/ibm932.c: Likewise. + * iconvdata/ibm933.c : Likewise. + * iconvdata/ibm935.c : Likewise. + * iconvdata/ibm937.c : Likewise. + * iconvdata/ibm939.c : Likewise. + * iconvdata/ibm943.c: Likewise. + * iconvdata/iso_11548-1.c: Likewise. + * iconvdata/iso-2022-cn.c : Likewise. + * iconvdata/iso-2022-cn-ext.c : Likewise. + * iconvdata/iso-2022-jp-3.c: Likewise. + * iconvdata/iso-2022-jp.c (gconv_end): Likewise. + * iconvdata/iso-2022-kr.c : Likewise. + * iconvdata/iso646.c (gconv_end): Likewise. + * iconvdata/iso_6937-2.c : Likewise. + * iconvdata/iso_6937.c : Likewise. + * iconvdata/iso8859-1.c: Likewise. + * iconvdata/johab.c (johab_sym_hanja_to_ucs): Likewise. + * iconvdata/shift_jisx0213.c : Likewise. + * iconvdata/sjis.c : Likewise. + * iconvdata/t.61.c : Likewise. + * iconvdata/tcvn5712-1.c : Likewise. + * iconvdata/tscii.c: Likewise. + * iconvdata/uhc.c : Likewise. + * iconvdata/unicode.c (gconv_end): Likewise. + * iconvdata/utf-16.c (gconv_end): Likewise. + * iconvdata/utf-32.c (gconv_end): Likewise. + * iconvdata/utf-7.c (base64): Likewise. + * iconv/gconv_cache.c (__gconv_load_cache): Likewise. + * iconv/gconv_close.c (__gconv_close): Likewise. + * iconv/gconv_open.c (__gconv_open): Likewise. + * iconv/gconv_simple.c (internal_ucs4_loop_single, ucs4_internal_loop, + ucs4_internal_loop_unaligned, ucs4_internal_loop_single, + internal_ucs4le_loop_single, ucs4le_internal_loop, + ucs4le_internal_loop_unaligned, ucs4le_internal_loop_single): Likewise. + * iconv/iconv.c (iconv): Likewise. + * iconv/iconv_close.c: Likewise. + * iconv/loop.c (SINGLE): Likewise. + * iconv/skeleton.c (FUNCTION_NAME): Likewise. + * include/atomic.h: Likewise. + * inet/inet6_option.c (option_alloc): Likewise. + * intl/bindtextdom.c (set_binding_values): Likewise. + * intl/dcigettext.c (DCIGETTEXT, _nl_find_msg): Likewise. + * intl/loadmsgcat.c (_nl_load_domain): Likewise. + * intl/localealias.c (read_alias_file): Likewise. + * libio/filedoalloc.c (_IO_file_doallocate): Likewise. + * libio/fileops.c (_IO_file_open, _IO_file_underflow_mmap, + _IO_new_file_overflow, _IO_file_xsgetn_mmap): Likewise. + * libio/fmemopen.c (fmemopen): Likewise. + * libio/iofgets.c (_IO_fgets): Likewise. + * libio/iofgets_u.c (fgets_unlocked): Likewise. + * libio/iofgetws.c (fgetws): Likewise. + * libio/iofgetws_u.c (fgetws_unlocked): Likewise. + * libio/iogetdelim.c (_IO_getdelim): Likewise. + * libio/wfileops.c (_IO_wfile_underflow, _IO_wfile_underflow_mmap, + adjust_wide_data, _IO_wfile_seekoff): Likewise. + * locale/findlocale.c (_nl_find_locale): Likewise. + * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. + * locale/loadlocale.c (_nl_intern_locale_data, _nl_load_locale): + Likewise. + * locale/setlocale.c (setlocale): Likewise. + * login/programs/pt_chown.c (main): Likewise. + * malloc/arena.c (ptmalloc_init, shrink_heap, arena_get2): Likewise. + * malloc/malloc.c (_int_malloc, _int_free): Likewise. + * malloc/memusage.c (update_data, malloc, realloc, calloc, free, + mmap, mmap64, mremap, munmap): Likewise. + * math/e_exp2l.c: Likewise. + * math/e_scalb.c (invalid_fn, __ieee754_scalb): Likewise. + * math/e_scalbf.c (invalid_fn, __ieee754_scalbf): Likewise. + * math/e_scalbl.c (invalid_fn, __ieee754_scalbl): Likewise. + * math/s_catan.c (__catan): Likewise. + * math/s_catanf.c (__catanf): Likewise. + * math/s_catanh.c (__catanh): Likewise. + * math/s_catanhf.c (__catanhf): Likewise. + * math/s_catanhl.c (__catanhl): Likewise. + * math/s_catanl.c (__catanl): Likewise. + * math/s_ccosh.c (__ccosh): Likewise. + * math/s_ccoshf.c (__ccoshf): Likewise. + * math/s_ccoshl.c (__ccoshl): Likewise. + * math/s_cexp.c (__cexp): Likewise. + * math/s_cexpf.c (__cexpf): Likewise. + * math/s_cexpl.c (__cexpl): Likewise. + * math/s_clog10.c (__clog10): Likewise. + * math/s_clog10f.c (__clog10f): Likewise. + * math/s_clog10l.c (__clog10l): Likewise. + * math/s_clog.c (__clog): Likewise. + * math/s_clogf.c (__clogf): Likewise. + * math/s_clogl.c (__clogl): Likewise. + * math/s_csin.c (__csin): Likewise. + * math/s_csinf.c (__csinf): Likewise. + * math/s_csinh.c (__csinh): Likewise. + * math/s_csinhf.c (__csinhf): Likewise. + * math/s_csinhl.c (__csinhl): Likewise. + * math/s_csinl.c (__csinl): Likewise. + * math/s_csqrt.c (__csqrt): Likewise. + * math/s_csqrtf.c (__csqrtf): Likewise. + * math/s_csqrtl.c (__csqrtl): Likewise. + * math/s_ctan.c (__ctan): Likewise. + * math/s_ctanf.c (__ctanf): Likewise. + * math/s_ctanh.c (__ctanh): Likewise. + * math/s_ctanhf.c (__ctanhf): Likewise. + * math/s_ctanhl.c (__ctanhl): Likewise. + * math/s_ctanl.c (__ctanl): Likewise. + * math/w_pow.c: Likewise. + * math/w_powf.c: Likewise. + * math/w_powl.c: Likewise. + * math/w_scalb.c (sysv_scalb): Likewise. + * math/w_scalbf.c (sysv_scalbf): Likewise. + * math/w_scalbl.c (sysv_scalbl): Likewise. + * misc/error.c (error_tail): Likewise. + * misc/pselect.c (__pselect): Likewise. + * nis/nis_callback.c (__nis_create_callback): Likewise. + * nis/nis_call.c (__nisfind_server): Likewise. + * nis/nis_creategroup.c (nis_creategroup): Likewise. + * nis/nis_domain_of_r.c (nis_domain_of_r): Likewise. + * nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise. + * nis/nis_getservlist.c (nis_getservlist): Likewise. + * nis/nis_lookup.c (nis_lookup): Likewise. + * nis/nis_subr.c (nis_leaf_of_r, nis_getnames): Likewise. + * nis/nis_table.c (__create_ib_request, nis_list, nis_add_entry, + nis_modify_entry, nis_first_entry, nis_next_entry): Likewise. + * nis/nis_xdr.c (xdr_endpoint): Likewise. + * nis/nss_compat/compat-grp.c (getgrent_next_file, internal_getgrnam_r, + internal_getgrgid_r): Likewise. + * nis/nss_compat/compat-initgroups.c (add_group, internal_getgrent_r): + Likewise. + * nis/nss_compat/compat-pwd.c (getpwent_next_file, internal_getpwnam_r, + internal_getpwuid_r): Likewise. + * nis/nss_compat/compat-spwd.c (getspent_next_file, + internal_getspnam_r): Likewise. + * nis/nss_nis/nis-alias.c (internal_nis_getaliasent_r, + _nss_nis_getaliasbyname_r): Likewise. + * nis/nss_nis/nis-ethers.c (_nss_nis_gethostton_r, + _nss_nis_getntohost_r): Likewise. + * nis/nss_nis/nis-grp.c (internal_nis_setgrent, + internal_nis_getgrent_r, _nss_nis_getgrnam_r, _nss_nis_getgrgid_r): + Likewise. + * nis/nss_nis/nis-hosts.c (_nss_nis_sethostent, + internal_nis_gethostent_r, internal_gethostbyname2_r, + _nss_nis_gethostbyname_r, _nss_nis_gethostbyaddr_r, + _nss_nis_gethostbyname4_r): Likewise. + * nis/nss_nis/nis-initgroups.c (internal_getgrent_r, + initgroups_netid): Likewise. + * nis/nss_nis/nis-netgrp.c (_nss_nis_setnetgrent): Likewise. + * nis/nss_nis/nis-network.c (internal_nis_getnetent_r, + _nss_nis_getnetbyname_r, _nss_nis_getnetbyaddr_r): Likewise. + * nis/nss_nis/nis-proto.c (_nss_nis_getprotobyname_r, + _nss_nis_getprotobynumber_r): Likewise. + * nis/nss_nis/nis-publickey.c (_nss_nis_getpublickey, + _nss_nis_getsecretkey): Likewise. + * nis/nss_nis/nis-pwd.c (_nis_saveit, internal_nis_setpwent, + internal_nis_getpwent_r, _nss_nis_getpwnam_r, _nss_nis_getpwuid_r): + Likewise. + * nis/nss_nis/nis-rpc.c (internal_nis_getrpcent_r, + _nss_nis_getrpcbyname_r, _nss_nis_getrpcbynumber_r): Likewise. + * nis/nss_nis/nis-service.c (dosearch, internal_nis_getservent_r, + _nss_nis_getservbyname_r, _nss_nis_getservbyport_r): Likewise. + * nis/nss_nis/nis-spwd.c (_nss_nis_setspent, internal_nis_getspent_r, + _nss_nis_getspnam_r): Likewise. + * nis/nss_nisplus/nisplus-alias.c (_nss_nisplus_getaliasbyname_r): + Likewise. + * nis/nss_nisplus/nisplus-ethers.c (_nss_nisplus_gethostton_r, + _nss_nisplus_getntohost_r): Likewise. + * nis/nss_nisplus/nisplus-grp.c (internal_nisplus_getgrent_r, + _nss_nisplus_getgrnam_r, _nss_nisplus_getgrgid_r): Likewise. + * nis/nss_nisplus/nisplus-hosts.c (internal_gethostbyname2_r, + _nss_nisplus_gethostbyaddr_r, _nss_nisplus_gethostbyname4_r): Likewise. + * nis/nss_nisplus/nisplus-initgroups.c (_nss_nisplus_initgroups_dyn): + Likewise. + * nis/nss_nisplus/nisplus-network.c (_nss_nisplus_getnetbyname_r, + _nss_nisplus_getnetbyaddr_r): Likewise. + * nis/nss_nisplus/nisplus-proto.c (_nss_nisplus_getprotobyname_r, + _nss_nisplus_getprotobynumber_r): Likewise. + * nis/nss_nisplus/nisplus-pwd.c (internal_nisplus_getpwent_r, + _nss_nisplus_getpwnam_r, _nss_nisplus_getpwuid_r): Likewise. + * nis/nss_nisplus/nisplus-rpc.c (_nss_nisplus_getrpcbyname_r): + Likewise. + * nis/nss_nisplus/nisplus-service.c (internal_nisplus_getservent_r, + _nss_nisplus_getservbyname_r, _nss_nisplus_getservbyport_r): Likewise. + * nis/nss_nisplus/nisplus-spwd.c (internal_nisplus_getspent_r, + _nss_nisplus_getspnam_r): Likewise. + * nis/ypclnt.c (__yp_bind, yp_match, yp_all, yp_maplist): Likewise. + * nscd/aicache.c (addhstaiX): Likewise. + * nscd/cache.c (cache_search, prune_cache): Likewise. + * nscd/connections.c (register_traced_file, send_ro_fd, handle_request, + nscd_run_prune, nscd_run_worker, fd_ready, main_loop_epoll): Likewise. + * nscd/grpcache.c (addgrbyX): Likewise. + * nscd/hstcache.c (addhstbyX): Likewise. + * nscd/initgrcache.c (addinitgroupsX): Likewise. + * nscd/mem.c (gc, mempool_alloc): Likewise. + * nscd/netgroupcache.c (do_notfound, addgetnetgrentX, addinnetgrX): + Likewise. + * nscd/nscd-client.h (__nscd_acquire_maplock, __nscd_drop_map_ref): + Likewise. + * nscd/nscd_getai.c (__nscd_getai): Likewise. + * nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise. + * nscd/nscd_gethst_r.c (__nscd_get_nl_timestamp, nscd_gethst_r): + Likewise. + * nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise. + * nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise. + * nscd/nscd_helper.c (__readvall, open_socket, + __nscd_get_mapping, __nscd_get_map_ref): Likewise. + * nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise. + * nscd/nscd_netgroup.c (__nscd_setnetgrent, __nscd_innetgr): Likewise. + * nscd/pwdcache.c (addpwbyX): Likewise. + * nscd/selinux.c (preserve_capabilities): Likewise. + * nscd/servicescache.c (addservbyX): Likewise. + * nss/nss_files/files-XXX.c (internal_getent): Likewise. + * posix/fnmatch.c (fnmatch): Likewise. + * posix/getopt.c (_getopt_internal_r): Likewise. + * posix/glob.c (glob, glob_in_dir): Likewise. + * posix/wordexp.c (exec_comm_child): Likewise. + * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyaddr2_r, getanswer_r, + gaih_getanswer_slice): Likewise. + * resolv/nss_dns/dns-network.c (getanswer_r): Likewise. + * resolv/res_init.c: Likewise. + * resolv/res_mkquery.c (res_nmkquery): Likewise. + * resolv/res_query.c (__libc_res_nquery): Likewise. + * resolv/res_send.c (__libc_res_nsend, send_vc, reopen, send_dg): + Likewise. + * stdio-common/_i18n_number.h (_i18n_number_rewrite): Likewise. + * stdio-common/perror.c (perror): Likewise. + * stdio-common/printf_fp.c (___printf_fp): Likewise. + * stdio-common/tmpnam.c (tmpnam): Likewise. + * stdio-common/vfscanf.c (_IO_vfscanf_internal): Likewise. + * stdlib/cxa_finalize.c (__cxa_finalize): Likewise. + * stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl): Likewise. + * stdlib/drand48-iter.c (__drand48_iterate): Likewise. + * stdlib/putenv.c (putenv): Likewise. + * stdlib/setenv.c (__add_to_environ): Likewise. + * stdlib/strtod_l.c (____STRTOF_INTERNAL): Likewise. + * stdlib/strtol_l.c (INTERNAL): Likewise. + * string/memmem.c (memmem): Likewise. + * string/strerror.c (strerror): Likewise. + * string/strnlen.c (__strnlen): Likewise. + * string/test-memmem.c (simple_memmem): Likewise. + * sunrpc/clnt_udp.c (__libc_clntudp_bufcreate): Likewise. + * sunrpc/pm_getport.c (__get_socket): Likewise. + * sysdeps/gnu/unwind-resume.c (init, _Unwind_Resume): Likewise. + * sysdeps/i386/dl-irel.h (elf_irel): Likewise. + * sysdeps/i386/dl-machine.h (elf_machine_runtime_setup, + elf_machine_rel, elf_machine_lazy_rel, elf_machine_lazy_rela): + Likewise. + * sysdeps/ieee754/dbl-64/e_atanh.c (__ieee754_atanh): Likewise. + * sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Likewise. + * sysdeps/ieee754/dbl-64/e_fmod.c (__ieee754_fmod): Likewise. + * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Likewise. + * sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Likewise. + * sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1, __ieee754_y1): Likewise. + * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn, __ieee754_yn): Likewise. + * sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Likewise. + * sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise. + * sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Likewise. + * sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise. + * sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise. + * sysdeps/ieee754/dbl-64/s_fma.c (__fma): Likewise. + * sysdeps/ieee754/dbl-64/s_log1p.c (__log1p): Likewise. + * sysdeps/ieee754/dbl-64/s_logb.c (__logb): Likewise. + * sysdeps/ieee754/dbl-64/s_modf.c (__modf): Likewise. + * sysdeps/ieee754/dbl-64/s_scalbln.c (__scalbln): Likewise. + * sysdeps/ieee754/dbl-64/s_scalbn.c (__scalbn): Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c (__ieee754_acosh): + Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c (__ieee754_log10): + Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c (__ieee754_log2): + Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c (__frexp): Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c (__logb): Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo): Likewise. + * sysdeps/ieee754/dbl-64/wordsize-64/s_round.c (__round): Likewise. + * sysdeps/ieee754/flt-32/e_atanhf.c (__ieee754_atanhf): Likewise. + * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): Likewise. + * sysdeps/ieee754/flt-32/s_logbf.c (__logbf): Likewise. + * sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Likewise. + * sysdeps/ieee754/ldbl-128ibm/math_ldbl.h (ldbl_nearbyint): Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_llrintl.c (__llrintl): Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_llroundl.c (__llroundl): Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_logbl.c (__logbl): Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_lrintl.c (__lrintl): Likewise. + * sysdeps/ieee754/ldbl-128ibm/s_lroundl.c (__lroundl): Likewise. + * sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Likewise. + * sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Likewise. + * sysdeps/ieee754/ldbl-96/e_j0l.c (__ieee754_j0l, __ieee754_y0l): + Likewise. + * sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l, __ieee754_y1l): + Likewise. + * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl, __ieee754_ynl): + Likewise. + * sysdeps/ieee754/ldbl-96/s_fma.c (__fma): Likewise. + * sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Likewise. + * sysdeps/posix/clock_getres.c (hp_timing_getres, realtime_getres): + Likewise. + * sysdeps/posix/fdopendir.c (__fdopendir): Likewise. + * sysdeps/posix/getaddrinfo.c (gaih_inet, getaddrinfo): Likewise. + * sysdeps/posix/opendir.c (__opendirat): Likewise. + * sysdeps/posix/sleep.c: Likewise. + * sysdeps/posix/tempname.c: Likewise. + * sysdeps/powerpc/powerpc32/dl-irel.h (elf_irela): Likewise. + * sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela): + Likewise. + * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_runtime_setup, + elf_machine_rela): Likewise. + * sysdeps/powerpc/powerpc64/dl-irel.h (elf_irela): Likewise. + * sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise. + * sysdeps/pthread/aio_notify.c (__aio_notify_only): Likewise. + * sysdeps/pthread/aio_suspend.c (do_aio_misc_wait, aio_suspend): + Likewise. + * sysdeps/s390/dl-irel.h (elf_irela): Likewise. + * sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup, + elf_machine_rela, elf_machine_lazy_rel): Likewise. + * sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup, + elf_machine_rela, elf_machine_lazy_rel): Likewise. + * sysdeps/s390/s390-64/utf16-utf32-z9.c (gconv_end): Likewise. + * sysdeps/s390/s390-64/utf8-utf16-z9.c (gconv_end): Likewise. + * sysdeps/s390/s390-64/utf8-utf32-z9.c (gconv_end): Likewise. + * sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise. + * sysdeps/sparc/sparc32/dl-irel.h (elf_irela): Likewise. + * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela, + elf_machine_lazy_rel): Likewise. + * sysdeps/sparc/sparc64/dl-irel.h (elf_irela): Likewise. + * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela, + elf_machine_lazy_rel): Likewise. + * sysdeps/sparc/sparc64/dl-plt.h (sparc64_fixup_plt): Likewise. + * sysdeps/unix/clock_gettime.c (hp_timing_gettime): Likewise. + * sysdeps/unix/clock_settime.c (hp_timing_settime): Likewise. + * sysdeps/unix/grantpt.c (grantpt): Likewise. + * sysdeps/unix/sysv/linux/accept4.c (accept4): Likewise. + * sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Likewise. + * sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise. + * sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard): + Likewise. + * sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise. + * sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise. + * sysdeps/unix/sysv/linux/fchownat.c (fchownat): Likewise. + * sysdeps/unix/sysv/linux/futimesat.c (futimesat): Likewise. + * sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise. + * sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise. + * sysdeps/unix/sysv/linux/i386/fallocate64.c (fallocate64): Likewise. + * sysdeps/unix/sysv/linux/i386/fallocate.c (fallocate): Likewise. + * sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Likewise. + * sysdeps/unix/sysv/linux/i386/fxstatat.c (__fxstatat): Likewise. + * sysdeps/unix/sysv/linux/i386/get_clockfreq.c (__get_clockfreq): + Likewise. + * sysdeps/unix/sysv/linux/i386/posix_fallocate64.c + (__posix_fallocate64_l64): Likewise. + * sysdeps/unix/sysv/linux/i386/posix_fallocate.c + (posix_fallocate): Likewise. + * sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64): Likewise. + * sysdeps/unix/sysv/linux/i386/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request, + getifaddrs_internal): Likewise. + * sysdeps/unix/sysv/linux/linkat.c (linkat): Likewise. + * sysdeps/unix/sysv/linux/mkdirat.c (mkdirat): Likewise. + * sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise. + * sysdeps/unix/sysv/linux/openat.c (OPENAT_NOT_CANCEL): Likewise. + * sysdeps/unix/sysv/linux/posix_fallocate64.c + (__posix_fallocate64_l64): Likewise. + * sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): + Likewise. + * sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Likewise. + * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq): + Likewise. + * sysdeps/unix/sysv/linux/readlinkat.c (readlinkat): Likewise. + * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Likewise. + * sysdeps/unix/sysv/linux/renameat.c (renameat): Likewise. + * sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/sched_setaffinity.c: Likewise. + * sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise. + * sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs, shm_open): + Likewise. + * sysdeps/unix/sysv/linux/sleep.c (__sleep): Likewise. + * sysdeps/unix/sysv/linux/symlinkat.c (symlinkat): Likewise. + * sysdeps/unix/sysv/linux/tcgetattr.c (__tcgetattr): Likewise. + * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Likewise. + * sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Likewise. + * sysdeps/unix/sysv/linux/unlinkat.c (unlinkat): Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c (__fxstatat): + Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c + (posix_fallocate): Likewise. + * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise. + * sysdeps/x86_64/dl-irel.h (elf_irela): Likewise. + * sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup, + elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rel): + Likewise. + * time/asctime.c (asctime_internal): Likewise. + * time/tzfile.c (__tzfile_read, __tzfile_compute): Likewise. + * time/tzset.c (__tzset_parse_tz): Likewise. + * wcsmbs/mbrtoc16.c (mbrtoc16): Likewise. + * wcsmbs/mbrtowc.c (__mbrtowc): Likewise. + * wcsmbs/wcsmbsload.c (__wcsmbs_load_conv): Likewise. + * wcsmbs/wcsmbsload.h: Likewise. + +2014-02-10 Ondřej Bílka + [BZ #15894] * stdlib/setenv.c (__add_to_environ): Remove duplicate code. diff --git a/assert/assert.c b/assert/assert.c index 2b85993..da7356a 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -67,7 +67,7 @@ __assert_fail_base (const char *fmt, const char *assertion, const char *file, total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1); struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (__builtin_expect (buf != MAP_FAILED, 1)) + if (__glibc_likely (buf != MAP_FAILED)) { buf->size = total; strcpy (buf->msg, str); diff --git a/benchtests/bench-memmem.c b/benchtests/bench-memmem.c index 6fe3bc6..763fb5c 100644 --- a/benchtests/bench-memmem.c +++ b/benchtests/bench-memmem.c @@ -43,7 +43,7 @@ simple_memmem (const void *haystack, size_t haystack_len, const void *needle, /* Sanity check, otherwise the loop might search through the whole memory. */ - if (__builtin_expect (haystack_len < needle_len, 0)) + if (__glibc_unlikely (haystack_len < needle_len)) return NULL; for (begin = (const char *) haystack; begin <= last_possible; ++begin) diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index bc44f98..d582270 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -54,7 +54,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, { const char *run_nlspath = nlspath; #define ENOUGH(n) \ - if (__builtin_expect (bufact + (n) >= bufmax, 0)) \ + if (__glibc_unlikely (bufact + (n) >= bufmax)) \ { \ char *old_buf = buf; \ bufmax += 256 + (n); \ @@ -253,7 +253,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, /* Determine whether the file is a catalog file and if yes whether it is written using the correct byte order. Else we have to swap the values. */ - if (__builtin_expect (catalog->file_ptr->magic == CATGETS_MAGIC, 1)) + if (__glibc_likely (catalog->file_ptr->magic == CATGETS_MAGIC)) swapping = 0; else if (catalog->file_ptr->magic == SWAPU32 (CATGETS_MAGIC)) swapping = 1; diff --git a/csu/libc-start.c b/csu/libc-start.c index 146e16b..3b7092b 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -214,7 +214,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), #endif /* Register the destructor of the dynamic linker if there is any. */ - if (__builtin_expect (rtld_fini != NULL, 1)) + if (__glibc_likely (rtld_fini != NULL)) __cxa_atexit ((void (*) (void *)) rtld_fini, NULL, NULL); #ifndef SHARED @@ -245,7 +245,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), #ifdef SHARED /* Auditing checkpoint: we have a new object. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct audit_ifaces *afct = GLRO(dl_audit); struct link_map *head = GL(dl_ns)[LM_ID_BASE]._ns_loaded; @@ -260,7 +260,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), #endif #ifdef SHARED - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS)) GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv[0]); #endif @@ -270,7 +270,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), int not_first_call; not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf); - if (__builtin_expect (! not_first_call, 1)) + if (__glibc_likely (! not_first_call)) { struct pthread *self = THREAD_SELF; diff --git a/debug/confstr_chk.c b/debug/confstr_chk.c index 4253540..5807380 100644 --- a/debug/confstr_chk.c +++ b/debug/confstr_chk.c @@ -22,7 +22,7 @@ size_t __confstr_chk (int name, char *buf, size_t len, size_t buflen) { - if (__builtin_expect (buflen < len, 0)) + if (__glibc_unlikely (buflen < len)) __chk_fail (); return confstr (name, buf, len); diff --git a/debug/fread_chk.c b/debug/fread_chk.c index 0f77a18..44e96e8 100644 --- a/debug/fread_chk.c +++ b/debug/fread_chk.c @@ -39,7 +39,7 @@ __fread_chk (void *__restrict ptr, size_t ptrlen, __chk_fail (); } - if (__builtin_expect (bytes_requested > ptrlen, 0)) + if (__glibc_unlikely (bytes_requested > ptrlen)) __chk_fail (); CHECK_FILE (stream, 0); diff --git a/debug/fread_u_chk.c b/debug/fread_u_chk.c index 6d4d969..f8a5bdb 100644 --- a/debug/fread_u_chk.c +++ b/debug/fread_u_chk.c @@ -39,7 +39,7 @@ __fread_unlocked_chk (void *__restrict ptr, size_t ptrlen, __chk_fail (); } - if (__builtin_expect (bytes_requested > ptrlen, 0)) + if (__glibc_unlikely (bytes_requested > ptrlen)) __chk_fail (); CHECK_FILE (stream, 0); diff --git a/debug/getgroups_chk.c b/debug/getgroups_chk.c index ec5728e..e426102 100644 --- a/debug/getgroups_chk.c +++ b/debug/getgroups_chk.c @@ -22,13 +22,13 @@ int __getgroups_chk (int size, __gid_t list[], size_t listlen) { - if (__builtin_expect (size < 0, 0)) + if (__glibc_unlikely (size < 0)) { __set_errno (EINVAL); return -1; } - if (__builtin_expect (size * sizeof (__gid_t) > listlen, 0)) + if (__glibc_unlikely (size * sizeof (__gid_t) > listlen)) __chk_fail (); return __getgroups (size, list); diff --git a/debug/mbsnrtowcs_chk.c b/debug/mbsnrtowcs_chk.c index 4445f98..aeb1c27 100644 --- a/debug/mbsnrtowcs_chk.c +++ b/debug/mbsnrtowcs_chk.c @@ -23,7 +23,7 @@ size_t __mbsnrtowcs_chk (wchar_t *dst, const char **src, size_t nmc, size_t len, mbstate_t *ps, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __mbsnrtowcs (dst, src, nmc, len, ps); diff --git a/debug/mbsrtowcs_chk.c b/debug/mbsrtowcs_chk.c index 32ff7b2..a5459b9 100644 --- a/debug/mbsrtowcs_chk.c +++ b/debug/mbsrtowcs_chk.c @@ -23,7 +23,7 @@ size_t __mbsrtowcs_chk (wchar_t *dst, const char **src, size_t len, mbstate_t *ps, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __mbsrtowcs (dst, src, len, ps); diff --git a/debug/mbstowcs_chk.c b/debug/mbstowcs_chk.c index 4359e19..d624a79 100644 --- a/debug/mbstowcs_chk.c +++ b/debug/mbstowcs_chk.c @@ -23,7 +23,7 @@ size_t __mbstowcs_chk (wchar_t *dst, const char *src, size_t len, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); mbstate_t state; diff --git a/debug/memcpy_chk.c b/debug/memcpy_chk.c index ab5adab..9bf5d9f 100644 --- a/debug/memcpy_chk.c +++ b/debug/memcpy_chk.c @@ -29,7 +29,7 @@ __memcpy_chk (dstpp, srcpp, len, dstlen) size_t len; size_t dstlen; { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return memcpy (dstpp, srcpp, len); diff --git a/debug/memmove_chk.c b/debug/memmove_chk.c index aa02873..f8c4454 100644 --- a/debug/memmove_chk.c +++ b/debug/memmove_chk.c @@ -33,7 +33,7 @@ MEMMOVE_CHK (dest, src, len, destlen) size_t len; size_t destlen; { - if (__builtin_expect (destlen < len, 0)) + if (__glibc_unlikely (destlen < len)) __chk_fail (); return memmove (dest, src, len); diff --git a/debug/mempcpy_chk.c b/debug/mempcpy_chk.c index 87db7e1..105356f 100644 --- a/debug/mempcpy_chk.c +++ b/debug/mempcpy_chk.c @@ -30,7 +30,7 @@ __mempcpy_chk (dstpp, srcpp, len, dstlen) size_t len; size_t dstlen; { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __mempcpy (dstpp, srcpp, len); diff --git a/debug/memset_chk.c b/debug/memset_chk.c index b48f740..28e7fae 100644 --- a/debug/memset_chk.c +++ b/debug/memset_chk.c @@ -25,7 +25,7 @@ __memset_chk (dstpp, c, len, dstlen) size_t len; size_t dstlen; { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return memset (dstpp, c, len); diff --git a/debug/stpcpy_chk.c b/debug/stpcpy_chk.c index d7228ec..4516137 100644 --- a/debug/stpcpy_chk.c +++ b/debug/stpcpy_chk.c @@ -34,7 +34,7 @@ __stpcpy_chk (dest, src, destlen) do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); *d++ = *s; } diff --git a/debug/strcat_chk.c b/debug/strcat_chk.c index e4e91d3..653efb4 100644 --- a/debug/strcat_chk.c +++ b/debug/strcat_chk.c @@ -33,7 +33,7 @@ __strcat_chk (dest, src, destlen) /* Find the end of the string. */ do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *s1++; } @@ -46,7 +46,7 @@ __strcat_chk (dest, src, destlen) do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; diff --git a/debug/strcpy_chk.c b/debug/strcpy_chk.c index 92549ae..5df98a0 100644 --- a/debug/strcpy_chk.c +++ b/debug/strcpy_chk.c @@ -56,7 +56,7 @@ __strcpy_chk (dest, src, destlen) do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *s; *(s++ + off) = c; diff --git a/debug/strncat_chk.c b/debug/strncat_chk.c index 955fc83..ff8b33f 100644 --- a/debug/strncat_chk.c +++ b/debug/strncat_chk.c @@ -33,7 +33,7 @@ __strncat_chk (s1, s2, n, s1len) /* Find the end of S1. */ do { - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s1++; } @@ -49,25 +49,25 @@ __strncat_chk (s1, s2, n, s1len) size_t n4 = n >> 2; do { - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; if (c == '\0') return s; - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; if (c == '\0') return s; - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; if (c == '\0') return s; - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; @@ -79,7 +79,7 @@ __strncat_chk (s1, s2, n, s1len) while (n > 0) { - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; @@ -90,7 +90,7 @@ __strncat_chk (s1, s2, n, s1len) if (c != '\0') { - if (__builtin_expect (s1len-- == 0, 0)) + if (__glibc_unlikely (s1len-- == 0)) __chk_fail (); *++s1 = '\0'; } diff --git a/debug/vsnprintf_chk.c b/debug/vsnprintf_chk.c index f28d98e..25631ef 100644 --- a/debug/vsnprintf_chk.c +++ b/debug/vsnprintf_chk.c @@ -33,7 +33,7 @@ ___vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen, Though, maxlen is supposed to be the size of buffer pointed to by s, so a conforming program can't pass such maxlen to *snprintf. */ - if (__builtin_expect (slen < maxlen, 0)) + if (__glibc_unlikely (slen < maxlen)) __chk_fail (); _IO_strnfile sf; diff --git a/debug/vswprintf_chk.c b/debug/vswprintf_chk.c index c8e6e44..d5262dc 100644 --- a/debug/vswprintf_chk.c +++ b/debug/vswprintf_chk.c @@ -32,7 +32,7 @@ __vswprintf_chk (wchar_t *s, size_t maxlen, int flags, size_t slen, Though, maxlen is supposed to be the size of buffer pointed to by s, so a conforming program can't pass such maxlen to *snprintf. */ - if (__builtin_expect (slen < maxlen, 0)) + if (__glibc_unlikely (slen < maxlen)) __chk_fail (); _IO_wstrnfile sf; @@ -44,7 +44,7 @@ __vswprintf_chk (wchar_t *s, size_t maxlen, int flags, size_t slen, /* We need to handle the special case where MAXLEN is 0. Use the overflow buffer right from the start. */ - if (__builtin_expect (maxlen == 0, 0)) + if (__glibc_unlikely (maxlen == 0)) /* Since we have to write at least the terminating L'\0' a buffer length of zero always makes the function fail. */ return -1; diff --git a/debug/wcpcpy_chk.c b/debug/wcpcpy_chk.c index 3972680..aaf573c 100644 --- a/debug/wcpcpy_chk.c +++ b/debug/wcpcpy_chk.c @@ -33,7 +33,7 @@ __wcpcpy_chk (wchar_t *dest, const wchar_t *src, size_t destlen) do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = wcp[off]; *++wcp = c; diff --git a/debug/wcpncpy_chk.c b/debug/wcpncpy_chk.c index b552a2e..e03bee6 100644 --- a/debug/wcpncpy_chk.c +++ b/debug/wcpncpy_chk.c @@ -23,7 +23,7 @@ wchar_t * __wcpncpy_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) { - if (__builtin_expect (destlen < n, 0)) + if (__glibc_unlikely (destlen < n)) __chk_fail (); /* This function is not often enough used to justify not using a diff --git a/debug/wcscat_chk.c b/debug/wcscat_chk.c index 2ee577c..1ad8c74 100644 --- a/debug/wcscat_chk.c +++ b/debug/wcscat_chk.c @@ -30,7 +30,7 @@ __wcscat_chk (wchar_t *dest, const wchar_t *src, size_t destlen) /* Find the end of the string. */ do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *s1++; } @@ -43,7 +43,7 @@ __wcscat_chk (wchar_t *dest, const wchar_t *src, size_t destlen) do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *s2++; *++s1 = c; diff --git a/debug/wcscpy_chk.c b/debug/wcscpy_chk.c index c64a9f6..3164e40 100644 --- a/debug/wcscpy_chk.c +++ b/debug/wcscpy_chk.c @@ -35,7 +35,7 @@ __wcscpy_chk (wchar_t *dest, const wchar_t *src, size_t n) do { - if (__builtin_expect (n-- == 0, 0)) + if (__glibc_unlikely (n-- == 0)) __chk_fail (); c = *wcp++; wcp[off] = c; @@ -48,7 +48,7 @@ __wcscpy_chk (wchar_t *dest, const wchar_t *src, size_t n) do { - if (__builtin_expect (n-- == 0, 0)) + if (__glibc_unlikely (n-- == 0)) __chk_fail (); c = *src++; *wcp++ = c; diff --git a/debug/wcsncat_chk.c b/debug/wcsncat_chk.c index 0de4e11..ec99024 100644 --- a/debug/wcsncat_chk.c +++ b/debug/wcsncat_chk.c @@ -29,7 +29,7 @@ __wcsncat_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) /* Find the end of DEST. */ do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *dest++; } @@ -45,25 +45,25 @@ __wcsncat_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) size_t n4 = n >> 2; do { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *src++; *++dest = c; if (c == L'\0') return s; - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *src++; *++dest = c; if (c == L'\0') return s; - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *src++; *++dest = c; if (c == L'\0') return s; - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *src++; *++dest = c; @@ -75,7 +75,7 @@ __wcsncat_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) while (n > 0) { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); c = *src++; *++dest = c; @@ -86,7 +86,7 @@ __wcsncat_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) if (c != L'\0') { - if (__builtin_expect (destlen-- == 0, 0)) + if (__glibc_unlikely (destlen-- == 0)) __chk_fail (); *++dest = L'\0'; } diff --git a/debug/wcsncpy_chk.c b/debug/wcsncpy_chk.c index abecabf..3eac236 100644 --- a/debug/wcsncpy_chk.c +++ b/debug/wcsncpy_chk.c @@ -23,7 +23,7 @@ wchar_t * __wcsncpy_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) { - if (__builtin_expect (destlen < n, 0)) + if (__glibc_unlikely (destlen < n)) __chk_fail (); /* This function is not often enough used to justify not using a diff --git a/debug/wcsnrtombs_chk.c b/debug/wcsnrtombs_chk.c index 122cd4b..f8bde89 100644 --- a/debug/wcsnrtombs_chk.c +++ b/debug/wcsnrtombs_chk.c @@ -23,7 +23,7 @@ size_t __wcsnrtombs_chk (char *dst, const wchar_t **src, size_t nwc, size_t len, mbstate_t *ps, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __wcsnrtombs (dst, src, nwc, len, ps); diff --git a/debug/wcsrtombs_chk.c b/debug/wcsrtombs_chk.c index 48ae91d..9d8ea5d 100644 --- a/debug/wcsrtombs_chk.c +++ b/debug/wcsrtombs_chk.c @@ -23,7 +23,7 @@ size_t __wcsrtombs_chk (char *dst, const wchar_t **src, size_t len, mbstate_t *ps, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __wcsrtombs (dst, src, len, ps); diff --git a/debug/wcstombs_chk.c b/debug/wcstombs_chk.c index f704cdc..cb7ed9a 100644 --- a/debug/wcstombs_chk.c +++ b/debug/wcstombs_chk.c @@ -23,7 +23,7 @@ size_t __wcstombs_chk (char *dst, const wchar_t *src, size_t len, size_t dstlen) { - if (__builtin_expect (dstlen < len, 0)) + if (__glibc_unlikely (dstlen < len)) __chk_fail (); mbstate_t state; diff --git a/debug/wmemcpy_chk.c b/debug/wmemcpy_chk.c index daeb44e..40c7d0b 100644 --- a/debug/wmemcpy_chk.c +++ b/debug/wmemcpy_chk.c @@ -23,7 +23,7 @@ wchar_t * __wmemcpy_chk (wchar_t *s1, const wchar_t *s2, size_t n, size_t ns1) { - if (__builtin_expect (ns1 < n, 0)) + if (__glibc_unlikely (ns1 < n)) __chk_fail (); return (wchar_t *) memcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t)); } diff --git a/debug/wmemmove_chk.c b/debug/wmemmove_chk.c index 59462cd..c82b4d0 100644 --- a/debug/wmemmove_chk.c +++ b/debug/wmemmove_chk.c @@ -23,7 +23,7 @@ wchar_t * __wmemmove_chk (wchar_t *s1, const wchar_t *s2, size_t n, size_t ns1) { - if (__builtin_expect (ns1 < n, 0)) + if (__glibc_unlikely (ns1 < n)) __chk_fail (); return (wchar_t *) memmove ((char *) s1, (char *) s2, n * sizeof (wchar_t)); } diff --git a/debug/wmempcpy_chk.c b/debug/wmempcpy_chk.c index 10be83c..cb62ab9 100644 --- a/debug/wmempcpy_chk.c +++ b/debug/wmempcpy_chk.c @@ -23,7 +23,7 @@ wchar_t * __wmempcpy_chk (wchar_t *s1, const wchar_t *s2, size_t n, size_t ns1) { - if (__builtin_expect (ns1 < n, 0)) + if (__glibc_unlikely (ns1 < n)) __chk_fail (); return (wchar_t *) __mempcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t)); diff --git a/debug/wmemset_chk.c b/debug/wmemset_chk.c index 4caabbe..025b3c1 100644 --- a/debug/wmemset_chk.c +++ b/debug/wmemset_chk.c @@ -22,7 +22,7 @@ wchar_t * __wmemset_chk (wchar_t *s, wchar_t c, size_t n, size_t dstlen) { - if (__builtin_expect (dstlen < n, 0)) + if (__glibc_unlikely (dstlen < n)) __chk_fail (); return wmemset (s, c, n); diff --git a/dirent/scandirat.c b/dirent/scandirat.c index 1076f28..01fc046 100644 --- a/dirent/scandirat.c +++ b/dirent/scandirat.c @@ -98,7 +98,7 @@ SCANDIRAT (dfd, 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)) { DIRENT_TYPE **new; if (vsize == 0) diff --git a/dlfcn/dladdr.c b/dlfcn/dladdr.c index 2b93cec..922ca44 100644 --- a/dlfcn/dladdr.c +++ b/dlfcn/dladdr.c @@ -32,7 +32,7 @@ int __dladdr (const void *address, Dl_info *info) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dladdr (address, info); # endif return _dl_addr (address, info, NULL, NULL); diff --git a/dlfcn/dladdr1.c b/dlfcn/dladdr1.c index a8f10be..0efc0dc 100644 --- a/dlfcn/dladdr1.c +++ b/dlfcn/dladdr1.c @@ -32,7 +32,7 @@ int __dladdr1 (const void *address, Dl_info *info, void **extra, int flags) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dladdr1 (address, info, extra, flags); # endif diff --git a/dlfcn/dlclose.c b/dlfcn/dlclose.c index 8b5decc..ca55b5f 100644 --- a/dlfcn/dlclose.c +++ b/dlfcn/dlclose.c @@ -39,7 +39,7 @@ int __dlclose (void *handle) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlclose (handle); # endif diff --git a/dlfcn/dlerror.c b/dlfcn/dlerror.c index d9bbecf..6dd47a7 100644 --- a/dlfcn/dlerror.c +++ b/dlfcn/dlerror.c @@ -63,7 +63,7 @@ __dlerror (void) struct dl_action_result *result; # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlerror (); # endif diff --git a/dlfcn/dlinfo.c b/dlfcn/dlinfo.c index f2527fe..1876d9d 100644 --- a/dlfcn/dlinfo.c +++ b/dlfcn/dlinfo.c @@ -111,7 +111,7 @@ int __dlinfo (void *handle, int request, void *arg DL_CALLER_DECL) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlinfo (handle, request, arg, DL_CALLER); # endif diff --git a/dlfcn/dlmopen.c b/dlfcn/dlmopen.c index 1e2cbcf..115f6e9 100644 --- a/dlfcn/dlmopen.c +++ b/dlfcn/dlmopen.c @@ -64,7 +64,7 @@ dlmopen_doit (void *a) /* It makes no sense to use RTLD_GLOBAL when loading a DSO into a namespace other than the base namespace. */ - if (__builtin_expect (args->mode & RTLD_GLOBAL, 0)) + if (__glibc_unlikely (args->mode & RTLD_GLOBAL)) GLRO(dl_signal_error) (EINVAL, NULL, NULL, N_("invalid mode")); } @@ -79,7 +79,7 @@ void * __dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlmopen (nsid, file, mode, RETURN_ADDRESS (0)); # endif diff --git a/dlfcn/dlopen.c b/dlfcn/dlopen.c index 2db6610..fa58c4c 100644 --- a/dlfcn/dlopen.c +++ b/dlfcn/dlopen.c @@ -74,7 +74,7 @@ void * __dlopen (const char *file, int mode DL_CALLER_DECL) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlopen (file, mode, DL_CALLER); # endif diff --git a/dlfcn/dlopenold.c b/dlfcn/dlopenold.c index 6d3a430..67fac16 100644 --- a/dlfcn/dlopenold.c +++ b/dlfcn/dlopenold.c @@ -70,7 +70,7 @@ __dlopen_nocheck (const char *file, int mode) mode |= RTLD_LAZY; args.mode = mode; - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlopen (file, mode, RETURN_ADDRESS (0)); return _dlerror_run (dlopen_doit, &args) ? NULL : args.new; diff --git a/dlfcn/dlsym.c b/dlfcn/dlsym.c index a1e2e01..7bcc78d 100644 --- a/dlfcn/dlsym.c +++ b/dlfcn/dlsym.c @@ -55,7 +55,7 @@ void * __dlsym (void *handle, const char *name DL_CALLER_DECL) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlsym (handle, name, DL_CALLER); # endif diff --git a/dlfcn/dlvsym.c b/dlfcn/dlvsym.c index 5d05d97..d7a766b 100644 --- a/dlfcn/dlvsym.c +++ b/dlfcn/dlvsym.c @@ -58,7 +58,7 @@ __dlvsym (void *handle, const char *name, const char *version_str DL_CALLER_DECL) { # ifdef SHARED - if (__builtin_expect (_dlfcn_hook != NULL, 0)) + if (__glibc_unlikely (_dlfcn_hook != NULL)) return _dlfcn_hook->dlvsym (handle, name, version_str, DL_CALLER); # endif diff --git a/elf/dl-cache.c b/elf/dl-cache.c index d36623f..91fef95 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -65,7 +65,7 @@ do \ \ /* Actually compare the entry with the key. */ \ cmpres = _dl_cache_libcmp (name, cache_data + key); \ - if (__builtin_expect (cmpres == 0, 0)) \ + if (__glibc_unlikely (cmpres == 0)) \ { \ /* Found it. LEFT now marks the last entry for which we \ know the name is correct. */ \ @@ -187,7 +187,7 @@ _dl_load_cache_lookup (const char *name) const char *best; /* Print a message if the loading of libs is traced. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE); if (cache == NULL) diff --git a/elf/dl-close.c b/elf/dl-close.c index 5bf1de7..f36ea0f 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -73,7 +73,7 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp, /* The entry might still be in its unused state if we are closing an object that wasn't fully set up. */ - if (__builtin_expect (old_map != NULL, 1)) + if (__glibc_likely (old_map != NULL)) { assert (old_map->l_tls_modid == idx); @@ -123,7 +123,7 @@ _dl_close_worker (struct link_map *map) dl_close_state = rerun; /* There are still references to this object. Do nothing more. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\nclosing file=%s; direct_opencount=%u\n", map->l_name, map->l_direct_opencount); @@ -280,7 +280,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we remove an object. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -452,7 +452,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we will start deleting objects. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct link_map *head = ns->_ns_loaded; struct audit_ifaces *afct = GLRO(dl_audit); @@ -536,7 +536,7 @@ _dl_close_worker (struct link_map *map) object. We can unmap it. */ /* Remove the object from the dtv slotinfo array if it uses TLS. */ - if (__builtin_expect (imap->l_tls_blocksize > 0, 0)) + if (__glibc_unlikely (imap->l_tls_blocksize > 0)) { any_tls = true; @@ -662,7 +662,7 @@ _dl_close_worker (struct link_map *map) free (imap->l_reldeps); /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\nfile=%s [%lu]; destroying link map\n", imap->l_name, imap->l_ns); @@ -704,7 +704,7 @@ _dl_close_worker (struct link_map *map) /* If we removed any object which uses TLS bump the generation counter. */ if (any_tls) { - if (__builtin_expect (++GL(dl_tls_generation) == 0, 0)) + if (__glibc_unlikely (++GL(dl_tls_generation) == 0)) _dl_fatal_printf ("TLS generation counter wrapped! Please report as described in "REPORT_BUGS_TO".\n"); if (tls_free_end == GL(dl_tls_static_used)) @@ -713,7 +713,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we have deleted all objects. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct link_map *head = ns->_ns_loaded; /* Do not call the functions for any auditing object. */ @@ -757,7 +757,7 @@ _dl_close (void *_map) struct link_map *map = _map; /* First see whether we can remove the object at all. */ - if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0)) + if (__glibc_unlikely (map->l_flags_1 & DF_1_NODELETE)) { assert (map->l_init_called); /* Nope. Do nothing. */ diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c index 8034077..d0f25e3 100644 --- a/elf/dl-conflict.c +++ b/elf/dl-conflict.c @@ -32,7 +32,7 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict, ElfW(Rela) *conflictend) { #if ! ELF_MACHINE_NO_RELA - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC)) _dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name)); { diff --git a/elf/dl-deps.c b/elf/dl-deps.c index 20c294e..9c83c81 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -127,7 +127,7 @@ empty dynamic string token substitution")); \ else \ { \ /* This is for DT_AUXILIARY. */ \ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0))\ + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) \ _dl_debug_printf (N_("\ cannot load auxiliary `%s' because of empty dynamic string token " \ "substitution\n"), __str); \ @@ -253,7 +253,7 @@ _dl_map_object_deps (struct link_map *map, bool malloced; int err = _dl_catch_error (&objname, &errstring, &malloced, openaux, &args); - if (__builtin_expect (errstring != NULL, 0)) + if (__glibc_unlikely (errstring != NULL)) { char *new_errstring = strdupa (errstring); objname = strdupa (objname); @@ -317,7 +317,7 @@ _dl_map_object_deps (struct link_map *map, bool malloced; (void) _dl_catch_error (&objname, &errstring, &malloced, openaux, &args); - if (__builtin_expect (errstring != NULL, 0)) + if (__glibc_unlikely (errstring != NULL)) { /* We are not interested in the error message. */ assert (errstring != NULL); @@ -342,7 +342,7 @@ _dl_map_object_deps (struct link_map *map, bool malloced; int err = _dl_catch_error (&objname, &errstring, &malloced, openaux, &args); - if (__builtin_expect (errstring != NULL, 0)) + if (__glibc_unlikely (errstring != NULL)) { char *new_errstring = strdupa (errstring); objname = strdupa (objname); @@ -622,7 +622,7 @@ Filters not supported with LD_TRACE_PRELINKING")); itself will always be initialize last. */ memcpy (l_initfini, map->l_searchlist.r_list, nlist * sizeof (struct link_map *)); - if (__builtin_expect (nlist > 1, 1)) + if (__glibc_likely (nlist > 1)) { /* We can skip looking for the binary itself which is at the front of the search list. */ @@ -645,7 +645,7 @@ Filters not supported with LD_TRACE_PRELINKING")); if (runp != NULL) /* Look through the dependencies of the object. */ while (*runp != NULL) - if (__builtin_expect (*runp++ == thisp, 0)) + if (__glibc_unlikely (*runp++ == thisp)) { /* Move the current object to the back past the last object with it as the dependency. */ diff --git a/elf/dl-dst.h b/elf/dl-dst.h index a00e921..cbc59d4 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -25,7 +25,7 @@ size_t __cnt = 0; \ const char *__sf = strchr (name, '$'); \ \ - if (__builtin_expect (__sf != NULL, 0)) \ + if (__glibc_unlikely (__sf != NULL)) \ __cnt = _dl_dst_count (__sf, is_path); \ \ __cnt; }) diff --git a/elf/dl-fini.c b/elf/dl-fini.c index 05bbd68..c355775 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -60,7 +60,7 @@ _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used, Lmid_t ns) if (runp != NULL) /* Look through the dependencies of the object. */ while (*runp != NULL) - if (__builtin_expect (*runp++ == thisp, 0)) + if (__glibc_unlikely (*runp++ == thisp)) { move: /* Move the current object to the back past the last @@ -90,21 +90,21 @@ _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used, Lmid_t ns) goto next; } - if (__builtin_expect (maps[k]->l_reldeps != NULL, 0)) + if (__glibc_unlikely (maps[k]->l_reldeps != NULL)) { unsigned int m = maps[k]->l_reldeps->act; struct link_map **relmaps = &maps[k]->l_reldeps->list[0]; /* Look through the relocation dependencies of the object. */ while (m-- > 0) - if (__builtin_expect (relmaps[m] == thisp, 0)) + if (__glibc_unlikely (relmaps[m] == thisp)) { /* If a cycle exists with a link time dependency, preserve the latter. */ struct link_map **runp = thisp->l_initfini; if (runp != NULL) while (*runp != NULL) - if (__builtin_expect (*runp++ == maps[k], 0)) + if (__glibc_unlikely (*runp++ == maps[k])) goto ignore; goto move; } @@ -286,7 +286,7 @@ _dl_fini (void) goto again; } - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS)) _dl_debug_printf ("\nruntime linker statistics:\n" " final number of relocations: %lu\n" "final number of relocations from cache: %lu\n", diff --git a/elf/dl-fptr.c b/elf/dl-fptr.c index 8088db3..40cb40a 100644 --- a/elf/dl-fptr.c +++ b/elf/dl-fptr.c @@ -209,7 +209,7 @@ _dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym, Elf_Symndx symidx; struct local *l; - if (__builtin_expect (ftab == NULL, 0)) + if (__glibc_unlikely (ftab == NULL)) ftab = make_fptr_table (map); symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]); diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c index 86d9e9c..e7c60f2 100644 --- a/elf/dl-hwcaps.c +++ b/elf/dl-hwcaps.c @@ -133,7 +133,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz, len = strlen (p); /* Skip entries that are not enabled in the mask word. */ - if (__builtin_expect (mask & ((ElfW(Word)) 1 << bit), 1)) + if (__glibc_likely (mask & ((ElfW(Word)) 1 << bit))) { temp[m].str = p; temp[m].len = len; diff --git a/elf/dl-init.c b/elf/dl-init.c index 28a6ff6d8..598df3b 100644 --- a/elf/dl-init.c +++ b/elf/dl-init.c @@ -52,7 +52,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env) return; /* Print a debug message if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS)) _dl_debug_printf ("\ncalling init: %s\n\n", DSO_FILENAME (l->l_name)); @@ -88,7 +88,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) ElfW(Dyn) *preinit_array_size = main_map->l_info[DT_PREINIT_ARRAYSZ]; unsigned int i; - if (__builtin_expect (GL(dl_initfirst) != NULL, 0)) + if (__glibc_unlikely (GL(dl_initfirst) != NULL)) { call_init (GL(dl_initfirst), argc, argv, env); GL(dl_initfirst) = NULL; @@ -102,7 +102,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) ElfW(Addr) *addrs; unsigned int cnt; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS)) _dl_debug_printf ("\ncalling preinit: %s\n\n", DSO_FILENAME (main_map->l_name)); diff --git a/elf/dl-libc.c b/elf/dl-libc.c index ceac3ca..6d1e981 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -158,7 +158,7 @@ __libc_dlopen_mode (const char *name, int mode) args.caller_dlopen = RETURN_ADDRESS (0); #ifdef SHARED - if (__builtin_expect (_dl_open_hook != NULL, 0)) + if (__glibc_unlikely (_dl_open_hook != NULL)) return _dl_open_hook->dlopen_mode (name, mode); return (dlerror_run (do_dlopen, &args) ? NULL : (void *) args.map); #else @@ -204,7 +204,7 @@ __libc_dlsym (void *map, const char *name) args.name = name; #ifdef SHARED - if (__builtin_expect (_dl_open_hook != NULL, 0)) + if (__glibc_unlikely (_dl_open_hook != NULL)) return _dl_open_hook->dlsym (map, name); #endif return (dlerror_run (do_dlsym, &args) ? NULL @@ -216,7 +216,7 @@ int __libc_dlclose (void *map) { #ifdef SHARED - if (__builtin_expect (_dl_open_hook != NULL, 0)) + if (__glibc_unlikely (_dl_open_hook != NULL)) return _dl_open_hook->dlclose (map); #endif return dlerror_run (do_dlclose, map); diff --git a/elf/dl-load.c b/elf/dl-load.c index 1be7a3c..6501ff2 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -333,7 +333,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, do { - if (__builtin_expect (*name == '$', 0)) + if (__glibc_unlikely (*name == '$')) { const char *repl = NULL; size_t len; @@ -565,7 +565,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, dirp->status[cnt] = init_val; dirp->what = what; - if (__builtin_expect (where != NULL, 1)) + if (__glibc_likely (where != NULL)) dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1 + (ncapstr * sizeof (enum r_dir_status)), where, where_len); @@ -836,7 +836,7 @@ _dl_init_paths (const char *llp) #ifdef SHARED /* Expand DSTs. */ size_t cnt = DL_DST_COUNT (llp, 1); - if (__builtin_expect (cnt == 0, 1)) + if (__glibc_likely (cnt == 0)) llp_tmp = strdupa (llp); else { @@ -935,7 +935,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, bool make_consistent = false; /* Get file information. */ - if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st) < 0, 0)) + if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &st) < 0)) { errstring = N_("cannot stat shared object"); call_lose_errno: @@ -999,7 +999,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("file=%s [%lu]; generating link map\n", name, nsid); /* This is the ELF header. We read it in `open_verify'. */ @@ -1057,7 +1057,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Enter the new object in the list of loaded objects. */ l = _dl_new_object (realname, name, l_type, loader, mode, nsid); - if (__builtin_expect (l == NULL, 0)) + if (__glibc_unlikely (l == NULL)) { #ifdef SHARED fail_new: @@ -1226,7 +1226,7 @@ cannot allocate TLS data structures for initial thread"); /* Now we install the TCB in the thread register. */ errstring = TLS_INIT_TP (tcb, 0); - if (__builtin_expect (errstring == NULL, 1)) + if (__glibc_likely (errstring == NULL)) { /* Now we are all good. */ l->l_tls_modid = ++GL(dl_tls_max_dtv_idx); @@ -1256,7 +1256,7 @@ cannot allocate TLS data structures for initial thread"); break; } - if (__builtin_expect (nloadcmds == 0, 0)) + if (__glibc_unlikely (nloadcmds == 0)) { /* This only happens for a bogus object that will be caught with another error below. But we don't want to go through the @@ -1294,7 +1294,7 @@ cannot allocate TLS data structures for initial thread"); c->prot, MAP_COPY|MAP_FILE, fd, c->mapoff); - if (__builtin_expect ((void *) l->l_map_start == MAP_FAILED, 0)) + if (__glibc_unlikely ((void *) l->l_map_start == MAP_FAILED)) { map_error: errstring = N_("failed to map segment from shared object"); @@ -1321,7 +1321,7 @@ cannot allocate TLS data structures for initial thread"); /* This object is loaded at a fixed address. This must never happen for objects loaded with dlopen(). */ - if (__builtin_expect ((mode & __RTLD_OPENEXEC) == 0, 0)) + if (__glibc_unlikely ((mode & __RTLD_OPENEXEC) == 0)) { errstring = N_("cannot dynamically load executable"); goto call_lose; @@ -1379,7 +1379,7 @@ cannot allocate TLS data structures for initial thread"); if (zeropage > zero) { /* Zero the final part of the last page of the segment. */ - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) { /* Dag nab it. */ if (__mprotect ((caddr_t) (zero @@ -1391,7 +1391,7 @@ cannot allocate TLS data structures for initial thread"); } } memset ((void *) zero, '\0', zeropage - zero); - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) __mprotect ((caddr_t) (zero & ~(GLRO(dl_pagesize) - 1)), GLRO(dl_pagesize), c->prot); } @@ -1403,7 +1403,7 @@ cannot allocate TLS data structures for initial thread"); mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage, c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0); - if (__builtin_expect (mapat == MAP_FAILED, 0)) + if (__glibc_unlikely (mapat == MAP_FAILED)) { errstring = N_("cannot map zero-fill pages"); goto call_lose_errno; @@ -1417,7 +1417,7 @@ cannot allocate TLS data structures for initial thread"); if (l->l_ld == 0) { - if (__builtin_expect (type == ET_DYN, 0)) + if (__glibc_unlikely (type == ET_DYN)) { errstring = N_("object file has no dynamic section"); goto call_lose; @@ -1467,7 +1467,7 @@ cannot allocate TLS data structures for initial thread"); /* Adjust the PT_PHDR value by the runtime load address. */ l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr); - if (__builtin_expect ((stack_flags &~ GL(dl_stack_flags)) & PF_X, 0)) + if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X)) { if (__builtin_expect (__check_caller (RETURN_ADDRESS (0), allow_ldso), 0) != 0) @@ -1490,7 +1490,7 @@ cannot allocate TLS data structures for initial thread"); const uintptr_t relro_end = ((m->l_addr + m->l_relro_addr + m->l_relro_size) & -GLRO(dl_pagesize)); - if (__builtin_expect (p + s <= relro_end, 1)) + if (__glibc_likely (p + s <= relro_end)) { /* The variable lies in the region protected by RELRO. */ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0) @@ -1526,7 +1526,7 @@ cannot enable executable stack as shared object requires"); l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr; /* We are done mapping in the file. We no longer need the descriptor. */ - if (__builtin_expect (__close (fd) != 0, 0)) + if (__glibc_unlikely (__close (fd) != 0)) { errstring = N_("cannot close file descriptor"); goto call_lose_errno; @@ -1539,7 +1539,7 @@ cannot enable executable stack as shared object requires"); l->l_entry += l->l_addr; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\ dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n", @@ -1754,7 +1754,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader, ehdr = (ElfW(Ehdr) *) fbp->buf; /* Now run the tests. */ - if (__builtin_expect (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)), 0)) + if (__glibc_unlikely (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)))) { errval = errno; errstring = (errval == 0 @@ -1939,7 +1939,7 @@ open_path (const char *name, size_t namelen, int secure, const char *current_what = NULL; int any = 0; - if (__builtin_expect (dirs == NULL, 0)) + if (__glibc_unlikely (dirs == NULL)) /* We're called before _dl_init_paths when loading the main executable given on the command line when rtld is run directly. */ return -1; @@ -1977,7 +1977,7 @@ open_path (const char *name, size_t namelen, int secure, - buf); /* Print name we try if this is wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf (" trying file=%s\n", buf); fd = open_verify (buf, fbp, loader, whatcode, found_other_class, @@ -2059,7 +2059,7 @@ open_path (const char *name, size_t namelen, int secure, while (*++dirs != NULL); /* Remove the whole path if none of the directories exists. */ - if (__builtin_expect (! any, 0)) + if (__glibc_unlikely (! any)) { /* Paths which were allocated using the minimal malloc() in ld.so must not be freed using the general free() in libc. */ @@ -2165,7 +2165,7 @@ _dl_map_object (struct link_map *loader, const char *name, size_t namelen = strlen (name) + 1; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("find library=%s [%lu]; searching\n", name, nsid); fd = -1; @@ -2268,7 +2268,7 @@ _dl_map_object (struct link_map *loader, const char *name, fd = open_verify (cached, &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded, LA_SER_CONFIG, &found_other_class, false); - if (__builtin_expect (fd != -1, 1)) + if (__glibc_likely (fd != -1)) { realname = local_strdup (cached); if (realname == NULL) @@ -2291,7 +2291,7 @@ _dl_map_object (struct link_map *loader, const char *name, &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); /* Add another newline when we are tracing the library loading. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\n"); } else diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index a58e5bc..690f404 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -110,7 +110,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, continue; /* Print some debugging info if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS)) _dl_debug_printf ("symbol=%s; lookup in file=%s [%lu]\n", undef_name, DSO_FILENAME (map->l_name), map->l_ns); @@ -143,7 +143,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, #define ALLOWED_STT \ ((1 << STT_NOTYPE) | (1 << STT_OBJECT) | (1 << STT_FUNC) \ | (1 << STT_COMMON) | (1 << STT_TLS) | (1 << STT_GNU_IFUNC)) - if (__builtin_expect (((1 << stt) & ALLOWED_STT) == 0, 0)) + if (__glibc_unlikely (((1 << stt) & ALLOWED_STT) == 0)) return NULL; if (sym != ref && strcmp (strtab + sym->st_name, undef_name)) @@ -153,7 +153,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, const ElfW(Half) *verstab = map->l_versyms; if (version != NULL) { - if (__builtin_expect (verstab == NULL, 0)) + if (__glibc_unlikely (verstab == NULL)) { /* We need a versioned symbol but haven't found any. If this is the object which is referenced in the verneed @@ -223,7 +223,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, const ElfW(Sym) *sym; const ElfW(Addr) *bitmask = map->l_gnu_bitmask; - if (__builtin_expect (bitmask != NULL, 1)) + if (__glibc_likely (bitmask != NULL)) { ElfW(Addr) bitmask_word = bitmask[(new_hash / __ELF_NATIVE_CLASS) @@ -287,7 +287,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, { case STB_WEAK: /* Weak definition. Use this value if we don't find another. */ - if (__builtin_expect (GLRO(dl_dynamic_weak), 0)) + if (__glibc_unlikely (GLRO(dl_dynamic_weak))) { if (! result->s) { @@ -412,7 +412,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, LD_TRACE_PRELINKING in _dl_debug_bindings. Don't allocate anything and don't enter anything into the hash table. */ - if (__builtin_expect (tab->size, 0)) + if (__glibc_unlikely (tab->size)) { assert (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK); __rtld_lock_unlock_recursive (tab->lock); @@ -530,7 +530,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) unsigned long long serial = map->l_serial; /* Make sure nobody can unload the object while we are at it. */ - if (__builtin_expect (flags & DL_LOOKUP_GSCOPE_LOCK, 0)) + if (__glibc_unlikely (flags & DL_LOOKUP_GSCOPE_LOCK)) { /* We can't just call __rtld_lock_lock_recursive (GL(dl_load_lock)) here, that can result in ABBA deadlock. */ @@ -617,7 +617,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) } /* Add the reference now. */ - if (__builtin_expect (l_reldepsact >= undef_map->l_reldepsmax, 0)) + if (__glibc_unlikely (l_reldepsact >= undef_map->l_reldepsmax)) { /* Allocate more memory for the dependency list. Since this can never happen during the startup phase we can use @@ -663,7 +663,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) } /* Display information if we are debugging. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\ \nfile=%s [%lu]; needed by %s [%lu] (relocation dependency)\n\n", DSO_FILENAME (map->l_name), @@ -679,7 +679,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) /* Release the lock. */ __rtld_lock_unlock_recursive (GL(dl_load_lock)); - if (__builtin_expect (flags & DL_LOOKUP_GSCOPE_LOCK, 0)) + if (__glibc_unlikely (flags & DL_LOOKUP_GSCOPE_LOCK)) THREAD_GSCOPE_SET_FLAG (); return result; @@ -726,7 +726,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, == 0); size_t i = 0; - if (__builtin_expect (skip_map != NULL, 0)) + if (__glibc_unlikely (skip_map != NULL)) /* Search the relevant loaded objects for a definition. */ while ((*scope)->r_list[i] != skip_map) ++i; @@ -763,7 +763,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, } } - if (__builtin_expect (current_value.s == NULL, 0)) + if (__glibc_unlikely (current_value.s == NULL)) { if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) && skip_map == NULL @@ -787,7 +787,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, int protected = (*ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED); - if (__builtin_expect (protected != 0, 0)) + if (__glibc_unlikely (protected != 0)) { /* It is very tricky. We need to figure out what value to return for the protected symbol. */ @@ -835,7 +835,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, version, type_class, flags, skip_map); /* The object is used. */ - if (__builtin_expect (current_value.m->l_used == 0, 0)) + if (__glibc_unlikely (current_value.m->l_used == 0)) current_value.m->l_used = 1; if (__builtin_expect (GLRO(dl_debug_mask) diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 22d0b3c..20a672a 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -68,7 +68,7 @@ __libc_memalign (size_t align, size_t n) /* Insufficient space left; allocate another page. */ caddr_t page; size_t nup = (n + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1); - if (__builtin_expect (nup == 0, 0)) + if (__glibc_unlikely (nup == 0)) { if (n) return NULL; diff --git a/elf/dl-open.c b/elf/dl-open.c index a9ca6b3..7cc4cc1 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -147,7 +147,7 @@ add_to_global (struct link_map *new) ns->_ns_main_searchlist->r_list[new_nlist++] = map; /* We modify the global scope. Report this. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES)) _dl_debug_printf ("\nadd %s [%lu] to global scope\n", map->l_name, map->l_ns); } @@ -232,7 +232,7 @@ dl_open_worker (void *a) return; } - if (__builtin_expect (mode & __RTLD_SPROF, 0)) + if (__glibc_unlikely (mode & __RTLD_SPROF)) /* This happens only if we load a DSO for 'sprof'. */ return; @@ -240,10 +240,10 @@ dl_open_worker (void *a) ++new->l_direct_opencount; /* It was already open. */ - if (__builtin_expect (new->l_searchlist.r_list != NULL, 0)) + if (__glibc_unlikely (new->l_searchlist.r_list != NULL)) { /* Let the user know about the opencount. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("opening file=%s [%lu]; direct_opencount=%u\n\n", new->l_name, new->l_ns, new->l_direct_opencount); @@ -269,7 +269,7 @@ dl_open_worker (void *a) #ifdef SHARED /* Auditing checkpoint: we have added all objects. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *head = GL(dl_ns)[new->l_ns]._ns_loaded; /* Do not call the functions for any auditing object. */ @@ -294,7 +294,7 @@ dl_open_worker (void *a) LIBC_PROBE (map_complete, 3, args->nsid, r, new); /* Print scope information. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES)) _dl_show_scope (new, 0); /* Only do lazy relocation if `LD_BIND_NOW' is not set. */ @@ -344,7 +344,7 @@ dl_open_worker (void *a) if (runp != NULL) /* Look through the dependencies of the object. */ while (*runp != NULL) - if (__builtin_expect (*runp++ == thisp, 0)) + if (__glibc_unlikely (*runp++ == thisp)) { /* Move the current object to the back past the last object with it as the dependency. */ @@ -391,7 +391,7 @@ dl_open_worker (void *a) } #ifdef SHARED - if (__builtin_expect (GLRO(dl_profile) != NULL, 0)) + if (__glibc_unlikely (GLRO(dl_profile) != NULL)) { /* If this here is the shared object which we want to profile make sure the profile is started. We can find out whether @@ -444,7 +444,7 @@ dl_open_worker (void *a) /* Avoid duplicates. */ continue; - if (__builtin_expect (cnt + 1 >= imap->l_scope_max, 0)) + if (__glibc_unlikely (cnt + 1 >= imap->l_scope_max)) { /* The 'r_scope' array is too small. Allocate a new one dynamically. */ @@ -511,7 +511,7 @@ dl_open_worker (void *a) } /* Print scope information. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES)) _dl_show_scope (imap, from_scope); } @@ -574,7 +574,7 @@ cannot load any more object with static TLS")); /* Mark the object as not deletable if the RTLD_NODELETE flags was passed. */ - if (__builtin_expect (mode & RTLD_NODELETE, 0)) + if (__glibc_unlikely (mode & RTLD_NODELETE)) new->l_flags_1 |= DF_1_NODELETE; #ifndef SHARED @@ -584,7 +584,7 @@ cannot load any more object with static TLS")); #endif /* Let the user know about the opencount. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("opening file=%s [%lu]; direct_opencount=%u\n\n", new->l_name, new->l_ns, new->l_direct_opencount); } @@ -601,14 +601,14 @@ _dl_open (const char *file, int mode, const void *caller_dlopen, Lmid_t nsid, /* Make sure we are alone. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); - if (__builtin_expect (nsid == LM_ID_NEWLM, 0)) + if (__glibc_unlikely (nsid == LM_ID_NEWLM)) { /* Find a new namespace. */ for (nsid = 1; DL_NNS > 1 && nsid < GL(dl_nns); ++nsid) if (GL(dl_ns)[nsid]._ns_loaded == NULL) break; - if (__builtin_expect (nsid == DL_NNS, 0)) + if (__glibc_unlikely (nsid == DL_NNS)) { /* No more namespace available. */ __rtld_lock_unlock_recursive (GL(dl_load_lock)); @@ -656,7 +656,7 @@ no more namespaces available for dlmopen()")); #endif /* See if an error occurred during loading. */ - if (__builtin_expect (errstring != NULL, 0)) + if (__glibc_unlikely (errstring != NULL)) { /* Remove the object from memory. It may be in an inconsistent state if relocation failed, for example. */ diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 1f66fcc..d2c6dac 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -183,14 +183,14 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], && __builtin_expect (l->l_info[DT_BIND_NOW] != NULL, 0)) lazy = 0; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC)) _dl_debug_printf ("\nrelocation processing: %s%s\n", DSO_FILENAME (l->l_name), lazy ? " (lazy)" : ""); /* DT_TEXTREL is now in level 2 and might phase out at some time. But we rewrite the DT_FLAGS entry to a DT_TEXTREL entry to make testing easier and therefore it will be available at all time. */ - if (__builtin_expect (l->l_info[DT_TEXTREL] != NULL, 0)) + if (__glibc_unlikely (l->l_info[DT_TEXTREL] != NULL)) { /* Bletch. We must make read-only segments writable long enough to relocate them. */ @@ -264,7 +264,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc); #ifndef PROF - if (__builtin_expect (consider_profiling, 0)) + if (__glibc_unlikely (consider_profiling)) { /* Allocate the array which will contain the already found relocations. If the shared object lacks a PLT (for example diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 655623b..773cb42 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -142,7 +142,7 @@ _dl_fixup ( value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value)); /* Finally, fix up the plt itself. */ - if (__builtin_expect (GLRO(dl_bind_not), 0)) + if (__glibc_unlikely (GLRO(dl_bind_not))) return value; return elf_machine_fixup_plt (l, result, reloc, rel_addr, value); @@ -347,7 +347,7 @@ _dl_profile_fixup ( #endif /* Store the result for later runs. */ - if (__builtin_expect (! GLRO(dl_bind_not), 1)) + if (__glibc_likely (! GLRO(dl_bind_not))) *resultp = value; } diff --git a/elf/dl-sym.c b/elf/dl-sym.c index f00975d..69671c1 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -128,7 +128,7 @@ do_sym (void *handle, const char *name, void *who, THREAD_GSCOPE_RESET_FLAG (); - if (__builtin_expect (errstring != NULL, 0)) + if (__glibc_unlikely (errstring != NULL)) { /* The lookup was unsuccessful. Rethrow the error. */ char *errstring_dup = strdupa (errstring); @@ -145,7 +145,7 @@ do_sym (void *handle, const char *name, void *who, } else if (handle == RTLD_NEXT) { - if (__builtin_expect (match == GL(dl_ns)[LM_ID_BASE]._ns_loaded, 0)) + if (__glibc_unlikely (match == GL(dl_ns)[LM_ID_BASE]._ns_loaded)) { if (match == NULL || caller < match->l_map_start @@ -183,7 +183,7 @@ RTLD_NEXT used in code not dynamically loaded")); value = DL_SYMBOL_ADDRESS (result, ref); /* Resolve indirect function address. */ - if (__builtin_expect (ELFW(ST_TYPE) (ref->st_info) == STT_GNU_IFUNC, 0)) + if (__glibc_unlikely (ELFW(ST_TYPE) (ref->st_info) == STT_GNU_IFUNC)) { DL_FIXUP_VALUE_TYPE fixup = DL_FIXUP_MAKE_VALUE (result, (ElfW(Addr)) value); @@ -195,7 +195,7 @@ RTLD_NEXT used in code not dynamically loaded")); /* Auditing checkpoint: we have a new binding. Provide the auditing libraries the possibility to change the value and tell us whether further auditing is wanted. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { const char *strtab = (const char *) D_PTR (result, l_info[DT_STRTAB]); diff --git a/elf/dl-tls.c b/elf/dl-tls.c index dbaea0a..9454d06 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -720,7 +720,7 @@ tls_get_addr_tail (GET_ADDR_ARGS, dtv_t *dtv, struct link_map *the_map) != FORCED_DYNAMIC_TLS_OFFSET, 0)) { __rtld_lock_lock_recursive (GL(dl_load_lock)); - if (__builtin_expect (the_map->l_tls_offset == NO_TLS_OFFSET, 1)) + if (__glibc_likely (the_map->l_tls_offset == NO_TLS_OFFSET)) { the_map->l_tls_offset = FORCED_DYNAMIC_TLS_OFFSET; __rtld_lock_unlock_recursive (GL(dl_load_lock)); @@ -732,7 +732,7 @@ tls_get_addr_tail (GET_ADDR_ARGS, dtv_t *dtv, struct link_map *the_map) != FORCED_DYNAMIC_TLS_OFFSET, 1)) { void *p = dtv[GET_ADDR_MODULE].pointer.val; - if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0)) + if (__glibc_unlikely (p == TLS_DTV_UNALLOCATED)) goto again; return (char *) p + GET_ADDR_OFFSET; @@ -755,7 +755,7 @@ update_get_addr (GET_ADDR_ARGS) void *p = dtv[GET_ADDR_MODULE].pointer.val; - if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0)) + if (__glibc_unlikely (p == TLS_DTV_UNALLOCATED)) return tls_get_addr_tail (GET_ADDR_PARAM, dtv, the_map); return (void *) p + GET_ADDR_OFFSET; @@ -769,12 +769,12 @@ __tls_get_addr (GET_ADDR_ARGS) { dtv_t *dtv = THREAD_DTV (); - if (__builtin_expect (dtv[0].counter != GL(dl_tls_generation), 0)) + if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation))) return update_get_addr (GET_ADDR_PARAM); void *p = dtv[GET_ADDR_MODULE].pointer.val; - if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0)) + if (__glibc_unlikely (p == TLS_DTV_UNALLOCATED)) return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL); return (char *) p + GET_ADDR_OFFSET; @@ -787,12 +787,12 @@ __tls_get_addr (GET_ADDR_ARGS) void * _dl_tls_get_addr_soft (struct link_map *l) { - if (__builtin_expect (l->l_tls_modid == 0, 0)) + if (__glibc_unlikely (l->l_tls_modid == 0)) /* This module has no TLS segment. */ return NULL; dtv_t *dtv = THREAD_DTV (); - if (__builtin_expect (dtv[0].counter != GL(dl_tls_generation), 0)) + if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation))) { /* This thread's DTV is not completely current, but it might already cover this module. */ @@ -817,7 +817,7 @@ _dl_tls_get_addr_soft (struct link_map *l) } void *data = dtv[l->l_tls_modid].pointer.val; - if (__builtin_expect (data == TLS_DTV_UNALLOCATED, 0)) + if (__glibc_unlikely (data == TLS_DTV_UNALLOCATED)) /* The DTV is current, but this thread has not yet needed to allocate this module's segment. */ data = NULL; diff --git a/elf/dl-version.c b/elf/dl-version.c index 651d4cf..525e9d5 100644 --- a/elf/dl-version.c +++ b/elf/dl-version.c @@ -82,13 +82,13 @@ match_symbol (const char *name, Lmid_t ns, ElfW(Word) hash, const char *string, int result = 0; /* Display information about what we are doing while debugging. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_VERSIONS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_VERSIONS)) _dl_debug_printf ("\ checking for version `%s' in file %s [%lu] required by file %s [%lu]\n", string, DSO_FILENAME (map->l_name), map->l_ns, name, ns); - if (__builtin_expect (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL, 0)) + if (__glibc_unlikely (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL)) { /* The file has no symbol versioning. I.e., the dependent object was linked against another version of this file. We @@ -145,7 +145,7 @@ no version information available (required by ", name, ")"); } /* Symbol not found. If it was a weak reference it is not fatal. */ - if (__builtin_expect (weak, 1)) + if (__glibc_likely (weak)) { if (verbose) { @@ -291,7 +291,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) section. */ map->l_versions = (struct r_found_version *) calloc (ndx_high + 1, sizeof (*map->l_versions)); - if (__builtin_expect (map->l_versions == NULL, 0)) + if (__glibc_unlikely (map->l_versions == NULL)) { errstring = N_("cannot allocate version reference table"); errval = ENOMEM; @@ -316,7 +316,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) { ElfW(Half) ndx = aux->vna_other & 0x7fff; /* In trace mode, dependencies may be missing. */ - if (__builtin_expect (ndx < map->l_nversions, 1)) + if (__glibc_likely (ndx < map->l_nversions)) { map->l_versions[ndx].hash = aux->vna_hash; map->l_versions[ndx].hidden = aux->vna_other & 0x8000; diff --git a/elf/dl-writev.h b/elf/dl-writev.h index ad67c1d..a5ce6c5 100644 --- a/elf/dl-writev.h +++ b/elf/dl-writev.h @@ -42,7 +42,7 @@ _dl_writev (int fd, const struct iovec *iov, size_t niov) errno when it's being used by another thread that cares about it. Yet we must be sure not to try calling the lock functions before the thread library is fully initialized. */ - if (__builtin_expect (INTUSE (_dl_starting_up), 0)) + if (__glibc_unlikely (INTUSE (_dl_starting_up))) __writev (fd, iov, niov); else { diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 46d2950..4211f4c 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -770,7 +770,7 @@ search_dir (const struct dir_entry *entry) lstat_buf.st_mode = DTTOIF (direntry->d_type); else #endif - if (__builtin_expect (lstat64 (real_file_name, &lstat_buf), 0)) + if (__glibc_unlikely (lstat64 (real_file_name, &lstat_buf))) { error (0, errno, _("Cannot lstat %s"), file_name); continue; @@ -794,7 +794,7 @@ search_dir (const struct dir_entry *entry) continue; } } - if (__builtin_expect (stat64 (target_name, &stat_buf), 0)) + if (__glibc_unlikely (stat64 (target_name, &stat_buf))) { if (opt_verbose) error (0, errno, _("Cannot stat %s"), file_name); diff --git a/elf/rtld.c b/elf/rtld.c index 6dcbabc..aa50cab 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -344,7 +344,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) } #endif - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS)) { #ifndef HP_TIMING_NONAVAIL print_statistics (&rtld_total_time); @@ -517,7 +517,7 @@ _dl_start (void *arg) # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" # endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); @@ -779,7 +779,7 @@ cannot allocate TLS data structures for initial thread"); #else = TLS_INIT_TP (tcbp, 0); #endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); tls_init_tp_called = true; @@ -813,7 +813,7 @@ do_preload (char *fname, struct link_map *main_map, const char *where) unsigned int old_nloaded = GL(dl_ns)[LM_ID_BASE]._ns_nloaded; (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, &args); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) { _dl_error_printf ("\ ERROR: ld.so: object '%s' from %s cannot be preloaded (%s): ignored.\n", @@ -1067,7 +1067,7 @@ of this helper program; chances are you did not intend to run this program.\n\ args.mode = __RTLD_OPENEXEC; (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, &args); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) /* We don't free the returned string, the programs stops anyway. */ _exit (EXIT_FAILURE); @@ -1394,7 +1394,7 @@ of this helper program; chances are you did not intend to run this program.\n\ GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid (); /* If we have auditing DSOs to load, do it now. */ - if (__builtin_expect (audit_list != NULL, 0)) + if (__glibc_unlikely (audit_list != NULL)) { /* Iterate over all entries in the list. The order is important. */ struct audit_ifaces *last_audit = NULL; @@ -1428,7 +1428,7 @@ of this helper program; chances are you did not intend to run this program.\n\ bool malloced; (void) _dl_catch_error (&objname, &err_str, &malloced, dlmopen_doit, &dlmargs); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) { not_loaded: _dl_error_printf ("\ @@ -1544,7 +1544,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", /* If we have any auditing modules, announce that we already have two objects loaded. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *ls[2] = { main_map, &GL(dl_rtld_map) }; @@ -1593,7 +1593,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", /* Auditing checkpoint: we are ready to signal that the initial map is being constructed. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -1612,7 +1612,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", struct link_map **preloads = NULL; unsigned int npreloads = 0; - if (__builtin_expect (preloadlist != NULL, 0)) + if (__glibc_unlikely (preloadlist != NULL)) { /* The LD_PRELOAD environment variable gives list of libraries separated by white space or colons that are loaded before the @@ -1643,12 +1643,12 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", the work but this does not matter, since it is not for production use. */ static const char preload_file[] = "/etc/ld.so.preload"; - if (__builtin_expect (__access (preload_file, R_OK) == 0, 0)) + if (__glibc_unlikely (__access (preload_file, R_OK) == 0)) { /* Read the contents of the file. */ file = _dl_sysdep_read_whole_file (preload_file, &file_size, PROT_READ | PROT_WRITE); - if (__builtin_expect (file != MAP_FAILED, 0)) + if (__glibc_unlikely (file != MAP_FAILED)) { /* Parse the file. It contains names of libraries to be loaded, separated by white spaces or `:'. It may also contain @@ -1720,7 +1720,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", } } - if (__builtin_expect (*first_preload != NULL, 0)) + if (__glibc_unlikely (*first_preload != NULL)) { /* Set up PRELOADS with a vector of the preloaded libraries. */ struct link_map *l = *first_preload; @@ -1757,7 +1757,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", break; bool rtld_multiple_ref = false; - if (__builtin_expect (i < main_map->l_searchlist.r_nlist, 1)) + if (__glibc_likely (i < main_map->l_searchlist.r_nlist)) { /* Some DT_NEEDED entry referred to the interpreter object itself, so put it back in the list of visible objects. We insert it into the @@ -1815,7 +1815,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (tcbp == NULL) tcbp = init_tls (); - if (__builtin_expect (audit_list == NULL, 1)) + if (__glibc_likely (audit_list == NULL)) /* Initialize security features. But only if we have not done it earlier. */ security_init (); @@ -2099,7 +2099,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (r_list == r_listend && liblist == liblistend) prelinked = true; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\nprelink checking: %s\n", prelinked ? "ok" : "failed"); } @@ -2117,7 +2117,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", GLRO(dl_init_all_dirs) = GL(dl_all_dirs); /* Print scope information. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES)) { _dl_debug_printf ("\nInitial object scopes\n"); @@ -2215,7 +2215,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", this has to go here because the calls it makes should use the rtld versions of the functions (particularly calloc()), but it needs to have _dl_profile_map set up by the relocator. */ - if (__builtin_expect (GL(dl_profile_map) != NULL, 0)) + if (__glibc_unlikely (GL(dl_profile_map) != NULL)) /* We must prepare the profiling. */ _dl_start_profile (); } @@ -2238,7 +2238,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #else = TLS_INIT_TP (tcbp, 0); #endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); } @@ -2279,7 +2279,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #ifdef SHARED /* Auditing checkpoint: we have added all objects. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *head = GL(dl_ns)[LM_ID_BASE]._ns_loaded; /* Do not call the functions for any auditing object. */ diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h index f3716b6..1057cf0 100644 --- a/elf/setup-vdso.h +++ b/elf/setup-vdso.h @@ -31,7 +31,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)), mapped and relocated it normally. */ struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL, 0, LM_ID_BASE); - if (__builtin_expect (l != NULL, 1)) + if (__glibc_likely (l != NULL)) { static ElfW(Dyn) dyn_temp[DL_RO_DYN_TEMP_CNT] attribute_relro; diff --git a/grp/compat-initgroups.c b/grp/compat-initgroups.c index 260c482..ff10e24 100644 --- a/grp/compat-initgroups.c +++ b/grp/compat-initgroups.c @@ -82,7 +82,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start, { /* Matches user and not yet on the list. Insert this group. */ - if (__builtin_expect (*start == *size, 0)) + if (__glibc_unlikely (*start == *size)) { /* Need a bigger buffer. */ gid_t *newgroups; diff --git a/grp/fgetgrent.c b/grp/fgetgrent.c index 2ab64d2..38c8383 100644 --- a/grp/fgetgrent.c +++ b/grp/fgetgrent.c @@ -57,7 +57,7 @@ fgetgrent (FILE *stream) char *new_buf; buffer_size += NSS_BUFLEN_GROUP; new_buf = realloc (buffer, buffer_size); - if (__builtin_expect (new_buf == NULL, 0)) + if (__glibc_unlikely (new_buf == NULL)) { /* We are out of memory. Free the current buffer so that the process gets a chance for a normal termination. */ diff --git a/grp/initgroups.c b/grp/initgroups.c index a2b6d31..bdde097 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -159,7 +159,7 @@ getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) long int size = MAX (1, *ngroups); gid_t *newgroups = (gid_t *) malloc (size * sizeof (gid_t)); - if (__builtin_expect (newgroups == NULL, 0)) + if (__glibc_unlikely (newgroups == NULL)) /* No more memory. */ // XXX This is wrong. The user provided memory, we have to use // XXX it. The internal functions must be called with the user @@ -212,7 +212,7 @@ initgroups (const char *user, gid_t group) size = 16; groups = (gid_t *) malloc (size * sizeof (gid_t)); - if (__builtin_expect (groups == NULL, 0)) + if (__glibc_unlikely (groups == NULL)) /* No more memory. */ return -1; diff --git a/grp/putgrent.c b/grp/putgrent.c index bb42927..029415f 100644 --- a/grp/putgrent.c +++ b/grp/putgrent.c @@ -33,7 +33,7 @@ putgrent (gr, stream) { int retval; - if (__builtin_expect (gr == NULL, 0) || __builtin_expect (stream == NULL, 0)) + if (__glibc_unlikely (gr == NULL) || __glibc_unlikely (stream == NULL)) { __set_errno (EINVAL); return -1; diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c index 9f66a3b..327bbf4 100644 --- a/hesiod/nss_hesiod/hesiod-grp.c +++ b/hesiod/nss_hesiod/hesiod-grp.c @@ -227,7 +227,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start, if (status == NSS_STATUS_SUCCESS && !internal_gid_in_list (groups, group, *start)) { - if (__builtin_expect (*start == *size, 0)) + if (__glibc_unlikely (*start == *size)) { /* Need a bigger buffer. */ gid_t *newgroups; diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c index 81d94ea..132e20b 100644 --- a/hurd/hurdinit.c +++ b/hurd/hurdinit.c @@ -38,7 +38,7 @@ int __libc_argc; error_t _hurd_ports_use (int which, error_t (*operate) (mach_port_t)) { - if (__builtin_expect (_hurd_ports == NULL, 0)) + if (__glibc_unlikely (_hurd_ports == NULL)) /* This means that _hurd_init has not been called yet, which is normally only the case in the bootstrap filesystem, and there only in the early phases of booting. */ diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c index 41a4688..f3a4337 100644 --- a/iconv/gconv_cache.c +++ b/iconv/gconv_cache.c @@ -79,7 +79,7 @@ __gconv_load_cache (void) cache_size = st.st_size; #ifdef _POSIX_MAPPED_FILES gconv_cache = __mmap (NULL, cache_size, PROT_READ, MAP_SHARED, fd, 0); - if (__builtin_expect (gconv_cache == MAP_FAILED, 0)) + if (__glibc_unlikely (gconv_cache == MAP_FAILED)) #endif { size_t already_read; diff --git a/iconv/gconv_close.c b/iconv/gconv_close.c index 9d01f14..81f0e0b 100644 --- a/iconv/gconv_close.c +++ b/iconv/gconv_close.c @@ -45,7 +45,7 @@ __gconv_close (__gconv_t cd) struct __gconv_trans_data *curp = transp; transp = transp->__next; - if (__builtin_expect (curp->__trans_end_fct != NULL, 0)) + if (__glibc_unlikely (curp->__trans_end_fct != NULL)) curp->__trans_end_fct (curp->__data); free (curp); diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c index 69a1f65..bfbe22b 100644 --- a/iconv/gconv_open.c +++ b/iconv/gconv_open.c @@ -45,7 +45,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle, errhand = strchr (toset, '/'); if (errhand != NULL) errhand = strchr (errhand + 1, '/'); - if (__builtin_expect (errhand != NULL, 1)) + if (__glibc_likely (errhand != NULL)) { if (*++errhand == '\0') errhand = NULL; @@ -318,7 +318,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle, struct __gconv_trans_data *curp = transp; transp = transp->__next; - if (__builtin_expect (curp->__trans_end_fct != NULL, 0)) + if (__glibc_unlikely (curp->__trans_end_fct != NULL)) curp->__trans_end_fct (curp->__data); free (curp); diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c index 27acb5e..e11e2ee 100644 --- a/iconv/gconv_simple.c +++ b/iconv/gconv_simple.c @@ -177,7 +177,7 @@ internal_ucs4_loop_single (struct __gconv_step *step, while (*inptrp < inend && cnt < 4) state->__value.__wchb[cnt++] = *(*inptrp)++; - if (__builtin_expect (cnt < 4, 0)) + if (__glibc_unlikely (cnt < 4)) { /* Still not enough bytes. Store the ones in the input buffer. */ state->__count &= ~7; @@ -249,7 +249,7 @@ ucs4_internal_loop (struct __gconv_step *step, inval = *(const uint32_t *) inptr; #endif - if (__builtin_expect (inval > 0x7fffffff, 0)) + if (__glibc_unlikely (inval > 0x7fffffff)) { /* The value is too large. We don't try transliteration here since this is not an error because of the lack of possibilities to @@ -308,7 +308,7 @@ ucs4_internal_loop_unaligned (struct __gconv_step *step, for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) { - if (__builtin_expect (inptr[0] > 0x80, 0)) + if (__glibc_unlikely (inptr[0] > 0x80)) { /* The value is too large. We don't try transliteration here since this is not an error because of the lack of possibilities to @@ -376,7 +376,7 @@ ucs4_internal_loop_single (struct __gconv_step *step, while (*inptrp < inend && cnt < 4) state->__value.__wchb[cnt++] = *(*inptrp)++; - if (__builtin_expect (cnt < 4, 0)) + if (__glibc_unlikely (cnt < 4)) { /* Still not enough bytes. Store the ones in the input buffer. */ state->__count &= ~7; @@ -546,7 +546,7 @@ internal_ucs4le_loop_single (struct __gconv_step *step, while (*inptrp < inend && cnt < 4) state->__value.__wchb[cnt++] = *(*inptrp)++; - if (__builtin_expect (cnt < 4, 0)) + if (__glibc_unlikely (cnt < 4)) { /* Still not enough bytes. Store the ones in the input buffer. */ state->__count &= ~7; @@ -617,7 +617,7 @@ ucs4le_internal_loop (struct __gconv_step *step, inval = *(const uint32_t *) inptr; #endif - if (__builtin_expect (inval > 0x7fffffff, 0)) + if (__glibc_unlikely (inval > 0x7fffffff)) { /* The value is too large. We don't try transliteration here since this is not an error because of the lack of possibilities to @@ -677,7 +677,7 @@ ucs4le_internal_loop_unaligned (struct __gconv_step *step, for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) { - if (__builtin_expect (inptr[3] > 0x80, 0)) + if (__glibc_unlikely (inptr[3] > 0x80)) { /* The value is too large. We don't try transliteration here since this is not an error because of the lack of possibilities to @@ -749,7 +749,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, while (*inptrp < inend && cnt < 4) state->__value.__wchb[cnt++] = *(*inptrp)++; - if (__builtin_expect (cnt < 4, 0)) + if (__glibc_unlikely (cnt < 4)) { /* Still not enough bytes. Store the ones in the input buffer. */ state->__count &= ~7; @@ -810,7 +810,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, #define LOOPFCT FROM_LOOP #define BODY \ { \ - if (__builtin_expect (*inptr > '\x7f', 0)) \ + if (__glibc_unlikely (*inptr > '\x7f')) \ { \ /* The value is too large. We don't try transliteration here since \ this is not an error because of the lack of possibilities to \ @@ -846,7 +846,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, #define LOOPFCT FROM_LOOP #define BODY \ { \ - if (__builtin_expect (*((const uint32_t *) inptr) > 0x7f, 0)) \ + if (__glibc_unlikely (*((const uint32_t *) inptr) > 0x7f)) \ { \ UNICODE_TAG_HANDLER (*((const uint32_t *) inptr), 4); \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ @@ -883,10 +883,10 @@ ucs4le_internal_loop_single (struct __gconv_step *step, { \ uint32_t wc = *((const uint32_t *) inptr); \ \ - if (__builtin_expect (wc < 0x80, 1)) \ + if (__glibc_likely (wc < 0x80)) \ /* It's an one byte sequence. */ \ *outptr++ = (unsigned char) wc; \ - else if (__builtin_expect (wc <= 0x7fffffff, 1)) \ + else if (__glibc_likely (wc <= 0x7fffffff)) \ { \ size_t step; \ unsigned char *start; \ @@ -895,7 +895,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, if ((wc & (~(uint32_t)0 << (5 * step + 1))) == 0) \ break; \ \ - if (__builtin_expect (outptr + step > outend, 0)) \ + if (__glibc_unlikely (outptr + step > outend)) \ { \ /* Too long. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -946,7 +946,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, /* Next input byte. */ \ uint32_t ch = *inptr; \ \ - if (__builtin_expect (ch < 0x80, 1)) \ + if (__glibc_likely (ch < 0x80)) \ { \ /* One byte sequence. */ \ ++inptr; \ @@ -964,25 +964,25 @@ ucs4le_internal_loop_single (struct __gconv_step *step, 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; \ @@ -1003,7 +1003,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, 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. */ \ @@ -1011,7 +1011,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, if ((inptr[i] & 0xc0) != 0x80) \ break; \ \ - if (__builtin_expect (inptr + i == inend, 1)) \ + if (__glibc_likely (inptr + i == inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -1073,19 +1073,19 @@ ucs4le_internal_loop_single (struct __gconv_step *step, 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; \ @@ -1164,7 +1164,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, { \ uint16_t u1 = get16 (inptr); \ \ - if (__builtin_expect (u1 >= 0xd800 && u1 < 0xe000, 0)) \ + if (__glibc_unlikely (u1 >= 0xd800 && u1 < 0xe000)) \ { \ /* Surrogate characters in UCS-2 input are not valid. Reject \ them. (Catching this here is not security relevant.) */ \ @@ -1198,12 +1198,12 @@ ucs4le_internal_loop_single (struct __gconv_step *step, { \ uint32_t val = *((const uint32_t *) inptr); \ \ - if (__builtin_expect (val >= 0x10000, 0)) \ + if (__glibc_unlikely (val >= 0x10000)) \ { \ UNICODE_TAG_HANDLER (val, 4); \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ - else if (__builtin_expect (val >= 0xd800 && val < 0xe000, 0)) \ + else if (__glibc_unlikely (val >= 0xd800 && val < 0xe000)) \ { \ /* Surrogate characters in UCS-4 input are not valid. \ We must catch this, because the UCS-2 output might be \ @@ -1248,7 +1248,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, { \ uint16_t u1 = bswap_16 (get16 (inptr)); \ \ - if (__builtin_expect (u1 >= 0xd800 && u1 < 0xe000, 0)) \ + if (__glibc_unlikely (u1 >= 0xd800 && u1 < 0xe000)) \ { \ /* Surrogate characters in UCS-2 input are not valid. Reject \ them. (Catching this here is not security relevant.) */ \ @@ -1288,12 +1288,12 @@ ucs4le_internal_loop_single (struct __gconv_step *step, #define BODY \ { \ uint32_t val = *((const uint32_t *) inptr); \ - if (__builtin_expect (val >= 0x10000, 0)) \ + if (__glibc_unlikely (val >= 0x10000)) \ { \ UNICODE_TAG_HANDLER (val, 4); \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ - else if (__builtin_expect (val >= 0xd800 && val < 0xe000, 0)) \ + else if (__glibc_unlikely (val >= 0xd800 && val < 0xe000)) \ { \ /* Surrogate characters in UCS-4 input are not valid. \ We must catch this, because the UCS-2 output might be \ diff --git a/iconv/iconv.c b/iconv/iconv.c index 30b3564..a45b90e 100644 --- a/iconv/iconv.c +++ b/iconv/iconv.c @@ -36,7 +36,7 @@ iconv (iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t irreversible; int result; - if (__builtin_expect (inbuf == NULL || *inbuf == NULL, 0)) + if (__glibc_unlikely (inbuf == NULL || *inbuf == NULL)) { if (outbuf == NULL || *outbuf == NULL) result = __gconv (gcd, NULL, NULL, NULL, NULL, &irreversible); diff --git a/iconv/iconv_close.c b/iconv/iconv_close.c index 1bf1793..304b412 100644 --- a/iconv/iconv_close.c +++ b/iconv/iconv_close.c @@ -26,7 +26,7 @@ int iconv_close (iconv_t cd) { - if (__builtin_expect (cd == (iconv_t *) -1L, 0)) + if (__glibc_unlikely (cd == (iconv_t *) -1L)) { __set_errno (EBADF); return -1; diff --git a/iconv/loop.c b/iconv/loop.c index b4af6d4..f836d08 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -241,7 +241,7 @@ /* If any of them recognized the input continue with the loop. */ \ if (result != __GCONV_ILLEGAL_INPUT) \ { \ - if (__builtin_expect (result == __GCONV_FULL_OUTPUT, 0)) \ + if (__glibc_unlikely (result == __GCONV_FULL_OUTPUT)) \ break; \ \ continue; \ @@ -442,7 +442,7 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, bytes from the state and at least one more, or the character is still incomplete, or we have some other error (like illegal input character, no space in output buffer). */ - if (__builtin_expect (inptr != bytebuf, 1)) + if (__glibc_likely (inptr != bytebuf)) { /* We found a new character. */ assert (inptr - bytebuf > (state->__count & 7)); diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 7743216..14318a6 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -410,7 +410,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, /* If the function is called with no input this means we have to reset to the initial state. The possibly partly converted input is dropped. */ - if (__builtin_expect (do_flush, 0)) + if (__glibc_unlikely (do_flush)) { /* This should never happen during error handling. */ assert (outbufstart == NULL); @@ -461,7 +461,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, if (result != __GCONV_EMPTY_INPUT) { - if (__builtin_expect (outerr != outbuf, 0)) + if (__glibc_unlikely (outerr != outbuf)) { /* We have a problem. Undo the conversion. */ outbuf = outstart; @@ -604,7 +604,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, SAVE_RESET_STATE (1); #endif - if (__builtin_expect (!unaligned, 1)) + if (__glibc_likely (!unaligned)) { if (FROM_DIRECTION) /* Run the conversion loop. */ @@ -635,7 +635,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, /* If we were called as part of an error handling module we don't do anything else here. */ - if (__builtin_expect (outbufstart != NULL, 0)) + if (__glibc_unlikely (outbufstart != NULL)) { *outbufstart = outbuf; return status; @@ -653,7 +653,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, /* If this is the last step leave the loop, there is nothing we can do. */ - if (__builtin_expect (data->__flags & __GCONV_IS_LAST, 0)) + if (__glibc_unlikely (data->__flags & __GCONV_IS_LAST)) { /* Store information about how many bytes are available. */ data->__outbuf = outbuf; @@ -666,7 +666,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, } /* Write out all output which was produced. */ - if (__builtin_expect (outbuf > outstart, 1)) + if (__glibc_likely (outbuf > outstart)) { const unsigned char *outerr = data->__outbuf; int result; @@ -677,7 +677,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, if (result != __GCONV_EMPTY_INPUT) { - if (__builtin_expect (outerr != outbuf, 0)) + if (__glibc_unlikely (outerr != outbuf)) { #ifdef RESET_INPUT_BUFFER RESET_INPUT_BUFFER; @@ -695,7 +695,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, SAVE_RESET_STATE (0); # endif - if (__builtin_expect (!unaligned, 1)) + if (__glibc_likely (!unaligned)) { if (FROM_DIRECTION) /* Run the conversion loop. */ @@ -738,7 +738,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, /* If we haven't consumed a single byte decrement the invocation counter. */ - if (__builtin_expect (outbuf == outstart, 0)) + if (__glibc_unlikely (outbuf == outstart)) --data->__invocation_counter; #endif /* reset input buffer */ } diff --git a/iconvdata/8bit-gap.c b/iconvdata/8bit-gap.c index bc21026..b33a6ea 100644 --- a/iconvdata/8bit-gap.c +++ b/iconvdata/8bit-gap.c @@ -88,7 +88,7 @@ struct gap uint32_t ch = get32 (inptr); \ unsigned char res; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ rp = NULL; \ diff --git a/iconvdata/ansi_x3.110.c b/iconvdata/ansi_x3.110.c index 8b490d1..9b67e62 100644 --- a/iconvdata/ansi_x3.110.c +++ b/iconvdata/ansi_x3.110.c @@ -567,7 +567,7 @@ static const char from_ucs4[][2] = /* Now test for a possible second byte and write this if possible. */ \ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ /* The result does not fit into the buffer. */ \ --outptr; \ diff --git a/iconvdata/big5.c b/iconvdata/big5.c index 2a5887b..4c8df8e 100644 --- a/iconvdata/big5.c +++ b/iconvdata/big5.c @@ -8401,7 +8401,7 @@ static const char from_ucs4_tab15[][2] = uint32_t ch2; \ int idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -8426,7 +8426,7 @@ static const char from_ucs4_tab15[][2] = ch = big5_to_ucs[idx]; \ \ /* Is this character defined? */ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ diff --git a/iconvdata/big5hkscs.c b/iconvdata/big5hkscs.c index 90a9bfc..6084bd8 100644 --- a/iconvdata/big5hkscs.c +++ b/iconvdata/big5hkscs.c @@ -17774,7 +17774,7 @@ static struct { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -17787,7 +17787,7 @@ static struct } \ else \ { \ - if (__builtin_expect (outbuf + 2 <= outend, 1)) \ + if (__glibc_likely (outbuf + 2 <= outend)) \ { \ /* Write out the last character. */ \ uint32_t lasttwo = data->__statep->__count >> 3; \ @@ -17814,7 +17814,7 @@ static struct \ /* Determine whether there is a buffered character pending. */ \ ch = *statep >> 3; \ - if (__builtin_expect (ch == 0, 1)) \ + if (__glibc_likely (ch == 0)) \ { \ /* No - so look at the next input byte. */ \ ch = *inptr; \ @@ -17826,7 +17826,7 @@ static struct uint32_t ch2; \ int idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -17887,7 +17887,7 @@ static struct \ inptr += 2; \ } \ - else if (__builtin_expect (ch == 0xff, 0)) \ + else if (__glibc_unlikely (ch == 0xff)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ @@ -17937,7 +17937,7 @@ static struct goto not_combining; \ \ /* Output the combined character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -17950,7 +17950,7 @@ static struct \ not_combining: \ /* Output the buffered character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -17992,7 +17992,7 @@ static struct else \ { \ /* Check for possible combining character. */ \ - if (__builtin_expect (ch == 0xca || ch == 0xea, 0)) \ + if (__glibc_unlikely (ch == 0xca || ch == 0xea)) \ { \ *statep = ((cp[0] << 8) | cp[1]) << 3; \ inptr += 4; \ @@ -18009,7 +18009,7 @@ static struct } \ \ *outptr++ = cp[0]; \ - if (__builtin_expect (cp[1] != '\0', 1)) \ + if (__glibc_likely (cp[1] != '\0')) \ *outptr++ = cp[1]; \ } \ } \ diff --git a/iconvdata/cp1255.c b/iconvdata/cp1255.c index 9a05d30..3106d20 100644 --- a/iconvdata/cp1255.c +++ b/iconvdata/cp1255.c @@ -65,7 +65,7 @@ { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -201,7 +201,7 @@ static const struct { unsigned int idx; unsigned int len; } comp_table[8] = { if (ch >= 0x80) \ { \ ch = to_ucs4[ch - 0x80]; \ - if (__builtin_expect (ch == L'\0', 0)) \ + if (__glibc_unlikely (ch == L'\0')) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -463,7 +463,7 @@ static const struct { res = 0; \ } \ \ - if (__builtin_expect (res != 0, 1)) \ + if (__glibc_likely (res != 0)) \ { \ *outptr++ = res; \ inptr += 4; \ @@ -515,7 +515,7 @@ static const struct { if (decomp_table[i].comb2 < 0) \ { \ /* See whether we have room for two bytes. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -527,7 +527,7 @@ static const struct { else \ { \ /* See whether we have room for three bytes. */ \ - if (__builtin_expect (outptr + 2 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 2 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/cp1258.c b/iconvdata/cp1258.c index bafa28c..6dc13b2 100644 --- a/iconvdata/cp1258.c +++ b/iconvdata/cp1258.c @@ -66,7 +66,7 @@ { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -375,7 +375,7 @@ static const struct if (ch >= 0x80) \ { \ ch = to_ucs4[ch - 0x80]; \ - if (__builtin_expect (ch == L'\0', 0)) \ + if (__glibc_unlikely (ch == L'\0')) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -802,7 +802,7 @@ static const struct res = 0; \ } \ \ - if (__builtin_expect (res != 0, 1)) \ + if (__glibc_likely (res != 0)) \ { \ *outptr++ = res; \ inptr += 4; \ @@ -845,7 +845,7 @@ static const struct } \ \ /* See whether we have room for two bytes. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/cp932.c b/iconvdata/cp932.c index b8269ac..c467aaa 100644 --- a/iconvdata/cp932.c +++ b/iconvdata/cp932.c @@ -4574,7 +4574,7 @@ static const char from_ucs4_extra[229][2] = uint32_t ch2; \ uint_fast32_t idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -4704,7 +4704,7 @@ static const char from_ucs4_extra[229][2] = /* Now test for a possible second byte and write this if possible. */\ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ /* The result does not fit into the buffer. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/iconvdata/euc-cn.c b/iconvdata/euc-cn.c index 0b8a74b..246ef5d 100644 --- a/iconvdata/euc-cn.c +++ b/iconvdata/euc-cn.c @@ -56,7 +56,7 @@ next byte is also available. */ \ const unsigned char *endp; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -67,14 +67,14 @@ ch = inptr[1]; \ \ /* All second bytes of a multibyte character must be >= 0xa1. */ \ - if (__builtin_expect (ch < 0xa1, 0)) \ + if (__glibc_unlikely (ch < 0xa1)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ /* This is code set 1: GB 2312-80. */ \ endp = inptr; \ \ ch = gb2312_to_ucs4 (&endp, 2, 0x80); \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ diff --git a/iconvdata/euc-jisx0213.c b/iconvdata/euc-jisx0213.c index 2737842..ff4e46f 100644 --- a/iconvdata/euc-jisx0213.c +++ b/iconvdata/euc-jisx0213.c @@ -79,7 +79,7 @@ { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -92,7 +92,7 @@ } \ else \ { \ - if (__builtin_expect (outbuf + 2 <= outend, 1)) \ + if (__glibc_likely (outbuf + 2 <= outend)) \ { \ /* Write out the last character. */ \ uint32_t lasttwo = data->__statep->__count >> 3; \ @@ -119,7 +119,7 @@ \ /* Determine whether there is a buffered character pending. */ \ ch = *statep >> 3; \ - if (__builtin_expect (ch == 0, 1)) \ + if (__glibc_likely (ch == 0)) \ { \ /* No - so look at the next input byte. */ \ ch = *inptr; \ @@ -132,7 +132,7 @@ /* Two or three byte character. */ \ uint32_t ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second byte is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -142,7 +142,7 @@ ch2 = inptr[1]; \ \ /* The second byte must be >= 0xa1 and <= 0xfe. */ \ - if (__builtin_expect (ch2 < 0xa1 || ch2 > 0xfe, 0)) \ + if (__glibc_unlikely (ch2 < 0xa1 || ch2 > 0xfe)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -151,7 +151,7 @@ if (ch == 0x8e) \ { \ /* Half-width katakana. */ \ - if (__builtin_expect (ch2 > 0xdf, 0)) \ + if (__glibc_unlikely (ch2 > 0xdf)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ ch = ch2 + 0xfec0; \ @@ -166,7 +166,7 @@ /* JISX 0213 plane 2. */ \ uint32_t ch3; \ \ - if (__builtin_expect (inptr + 2 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 2 >= inend)) \ { \ /* The third byte is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -323,7 +323,7 @@ static const struct if (len > 0) \ { \ /* Output the combined character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -338,7 +338,7 @@ static const struct \ not_combining: \ /* Output the buffered character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -355,7 +355,7 @@ static const struct else if (ch >= 0xff61 && ch <= 0xff9f) \ { \ /* Half-width katakana. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -389,7 +389,7 @@ static const struct if (jch & 0x8000) \ { \ /* JISX 0213 plane 2. */ \ - if (__builtin_expect (outptr + 2 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 2 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -399,7 +399,7 @@ static const struct else \ { \ /* JISX 0213 plane 1. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/euc-jp-ms.c b/iconvdata/euc-jp-ms.c index 5ec40ad..854e301 100644 --- a/iconvdata/euc-jp-ms.c +++ b/iconvdata/euc-jp-ms.c @@ -4673,7 +4673,7 @@ static const unsigned char from_ucs4_extra[229][2] = character is also available. */ \ unsigned char ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -4684,7 +4684,7 @@ static const unsigned char from_ucs4_extra[229][2] = ch2 = (unsigned char)inptr[1]; \ \ /* All second bytes of a multibyte character must be >= 0xa1. */ \ - if (__builtin_expect (ch2 < 0xa1, 0)) \ + if (__glibc_unlikely (ch2 < 0xa1)) \ { \ /* This is an illegal character. */ \ if (! ignore_errors_p ()) \ @@ -4703,7 +4703,7 @@ static const unsigned char from_ucs4_extra[229][2] = /* This is code set 2: half-width katakana. */ \ ch = jisx0201_to_ucs4 (ch2); \ /*if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR)*/ \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ /* Illegal character. */ \ if (! ignore_errors_p ()) \ @@ -4896,15 +4896,15 @@ static const unsigned char from_ucs4_extra[229][2] = /* Now test for a possible second byte and write this if possible. */\ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ /* The result does not fit into the buffer. */ \ result = __GCONV_FULL_OUTPUT; \ break; \ } \ - if (__builtin_expect (cp[1] < 0x80, 0)) \ + if (__glibc_unlikely (cp[1] < 0x80)) \ { \ - if (__builtin_expect (outptr + 2 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 2 >= outend)) \ { \ /* The result does not fit into the buffer. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/iconvdata/euc-jp.c b/iconvdata/euc-jp.c index b903091..a7f2ae3 100644 --- a/iconvdata/euc-jp.c +++ b/iconvdata/euc-jp.c @@ -57,7 +57,7 @@ byte is also available. */ \ int ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second byte is not available. Store the \ intermediate result. */ \ @@ -68,7 +68,7 @@ ch2 = inptr[1]; \ \ /* All second bytes of a multibyte character must be >= 0xa1. */ \ - if (__builtin_expect (ch2 < 0xa1, 0)) \ + if (__glibc_unlikely (ch2 < 0xa1)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ if (ch == 0x8e) \ @@ -105,7 +105,7 @@ result = __GCONV_INCOMPLETE_INPUT; \ break; \ } \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ /* Illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ @@ -151,7 +151,7 @@ size_t found; \ \ /* See whether we have room for at least two characters. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/euc-kr.c b/iconvdata/euc-kr.c index d4f0e00..f14d989 100644 --- a/iconvdata/euc-kr.c +++ b/iconvdata/euc-kr.c @@ -93,13 +93,13 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp) /* Two-byte character. First test whether the next byte \ is also available. */ \ ch = ksc5601_to_ucs4 (&inptr, inend - inptr, 0x80); \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* The second byte is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ } \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ } \ @@ -144,7 +144,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp) /* Now test for a possible second byte and write this if possible. */ \ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ /* The result does not fit into the buffer. */ \ --outptr; \ diff --git a/iconvdata/gb18030.c b/iconvdata/gb18030.c index 4302fbf..4eaa8b5 100644 --- a/iconvdata/gb18030.c +++ b/iconvdata/gb18030.c @@ -24212,7 +24212,7 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] = \ inptr += 4; \ } \ - else if (__builtin_expect (ch2 >= 0x40, 1)) \ + else if (__glibc_likely (ch2 >= 0x40)) \ { \ /* A two-byte character */ \ idx = (ch - 0x81) * 192 + (ch2 - 0x40); \ @@ -24375,7 +24375,7 @@ static const unsigned char __ucs_to_gb18030_tab2[][2] = { \ /* See whether there is enough room for all four bytes we \ write. */ \ - if (__builtin_expect (outptr + 3 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 3 >= outend)) \ { \ /* We have not enough room. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/iconvdata/gbbig5.c b/iconvdata/gbbig5.c index 9a68c5c..1eb1067 100644 --- a/iconvdata/gbbig5.c +++ b/iconvdata/gbbig5.c @@ -4805,7 +4805,7 @@ const char __from_big5_to_gb2312 [13973][2] = const char *cp; \ int idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -4817,7 +4817,7 @@ const char __from_big5_to_gb2312 [13973][2] = ch = inptr[1]; \ \ /* All second bytes of a multibyte character must be >= 0xa1. */ \ - if (__builtin_expect (ch < 0xa1, 0)) \ + if (__glibc_unlikely (ch < 0xa1)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -4827,7 +4827,7 @@ const char __from_big5_to_gb2312 [13973][2] = \ /* Get the value from the table. */ \ cp = __from_gb2312_to_big5[idx]; \ - if (__builtin_expect (cp[0] == '\0', 0)) \ + if (__glibc_unlikely (cp[0] == '\0')) \ { \ /* We do not have a mapping for this character. \ If ignore errors, map it to 0xa1bc - big5 box character */ \ @@ -4836,7 +4836,7 @@ const char __from_big5_to_gb2312 [13973][2] = break; \ \ /* See if there is enough room to write the second byte. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -4894,7 +4894,7 @@ const char __from_big5_to_gb2312 [13973][2] = const char *cp; \ int idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -4918,7 +4918,7 @@ const char __from_big5_to_gb2312 [13973][2] = \ /* Get the value from the table. */ \ cp = __from_big5_to_gb2312 [idx]; \ - if (__builtin_expect (cp[0] == '\0', 0)) \ + if (__glibc_unlikely (cp[0] == '\0')) \ { \ /* We do not have a mapping for this character. \ If ignore errors, map it to 0xa1f5 - gb box character */ \ @@ -4927,7 +4927,7 @@ const char __from_big5_to_gb2312 [13973][2] = break; \ \ /* See if there is enough room to write the second byte. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/gbgbk.c b/iconvdata/gbgbk.c index b870d9d..88f9cd9 100644 --- a/iconvdata/gbgbk.c +++ b/iconvdata/gbgbk.c @@ -73,7 +73,7 @@ UCS4 -> GB2312 -> GBK -> UCS4 \ \ might not produce identical text. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -81,7 +81,7 @@ break; \ } \ \ - if (__builtin_expect (outend - outptr < 2, 0)) \ + if (__glibc_unlikely (outend - outptr < 2)) \ { \ /* We ran out of space. */ \ result = __GCONV_FULL_OUTPUT; \ @@ -91,7 +91,7 @@ ch = (ch << 8) | inptr[1]; \ \ /* Map 0xA844 (U2015 in GBK) to 0xA1AA (U2015 in GB2312). */ \ - if (__builtin_expect (ch == 0xa844, 0)) \ + if (__glibc_unlikely (ch == 0xa844)) \ ch = 0xa1aa; \ \ /* Now determine whether the character is valid. */ \ @@ -134,7 +134,7 @@ \ if (ch > 0x7f) \ { \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -142,7 +142,7 @@ break; \ } \ \ - if (__builtin_expect (outend - outptr < 2, 0)) \ + if (__glibc_unlikely (outend - outptr < 2)) \ { \ /* We ran out of space. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/iconvdata/gbk.c b/iconvdata/gbk.c index 2f7d7fb..05d7eb8 100644 --- a/iconvdata/gbk.c +++ b/iconvdata/gbk.c @@ -13157,7 +13157,7 @@ static const char __gbk_from_ucs4_tab12[][2] = uint32_t ch2; \ int idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c index 373d49a..9de32c5 100644 --- a/iconvdata/ibm1364.c +++ b/iconvdata/ibm1364.c @@ -77,7 +77,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -120,7 +120,7 @@ enum else \ { \ /* This is a combined character. Make sure we have room. */ \ - if (__builtin_expect (outptr + 8 > outend, 0)) \ + if (__glibc_unlikely (outptr + 8 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -204,7 +204,7 @@ enum { \ assert (curcs == db); \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -274,7 +274,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -301,7 +301,7 @@ enum { \ uint32_t ch = get32 (inptr); \ \ - if (__builtin_expect (ch >= UCS_LIMIT, 0)) \ + if (__glibc_unlikely (ch >= UCS_LIMIT)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ @@ -353,7 +353,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -364,13 +364,13 @@ enum } \ else \ { \ - if (__builtin_expect (curcs == db, 0)) \ + if (__glibc_unlikely (curcs == db)) \ { \ /* We know there is room for at least one byte. */ \ *outptr++ = SI; \ curcs = sb; \ \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm930.c b/iconvdata/ibm930.c index 8327690..1c50f1f 100644 --- a/iconvdata/ibm930.c +++ b/iconvdata/ibm930.c @@ -61,7 +61,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -150,7 +150,7 @@ enum \ assert (curcs == db); \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -197,7 +197,7 @@ enum const struct gap *rp2 = __ucs4_to_ibm930db_idx; \ const char *cp; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ @@ -227,7 +227,7 @@ enum { \ if (curcs == sb) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -236,7 +236,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -249,7 +249,7 @@ enum { \ if (curcs == db) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -257,7 +257,7 @@ enum *outptr++ = SI; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm932.c b/iconvdata/ibm932.c index 4ceeaae..cd43619 100644 --- a/iconvdata/ibm932.c +++ b/iconvdata/ibm932.c @@ -64,7 +64,7 @@ if (__builtin_expect (res == 0, 0) && ch != 0) \ { \ /* Use the IBM932 table for double byte. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. \ Store the intermediate result. */ \ @@ -134,7 +134,7 @@ uint32_t high; \ uint16_t pccode; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ rp = NULL; \ @@ -156,7 +156,7 @@ high = (sizeof (__ucs4_to_ibm932db) >> 1) \ / sizeof (__ucs4_to_ibm932db[0][FROM]); \ pccode = ch; \ - if (__builtin_expect (rp != NULL, 1)) \ + if (__glibc_likely (rp != NULL)) \ while (low < high) \ { \ i = (low + high) >> 1; \ @@ -173,7 +173,7 @@ } \ if (found) \ { \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -189,7 +189,7 @@ } \ else \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm933.c b/iconvdata/ibm933.c index 4723df4..149902b 100644 --- a/iconvdata/ibm933.c +++ b/iconvdata/ibm933.c @@ -61,7 +61,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -149,7 +149,7 @@ enum assert (curcs == db); \ \ /* Use the IBM933 table for double byte. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -196,7 +196,7 @@ enum const struct gap *rp2 = __ucs4_to_ibm933db_idx; \ const char *cp; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ @@ -226,7 +226,7 @@ enum { \ if (curcs == sb) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -235,7 +235,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -248,7 +248,7 @@ enum { \ if (curcs == db) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -256,7 +256,7 @@ enum *outptr++ = SI; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm935.c b/iconvdata/ibm935.c index 1ed311b..9a7a862e 100644 --- a/iconvdata/ibm935.c +++ b/iconvdata/ibm935.c @@ -61,7 +61,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -149,7 +149,7 @@ enum assert (curcs == db); \ \ /* Use the IBM935 table for double byte. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. \ Store the intermediate result. */ \ @@ -196,7 +196,7 @@ enum const struct gap *rp2 = __ucs4_to_ibm935db_idx; \ const char *cp; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ @@ -226,7 +226,7 @@ enum { \ if (curcs == sb) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -235,7 +235,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -248,7 +248,7 @@ enum { \ if (curcs == db) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -256,7 +256,7 @@ enum *outptr++ = SI; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm937.c b/iconvdata/ibm937.c index 1edaf62..5a4ab92 100644 --- a/iconvdata/ibm937.c +++ b/iconvdata/ibm937.c @@ -61,7 +61,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -149,7 +149,7 @@ enum assert (curcs == db); \ \ /* Use the IBM937 table for double byte. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. \ Store the intermediate result. */ \ @@ -196,7 +196,7 @@ enum const struct gap *rp2 = __ucs4_to_ibm937db_idx; \ const char *cp; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ @@ -226,7 +226,7 @@ enum { \ if (curcs == sb) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -235,7 +235,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -248,7 +248,7 @@ enum { \ if (curcs == db) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -256,7 +256,7 @@ enum *outptr++ = SI; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm939.c b/iconvdata/ibm939.c index b40c486..b507928 100644 --- a/iconvdata/ibm939.c +++ b/iconvdata/ibm939.c @@ -61,7 +61,7 @@ { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf >= outend, 0)) \ + if (__glibc_unlikely (outbuf >= outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -149,7 +149,7 @@ enum \ assert (curcs == db); \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -196,7 +196,7 @@ enum const struct gap *rp2 = __ucs4_to_ibm939db_idx; \ const char *cp; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ goto ibm939_invalid_char; \ @@ -226,7 +226,7 @@ enum { \ if (curcs == sb) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -235,7 +235,7 @@ enum curcs = db; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -248,7 +248,7 @@ enum { \ if (curcs == db) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -256,7 +256,7 @@ enum *outptr++ = SI; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/ibm943.c b/iconvdata/ibm943.c index 495e379..0ca3327 100644 --- a/iconvdata/ibm943.c +++ b/iconvdata/ibm943.c @@ -65,7 +65,7 @@ __builtin_expect (res == 0, 0) && ch != 0)) \ { \ /* Use the IBM943 table for double byte. */ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. \ Store the intermediate result. */ \ @@ -135,7 +135,7 @@ uint32_t high; \ uint16_t pccode; \ \ - if (__builtin_expect (ch >= 0xffff, 0)) \ + if (__glibc_unlikely (ch >= 0xffff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ rp = NULL; \ @@ -157,7 +157,7 @@ high = (sizeof (__ucs4_to_ibm943db) >> 1) \ / sizeof (__ucs4_to_ibm943db[0][FROM]); \ pccode = ch; \ - if (__builtin_expect (rp != NULL, 1)) \ + if (__glibc_likely (rp != NULL)) \ while (low < high) \ { \ i = (low + high) >> 1; \ @@ -174,7 +174,7 @@ } \ if (found) \ { \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -190,7 +190,7 @@ } \ else \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/iso-2022-cn-ext.c b/iconvdata/iso-2022-cn-ext.c index 64196ac..147f869 100644 --- a/iconvdata/iso-2022-cn-ext.c +++ b/iconvdata/iso-2022-cn-ext.c @@ -137,7 +137,7 @@ enum { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf == outend, 0)) \ + if (__glibc_unlikely (outbuf == outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ diff --git a/iconvdata/iso-2022-cn.c b/iconvdata/iso-2022-cn.c index 0e5a6aa..a282806 100644 --- a/iconvdata/iso-2022-cn.c +++ b/iconvdata/iso-2022-cn.c @@ -88,7 +88,7 @@ enum { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf == outend, 0)) \ + if (__glibc_unlikely (outbuf == outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -121,7 +121,7 @@ enum uint32_t ch = *inptr; \ \ /* This is a 7bit character set, disallow all 8bit characters. */ \ - if (__builtin_expect (ch >= 0x7f, 0)) \ + if (__glibc_unlikely (ch >= 0x7f)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ /* Recognize escape sequences. */ \ @@ -246,7 +246,7 @@ enum { \ *outptr++ = SI; \ set = ASCII_set; \ - if (__builtin_expect (outptr == outend, 0)) \ + if (__glibc_unlikely (outptr == outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -319,7 +319,7 @@ enum { \ const char *escseq; \ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -342,7 +342,7 @@ enum \ if (used == CNS11643_2_set) \ { \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -357,7 +357,7 @@ enum SO charset. */ \ if (set == ASCII_set) \ { \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -368,13 +368,13 @@ enum \ /* Always test the length here since we have used up all the \ guaranteed output buffer slots. */ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ } \ } \ - else if (__builtin_expect (outptr + 2 > outend, 0)) \ + else if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/iso-2022-jp-3.c b/iconvdata/iso-2022-jp-3.c index e90d68a..b676aa1 100644 --- a/iconvdata/iso-2022-jp-3.c +++ b/iconvdata/iso-2022-jp-3.c @@ -96,7 +96,7 @@ enum + ((data->__statep->__count & CURRENT_SEL_MASK) != ASCII_set \ ? 3 : 0); \ \ - if (__builtin_expect (outbuf + need > outend, 0)) \ + if (__glibc_unlikely (outbuf + need > outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -153,7 +153,7 @@ enum uint32_t ch = *inptr; \ \ /* Recognize escape sequences. */ \ - if (__builtin_expect (ch == ESC, 0)) \ + if (__glibc_unlikely (ch == ESC)) \ { \ /* We now must be prepared to read two to three more bytes. \ If we have a match in the first byte but then the input buffer \ @@ -242,7 +242,7 @@ enum { \ /* Use the JIS X 0201 table. */ \ ch = jisx0201_to_ucs4 (ch); \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ @@ -252,7 +252,7 @@ enum { \ /* Use the JIS X 0201 table. */ \ ch = jisx0201_to_ucs4 (ch + 0x80); \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ @@ -266,19 +266,19 @@ enum provide the appropriate tables. */ \ ch = jisx0208_to_ucs4 (&inptr, inend - inptr, 0); \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ } \ - else if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + else if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ } \ else /* (set == JISX0213_1_2004_set || set == JISX0213_2_set) */ \ { \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ @@ -416,7 +416,7 @@ static const struct || (set != JISX0213_1_2000_set && set != JISX0213_1_2004_set) \ ? 4 : 0); \ \ - if (__builtin_expect (outptr + need + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + need + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -444,7 +444,7 @@ static const struct { \ size_t need = (lasttwo >> 16 ? 3 : 0); \ \ - if (__builtin_expect (outptr + need + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + need + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -520,7 +520,7 @@ static const struct inptr += 4; \ continue; \ } \ - if (__builtin_expect (written == 0, 0)) \ + if (__glibc_unlikely (written == 0)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -558,7 +558,7 @@ static const struct continue; \ } \ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -578,7 +578,7 @@ static const struct { \ /* We must encode using ASCII. First write out the escape \ sequence. */ \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -589,7 +589,7 @@ static const struct *outptr++ = 'B'; \ set = ASCII_set; \ \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -606,7 +606,7 @@ static const struct { \ if (set != JISX0201_Roman_set) \ { \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -617,7 +617,7 @@ static const struct set = JISX0201_Roman_set; \ } \ \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -644,7 +644,7 @@ static const struct \ if (set != JISX0208_1983_set) \ { \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -655,7 +655,7 @@ static const struct set = JISX0208_1983_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -677,7 +677,7 @@ static const struct \ if (set != new_set) \ { \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -703,7 +703,7 @@ static const struct continue; \ } \ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -732,7 +732,7 @@ static const struct set = JISX0201_Kana_set; \ } \ \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c index e9d5db4..3428c32 100644 --- a/iconvdata/iso-2022-jp.c +++ b/iconvdata/iso-2022-jp.c @@ -231,7 +231,7 @@ gconv_end (struct __gconv_step *data) { \ /* We are not in the initial state. To switch back we have \ to emit the sequence `Esc ( B'. */ \ - if (__builtin_expect (outbuf + 3 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 3 > outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -404,7 +404,7 @@ gconv_end (struct __gconv_step *data) { \ /* Use the JIS X 0201 table. */ \ ch = jisx0201_to_ucs4 (ch); \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ ++inptr; \ } \ @@ -412,7 +412,7 @@ gconv_end (struct __gconv_step *data) { \ /* Use the JIS X 0201 table. */ \ ch = jisx0201_to_ucs4 (ch + 0x80); \ - if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ ++inptr; \ } \ @@ -438,12 +438,12 @@ gconv_end (struct __gconv_step *data) ch = ksc5601_to_ucs4 (&inptr, inend - inptr, 0); \ } \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ } \ - else if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + else if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ @@ -493,7 +493,7 @@ static const cvlist_t conversion_lists[4] = if (var == iso2022jp2) \ { \ /* Handle Unicode tag characters (range U+E0000..U+E007F). */ \ - if (__builtin_expect ((ch >> 7) == (0xe0000 >> 7), 0)) \ + if (__glibc_unlikely ((ch >> 7) == (0xe0000 >> 7))) \ { \ ch &= 0x7f; \ if (ch >= 'A' && ch <= 'Z') \ @@ -529,7 +529,7 @@ static const cvlist_t conversion_lists[4] = \ /* Non-tag characters reset the tag parsing state, if the current \ state is a temporary state. */ \ - if (__builtin_expect (tag >= TAG_language, 0)) \ + if (__glibc_unlikely (tag >= TAG_language)) \ tag = TAG_none; \ } \ \ @@ -613,7 +613,7 @@ static const cvlist_t conversion_lists[4] = else \ written = __UNKNOWN_10646_CHAR; \ \ - if (__builtin_expect (written == 0, 0)) \ + if (__glibc_unlikely (written == 0)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -629,7 +629,7 @@ static const cvlist_t conversion_lists[4] = { \ if (ch >= 0x80 && ch <= 0xff) \ { \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -643,7 +643,7 @@ static const cvlist_t conversion_lists[4] = } \ else if (set2 == ISO88597_set) \ { \ - if (__builtin_expect (ch < 0xffff, 1)) \ + if (__glibc_likely (ch < 0xffff)) \ { \ const struct gap *rp = from_idx; \ \ @@ -655,7 +655,7 @@ static const cvlist_t conversion_lists[4] = iso88597_from_ucs4[ch - 0xa0 + rp->idx]; \ if (res != '\0') \ { \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -685,7 +685,7 @@ static const cvlist_t conversion_lists[4] = { \ /* We must encode using ASCII. First write out the \ escape sequence. */ \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -696,7 +696,7 @@ static const cvlist_t conversion_lists[4] = *outptr++ = 'B'; \ set = ASCII_set; \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -742,7 +742,7 @@ static const cvlist_t conversion_lists[4] = set2 = ISO88591_set; \ } \ \ - if (__builtin_expect (outptr + 3 > outend, 0)) \ + if (__glibc_unlikely (outptr + 3 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -755,7 +755,7 @@ static const cvlist_t conversion_lists[4] = } \ \ /* Try ISO 8859-7 upper half. */ \ - if (__builtin_expect (ch < 0xffff, 1)) \ + if (__glibc_likely (ch < 0xffff)) \ { \ const struct gap *rp = from_idx; \ \ @@ -817,7 +817,7 @@ static const cvlist_t conversion_lists[4] = set = JISX0201_Roman_set; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -844,7 +844,7 @@ static const cvlist_t conversion_lists[4] = set = JISX0208_1983_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -855,7 +855,7 @@ static const cvlist_t conversion_lists[4] = break; \ } \ \ - if (__builtin_expect (var == iso2022jp, 0)) \ + if (__glibc_unlikely (var == iso2022jp)) \ /* Don't use the other Japanese character sets. */ \ break; \ \ @@ -877,7 +877,7 @@ static const cvlist_t conversion_lists[4] = set = JISX0212_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -910,7 +910,7 @@ static const cvlist_t conversion_lists[4] = set = GB2312_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -944,7 +944,7 @@ static const cvlist_t conversion_lists[4] = set = KSC5601_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ @@ -979,7 +979,7 @@ static const cvlist_t conversion_lists[4] = set = JISX0201_Kana_set; \ } \ \ - if (__builtin_expect (outptr + 1 > outend, 0)) \ + if (__glibc_unlikely (outptr + 1 > outend)) \ { \ res = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/iso-2022-kr.c b/iconvdata/iso-2022-kr.c index 2377ae5..14080c1 100644 --- a/iconvdata/iso-2022-kr.c +++ b/iconvdata/iso-2022-kr.c @@ -86,7 +86,7 @@ enum { \ /* We are not in the initial state. To switch back we have \ to emit `SI'. */ \ - if (__builtin_expect (outbuf == outend, 0)) \ + if (__glibc_unlikely (outbuf == outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ @@ -118,7 +118,7 @@ enum uint32_t ch = *inptr; \ \ /* This is a 7bit character set, disallow all 8bit characters. */ \ - if (__builtin_expect (ch > 0x7f, 0)) \ + if (__glibc_unlikely (ch > 0x7f)) \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ \ /* Recognize escape sequences. */ \ @@ -171,12 +171,12 @@ enum /* Use the KSC 5601 table. */ \ ch = ksc5601_to_ucs4 (&inptr, inend - inptr, 0); \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ result = __GCONV_INCOMPLETE_INPUT; \ break; \ } \ - else if (__builtin_expect (ch == __UNKNOWN_10646_CHAR, 0)) \ + else if (__glibc_unlikely (ch == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ } \ @@ -209,7 +209,7 @@ enum { \ *outptr++ = SI; \ set = ASCII_set; \ - if (__builtin_expect (outptr == outend, 0)) \ + if (__glibc_unlikely (outptr == outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -243,7 +243,7 @@ enum set = KSC5601_set; \ } \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/iso646.c b/iconvdata/iso646.c index 35fe93d..b450fcc 100644 --- a/iconvdata/iso646.c +++ b/iconvdata/iso646.c @@ -870,7 +870,7 @@ gconv_end (struct __gconv_step *data) ch = 0x5d; \ break; \ default: \ - if (__builtin_expect (ch > 0x7f, 0)) \ + if (__glibc_unlikely (ch > 0x7f)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ failure = __GCONV_ILLEGAL_INPUT; \ diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c index 6aa6e35..6610cae 100644 --- a/iconvdata/iso8859-1.c +++ b/iconvdata/iso8859-1.c @@ -50,7 +50,7 @@ #define BODY \ { \ uint32_t ch = *((const uint32_t *) inptr); \ - if (__builtin_expect (ch > 0xff, 0)) \ + if (__glibc_unlikely (ch > 0xff)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ diff --git a/iconvdata/iso_11548-1.c b/iconvdata/iso_11548-1.c index 51aed76..37f55c0 100644 --- a/iconvdata/iso_11548-1.c +++ b/iconvdata/iso_11548-1.c @@ -53,7 +53,7 @@ #define BODY \ { \ uint32_t ch = *((const uint32_t *) inptr); \ - if (__builtin_expect ((ch & 0xffffff00u) != BRAILLE_UCS_BASE, 0)) \ + if (__glibc_unlikely ((ch & 0xffffff00u) != BRAILLE_UCS_BASE)) \ { \ UNICODE_TAG_HANDLER (ch, 4); \ \ diff --git a/iconvdata/iso_6937-2.c b/iconvdata/iso_6937-2.c index d5e09a3..03f0873 100644 --- a/iconvdata/iso_6937-2.c +++ b/iconvdata/iso_6937-2.c @@ -397,7 +397,7 @@ static const char from_ucs4[][2] = is also available. */ \ int ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -416,7 +416,7 @@ static const char from_ucs4[][2] = \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* Illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ @@ -536,7 +536,7 @@ static const char from_ucs4[][2] = /* Now test for a possible second byte and write this if possible. */ \ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ /* The result does not fit into the buffer. */ \ --outptr; \ diff --git a/iconvdata/iso_6937.c b/iconvdata/iso_6937.c index 66d86b1..71a829a 100644 --- a/iconvdata/iso_6937.c +++ b/iconvdata/iso_6937.c @@ -397,7 +397,7 @@ static const char from_ucs4[][2] = is also available. */ \ int ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -416,7 +416,7 @@ static const char from_ucs4[][2] = \ ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* Illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ @@ -520,7 +520,7 @@ static const char from_ucs4[][2] = fail = 1; \ } \ \ - if (__builtin_expect (fail, 0)) \ + if (__glibc_unlikely (fail)) \ { \ /* Illegal characters. */ \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ @@ -538,7 +538,7 @@ static const char from_ucs4[][2] = /* Now test for a possible second byte and write this if possible. */ \ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ /* The result does not fit into the buffer. */ \ --outptr; \ diff --git a/iconvdata/johab.c b/iconvdata/johab.c index fb280a3..07d6b6d 100644 --- a/iconvdata/johab.c +++ b/iconvdata/johab.c @@ -192,7 +192,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) uint32_t ch2; \ uint_fast32_t idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store the \ intermediate result. */ \ @@ -202,7 +202,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) \ ch2 = inptr[1]; \ idx = ch * 256 + ch2; \ - if (__builtin_expect (ch <= 0xd3, 1)) \ + if (__glibc_likely (ch <= 0xd3)) \ { \ /* Hangul */ \ int_fast32_t i, m, f; \ @@ -262,7 +262,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) } \ } \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ @@ -313,7 +313,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) { \ if (ch >= 0xac00 && ch <= 0xd7a3) \ { \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -334,7 +334,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) { \ ch = jamo_from_ucs_table[ch - 0x3131]; \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -355,7 +355,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2) result = __GCONV_FULL_OUTPUT; \ break; \ } \ - if (__builtin_expect (written == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (written == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ diff --git a/iconvdata/shift_jisx0213.c b/iconvdata/shift_jisx0213.c index 94a2d15..a6c19ac 100644 --- a/iconvdata/shift_jisx0213.c +++ b/iconvdata/shift_jisx0213.c @@ -79,7 +79,7 @@ { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -92,7 +92,7 @@ } \ else \ { \ - if (__builtin_expect (outbuf + 2 <= outend, 1)) \ + if (__glibc_likely (outbuf + 2 <= outend)) \ { \ /* Write out the last character. */ \ uint32_t lasttwo = data->__statep->__count >> 3; \ @@ -119,7 +119,7 @@ \ /* Determine whether there is a buffered character pending. */ \ ch = *statep >> 3; \ - if (__builtin_expect (ch == 0, 1)) \ + if (__glibc_likely (ch == 0)) \ { \ /* No - so look at the next input byte. */ \ ch = *inptr; \ @@ -127,9 +127,9 @@ if (ch < 0x80) \ { \ /* Plain ISO646-JP character. */ \ - if (__builtin_expect (ch == 0x5c, 0)) \ + if (__glibc_unlikely (ch == 0x5c)) \ ch = 0xa5; \ - else if (__builtin_expect (ch == 0x7e, 0)) \ + else if (__glibc_unlikely (ch == 0x7e)) \ ch = 0x203e; \ ++inptr; \ } \ @@ -144,7 +144,7 @@ /* Two byte character. */ \ uint32_t ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second byte is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -154,7 +154,7 @@ ch2 = inptr[1]; \ \ /* The second byte must be in the range 0x{40..7E,80..FC}. */ \ - if (__builtin_expect (ch2 < 0x40 || ch2 == 0x7f || ch2 > 0xfc, 0))\ + if (__glibc_unlikely (ch2 < 0x40 || ch2 == 0x7f || ch2 > 0xfc)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -332,7 +332,7 @@ static const struct if (len > 0) \ { \ /* Output the combined character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -347,7 +347,7 @@ static const struct \ not_combining: \ /* Output the buffered character. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -421,7 +421,7 @@ static const struct } \ \ /* Output the shifted representation. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/sjis.c b/iconvdata/sjis.c index 34df564..b0eacd1 100644 --- a/iconvdata/sjis.c +++ b/iconvdata/sjis.c @@ -4361,7 +4361,7 @@ static const char from_ucs4_extra[0x100][2] = uint32_t ch2; \ uint_fast32_t idx; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second byte is not available. Store \ the intermediate result. */ \ @@ -4371,7 +4371,7 @@ static const char from_ucs4_extra[0x100][2] = \ ch2 = inptr[1]; \ idx = ch * 256 + ch2; \ - if (__builtin_expect (ch2 < 0x40, 0)) \ + if (__glibc_unlikely (ch2 < 0x40)) \ { \ /* This is illegal. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ @@ -4398,7 +4398,7 @@ static const char from_ucs4_extra[0x100][2] = else \ ch = cjk_block4[(ch - 0xe0) * 192 + ch2 - 0x40]; \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ @@ -4469,7 +4469,7 @@ static const char from_ucs4_extra[0x100][2] = /* Now test for a possible second byte and write this if possible. */\ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ /* The result does not fit into the buffer. */ \ result = __GCONV_FULL_OUTPUT; \ diff --git a/iconvdata/t.61.c b/iconvdata/t.61.c index e820eb9..e20ff86 100644 --- a/iconvdata/t.61.c +++ b/iconvdata/t.61.c @@ -390,7 +390,7 @@ static const char from_ucs4[][2] = is also available. */ \ uint32_t ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -487,7 +487,7 @@ static const char from_ucs4[][2] = /* Now test for a possible second byte and write this if possible. */ \ if (cp[1] != '\0') \ { \ - if (__builtin_expect (outptr >= outend, 0)) \ + if (__glibc_unlikely (outptr >= outend)) \ { \ /* The result does not fit into the buffer. */ \ --outptr; \ diff --git a/iconvdata/tcvn5712-1.c b/iconvdata/tcvn5712-1.c index 7a3ab45..21e1d45 100644 --- a/iconvdata/tcvn5712-1.c +++ b/iconvdata/tcvn5712-1.c @@ -64,7 +64,7 @@ { \ if (FROM_DIRECTION) \ { \ - if (__builtin_expect (outbuf + 4 <= outend, 1)) \ + if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ *((uint32_t *) outbuf) = data->__statep->__count >> 3; \ @@ -652,7 +652,7 @@ static const struct res = 0; \ } \ \ - if (__builtin_expect (res != 0, 1)) \ + if (__glibc_likely (res != 0)) \ { \ *outptr++ = res; \ inptr += 4; \ @@ -696,7 +696,7 @@ static const struct } \ \ /* See whether we have room for two bytes. */ \ - if (__builtin_expect (outptr + 1 >= outend, 0)) \ + if (__glibc_unlikely (outptr + 1 >= outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/tscii.c b/iconvdata/tscii.c index e8363d1..8b98a0e 100644 --- a/iconvdata/tscii.c +++ b/iconvdata/tscii.c @@ -90,7 +90,7 @@ { \ do \ { \ - if (__builtin_expect (outbuf + 4 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 4 > outend)) \ { \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ @@ -108,10 +108,10 @@ else \ { \ uint32_t last = data->__statep->__count >> 3; \ - if (__builtin_expect (last >> 8, 0)) \ + if (__glibc_unlikely (last >> 8)) \ { \ /* Write out the last character, two bytes. */ \ - if (__builtin_expect (outbuf + 2 <= outend, 1)) \ + if (__glibc_likely (outbuf + 2 <= outend)) \ { \ *outbuf++ = last & 0xff; \ *outbuf++ = (last >> 8) & 0xff; \ @@ -124,7 +124,7 @@ else \ { \ /* Write out the last character, a single byte. */ \ - if (__builtin_expect (outbuf < outend, 1)) \ + if (__glibc_likely (outbuf < outend)) \ { \ *outbuf++ = last & 0xff; \ data->__statep->__count = 0; \ @@ -384,7 +384,7 @@ static const uint32_t tscii_next_state[6] = /* See whether we have room for two characters. Otherwise \ store only the first character now, and put the second \ one into the queue. */ \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = u2 << 8; \ result = __GCONV_FULL_OUTPUT; \ @@ -421,7 +421,7 @@ static const uint32_t tscii_next_state[6] = inptr++; \ put32 (outptr, 0x0BB8); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BCD << 8) + (4 << 4); \ result = __GCONV_FULL_OUTPUT; \ @@ -429,7 +429,7 @@ static const uint32_t tscii_next_state[6] = } \ put32 (outptr, 0x0BCD); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BB0 << 8) + (2 << 4); \ result = __GCONV_FULL_OUTPUT; \ @@ -437,7 +437,7 @@ static const uint32_t tscii_next_state[6] = } \ put32 (outptr, 0x0BB0); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BC0 << 8); \ result = __GCONV_FULL_OUTPUT; \ @@ -454,7 +454,7 @@ static const uint32_t tscii_next_state[6] = inptr++; \ put32 (outptr, 0x0B95); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BCD << 8) + (1 << 4); \ result = __GCONV_FULL_OUTPUT; \ @@ -462,7 +462,7 @@ static const uint32_t tscii_next_state[6] = } \ put32 (outptr, 0x0BCD); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BB7 << 8); \ result = __GCONV_FULL_OUTPUT; \ @@ -479,7 +479,7 @@ static const uint32_t tscii_next_state[6] = inptr++; \ put32 (outptr, 0x0B95); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BCD << 8) + (5 << 4); \ result = __GCONV_FULL_OUTPUT; \ @@ -487,7 +487,7 @@ static const uint32_t tscii_next_state[6] = } \ put32 (outptr, 0x0BCD); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BB7 << 8) + (3 << 4); \ result = __GCONV_FULL_OUTPUT; \ @@ -495,7 +495,7 @@ static const uint32_t tscii_next_state[6] = } \ put32 (outptr, 0x0BB7); \ outptr += 4; \ - if (__builtin_expect (outptr + 4 > outend, 0)) \ + if (__glibc_unlikely (outptr + 4 > outend)) \ { \ *statep = (0x0BCD << 8); \ result = __GCONV_FULL_OUTPUT; \ @@ -592,7 +592,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BC6) \ { \ - if (__builtin_expect (outptr + 2 <= outend, 1)) \ + if (__glibc_likely (outptr + 2 <= outend)) \ { \ *outptr++ = 0xa6; \ *outptr++ = last; \ @@ -608,7 +608,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BC7) \ { \ - if (__builtin_expect (outptr + 2 <= outend, 1)) \ + if (__glibc_likely (outptr + 2 <= outend)) \ { \ *outptr++ = 0xa7; \ *outptr++ = last; \ @@ -624,7 +624,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BC8) \ { \ - if (__builtin_expect (outptr + 2 <= outend, 1)) \ + if (__glibc_likely (outptr + 2 <= outend)) \ { \ *outptr++ = 0xa8; \ *outptr++ = last; \ @@ -640,7 +640,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BCA) \ { \ - if (__builtin_expect (outptr + 3 <= outend, 1)) \ + if (__glibc_likely (outptr + 3 <= outend)) \ { \ *outptr++ = 0xa6; \ *outptr++ = last; \ @@ -657,7 +657,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BCB) \ { \ - if (__builtin_expect (outptr + 3 <= outend, 1)) \ + if (__glibc_likely (outptr + 3 <= outend)) \ { \ *outptr++ = 0xa7; \ *outptr++ = last; \ @@ -674,7 +674,7 @@ static const uint8_t consonant_with_virama[18] = } \ if (ch == 0x0BCC) \ { \ - if (__builtin_expect (outptr + 3 <= outend, 1)) \ + if (__glibc_likely (outptr + 3 <= outend)) \ { \ *outptr++ = 0xa7; \ *outptr++ = last; \ @@ -771,9 +771,9 @@ static const uint8_t consonant_with_virama[18] = } \ \ /* Output the buffered character. */ \ - if (__builtin_expect (last >> 8, 0)) \ + if (__glibc_unlikely (last >> 8)) \ { \ - if (__builtin_expect (outptr + 2 <= outend, 1)) \ + if (__glibc_likely (outptr + 2 <= outend)) \ { \ *outptr++ = last & 0xff; \ *outptr++ = (last >> 8) & 0xff; \ @@ -808,7 +808,7 @@ static const uint8_t consonant_with_virama[18] = else if (ch >= 0x0BCA && ch <= 0x0BCC) \ { \ /* See whether we have room for two bytes. */ \ - if (__builtin_expect (outptr + 2 <= outend, 1)) \ + if (__glibc_likely (outptr + 2 <= outend)) \ { \ *outptr++ = (ch == 0x0BCA ? 0xa6 : 0xa7); \ *outptr++ = (ch != 0x0BCC ? 0xa1 : 0xaa); \ diff --git a/iconvdata/uhc.c b/iconvdata/uhc.c index 4f5e714..318c349 100644 --- a/iconvdata/uhc.c +++ b/iconvdata/uhc.c @@ -3076,7 +3076,7 @@ static const char uhc_hangul_from_ucs[11172][2] = is also available. */ \ uint32_t ch2; \ \ - if (__builtin_expect (inptr + 1 >= inend, 0)) \ + if (__glibc_unlikely (inptr + 1 >= inend)) \ { \ /* The second character is not available. Store \ the intermediate result. */ \ @@ -3123,7 +3123,7 @@ static const char uhc_hangul_from_ucs[11172][2] = ? (ch - 0x81) * 178 \ : 5696 + (ch - 0xa1) * 84)]; \ \ - if (__builtin_expect (ch == 0, 0)) \ + if (__glibc_unlikely (ch == 0)) \ { \ /* This is an illegal character. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (2); \ @@ -3173,7 +3173,7 @@ static const char uhc_hangul_from_ucs[11172][2] = { \ const char *s = uhc_hangul_from_ucs[ch - 0xac00]; \ \ - if (__builtin_expect (outptr + 2 > outend, 0)) \ + if (__glibc_unlikely (outptr + 2 > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -3186,12 +3186,12 @@ static const char uhc_hangul_from_ucs[11172][2] = { \ size_t written = ucs4_to_ksc5601_hanja (ch, outptr, outend - outptr); \ \ - if (__builtin_expect (written == 0, 0)) \ + if (__glibc_unlikely (written == 0)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ } \ - if (__builtin_expect (written == __UNKNOWN_10646_CHAR, 0)) \ + if (__glibc_unlikely (written == __UNKNOWN_10646_CHAR)) \ { \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ @@ -3213,7 +3213,7 @@ static const char uhc_hangul_from_ucs[11172][2] = UNICODE_TAG_HANDLER (ch, 4); \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ - if (__builtin_expect (written == 0, 0)) \ + if (__glibc_unlikely (written == 0)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ diff --git a/iconvdata/unicode.c b/iconvdata/unicode.c index 00d63ef..ed74582 100644 --- a/iconvdata/unicode.c +++ b/iconvdata/unicode.c @@ -64,7 +64,7 @@ else if (!data->__internal_use && data->__invocation_counter == 0) \ { \ /* Emit the Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 2 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put16u (outbuf, BOM); \ @@ -150,12 +150,12 @@ gconv_end (struct __gconv_step *data) { \ uint32_t c = get32 (inptr); \ \ - if (__builtin_expect (c >= 0x10000, 0)) \ + if (__glibc_unlikely (c >= 0x10000)) \ { \ UNICODE_TAG_HANDLER (c, 4); \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ - else if (__builtin_expect (c >= 0xd800 && c < 0xe000, 0)) \ + else if (__glibc_unlikely (c >= 0xd800 && c < 0xe000)) \ { \ /* Surrogate characters in UCS-4 input are not valid. \ We must catch this, because the UCS-2 output might be \ @@ -195,7 +195,7 @@ gconv_end (struct __gconv_step *data) if (swap) \ u1 = bswap_16 (u1); \ \ - if (__builtin_expect (u1 >= 0xd800 && u1 < 0xe000, 0)) \ + if (__glibc_unlikely (u1 >= 0xd800 && u1 < 0xe000)) \ { \ /* Surrogate characters in UCS-2 input are not valid. Reject \ them. (Catching this here is not security relevant.) */ \ diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c index 43be4be..48edfa3 100644 --- a/iconvdata/utf-16.c +++ b/iconvdata/utf-16.c @@ -43,7 +43,7 @@ #define PREPARE_LOOP \ enum direction dir = ((struct utf16_data *) step->__data)->dir; \ enum variant var = ((struct utf16_data *) step->__data)->var; \ - if (__builtin_expect (data->__invocation_counter == 0, 0)) \ + if (__glibc_unlikely (data->__invocation_counter == 0)) \ { \ if (var == UTF_16) \ { \ @@ -67,7 +67,7 @@ else if (!FROM_DIRECTION && !data->__internal_use) \ { \ /* Emit the Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 2 > outend, 0)) \ + if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ put16u (outbuf, BOM); \ @@ -200,7 +200,7 @@ gconv_end (struct __gconv_step *data) { \ uint32_t c = get32 (inptr); \ \ - if (__builtin_expect (c >= 0xd800 && c < 0xe000, 0)) \ + if (__glibc_unlikely (c >= 0xd800 && c < 0xe000)) \ { \ /* Surrogate characters in UCS-4 input are not valid. \ We must catch this. If we let surrogates pass through, \ @@ -216,15 +216,15 @@ gconv_end (struct __gconv_step *data) \ if (swap) \ { \ - if (__builtin_expect (c >= 0x10000, 0)) \ + if (__glibc_unlikely (c >= 0x10000)) \ { \ - if (__builtin_expect (c >= 0x110000, 0)) \ + if (__glibc_unlikely (c >= 0x110000)) \ { \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ \ /* 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; \ @@ -240,15 +240,15 @@ gconv_end (struct __gconv_step *data) } \ else \ { \ - if (__builtin_expect (c >= 0x10000, 0)) \ + if (__glibc_unlikely (c >= 0x10000)) \ { \ - if (__builtin_expect (c >= 0x110000, 0)) \ + if (__glibc_unlikely (c >= 0x110000)) \ { \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ \ /* 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; \ @@ -296,7 +296,7 @@ gconv_end (struct __gconv_step *data) \ /* 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. */ \ @@ -330,7 +330,7 @@ gconv_end (struct __gconv_step *data) { \ /* 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. */ \ diff --git a/iconvdata/utf-32.c b/iconvdata/utf-32.c index f21f2be..7705d47 100644 --- a/iconvdata/utf-32.c +++ b/iconvdata/utf-32.c @@ -44,7 +44,7 @@ int swap; \ if (FROM_DIRECTION && var == UTF_32) \ { \ - if (__builtin_expect (data->__invocation_counter == 0, 0)) \ + if (__glibc_unlikely (data->__invocation_counter == 0)) \ { \ /* We have to find out which byte order the file is encoded in. */ \ if (inptr + 4 > inend) \ @@ -65,7 +65,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); \ @@ -196,11 +196,11 @@ gconv_end (struct __gconv_step *data) { \ uint32_t c = get32 (inptr); \ \ - if (__builtin_expect (c >= 0x110000, 0)) \ + if (__glibc_unlikely (c >= 0x110000)) \ { \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ } \ - else if (__builtin_expect (c >= 0xd800 && c < 0xe000, 0)) \ + else if (__glibc_unlikely (c >= 0xd800 && c < 0xe000)) \ { \ /* Surrogate characters in UCS-4 input are not valid. \ We must catch this. If we let surrogates pass through, \ @@ -238,7 +238,7 @@ gconv_end (struct __gconv_step *data) if (swap) \ u1 = bswap_32 (u1); \ \ - if (__builtin_expect (u1 >= 0x110000, 0)) \ + if (__glibc_unlikely (u1 >= 0x110000)) \ { \ /* This is illegal. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (4); \ diff --git a/iconvdata/utf-7.c b/iconvdata/utf-7.c index 17a9fea..99c255e 100644 --- a/iconvdata/utf-7.c +++ b/iconvdata/utf-7.c @@ -167,9 +167,9 @@ base64 (unsigned int i) put32 (outptr, ch); \ outptr += 4; \ } \ - else if (__builtin_expect (ch == '+', 1)) \ + else if (__glibc_likely (ch == '+')) \ { \ - if (__builtin_expect (inptr + 2 > inend, 0)) \ + if (__glibc_unlikely (inptr + 2 > inend)) \ { \ /* Not enough input available. */ \ result = __GCONV_INCOMPLETE_INPUT; \ @@ -340,7 +340,7 @@ base64 (unsigned int i) else \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ \ - if (__builtin_expect (outptr + count > outend, 0)) \ + if (__glibc_unlikely (outptr + count > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -381,7 +381,7 @@ base64 (unsigned int i) size_t count; \ \ count = ((statep->__count & 0x18) >= 0x10) + isxbase64 (ch) + 1; \ - if (__builtin_expect (outptr + count > outend, 0)) \ + if (__glibc_unlikely (outptr + count > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -405,7 +405,7 @@ base64 (unsigned int i) else \ STANDARD_TO_LOOP_ERR_HANDLER (4); \ \ - if (__builtin_expect (outptr + count > outend, 0)) \ + if (__glibc_unlikely (outptr + count > outend)) \ { \ result = __GCONV_FULL_OUTPUT; \ break; \ @@ -509,7 +509,7 @@ base64 (unsigned int i) /* Deactivate base64 encoding. */ \ size_t count = ((state & 0x18) >= 0x10) + 1; \ \ - if (__builtin_expect (outbuf + count > outend, 0)) \ + if (__glibc_unlikely (outbuf + count > outend)) \ /* We don't have enough room in the output buffer. */ \ status = __GCONV_FULL_OUTPUT; \ else \ diff --git a/include/atomic.h b/include/atomic.h index 5a5319a..3e82b6a 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -375,7 +375,7 @@ do \ { \ __atg11_oldval = *__atg11_memp; \ - if (__builtin_expect (__atg11_oldval <= 0, 0)) \ + if (__glibc_unlikely (__atg11_oldval <= 0)) \ break; \ } \ while (__builtin_expect \ diff --git a/inet/inet6_option.c b/inet/inet6_option.c index a828697..d184ed9 100644 --- a/inet/inet6_option.c +++ b/inet/inet6_option.c @@ -190,7 +190,7 @@ option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy) int dsize = cmsg->cmsg_len - CMSG_LEN (0); /* The first two bytes of the option are for the extended header. */ - if (__builtin_expect (dsize == 0, 0)) + if (__glibc_unlikely (dsize == 0)) { cmsg->cmsg_len += sizeof (struct ip6_ext); dsize = sizeof (struct ip6_ext); diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index 20c37b2..c362496 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -158,12 +158,12 @@ set_binding_values (domainname, dirnamep, codesetp) #else size_t len = strlen (dirname) + 1; result = (char *) malloc (len); - if (__builtin_expect (result != NULL, 1)) + if (__glibc_likely (result != NULL)) memcpy (result, dirname, len); #endif } - if (__builtin_expect (result != NULL, 1)) + if (__glibc_likely (result != NULL)) { if (binding->dirname != _nl_default_dirname) free (binding->dirname); @@ -196,11 +196,11 @@ set_binding_values (domainname, dirnamep, codesetp) #else size_t len = strlen (codeset) + 1; result = (char *) malloc (len); - if (__builtin_expect (result != NULL, 1)) + if (__glibc_likely (result != NULL)) memcpy (result, codeset, len); #endif - if (__builtin_expect (result != NULL, 1)) + if (__glibc_likely (result != NULL)) { free (binding->codeset); @@ -228,7 +228,7 @@ set_binding_values (domainname, dirnamep, codesetp) struct binding *new_binding = (struct binding *) malloc (offsetof (struct binding, domainname) + len); - if (__builtin_expect (new_binding == NULL, 0)) + if (__glibc_unlikely (new_binding == NULL)) goto failed; memcpy (new_binding->domainname, domainname, len); @@ -249,12 +249,12 @@ set_binding_values (domainname, dirnamep, codesetp) char *result; #if defined _LIBC || defined HAVE_STRDUP result = strdup (dirname); - if (__builtin_expect (result == NULL, 0)) + if (__glibc_unlikely (result == NULL)) goto failed_dirname; #else size_t len = strlen (dirname) + 1; result = (char *) malloc (len); - if (__builtin_expect (result == NULL, 0)) + if (__glibc_unlikely (result == NULL)) goto failed_dirname; memcpy (result, dirname, len); #endif @@ -278,12 +278,12 @@ set_binding_values (domainname, dirnamep, codesetp) #if defined _LIBC || defined HAVE_STRDUP result = strdup (codeset); - if (__builtin_expect (result == NULL, 0)) + if (__glibc_unlikely (result == NULL)) goto failed_codeset; #else size_t len = strlen (codeset) + 1; result = (char *) malloc (len); - if (__builtin_expect (result == NULL, 0)) + if (__glibc_unlikely (result == NULL)) goto failed_codeset; memcpy (result, codeset, len); #endif diff --git a/intl/dcigettext.c b/intl/dcigettext.c index f3d97fb..723dd7e 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -640,7 +640,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) /* Resource problems are not fatal, instead we return no translation. */ - if (__builtin_expect (retval == (char *) -1, 0)) + if (__glibc_unlikely (retval == (char *) -1)) goto no_translation; if (retval != NULL) @@ -654,7 +654,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) /* Returning -1 means that some resource problem exists (likely memory) and that the strings could not be converted. Return the original strings. */ - if (__builtin_expect (retval == (char *) -1, 0)) + if (__glibc_unlikely (retval == (char *) -1)) goto no_translation; if (retval != NULL) @@ -904,7 +904,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) realloc (domain->conversions, (nconversions + 1) * sizeof (struct converted_domain)); - if (__builtin_expect (new_conversions == NULL, 0)) + if (__glibc_unlikely (new_conversions == NULL)) { /* Nothing we can do, no more memory. We cannot use the translation because it might be encoded incorrectly. */ @@ -917,7 +917,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) /* Copy the 'encoding' string to permanent storage. */ encoding = strdup (encoding); - if (__builtin_expect (encoding == NULL, 0)) + if (__glibc_unlikely (encoding == NULL)) /* Nothing we can do, no more memory. We cannot use the translation because it might be encoded incorrectly. */ goto unlock_fail; @@ -948,7 +948,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) /* Resource problems are fatal. If we continue onwards we will only attempt to calloc a new conv_tab and fail later. */ - if (__builtin_expect (nullentry == (char *) -1, 0)) + if (__glibc_unlikely (nullentry == (char *) -1)) return (char *) -1; if (nullentry != NULL) @@ -981,12 +981,12 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) charset = norm_add_slashes (charset, ""); int r = __gconv_open (outcharset, charset, &convd->conv, GCONV_AVOID_NOCONV); - if (__builtin_expect (r != __GCONV_OK, 0)) + if (__glibc_unlikely (r != __GCONV_OK)) { /* If the output encoding is the same there is nothing to do. Otherwise do not use the translation at all. */ - if (__builtin_expect (r != __GCONV_NULCONV, 1)) + if (__glibc_likely (r != __GCONV_NULCONV)) { __libc_rwlock_unlock (domain->conversions_lock); free ((char *) encoding); @@ -1053,7 +1053,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) handle this case by converting RESULTLEN bytes, including NULs. */ - if (__builtin_expect (convd->conv_tab == NULL, 0)) + if (__glibc_unlikely (convd->conv_tab == NULL)) { __libc_lock_lock (lock); if (convd->conv_tab == NULL) @@ -1069,7 +1069,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) __libc_lock_unlock (lock); } - if (__builtin_expect (convd->conv_tab == (char **) -1, 0)) + if (__glibc_unlikely (convd->conv_tab == (char **) -1)) /* Nothing we can do, no more memory. We cannot use the translation because it might be encoded incorrectly. */ return (char *) -1; @@ -1190,7 +1190,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) /* Fall through and return -1. */ # endif } - if (__builtin_expect (newmem == NULL, 0)) + if (__glibc_unlikely (newmem == NULL)) { freemem = NULL; freemem_size = 0; diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 18bd501..b96a997 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -829,7 +829,7 @@ _nl_load_domain (domain_file, domainbinding) data = (struct mo_file_header *) mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); - if (__builtin_expect (data != MAP_FAILED, 1)) + if (__glibc_likely (data != MAP_FAILED)) { /* mmap() call was successful. */ close (fd); @@ -1257,7 +1257,7 @@ _nl_load_domain (domain_file, domainbinding) /* Get the header entry and look for a plural specification. */ nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); - if (__builtin_expect (nullentry == (char *) -1, 0)) + if (__glibc_unlikely (nullentry == (char *) -1)) { __libc_rwlock_fini (domain->conversions_lock); goto invalid; diff --git a/intl/localealias.c b/intl/localealias.c index ef826c0..9ab4328 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -293,7 +293,7 @@ read_alias_file (fname, fname_len) *cp++ = '\0'; if (nmap >= maxmap) - if (__builtin_expect (extend_alias_table (), 0)) + if (__glibc_unlikely (extend_alias_table ())) goto out; alias_len = strlen (alias) + 1; @@ -309,7 +309,7 @@ read_alias_file (fname, fname_len) if (new_pool == NULL) goto out; - if (__builtin_expect (string_space != new_pool, 0)) + if (__glibc_unlikely (string_space != new_pool)) { size_t i; diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index 3b66ec6..7900577 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -103,7 +103,7 @@ _IO_file_doallocate (fp) function it points to. This is to make sure _IO_cleanup gets called on exit. We call it from _IO_file_doallocate, since that is likely to get called by any program that does buffered I/O. */ - if (__builtin_expect (_IO_cleanup_registration_needed != NULL, 0)) + if (__glibc_unlikely (_IO_cleanup_registration_needed != NULL)) (*_IO_cleanup_registration_needed) (); #endif diff --git a/libio/fileops.c b/libio/fileops.c index 36bea49..a3499be 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -220,7 +220,7 @@ _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64) { int fdesc; #ifdef _LIBC - if (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)) + if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL)) fdesc = open_not_cancel (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot); else @@ -726,7 +726,7 @@ _IO_file_underflow_mmap (_IO_FILE *fp) if (fp->_IO_read_ptr < fp->_IO_read_end) return *(unsigned char *) fp->_IO_read_ptr; - if (__builtin_expect (mmap_remap_check (fp), 0)) + if (__glibc_unlikely (mmap_remap_check (fp))) /* We punted to the regular file functions. */ return _IO_UNDERFLOW (fp); @@ -836,7 +836,7 @@ _IO_new_file_overflow (f, ch) makes room for subsequent output. Otherwise, set the read pointers to _IO_read_end (leaving that alone, so it can continue to correspond to the external position). */ - if (__builtin_expect (_IO_in_backup (f), 0)) + if (__glibc_unlikely (_IO_in_backup (f))) { size_t nbackup = f->_IO_read_end - f->_IO_read_ptr; _IO_free_backup_area (f); @@ -1464,7 +1464,7 @@ _IO_file_xsgetn_mmap (fp, data, n) if (have < n) { - if (__builtin_expect (_IO_in_backup (fp), 0)) + if (__glibc_unlikely (_IO_in_backup (fp))) { #ifdef _LIBC s = __mempcpy (s, read_ptr, have); @@ -1481,7 +1481,7 @@ _IO_file_xsgetn_mmap (fp, data, n) if (have < n) { /* Check that we are mapping all of the file, in case it grew. */ - if (__builtin_expect (mmap_remap_check (fp), 0)) + if (__glibc_unlikely (mmap_remap_check (fp))) /* We punted mmap, so complete with the vanilla code. */ return s - (char *) data + _IO_XSGETN (fp, data, n); diff --git a/libio/fmemopen.c b/libio/fmemopen.c index e370a8b..aee2696 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -202,7 +202,7 @@ fmemopen (void *buf, size_t len, const char *mode) cookie_io_functions_t iof; fmemopen_cookie_t *c; - if (__builtin_expect (len == 0, 0)) + if (__glibc_unlikely (len == 0)) { einval: __set_errno (EINVAL); @@ -228,7 +228,7 @@ fmemopen (void *buf, size_t len, const char *mode) } else { - if (__builtin_expect ((uintptr_t) len > -(uintptr_t) buf, 0)) + if (__glibc_unlikely ((uintptr_t) len > -(uintptr_t) buf)) { free (c); goto einval; diff --git a/libio/iofgets.c b/libio/iofgets.c index bf7f84a..1b708ca 100644 --- a/libio/iofgets.c +++ b/libio/iofgets.c @@ -39,7 +39,7 @@ _IO_fgets (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; - if (__builtin_expect (n == 1, 0)) + if (__glibc_unlikely (n == 1)) { /* Another irregular case: since we have to store a NUL byte and there is only room for exactly one byte, we don't have to diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c index 128327e..b2d4d8f 100644 --- a/libio/iofgets_u.c +++ b/libio/iofgets_u.c @@ -39,7 +39,7 @@ fgets_unlocked (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; - if (__builtin_expect (n == 1, 0)) + if (__glibc_unlikely (n == 1)) { /* Another irregular case: since we have to store a NUL byte and there is only room for exactly one byte, we don't have to diff --git a/libio/iofgetws.c b/libio/iofgetws.c index 193c1a9..fcbdda8 100644 --- a/libio/iofgetws.c +++ b/libio/iofgetws.c @@ -39,7 +39,7 @@ fgetws (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; - if (__builtin_expect (n == 1, 0)) + if (__glibc_unlikely (n == 1)) { /* Another irregular case: since we have to store a NUL byte and there is only room for exactly one byte, we don't have to diff --git a/libio/iofgetws_u.c b/libio/iofgetws_u.c index 14c4898..1126d7b 100644 --- a/libio/iofgetws_u.c +++ b/libio/iofgetws_u.c @@ -39,7 +39,7 @@ fgetws_unlocked (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; - if (__builtin_expect (n == 1, 0)) + if (__glibc_unlikely (n == 1)) { /* Another irregular case: since we have to store a NUL byte and there is only room for exactly one byte, we don't have to diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c index e2e0b07..a817050 100644 --- a/libio/iogetdelim.c +++ b/libio/iogetdelim.c @@ -89,7 +89,7 @@ _IO_getdelim (lineptr, n, delimiter, fp) t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len); if (t != NULL) len = (t - fp->_IO_read_ptr) + 1; - if (__builtin_expect (len >= SSIZE_MAX - cur_len, 0)) + if (__glibc_unlikely (len >= SSIZE_MAX - cur_len)) { __set_errno (EOVERFLOW); result = -1; diff --git a/libio/wfileops.c b/libio/wfileops.c index 877fc1f..9cebe77 100644 --- a/libio/wfileops.c +++ b/libio/wfileops.c @@ -123,7 +123,7 @@ _IO_wfile_underflow (fp) enum __codecvt_result status; _IO_ssize_t count; - if (__builtin_expect (fp->_flags & _IO_NO_READS, 0)) + if (__glibc_unlikely (fp->_flags & _IO_NO_READS)) { fp->_flags |= _IO_ERR_SEEN; __set_errno (EBADF); @@ -264,7 +264,7 @@ _IO_wfile_underflow (fp) const char *from = fp->_IO_read_ptr; const char *to = fp->_IO_read_end; size_t to_copy = count; - if (__builtin_expect (naccbuf != 0, 0)) + if (__glibc_unlikely (naccbuf != 0)) { to_copy = MIN (sizeof (accbuf) - naccbuf, count); to = __mempcpy (&accbuf[naccbuf], from, to_copy); @@ -277,7 +277,7 @@ _IO_wfile_underflow (fp) fp->_wide_data->_IO_buf_end, &fp->_wide_data->_IO_read_end); - if (__builtin_expect (naccbuf != 0, 0)) + if (__glibc_unlikely (naccbuf != 0)) fp->_IO_read_ptr += MAX (0, read_ptr_copy - &accbuf[naccbuf - to_copy]); else fp->_IO_read_ptr = (char *) read_ptr_copy; @@ -341,7 +341,7 @@ _IO_wfile_underflow_mmap (_IO_FILE *fp) struct _IO_codecvt *cd; const char *read_stop; - if (__builtin_expect (fp->_flags & _IO_NO_READS, 0)) + if (__glibc_unlikely (fp->_flags & _IO_NO_READS)) { fp->_flags |= _IO_ERR_SEEN; __set_errno (EBADF); @@ -581,7 +581,7 @@ adjust_wide_data (_IO_FILE *fp, bool do_convert) &fp->_wide_data->_IO_read_end); /* Should we return EILSEQ? */ - if (__builtin_expect (status == __codecvt_error, 0)) + if (__glibc_unlikely (status == __codecvt_error)) { fp->_flags |= _IO_ERR_SEEN; return -1; @@ -755,7 +755,7 @@ _IO_wfile_seekoff (fp, offset, dir, mode) /* If there was an error, then return WEOF. TODO: set buffer state. */ - if (__builtin_expect (status == __codecvt_error, 0)) + if (__glibc_unlikely (status == __codecvt_error)) return WEOF; } while (delta > 0); diff --git a/locale/findlocale.c b/locale/findlocale.c index 0c42b99..bbaf708 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -101,11 +101,11 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* We really have to load some data. First we try the archive, but only if there was no LOCPATH environment variable specified. */ - if (__builtin_expect (locale_path == NULL, 1)) + if (__glibc_likely (locale_path == NULL)) { struct __locale_data *data = _nl_load_locale_from_archive (category, name); - if (__builtin_expect (data != NULL, 1)) + if (__glibc_likely (data != NULL)) return data; /* Nothing in the archive. Set the default path to search below. */ diff --git a/locale/loadarchive.c b/locale/loadarchive.c index e14535e..22ac90d 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -263,7 +263,7 @@ _nl_load_locale_from_archive (int category, const char **namep) } /* If there is no archive or it cannot be loaded for some reason fail. */ - if (__builtin_expect (headmap.ptr == NULL, 0)) + if (__glibc_unlikely (headmap.ptr == NULL)) goto close_and_out; /* We have the archive available. To find the name we first have to @@ -459,11 +459,11 @@ _nl_load_locale_from_archive (int category, const char **namep) Now we need the expected data structures to point into the data. */ lia = malloc (sizeof *lia); - if (__builtin_expect (lia == NULL, 0)) + if (__glibc_unlikely (lia == NULL)) return NULL; lia->name = strdup (*namep); - if (__builtin_expect (lia->name == NULL, 0)) + if (__glibc_unlikely (lia->name == NULL)) { free (lia); return NULL; @@ -478,7 +478,7 @@ _nl_load_locale_from_archive (int category, const char **namep) lia->data[cnt] = _nl_intern_locale_data (cnt, results[cnt].addr, results[cnt].len); - if (__builtin_expect (lia->data[cnt] != NULL, 1)) + if (__glibc_likely (lia->data[cnt] != NULL)) { /* _nl_intern_locale_data leaves us these fields to initialize. */ lia->data[cnt]->alloc = ld_archive; diff --git a/locale/loadlocale.c b/locale/loadlocale.c index f926036..13eecea 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -107,7 +107,7 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize) for (cnt = 0; cnt < newdata->nstrings; ++cnt) { size_t idx = filedata->strindex[cnt]; - if (__builtin_expect (idx > (size_t) newdata->filesize, 0)) + if (__glibc_unlikely (idx > (size_t) newdata->filesize)) { puntdata: free (newdata); @@ -183,7 +183,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) close_not_cancel_no_status (fd); return; } - if (__builtin_expect (S_ISDIR (st.st_mode), 0)) + if (__glibc_unlikely (S_ISDIR (st.st_mode))) { /* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo instead. */ @@ -221,7 +221,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) # endif filedata = __mmap ((caddr_t) 0, st.st_size, PROT_READ, MAP_FILE|MAP_COPY, fd, 0); - if (__builtin_expect (filedata == MAP_FAILED, 0)) + if (__glibc_unlikely (filedata == MAP_FAILED)) { filedata = NULL; if (__builtin_expect (errno, ENOSYS) == ENOSYS) @@ -258,12 +258,12 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) /* We have mapped the data, so we no longer need the descriptor. */ close_not_cancel_no_status (fd); - if (__builtin_expect (filedata == NULL, 0)) + if (__glibc_unlikely (filedata == NULL)) /* We failed to map or read the data. */ return; newdata = _nl_intern_locale_data (category, filedata, st.st_size); - if (__builtin_expect (newdata == NULL, 0)) + if (__glibc_unlikely (newdata == NULL)) /* Bad data. */ { #ifdef _POSIX_MAPPED_FILES diff --git a/locale/setlocale.c b/locale/setlocale.c index b70fa6c..9458468 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -278,7 +278,7 @@ setlocale (int category, const char *locale) if (category != LC_ALL) newnames[category] = (char *) locale; - if (__builtin_expect (strchr (locale, ';') != NULL, 0)) + if (__glibc_unlikely (strchr (locale, ';') != NULL)) { /* This is a composite name. Make a copy and split it up. */ char *np = strdupa (locale); diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c index f33f603..55f1027 100644 --- a/login/programs/pt_chown.c +++ b/login/programs/pt_chown.c @@ -170,7 +170,7 @@ main (int argc, char *argv[]) cap_free (caps); - if (__builtin_expect (res != 0, 0)) + if (__glibc_unlikely (res != 0)) return FAIL_EXEC; } #endif diff --git a/malloc/arena.c b/malloc/arena.c index 71678a9..60ae9a4 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -376,7 +376,7 @@ ptmalloc_init (void) tsd_setspecific (arena_key, (void *) &main_arena); thread_atfork (ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2); const char *s = NULL; - if (__builtin_expect (_environ != NULL, 1)) + if (__glibc_likely (_environ != NULL)) { char **runp = _environ; char *envline; @@ -624,7 +624,7 @@ shrink_heap (heap_info *h, long diff) /* Try to re-map the extra heap space freshly to save memory, and make it inaccessible. See malloc-sysdep.h to know when this is true. */ - if (__builtin_expect (check_may_shrink_heap (), 0)) + if (__glibc_unlikely (check_may_shrink_heap ())) { if ((char *) MMAP ((char *) h + new_size, diff, PROT_NONE, MAP_FIXED) == (char *) MAP_FAILED) @@ -863,12 +863,12 @@ arena_get2 (mstate a_tsd, size_t size, mstate avoid_arena) narenas_limit is 0. There is no possibility for narenas to be too big for the test to always fail since there is not enough address space to create that many arenas. */ - if (__builtin_expect (n <= narenas_limit - 1, 0)) + if (__glibc_unlikely (n <= narenas_limit - 1)) { if (catomic_compare_and_exchange_bool_acq (&narenas, n + 1, n)) goto repeat; a = _int_new_arena (size); - if (__builtin_expect (a == NULL, 0)) + if (__glibc_unlikely (a == NULL)) catomic_decrement (&narenas); } else diff --git a/malloc/malloc.c b/malloc/malloc.c index 4f20999..9a45707 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3368,7 +3368,7 @@ _int_malloc (mstate av, size_t bytes) else { bck = victim->bk; - if (__builtin_expect (bck->fd != victim, 0)) + if (__glibc_unlikely (bck->fd != victim)) { errstr = "malloc(): smallbin double linked list corrupted"; goto errout; @@ -3591,7 +3591,7 @@ _int_malloc (mstate av, size_t bytes) have to perform a complete insert here. */ bck = unsorted_chunks (av); fwd = bck->fd; - if (__builtin_expect (fwd->bk != bck, 0)) + if (__glibc_unlikely (fwd->bk != bck)) { errstr = "malloc(): corrupted unsorted chunks"; goto errout; @@ -3698,7 +3698,7 @@ _int_malloc (mstate av, size_t bytes) have to perform a complete insert here. */ bck = unsorted_chunks (av); fwd = bck->fd; - if (__builtin_expect (fwd->bk != bck, 0)) + if (__glibc_unlikely (fwd->bk != bck)) { errstr = "malloc(): corrupted unsorted chunks 2"; goto errout; @@ -3824,7 +3824,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) } /* We know that each chunk is at least MINSIZE bytes in size or a multiple of MALLOC_ALIGNMENT. */ - if (__builtin_expect (size < MINSIZE || !aligned_OK (size), 0)) + if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) { errstr = "free(): invalid size"; goto errout; @@ -3922,7 +3922,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) /* Lightweight tests: check whether the block is already the top block. */ - if (__builtin_expect (p == av->top, 0)) + if (__glibc_unlikely (p == av->top)) { errstr = "double free or corruption (top)"; goto errout; @@ -3936,7 +3936,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) goto errout; } /* Or whether the block is actually not marked used. */ - if (__builtin_expect (!prev_inuse(nextchunk), 0)) + if (__glibc_unlikely (!prev_inuse(nextchunk))) { errstr = "double free or corruption (!prev)"; goto errout; @@ -3979,7 +3979,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) bck = unsorted_chunks(av); fwd = bck->fd; - if (__builtin_expect (fwd->bk != bck, 0)) + if (__glibc_unlikely (fwd->bk != bck)) { errstr = "free(): corrupted unsorted chunks"; goto errout; diff --git a/malloc/memusage.c b/malloc/memusage.c index bfbaecc..bd8bcd9 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -137,20 +137,20 @@ update_data (struct header *result, size_t len, size_t old_len) value. The base stack pointer might not be set if this is not the main thread and it is the first call to any of these functions. */ - if (__builtin_expect (!start_sp, 0)) + if (__glibc_unlikely (!start_sp)) start_sp = GETSP (); uintptr_t sp = GETSP (); #ifdef STACK_GROWS_UPWARD /* This can happen in threads where we didn't catch the thread's stack early enough. */ - if (__builtin_expect (sp < start_sp, 0)) + if (__glibc_unlikely (sp < start_sp)) start_sp = sp; size_t current_stack = sp - start_sp; #else /* This can happen in threads where we didn't catch the thread's stack early enough. */ - if (__builtin_expect (sp > start_sp, 0)) + if (__glibc_unlikely (sp > start_sp)) start_sp = sp; size_t current_stack = start_sp - sp; #endif @@ -330,7 +330,7 @@ malloc (size_t len) struct header *result = NULL; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -382,7 +382,7 @@ realloc (void *old, size_t len) size_t old_len; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -476,7 +476,7 @@ calloc (size_t n, size_t len) size_t size = n * len; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -526,7 +526,7 @@ free (void *ptr) struct header *real; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return; @@ -578,7 +578,7 @@ mmap (void *start, size_t len, int prot, int flags, int fd, off_t offset) void *result = NULL; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -631,7 +631,7 @@ mmap64 (void *start, size_t len, int prot, int flags, int fd, off64_t offset) void *result = NULL; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -689,7 +689,7 @@ mremap (void *start, size_t old_len, size_t len, int flags, ...) va_end (ap); /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return NULL; @@ -750,7 +750,7 @@ munmap (void *start, size_t len) int result; /* Determine real implementation if not already happened. */ - if (__builtin_expect (initialized <= 0, 0)) + if (__glibc_unlikely (initialized <= 0)) { if (initialized == -1) return -1; @@ -766,7 +766,7 @@ munmap (void *start, size_t len) /* Keep track of number of calls. */ catomic_increment (&calls[idx_munmap]); - if (__builtin_expect (result == 0, 1)) + if (__glibc_likely (result == 0)) { /* Keep track of total memory freed using `free'. */ catomic_add (&total[idx_munmap], len); diff --git a/math/e_exp2l.c b/math/e_exp2l.c index 0bea772..c0edfbe 100644 --- a/math/e_exp2l.c +++ b/math/e_exp2l.c @@ -23,7 +23,7 @@ long double __ieee754_exp2l (long double x) { - if (__builtin_expect (isless (x, (long double) LDBL_MAX_EXP), 1)) + if (__glibc_likely (isless (x, (long double) LDBL_MAX_EXP))) { if (__builtin_expect (isgreaterequal (x, (long double) (LDBL_MIN_EXP - LDBL_MANT_DIG diff --git a/math/e_scalb.c b/math/e_scalb.c index 487f441..bddedfa 100644 --- a/math/e_scalb.c +++ b/math/e_scalb.c @@ -40,9 +40,9 @@ invalid_fn (double x, double fn) double __ieee754_scalb (double x, double fn) { - if (__builtin_expect (__isnan (x), 0)) + if (__glibc_unlikely (__isnan (x))) return x * fn; - if (__builtin_expect (!__finite (fn), 0)) + if (__glibc_unlikely (!__finite (fn))) { if (__isnan (fn) || fn > 0.0) return x * fn; @@ -50,7 +50,7 @@ __ieee754_scalb (double x, double fn) return x; return x / -fn; } - if (__builtin_expect ((double) (int) fn != fn, 0)) + if (__glibc_unlikely ((double) (int) fn != fn)) return invalid_fn (x, fn); return __scalbn (x, (int) fn); diff --git a/math/e_scalbf.c b/math/e_scalbf.c index 68e6c5f..319752c 100644 --- a/math/e_scalbf.c +++ b/math/e_scalbf.c @@ -40,9 +40,9 @@ invalid_fn (float x, float fn) float __ieee754_scalbf (float x, float fn) { - if (__builtin_expect (__isnanf (x), 0)) + if (__glibc_unlikely (__isnanf (x))) return x * fn; - if (__builtin_expect (!__finitef (fn), 0)) + if (__glibc_unlikely (!__finitef (fn))) { if (__isnanf (fn) || fn > 0.0f) return x * fn; @@ -50,7 +50,7 @@ __ieee754_scalbf (float x, float fn) return x; return x / -fn; } - if (__builtin_expect ((float) (int) fn != fn, 0)) + if (__glibc_unlikely ((float) (int) fn != fn)) return invalid_fn (x, fn); return __scalbnf (x, (int) fn); diff --git a/math/e_scalbl.c b/math/e_scalbl.c index 256e7b1..5815a0d 100644 --- a/math/e_scalbl.c +++ b/math/e_scalbl.c @@ -40,9 +40,9 @@ invalid_fn (long double x, long double fn) long double __ieee754_scalbl (long double x, long double fn) { - if (__builtin_expect (__isnanl (x), 0)) + if (__glibc_unlikely (__isnanl (x))) return x * fn; - if (__builtin_expect (!__finitel (fn), 0)) + if (__glibc_unlikely (!__finitel (fn))) { if (__isnanl (fn) || fn > 0.0L) return x * fn; @@ -50,7 +50,7 @@ __ieee754_scalbl (long double x, long double fn) return x; return x / -fn; } - if (__builtin_expect ((long double) (int) fn != fn, 0)) + if (__glibc_unlikely ((long double) (int) fn != fn)) return invalid_fn (x, fn); return __scalbnl (x, (int) fn); diff --git a/math/s_catan.c b/math/s_catan.c index 87cdd31..d6552d8 100644 --- a/math/s_catan.c +++ b/math/s_catan.c @@ -29,7 +29,7 @@ __catan (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (rcls == FP_INFINITE) { @@ -55,7 +55,7 @@ __catan (__complex__ double x) __imag__ res = __nan (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_catanf.c b/math/s_catanf.c index 80a3474..41e419d 100644 --- a/math/s_catanf.c +++ b/math/s_catanf.c @@ -29,7 +29,7 @@ __catanf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (rcls == FP_INFINITE) { @@ -55,7 +55,7 @@ __catanf (__complex__ float x) __imag__ res = __nanf (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_catanh.c b/math/s_catanh.c index 0c8b268..2ba1298 100644 --- a/math/s_catanh.c +++ b/math/s_catanh.c @@ -29,7 +29,7 @@ __catanh (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -50,7 +50,7 @@ __catanh (__complex__ double x) __imag__ res = __nan (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_catanhf.c b/math/s_catanhf.c index ebb7b82..0ee69a5 100644 --- a/math/s_catanhf.c +++ b/math/s_catanhf.c @@ -29,7 +29,7 @@ __catanhf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -50,7 +50,7 @@ __catanhf (__complex__ float x) __imag__ res = __nanf (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_catanhl.c b/math/s_catanhl.c index d45f1d1..537bb3e 100644 --- a/math/s_catanhl.c +++ b/math/s_catanhl.c @@ -36,7 +36,7 @@ __catanhl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -57,7 +57,7 @@ __catanhl (__complex__ long double x) __imag__ res = __nanl (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_catanl.c b/math/s_catanl.c index 32a4424..cea9282 100644 --- a/math/s_catanl.c +++ b/math/s_catanl.c @@ -36,7 +36,7 @@ __catanl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (rcls == FP_INFINITE) { @@ -62,7 +62,7 @@ __catanl (__complex__ long double x) __imag__ res = __nanl (""); } } - else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } diff --git a/math/s_ccosh.c b/math/s_ccosh.c index 3ee40b1..a3b9327 100644 --- a/math/s_ccosh.c +++ b/math/s_ccosh.c @@ -30,16 +30,16 @@ __ccosh (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } @@ -108,12 +108,12 @@ __ccosh (__complex__ double x) else if (rcls == FP_INFINITE) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c index 4a9e94d..084fc6d 100644 --- a/math/s_ccoshf.c +++ b/math/s_ccoshf.c @@ -30,16 +30,16 @@ __ccoshf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2); float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } @@ -105,15 +105,15 @@ __ccoshf (__complex__ float x) feraiseexcept (FE_INVALID); } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } diff --git a/math/s_ccoshl.c b/math/s_ccoshl.c index bb79aad..e958c49 100644 --- a/math/s_ccoshl.c +++ b/math/s_ccoshl.c @@ -30,16 +30,16 @@ __ccoshl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } @@ -105,15 +105,15 @@ __ccoshl (__complex__ long double x) feraiseexcept (FE_INVALID); } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } diff --git a/math/s_cexp.c b/math/s_cexp.c index dcb3228..a636e35 100644 --- a/math/s_cexp.c +++ b/math/s_cexp.c @@ -30,16 +30,16 @@ __cexp (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } @@ -97,10 +97,10 @@ __cexp (__complex__ double x) feraiseexcept (FE_INVALID); } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ double value = signbit (__real__ x) ? 0.0 : HUGE_VAL; @@ -115,7 +115,7 @@ __cexp (__complex__ double x) { double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } diff --git a/math/s_cexpf.c b/math/s_cexpf.c index 8bfc7e2..d0cdf79 100644 --- a/math/s_cexpf.c +++ b/math/s_cexpf.c @@ -30,16 +30,16 @@ __cexpf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2); float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } @@ -97,10 +97,10 @@ __cexpf (__complex__ float x) feraiseexcept (FE_INVALID); } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ float value = signbit (__real__ x) ? 0.0 : HUGE_VALF; @@ -115,7 +115,7 @@ __cexpf (__complex__ float x) { float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } diff --git a/math/s_cexpl.c b/math/s_cexpl.c index bd5572d..3b64fd1 100644 --- a/math/s_cexpl.c +++ b/math/s_cexpl.c @@ -30,16 +30,16 @@ __cexpl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } @@ -97,10 +97,10 @@ __cexpl (__complex__ long double x) feraiseexcept (FE_INVALID); } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL; @@ -115,7 +115,7 @@ __cexpl (__complex__ long double x) { long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } diff --git a/math/s_clog.c b/math/s_clog.c index e2b5846..8639868 100644 --- a/math/s_clog.c +++ b/math/s_clog.c @@ -29,7 +29,7 @@ __clog (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; @@ -37,7 +37,7 @@ __clog (__complex__ double x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ double absx = fabs (__real__ x), absy = fabs (__imag__ x); diff --git a/math/s_clog10.c b/math/s_clog10.c index 0274db3..417d561 100644 --- a/math/s_clog10.c +++ b/math/s_clog10.c @@ -32,7 +32,7 @@ __clog10 (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; @@ -40,7 +40,7 @@ __clog10 (__complex__ double x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ double absx = fabs (__real__ x), absy = fabs (__imag__ x); diff --git a/math/s_clog10f.c b/math/s_clog10f.c index dc676b2..a9120e0 100644 --- a/math/s_clog10f.c +++ b/math/s_clog10f.c @@ -32,7 +32,7 @@ __clog10f (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; @@ -40,7 +40,7 @@ __clog10f (__complex__ float x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsf (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ float absx = fabsf (__real__ x), absy = fabsf (__imag__ x); diff --git a/math/s_clog10l.c b/math/s_clog10l.c index f7c3ec4..ac33a8f 100644 --- a/math/s_clog10l.c +++ b/math/s_clog10l.c @@ -39,7 +39,7 @@ __clog10l (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PIl : 0.0; @@ -47,7 +47,7 @@ __clog10l (__complex__ long double x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsl (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x); diff --git a/math/s_clogf.c b/math/s_clogf.c index 73c2928..79117df 100644 --- a/math/s_clogf.c +++ b/math/s_clogf.c @@ -29,7 +29,7 @@ __clogf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; @@ -37,7 +37,7 @@ __clogf (__complex__ float x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsf (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ float absx = fabsf (__real__ x), absy = fabsf (__imag__ x); diff --git a/math/s_clogl.c b/math/s_clogl.c index ec2ff84..bdf82c1 100644 --- a/math/s_clogl.c +++ b/math/s_clogl.c @@ -36,7 +36,7 @@ __clogl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) + if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PIl : 0.0; @@ -44,7 +44,7 @@ __clogl (__complex__ long double x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabsl (__real__ x); } - else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) + else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x); diff --git a/math/s_csin.c b/math/s_csin.c index 48a4a90..b4c8a1b 100644 --- a/math/s_csin.c +++ b/math/s_csin.c @@ -33,16 +33,16 @@ __csin (__complex__ double x) __real__ x = fabs (__real__ x); - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); double sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincos (__real__ x, &sinix, &cosix); } @@ -136,7 +136,7 @@ __csin (__complex__ double x) /* Real part is finite. */ double sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincos (__real__ x, &sinix, &cosix); } diff --git a/math/s_csinf.c b/math/s_csinf.c index 26c4bb0..1faefd1 100644 --- a/math/s_csinf.c +++ b/math/s_csinf.c @@ -33,16 +33,16 @@ __csinf (__complex__ float x) __real__ x = fabsf (__real__ x); - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2); float sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincosf (__real__ x, &sinix, &cosix); } @@ -136,7 +136,7 @@ __csinf (__complex__ float x) /* Real part is finite. */ float sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincosf (__real__ x, &sinix, &cosix); } diff --git a/math/s_csinh.c b/math/s_csinh.c index 3fc737b..428add6 100644 --- a/math/s_csinh.c +++ b/math/s_csinh.c @@ -33,16 +33,16 @@ __csinh (__complex__ double x) __real__ x = fabs (__real__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } @@ -125,12 +125,12 @@ __csinh (__complex__ double x) else if (rcls == FP_INFINITE) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } diff --git a/math/s_csinhf.c b/math/s_csinhf.c index 081c759..d31f705 100644 --- a/math/s_csinhf.c +++ b/math/s_csinhf.c @@ -33,16 +33,16 @@ __csinhf (__complex__ float x) __real__ x = fabsf (__real__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2); float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } @@ -122,15 +122,15 @@ __csinhf (__complex__ float x) } } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ float sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } diff --git a/math/s_csinhl.c b/math/s_csinhl.c index 3c4ba0d..c6e58f1 100644 --- a/math/s_csinhl.c +++ b/math/s_csinhl.c @@ -33,16 +33,16 @@ __csinhl (__complex__ long double x) __real__ x = fabsl (__real__ x); - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } @@ -122,15 +122,15 @@ __csinhl (__complex__ long double x) } } } - else if (__builtin_expect (rcls == FP_INFINITE, 1)) + else if (__glibc_likely (rcls == FP_INFINITE)) { /* Real part is infinite. */ - if (__builtin_expect (icls > FP_ZERO, 1)) + if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ long double sinix, cosix; - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } diff --git a/math/s_csinl.c b/math/s_csinl.c index 5ae8969..a3316d3 100644 --- a/math/s_csinl.c +++ b/math/s_csinl.c @@ -33,16 +33,16 @@ __csinl (__complex__ long double x) __real__ x = fabsl (__real__ x); - if (__builtin_expect (icls >= FP_ZERO, 1)) + if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ - if (__builtin_expect (rcls >= FP_ZERO, 1)) + if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincosl (__real__ x, &sinix, &cosix); } @@ -136,7 +136,7 @@ __csinl (__complex__ long double x) /* Real part is finite. */ long double sinix, cosix; - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincosl (__real__ x, &sinix, &cosix); } diff --git a/math/s_csqrt.c b/math/s_csqrt.c index 2bbd2b8..a19bb34 100644 --- a/math/s_csqrt.c +++ b/math/s_csqrt.c @@ -30,7 +30,7 @@ __csqrt (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -59,7 +59,7 @@ __csqrt (__complex__ double x) } else { - if (__builtin_expect (icls == FP_ZERO, 0)) + if (__glibc_unlikely (icls == FP_ZERO)) { if (__real__ x < 0.0) { @@ -73,7 +73,7 @@ __csqrt (__complex__ double x) __imag__ res = __copysign (0.0, __imag__ x); } } - else if (__builtin_expect (rcls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO)) { double r; if (fabs (__imag__ x) >= 2.0 * DBL_MIN) diff --git a/math/s_csqrtf.c b/math/s_csqrtf.c index b2a11de..1c22df8 100644 --- a/math/s_csqrtf.c +++ b/math/s_csqrtf.c @@ -30,7 +30,7 @@ __csqrtf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -59,7 +59,7 @@ __csqrtf (__complex__ float x) } else { - if (__builtin_expect (icls == FP_ZERO, 0)) + if (__glibc_unlikely (icls == FP_ZERO)) { if (__real__ x < 0.0) { @@ -73,7 +73,7 @@ __csqrtf (__complex__ float x) __imag__ res = __copysignf (0.0, __imag__ x); } } - else if (__builtin_expect (rcls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO)) { float r; if (fabsf (__imag__ x) >= 2.0f * FLT_MIN) diff --git a/math/s_csqrtl.c b/math/s_csqrtl.c index a72bac1..2dab3db 100644 --- a/math/s_csqrtl.c +++ b/math/s_csqrtl.c @@ -30,7 +30,7 @@ __csqrtl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) + if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { @@ -59,7 +59,7 @@ __csqrtl (__complex__ long double x) } else { - if (__builtin_expect (icls == FP_ZERO, 0)) + if (__glibc_unlikely (icls == FP_ZERO)) { if (__real__ x < 0.0) { @@ -73,7 +73,7 @@ __csqrtl (__complex__ long double x) __imag__ res = __copysignl (0.0, __imag__ x); } } - else if (__builtin_expect (rcls == FP_ZERO, 0)) + else if (__glibc_unlikely (rcls == FP_ZERO)) { long double r; if (fabsl (__imag__ x) >= 2.0L * LDBL_MIN) diff --git a/math/s_ctan.c b/math/s_ctan.c index 6fed4fe..407ff5a 100644 --- a/math/s_ctan.c +++ b/math/s_ctan.c @@ -28,7 +28,7 @@ __ctan (__complex__ double x) { __complex__ double res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_ns (__imag__ x)) { @@ -58,7 +58,7 @@ __ctan (__complex__ double x) /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincos (__real__ x, &sinrx, &cosrx); } diff --git a/math/s_ctanf.c b/math/s_ctanf.c index a2343dd..e6f345a 100644 --- a/math/s_ctanf.c +++ b/math/s_ctanf.c @@ -28,7 +28,7 @@ __ctanf (__complex__ float x) { __complex__ float res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_nsf (__imag__ x)) { @@ -57,7 +57,7 @@ __ctanf (__complex__ float x) /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - if (__builtin_expect (fpclassify(__real__ x) != FP_SUBNORMAL, 1)) + if (__glibc_likely (fpclassify(__real__ x) != FP_SUBNORMAL)) { __sincosf (__real__ x, &sinrx, &cosrx); } diff --git a/math/s_ctanh.c b/math/s_ctanh.c index 0ca35e0..be3e47e 100644 --- a/math/s_ctanh.c +++ b/math/s_ctanh.c @@ -28,7 +28,7 @@ __ctanh (__complex__ double x) { __complex__ double res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_ns (__real__ x)) { @@ -58,7 +58,7 @@ __ctanh (__complex__ double x) /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincos (__imag__ x, &sinix, &cosix); } diff --git a/math/s_ctanhf.c b/math/s_ctanhf.c index 8938d70..39a335e 100644 --- a/math/s_ctanhf.c +++ b/math/s_ctanhf.c @@ -28,7 +28,7 @@ __ctanhf (__complex__ float x) { __complex__ float res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_nsf (__real__ x)) { @@ -57,7 +57,7 @@ __ctanhf (__complex__ float x) /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - if (__builtin_expect (fpclassify(__imag__ x) != FP_SUBNORMAL, 1)) + if (__glibc_likely (fpclassify(__imag__ x) != FP_SUBNORMAL)) { __sincosf (__imag__ x, &sinix, &cosix); } diff --git a/math/s_ctanhl.c b/math/s_ctanhl.c index 098e009..64e448b 100644 --- a/math/s_ctanhl.c +++ b/math/s_ctanhl.c @@ -28,7 +28,7 @@ __ctanhl (__complex__ long double x) { __complex__ long double res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_nsl (__real__ x)) { @@ -58,7 +58,7 @@ __ctanhl (__complex__ long double x) /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - if (__builtin_expect (icls != FP_SUBNORMAL, 1)) + if (__glibc_likely (icls != FP_SUBNORMAL)) { __sincosl (__imag__ x, &sinix, &cosix); } diff --git a/math/s_ctanl.c b/math/s_ctanl.c index 98fdac0..282febd 100644 --- a/math/s_ctanl.c +++ b/math/s_ctanl.c @@ -28,7 +28,7 @@ __ctanl (__complex__ long double x) { __complex__ long double res; - if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) + if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (__isinf_nsl (__imag__ x)) { @@ -58,7 +58,7 @@ __ctanl (__complex__ long double x) /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) + if (__glibc_likely (rcls != FP_SUBNORMAL)) { __sincosl (__real__ x, &sinrx, &cosrx); } diff --git a/math/w_pow.c b/math/w_pow.c index 713d7a8..26790b9 100644 --- a/math/w_pow.c +++ b/math/w_pow.c @@ -25,7 +25,7 @@ double __pow (double x, double y) { double z = __ieee754_pow (x, y); - if (__builtin_expect (!__finite (z), 0)) + if (__glibc_unlikely (!__finite (z))) { if (_LIB_VERSION != _IEEE_) { diff --git a/math/w_powf.c b/math/w_powf.c index 1ba22c0..fa9e007 100644 --- a/math/w_powf.c +++ b/math/w_powf.c @@ -25,7 +25,7 @@ float __powf (float x, float y) { float z = __ieee754_powf (x, y); - if (__builtin_expect (!__finitef (z), 0)) + if (__glibc_unlikely (!__finitef (z))) { if (_LIB_VERSION != _IEEE_) { diff --git a/math/w_powl.c b/math/w_powl.c index eba9202..7c8d9f8 100644 --- a/math/w_powl.c +++ b/math/w_powl.c @@ -25,7 +25,7 @@ long double __powl (long double x, long double y) { long double z = __ieee754_powl (x, y); - if (__builtin_expect (!__finitel (z), 0)) + if (__glibc_unlikely (!__finitel (z))) { if (_LIB_VERSION != _IEEE_) { diff --git a/math/w_scalb.c b/math/w_scalb.c index 21b0c79..dbfefaf 100644 --- a/math/w_scalb.c +++ b/math/w_scalb.c @@ -27,7 +27,7 @@ sysv_scalb (double x, double fn) { double z = __ieee754_scalb (x, fn); - if (__builtin_expect (__isinf (z), 0)) + if (__glibc_unlikely (__isinf (z))) { if (__finite (x)) return __kernel_standard (x, fn, 32); /* scalb overflow */ diff --git a/math/w_scalbf.c b/math/w_scalbf.c index c23e35b..244fd1e 100644 --- a/math/w_scalbf.c +++ b/math/w_scalbf.c @@ -27,7 +27,7 @@ sysv_scalbf (float x, float fn) { float z = __ieee754_scalbf (x, fn); - if (__builtin_expect (__isinff (z), 0)) + if (__glibc_unlikely (__isinff (z))) { if (__finitef (x)) return __kernel_standard_f (x, fn, 132); /* scalb overflow */ diff --git a/math/w_scalbl.c b/math/w_scalbl.c index 4252af3..cffaa67 100644 --- a/math/w_scalbl.c +++ b/math/w_scalbl.c @@ -27,7 +27,7 @@ sysv_scalbl (long double x, long double fn) { long double z = __ieee754_scalbl (x, fn); - if (__builtin_expect (__isinfl (z), 0)) + if (__glibc_unlikely (__isinfl (z))) { if (__finitel (x)) return __kernel_standard_l (x, fn, 232); /* scalb overflow */ diff --git a/misc/error.c b/misc/error.c index dfaa240..63bd309 100644 --- a/misc/error.c +++ b/misc/error.c @@ -165,7 +165,7 @@ error_tail (int status, int errnum, const char *message, va_list args) if (res != len) break; - if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0)) + if (__glibc_unlikely (len >= SIZE_MAX / sizeof (wchar_t) / 2)) { /* This really should not happen if everything is fine. */ res = (size_t) -1; diff --git a/misc/pselect.c b/misc/pselect.c index 2f6517b..478dcce 100644 --- a/misc/pselect.c +++ b/misc/pselect.c @@ -45,7 +45,7 @@ __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, { /* Catch bugs which would be hidden by the TIMESPEC_TO_TIMEVAL computations. The division by 1000 truncates values. */ - if (__builtin_expect (timeout->tv_nsec < 0, 0)) + if (__glibc_unlikely (timeout->tv_nsec < 0)) { __set_errno (EINVAL); return -1; diff --git a/nis/nis_call.c b/nis/nis_call.c index c437732..df926a3 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -797,7 +797,7 @@ __prepare_niscall (const_nis_name name, directory_obj **dirp, dir_binding *bptrp, unsigned int flags) { nis_error retcode = __nisfind_server (name, 1, dirp, bptrp, flags); - if (__builtin_expect (retcode != NIS_SUCCESS, 0)) + if (__glibc_unlikely (retcode != NIS_SUCCESS)) return retcode; do diff --git a/nis/nis_callback.c b/nis/nis_callback.c index 958c49f..e352733 100644 --- a/nis/nis_callback.c +++ b/nis/nis_callback.c @@ -271,18 +271,18 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *, cb = (struct nis_cb *) calloc (1, sizeof (struct nis_cb) + sizeof (nis_server)); - if (__builtin_expect (cb == NULL, 0)) + if (__glibc_unlikely (cb == NULL)) goto failed; cb->serv = (nis_server *) (cb + 1); cb->serv->name = strdup (nis_local_principal ()); - if (__builtin_expect (cb->serv->name == NULL, 0)) + if (__glibc_unlikely (cb->serv->name == NULL)) goto failed; cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint)); - if (__builtin_expect (cb->serv->ep.ep_val == NULL, 0)) + if (__glibc_unlikely (cb->serv->ep.ep_val == NULL)) goto failed; cb->serv->ep.ep_len = 1; cb->serv->ep.ep_val[0].family = strdup ("inet"); - if (__builtin_expect (cb->serv->ep.ep_val[0].family == NULL, 0)) + if (__glibc_unlikely (cb->serv->ep.ep_val[0].family == NULL)) goto failed; cb->callback = callback; cb->userdata = userdata; @@ -314,7 +314,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *, } cb->serv->ep.ep_val[0].proto = strdup ((flags & USE_DGRAM) ? "udp" : "tcp"); - if (__builtin_expect (cb->serv->ep.ep_val[0].proto == NULL, 0)) + if (__glibc_unlikely (cb->serv->ep.ep_val[0].proto == NULL)) goto failed; cb->xprt = ((flags & USE_DGRAM) ? svcudp_bufcreate (sock, 100, 8192) diff --git a/nis/nis_creategroup.c b/nis/nis_creategroup.c index a916734..dd7f317 100644 --- a/nis/nis_creategroup.c +++ b/nis/nis_creategroup.c @@ -46,7 +46,7 @@ nis_creategroup (const_nis_name group, unsigned int flags) return NIS_BADNAME; obj = calloc (1, sizeof (nis_object)); - if (__builtin_expect (obj == NULL, 0)) + if (__glibc_unlikely (obj == NULL)) return NIS_NOMEMORY; obj->zo_oid.ctime = obj->zo_oid.mtime = time (NULL); diff --git a/nis/nis_domain_of_r.c b/nis/nis_domain_of_r.c index 52af9cc..5216f49 100644 --- a/nis/nis_domain_of_r.c +++ b/nis/nis_domain_of_r.c @@ -50,7 +50,7 @@ nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen) return strcpy (buffer, "."); } - if (__builtin_expect (cptr_len >= buflen, 0)) + if (__glibc_unlikely (cptr_len >= buflen)) { __set_errno (ERANGE); return NULL; diff --git a/nis/nis_findserv.c b/nis/nis_findserv.c index b566425..8adad82 100644 --- a/nis/nis_findserv.c +++ b/nis/nis_findserv.c @@ -89,7 +89,7 @@ __nis_findfastest_with_timeout (dir_binding *bind, pings = malloc (sizeof (struct findserv_req) * pings_max); xid_seed = (u_int32_t) (time (NULL) ^ getpid ()); - if (__builtin_expect (pings == NULL, 0)) + if (__glibc_unlikely (pings == NULL)) return -1; memset (&sin, '\0', sizeof (sin)); @@ -118,7 +118,7 @@ __nis_findfastest_with_timeout (dir_binding *bind, pings_max += 10; new_pings = realloc (pings, sizeof (struct findserv_req) * pings_max); - if (__builtin_expect (new_pings == NULL, 0)) + if (__glibc_unlikely (new_pings == NULL)) { free (pings); return -1; diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c index ac9278e..f180bad 100644 --- a/nis/nis_getservlist.c +++ b/nis/nis_getservlist.c @@ -38,7 +38,7 @@ nis_getservlist (const_nis_name dir) serv = malloc (sizeof (nis_server *) * (NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1)); - if (__builtin_expect (serv == NULL, 0)) + if (__glibc_unlikely (serv == NULL)) { nis_freeresult (res); return NULL; @@ -50,7 +50,7 @@ nis_getservlist (const_nis_name dir) server = &NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i]; serv[i] = calloc (1, sizeof (nis_server)); - if (__builtin_expect (serv[i] == NULL, 0)) + if (__glibc_unlikely (serv[i] == NULL)) { free_all: while (i-- > 0) @@ -81,7 +81,7 @@ nis_getservlist (const_nis_name dir) if (server->name != NULL) { serv[i]->name = strdup (server->name); - if (__builtin_expect (serv[i]->name == NULL, 0)) + if (__glibc_unlikely (serv[i]->name == NULL)) { ++i; goto free_all; @@ -95,7 +95,7 @@ nis_getservlist (const_nis_name dir) serv[i]->ep.ep_val = malloc (server->ep.ep_len * sizeof (endpoint)); - if (__builtin_expect (serv[i]->ep.ep_val == NULL, 0)) + if (__glibc_unlikely (serv[i]->ep.ep_val == NULL)) { ++i; goto free_all; @@ -126,7 +126,7 @@ nis_getservlist (const_nis_name dir) if (server->pkey.n_len > 0) { serv[i]->pkey.n_bytes = malloc (server->pkey.n_len); - if (__builtin_expect (serv[i]->pkey.n_bytes == NULL, 0)) + if (__glibc_unlikely (serv[i]->pkey.n_bytes == NULL)) { ++i; goto free_all; @@ -140,7 +140,7 @@ nis_getservlist (const_nis_name dir) else { serv = malloc (sizeof (nis_server *)); - if (__builtin_expect (serv != NULL, 0)) + if (__glibc_unlikely (serv != NULL)) serv[0] = NULL; } diff --git a/nis/nis_lookup.c b/nis/nis_lookup.c index a41f121..b9096c9 100644 --- a/nis/nis_lookup.c +++ b/nis/nis_lookup.c @@ -63,7 +63,7 @@ nis_lookup (const_nis_name name, const unsigned int flags) req.ns_object.ns_object_val = NULL; status = __prepare_niscall (req.ns_name, &dir, &bptr, flags); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) { NIS_RES_STATUS (res) = status; goto out; @@ -147,7 +147,7 @@ nis_lookup (const_nis_name name, const unsigned int flags) dir = NULL; status = __prepare_niscall (req.ns_name, &dir, &bptr, flags); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) { NIS_RES_STATUS (res) = status; goto out; diff --git a/nis/nis_subr.c b/nis/nis_subr.c index 4a4580a..8f6f1d7 100644 --- a/nis/nis_subr.c +++ b/nis/nis_subr.c @@ -38,7 +38,7 @@ nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen) while (name[i] != '.' && name[i] != '\0') i++; - if (__builtin_expect (i >= buflen, 0)) + if (__glibc_unlikely (i >= buflen)) { __set_errno (ERANGE); return NULL; @@ -118,7 +118,7 @@ nis_getnames (const_nis_name name) int count = 2; nis_name *getnames = malloc ((count + 1) * sizeof (char *)); - if (__builtin_expect (getnames == NULL, 0)) + if (__glibc_unlikely (getnames == NULL)) return NULL; /* Do we have a fully qualified NIS+ name ? If yes, give it back */ @@ -200,12 +200,12 @@ nis_getnames (const_nis_name name) count += 5; nis_name *newp = realloc (getnames, (count + 1) * sizeof (char *)); - if (__builtin_expect (newp == NULL, 0)) + if (__glibc_unlikely (newp == NULL)) goto free_null; getnames = newp; } tmp = malloc (strlen (cptr) + local_domain_len + name_len + 2); - if (__builtin_expect (tmp == NULL, 0)) + if (__glibc_unlikely (tmp == NULL)) goto free_null; getnames[pos] = tmp; @@ -235,7 +235,7 @@ nis_getnames (const_nis_name name) char *p; tmp = malloc (cplen + local_domain_len + name_len + 2); - if (__builtin_expect (tmp == NULL, 0)) + if (__glibc_unlikely (tmp == NULL)) goto free_null; p = __stpcpy (tmp, name); @@ -251,7 +251,7 @@ nis_getnames (const_nis_name name) char *p; tmp = malloc (cplen + name_len + 3); - if (__builtin_expect (tmp == NULL, 0)) + if (__glibc_unlikely (tmp == NULL)) goto free_null; p = __mempcpy (tmp, name, name_len); @@ -267,7 +267,7 @@ nis_getnames (const_nis_name name) count += 5; nis_name *newp = realloc (getnames, (count + 1) * sizeof (char *)); - if (__builtin_expect (newp == NULL, 0)) + if (__glibc_unlikely (newp == NULL)) goto free_null; getnames = newp; } diff --git a/nis/nis_table.c b/nis/nis_table.c index 9344a1f..bb74873 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -92,7 +92,7 @@ __create_ib_request (const_nis_name name, unsigned int flags) if (cptr != NULL) *cptr++ = '\0'; - if (__builtin_expect (val == NULL, 0)) + if (__glibc_unlikely (val == NULL)) { nis_free_request (ibreq); return NULL; @@ -282,7 +282,7 @@ nis_list (const_nis_name name, unsigned int flags, } while (__nisbind_connect (&bptr) != NIS_SUCCESS) - if (__builtin_expect (__nisbind_next (&bptr) != NIS_SUCCESS, 0)) + if (__glibc_unlikely (__nisbind_next (&bptr) != NIS_SUCCESS)) { NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE; goto fail; @@ -302,7 +302,7 @@ nis_list (const_nis_name name, unsigned int flags, (xdrproc_t) _xdr_nis_result, (caddr_t) res, RPCTIMEOUT); - if (__builtin_expect (clnt_status != RPC_SUCCESS, 0)) + if (__glibc_unlikely (clnt_status != RPC_SUCCESS)) NIS_RES_STATUS (res) = NIS_RPCERROR; else switch (NIS_RES_STATUS (res)) @@ -316,7 +316,7 @@ nis_list (const_nis_name name, unsigned int flags, free (ibreq->ibr_name); ibreq->ibr_name = NULL; /* If we hit the link limit, bail. */ - if (__builtin_expect (count_links > NIS_MAXLINKS, 0)) + if (__glibc_unlikely (count_links > NIS_MAXLINKS)) { NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; ++done; @@ -491,7 +491,7 @@ nis_list (const_nis_name name, unsigned int flags, /* Try the next domainname if we don't follow a link. */ free (ibreq->ibr_name); ibreq->ibr_name = NULL; - if (__builtin_expect (count_links, 0)) + if (__glibc_unlikely (count_links)) { NIS_RES_STATUS (res) = NIS_LINKNAMEERROR; ++done; @@ -597,7 +597,7 @@ nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags) (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, (caddr_t) res, 0, NULL); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) NIS_RES_STATUS (res) = status; nis_free_request (ibreq); @@ -654,7 +654,7 @@ nis_modify_entry (const_nis_name name, const nis_object *obj2, (xdrproc_t) _xdr_ib_request, (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, (caddr_t) res, 0, NULL); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) NIS_RES_STATUS (res) = status; nis_free_request (ibreq); @@ -739,7 +739,7 @@ nis_first_entry (const_nis_name name) (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, (caddr_t) res, 0, NULL); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) NIS_RES_STATUS (res) = status; nis_free_request (ibreq); @@ -782,7 +782,7 @@ nis_next_entry (const_nis_name name, const netobj *cookie) (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result, (caddr_t) res, 0, NULL); - if (__builtin_expect (status != NIS_SUCCESS, 0)) + if (__glibc_unlikely (status != NIS_SUCCESS)) NIS_RES_STATUS (res) = status; if (cookie != NULL) diff --git a/nis/nis_xdr.c b/nis/nis_xdr.c index d7ca819..c391d9c 100644 --- a/nis/nis_xdr.c +++ b/nis/nis_xdr.c @@ -75,7 +75,7 @@ xdr_endpoint (XDR *xdrs, endpoint *objp) if (__builtin_expect (res, TRUE)) { res = xdr_string (xdrs, &objp->family, ~0); - if (__builtin_expect (res, 1)) + if (__glibc_likely (res)) res = xdr_string (xdrs, &objp->proto, ~0); } return res; diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index 2d57461..78e14d6 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -288,7 +288,7 @@ getgrent_next_file (struct group *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -321,7 +321,7 @@ getgrent_next_file (struct group *result, ent_t *ent, !(parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; @@ -421,7 +421,7 @@ internal_getgrnam_r (const char *name, struct group *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -454,7 +454,7 @@ internal_getgrnam_r (const char *name, struct group *result, ent_t *ent, !(parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; @@ -552,7 +552,7 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -585,7 +585,7 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent, !(parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c index fa15238..c5ba606 100644 --- a/nis/nss_compat/compat-initgroups.c +++ b/nis/nss_compat/compat-initgroups.c @@ -214,7 +214,7 @@ add_group (long int *start, long int *size, gid_t **groupsp, long int limit, gid_t *groups = *groupsp; /* Matches user. Insert this group. */ - if (__builtin_expect (*start == *size, 0)) + if (__glibc_unlikely (*start == *size)) { /* Need a bigger buffer. */ gid_t *newgroups; @@ -420,7 +420,7 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -453,7 +453,7 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user, !(parse_res = _nss_files_parse_grent (p, &grpbuf, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 021fb18..127673c 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -528,7 +528,7 @@ getpwent_next_file (struct passwd *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -561,7 +561,7 @@ getpwent_next_file (struct passwd *result, ent_t *ent, !(parse_res = _nss_files_parse_pwent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; @@ -727,7 +727,7 @@ internal_getpwnam_r (const char *name, struct passwd *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -761,7 +761,7 @@ internal_getpwnam_r (const char *name, struct passwd *result, ent_t *ent, !(parse_res = _nss_files_parse_pwent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; @@ -934,7 +934,7 @@ internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -967,7 +967,7 @@ internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, !(parse_res = _nss_files_parse_pwent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index 1c2ec3d..4890ce6 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -485,7 +485,7 @@ getspent_next_file (struct spwd *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -515,7 +515,7 @@ getspent_next_file (struct spwd *result, ent_t *ent, || !(parse_res = _nss_files_parse_spent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; @@ -685,7 +685,7 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, do { /* We need at least 3 characters for one line. */ - if (__builtin_expect (buflen < 3, 0)) + if (__glibc_unlikely (buflen < 3)) { erange: *errnop = ERANGE; @@ -718,7 +718,7 @@ internal_getspnam_r (const char *name, struct spwd *result, ent_t *ent, !(parse_res = _nss_files_parse_spent (p, result, data, buflen, errnop))); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) /* The parser ran out of space. */ goto erange_reset; diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c index 2f708c1..995e610 100644 --- a/nis/nss_nis/nis-alias.c +++ b/nis/nss_nis/nis-alias.c @@ -125,7 +125,7 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; alias->alias_local = 0; @@ -147,7 +147,7 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, yperr = yp_next (domain, "mail.aliases", oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -156,7 +156,7 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -170,7 +170,7 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer, parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { free (outkey); *errnop = ERANGE; @@ -213,7 +213,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; size_t namlen = strlen (name); @@ -244,7 +244,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, if (!use_alloca) free (name2); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -253,7 +253,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -269,7 +269,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias, alias->alias_local = 0; int parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c index a803c27..59190cf 100644 --- a/nis/nss_nis/nis-ethers.c +++ b/nis/nss_nis/nis-ethers.c @@ -188,7 +188,7 @@ _nss_nis_gethostton_r (const char *name, struct etherent *eth, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char *result; @@ -196,7 +196,7 @@ _nss_nis_gethostton_r (const char *name, struct etherent *eth, int yperr = yp_match (domain, "ethers.byname", name, strlen (name), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -205,7 +205,7 @@ _nss_nis_gethostton_r (const char *name, struct etherent *eth, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -220,7 +220,7 @@ _nss_nis_gethostton_r (const char *name, struct etherent *eth, int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; @@ -241,7 +241,7 @@ _nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[33]; @@ -257,7 +257,7 @@ _nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, int len; int yperr = yp_match (domain, "ethers.byaddr", buf, nlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -266,7 +266,7 @@ _nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -281,7 +281,7 @@ _nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth, int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 5336807..20211de 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -85,7 +85,7 @@ internal_nis_setgrent (void) { /* We have to read all the data now. */ char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; struct ypall_callback ypcb; @@ -152,7 +152,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, handle_batch_read: bucket = intern.next; - if (__builtin_expect (intern.offset >= bucket->size, 0)) + if (__glibc_unlikely (intern.offset >= bucket->size)) { if (bucket->next == NULL) return NSS_STATUS_NOTFOUND; @@ -191,7 +191,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, yperr = yp_next (domain, "group.byname", oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -201,7 +201,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, } } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { if (!batch_read) free (result); @@ -218,7 +218,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { if (!batch_read) free (outkey); @@ -267,7 +267,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char *result; @@ -275,7 +275,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, int yperr = yp_match (domain, "group.byname", name, strlen (name), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -284,7 +284,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -314,7 +314,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, char *buffer, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[32]; @@ -324,7 +324,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, int len; int yperr = yp_match (domain, "group.bygid", buf, nlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -333,7 +333,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -348,7 +348,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index f73a0ec..462176e 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -136,14 +136,14 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, int af, int flags) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); buffer += pad; struct parser_data *data = (void *) buffer; - if (__builtin_expect (buflen < sizeof *data + 1 + pad, 0)) + if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) { *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; @@ -168,7 +168,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, yperr = yp_next (domain, "hosts.byname", oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -188,7 +188,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, return retval; } - if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) { free (result); *h_errnop = NETDB_INTERNAL; @@ -203,7 +203,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer, free (result); parse_res = parse_line (p, host, data, buflen, errnop, af, flags); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { free (outkey); *h_errnop = NETDB_INTERNAL; @@ -281,7 +281,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host, int len; int yperr = yp_match (domain, "hosts.byname", name2, namlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -296,7 +296,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host, } const size_t linebuflen = buffer + buflen - data->linebuffer; - if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) { free (result); *h_errnop = NETDB_INTERNAL; @@ -312,7 +312,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host, int parse_res = parse_line (p, host, data, buflen, errnop, af, flags); - if (__builtin_expect (parse_res < 1 || host->h_addrtype != af, 0)) + if (__glibc_unlikely (parse_res < 1 || host->h_addrtype != af)) { if (parse_res == -1) { @@ -373,14 +373,14 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, int *errnop, int *h_errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data); buffer += pad; struct parser_data *data = (void *) buffer; - if (__builtin_expect (buflen < sizeof *data + 1 + pad, 0)) + if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) { *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; @@ -395,7 +395,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, int yperr = yp_match (domain, "hosts.byaddr", buf, strlen (buf), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -411,7 +411,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, } const size_t linebuflen = buffer + buflen - data->linebuffer; - if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > linebuflen)) { free (result); *errnop = ERANGE; @@ -428,7 +428,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, int parse_res = parse_line (p, host, data, buflen, errnop, af, ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { @@ -472,7 +472,7 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, int len; int yperr = yp_match (domain, "hosts.byname", name2, namlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -493,7 +493,7 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, buffer += pad; buflen = buflen > pad ? buflen - pad : 0; - if (__builtin_expect (buflen < sizeof (struct gaih_addrtuple), 0)) + if (__glibc_unlikely (buflen < sizeof (struct gaih_addrtuple))) { erange: free (result); @@ -512,14 +512,14 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, struct parser_data *data = (void *) buffer; - if (__builtin_expect (buflen < sizeof *data + 1 + pad, 0)) + if (__glibc_unlikely (buflen < sizeof *data + 1 + pad)) goto erange; buflen -= pad; struct hostent host; int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC, 0); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c index 30bc90f..e8fcca1 100644 --- a/nis/nss_nis/nis-initgroups.c +++ b/nis/nss_nis/nis-initgroups.c @@ -72,7 +72,7 @@ internal_getgrent_r (struct group *grp, char *buffer, size_t buflen, { struct response_t *bucket = intern->next; - if (__builtin_expect (intern->offset >= bucket->size, 0)) + if (__glibc_unlikely (intern->offset >= bucket->size)) { if (bucket->next == NULL) return NSS_STATUS_NOTFOUND; @@ -88,7 +88,7 @@ internal_getgrent_r (struct group *grp, char *buffer, size_t buflen, ++intern->offset; size_t len = strlen (p) + 1; - if (__builtin_expect (len > buflen, 0)) + if (__glibc_unlikely (len > buflen)) { *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; @@ -106,7 +106,7 @@ internal_getgrent_r (struct group *grp, char *buffer, size_t buflen, parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) return NSS_STATUS_TRYAGAIN; intern->offset += len; @@ -160,7 +160,7 @@ initgroups_netid (uid_t uid, gid_t group, long int *start, long int *size, int reslen; int yperr = yp_match (domainname, "netid.byname", key, keylen, &result, &reslen); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) return yperr2nss (yperr); /* Parse the result: following the colon is a comma separated list of diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index d4b2e56..d03d715 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -54,16 +54,16 @@ _nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp) status = NSS_STATUS_SUCCESS; - if (__builtin_expect (group == NULL || group[0] == '\0', 0)) + if (__glibc_unlikely (group == NULL || group[0] == '\0')) return NSS_STATUS_UNAVAIL; char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; status = yperr2nss (yp_match (domain, "netgroup", group, strlen (group), &netgrp->data, &len)); - if (__builtin_expect (status == NSS_STATUS_SUCCESS, 1)) + if (__glibc_likely (status == NSS_STATUS_SUCCESS)) { /* Our implementation of yp_match already allocates a buffer which is one byte larger than the value in LEN specifies diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c index da28860..f28fbda 100644 --- a/nis/nss_nis/nis-network.c +++ b/nis/nss_nis/nis-network.c @@ -74,7 +74,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, struct parser_data *data = (void *) buffer; char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; /* Get the next entry until we found a correct one. */ @@ -94,7 +94,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, yperr = yp_next (domain, "networks.byname", oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -106,7 +106,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -121,7 +121,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, free (result); parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { free (outkey); *herrnop = NETDB_INTERNAL; @@ -166,7 +166,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; struct parser_data *data = (void *) buffer; @@ -191,7 +191,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, int yperr = yp_match (domain, "networks.byname", name2, namlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -203,7 +203,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -219,7 +219,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, int parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { *herrnop = NETDB_INTERNAL; if (parse_res == -1) @@ -237,7 +237,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, int *herrnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; struct in_addr in = { .s_addr = htonl (addr) }; @@ -252,7 +252,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, int yperr = yp_match (domain, "networks.byaddr", buf, blen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -277,7 +277,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, } } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -294,7 +294,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, int parse_res = _nss_files_parse_netent (p, net, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { *herrnop = NETDB_INTERNAL; if (parse_res == -1) diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index eff2edd..e165f10 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -185,7 +185,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char *result; @@ -193,7 +193,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, int yperr = yp_match (domain, "protocols.byname", name, strlen (name), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -202,7 +202,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -217,7 +217,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; @@ -232,7 +232,7 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, char *buffer, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[32]; @@ -243,7 +243,7 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, int yperr = yp_match (domain, "protocols.bynumber", buf, nlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -252,7 +252,7 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -267,7 +267,7 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c index cec43e2..7a13341 100644 --- a/nis/nss_nis/nis-publickey.c +++ b/nis/nss_nis/nis-publickey.c @@ -56,7 +56,7 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) int yperr = yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -102,7 +102,7 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, int yperr = yp_match (domain, "publickey.byname", netname, strlen (netname), &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index 6726efd..aab14c6 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -57,7 +57,7 @@ _nis_saveit (int instatus, char *inkey, int inkeylen, char *inval, { struct response_t *bucket = intern->next; - if (__builtin_expect (bucket == NULL, 0)) + if (__glibc_unlikely (bucket == NULL)) { #define MINSIZE 4096 - 4 * sizeof (void *) const size_t minsize = MAX (MINSIZE, 2 * (invallen + 1)); @@ -92,7 +92,7 @@ _nis_saveit (int instatus, char *inkey, int inkeylen, char *inval, } char *p = mempcpy (&bucket->mem[intern->offset], inval, invallen); - if (__builtin_expect (p[-1] != '\0', 0)) + if (__glibc_unlikely (p[-1] != '\0')) { *p = '\0'; ++invallen; @@ -143,7 +143,7 @@ internal_nis_setpwent (void) { /* We have to read all the data now. */ char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; struct ypall_callback ypcb; @@ -210,7 +210,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, handle_batch_read: bucket = intern.next; - if (__builtin_expect (intern.offset >= bucket->size, 0)) + if (__glibc_unlikely (intern.offset >= bucket->size)) { if (bucket->next == NULL) return NSS_STATUS_NOTFOUND; @@ -249,7 +249,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, yperr = yp_next (domain, "passwd.byname", oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -312,7 +312,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, else { non_adjunct: - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -330,7 +330,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen, parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { if (!batch_read) free (outkey); @@ -379,7 +379,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; size_t namelen = strlen (name); @@ -388,7 +388,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, int len; int yperr = yp_match (domain, "passwd.byname", name, namelen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -447,7 +447,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, else { non_adjunct: - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -464,7 +464,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; @@ -480,7 +480,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[32]; @@ -490,7 +490,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, int len; int yperr = yp_match (domain, "passwd.byuid", buf, nlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -552,7 +552,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, else { non_adjunct: - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -569,7 +569,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c index a2fff63..cb4b089 100644 --- a/nis/nss_nis/nis-rpc.c +++ b/nis/nss_nis/nis-rpc.c @@ -124,7 +124,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, { struct response_t *bucket = intern->next; - if (__builtin_expect (intern->offset >= bucket->size, 0)) + if (__glibc_unlikely (intern->offset >= bucket->size)) { if (bucket->next == NULL) return NSS_STATUS_NOTFOUND; @@ -139,7 +139,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, ++intern->offset; size_t len = strlen (p) + 1; - if (__builtin_expect (len > buflen, 0)) + if (__glibc_unlikely (len > buflen)) { *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; @@ -156,7 +156,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, p = memcpy (buffer, &bucket->mem[intern->offset], len); parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) return NSS_STATUS_TRYAGAIN; intern->offset += len; @@ -193,7 +193,7 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, intern_t data = { NULL, NULL, 0 }; enum nss_status status = internal_nis_setrpcent (&data); - if (__builtin_expect (status != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (status != NSS_STATUS_SUCCESS)) return status; int found = 0; @@ -222,7 +222,7 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc, internal_nis_endrpcent (&data); - if (__builtin_expect (!found && status == NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (!found && status == NSS_STATUS_SUCCESS)) return NSS_STATUS_NOTFOUND; return status; @@ -233,7 +233,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, char *buffer, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; char buf[32]; @@ -243,7 +243,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, int len; int yperr = yp_match (domain, "rpc.bynumber", buf, nlen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -252,7 +252,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, return retval; } - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -267,7 +267,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, int parse_res = _nss_files_parse_rpcent (p, rpc, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c index fd79d3f..f9b4a86 100644 --- a/nis/nss_nis/nis-service.c +++ b/nis/nss_nis/nis-service.c @@ -56,12 +56,12 @@ dosearch (int instatus, char *inkey, int inkeylen, char *inval, { struct search_t *req = (struct search_t *) indata; - if (__builtin_expect (instatus != YP_TRUE, 0)) + if (__glibc_unlikely (instatus != YP_TRUE)) return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { - if (__builtin_expect ((size_t) (invallen + 1) > req->buflen, 0)) + if (__glibc_unlikely ((size_t) (invallen + 1) > req->buflen)) { *req->errnop = ERANGE; req->status = NSS_STATUS_TRYAGAIN; @@ -196,7 +196,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, { struct response_t *bucket = intern.next; - if (__builtin_expect (intern.offset >= bucket->size, 0)) + if (__glibc_unlikely (intern.offset >= bucket->size)) { if (bucket->next == NULL) return NSS_STATUS_NOTFOUND; @@ -211,7 +211,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, ++intern.offset; size_t len = strlen (p) + 1; - if (__builtin_expect (len > buflen, 0)) + if (__glibc_unlikely (len > buflen)) { *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; @@ -228,7 +228,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer, p = memcpy (buffer, &bucket->mem[intern.offset], len); parse_res = _nss_files_parse_servent (p, serv, pdata, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) return NSS_STATUS_TRYAGAIN; intern.offset += len; @@ -265,7 +265,7 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol, } char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; /* If the protocol is given, we could try if our NIS server knows @@ -289,9 +289,9 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol, /* If we found the key, it's ok and parse the result. If not, fall through and parse the complete table. */ - if (__builtin_expect (status == YPERR_SUCCESS, 1)) + if (__glibc_likely (status == YPERR_SUCCESS)) { - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -306,7 +306,7 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol, int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 0, 0)) + if (__glibc_unlikely (parse_res < 0)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; @@ -336,7 +336,7 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol, req.status = NSS_STATUS_NOTFOUND; status = yp_all (domain, "services.byname", &ypcb); - if (__builtin_expect (status != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (status != YPERR_SUCCESS)) return yperr2nss (status); return req.status; @@ -348,7 +348,7 @@ _nss_nis_getservbyport_r (int port, const char *protocol, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; /* If the protocol is given, we only need one query. @@ -370,9 +370,9 @@ _nss_nis_getservbyport_r (int port, const char *protocol, /* If we found the key, it's ok and parse the result. If not, fall through and parse the complete table. */ - if (__builtin_expect (status == YPERR_SUCCESS, 1)) + if (__glibc_likely (status == YPERR_SUCCESS)) { - if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + 1) > buflen)) { free (result); *errnop = ERANGE; @@ -386,7 +386,7 @@ _nss_nis_getservbyport_r (int port, const char *protocol, free (result); int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 0, 0)) + if (__glibc_unlikely (parse_res < 0)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; @@ -417,7 +417,7 @@ _nss_nis_getservbyport_r (int port, const char *protocol, req.status = NSS_STATUS_NOTFOUND; int status = yp_all (domain, "services.byname", &ypcb); - if (__builtin_expect (status != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (status != YPERR_SUCCESS)) return yperr2nss (status); return req.status; diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c index d024c0d..7cfc3ce 100644 --- a/nis/nss_nis/nis-spwd.c +++ b/nis/nss_nis/nis-spwd.c @@ -71,7 +71,7 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen, int *errnop) { char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; /* Get the next entry until we found a correct one. */ @@ -102,7 +102,7 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen, ? "passwd.adjunct.byname" : "shadow.byname"), oldkey, oldkeylen, &outkey, &keylen, &result, &len); - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -177,7 +177,7 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, const size_t name_len = strlen (name); char *domain; - if (__builtin_expect (yp_get_default_domain (&domain), 0)) + if (__glibc_unlikely (yp_get_default_domain (&domain))) return NSS_STATUS_UNAVAIL; bool adjunct_used = false; @@ -194,7 +194,7 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, adjunct_used = true; } - if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + if (__glibc_unlikely (yperr != YPERR_SUCCESS)) { enum nss_status retval = yperr2nss (yperr); @@ -203,7 +203,7 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, return retval; } - if (__builtin_expect ((size_t) (len + (adjunct_used ? 3 : 1)) > buflen, 0)) + if (__glibc_unlikely ((size_t) (len + (adjunct_used ? 3 : 1)) > buflen)) { free (result); *errnop = ERANGE; @@ -224,7 +224,7 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, int parse_res = _nss_files_parse_spent (p, sp, (void *) buffer, buflen, errnop); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c index e3a82ff..9e3849b 100644 --- a/nis/nss_nisplus/nisplus-alias.c +++ b/nis/nss_nisplus/nisplus-alias.c @@ -310,7 +310,7 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); nis_freeresult (result); @@ -323,7 +323,7 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias, /* We do not need the lookup result anymore. */ nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { __set_errno (olderr); diff --git a/nis/nss_nisplus/nisplus-ethers.c b/nis/nss_nisplus/nisplus-ethers.c index cc7695f..a962166 100644 --- a/nis/nss_nisplus/nisplus-ethers.c +++ b/nis/nss_nisplus/nisplus-ethers.c @@ -264,7 +264,7 @@ _nss_nisplus_gethostton_r (const char *name, struct etherent *eth, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); nis_freeresult (result); @@ -277,7 +277,7 @@ _nss_nisplus_gethostton_r (const char *name, struct etherent *eth, /* We do not need the lookup result anymore. */ nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { __set_errno (olderr); @@ -331,7 +331,7 @@ _nss_nisplus_getntohost_r (const struct ether_addr *addr, struct etherent *eth, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); nis_freeresult (result); @@ -344,7 +344,7 @@ _nss_nisplus_getntohost_r (const struct ether_addr *addr, struct etherent *eth, /* We do not need the lookup result anymore. */ nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nisplus/nisplus-grp.c b/nis/nss_nisplus/nisplus-grp.c index 8667532..58f31c8 100644 --- a/nis/nss_nisplus/nisplus-grp.c +++ b/nis/nss_nisplus/nisplus-grp.c @@ -242,7 +242,7 @@ internal_nisplus_getgrent_r (struct group *gr, char *buffer, size_t buflen, parse_res = _nss_nisplus_parse_grent (&result, gr, buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { *errnop = ERANGE; retval = NSS_STATUS_TRYAGAIN; @@ -316,7 +316,7 @@ _nss_nisplus_getgrnam_r (const char *name, struct group *gr, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -326,7 +326,7 @@ _nss_nisplus_getgrnam_r (const char *name, struct group *gr, parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen, errnop); nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { @@ -371,7 +371,7 @@ _nss_nisplus_getgrgid_r (const gid_t gid, struct group *gr, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -384,7 +384,7 @@ _nss_nisplus_getgrgid_r (const gid_t gid, struct group *gr, parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen, errnop); nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { __set_errno (olderr); diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c index 62440f2..b3e0df5 100644 --- a/nis/nss_nisplus/nisplus-hosts.c +++ b/nis/nss_nisplus/nisplus-hosts.c @@ -439,7 +439,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host, } int retval = niserr2nss (result->status); - if (__builtin_expect (retval != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) { if (retval == NSS_STATUS_TRYAGAIN) { @@ -543,7 +543,7 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, } retval = niserr2nss (result->status); - if (__builtin_expect (retval != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) { if (retval == NSS_STATUS_TRYAGAIN) { @@ -587,7 +587,7 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host, buffer, buflen, errnop, herrnop, 0); - if (__builtin_expect (status == NSS_STATUS_SUCCESS, 1)) + if (__glibc_likely (status == NSS_STATUS_SUCCESS)) { if (*pat == NULL) { @@ -596,7 +596,7 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, buffer += pad; buflen = buflen > pad ? buflen - pad : 0; - if (__builtin_expect (buflen < sizeof (struct gaih_addrtuple), 0)) + if (__glibc_unlikely (buflen < sizeof (struct gaih_addrtuple))) { free (result); *errnop = ERANGE; diff --git a/nis/nss_nisplus/nisplus-initgroups.c b/nis/nss_nisplus/nisplus-initgroups.c index 9df9643..c304f0e 100644 --- a/nis/nss_nisplus/nisplus-initgroups.c +++ b/nis/nss_nisplus/nisplus-initgroups.c @@ -67,7 +67,7 @@ _nss_nisplus_initgroups_dyn (const char *user, gid_t group, long int *start, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -98,7 +98,7 @@ _nss_nisplus_initgroups_dyn (const char *user, gid_t group, long int *start, gid_t gid; char *endp; - if (__builtin_expect (numstr[len - 1] != '\0', 0)) + if (__glibc_unlikely (numstr[len - 1] != '\0')) { char numstrbuf[len + 1]; memcpy (numstrbuf, numstr, len); diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c index ed4a8f3..43e955d 100644 --- a/nis/nss_nisplus/nisplus-network.c +++ b/nis/nss_nisplus/nisplus-network.c @@ -376,7 +376,7 @@ _nss_nisplus_getnetbyname_r (const char *name, struct netent *network, } retval = niserr2nss (result->status); - if (__builtin_expect (retval != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) { if (retval == NSS_STATUS_TRYAGAIN) { @@ -447,7 +447,7 @@ _nss_nisplus_getnetbyaddr_r (uint32_t addr, const int type, return NSS_STATUS_TRYAGAIN; } enum nss_status retval = niserr2nss (result->status); - if (__builtin_expect (retval != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (retval != NSS_STATUS_SUCCESS)) { if (b2len > 2 && buf2[b2len - 2] == '.' && buf2[b2len - 1] == '0') { diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c index 358d7de..cfe32f5 100644 --- a/nis/nss_nisplus/nisplus-proto.c +++ b/nis/nss_nisplus/nisplus-proto.c @@ -347,7 +347,7 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -408,7 +408,7 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c index 1a732bc..811131c 100644 --- a/nis/nss_nisplus/nisplus-pwd.c +++ b/nis/nss_nisplus/nisplus-pwd.c @@ -243,7 +243,7 @@ internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen, parse_res = _nss_nisplus_parse_pwent (&result, pw, buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { *errnop = ERANGE; retval = NSS_STATUS_TRYAGAIN; @@ -317,7 +317,7 @@ _nss_nisplus_getpwnam_r (const char *name, struct passwd *pw, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -331,7 +331,7 @@ _nss_nisplus_getpwnam_r (const char *name, struct passwd *pw, nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { @@ -376,7 +376,7 @@ _nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -390,7 +390,7 @@ _nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw, nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { diff --git a/nis/nss_nisplus/nisplus-rpc.c b/nis/nss_nisplus/nisplus-rpc.c index 5604a5f..0bcd0fb 100644 --- a/nis/nss_nisplus/nisplus-rpc.c +++ b/nis/nss_nisplus/nisplus-rpc.c @@ -351,7 +351,7 @@ _nss_nisplus_getrpcbyname_r (const char *name, struct rpcent *rpc, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); diff --git a/nis/nss_nisplus/nisplus-service.c b/nis/nss_nisplus/nisplus-service.c index 805ccfb..c32823b 100644 --- a/nis/nss_nisplus/nisplus-service.c +++ b/nis/nss_nisplus/nisplus-service.c @@ -258,7 +258,7 @@ internal_nisplus_getservent_r (struct servent *serv, char *buffer, parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { nis_freeresult (result); result = saved_res; @@ -360,7 +360,7 @@ _nss_nisplus_getservbyname_r (const char *name, const char *protocol, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -374,7 +374,7 @@ _nss_nisplus_getservbyname_r (const char *name, const char *protocol, errnop); nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { @@ -429,7 +429,7 @@ _nss_nisplus_getservbyport_r (const int number, const char *protocol, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -443,7 +443,7 @@ _nss_nisplus_getservbyport_r (const int number, const char *protocol, errnop); nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c index 5b671e2..f3c7f9d 100644 --- a/nis/nss_nisplus/nisplus-spwd.c +++ b/nis/nss_nisplus/nisplus-spwd.c @@ -124,7 +124,7 @@ internal_nisplus_getspent_r (struct spwd *sp, char *buffer, size_t buflen, parse_res = _nss_nisplus_parse_spent (result, sp, buffer, buflen, errnop); - if (__builtin_expect (parse_res == -1, 0)) + if (__glibc_unlikely (parse_res == -1)) { nis_freeresult (result); result = saved_res; @@ -189,7 +189,7 @@ _nss_nisplus_getspnam_r (const char *name, struct spwd *sp, return NSS_STATUS_TRYAGAIN; } - if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0)) + if (__glibc_unlikely (niserr2nss (result->status) != NSS_STATUS_SUCCESS)) { enum nss_status status = niserr2nss (result->status); @@ -202,7 +202,7 @@ _nss_nisplus_getspnam_r (const char *name, struct spwd *sp, parse_res = _nss_nisplus_parse_spent (result, sp, buffer, buflen, errnop); nis_freeresult (result); - if (__builtin_expect (parse_res < 1, 0)) + if (__glibc_unlikely (parse_res < 1)) { if (parse_res == -1) { diff --git a/nis/ypclnt.c b/nis/ypclnt.c index 400db0a..dd1833b 100644 --- a/nis/ypclnt.c +++ b/nis/ypclnt.c @@ -183,7 +183,7 @@ __yp_bind (const char *domain, dom_binding **ypdb) { is_new = 1; ysd = (dom_binding *) calloc (1, sizeof *ysd); - if (__builtin_expect (ysd == NULL, 0)) + if (__glibc_unlikely (ysd == NULL)) return YPERR_RESRC; } @@ -471,7 +471,7 @@ yp_match (const char *indomain, const char *inmap, const char *inkey, *outvallen = resp.val.valdat_len; *outval = malloc (*outvallen + 1); int status = YPERR_RESRC; - if (__builtin_expect (*outval != NULL, 1)) + if (__glibc_likely (*outval != NULL)) { memcpy (*outval, resp.val.valdat_val, *outvallen); (*outval)[*outvallen] = '\0'; @@ -770,7 +770,7 @@ yp_all (const char *indomain, const char *inmap, (caddr_t) &req, (xdrproc_t) __xdr_ypresp_all, (caddr_t) &data, RPCTIMEOUT); - if (__builtin_expect (result != RPC_SUCCESS, 0)) + if (__glibc_unlikely (result != RPC_SUCCESS)) { /* Print the error message only on the last try. */ if (try == MAXTRIES - 1) @@ -811,7 +811,7 @@ yp_maplist (const char *indomain, struct ypmaplist **outmaplist) (caddr_t) &indomain, (xdrproc_t) xdr_ypresp_maplist, (caddr_t) &resp); - if (__builtin_expect (result == YPERR_SUCCESS, 1)) + if (__glibc_likely (result == YPERR_SUCCESS)) { *outmaplist = resp.maps; /* We don't free the list, this will be done by ypserv diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 474a473..f7241c5 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,76 @@ +2014-02-10 Ondřej Bílka + + * allocatestack.c (queue_stack, allocate_stack, + __deallocate_stack, __reclaim_stacks): Use glibc_likely instead + __builtin_expect. + * cancellation.c (__pthread_enable_asynccancel, + __pthread_disable_asynccancel): Likewise. + * cleanup_defer.c (__pthread_register_cancel_defer, + __pthread_unregister_cancel_restore): Likewise. + * cleanup_defer_compat.c (_pthread_cleanup_push_defer, + _pthread_cleanup_pop_restore): Likewise. + * cond-perf.c (main): Likewise. + * nptl-init.c (sigcancel_handler, sighandler_setxid): Likewise. + * perf.c (get_clockfreq): Likewise. + * pthread_barrier_destroy.c (pthread_barrier_destroy): Likewise. + * pthread_barrier_init.c (pthread_barrier_init): Likewise. + * pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise. + * pthread_cond_wait.c (__pthread_cond_wait): Likewise. + * pthread_create.c (__free_tcb, start_thread, __pthread_create_2_1): + Likewise. + * pthread_getattr_np.c (pthread_getattr_np): Likewise. + * pthread_getspecific.c (__pthread_getspecific): Likewise. + * pthread_join.c (pthread_join): Likewise. + * pthread_key_delete.c (pthread_key_delete): Likewise. + * pthread_mutex_init.c (__pthread_mutex_init): Likewise. + * pthread_mutex_lock.c (__pthread_mutex_lock, + __pthread_mutex_lock_full): Likewise. + * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise. + * pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise. + * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise. + * pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Likewise. + * pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock): Likewise. + * pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock): Likewise. + * pthread_rwlock_tryrdlock.c (__pthread_rwlock_tryrdlock): Likewise. + * pthread_setcancelstate.c (__pthread_setcancelstate): Likewise. + * pthread_setcanceltype.c (__pthread_setcanceltype): Likewise. + * pthread_setschedprio.c (pthread_setschedprio): Likewise. + * pthread_setspecific.c (__pthread_setspecific): Likewise. + * sem_init.c (__new_sem_init): Likewise. + * sem_open.c (__where_is_shmfs): Likewise. + * sigaction.c: Likewise. + * sockperf.c (get_clockfreq): Likewise. + * sysdeps/pthread/createthread.c (do_clone, create_thread): Likewise. + * sysdeps/pthread/setxid.h: Likewise. + * sysdeps/pthread/timer_create.c (timer_create): Likewise. + * sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init, + __unwind_freeres, _Unwind_Resume, __gcc_personality_v0, + _Unwind_ForcedUnwind): Likewise. + * sysdeps/unix/sysv/linux/getpid.c (__getpid): Likewise. + * sysdeps/unix/sysv/linux/lowlevelrobustlock.c + (__lll_robust_lock_wait, __lll_robust_timedlock_wait): Likewise. + * sysdeps/unix/sysv/linux/mq_notify.c (mq_notify): Likewise. + * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise. + * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise. + * sysdeps/unix/sysv/linux/pthread_setaffinity.c + (__pthread_setaffinity_new): Likewise. + * sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue): + Likewise. + * sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/s390/lowlevellock.h (__lll_robust_trylock, + __lll_robust_lock, __lll_cond_lock, __lll_robust_timedlock): Likewise. + * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_lock, + __lll_cond_lock, __lll_timedlock, __lll_robust_timedlock): Likewise. + * sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c + (pthread_barrier_destroy): Likewise. + * sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c + (pthread_barrier_init): Likewise. + * sysdeps/unix/sysv/linux/sparc/sem_init.c (__new_sem_init): Likewise. + * sysdeps/unix/sysv/linux/x86_64/timer_create.c (__timer_create_old): + Likewise. + * unwind.c (unwind_stop): Likewise. + 2014-02-08 Mike Frysinger * sem_open.c (__where_is_shmfs): Compare f.f_type to RAMFS_MAGIC too. diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 13eca47..1e22f7d 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -306,7 +306,7 @@ queue_stack (struct pthread *stack) stack_list_add (&stack->list, &stack_cache); stack_cache_actsize += stack->stackblock_size; - if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0)) + if (__glibc_unlikely (stack_cache_actsize > stack_cache_maxsize)) __free_stacks (stack_cache_maxsize); } @@ -368,7 +368,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, } /* Get memory for the stack. */ - if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0)) + if (__glibc_unlikely (attr->flags & ATTR_FLAG_STACKADDR)) { uintptr_t adj; @@ -504,7 +504,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, mem = mmap (NULL, size, prot, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); - if (__builtin_expect (mem == MAP_FAILED, 0)) + if (__glibc_unlikely (mem == MAP_FAILED)) return errno; /* SIZE is guaranteed to be greater than zero. @@ -525,7 +525,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* Make sure the coloring offsets does not disturb the alignment of the TCB and static TLS block. */ - if (__builtin_expect ((coloring & __static_tls_align_m1) != 0, 0)) + if (__glibc_unlikely ((coloring & __static_tls_align_m1) != 0)) coloring = (((coloring + __static_tls_align_m1) & ~(__static_tls_align_m1)) & ~pagesize_m1); @@ -629,7 +629,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, } /* Create or resize the guard area if necessary. */ - if (__builtin_expect (guardsize > pd->guardsize, 0)) + if (__glibc_unlikely (guardsize > pd->guardsize)) { #ifdef NEED_SEPARATE_REGISTER_STACK char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1); @@ -752,7 +752,7 @@ __deallocate_stack (struct pthread *pd) not reset the 'used' flag in the 'tid' field. This is done by the kernel. If no thread has been created yet this field is still zero. */ - if (__builtin_expect (! pd->user_stack, 1)) + if (__glibc_likely (! pd->user_stack)) (void) queue_stack (pd); else /* Free the memory associated with the ELF TLS. */ @@ -916,7 +916,7 @@ __reclaim_stacks (void) INIT_LIST_HEAD (&stack_used); INIT_LIST_HEAD (&__stack_user); - if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0)) + if (__glibc_unlikely (THREAD_GETMEM (self, user_stack))) list_add (&self->list, &__stack_user); else list_add (&self->list, &stack_used); diff --git a/nptl/cancellation.c b/nptl/cancellation.c index bddea1f..aaf102d 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -40,7 +40,7 @@ __pthread_enable_asynccancel (void) int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) { if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) { @@ -79,7 +79,7 @@ __pthread_disable_asynccancel (int oldtype) int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) break; /* Prepare the next round. */ diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c index 4049497..a8fc403 100644 --- a/nptl/cleanup_defer.c +++ b/nptl/cleanup_defer.c @@ -34,14 +34,14 @@ __pthread_register_cancel_defer (__pthread_unwind_buf_t *buf) int cancelhandling = THREAD_GETMEM (self, cancelhandling); /* Disable asynchronous cancellation for now. */ - if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0)) + if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK)) while (1) { int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, cancelhandling & ~CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; @@ -78,7 +78,7 @@ __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf) cancelhandling | CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; diff --git a/nptl/cleanup_defer_compat.c b/nptl/cleanup_defer_compat.c index b57fd4e..9c52f5f 100644 --- a/nptl/cleanup_defer_compat.c +++ b/nptl/cleanup_defer_compat.c @@ -34,14 +34,14 @@ _pthread_cleanup_push_defer (buffer, routine, arg) int cancelhandling = THREAD_GETMEM (self, cancelhandling); /* Disable asynchronous cancellation for now. */ - if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0)) + if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK)) while (1) { int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, cancelhandling & ~CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; @@ -78,7 +78,7 @@ _pthread_cleanup_pop_restore (buffer, execute) cancelhandling | CANCELTYPE_BITMASK, cancelhandling); - if (__builtin_expect (curval == cancelhandling, 1)) + if (__glibc_likely (curval == cancelhandling)) /* Successfully replaced the value. */ break; diff --git a/nptl/cond-perf.c b/nptl/cond-perf.c index e37914e..9c9488e 100644 --- a/nptl/cond-perf.c +++ b/nptl/cond-perf.c @@ -70,7 +70,7 @@ main (int argc, char *argv[]) pthread_t th[nthreads]; int i; for (i = 0; __builtin_expect (i < nthreads, 1); ++i) - if (__builtin_expect ((err = pthread_create (&th[i], NULL, cons, (void *) (long) i)) != 0, 0)) + if (__glibc_unlikely ((err = pthread_create (&th[i], NULL, cons, (void *) (long) i)) != 0)) printf ("pthread_create: %s\n", strerror (err)); for (i = 0; __builtin_expect (i < nrounds, 1); ++i) diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 4d1f7d8..794156b 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -175,7 +175,7 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx) /* Determine the process ID. It might be negative if the thread is in the middle of a fork() call. */ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (pid < 0, 0)) + if (__glibc_unlikely (pid < 0)) pid = -pid; /* Safety check. It would be possible to call this function for @@ -232,7 +232,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) /* Determine the process ID. It might be negative if the thread is in the middle of a fork() call. */ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (pid < 0, 0)) + if (__glibc_unlikely (pid < 0)) pid = -pid; /* Safety check. It would be possible to call this function for diff --git a/nptl/perf.c b/nptl/perf.c index ceb30c6..3ecab2c 100644 --- a/nptl/perf.c +++ b/nptl/perf.c @@ -633,7 +633,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. */ @@ -645,7 +645,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/nptl/pthread_barrier_destroy.c b/nptl/pthread_barrier_destroy.c index 60fe2df..c59a861 100644 --- a/nptl/pthread_barrier_destroy.c +++ b/nptl/pthread_barrier_destroy.c @@ -32,7 +32,7 @@ pthread_barrier_destroy (barrier) lll_lock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG); - if (__builtin_expect (ibarrier->left == ibarrier->init_count, 1)) + if (__glibc_likely (ibarrier->left == ibarrier->init_count)) /* The barrier is not used anymore. */ result = 0; else diff --git a/nptl/pthread_barrier_init.c b/nptl/pthread_barrier_init.c index 0e603ba..ac180a9 100644 --- a/nptl/pthread_barrier_init.c +++ b/nptl/pthread_barrier_init.c @@ -36,7 +36,7 @@ pthread_barrier_init (barrier, attr, count) { struct pthread_barrier *ibarrier; - if (__builtin_expect (count == 0, 0)) + if (__glibc_unlikely (count == 0)) return EINVAL; const struct pthread_barrierattr *iattr diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c index b975b8f..1698085 100644 --- a/nptl/pthread_cond_timedwait.c +++ b/nptl/pthread_cond_timedwait.c @@ -87,7 +87,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ - if (__builtin_expect (abstime->tv_sec < 0, 0)) + if (__glibc_unlikely (abstime->tv_sec < 0)) goto timeout; /* Remember the mutex we are using here. If there is already a @@ -143,7 +143,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) --rt.tv_sec; } /* Did we already time out? */ - if (__builtin_expect (rt.tv_sec < 0, 0)) + if (__glibc_unlikely (rt.tv_sec < 0)) { if (cbuffer.bc_seq != cond->__data.__broadcast_seq) goto bc_out; @@ -217,7 +217,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) break; /* Not woken yet. Maybe the time expired? */ - if (__builtin_expect (err == -ETIMEDOUT, 0)) + if (__glibc_unlikely (err == -ETIMEDOUT)) { timeout: /* Yep. Adjust the counters. */ diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index 6222d92..9d2dfce 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -119,7 +119,7 @@ __pthread_cond_wait (cond, mutex) /* Now we can release the mutex. */ err = __pthread_mutex_unlock_usercnt (mutex, 0); - if (__builtin_expect (err, 0)) + if (__glibc_unlikely (err)) { lll_unlock (cond->__data.__lock, pshared); return err; diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 9d7f52f..cee0806 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -211,7 +211,7 @@ __free_tcb (struct pthread *pd) abort (); /* Free TPP data. */ - if (__builtin_expect (pd->tpp != NULL, 0)) + if (__glibc_unlikely (pd->tpp != NULL)) { struct priority_protection_data *tpp = pd->tpp; @@ -246,7 +246,7 @@ start_thread (void *arg) __ctype_init (); /* Allow setxid from now onwards. */ - if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0) == -2, 0)) + if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2)) lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE); #ifdef __NR_set_robust_list @@ -265,7 +265,7 @@ start_thread (void *arg) /* If the parent was running cancellation handlers while creating the thread the new thread inherited the signal mask. Reset the cancellation signal mask. */ - if (__builtin_expect (pd->parent_cancelhandling & CANCELING_BITMASK, 0)) + if (__glibc_unlikely (pd->parent_cancelhandling & CANCELING_BITMASK)) { INTERNAL_SYSCALL_DECL (err); sigset_t mask; @@ -285,12 +285,12 @@ start_thread (void *arg) int not_first_call; not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf); - if (__builtin_expect (! not_first_call, 1)) + if (__glibc_likely (! not_first_call)) { /* Store the new cleanup handler info. */ THREAD_SETMEM (pd, cleanup_jmp_buf, &unwind_buf); - if (__builtin_expect (pd->stopped_start, 0)) + if (__glibc_unlikely (pd->stopped_start)) { int oldtype = CANCEL_ASYNC (); @@ -327,12 +327,12 @@ start_thread (void *arg) /* If this is the last thread we terminate the process now. We do not notify the debugger, it might just irritate it if there is no thread left. */ - if (__builtin_expect (atomic_decrement_and_test (&__nptl_nthreads), 0)) + if (__glibc_unlikely (atomic_decrement_and_test (&__nptl_nthreads))) /* This was the last thread. */ exit (0); /* Report the death of the thread if this is wanted. */ - if (__builtin_expect (pd->report_events, 0)) + if (__glibc_unlikely (pd->report_events)) { /* See whether TD_DEATH is in any of the mask. */ const int idx = __td_eventword (TD_DEATH); @@ -412,7 +412,7 @@ start_thread (void *arg) if (IS_DETACHED (pd)) /* Free the TCB. */ __free_tcb (pd); - else if (__builtin_expect (pd->cancelhandling & SETXID_BITMASK, 0)) + else if (__glibc_unlikely (pd->cancelhandling & SETXID_BITMASK)) { /* Some other thread might call any of the setXid functions and expect us to reply. In this case wait until we did that. */ @@ -482,7 +482,7 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg) int err = ALLOCATE_STACK (iattr, &pd); int retval = 0; - if (__builtin_expect (err != 0, 0)) + if (__glibc_unlikely (err != 0)) /* Something went wrong. Maybe a parameter of the attributes is invalid or we could not allocate memory. Note we have to translate error codes. */ diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index e79f282..21110c3 100644 --- a/nptl/pthread_getattr_np.c +++ b/nptl/pthread_getattr_np.c @@ -57,7 +57,7 @@ pthread_getattr_np (thread_id, attr) iattr->guardsize = thread->reported_guardsize; /* The sizes are subject to alignment. */ - if (__builtin_expect (thread->stackblock != NULL, 1)) + if (__glibc_likely (thread->stackblock != NULL)) { iattr->stacksize = thread->stackblock_size; iattr->stackaddr = (char *) thread->stackblock + iattr->stacksize; diff --git a/nptl/pthread_getspecific.c b/nptl/pthread_getspecific.c index e0e7dac..e0cc199 100644 --- a/nptl/pthread_getspecific.c +++ b/nptl/pthread_getspecific.c @@ -28,7 +28,7 @@ __pthread_getspecific (key) /* Special case access to the first 2nd-level block. This is the usual case. */ - if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1)) + if (__glibc_likely (key < PTHREAD_KEY_2NDLEVEL_SIZE)) data = &THREAD_SELF->specific_1stblock[key]; else { @@ -58,7 +58,7 @@ __pthread_getspecific (key) { uintptr_t seq = data->seq; - if (__builtin_expect (seq != __pthread_keys[key].seq, 0)) + if (__glibc_unlikely (seq != __pthread_keys[key].seq)) result = data->data = NULL; } diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c index 69f844a..5a43182 100644 --- a/nptl/pthread_join.c +++ b/nptl/pthread_join.c @@ -99,7 +99,7 @@ pthread_join (threadid, thread_return) pthread_cleanup_pop (0); - if (__builtin_expect (result == 0, 1)) + if (__glibc_likely (result == 0)) { /* We mark the thread as terminated and as joined. */ pd->tid = -1; diff --git a/nptl/pthread_key_delete.c b/nptl/pthread_key_delete.c index a79a0ea..d2981b8 100644 --- a/nptl/pthread_key_delete.c +++ b/nptl/pthread_key_delete.c @@ -27,7 +27,7 @@ pthread_key_delete (key) { int result = EINVAL; - if (__builtin_expect (key < PTHREAD_KEYS_MAX, 1)) + if (__glibc_likely (key < PTHREAD_KEYS_MAX)) { unsigned int seq = __pthread_keys[key].seq; diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index d67dcdb..2b34688 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -59,7 +59,7 @@ __pthread_mutex_init (mutex, mutexattr) case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT: #ifndef __ASSUME_FUTEX_LOCK_PI - if (__builtin_expect (tpi_supported == 0, 0)) + if (__glibc_unlikely (tpi_supported == 0)) { int lock = 0; INTERNAL_SYSCALL_DECL (err); @@ -68,7 +68,7 @@ __pthread_mutex_init (mutex, mutexattr) assert (INTERNAL_SYSCALL_ERROR_P (ret, err)); tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1; } - if (__builtin_expect (tpi_supported < 0, 0)) + if (__glibc_unlikely (tpi_supported < 0)) return ENOTSUP; #endif break; diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index add76e8..2c31777 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -71,7 +71,7 @@ __pthread_mutex_lock (mutex) | PTHREAD_MUTEX_ELISION_FLAGS_NP), 0)) return __pthread_mutex_lock_full (mutex); - if (__builtin_expect (type == PTHREAD_MUTEX_TIMED_NP, 1)) + if (__glibc_likely (type == PTHREAD_MUTEX_TIMED_NP)) { FORCE_ELISION (mutex, goto elision); simple: @@ -80,7 +80,7 @@ __pthread_mutex_lock (mutex) assert (mutex->__data.__owner == 0); } #ifdef HAVE_ELISION - else if (__builtin_expect (type == PTHREAD_MUTEX_TIMED_ELISION_NP, 1)) + else if (__glibc_likely (type == PTHREAD_MUTEX_TIMED_ELISION_NP)) { elision: __attribute__((unused)) /* This case can never happen on a system without elision, @@ -101,7 +101,7 @@ __pthread_mutex_lock (mutex) if (mutex->__data.__owner == id) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -150,7 +150,7 @@ __pthread_mutex_lock (mutex) pid_t id = THREAD_GETMEM (THREAD_SELF, tid); assert (PTHREAD_MUTEX_TYPE (mutex) == PTHREAD_MUTEX_ERRORCHECK_NP); /* Check whether we already hold the mutex. */ - if (__builtin_expect (mutex->__data.__owner == id, 0)) + if (__glibc_unlikely (mutex->__data.__owner == id)) return EDEADLK; goto simple; } @@ -229,7 +229,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) } /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { int kind = PTHREAD_MUTEX_TYPE (mutex); if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP) @@ -245,7 +245,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -296,7 +296,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) oldval = mutex->__data.__lock; /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { if (kind == PTHREAD_MUTEX_ERRORCHECK_NP) { @@ -309,7 +309,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -359,7 +359,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) assert (robust || (oldval & FUTEX_OWNER_DIED) == 0); } - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); @@ -427,7 +427,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) if (kind == PTHREAD_MUTEX_RECURSIVE_NP) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 8e7a52b..0361923 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -61,7 +61,7 @@ pthread_mutex_timedlock (mutex, abstime) if (mutex->__data.__owner == id) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -84,7 +84,7 @@ pthread_mutex_timedlock (mutex, abstime) /* Error checking mutex. */ case PTHREAD_MUTEX_ERRORCHECK_NP: /* Check whether we already hold the mutex. */ - if (__builtin_expect (mutex->__data.__owner == id, 0)) + if (__glibc_unlikely (mutex->__data.__owner == id)) return EDEADLK; /* FALLTHROUGH */ @@ -175,7 +175,7 @@ pthread_mutex_timedlock (mutex, abstime) } /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { int kind = PTHREAD_MUTEX_TYPE (mutex); if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP) @@ -191,7 +191,7 @@ pthread_mutex_timedlock (mutex, abstime) NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -250,7 +250,7 @@ pthread_mutex_timedlock (mutex, abstime) oldval = mutex->__data.__lock; /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { if (kind == PTHREAD_MUTEX_ERRORCHECK_NP) { @@ -263,7 +263,7 @@ pthread_mutex_timedlock (mutex, abstime) THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -337,7 +337,7 @@ pthread_mutex_timedlock (mutex, abstime) assert (robust || (oldval & FUTEX_OWNER_DIED) == 0); } - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); @@ -400,7 +400,7 @@ pthread_mutex_timedlock (mutex, abstime) if (kind == PTHREAD_MUTEX_RECURSIVE_NP) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 4d5f75d..e46f22c 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -50,7 +50,7 @@ __pthread_mutex_trylock (mutex) if (mutex->__data.__owner == id) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -133,7 +133,7 @@ __pthread_mutex_trylock (mutex) } /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { int kind = PTHREAD_MUTEX_TYPE (mutex); if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP) @@ -149,7 +149,7 @@ __pthread_mutex_trylock (mutex) NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -211,7 +211,7 @@ __pthread_mutex_trylock (mutex) oldval = mutex->__data.__lock; /* Check whether we already hold the mutex. */ - if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0)) + if (__glibc_unlikely ((oldval & FUTEX_TID_MASK) == id)) { if (kind == PTHREAD_MUTEX_ERRORCHECK_NP) { @@ -224,7 +224,7 @@ __pthread_mutex_trylock (mutex) THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; @@ -270,7 +270,7 @@ __pthread_mutex_trylock (mutex) oldval = mutex->__data.__lock; } - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); @@ -337,7 +337,7 @@ __pthread_mutex_trylock (mutex) if (kind == PTHREAD_MUTEX_RECURSIVE_NP) { /* Just bump the counter. */ - if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) + if (__glibc_unlikely (mutex->__data.__count + 1 == 0)) /* Overflow of the counter. */ return EAGAIN; diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 8fe5b67..95ae933 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -60,7 +60,7 @@ __pthread_mutex_unlock_usercnt (mutex, decr) return 0; } - else if (__builtin_expect (type == PTHREAD_MUTEX_TIMED_ELISION_NP, 1)) + else if (__glibc_likely (type == PTHREAD_MUTEX_TIMED_ELISION_NP)) { /* Don't reset the owner/users fields for elision. */ return lll_unlock_elision (mutex->__data.__lock, diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c index a06c3f2..3773f7d 100644 --- a/nptl/pthread_rwlock_rdlock.c +++ b/nptl/pthread_rwlock_rdlock.c @@ -45,7 +45,7 @@ __pthread_rwlock_rdlock (rwlock) || PTHREAD_RWLOCK_PREFER_READER_P (rwlock))) { /* Increment the reader counter. Avoid overflow. */ - if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) + if (__glibc_unlikely (++rwlock->__data.__nr_readers == 0)) { /* Overflow on number of readers. */ --rwlock->__data.__nr_readers; @@ -67,7 +67,7 @@ __pthread_rwlock_rdlock (rwlock) } /* Remember that we are a reader. */ - if (__builtin_expect (++rwlock->__data.__nr_readers_queued == 0, 0)) + if (__glibc_unlikely (++rwlock->__data.__nr_readers_queued == 0)) { /* Overflow on number of queued readers. */ --rwlock->__data.__nr_readers_queued; diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c index 770cc34..81b2ee4 100644 --- a/nptl/pthread_rwlock_timedrdlock.c +++ b/nptl/pthread_rwlock_timedrdlock.c @@ -78,7 +78,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime) /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ - if (__builtin_expect (abstime->tv_sec < 0, 0)) + if (__glibc_unlikely (abstime->tv_sec < 0)) { result = ETIMEDOUT; break; diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c index 2e1390b..26f2139 100644 --- a/nptl/pthread_rwlock_timedwrlock.c +++ b/nptl/pthread_rwlock_timedwrlock.c @@ -69,7 +69,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime) /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ - if (__builtin_expect (abstime->tv_sec < 0, 0)) + if (__glibc_unlikely (abstime->tv_sec < 0)) { result = ETIMEDOUT; break; diff --git a/nptl/pthread_rwlock_tryrdlock.c b/nptl/pthread_rwlock_tryrdlock.c index 697aa80..f7b1e6b 100644 --- a/nptl/pthread_rwlock_tryrdlock.c +++ b/nptl/pthread_rwlock_tryrdlock.c @@ -32,7 +32,7 @@ __pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) && (rwlock->__data.__nr_writers_queued == 0 || PTHREAD_RWLOCK_PREFER_READER_P (rwlock))) { - if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) + if (__glibc_unlikely (++rwlock->__data.__nr_readers == 0)) { --rwlock->__data.__nr_readers; result = EAGAIN; diff --git a/nptl/pthread_setcancelstate.c b/nptl/pthread_setcancelstate.c index 3bb0503..5c3ca86 100644 --- a/nptl/pthread_setcancelstate.c +++ b/nptl/pthread_setcancelstate.c @@ -55,7 +55,7 @@ __pthread_setcancelstate (state, oldstate) atomically since other bits could be modified as well. */ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) { if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) __do_cancel (); diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c index 0a7691f..fb1631f 100644 --- a/nptl/pthread_setcanceltype.c +++ b/nptl/pthread_setcanceltype.c @@ -55,7 +55,7 @@ __pthread_setcanceltype (type, oldtype) atomically since other bits could be modified as well. */ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, oldval); - if (__builtin_expect (curval == oldval, 1)) + if (__glibc_likely (curval == oldval)) { if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) { diff --git a/nptl/pthread_setschedprio.c b/nptl/pthread_setschedprio.c index 033bfec..c58ba94 100644 --- a/nptl/pthread_setschedprio.c +++ b/nptl/pthread_setschedprio.c @@ -48,7 +48,7 @@ pthread_setschedprio (threadid, prio) param.sched_priority = pd->tpp->priomax; /* Try to set the scheduler information. */ - if (__builtin_expect (sched_setparam (pd->tid, ¶m) == -1, 0)) + if (__glibc_unlikely (sched_setparam (pd->tid, ¶m) == -1)) result = errno; else { diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c index 877fb02..0ace861 100644 --- a/nptl/pthread_setspecific.c +++ b/nptl/pthread_setspecific.c @@ -36,7 +36,7 @@ __pthread_setspecific (key, value) /* Special case access to the first 2nd-level block. This is the usual case. */ - if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1)) + if (__glibc_likely (key < PTHREAD_KEY_2NDLEVEL_SIZE)) { /* Verify the key is sane. */ if (KEY_UNUSED ((seq = __pthread_keys[key].seq))) diff --git a/nptl/sem_init.c b/nptl/sem_init.c index 8bfb9c1..7af2775 100644 --- a/nptl/sem_init.c +++ b/nptl/sem_init.c @@ -31,7 +31,7 @@ __new_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; @@ -66,7 +66,7 @@ __old_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; diff --git a/nptl/sem_open.c b/nptl/sem_open.c index b57e6b7..cf91859 100644 --- a/nptl/sem_open.c +++ b/nptl/sem_open.c @@ -74,10 +74,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; } diff --git a/nptl/sigaction.c b/nptl/sigaction.c index 33cf9ad..7b01bfc 100644 --- a/nptl/sigaction.c +++ b/nptl/sigaction.c @@ -34,7 +34,7 @@ __sigaction (sig, act, oact) const struct sigaction *act; struct sigaction *oact; { - if (__builtin_expect (sig == SIGCANCEL || sig == SIGSETXID, 0)) + if (__glibc_unlikely (sig == SIGCANCEL || sig == SIGSETXID)) { __set_errno (EINVAL); return -1; diff --git a/nptl/sockperf.c b/nptl/sockperf.c index d29a6ee..740fb88 100644 --- a/nptl/sockperf.c +++ b/nptl/sockperf.c @@ -479,7 +479,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. */ @@ -491,7 +491,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/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c index 2a9a723..93f93ee 100644 --- a/nptl/sysdeps/pthread/createthread.c +++ b/nptl/sysdeps/pthread/createthread.c @@ -56,7 +56,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, PREPARE_CREATE; #endif - if (__builtin_expect (stopped != 0, 0)) + if (__glibc_unlikely (stopped != 0)) /* We make sure the thread does not run far by forcing it to get a lock. We lock it here too so that the new thread cannot continue until we tell it to. */ @@ -75,7 +75,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, int rc = ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags, pd, &pd->tid, TLS_VALUE, &pd->tid); - if (__builtin_expect (rc == -1, 0)) + if (__glibc_unlikely (rc == -1)) { atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second. */ @@ -93,7 +93,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, } /* Now we have the possibility to set scheduling parameters etc. */ - if (__builtin_expect (stopped != 0, 0)) + if (__glibc_unlikely (stopped != 0)) { INTERNAL_SYSCALL_DECL (err); int res = 0; @@ -104,7 +104,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid, attr->cpusetsize, attr->cpuset); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) { /* The operation failed. We have to kill the thread. First send it the cancellation signal. */ @@ -129,7 +129,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, res = INTERNAL_SYSCALL (sched_setscheduler, err, 3, pd->tid, pd->schedpolicy, &pd->schedparam); - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))) goto err_out; } } @@ -183,7 +183,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, | CLONE_CHILD_CLEARTID | CLONE_SYSVSEM | 0); - if (__builtin_expect (THREAD_GETMEM (THREAD_SELF, report_events), 0)) + if (__glibc_unlikely (THREAD_GETMEM (THREAD_SELF, report_events))) { /* The parent thread is supposed to report events. Check whether the TD_CREATE event is needed, too. */ diff --git a/nptl/sysdeps/pthread/setxid.h b/nptl/sysdeps/pthread/setxid.h index 65a1ce7..76c88e0 100644 --- a/nptl/sysdeps/pthread/setxid.h +++ b/nptl/sysdeps/pthread/setxid.h @@ -48,7 +48,7 @@ ({ \ extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\ int __result; \ - if (__builtin_expect (__nptl_setxid != NULL, 0)) \ + if (__glibc_unlikely (__nptl_setxid != NULL)) \ { \ struct xid_command __cmd; \ __cmd.syscall_no = __NR_##name; \ diff --git a/nptl/sysdeps/pthread/timer_create.c b/nptl/sysdeps/pthread/timer_create.c index 359a770..461d28e 100644 --- a/nptl/sysdeps/pthread/timer_create.c +++ b/nptl/sysdeps/pthread/timer_create.c @@ -68,7 +68,7 @@ timer_create (clock_id, evp, timerid) pthread_mutex_lock (&__timer_mutex); newtimer = __timer_alloc (); - if (__builtin_expect (newtimer == NULL, 0)) + if (__glibc_unlikely (newtimer == NULL)) { __set_errno (EAGAIN); goto unlock_bail; @@ -123,7 +123,7 @@ timer_create (clock_id, evp, timerid) thread = __timer_thread_alloc (&newtimer->attr, clock_id); /* Out of luck; no threads are available. */ - if (__builtin_expect (thread == NULL, 0)) + if (__glibc_unlikely (thread == NULL)) { __set_errno (EAGAIN); goto unlock_bail; diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c index cb94ea6..9d7bdc5 100644 --- a/nptl/sysdeps/pthread/unwind-forcedunwind.c +++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c @@ -42,7 +42,7 @@ pthread_cancel_init (void) void *getcfa; void *handle; - if (__builtin_expect (libgcc_s_handle != NULL, 1)) + if (__glibc_likely (libgcc_s_handle != NULL)) { /* Force gcc to reload all values. */ asm volatile ("" ::: "memory"); @@ -93,7 +93,7 @@ __unwind_freeres (void) void _Unwind_Resume (struct _Unwind_Exception *exc) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -109,7 +109,7 @@ __gcc_personality_v0 (int version, _Unwind_Action actions, struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -125,7 +125,7 @@ _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, void *stop_argument) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); @@ -140,7 +140,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_handle == NULL, 0)) + if (__glibc_unlikely (libgcc_s_handle == NULL)) pthread_cancel_init (); else atomic_read_barrier (); diff --git a/nptl/sysdeps/unix/sysv/linux/getpid.c b/nptl/sysdeps/unix/sysv/linux/getpid.c index f806f2f..937b1d4 100644 --- a/nptl/sysdeps/unix/sysv/linux/getpid.c +++ b/nptl/sysdeps/unix/sysv/linux/getpid.c @@ -27,10 +27,10 @@ static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval); static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval) { - if (__builtin_expect (oldval == 0, 1)) + if (__glibc_likely (oldval == 0)) { pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid); - if (__builtin_expect (selftid != 0, 1)) + if (__glibc_likely (selftid != 0)) return selftid; } @@ -53,7 +53,7 @@ __getpid (void) pid_t result = INTERNAL_SYSCALL (getpid, err, 0); #else pid_t result = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (result <= 0, 0)) + if (__glibc_unlikely (result <= 0)) result = really_getpid (result); #endif return result; diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c index 5c9ada1..c894b1e 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c @@ -35,7 +35,7 @@ __lll_robust_lock_wait (int *futex, int private) do { - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) return oldval; int newval = oldval | FUTEX_WAITERS; @@ -72,7 +72,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ - if (__builtin_expect (abstime->tv_sec < 0, 0)) + if (__glibc_unlikely (abstime->tv_sec < 0)) return ETIMEDOUT; do @@ -100,7 +100,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, #endif /* Wait. */ - if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) return oldval; int newval = oldval | FUTEX_WAITERS; diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c index 0d20919..3138ad2 100644 --- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c +++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c @@ -266,7 +266,7 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) /* If we cannot create the netlink socket we cannot provide SIGEV_THREAD support. */ - if (__builtin_expect (netlink_socket == -1, 0)) + if (__glibc_unlikely (netlink_socket == -1)) { __set_errno (ENOSYS); return -1; @@ -299,7 +299,7 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) int retval = INLINE_SYSCALL (mq_notify, 2, mqdes, &se); /* If it failed, free the allocated memory. */ - if (__builtin_expect (retval != 0, 0)) + if (__glibc_unlikely (retval != 0)) free (data.attr); return retval; diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index fe85670..ab92c3f 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -306,7 +306,7 @@ extern int __lll_robust_timedlock_wait ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val > 1, 0)) \ + if (__glibc_unlikely (__val > 1)) \ lll_futex_wake (__futex, 1, private); \ })) @@ -314,7 +314,7 @@ extern int __lll_robust_timedlock_wait ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__val & FUTEX_WAITERS)) \ lll_futex_wake (__futex, 1, private); \ })) diff --git a/nptl/sysdeps/unix/sysv/linux/pt-raise.c b/nptl/sysdeps/unix/sysv/linux/pt-raise.c index 68059db..74762b7 100644 --- a/nptl/sysdeps/unix/sysv/linux/pt-raise.c +++ b/nptl/sysdeps/unix/sysv/linux/pt-raise.c @@ -31,7 +31,7 @@ raise (sig) fork function temporarily invalidated the PID field. Adjust for that. */ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (pid < 0, 0)) + if (__glibc_unlikely (pid < 0)) pid = -pid; return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid), diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c index 43e5c02..f8957ae 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c @@ -40,7 +40,7 @@ __pthread_kill (threadid, signo) if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */ pid_t tid = atomic_forced_read (pd->tid); - if (__builtin_expect (tid <= 0, 0)) + if (__glibc_unlikely (tid <= 0)) /* Not a valid thread handle. */ return ESRCH; diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c index 288d73f..874cf4b 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c @@ -61,7 +61,7 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize, INTERNAL_SYSCALL_DECL (err); int res; - if (__builtin_expect (__kernel_cpumask_size == 0, 0)) + if (__glibc_unlikely (__kernel_cpumask_size == 0)) { res = __determine_cpumask_size (pd->tid); if (res != 0) diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c index 9c3e73c..8dee3a6 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c @@ -44,7 +44,7 @@ pthread_sigqueue (threadid, signo, value) if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */ pid_t tid = atomic_forced_read (pd->tid); - if (__builtin_expect (tid <= 0, 0)) + if (__glibc_unlikely (tid <= 0)) /* Not a valid thread handle. */ return ESRCH; diff --git a/nptl/sysdeps/unix/sysv/linux/raise.c b/nptl/sysdeps/unix/sysv/linux/raise.c index 321d9c3..67c9b1f 100644 --- a/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/nptl/sysdeps/unix/sysv/linux/raise.c @@ -50,7 +50,7 @@ raise (sig) /* raise is an async-safe function. It could be called while the fork/vfork function temporarily invalidated the PID field. Adjust for that. */ - if (__builtin_expect (pid <= 0, 0)) + if (__glibc_unlikely (pid <= 0)) pid = (pid & INT_MAX) == 0 ? selftid : -pid; return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h index 80dc905..864dcbc 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h @@ -233,7 +233,7 @@ static inline void __attribute__ ((always_inline)) __lll_lock (int *futex, int private) { - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 1, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 1, 0))) { if (__builtin_constant_p (private) && private == LLL_PRIVATE) __lll_lock_wait_private (futex); @@ -260,7 +260,7 @@ static inline void __attribute__ ((always_inline)) __lll_cond_lock (int *futex, int private) { - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 2, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 2, 0))) __lll_lock_wait (futex, private); } #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) @@ -278,7 +278,7 @@ __attribute__ ((always_inline)) __lll_timedlock (int *futex, const struct timespec *abstime, int private) { int result = 0; - if (__builtin_expect (atomic_compare_and_exchange_bool_acq (futex, 1, 0), 0)) + if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 1, 0))) result = __lll_timedlock_wait (futex, abstime, private); return result; } @@ -307,7 +307,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, int *__futexp = (futex); \ \ lll_compare_and_swap (__futexp, __oldval, __newval, "slr %2,%2"); \ - if (__builtin_expect (__oldval > 1, 0)) \ + if (__glibc_unlikely (__oldval > 1)) \ lll_futex_wake (__futexp, 1, private); \ }) #define lll_unlock(futex, private) __lll_unlock(&(futex), private) @@ -320,7 +320,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, int *__futexp = (futex); \ \ lll_compare_and_swap (__futexp, __oldval, __newval, "slr %2,%2"); \ - if (__builtin_expect (__oldval & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__oldval & FUTEX_WAITERS)) \ lll_futex_wake (__futexp, 1, private); \ }) #define lll_robust_unlock(futex, private) \ diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h index d851d74..d4ed7a9 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h @@ -223,7 +223,7 @@ __lll_lock (int *futex, int private) { int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0); - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) { if (__builtin_constant_p (private) && private == LLL_PRIVATE) __lll_lock_wait_private (futex); @@ -251,7 +251,7 @@ __lll_cond_lock (int *futex, int private) { int val = atomic_compare_and_exchange_val_24_acq (futex, 2, 0); - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) __lll_lock_wait (futex, private); } #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) @@ -272,7 +272,7 @@ __lll_timedlock (int *futex, const struct timespec *abstime, int private) int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0); int result = 0; - if (__builtin_expect (val != 0, 0)) + if (__glibc_unlikely (val != 0)) result = __lll_timedlock_wait (futex, abstime, private); return result; } @@ -296,7 +296,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_24_rel (__futex, 0); \ - if (__builtin_expect (__val > 1, 0)) \ + if (__glibc_unlikely (__val > 1)) \ lll_futex_wake (__futex, 1, private); \ })) @@ -304,7 +304,7 @@ __lll_robust_timedlock (int *futex, const struct timespec *abstime, ((void) ({ \ int *__futex = &(lock); \ int __val = atomic_exchange_rel (__futex, 0); \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + if (__glibc_unlikely (__val & FUTEX_WAITERS)) \ lll_futex_wake (__futex, 1, private); \ })) diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c index 4ce7871..2221a27 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c @@ -33,7 +33,7 @@ pthread_barrier_destroy (barrier) lll_lock (ibarrier->b.lock, private); - if (__builtin_expect (ibarrier->b.left == ibarrier->b.init_count, 1)) + if (__glibc_likely (ibarrier->b.left == ibarrier->b.init_count)) /* The barrier is not used anymore. */ result = 0; else diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c index 9bc7a05..6af6863 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c @@ -28,7 +28,7 @@ pthread_barrier_init (barrier, attr, count) { union sparc_pthread_barrier *ibarrier; - if (__builtin_expect (count == 0, 0)) + if (__glibc_unlikely (count == 0)) return EINVAL; struct pthread_barrierattr *iattr = (struct pthread_barrierattr *) attr; diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c index d415366..cbefdc4 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c @@ -32,7 +32,7 @@ __new_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; @@ -66,7 +66,7 @@ __old_sem_init (sem, pshared, value) unsigned int value; { /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) + if (__glibc_unlikely (value > SEM_VALUE_MAX)) { __set_errno (EINVAL); return -1; diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c index e46eef4..7624f2c 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/timer_create.c @@ -50,7 +50,7 @@ __timer_create_old (clockid_t clock_id, struct sigevent *evp, int *timerid) break; } - if (__builtin_expect (i == OLD_TIMER_MAX, 0)) + if (__glibc_unlikely (i == OLD_TIMER_MAX)) { /* No free slot. */ (void) __timer_delete_new (newp); diff --git a/nptl/unwind.c b/nptl/unwind.c index fb2489c..a71015a 100644 --- a/nptl/unwind.c +++ b/nptl/unwind.c @@ -62,7 +62,7 @@ unwind_stop (int version, _Unwind_Action actions, adj)) do_longjump = 1; - if (__builtin_expect (curp != NULL, 0)) + if (__glibc_unlikely (curp != NULL)) { /* Handle the compatibility stuff. Execute all handlers registered with the old method which would be unwound by this diff --git a/nscd/aicache.c b/nscd/aicache.c index d6b928c..98d40a1 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -77,7 +77,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, char strdata[0]; } *dataset = NULL; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in hosts cache!"), (char *) key); @@ -434,7 +434,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, struct dataset *newp = (struct dataset *) mempool_alloc (db, total + req->key_len, 1); - if (__builtin_expect (newp != NULL, 1)) + if (__glibc_likely (newp != NULL)) { /* Adjust pointer into the memory block. */ key_copy = (char *) newp + (key_copy - (char *) dataset); diff --git a/nscd/cache.c b/nscd/cache.c index 2c35a34..5e8a42f 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -138,7 +138,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet, bool first, struct database_dyn *table, uid_t owner, bool prune_wakeup) { - if (__builtin_expect (debug_level >= 2, 0)) + if (__glibc_unlikely (debug_level >= 2)) { const char *str; char buf[INET6_ADDRSTRLEN + 1]; @@ -311,7 +311,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) bool *mark; size_t memory_needed = cnt * sizeof (bool); bool mark_use_alloca; - if (__builtin_expect (memory_needed <= MAX_STACK_USE, 1)) + if (__glibc_likely (memory_needed <= MAX_STACK_USE)) { mark = alloca (cnt * sizeof (bool)); memset (mark, '\0', memory_needed); @@ -327,7 +327,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) char *const data = table->data; bool any = false; - if (__builtin_expect (debug_level > 2, 0)) + if (__glibc_unlikely (debug_level > 2)) dbg_log (_("pruning %s cache; time %ld"), dbnames[table - dbs], (long int) now); @@ -343,7 +343,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) struct datahead *dh = (struct datahead *) (data + runp->packet); /* Some debug support. */ - if (__builtin_expect (debug_level > 2, 0)) + if (__glibc_unlikely (debug_level > 2)) { char buf[INET6_ADDRSTRLEN]; const char *str; @@ -422,7 +422,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) } while (cnt > 0); - if (__builtin_expect (fd != -1, 0)) + if (__glibc_unlikely (fd != -1)) { /* Reply to the INVALIDATE initiator that the cache has been invalidated. */ @@ -436,7 +436,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) /* Now we have to get the write lock since we are about to modify the table. */ - if (__builtin_expect (pthread_rwlock_trywrlock (&table->lock) != 0, 0)) + if (__glibc_unlikely (pthread_rwlock_trywrlock (&table->lock) != 0)) { ++table->head->wrlockdelayed; pthread_rwlock_wrlock (&table->lock); @@ -492,7 +492,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) MS_ASYNC); /* One extra pass if we do debugging. */ - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { struct hashentry *runp = head; @@ -517,7 +517,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd) } } - if (__builtin_expect (! mark_use_alloca, 0)) + if (__glibc_unlikely (! mark_use_alloca)) free (mark); /* Run garbage collection if any entry has been removed or replaced. */ diff --git a/nscd/connections.c b/nscd/connections.c index f3732f5..f463f45 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -999,7 +999,7 @@ register_traced_file (size_t dbidx, struct traced_file *finfo) if (! dbs[dbidx].enabled || ! dbs[dbidx].check_file) return; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) dbg_log (_("register trace file %s for database %s"), finfo->fname, dbnames[dbidx]); @@ -1129,7 +1129,7 @@ send_ro_fd (struct database_dyn *db, char *key, int fd) #endif (void) TEMP_FAILURE_RETRY (sendmsg (fd, &msg, MSG_NOSIGNAL)); - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) dbg_log (_("provide access to FD %d, for %s"), db->ro_fd, key); } #endif /* SCM_RIGHTS */ @@ -1201,7 +1201,7 @@ request from '%s' [%ld] not handled due to missing permission"), } /* Is this service enabled? */ - if (__builtin_expect (!db->enabled, 0)) + if (__glibc_unlikely (!db->enabled)) { /* No, sent the prepared record. */ if (TEMP_FAILURE_RETRY (send (fd, db->disabled_iov->iov_base, @@ -1220,7 +1220,7 @@ request from '%s' [%ld] not handled due to missing permission"), } /* Be sure we can read the data. */ - if (__builtin_expect (pthread_rwlock_tryrdlock (&db->lock) != 0, 0)) + if (__glibc_unlikely (pthread_rwlock_tryrdlock (&db->lock) != 0)) { ++db->head->rdlockdelayed; pthread_rwlock_rdlock (&db->lock); @@ -1236,7 +1236,7 @@ request from '%s' [%ld] not handled due to missing permission"), ssize_t nwritten; #ifdef HAVE_SENDFILE - if (__builtin_expect (db->mmap_used, 1)) + if (__glibc_likely (db->mmap_used)) { assert (db->wr_fd != -1); assert ((char *) cached->data > (char *) db->data); @@ -1603,7 +1603,7 @@ nscd_run_prune (void *p) dbs[my_number].head->timestamp = now; struct timespec prune_ts; - if (__builtin_expect (clock_gettime (timeout_clock, &prune_ts) == -1, 0)) + if (__glibc_unlikely (clock_gettime (timeout_clock, &prune_ts) == -1)) /* Should never happen. */ abort (); @@ -1656,7 +1656,7 @@ nscd_run_prune (void *p) we need to wake up occasionally to update the timestamp. Wait 90% of the update period. */ #define UPDATE_MAPPING_TIMEOUT (MAPPING_TIMEOUT * 9 / 10) - if (__builtin_expect (! dont_need_update, 0)) + if (__glibc_unlikely (! dont_need_update)) { next_wait = MIN (UPDATE_MAPPING_TIMEOUT, next_wait); dbs[my_number].head->timestamp = now; @@ -1756,7 +1756,7 @@ nscd_run_worker (void *p) #ifdef SO_PEERCRED pid_t pid = 0; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { struct ucred caller; socklen_t optlen = sizeof (caller); @@ -1849,7 +1849,7 @@ fd_ready (int fd) } bool do_signal = true; - if (__builtin_expect (nready == 0, 0)) + if (__glibc_unlikely (nready == 0)) { ++client_queued; do_signal = false; @@ -2264,7 +2264,7 @@ main_loop_epoll (int efd) sizeof (inev))); if (nb < (ssize_t) sizeof (struct inotify_event)) { - if (__builtin_expect (nb == -1 && errno != EAGAIN, 0)) + if (__glibc_unlikely (nb == -1 && errno != EAGAIN)) { /* Something went wrong when reading the inotify data. Better disable inotify. */ diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 8f5d39b..b5a33eb 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -452,7 +452,7 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req, bool use_malloc = false; int errval = 0; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in group cache!"), keystr); @@ -465,7 +465,7 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req, { errno = 0; - if (__builtin_expect (buflen > 32768, 0)) + if (__glibc_unlikely (buflen > 32768)) { char *old_buffer = buffer; buflen *= 2; diff --git a/nscd/hstcache.c b/nscd/hstcache.c index abedf9a..a79b67a 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -480,7 +480,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, int errval = 0; int32_t ttl = INT32_MAX; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { const char *str; char buf[INET6_ADDRSTRLEN + 1]; @@ -502,7 +502,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, { errno = 0; - if (__builtin_expect (buflen > 32768, 0)) + if (__glibc_unlikely (buflen > 32768)) { char *old_buffer = buffer; buflen *= 2; diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index a727fa9..1bf9f0d 100644 --- a/nscd/initgrcache.c +++ b/nscd/initgrcache.c @@ -71,7 +71,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, char strdata[0]; } *dataset = NULL; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in group cache!"), (char *) key); @@ -112,7 +112,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, mempool_alloc. */ // XXX This really should use alloca. need to change the backends. gid_t *groups = (gid_t *) malloc (size * sizeof (gid_t)); - if (__builtin_expect (groups == NULL, 0)) + if (__glibc_unlikely (groups == NULL)) /* No more memory. */ goto out; diff --git a/nscd/mem.c b/nscd/mem.c index 0d09e21..b4090fb 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -124,11 +124,11 @@ gc (struct database_dyn *db) /* In prune_cache we are also using a dynamically allocated array. If the array in the caller is too large we have malloc'ed it. */ size_t stack_used = sizeof (bool) * db->head->module; - if (__builtin_expect (stack_used > MAX_STACK_USE, 0)) + if (__glibc_unlikely (stack_used > MAX_STACK_USE)) stack_used = 0; size_t nmark = (db->head->first_free / BLOCK_ALIGN + BITS - 1) / BITS; size_t memory_needed = nmark * sizeof (BITMAP_T); - if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1)) + if (__glibc_likely (stack_used + memory_needed <= MAX_STACK_USE)) { mark = (BITMAP_T *) alloca_account (memory_needed, stack_used); mark_use_malloc = false; @@ -146,7 +146,7 @@ gc (struct database_dyn *db) struct hashentry **he; struct hashentry **he_data; bool he_use_malloc; - if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1)) + if (__glibc_likely (stack_used + memory_needed <= MAX_STACK_USE)) { he = alloca_account (memory_needed, stack_used); he_use_malloc = false; @@ -421,7 +421,7 @@ gc (struct database_dyn *db) } while (runp != moves->next); - if (__builtin_expect (debug_level >= 3, 0)) + if (__glibc_unlikely (debug_level >= 3)) dbg_log (_("freed %zu bytes in %s cache"), db->head->first_free - ((char *) moves->to + moves->size - db->data), @@ -432,7 +432,7 @@ gc (struct database_dyn *db) db->head->first_free = (char *) moves->to + moves->size - db->data; /* Consistency check. */ - if (__builtin_expect (debug_level >= 3, 0)) + if (__glibc_unlikely (debug_level >= 3)) { for (size_t idx = 0; idx < db->head->module; ++idx) { @@ -527,7 +527,7 @@ mempool_alloc (struct database_dyn *db, size_t len, int data_alloc) retry: res = db->data + db->head->first_free; - if (__builtin_expect (db->head->first_free + len > db->head->data_size, 0)) + if (__glibc_unlikely (db->head->first_free + len > db->head->data_size)) { if (! tried_resize) { diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index be01fe8..426d3c5 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -120,7 +120,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, const char *key, uid_t uid, struct hashentry *he, struct datahead *dh, struct dataset **resultp) { - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in netgroup cache!"), key); @@ -398,7 +398,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, { struct dataset *newp = (struct dataset *) mempool_alloc (db, total + req->key_len, 1); - if (__builtin_expect (newp != NULL, 1)) + if (__glibc_likely (newp != NULL)) { /* Adjust pointer into the memory block. */ key_copy = (char *) newp + (key_copy - buffer); @@ -494,7 +494,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, key = (char *) rawmemchr (key, '\0') + 1; const char *domain = *key++ ? key : NULL; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s (%s,%s,%s)\" in netgroup cache!"), @@ -531,7 +531,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, 1); struct indataset dataset_mem; bool cacheable = true; - if (__builtin_expect (dataset == NULL, 0)) + if (__glibc_unlikely (dataset == NULL)) { cacheable = false; dataset = &dataset_mem; diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index b5c9f87..98f77e7 100644 --- a/nscd/nscd-client.h +++ b/nscd/nscd-client.h @@ -331,7 +331,7 @@ __nscd_acquire_maplock (volatile struct locked_map_ptr *mapptr) 1, 0) != 0, 0)) { // XXX Best number of rounds? - if (__builtin_expect (++cnt > 5, 0)) + if (__glibc_unlikely (++cnt > 5)) return false; atomic_delay (); @@ -369,7 +369,7 @@ __nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle) if (map != NO_MAPPING) { int now_cycle = map->head->gc_cycle; - if (__builtin_expect (now_cycle != *gc_cycle, 0)) + if (__glibc_unlikely (now_cycle != *gc_cycle)) { /* We might have read inconsistent data. */ *gc_cycle = now_cycle; diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c index 155cfef..328c261 100644 --- a/nscd/nscd_getai.c +++ b/nscd/nscd_getai.c @@ -42,7 +42,7 @@ extern int __nss_have_localdomain attribute_hidden; int __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) { - if (__builtin_expect (__nss_have_localdomain >= 0, 0)) + if (__glibc_unlikely (__nss_have_localdomain >= 0)) { if (__nss_have_localdomain == 0) __nss_have_localdomain = getenv ("LOCALDOMAIN") != NULL ? 1 : -1; @@ -171,7 +171,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) } else { - if (__builtin_expect (ai_resp.found == -1, 0)) + if (__glibc_unlikely (ai_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_hosts = 1; diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c index ed5dc11..d9b91a4 100644 --- a/nscd/nscd_getgr_r.c +++ b/nscd/nscd_getgr_r.c @@ -143,7 +143,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, /* No value found so far. */ *result = NULL; - if (__builtin_expect (gr_resp.found == -1, 0)) + if (__glibc_unlikely (gr_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_group = 1; @@ -164,7 +164,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, & (__alignof__ (char *) - 1)); total_len = (align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *) + gr_resp.gr_name_len + gr_resp.gr_passwd_len); - if (__builtin_expect (buflen < total_len, 0)) + if (__glibc_unlikely (buflen < total_len)) { no_room: __set_errno (ERANGE); @@ -190,7 +190,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, if (gr_name == NULL) { /* Handle a simple, usual case: no group members. */ - if (__builtin_expect (gr_resp.gr_mem_cnt == 0, 1)) + if (__glibc_likely (gr_resp.gr_mem_cnt == 0)) { size_t n = gr_resp.gr_name_len + gr_resp.gr_passwd_len; if (__builtin_expect (__readall (sock, resultbuf->gr_name, n) @@ -217,7 +217,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, /* Get this data. */ size_t n = __readvall (sock, vec, 2); - if (__builtin_expect (n != total_len, 0)) + if (__glibc_unlikely (n != total_len)) goto out_close; } } @@ -239,7 +239,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, p += len[cnt]; } - if (__builtin_expect (gr_name + gr_name_len + total_len > recend, 0)) + if (__glibc_unlikely (gr_name + gr_name_len + total_len > recend)) { /* len array might contain garbage during nscd GC cycle, retry rather than fail in that case. */ @@ -247,7 +247,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, retval = -2; goto out_close; } - if (__builtin_expect (total_len > buflen, 0)) + if (__glibc_unlikely (total_len > buflen)) { /* len array might contain garbage during nscd GC cycle, retry rather than fail in that case. */ diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 3368fc4..fe885ee 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -140,7 +140,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, struct hostent *resultbuf, char *buffer, size_t buflen, struct hostent **result, int *h_errnop) { - if (__builtin_expect (__nss_have_localdomain >= 0, 0)) + if (__glibc_unlikely (__nss_have_localdomain >= 0)) { if (__nss_have_localdomain == 0) __nss_have_localdomain = getenv ("LOCALDOMAIN") != NULL ? 1 : -1; @@ -232,7 +232,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, /* No value found so far. */ *result = NULL; - if (__builtin_expect (hst_resp.found == -1, 0)) + if (__glibc_unlikely (hst_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_hosts = 1; @@ -377,7 +377,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, goto out_close; } /* See whether this would exceed the buffer capacity. */ - if (__builtin_expect (cp > buffer + buflen, 0)) + if (__glibc_unlikely (cp > buffer + buflen)) { /* aliases_len array might contain garbage during nscd GC cycle, retry rather than fail in that case. */ diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c index 5454ab6..278b9db 100644 --- a/nscd/nscd_getpw_r.c +++ b/nscd/nscd_getpw_r.c @@ -134,7 +134,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type, /* No value found so far. */ *result = NULL; - if (__builtin_expect (pw_resp.found == -1, 0)) + if (__glibc_unlikely (pw_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_passwd = 1; @@ -165,9 +165,9 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type, p += pw_resp.pw_shell_len; ssize_t total = p - buffer; - if (__builtin_expect (pw_name + total > recend, 0)) + if (__glibc_unlikely (pw_name + total > recend)) goto out_close; - if (__builtin_expect (buflen < total, 0)) + if (__glibc_unlikely (buflen < total)) { __set_errno (ERANGE); retval = ERANGE; @@ -179,7 +179,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type, { ssize_t nbytes = __readall (sock, buffer, total); - if (__builtin_expect (nbytes != total, 0)) + if (__glibc_unlikely (nbytes != total)) { /* The `errno' to some value != ERANGE. */ __set_errno (ENOENT); diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c index 38f159e..4e3f702 100644 --- a/nscd/nscd_getserv_r.c +++ b/nscd/nscd_getserv_r.c @@ -189,7 +189,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, /* No value found so far. */ *result = NULL; - if (__builtin_expect (serv_resp.found == -1, 0)) + if (__glibc_unlikely (serv_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_services = 1; @@ -300,7 +300,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, } /* See whether this would exceed the buffer capacity. */ - if (__builtin_expect (cp > buf + buflen, 0)) + if (__glibc_unlikely (cp > buf + buflen)) { /* aliases_len array might contain garbage during nscd GC cycle, retry rather than fail in that case. */ diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index e4fb2e5..0d61643 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -110,7 +110,7 @@ __readvall (int fd, const struct iovec *iov, int iovcnt) ssize_t ret = TEMP_FAILURE_RETRY (__readv (fd, iov, iovcnt)); if (ret <= 0) { - if (__builtin_expect (ret == 0 || errno != EAGAIN, 1)) + if (__glibc_likely (ret == 0 || errno != EAGAIN)) /* A genuine error or no data to read. */ return ret; @@ -226,7 +226,7 @@ open_socket (request_type type, const char *key, size_t keylen) ssize_t wres = TEMP_FAILURE_RETRY (__send (sock, &reqdata, real_sizeof_reqdata, MSG_NOSIGNAL)); - if (__builtin_expect (wres == (ssize_t) real_sizeof_reqdata, 1)) + if (__glibc_likely (wres == (ssize_t) real_sizeof_reqdata)) /* We managed to send the request. */ return sock; @@ -339,13 +339,13 @@ __nscd_get_mapping (request_type type, const char *key, int *ip = (void *) CMSG_DATA (cmsg); mapfd = *ip; - if (__builtin_expect (n != keylen && n != keylen + sizeof (mapsize), 0)) + if (__glibc_unlikely (n != keylen && n != keylen + sizeof (mapsize))) goto out_close; - if (__builtin_expect (strcmp (resdata, key) != 0, 0)) + if (__glibc_unlikely (strcmp (resdata, key) != 0)) goto out_close; - if (__builtin_expect (n == keylen, 0)) + if (__glibc_unlikely (n == keylen)) { struct stat64 st; if (__builtin_expect (fstat64 (mapfd, &st) != 0, 0) @@ -358,7 +358,7 @@ __nscd_get_mapping (request_type type, const char *key, /* The file is large enough, map it now. */ void *mapping = __mmap (NULL, mapsize, PROT_READ, MAP_SHARED, mapfd, 0); - if (__builtin_expect (mapping != MAP_FAILED, 1)) + if (__glibc_likely (mapping != MAP_FAILED)) { /* Check whether the database is correct and up-to-date. */ struct database_pers_head *head = mapping; @@ -383,7 +383,7 @@ __nscd_get_mapping (request_type type, const char *key, ALIGN) + head->data_size); - if (__builtin_expect (mapsize < size, 0)) + if (__glibc_unlikely (mapsize < size)) goto out_unmap; /* Allocate a record for the mapping. */ @@ -433,7 +433,7 @@ __nscd_get_map_ref (request_type type, const char *name, cur = mapptr->mapped; - if (__builtin_expect (cur != NO_MAPPING, 1)) + if (__glibc_likely (cur != NO_MAPPING)) { /* If not mapped or timestamp not updated, request new map. */ if (cur == NULL @@ -443,7 +443,7 @@ __nscd_get_map_ref (request_type type, const char *name, cur = __nscd_get_mapping (type, name, (struct mapped_database **) &mapptr->mapped); - if (__builtin_expect (cur != NO_MAPPING, 1)) + if (__glibc_likely (cur != NO_MAPPING)) { if (__builtin_expect (((*gc_cyclep = cur->head->gc_cycle) & 1) != 0, 0)) diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c index 8bc3e6c..a11ef06 100644 --- a/nscd/nscd_initgroups.c +++ b/nscd/nscd_initgroups.c @@ -130,7 +130,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size, } else { - if (__builtin_expect (initgr_resp.found == -1, 0)) + if (__glibc_unlikely (initgr_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_group = 1; diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c index 4acb0be..104bf21 100644 --- a/nscd/nscd_netgroup.c +++ b/nscd/nscd_netgroup.c @@ -124,7 +124,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap) } else { - if (__builtin_expect (netgroup_resp.found == -1, 0)) + if (__glibc_unlikely (netgroup_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_netgroup = 1; @@ -248,7 +248,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user, retval = innetgroup_resp.result; else { - if (__builtin_expect (innetgroup_resp.found == -1, 0)) + if (__glibc_unlikely (innetgroup_resp.found == -1)) { /* The daemon does not cache this database. */ __nss_not_use_nscd_netgroup = 1; diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index 5adb8ad..fa355c3 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -430,7 +430,7 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req, bool use_malloc = false; int errval = 0; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in password cache!"), keystr); @@ -443,7 +443,7 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req, { errno = 0; - if (__builtin_expect (buflen > 32768, 0)) + if (__glibc_unlikely (buflen > 32768)) { char *old_buffer = buffer; buflen *= 2; diff --git a/nscd/selinux.c b/nscd/selinux.c index c0c8e22..e477254 100644 --- a/nscd/selinux.c +++ b/nscd/selinux.c @@ -212,7 +212,7 @@ preserve_capabilities (void) cap_free (tmp_caps); - if (__builtin_expect (res != 0, 0)) + if (__glibc_unlikely (res != 0)) { cap_free (new_caps); dbg_log (_("Failed to drop capabilities")); diff --git a/nscd/servicescache.c b/nscd/servicescache.c index 52058a6..12ce9b2 100644 --- a/nscd/servicescache.c +++ b/nscd/servicescache.c @@ -389,7 +389,7 @@ addservbyX (struct database_dyn *db, int fd, request_header *req, bool use_malloc = false; int errval = 0; - if (__builtin_expect (debug_level > 0, 0)) + if (__glibc_unlikely (debug_level > 0)) { if (he == NULL) dbg_log (_("Haven't found \"%s\" in services cache!"), key); @@ -402,7 +402,7 @@ addservbyX (struct database_dyn *db, int fd, request_header *req, { errno = 0; - if (__builtin_expect (buflen > 32768, 0)) + if (__glibc_unlikely (buflen > 32768)) { char *old_buffer = buffer; buflen *= 2; diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c index 36242f9..00b2ecf 100644 --- a/nss/nss_files/files-XXX.c +++ b/nss/nss_files/files-XXX.c @@ -272,7 +272,7 @@ internal_getent (struct STRUCTURE *result, || ! (parse_result = parse_line (p, result, data, buflen, errnop EXTRA_ARGS))); - if (__builtin_expect (parse_result == -1, 0)) + if (__glibc_unlikely (parse_result == -1)) { H_ERRNO_SET (NETDB_INTERNAL); return NSS_STATUS_TRYAGAIN; diff --git a/posix/fnmatch.c b/posix/fnmatch.c index f748d3d..4f14a8b 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -348,12 +348,12 @@ fnmatch (pattern, string, flags) #else n = strlen (pattern); #endif - if (__builtin_expect (n < 1024, 1)) + if (__glibc_likely (n < 1024)) { wpattern = (wchar_t *) alloca_account ((n + 1) * sizeof (wchar_t), alloca_used); n = mbsrtowcs (wpattern, &p, n + 1, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) /* Something wrong. XXX Do we have to set `errno' to something which mbsrtows hasn't already done? */ @@ -368,12 +368,12 @@ fnmatch (pattern, string, flags) { prepare_wpattern: n = mbsrtowcs (NULL, &pattern, 0, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) /* Something wrong. XXX Do we have to set `errno' to something which mbsrtows hasn't already done? */ return -1; - if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0)) + if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t))) { __set_errno (ENOMEM); return -2; @@ -393,12 +393,12 @@ fnmatch (pattern, string, flags) n = strlen (string); #endif p = string; - if (__builtin_expect (n < 1024, 1)) + if (__glibc_likely (n < 1024)) { wstring = (wchar_t *) alloca_account ((n + 1) * sizeof (wchar_t), alloca_used); n = mbsrtowcs (wstring, &p, n + 1, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) { /* Something wrong. XXX Do we have to set `errno' to something which @@ -417,12 +417,12 @@ fnmatch (pattern, string, flags) { prepare_wstring: n = mbsrtowcs (NULL, &string, 0, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) /* Something wrong. XXX Do we have to set `errno' to something which mbsrtows hasn't already done? */ goto free_return; - if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0)) + if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t))) { free (wpattern_malloc); __set_errno (ENOMEM); diff --git a/posix/getopt.c b/posix/getopt.c index 2d481f1..a859acb 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -601,7 +601,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, fputc_unlocked ('\n', fp); - if (__builtin_expect (fclose (fp) != EOF, 1)) + if (__glibc_likely (fclose (fp) != EOF)) { _IO_flockfile (stderr); diff --git a/posix/glob.c b/posix/glob.c index f143108..aa4bb92 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -354,7 +354,7 @@ glob (pattern, flags, errfunc, pglob) /* It is an illegal expression. */ illegal_brace: #ifdef _LIBC - if (__builtin_expect (!alloca_onealt, 0)) + if (__glibc_unlikely (!alloca_onealt)) #endif free (onealt); return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); @@ -404,7 +404,7 @@ glob (pattern, flags, errfunc, pglob) if (result && result != GLOB_NOMATCH) { #ifdef _LIBC - if (__builtin_expect (!alloca_onealt, 0)) + if (__glibc_unlikely (!alloca_onealt)) #endif free (onealt); if (!(flags & GLOB_APPEND)) @@ -425,7 +425,7 @@ glob (pattern, flags, errfunc, pglob) } #ifdef _LIBC - if (__builtin_expect (!alloca_onealt, 0)) + if (__glibc_unlikely (!alloca_onealt)) #endif free (onealt); @@ -488,7 +488,7 @@ glob (pattern, flags, errfunc, pglob) } else { - if (__builtin_expect (pattern[0] == '\0', 0)) + if (__glibc_unlikely (pattern[0] == '\0')) { dirs.gl_pathv = NULL; goto no_matches; @@ -671,7 +671,7 @@ glob (pattern, flags, errfunc, pglob) 2 * pwbuflen); if (newp == NULL) { - if (__builtin_expect (malloc_pwtmpbuf, 0)) + if (__glibc_unlikely (malloc_pwtmpbuf)) free (pwtmpbuf); retval = GLOB_NOSPACE; goto out; @@ -717,7 +717,7 @@ glob (pattern, flags, errfunc, pglob) { if (flags & GLOB_TILDE_CHECK) { - if (__builtin_expect (malloc_home_dir, 0)) + if (__glibc_unlikely (malloc_home_dir)) free (home_dir); retval = GLOB_NOMATCH; goto out; @@ -730,7 +730,7 @@ glob (pattern, flags, errfunc, pglob) /* Now construct the full directory. */ if (dirname[1] == '\0') { - if (__builtin_expect (malloc_dirname, 0)) + if (__glibc_unlikely (malloc_dirname)) free (dirname); dirname = home_dir; @@ -750,7 +750,7 @@ glob (pattern, flags, errfunc, pglob) newp = malloc (home_len + dirlen); if (newp == NULL) { - if (__builtin_expect (malloc_home_dir, 0)) + if (__glibc_unlikely (malloc_home_dir)) free (home_dir); retval = GLOB_NOSPACE; goto out; @@ -760,7 +760,7 @@ glob (pattern, flags, errfunc, pglob) mempcpy (mempcpy (newp, home_dir, home_len), &dirname[1], dirlen); - if (__builtin_expect (malloc_dirname, 0)) + if (__glibc_unlikely (malloc_dirname)) free (dirname); dirname = newp; @@ -859,7 +859,7 @@ glob (pattern, flags, errfunc, pglob) if (pwtmpbuf == NULL) { nomem_getpw: - if (__builtin_expect (malloc_user_name, 0)) + if (__glibc_unlikely (malloc_user_name)) free (user_name); retval = GLOB_NOSPACE; goto out; @@ -884,7 +884,7 @@ glob (pattern, flags, errfunc, pglob) 2 * buflen); if (newp == NULL) { - if (__builtin_expect (malloc_pwtmpbuf, 0)) + if (__glibc_unlikely (malloc_pwtmpbuf)) free (pwtmpbuf); goto nomem_getpw; } @@ -897,7 +897,7 @@ glob (pattern, flags, errfunc, pglob) p = getpwnam (user_name); # endif - if (__builtin_expect (malloc_user_name, 0)) + if (__glibc_unlikely (malloc_user_name)) free (user_name); /* If we found a home directory use this. */ @@ -906,7 +906,7 @@ glob (pattern, flags, errfunc, pglob) size_t home_len = strlen (p->pw_dir); size_t rest_len = end_name == NULL ? 0 : strlen (end_name); - if (__builtin_expect (malloc_dirname, 0)) + if (__glibc_unlikely (malloc_dirname)) free (dirname); malloc_dirname = 0; @@ -918,7 +918,7 @@ glob (pattern, flags, errfunc, pglob) dirname = malloc (home_len + rest_len + 1); if (dirname == NULL) { - if (__builtin_expect (malloc_pwtmpbuf, 0)) + if (__glibc_unlikely (malloc_pwtmpbuf)) free (pwtmpbuf); retval = GLOB_NOSPACE; goto out; @@ -931,12 +931,12 @@ glob (pattern, flags, errfunc, pglob) dirlen = home_len + rest_len; dirname_modified = 1; - if (__builtin_expect (malloc_pwtmpbuf, 0)) + if (__glibc_unlikely (malloc_pwtmpbuf)) free (pwtmpbuf); } else { - if (__builtin_expect (malloc_pwtmpbuf, 0)) + if (__glibc_unlikely (malloc_pwtmpbuf)) free (pwtmpbuf); if (flags & GLOB_TILDE_CHECK) @@ -1035,7 +1035,7 @@ glob (pattern, flags, errfunc, pglob) *(char *) &dirname[--dirlen] = '\0'; } - if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) != 0, 0)) + if (__glibc_unlikely ((flags & GLOB_ALTDIRFUNC) != 0)) { /* Use the alternative access functions also in the recursive call. */ @@ -1253,7 +1253,7 @@ glob (pattern, flags, errfunc, pglob) } out: - if (__builtin_expect (malloc_dirname, 0)) + if (__glibc_unlikely (malloc_dirname)) free (dirname); return retval; @@ -1530,7 +1530,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, of the function to copy this name into the result. */ flags |= GLOB_NOCHECK; - if (__builtin_expect (!alloca_fullname, 0)) + if (__glibc_unlikely (!alloca_fullname)) free (fullname); } else @@ -1573,7 +1573,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, } d64buf; - if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) + if (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)) { struct dirent *d32 = (*pglob->gl_readdir) (stream); if (d32 != NULL) @@ -1732,7 +1732,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, if (stream != NULL) { save = errno; - if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) + if (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)) (*pglob->gl_closedir) (stream); else closedir (stream); diff --git a/posix/wordexp.c b/posix/wordexp.c index 366ec18..b6b65dd 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -823,7 +823,7 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec) args[1] = "-nc"; /* Redirect output. */ - if (__builtin_expect (fildes[1] != STDOUT_FILENO, 1)) + if (__glibc_likely (fildes[1] != STDOUT_FILENO)) { __dup2 (fildes[1], STDOUT_FILENO); __close (fildes[1]); diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index f8f192e..541c25a 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -398,7 +398,7 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, buffer += pad; buflen = buflen > pad ? buflen - pad : 0; - if (__builtin_expect (buflen < sizeof (struct host_data), 0)) + if (__glibc_unlikely (buflen < sizeof (struct host_data))) { *errnop = ERANGE; *h_errnop = NETDB_INTERNAL; @@ -452,7 +452,7 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, break; case AF_INET6: /* Only lookup with the byte string format if the user wants it. */ - if (__builtin_expect (_res.options & RES_USEBSTRING, 0)) + if (__glibc_unlikely (_res.options & RES_USEBSTRING)) { qp = stpcpy (qbuf, "\\[x"); for (n = 0; n < IN6ADDRSZ; ++n) @@ -613,7 +613,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, int have_to_map = 0; uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data); buffer += pad; - if (__builtin_expect (buflen < sizeof (struct host_data) + pad, 0)) + if (__glibc_unlikely (buflen < sizeof (struct host_data) + pad)) { /* The buffer is too small. */ too_small: @@ -727,14 +727,14 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, n = -1; } - if (__builtin_expect (n < 0 || (*name_ok) (bp) == 0, 0)) + if (__glibc_unlikely (n < 0 || (*name_ok) (bp) == 0)) { ++had_error; continue; } cp += n; /* name */ - if (__builtin_expect (cp + 10 > end_of_message, 0)) + if (__glibc_unlikely (cp + 10 > end_of_message)) { ++had_error; continue; @@ -748,7 +748,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, cp += INT32SZ; /* TTL */ n = __ns_get16 (cp); cp += INT16SZ; /* len */ - if (__builtin_expect (class != C_IN, 0)) + if (__glibc_unlikely (class != C_IN)) { /* XXX - debug? syslog? */ cp += n; @@ -764,7 +764,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1]) continue; n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__builtin_expect (n < 0 || (*name_ok) (tbuf) == 0, 0)) + if (__glibc_unlikely (n < 0 || (*name_ok) (tbuf) == 0)) { ++had_error; continue; @@ -782,7 +782,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, linebuflen -= n; /* Get canonical name. */ n = strlen (tbuf) + 1; /* For the \0. */ - if (__builtin_expect (n > linebuflen, 0)) + if (__glibc_unlikely (n > linebuflen)) goto too_small; if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) { @@ -798,7 +798,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (qtype == T_PTR && type == T_CNAME) { n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0)) + if (__glibc_unlikely (n < 0 || res_dnok (tbuf) == 0)) { ++had_error; continue; @@ -806,7 +806,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, cp += n; /* Get canonical name. */ n = strlen (tbuf) + 1; /* For the \0. */ - if (__builtin_expect (n > linebuflen, 0)) + if (__glibc_unlikely (n > linebuflen)) goto too_small; if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) { @@ -833,7 +833,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (type == T_A && qtype == T_AAAA && map) have_to_map = 1; - else if (__builtin_expect (type != qtype, 0)) + else if (__glibc_unlikely (type != qtype)) { syslog (LOG_NOTICE | LOG_AUTH, "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", @@ -845,7 +845,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, switch (type) { case T_PTR: - if (__builtin_expect (strcasecmp (tname, bp) != 0, 0)) + if (__glibc_unlikely (strcasecmp (tname, bp) != 0)) { syslog (LOG_NOTICE | LOG_AUTH, AskedForGot, qname, bp); cp += n; @@ -862,7 +862,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, n = -1; } - if (__builtin_expect (n < 0 || res_hnok (bp) == 0, 0)) + if (__glibc_unlikely (n < 0 || res_hnok (bp) == 0)) { ++had_error; break; @@ -892,7 +892,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (have_to_map) { n = strlen (bp) + 1; /* for the \0 */ - if (__builtin_expect (n >= MAXHOSTNAMELEN, 0)) + if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) { ++had_error; break; @@ -938,7 +938,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, linebuflen -= sizeof (align) - ((u_long) bp % sizeof (align)); bp += sizeof (align) - ((u_long) bp % sizeof (align)); - if (__builtin_expect (n > linebuflen, 0)) + if (__glibc_unlikely (n > linebuflen)) goto too_small; bp = __mempcpy (*hap++ = bp, cp, n); cp += n; @@ -1009,7 +1009,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, int qdcount = ntohs (hp->qdcount); const u_char *cp = answer->buf + HFIXEDSZ; const u_char *end_of_message = answer->buf + anslen; - if (__builtin_expect (qdcount != 1, 0)) + if (__glibc_unlikely (qdcount != 1)) { *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; @@ -1063,7 +1063,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, n = -1; } - if (__builtin_expect (n < 0 || res_hnok (buffer) == 0, 0)) + if (__glibc_unlikely (n < 0 || res_hnok (buffer) == 0)) { ++had_error; continue; @@ -1077,7 +1077,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, cp += n; /* name */ - if (__builtin_expect (cp + 10 > end_of_message, 0)) + if (__glibc_unlikely (cp + 10 > end_of_message)) { ++had_error; continue; @@ -1107,7 +1107,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, *ttlp = ttl; n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__builtin_expect (n < 0 || res_hnok (tbuf) == 0, 0)) + if (__glibc_unlikely (n < 0 || res_hnok (tbuf) == 0)) { ++had_error; continue; @@ -1124,9 +1124,9 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, } n = strlen (tbuf) + 1; - if (__builtin_expect (n > buflen, 0)) + if (__glibc_unlikely (n > buflen)) goto too_small; - if (__builtin_expect (n >= MAXHOSTNAMELEN, 0)) + if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) { ++had_error; continue; @@ -1143,7 +1143,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, // We should not see any types other than those explicitly listed // below. Some types sent by server seem missing, though. Just // collect the data for now. - if (__builtin_expect (type != T_A && type != T_AAAA, 0)) + if (__glibc_unlikely (type != T_A && type != T_AAAA)) #else if (__builtin_expect (type == T_SIG, 0) || __builtin_expect (type == T_KEY, 0) diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 8e80a60..b8aee21 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -268,7 +268,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result, uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct net_data); buffer += pad; - if (__builtin_expect (buflen < sizeof (*net_data) + pad, 0)) + if (__glibc_unlikely (buflen < sizeof (*net_data) + pad)) { /* The buffer is too small. */ too_small: diff --git a/resolv/res_init.c b/resolv/res_init.c index 5e1a747..ea133f8 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -334,7 +334,7 @@ __res_vinit(res_state statp, int preinit) { sa6->sin6_flowinfo = 0; sa6->sin6_addr = a6; - if (__builtin_expect (el == NULL, 1)) + if (__glibc_likely (el == NULL)) sa6->sin6_scope_id = 0; else { int try_numericscope = 1; diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c index 6170763..1635e6a 100644 --- a/resolv/res_mkquery.c +++ b/resolv/res_mkquery.c @@ -180,7 +180,7 @@ res_nmkquery(res_state statp, n = ns_name_compress((char *)data, cp, buflen, (const u_char **) dnptrs, (const u_char **) lastdnptr); - if (__builtin_expect (n < 0, 0)) + if (__glibc_unlikely (n < 0)) return (-1); cp += n; buflen -= n; @@ -195,7 +195,7 @@ res_nmkquery(res_state statp, /* * Initialize answer section */ - if (__builtin_expect (buflen < 1 + RRFIXEDSZ + datalen, 0)) + if (__glibc_unlikely (buflen < 1 + RRFIXEDSZ + datalen)) return (-1); *cp++ = '\0'; /* no domain name */ NS_PUT16 (type, cp); diff --git a/resolv/res_query.c b/resolv/res_query.c index 1325f97..88230f4 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -202,7 +202,7 @@ __libc_res_nquery(res_state statp, goto again; } } - if (__builtin_expect (n <= 0, 0)) { + if (__glibc_unlikely (n <= 0)) { /* If the query choked with EDNS0, retry without EDNS0. */ if ((statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0 && ((oflags ^ statp->_flags) & RES_F_EDNS0ERR) != 0) { diff --git a/resolv/res_send.c b/resolv/res_send.c index 7f2e85f..f46630d 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -358,7 +358,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, } #ifdef USE_HOOKS - if (__builtin_expect (statp->qhook || statp->rhook, 0)) { + if (__glibc_unlikely (statp->qhook || statp->rhook)) { if (anssiz < MAXPACKET && ansp) { u_char *buf = malloc (MAXPACKET); if (buf == NULL) @@ -499,7 +499,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, goto next_ns; same_ns: #ifdef USE_HOOKS - if (__builtin_expect (statp->qhook != NULL, 0)) { + if (__glibc_unlikely (statp->qhook != NULL)) { int done = 0, loops = 0; do { @@ -541,7 +541,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, : &((struct sockaddr_in *) nsap)->sin_addr), tmpbuf, sizeof (tmpbuf)))); - if (__builtin_expect (v_circuit, 0)) { + if (__glibc_unlikely (v_circuit)) { /* Use VC; at most one attempt per server. */ try = statp->retry; n = send_vc(statp, buf, buflen, buf2, buflen2, @@ -595,7 +595,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, __res_iclose(statp, false); } #ifdef USE_HOOKS - if (__builtin_expect (statp->rhook, 0)) { + if (__glibc_unlikely (statp->rhook)) { int done = 0, loops = 0; do { @@ -814,7 +814,7 @@ send_vc(res_state statp, if (rlen > *thisanssizp) { /* Yes, we test ANSCP here. If we have two buffers both will be allocatable. */ - if (__builtin_expect (anscp != NULL, 1)) { + if (__glibc_likely (anscp != NULL)) { u_char *newp = malloc (MAXPACKET); if (newp == NULL) { *terrno = ENOMEM; @@ -835,7 +835,7 @@ send_vc(res_state statp, } else len = rlen; - if (__builtin_expect (len < HFIXEDSZ, 0)) { + if (__glibc_unlikely (len < HFIXEDSZ)) { /* * Undersized message. */ @@ -851,13 +851,13 @@ send_vc(res_state statp, cp += n; len -= n; } - if (__builtin_expect (n <= 0, 0)) { + if (__glibc_unlikely (n <= 0)) { *terrno = errno; Perror(statp, stderr, "read(vc)", errno); __res_iclose(statp, false); return (0); } - if (__builtin_expect (truncating, 0)) { + if (__glibc_unlikely (truncating)) { /* * Flush rest of answer so connection stays in synch. */ @@ -917,7 +917,7 @@ reopen (res_state statp, int *terrno, int ns) /* only try IPv6 if IPv6 NS and if not failed before */ if (nsap->sa_family == AF_INET6 && !statp->ipv6_unavail) { - if (__builtin_expect (__have_o_nonblock >= 0, 1)) { + if (__glibc_likely (__have_o_nonblock >= 0)) { EXT(statp).nssocks[ns] = socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, 0); @@ -928,14 +928,14 @@ reopen (res_state statp, int *terrno, int ns) && errno == EINVAL ? -1 : 1); #endif } - if (__builtin_expect (__have_o_nonblock < 0, 0)) + if (__glibc_unlikely (__have_o_nonblock < 0)) EXT(statp).nssocks[ns] = socket(PF_INET6, SOCK_DGRAM, 0); if (EXT(statp).nssocks[ns] < 0) statp->ipv6_unavail = errno == EAFNOSUPPORT; slen = sizeof (struct sockaddr_in6); } else if (nsap->sa_family == AF_INET) { - if (__builtin_expect (__have_o_nonblock >= 0, 1)) { + if (__glibc_likely (__have_o_nonblock >= 0)) { EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, 0); @@ -946,7 +946,7 @@ reopen (res_state statp, int *terrno, int ns) && errno == EINVAL ? -1 : 1); #endif } - if (__builtin_expect (__have_o_nonblock < 0, 0)) + if (__glibc_unlikely (__have_o_nonblock < 0)) EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0); slen = sizeof (struct sockaddr_in); @@ -973,7 +973,7 @@ reopen (res_state statp, int *terrno, int ns) __res_iclose(statp, false); return (0); } - if (__builtin_expect (__have_o_nonblock < 0, 0)) { + if (__glibc_unlikely (__have_o_nonblock < 0)) { /* Make socket non-blocking. */ int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL); if (fl != -1) @@ -1055,7 +1055,7 @@ send_dg(res_state statp, n = 0; if (nwritten == 0) n = __poll (pfd, 1, 0); - if (__builtin_expect (n == 0, 0)) { + if (__glibc_unlikely (n == 0)) { n = __poll (pfd, 1, ptimeout); need_recompute = 1; } @@ -1130,7 +1130,7 @@ send_dg(res_state statp, reqs[1].msg_hdr.msg_controllen = 0; int ndg = __sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL); - if (__builtin_expect (ndg == 2, 1)) + if (__glibc_likely (ndg == 2)) { if (reqs[0].msg_len != buflen || reqs[1].msg_len != buflen2) @@ -1146,7 +1146,7 @@ send_dg(res_state statp, else { #ifndef __ASSUME_SENDMMSG - if (__builtin_expect (have_sendmmsg == 0, 0)) + if (__glibc_unlikely (have_sendmmsg == 0)) { if (ndg < 0 && errno == ENOSYS) { @@ -1246,7 +1246,7 @@ send_dg(res_state statp, *thisresplenp = recvfrom(pfd[0].fd, (char*)*thisansp, *thisanssizp, 0, (struct sockaddr *)&from, &fromlen); - if (__builtin_expect (*thisresplenp <= 0, 0)) { + if (__glibc_unlikely (*thisresplenp <= 0)) { if (errno == EINTR || errno == EAGAIN) { need_recompute = 1; goto wait; @@ -1255,7 +1255,7 @@ send_dg(res_state statp, goto err_out; } *gotsomewhere = 1; - if (__builtin_expect (*thisresplenp < HFIXEDSZ, 0)) { + if (__glibc_unlikely (*thisresplenp < HFIXEDSZ)) { /* * Undersized message. */ diff --git a/stdio-common/_i18n_number.h b/stdio-common/_i18n_number.h index 061c4d4..299c3e0 100644 --- a/stdio-common/_i18n_number.h +++ b/stdio-common/_i18n_number.h @@ -42,7 +42,7 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end) wint_t wthousands = __towctrans (L',', map); #ifndef COMPILE_WPRINTF - if (__builtin_expect (map != NULL, 0)) + if (__glibc_unlikely (map != NULL)) { mbstate_t state; memset (&state, '\0', sizeof (state)); diff --git a/stdio-common/perror.c b/stdio-common/perror.c index acd97d2..4b47015 100644 --- a/stdio-common/perror.c +++ b/stdio-common/perror.c @@ -60,7 +60,7 @@ perror (const char *s) || (fd = __dup (fd)) == -1 || (fp = fdopen (fd, "w+")) == NULL) { - if (__builtin_expect (fd != -1, 0)) + if (__glibc_unlikely (fd != -1)) __close (fd); /* Use standard error as is. */ diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index 7a3292c..9cd4b4b 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -1094,7 +1094,7 @@ ___printf_fp (FILE *fp, /* Write the exponent if it is needed. */ if (type != 'f') { - if (__builtin_expect (expsign != 0 && exponent == 4 && spec == 'g', 0)) + if (__glibc_unlikely (expsign != 0 && exponent == 4 && spec == 'g')) { /* This is another special case. The exponent of the number is really smaller than -4, which requires the 'e'/'E' format. @@ -1180,7 +1180,7 @@ ___printf_fp (FILE *fp, size_t nbuffer = (2 + chars_needed * factor + decimal_len + ngroups * thousands_sep_len); - if (__builtin_expect (buffer_malloced, 0)) + if (__glibc_unlikely (buffer_malloced)) { buffer = (char *) malloc (nbuffer); if (buffer == NULL) @@ -1208,7 +1208,7 @@ ___printf_fp (FILE *fp, } tmpptr = buffer; - if (__builtin_expect (info->i18n, 0)) + if (__glibc_unlikely (info->i18n)) { #ifdef COMPILE_WPRINTF wstartp = _i18n_number_rewrite (wstartp, wcp, @@ -1228,7 +1228,7 @@ ___printf_fp (FILE *fp, PRINT (tmpptr, wstartp, wide ? wcp - wstartp : cp - tmpptr); /* Free the memory if necessary. */ - if (__builtin_expect (buffer_malloced, 0)) + if (__glibc_unlikely (buffer_malloced)) { free (buffer); free (wbuffer); diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c index 3d03862..d8cd509 100644 --- a/stdio-common/tmpnam.c +++ b/stdio-common/tmpnam.c @@ -38,7 +38,7 @@ tmpnam (char *s) 0)) return NULL; - if (__builtin_expect (__gen_tempname (tmpbuf, 0, 0, __GT_NOCREATE), 0)) + if (__glibc_unlikely (__gen_tempname (tmpbuf, 0, 0, __GT_NOCREATE))) return NULL; if (s == NULL) diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index 2e1e91a..e0d2245 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -269,7 +269,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, #define ADDW(Ch) \ do \ { \ - if (__builtin_expect (wpsize == wpmax, 0)) \ + if (__glibc_unlikely (wpsize == wpmax)) \ { \ CHAR_T *old = wp; \ size_t newsize = (UCHAR_MAX + 1 > 2 * wpmax \ @@ -392,7 +392,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, do { c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); else if (c != (unsigned char) *f++) { @@ -420,7 +420,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, c = inchar (); /* Characters other than format specs must just match. */ - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); /* We saw white space char as the last character in the format @@ -428,12 +428,12 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, if (skip_space) { while (ISSPACE (c)) - if (__builtin_expect (inchar () == EOF, 0)) + if (__glibc_unlikely (inchar () == EOF)) input_error (); skip_space = 0; } - if (__builtin_expect (c != fc, 0)) + if (__glibc_unlikely (c != fc)) { ungetc (c, s); conv_error (); @@ -581,7 +581,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, } /* End of the format string? */ - if (__builtin_expect (*f == L_('\0'), 0)) + if (__glibc_unlikely (*f == L_('\0'))) conv_error (); /* Find the conversion specifier. */ @@ -610,9 +610,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { case L_('%'): /* Must match a literal '%'. */ c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); - if (__builtin_expect (c != fc, 0)) + if (__glibc_unlikely (c != fc)) { ungetc_not_eof (c, s); conv_error (); @@ -710,7 +710,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, #endif c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); #ifdef COMPILE_WSCANF @@ -758,7 +758,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, } n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c, &state); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) /* No valid wide character. */ input_error (); @@ -836,7 +836,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, STRING_ARG (wstr, wchar_t, (width > 1024 ? 1024 : width)); c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); #ifdef COMPILE_WSCANF @@ -946,14 +946,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { /* Possibly correct character, just not enough input. */ - if (__builtin_expect (inchar () == EOF, 0)) + if (__glibc_unlikely (inchar () == EOF)) encode_error (); buf[0] = c; continue; } - if (__builtin_expect (n != 1, 0)) + if (__glibc_unlikely (n != 1)) encode_error (); /* We have a match. */ @@ -991,7 +991,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, STRING_ARG (str, char, 100); c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); #ifdef COMPILE_WSCANF @@ -1060,7 +1060,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c, &state); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) encode_error (); assert (n <= MB_CUR_MAX); @@ -1262,14 +1262,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { /* Possibly correct character, just not enough input. */ - if (__builtin_expect (inchar () == EOF, 0)) + if (__glibc_unlikely (inchar () == EOF)) encode_error (); buf[0] = c; continue; } - if (__builtin_expect (n != 1, 0)) + if (__glibc_unlikely (n != 1)) encode_error (); /* We have a match. */ @@ -1368,7 +1368,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, number: c = inchar (); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); /* Check for a sign. */ @@ -1434,7 +1434,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, #endif /* Get the alternative digit forms if there are any. */ - if (__builtin_expect (map != NULL, 0)) + if (__glibc_unlikely (map != NULL)) { /* Adding new level for extra digits set in locale file. */ ++to_level; @@ -1502,7 +1502,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { /* Get the string for the digits with value N. */ #ifdef COMPILE_WSCANF - if (__builtin_expect (map != NULL, 0)) + if (__glibc_unlikely (map != NULL)) wcdigits[n] = wcdigits_extended[n]; else wcdigits[n] = (const wchar_t *) @@ -1521,7 +1521,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, const char *cmpp; int avail = width > 0 ? width : INT_MAX; - if (__builtin_expect (map != NULL, 0)) + if (__glibc_unlikely (map != NULL)) mbdigits[n] = mbdigits_extended[n]; else mbdigits[n] @@ -1795,7 +1795,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, else num.ul = __strtoul_internal (wp, &tw, base, flags & GROUP); } - if (__builtin_expect (wp == tw, 0)) + if (__glibc_unlikely (wp == tw)) conv_error (); if (!(flags & SUPPRESS)) @@ -1842,7 +1842,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, c = inchar (); if (width > 0) --width; - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) input_error (); got_digit = got_dot = got_e = 0; @@ -1851,7 +1851,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, if (c == L_('-') || c == L_('+')) { negative = c == L_('-'); - if (__builtin_expect (width == 0 || inchar () == EOF, 0)) + if (__glibc_unlikely (width == 0 || inchar () == EOF)) /* EOF is only an input error before we read any chars. */ conv_error (); if (width > 0) @@ -2334,7 +2334,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, *ARG (float *) = negative ? -d : d; } - if (__builtin_expect (tw == wp, 0)) + if (__glibc_unlikely (tw == wp)) conv_error (); if (!(flags & SUPPRESS)) @@ -2374,7 +2374,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, while ((fc = *f++) != L'\0' && fc != L']'); - if (__builtin_expect (fc == L'\0', 0)) + if (__glibc_unlikely (fc == L'\0')) conv_error (); wchar_t *twend = (wchar_t *) f - 1; #else @@ -2410,7 +2410,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, /* Add the character to the flag map. */ wp[fc] = 1; - if (__builtin_expect (fc == '\0', 0)) + if (__glibc_unlikely (fc == '\0')) conv_error(); #endif @@ -2418,7 +2418,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { size_t now = read_in; #ifdef COMPILE_WSCANF - if (__builtin_expect (inchar () == WEOF, 0)) + if (__glibc_unlikely (inchar () == WEOF)) input_error (); do @@ -2530,7 +2530,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, size_t cnt = 0; mbstate_t cstate; - if (__builtin_expect (inchar () == EOF, 0)) + if (__glibc_unlikely (inchar () == EOF)) input_error (); memset (&cstate, '\0', sizeof (cstate)); @@ -2613,13 +2613,13 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, } while (inchar () != EOF); - if (__builtin_expect (cnt != 0, 0)) + if (__glibc_unlikely (cnt != 0)) /* We stopped in the middle of recognizing another character. That's a problem. */ encode_error (); #endif - if (__builtin_expect (now == read_in, 0)) + if (__glibc_unlikely (now == read_in)) /* We haven't succesfully read any character. */ conv_error (); @@ -2645,7 +2645,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { size_t now = read_in; - if (__builtin_expect (inchar () == EOF, 0)) + if (__glibc_unlikely (inchar () == EOF)) input_error (); #ifdef COMPILE_WSCANF @@ -2754,7 +2754,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, } n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c, &state); - if (__builtin_expect (n == (size_t) -1, 0)) + if (__glibc_unlikely (n == (size_t) -1)) encode_error (); assert (n <= MB_CUR_MAX); @@ -2817,7 +2817,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, while (--width > 0 && inchar () != EOF); #endif - if (__builtin_expect (now == read_in, 0)) + if (__glibc_unlikely (now == read_in)) /* We haven't succesfully read any character. */ conv_error (); @@ -2911,9 +2911,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, if (errp != NULL) *errp |= errval; - if (__builtin_expect (done == EOF, 0)) + if (__glibc_unlikely (done == EOF)) { - if (__builtin_expect (ptrs_to_free != NULL, 0)) + if (__glibc_unlikely (ptrs_to_free != NULL)) { struct ptrs_to_free *p = ptrs_to_free; while (p != NULL) @@ -2928,7 +2928,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, } } } - else if (__builtin_expect (strptr != NULL, 0)) + else if (__glibc_unlikely (strptr != NULL)) { free (*strptr); *strptr = NULL; diff --git a/stdlib/cxa_finalize.c b/stdlib/cxa_finalize.c index 299a9c0..04f8e9a 100644 --- a/stdlib/cxa_finalize.c +++ b/stdlib/cxa_finalize.c @@ -57,7 +57,7 @@ __cxa_finalize (void *d) /* It is possible that that last exit function registered more exit functions. Start the loop over. */ - if (__builtin_expect (check != __new_exitfn_called, 0)) + if (__glibc_unlikely (check != __new_exitfn_called)) goto restart; } } diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c index d2f88d3..1a6d986 100644 --- a/stdlib/cxa_thread_atexit_impl.c +++ b/stdlib/cxa_thread_atexit_impl.c @@ -52,7 +52,7 @@ __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol) /* See if we already encountered the DSO. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); - if (__builtin_expect (dso_symbol_cache != dso_symbol, 0)) + if (__glibc_unlikely (dso_symbol_cache != dso_symbol)) { ElfW(Addr) caller = (ElfW(Addr)) dso_symbol; diff --git a/stdlib/drand48-iter.c b/stdlib/drand48-iter.c index 10d2969..82e5887 100644 --- a/stdlib/drand48-iter.c +++ b/stdlib/drand48-iter.c @@ -35,7 +35,7 @@ __drand48_iterate (xsubi, buffer) uint64_t result; /* Initialize buffer, if not yet done. */ - if (__builtin_expect (!buffer->__init, 0)) + if (__glibc_unlikely (!buffer->__init)) { buffer->__a = 0x5deece66dull; buffer->__c = 0xb; diff --git a/stdlib/putenv.c b/stdlib/putenv.c index 9bc1687..e6ad267 100644 --- a/stdlib/putenv.c +++ b/stdlib/putenv.c @@ -77,7 +77,7 @@ putenv (string) #endif int result = __add_to_environ (name, NULL, string, 1); - if (__builtin_expect (use_malloc, 0)) + if (__glibc_unlikely (use_malloc)) free (name); return result; diff --git a/stdlib/setenv.c b/stdlib/setenv.c index 6b5f9be..e244e18 100644 --- a/stdlib/setenv.c +++ b/stdlib/setenv.c @@ -191,17 +191,17 @@ __add_to_environ (name, value, combined, replace) # endif np = KNOWN_VALUE (new_value); - if (__builtin_expect (np == NULL, 1)) + if (__glibc_likely (np == NULL)) #endif { #ifdef USE_TSEARCH - if (__builtin_expect (! use_alloca, 0)) + if (__glibc_unlikely (! use_alloca)) np = new_value; else #endif { np = malloc (varlen); - if (__builtin_expect (np == NULL, 0)) + if (__glibc_unlikely (np == NULL)) { UNLOCK; return -1; diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index c80306d..6707e48 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -545,7 +545,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) struct __locale_data *current = loc->__locales[LC_NUMERIC]; - if (__builtin_expect (group, 0)) + if (__glibc_unlikely (group)) { grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) @@ -709,7 +709,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) while (c == L'0' || ((wint_t) thousands != L'\0' && c == (wint_t) thousands)) c = *++cp; #else - if (__builtin_expect (thousands == NULL, 1)) + if (__glibc_likely (thousands == NULL)) while (c == '0') c = *++cp; else @@ -789,7 +789,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) /* Not a digit or separator: end of the integer part. */ break; #else - if (__builtin_expect (thousands == NULL, 1)) + if (__glibc_likely (thousands == NULL)) break; else { @@ -1181,10 +1181,10 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) exponent -= incr; } - if (__builtin_expect (exponent > MAX_10_EXP + 1 - (intmax_t) int_no, 0)) + if (__glibc_unlikely (exponent > MAX_10_EXP + 1 - (intmax_t) int_no)) return overflow_value (negative); - if (__builtin_expect (exponent < MIN_10_EXP - (DIG + 1), 0)) + if (__glibc_unlikely (exponent < MIN_10_EXP - (DIG + 1))) return underflow_value (negative); if (int_no > 0) @@ -1245,7 +1245,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) /* Now we know the exponent of the number in base two. Check it against the maximum possible exponent. */ - if (__builtin_expect (bits > MAX_EXP, 0)) + if (__glibc_unlikely (bits > MAX_EXP)) return overflow_value (negative); /* We have already the first BITS bits of the result. Together with diff --git a/stdlib/strtol_l.c b/stdlib/strtol_l.c index 95c2df3..c77b43d 100644 --- a/stdlib/strtol_l.c +++ b/stdlib/strtol_l.c @@ -255,7 +255,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc) in the format described in . */ const char *grouping; - if (__builtin_expect (group, 0)) + if (__glibc_unlikely (group)) { grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) @@ -297,7 +297,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc) /* Skip white space. */ while (ISSPACE (*s)) ++s; - if (__builtin_expect (*s == L_('\0'), 0)) + if (__glibc_unlikely (*s == L_('\0'))) goto noconv; /* Check for a sign. */ @@ -331,7 +331,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc) if (base != 10) grouping = NULL; - if (__builtin_expect (grouping != NULL, 0)) + if (__glibc_unlikely (grouping != NULL)) { # ifndef USE_WIDE_CHAR thousands_len = strlen (thousands); @@ -499,7 +499,7 @@ INTERNAL (__strtol_l) (nptr, endptr, base, group, loc) overflow = 1; #endif - if (__builtin_expect (overflow, 0)) + if (__glibc_unlikely (overflow)) { __set_errno (ERANGE); #if UNSIGNED diff --git a/string/memmem.c b/string/memmem.c index 93e5e18..b2842fe 100644 --- a/string/memmem.c +++ b/string/memmem.c @@ -53,7 +53,7 @@ memmem (const void *haystack_start, size_t haystack_len, /* Sanity check, otherwise the loop might search through the whole memory. */ - if (__builtin_expect (haystack_len < needle_len, 0)) + if (__glibc_unlikely (haystack_len < needle_len)) return NULL; /* Use optimizations in memchr when possible, to reduce the search diff --git a/string/strerror.c b/string/strerror.c index 5eed633..3d732a2 100644 --- a/string/strerror.c +++ b/string/strerror.c @@ -32,7 +32,7 @@ strerror (errnum) char *ret = __strerror_r (errnum, NULL, 0); int saved_errno; - if (__builtin_expect (ret != NULL, 1)) + if (__glibc_likely (ret != NULL)) return ret; saved_errno = errno; if (buf == NULL) diff --git a/string/strnlen.c b/string/strnlen.c index 8d53afb..b3ab7ae 100644 --- a/string/strnlen.c +++ b/string/strnlen.c @@ -40,7 +40,7 @@ __strnlen (const char *str, size_t maxlen) if (maxlen == 0) return 0; - if (__builtin_expect (end_ptr < str, 0)) + if (__glibc_unlikely (end_ptr < str)) end_ptr = (const char *) ~0UL; /* Handle the first few characters by reading one character at a time. diff --git a/string/test-memmem.c b/string/test-memmem.c index 1b4e4b7..caaa191 100644 --- a/string/test-memmem.c +++ b/string/test-memmem.c @@ -44,7 +44,7 @@ simple_memmem (const void *haystack, size_t haystack_len, const void *needle, /* Sanity check, otherwise the loop might search through the whole memory. */ - if (__builtin_expect (haystack_len < needle_len, 0)) + if (__glibc_unlikely (haystack_len < needle_len)) return NULL; for (begin = (const char *) haystack; begin <= last_possible; ++begin) diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index 1b6a20b..6ffa5f2 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -196,7 +196,7 @@ __libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, # endif } #endif - if (__builtin_expect (*sockp < 0, 0)) + if (__glibc_unlikely (*sockp < 0)) { struct rpc_createerr *ce = &get_rpc_createerr (); ce->cf_stat = RPC_SYSTEMERROR; diff --git a/sunrpc/pm_getport.c b/sunrpc/pm_getport.c index f10f872..d9df0cc 100644 --- a/sunrpc/pm_getport.c +++ b/sunrpc/pm_getport.c @@ -59,7 +59,7 @@ __get_socket (struct sockaddr_in *saddr) laddr.sin_addr.s_addr = htonl (INADDR_ANY); int cc = __bind (so, (struct sockaddr *) &laddr, namelen); - if (__builtin_expect (cc < 0, 0)) + if (__glibc_unlikely (cc < 0)) { fail: __close (so); @@ -67,7 +67,7 @@ __get_socket (struct sockaddr_in *saddr) } cc = __connect (so, (struct sockaddr *) saddr, namelen); - if (__builtin_expect (cc < 0, 0)) + if (__glibc_unlikely (cc < 0)) goto fail; return so; diff --git a/sysdeps/gnu/unwind-resume.c b/sysdeps/gnu/unwind-resume.c index 8963bf6..c7d6870 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 6eb3495..4cf81ee 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 917550c..368bee2 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 21bb990..0f96743 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 10e23e2..588fbfd 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 c83c2ae..e82b302 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 1c42755..a35a9e5 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 88242bc..5cbfcbe 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 ab754c6..bc7ca06 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 f48e43a..236878b 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 0b2889c..05d318b 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 c3d465a..8548ee3 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 890a4a2..997d7ce 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 851b510..4ff28bf 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 5500746..a33758d 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 cfaa22d..389acd4 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 ea1dc6c..fd4dce5 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= 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 c065826..7a6c49a 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 1dce638..0a1e130 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 6402927..874b98e 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 6e7d5ad..0f58034 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 26268f2..ccccdaf 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= 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 6dc7b7d..5ccb78c 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 d03e33e..f2d980d 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 e51c849..1970ce9 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 b22503f..06b9242 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 684858c..8b86b81 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 dbd3fe4..da4fa4d 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 e8da51a..7b72587 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 011adbb..ba0267e 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 48b63ab..1d5f27b 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 a140fb3..205097d 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 1b6e27a..051352f 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 345f390..86996bf 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 4a6e2d5..dd84074 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 da8d71b..dbd3478 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 56c3a81..2b47c52 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 107778d..27b72e2 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 477c3a6..2832f41 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 3939259..56f48f1 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 4c13018..5c0a2e1 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 fa8e27e..11d097c 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 fde2811..354be4e 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 0564321..4983eda 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 27f264b..0bb1399 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 d8c6ec0..4071996 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 8218237..e1a399b 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 e366701..2740b3a 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 4a72c27..d8b1909 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 1f86549..d21c0cc 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -113,7 +113,7 @@ # include # 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 16b786b..9d6f56a 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 4b77966..7ef1e3b 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 96d08c5..23b610f 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 8f834ce..ae9e1b6 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 dd44df5..bc99183 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 302f1a7..2202572 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 b8f8a5b..e7b43ba 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 82d5e4c..401ee1c 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 928581e..4fd2745 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 e919223..2f37169 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 f7d9e07..11a098f 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 8636774..7475421 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 5120837..cb74f34 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 5e5fd6c..4f3db89 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 03441ec..5b61e0a 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 91b125d..e7d31b4 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 85b36cd..9aae20a 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 b285402..ef4ad4c 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 be1927b..82bc186 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 4a1e5b6..d4ca697 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 f3c67ef..7ce6dfc 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 602dfb6..c4f067f 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 0e21134..019e96b 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 45d4680..be49911 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 dd333b4..5c8e75a 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 6608e6a..af13438 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 06abac2..c00f431 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 803988d..4d3e43e 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 b0329cd..196b800 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 ce7290e..89ea20b 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 9acbf36..1ec0922 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 b6195c8..24bd51b 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 00fc6f3..3a4299e 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 14c3048..d69021b 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 7726bb6..5c2359c 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 4180947..8fdbbb8 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 9555c26..024d4d0 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 bcadf8d..f532898 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 4fa61e8..1aa1fcf 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 90abe32..2782eeb 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 01888e9..54f87c9 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 7b88671..d83e8f8 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 ad09be6..29cefb8 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 72d69c5..77099f3 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 e16e418..c5f12d8 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 9bb8ace..2cf233b 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 477f9f8..cb75ffc 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 73983ae..4f5881b 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 61e0a4d..4e3767a 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 0a6aa81..8b37943 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 8fbbd41..7d096d3 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 bcb9a6c..04ff42e 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 8addae2..dbc4c75 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 fa7c8c5..1c6191b 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 020cd9a..91fc275 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 7734533..1f8ebba 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 598ff40..f8494be 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 fef8fd5..cec6fdb 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 46b731e..3b352c6 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 ae9bb35..0c5ed3f 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 a739100..d759f7a 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 8d808ce..d257d25 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 a03d012..6ce85db 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 0925d85..6366c86 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 29f0e54..5aec8af 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 8f3b521..84e42a1 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 4a9a9d9..f52690f 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 62e47e1..9e3643f 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 1249fe8..f0f2f4b 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 504c95f..8df04a9 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; } diff --git a/time/asctime.c b/time/asctime.c index dfbafbf..073cf84 100644 --- a/time/asctime.c +++ b/time/asctime.c @@ -46,7 +46,7 @@ asctime_internal (const struct tm *tp, char *buf, size_t buflen) this would mean the output needs more space. This would not be a problem if the 'asctime_r' interface would be defined sanely and a buffer size would be passed. */ - if (__builtin_expect (tp->tm_year > INT_MAX - 1900, 0)) + if (__glibc_unlikely (tp->tm_year > INT_MAX - 1900)) { eoverflow: __set_errno (EOVERFLOW); diff --git a/time/tzfile.c b/time/tzfile.c index deef58e..52f0994 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -232,7 +232,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) > (SIZE_MAX - total_size) / sizeof (struct ttinfo), 0)) goto lose; total_size += num_types * sizeof (struct ttinfo); - if (__builtin_expect (chars > SIZE_MAX - total_size, 0)) + if (__glibc_unlikely (chars > SIZE_MAX - total_size)) goto lose; total_size += chars; if (__builtin_expect (__alignof__ (struct leap) - 1 @@ -261,16 +261,16 @@ __tzfile_read (const char *file, size_t extra, char **extrap) || tzspec_len < num_leaps * 12, 0)) goto lose; tzspec_len -= num_leaps * 12; - if (__builtin_expect (tzspec_len < num_isstd, 0)) + if (__glibc_unlikely (tzspec_len < num_isstd)) goto lose; tzspec_len -= num_isstd; - if (__builtin_expect (tzspec_len == 0 || tzspec_len - 1 < num_isgmt, 0)) + if (__glibc_unlikely (tzspec_len == 0 || tzspec_len - 1 < num_isgmt)) goto lose; tzspec_len -= num_isgmt + 1; - if (__builtin_expect (SIZE_MAX - total_size < tzspec_len, 0)) + if (__glibc_unlikely (SIZE_MAX - total_size < tzspec_len)) goto lose; } - if (__builtin_expect (SIZE_MAX - total_size - tzspec_len < extra, 0)) + if (__glibc_unlikely (SIZE_MAX - total_size - tzspec_len < extra)) goto lose; /* Allocate enough memory including the extra block requested by the @@ -310,7 +310,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) /* Check for bogus indices in the data file, so we can hereafter safely use type_idxs[T] as indices into `types' and never crash. */ for (i = 0; i < num_transitions; ++i) - if (__builtin_expect (type_idxs[i] >= num_types, 0)) + if (__glibc_unlikely (type_idxs[i] >= num_types)) goto lose; if ((BYTE_ORDER != BIG_ENDIAN && (sizeof (time_t) == 4 || trans_width == 4)) @@ -341,18 +341,18 @@ __tzfile_read (const char *file, size_t extra, char **extrap) 0)) goto lose; c = getc_unlocked (f); - if (__builtin_expect ((unsigned int) c > 1u, 0)) + if (__glibc_unlikely ((unsigned int) c > 1u)) goto lose; types[i].isdst = c; c = getc_unlocked (f); - if (__builtin_expect ((size_t) c > chars, 0)) + if (__glibc_unlikely ((size_t) c > chars)) /* Bogus index in data file. */ goto lose; types[i].idx = c; types[i].offset = (long int) decode (x); } - if (__builtin_expect (fread_unlocked (zone_names, 1, chars, f) != chars, 0)) + if (__glibc_unlikely (fread_unlocked (zone_names, 1, chars, f) != chars)) goto lose; for (i = 0; i < num_leaps; ++i) @@ -366,7 +366,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) else leaps[i].transition = (time_t) decode64 (x); - if (__builtin_expect (fread_unlocked (x, 1, 4, f) != 4, 0)) + if (__glibc_unlikely (fread_unlocked (x, 1, 4, f) != 4)) goto lose; leaps[i].change = (long int) decode (x); } @@ -374,7 +374,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) for (i = 0; i < num_isstd; ++i) { int c = getc_unlocked (f); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) goto lose; types[i].isstd = c != 0; } @@ -384,7 +384,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) for (i = 0; i < num_isgmt; ++i) { int c = getc_unlocked (f); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) goto lose; types[i].isgmt = c != 0; } @@ -627,7 +627,7 @@ __tzfile_compute (time_t timer, int use_localtime, __tzname[0] = NULL; __tzname[1] = NULL; - if (__builtin_expect (num_transitions == 0 || timer < transitions[0], 0)) + if (__glibc_unlikely (num_transitions == 0 || timer < transitions[0])) { /* TIMER is before any transition (or there are no transitions). Choose the first non-DST type @@ -657,9 +657,9 @@ __tzfile_compute (time_t timer, int use_localtime, ++j; } } - else if (__builtin_expect (timer >= transitions[num_transitions - 1], 0)) + else if (__glibc_unlikely (timer >= transitions[num_transitions - 1])) { - if (__builtin_expect (tzspec == NULL, 0)) + if (__glibc_unlikely (tzspec == NULL)) { use_last: i = num_transitions; @@ -671,7 +671,7 @@ __tzfile_compute (time_t timer, int use_localtime, /* Convert to broken down structure. If this fails do not use the string. */ - if (__builtin_expect (! __offtime (&timer, 0, tp), 0)) + if (__glibc_unlikely (! __offtime (&timer, 0, tp))) goto use_last; /* Use the rules from the TZ string to compute the change. */ @@ -680,7 +680,7 @@ __tzfile_compute (time_t timer, int use_localtime, /* If tzspec comes from posixrules loaded by __tzfile_default, override the STD and DST zone names with the ones user requested in TZ envvar. */ - if (__builtin_expect (zone_names == (char *) &leaps[num_leaps], 0)) + if (__glibc_unlikely (zone_names == (char *) &leaps[num_leaps])) { assert (num_types == 2); __tzname[0] = __tzstring (zone_names); @@ -762,7 +762,7 @@ __tzfile_compute (time_t timer, int use_localtime, ++j; } - if (__builtin_expect (__tzname[0] == NULL, 0)) + if (__glibc_unlikely (__tzname[0] == NULL)) __tzname[0] = __tzname[1]; i = type_idxs[i - 1]; diff --git a/time/tzset.c b/time/tzset.c index bfcd943..77bfde9 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -184,16 +184,16 @@ __tzset_parse_tz (tz) { /* Check for the quoted version. */ char *wp = tzbuf; - if (__builtin_expect (*tz++ != '<', 0)) + if (__glibc_unlikely (*tz++ != '<')) goto out; while (isalnum (*tz) || *tz == '+' || *tz == '-') *wp++ = *tz++; - if (__builtin_expect (*tz++ != '>' || wp - tzbuf < 3, 0)) + if (__glibc_unlikely (*tz++ != '>' || wp - tzbuf < 3)) goto out; *wp = '\0'; } - else if (__builtin_expect (consumed < 3, 0)) + else if (__glibc_unlikely (consumed < 3)) goto out; else tz += consumed; @@ -232,19 +232,19 @@ __tzset_parse_tz (tz) /* Check for the quoted version. */ char *wp = tzbuf; const char *rp = tz; - if (__builtin_expect (*rp++ != '<', 0)) + if (__glibc_unlikely (*rp++ != '<')) /* Punt on name, set up the offsets. */ goto done_names; while (isalnum (*rp) || *rp == '+' || *rp == '-') *wp++ = *rp++; - if (__builtin_expect (*rp++ != '>' || wp - tzbuf < 3, 0)) + if (__glibc_unlikely (*rp++ != '>' || wp - tzbuf < 3)) /* Punt on name, set up the offsets. */ goto done_names; *wp = '\0'; tz = rp; } - else if (__builtin_expect (consumed < 3, 0)) + else if (__glibc_unlikely (consumed < 3)) /* Punt on name, set up the offsets. */ goto done_names; else diff --git a/wcsmbs/mbrtoc16.c b/wcsmbs/mbrtoc16.c index 9fa31bc..643aaf5 100644 --- a/wcsmbs/mbrtoc16.c +++ b/wcsmbs/mbrtoc16.c @@ -88,7 +88,7 @@ mbrtoc16 (char16_t *pc16, const char *s, size_t n, mbstate_t *ps) /* Do a normal conversion. */ inbuf = (const unsigned char *) s; endbuf = inbuf + n; - if (__builtin_expect (endbuf < inbuf, 0)) + if (__glibc_unlikely (endbuf < inbuf)) { endbuf = (const unsigned char *) ~(uintptr_t) 0; if (endbuf == inbuf) diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c index 6eeaa55..c57217a 100644 --- a/wcsmbs/mbrtowc.c +++ b/wcsmbs/mbrtowc.c @@ -70,7 +70,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) /* Do a normal conversion. */ inbuf = (const unsigned char *) s; endbuf = inbuf + n; - if (__builtin_expect (endbuf < inbuf, 0)) + if (__glibc_unlikely (endbuf < inbuf)) { endbuf = (const unsigned char *) ~(uintptr_t) 0; if (endbuf == inbuf) diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c index 8267faf..84733b3 100644 --- a/wcsmbs/wcsmbsload.c +++ b/wcsmbs/wcsmbsload.c @@ -156,7 +156,7 @@ __wcsmbs_load_conv (struct __locale_data *new_category) /* We should repeat the test since while we waited some other thread might have run this function. */ - if (__builtin_expect (new_category->private.ctype == NULL, 1)) + if (__glibc_likely (new_category->private.ctype == NULL)) { /* We must find the real functions. */ const char *charset_name; diff --git a/wcsmbs/wcsmbsload.h b/wcsmbs/wcsmbsload.h index a709428..7636da7 100644 --- a/wcsmbs/wcsmbsload.h +++ b/wcsmbs/wcsmbsload.h @@ -68,9 +68,9 @@ extern const struct __locale_data _nl_C_LC_CTYPE attribute_hidden; static inline const struct gconv_fcts * get_gconv_fcts (struct __locale_data *data) { - if (__builtin_expect (data->private.ctype == NULL, 0)) + if (__glibc_unlikely (data->private.ctype == NULL)) { - if (__builtin_expect (data == &_nl_C_LC_CTYPE, 0)) + if (__glibc_unlikely (data == &_nl_C_LC_CTYPE)) return &__wcsmbs_gconv_fcts_c; __wcsmbs_load_conv (data); } -- 2.7.4