This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use __glibc_(un)likely instead __builtin_expect.


Hi,

Now I return to one of todo-list issues which is using glibc-likely/unlikely.

First comes a easy case which can be expressed as following script.

cat $1 | sed -e "s/if (__builtin_expect (\(.*\), 0))/if (__glibc_unlikely (\1))/" | sed -e "s/if (__builtin_expect (\(.*\), 1))/if (__glibc_likely (\1))/"

After running it and fixing trailing spaces in macros a patch is
following:

./nptl/ChangeLog:


	* allocatestack.c: Use __libc_likely instead __builtin_expect.
	* cancellation.c: Likewise.
	* cleanup_defer.c: Likewise.
	* cleanup_defer_compat.c: Likewise.
	* cond-perf.c: Likewise.
	* nptl-init.c: Likewise.
	* perf.c: Likewise.
	* pthread_barrier_destroy.c: Likewise.
	* pthread_barrier_init.c: Likewise.
	* pthread_cond_timedwait.c: Likewise.
	* pthread_cond_wait.c: Likewise.
	* pthread_create.c: Likewise.
	* pthread_getattr_np.c: Likewise.
	* pthread_getspecific.c: Likewise.
	* pthread_join.c: Likewise.
	* pthread_key_delete.c: Likewise.
	* pthread_mutex_init.c: Likewise.
	* pthread_mutex_lock.c: Likewise.
	* pthread_mutex_timedlock.c: Likewise.
	* pthread_mutex_trylock.c: Likewise.
	* pthread_mutex_unlock.c: Likewise.
	* pthread_rwlock_rdlock.c: Likewise.
	* pthread_rwlock_timedrdlock.c: Likewise.
	* pthread_rwlock_timedwrlock.c: Likewise.
	* pthread_rwlock_tryrdlock.c: Likewise.
	* pthread_setcancelstate.c: Likewise.
	* pthread_setcanceltype.c: Likewise.
	* pthread_setschedprio.c: Likewise.
	* pthread_setspecific.c: Likewise.
	* sem_init.c: Likewise.
	* sem_open.c: Likewise.
	* sigaction.c: Likewise.
	* sockperf.c: Likewise.
	* sysdeps/pthread/createthread.c: Likewise.
	* sysdeps/pthread/setxid.h: Likewise.
	* sysdeps/pthread/timer_create.c: Likewise.
	* sysdeps/pthread/unwind-forcedunwind.c: Likewise.
	* sysdeps/unix/sysv/linux/fork.c: Likewise.
	* sysdeps/unix/sysv/linux/getpid.c: Likewise.
	* sysdeps/unix/sysv/linux/lowlevelrobustlock.c: Likewise.
	* sysdeps/unix/sysv/linux/mq_notify.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/pthread_kill.c: Likewise.
	* sysdeps/unix/sysv/linux/pthread_setaffinity.c: Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigqueue.c: Likewise.
	* sysdeps/unix/sysv/linux/pt-raise.c: Likewise.
	* sysdeps/unix/sysv/linux/raise.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sem_init.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/timer_create.c: Likewise.
	* unwind.c: Likewise.

./ChangeLog:


	* assert/assert.c: Use __libc_likely instead __builtin_expect.
	* benchtests/bench-memmem.c: Likewise.
	* catgets/open_catalog.c: Likewise.
	* csu/libc-start.c: Likewise.
	* csu/libc-tls.c: Likewise.
	* debug/confstr_chk.c: Likewise.
	* debug/fread_chk.c: Likewise.
	* debug/fread_u_chk.c: 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: Likewise.
	* debug/stpncpy_chk.c: Likewise.
	* debug/strcat_chk.c: Likewise.
	* debug/strcpy_chk.c: Likewise.
	* debug/strncat_chk.c: Likewise.
	* debug/strncpy_chk.c: Likewise.
	* debug/vsnprintf_chk.c: Likewise.
	* debug/vswprintf_chk.c: Likewise.
	* debug/wcpcpy_chk.c: Likewise.
	* debug/wcpncpy_chk.c: Likewise.
	* debug/wcscat_chk.c: Likewise.
	* debug/wcscpy_chk.c: Likewise.
	* debug/wcsncat_chk.c: 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: Likewise.
	* dlfcn/dladdr1.c: Likewise.
	* dlfcn/dladdr.c: Likewise.
	* dlfcn/dlclose.c: Likewise.
	* dlfcn/dlerror.c: Likewise.
	* dlfcn/dlinfo.c: Likewise.
	* dlfcn/dlmopen.c: Likewise.
	* dlfcn/dlopen.c: Likewise.
	* dlfcn/dlopenold.c: Likewise.
	* dlfcn/dlsym.c: Likewise.
	* dlfcn/dlvsym.c: Likewise.
	* elf/dl-cache.c: Likewise.
	* elf/dl-close.c: Likewise.
	* elf/dl-conflict.c: Likewise.
	* elf/dl-deps.c: Likewise.
	* elf/dl-dst.h: Likewise.
	* elf/dl-fini.c: Likewise.
	* elf/dl-fptr.c: Likewise.
	* elf/dl-hwcaps.c: Likewise.
	* elf/dl-init.c: Likewise.
	* elf/dl-libc.c: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-minimal.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-runtime.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-sysdep.c: Likewise.
	* elf/dl-tls.c: Likewise.
	* elf/dl-version.c: Likewise.
	* elf/dl-writev.h: Likewise.
	* elf/ldconfig.c: Likewise.
	* elf/rtld.c: Likewise.
	* elf/setup-vdso.h: Likewise.
	* grp/compat-initgroups.c: Likewise.
	* grp/fgetgrent.c: Likewise.
	* grp/initgroups.c: Likewise.
	* grp/putgrent.c: Likewise.
	* hesiod/nss_hesiod/hesiod-grp.c: Likewise.
	* hurd/hurdinit.c: Likewise.
	* iconvdata/8bit-gap.c: 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: Likewise.
	* iconvdata/gb18030.c: Likewise.
	* iconvdata/gbbig5.c: 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: Likewise.
	* iconvdata/iso-2022-kr.c: Likewise.
	* iconvdata/iso646.c: Likewise.
	* iconvdata/iso_6937-2.c: Likewise.
	* iconvdata/iso_6937.c: Likewise.
	* iconvdata/iso8859-1.c: Likewise.
	* iconvdata/johab.c: 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: Likewise.
	* iconvdata/utf-16.c: Likewise.
	* iconvdata/utf-32.c: Likewise.
	* iconvdata/utf-7.c: Likewise.
	* iconv/gconv_cache.c: Likewise.
	* iconv/gconv_close.c: Likewise.
	* iconv/gconv_open.c: Likewise.
	* iconv/gconv_simple.c: Likewise.
	* iconv/iconv.c: Likewise.
	* iconv/iconv_close.c: Likewise.
	* iconv/loop.c: Likewise.
	* iconv/skeleton.c: Likewise.
	* include/atomic.h: Likewise.
	* inet/inet6_option.c: Likewise.
	* intl/bindtextdom.c: Likewise.
	* intl/dcigettext.c: Likewise.
	* intl/loadmsgcat.c: Likewise.
	* intl/localealias.c: Likewise.
	* libio/filedoalloc.c: Likewise.
	* libio/fileops.c: Likewise.
	* libio/fmemopen.c: Likewise.
	* libio/iofgets.c: Likewise.
	* libio/iofgets_u.c: Likewise.
	* libio/iofgetws.c: Likewise.
	* libio/iofgetws_u.c: Likewise.
	* libio/iogetdelim.c: Likewise.
	* libio/wfileops.c: Likewise.
	* locale/findlocale.c: Likewise.
	* locale/loadarchive.c: Likewise.
	* locale/loadlocale.c: Likewise.
	* locale/setlocale.c: Likewise.
	* login/programs/pt_chown.c: Likewise.
	* malloc/arena.c: Likewise.
	* malloc/malloc.c: Likewise.
	* malloc/memusage.c: Likewise.
	* math/e_exp2l.c: Likewise.
	* math/e_scalb.c: Likewise.
	* math/e_scalbf.c: Likewise.
	* math/e_scalbl.c: Likewise.
	* math/s_catan.c: Likewise.
	* math/s_catanf.c: Likewise.
	* math/s_catanh.c: Likewise.
	* math/s_catanhf.c: Likewise.
	* math/s_catanhl.c: Likewise.
	* math/s_catanl.c: Likewise.
	* math/s_ccosh.c: Likewise.
	* math/s_ccoshf.c: Likewise.
	* math/s_ccoshl.c: Likewise.
	* math/s_cexp.c: Likewise.
	* math/s_cexpf.c: Likewise.
	* math/s_cexpl.c: Likewise.
	* math/s_clog10.c: Likewise.
	* math/s_clog10f.c: Likewise.
	* math/s_clog10l.c: Likewise.
	* math/s_clog.c: Likewise.
	* math/s_clogf.c: Likewise.
	* math/s_clogl.c: Likewise.
	* math/s_csin.c: Likewise.
	* math/s_csinf.c: Likewise.
	* math/s_csinh.c: Likewise.
	* math/s_csinhf.c: Likewise.
	* math/s_csinhl.c: Likewise.
	* math/s_csinl.c: Likewise.
	* math/s_csqrt.c: Likewise.
	* math/s_csqrtf.c: Likewise.
	* math/s_csqrtl.c: Likewise.
	* math/s_ctan.c: Likewise.
	* math/s_ctanf.c: Likewise.
	* math/s_ctanh.c: Likewise.
	* math/s_ctanhf.c: Likewise.
	* math/s_ctanhl.c: Likewise.
	* math/s_ctanl.c: Likewise.
	* math/w_pow.c: Likewise.
	* math/w_powf.c: Likewise.
	* math/w_powl.c: Likewise.
	* math/w_scalb.c: Likewise.
	* math/w_scalbf.c: Likewise.
	* math/w_scalbl.c: Likewise.
	* misc/error.c: Likewise.
	* misc/pselect.c: Likewise.
	* nis/nis_callback.c: Likewise.
	* nis/nis_call.c: Likewise.
	* nis/nis_creategroup.c: Likewise.
	* nis/nis_domain_of_r.c: Likewise.
	* nis/nis_findserv.c: Likewise.
	* nis/nis_getservlist.c: Likewise.
	* nis/nis_lookup.c: Likewise.
	* nis/nis_subr.c: Likewise.
	* nis/nis_table.c: Likewise.
	* nis/nis_xdr.c: Likewise.
	* nis/nss_compat/compat-grp.c: Likewise.
	* nis/nss_compat/compat-initgroups.c: Likewise.
	* nis/nss_compat/compat-pwd.c: Likewise.
	* nis/nss_compat/compat-spwd.c: Likewise.
	* nis/nss_nis/nis-alias.c: Likewise.
	* nis/nss_nis/nis-ethers.c: Likewise.
	* nis/nss_nis/nis-grp.c: Likewise.
	* nis/nss_nis/nis-hosts.c: Likewise.
	* nis/nss_nis/nis-initgroups.c: Likewise.
	* nis/nss_nis/nis-netgrp.c: Likewise.
	* nis/nss_nis/nis-network.c: Likewise.
	* nis/nss_nis/nis-proto.c: Likewise.
	* nis/nss_nis/nis-publickey.c: Likewise.
	* nis/nss_nis/nis-pwd.c: Likewise.
	* nis/nss_nis/nis-rpc.c: Likewise.
	* nis/nss_nis/nis-service.c: Likewise.
	* nis/nss_nis/nis-spwd.c: Likewise.
	* nis/nss_nisplus/nisplus-alias.c: Likewise.
	* nis/nss_nisplus/nisplus-ethers.c: Likewise.
	* nis/nss_nisplus/nisplus-grp.c: Likewise.
	* nis/nss_nisplus/nisplus-hosts.c: Likewise.
	* nis/nss_nisplus/nisplus-initgroups.c: Likewise.
	* nis/nss_nisplus/nisplus-network.c: Likewise.
	* nis/nss_nisplus/nisplus-proto.c: Likewise.
	* nis/nss_nisplus/nisplus-pwd.c: Likewise.
	* nis/nss_nisplus/nisplus-rpc.c: Likewise.
	* nis/nss_nisplus/nisplus-service.c: Likewise.
	* nis/nss_nisplus/nisplus-spwd.c: Likewise.
	* nis/ypclnt.c: Likewise.
	* nscd/aicache.c: Likewise.
	* nscd/cache.c: Likewise.
	* nscd/connections.c: Likewise.
	* nscd/grpcache.c: Likewise.
	* nscd/hstcache.c: Likewise.
	* nscd/initgrcache.c: Likewise.
	* nscd/mem.c: Likewise.
	* nscd/netgroupcache.c: Likewise.
	* nscd/nscd-client.h: Likewise.
	* nscd/nscd_getai.c: Likewise.
	* nscd/nscd_getgr_r.c: Likewise.
	* nscd/nscd_gethst_r.c: Likewise.
	* nscd/nscd_getpw_r.c: Likewise.
	* nscd/nscd_getserv_r.c: Likewise.
	* nscd/nscd_helper.c: Likewise.
	* nscd/nscd_initgroups.c: Likewise.
	* nscd/nscd_netgroup.c: Likewise.
	* nscd/pwdcache.c: Likewise.
	* nscd/selinux.c: Likewise.
	* nscd/servicescache.c: Likewise.
	* nss/nss_files/files-XXX.c: Likewise.
	* posix/fnmatch.c: Likewise.
	* posix/fnmatch_loop.c: Likewise.
	* posix/getopt.c: Likewise.
	* posix/glob.c: Likewise.
	* posix/wordexp.c: Likewise.
	* resolv/nss_dns/dns-host.c: Likewise.
	* resolv/nss_dns/dns-network.c: Likewise.
	* resolv/res_init.c: Likewise.
	* resolv/res_mkquery.c: Likewise.
	* resolv/res_query.c: Likewise.
	* resolv/res_send.c: Likewise.
	* stdio-common/_i18n_number.h: Likewise.
	* stdio-common/perror.c: Likewise.
	* stdio-common/printf_fp.c: Likewise.
	* stdio-common/tmpnam.c: Likewise.
	* stdio-common/vfscanf.c: Likewise.
	* stdlib/cxa_finalize.c: Likewise.
	* stdlib/cxa_thread_atexit_impl.c: Likewise.
	* stdlib/drand48-iter.c: Likewise.
	* stdlib/putenv.c: Likewise.
	* stdlib/setenv.c: Likewise.
	* stdlib/strtod_l.c: Likewise.
	* stdlib/strtol_l.c: Likewise.
	* string/memmem.c: Likewise.
	* string/strerror.c: Likewise.
	* string/strnlen.c: Likewise.
	* string/test-memmem.c: Likewise.
	* sunrpc/clnt_udp.c: Likewise.
	* sunrpc/pm_getport.c: Likewise.
	* sysdeps/gnu/unwind-resume.c: Likewise.
	* sysdeps/i386/dl-irel.h: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* sysdeps/ieee754/dbl-64/e_atanh.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp2.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_fmod.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_hypot.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_j1.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_log10.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_log2.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_log.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_sinh.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_log1p.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_logb.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_modf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_scalbln.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_scalbn.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_round.c: Likewise.
	* sysdeps/ieee754/flt-32/e_atanhf.c: Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
	* sysdeps/ieee754/flt-32/s_logbf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_logbl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_j0l.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_j1l.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
	* sysdeps/mach/hurd/check_fds.c: Likewise.
	* sysdeps/mach/hurd/dl-execstack.c: Likewise.
	* sysdeps/posix/clock_getres.c: Likewise.
	* sysdeps/posix/fdopendir.c: Likewise.
	* sysdeps/posix/getaddrinfo.c: Likewise.
	* sysdeps/posix/opendir.c: Likewise.
	* sysdeps/posix/sleep.c: Likewise.
	* sysdeps/posix/tempname.c: Likewise.
	* sysdeps/powerpc/powerpc32/dl-irel.h: Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.c: Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_logbf.c: Likewise.
	* sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c: Likewise.
	* sysdeps/powerpc/powerpc64/dl-irel.h: Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/power4/fpu/w_sqrt.c: Likewise.
	* sysdeps/powerpc/powerpc64/power4/fpu/w_sqrtf.c: Likewise.
	* sysdeps/pthread/aio_notify.c: Likewise.
	* sysdeps/pthread/aio_suspend.c: Likewise.
	* sysdeps/s390/dl-irel.h: Likewise.
	* sysdeps/s390/s390-32/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/utf16-utf32-z9.c: Likewise.
	* sysdeps/s390/s390-64/utf8-utf16-z9.c: Likewise.
	* sysdeps/s390/s390-64/utf8-utf32-z9.c: Likewise.
	* sysdeps/sh/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc32/dl-irel.h: Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc64/dl-irel.h: Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc64/dl-plt.h: Likewise.
	* sysdeps/unix/clock_gettime.c: Likewise.
	* sysdeps/unix/clock_settime.c: Likewise.
	* sysdeps/unix/grantpt.c: Likewise.
	* sysdeps/unix/sysv/linux/accept4.c: Likewise.
	* sysdeps/unix/sysv/linux/adjtime.c: Likewise.
	* sysdeps/unix/sysv/linux/check_pf.c: Likewise.
	* sysdeps/unix/sysv/linux/dl-osinfo.h: Likewise.
	* sysdeps/unix/sysv/linux/faccessat.c: Likewise.
	* sysdeps/unix/sysv/linux/fchmodat.c: Likewise.
	* sysdeps/unix/sysv/linux/fchownat.c: Likewise.
	* sysdeps/unix/sysv/linux/futimesat.c: Likewise.
	* sysdeps/unix/sysv/linux/fxstatat64.c: Likewise.
	* sysdeps/unix/sysv/linux/fxstatat.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/fchownat.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/fxstatat.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/posix_fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/posix_fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/ifaddrs.c: Likewise.
	* sysdeps/unix/sysv/linux/linkat.c: Likewise.
	* sysdeps/unix/sysv/linux/malloc-sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/mkdirat.c: Likewise.
	* sysdeps/unix/sysv/linux/mq_unlink.c: Likewise.
	* sysdeps/unix/sysv/linux/openat.c: Likewise.
	* sysdeps/unix/sysv/linux/posix_fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/posix_fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/fchownat.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c: Likewise.
	* sysdeps/unix/sysv/linux/readlinkat.c: Likewise.
	* sysdeps/unix/sysv/linux/recvmmsg.c: Likewise.
	* sysdeps/unix/sysv/linux/renameat.c: 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: Likewise.
	* sysdeps/unix/sysv/linux/shm_open.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/sleep.c: Likewise.
	* sysdeps/unix/sysv/linux/symlinkat.c: Likewise.
	* sysdeps/unix/sysv/linux/tcgetattr.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
	* sysdeps/unix/sysv/linux/unlinkat.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/xmknodat.c: Likewise.
	* sysdeps/x86_64/dl-irel.h: Likewise.
	* sysdeps/x86_64/dl-machine.h: Likewise.
	* sysdeps/x86_64/multiarch/strstr.c: Likewise.
	* time/asctime.c: Likewise.
	* time/tzfile.c: Likewise.
	* time/tzset.c: Likewise.
	* wcsmbs/mbrtoc16.c: Likewise.
	* wcsmbs/mbrtowc.c: Likewise.
	* wcsmbs/wcsmbsload.c: Likewise.
	* wcsmbs/wcsmbsload.h: Likewise.


diff --git a/assert/assert.c b/assert/assert.c
index 61e7f6b..30bd725 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 b8f8a8b..c7bd8f2 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 a6c14de..fdaf77c 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 c898d06..d53d10f 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 40498c8..0881211 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 2a98fd3..18a6afb 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 0731ae7..d9e8d67 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 a33f83b..043a56a 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 a85d4b4..d9d74d3 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 4465cfc..8e78662 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 323f65b..8f5b6b0 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 a53dd76..029a9e6 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 ();
 
   unsigned long int dstp = (long int) dstpp;
diff --git a/debug/memmove_chk.c b/debug/memmove_chk.c
index 3ea34c6..030cfa2 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 ();
 
   unsigned long int dstp = (long int) dest;
diff --git a/debug/mempcpy_chk.c b/debug/mempcpy_chk.c
index 6895883..74c8d4b 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 ();
 
   unsigned long int dstp = (long int) dstpp;
diff --git a/debug/memset_chk.c b/debug/memset_chk.c
index bfbc29d..80e24a1 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 ();
 
   long int dstp = (long int) dstpp;
diff --git a/debug/stpcpy_chk.c b/debug/stpcpy_chk.c
index b16b83d..6071b49 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/stpncpy_chk.c b/debug/stpncpy_chk.c
index 35a2c23..f3d8b89 100644
--- a/debug/stpncpy_chk.c
+++ b/debug/stpncpy_chk.c
@@ -28,7 +28,7 @@ __stpncpy_chk (char *dest, const char *src, size_t n, size_t destlen)
   char c;
   char *s = dest;
 
-  if (__builtin_expect (destlen < n, 0))
+  if (__glibc_unlikely (destlen < n))
     __chk_fail ();
 
   if (n >= 4)
diff --git a/debug/strcat_chk.c b/debug/strcat_chk.c
index 20623d4..0584fdc 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 81bf46f..5b6683b 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 5e14aff..4c922b8 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/strncpy_chk.c b/debug/strncpy_chk.c
index d067bd9..80ee1b6 100644
--- a/debug/strncpy_chk.c
+++ b/debug/strncpy_chk.c
@@ -29,7 +29,7 @@ __strncpy_chk (s1, s2, n, s1len)
   char c;
   char *s = s1;
 
-  if (__builtin_expect (s1len < n, 0))
+  if (__glibc_unlikely (s1len < n))
     __chk_fail ();
 
   --s1;
diff --git a/debug/vsnprintf_chk.c b/debug/vsnprintf_chk.c
index 8924f99..61d4c09 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 b298a0b..fc5b89ed 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 7c836e6..f1d7cee 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 a24e8fa..317cbc9 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 2bd7e76..ec9aa8e 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 61092c3..4453ef2 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 650e93d..b5682f8 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 89762d0..3644a79 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 47d649b..c5f19c7 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 cd1a107..5387e21 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 2de1d9f..9571a86 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 fe5fd9c..e0ec1f3 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 474c9d0..5961dc2 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 1fe3511..4c79114 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 537cd2a..0f7d74e 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 0f2a440..26705c6 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 9c09f70..8ba81ac 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 3b2f3f3..b5d13eb 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 df34a0c..61f6eb6 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 0ae2bbe..6fb9404 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 91795d3..1b091f9 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 5e32f5d..38e03cd 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 899a4f5..67ac013 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 fa587af..6a67482 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 ad5eee6..4105dc2 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 fd95267..f9ed250 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 0b68d18..529a5f0 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 fe3014c..172847e 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);
 
@@ -281,7 +281,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)
@@ -453,7 +453,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);
@@ -537,7 +537,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;
 
@@ -665,7 +665,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);
 
@@ -707,7 +707,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))
@@ -716,7 +716,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.  */
@@ -766,7 +766,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 11e3cd8..15f2eb2 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 6652f6d..2575e83 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 3ed95d0..21b5c5d 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 6b245f0..458aaf1 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 45e3abc..1800391 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 94cbf6c..2d794db 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 a657eb6..1b96597 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));
 
@@ -94,7 +94,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;
@@ -108,7 +108,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 397d898..d275b64 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 6a73f27..24f0e4a 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;
@@ -557,7 +557,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);
@@ -830,7 +830,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
 	{
@@ -929,7 +929,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:
@@ -993,7 +993,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'.  */
@@ -1051,7 +1051,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:
@@ -1220,7 +1220,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);
@@ -1250,7 +1250,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
@@ -1288,7 +1288,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");
@@ -1315,7 +1315,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;
@@ -1373,7 +1373,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
@@ -1385,7 +1385,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);
 	      }
@@ -1397,7 +1397,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;
@@ -1411,7 +1411,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;
@@ -1461,7 +1461,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)
@@ -1484,7 +1484,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)
@@ -1520,7 +1520,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;
@@ -1533,7 +1533,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",
@@ -1748,7 +1748,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
@@ -1933,7 +1933,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;
@@ -1971,7 +1971,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,
@@ -2053,7 +2053,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.  */
@@ -2159,7 +2159,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 39f463e..137fcdc 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 82cc15d..962229c 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 1403c8c..451d517 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 5c54310..a12e602 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 8284748..b190abd 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 05de6c1..dd0d636 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 576d9a1..46e3aa3 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 62be4ae..0ec82a9 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 0fc0b2b..a4fbef1 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 c7b9eb9..21da007 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 51682f2..b3696de 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);
@@ -1391,7 +1391,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;
@@ -1425,7 +1425,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 ("\
@@ -1541,7 +1541,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) };
 
@@ -1590,7 +1590,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)
@@ -1609,7 +1609,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
@@ -1640,12 +1640,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
@@ -1717,7 +1717,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;
@@ -1754,7 +1754,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
@@ -1812,7 +1812,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 ();
@@ -2096,7 +2096,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");
     }
@@ -2114,7 +2114,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");
 
@@ -2212,7 +2212,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 ();
     }
@@ -2239,7 +2239,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);
     }
@@ -2280,7 +2280,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 056d885..34bdc40 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 a5fed92..2cbbe635 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 932d8fb..3206cf4 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 43261bf..e191d81 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 b11952f..dc0f433 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 3b3619e..8758fd3 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 ccd2d6e..e3440df 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 89b8d7f..c0a66d8 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 99c3377..0e25392 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 9c5ff80..856a701 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 93ca171..ca4e73b 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 05ecf4a..fef1f93 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 ad0181f..8ae7a61 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 6997e05..b6ac0a6 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 1f0e49d..3af4b3f 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 d3acc00..3d3c29e 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 8894d97..4fa7f94 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 5487323..863a3e0 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 150ae3c..babef37 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 d128ea7..1d2bbdc 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 19a83fa..27e2ab3 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 9cf3a48..ab76a2a 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 cf04f32..9c85e02 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 883da6a..e6b2754 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 37dd1b9..2bad50f 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 1b3f532..8ddb3fa 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 f675b29..d74d4c9 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 bb75fa7..a18d3b2 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 8568e3a..845007b 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 e3b888a..a2842ec 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 0dfa250..fb7ac44 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 86477a7..7dedb5b 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 0764fb2..4617f53 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 145d12f..eb706e8 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 7d5628b..d7a3e2b 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 b913cbb..2db74af 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 d42b98c..79f8e0b 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 b3a6555..f96f7d7 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 4d2f58b..7e248ea 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 e15fa9f..570a573 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 03eb610..5487dbd 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 7fb513f..dd87de6 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 8e26ea9..178f728 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 891ad69..ece8048 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 349cd6f..b25a684 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 de70529..381cac3 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 a76c273..fb2bcd6 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 02aecf9..7dafd46 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 18525cf..2b8a818 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 9c15e68..daa959b 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 26fa20a..f9f7d61 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 6f7663d..5f5717c 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 1c0bd2c..271a177 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 3cf17e6..1fca14b 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 ee3aad9..72af30a 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 250b207..f7e67be 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 5d6c92d..37d2af4 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 6d3e6da..65f76fa 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 8290278..69c8559 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 92dbcc5..6a0c6e4 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 f8000a1..7eee4e8 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 e4cc8d4..4103192 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 f4aa215..4ad2118 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 ac90ed1..9c8fa2a 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 ee71eaf..c7537c6 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 1408e3d..6bb5bd1 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 c58e860..c3c4b91 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 02c764f..6466b45 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 bab5aa5..3e445fa 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 9b32fea..3b6788f 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 086d685..c48d808 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 1584bee..39a03f7 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 a7304c5..d563af3 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 0a156ea..9cd9d52 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;
@@ -752,7 +752,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 3c04aa8..ec3cb45 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 70136dc..43647a1 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
@@ -455,11 +455,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;
@@ -474,7 +474,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 45162f1..d78e508 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 e83a156..d8af894 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 598f5dd..64e1c4a 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 d81ed0d..19f02d8 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -387,7 +387,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;
@@ -623,7 +623,7 @@ shrink_heap(heap_info *h, long diff)
     return -1;
   /* 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)
@@ -867,12 +867,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 1a18c3f..7babf7d 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2447,7 +2447,7 @@ static void* sysmalloc(INTERNAL_SIZE_T nb, mstate av)
   if (brk != (char*)(MORECORE_FAILURE)) {
     /* Call the `morecore' hook if necessary.  */
     void (*hook) (void) = force_reg (__after_morecore_hook);
-    if (__builtin_expect (hook != NULL, 0))
+    if (__glibc_unlikely (hook != NULL))
       (*hook) ();
   } else {
   /*
@@ -2585,7 +2585,7 @@ static void* sysmalloc(INTERNAL_SIZE_T nb, mstate av)
 	} else {
 	  /* Call the `morecore' hook if necessary.  */
 	  void (*hook) (void) = force_reg (__after_morecore_hook);
-	  if (__builtin_expect (hook != NULL, 0))
+	  if (__glibc_unlikely (hook != NULL))
 	    (*hook) ();
 	}
       }
@@ -2736,7 +2736,7 @@ static int systrim(size_t pad, mstate av)
       MORECORE(-extra);
       /* Call the `morecore' hook if necessary.  */
       void (*hook) (void) = force_reg (__after_morecore_hook);
-      if (__builtin_expect (hook != NULL, 0))
+      if (__glibc_unlikely (hook != NULL))
 	(*hook) ();
       new_brk = (char*)(MORECORE(0));
 
@@ -2773,7 +2773,7 @@ munmap_chunk(mchunkptr p)
      page size.  But gcc does not recognize the optimization possibility
      (in the moment at least) so we combine the two values into one before
      the bit test.  */
-  if (__builtin_expect (((block | total_size) & (GLRO(dl_pagesize) - 1)) != 0, 0))
+  if (__glibc_unlikely (((block | total_size) & (GLRO(dl_pagesize) - 1)) != 0))
     {
       malloc_printerr (check_action, "munmap_chunk(): invalid pointer",
 		       chunk2mem (p));
@@ -2841,7 +2841,7 @@ __libc_malloc(size_t bytes)
 
   void *(*hook) (size_t, const void *)
     = force_reg (__malloc_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     return (*hook)(bytes, RETURN_ADDRESS (0));
 
   arena_lookup(ar_ptr);
@@ -2873,7 +2873,7 @@ __libc_free(void* mem)
 
   void (*hook) (void *, const void *)
     = force_reg (__free_hook);
-  if (__builtin_expect (hook != NULL, 0)) {
+  if (__glibc_unlikely (hook != NULL))       {
     (*hook)(mem, RETURN_ADDRESS (0));
     return;
   }
@@ -2914,7 +2914,7 @@ __libc_realloc(void* oldmem, size_t bytes)
 
   void *(*hook) (void *, size_t, const void *) =
     force_reg (__realloc_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     return (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
 
 #if REALLOC_ZERO_BYTES_FREES
@@ -3008,7 +3008,7 @@ __libc_memalign(size_t alignment, size_t bytes)
 
   void *(*hook) (size_t, size_t, const void *) =
     force_reg (__memalign_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     return (*hook)(alignment, bytes, RETURN_ADDRESS (0));
 
   /* If need less alignment than we give anyway, just relay to malloc */
@@ -3065,7 +3065,7 @@ __libc_valloc(size_t bytes)
 
   void *(*hook) (size_t, size_t, const void *) =
     force_reg (__memalign_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     return (*hook)(pagesz, bytes, RETURN_ADDRESS (0));
 
   arena_get(ar_ptr, bytes + pagesz + MINSIZE);
@@ -3109,7 +3109,7 @@ __libc_pvalloc(size_t bytes)
 
   void *(*hook) (size_t, size_t, const void *) =
     force_reg (__memalign_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     return (*hook)(pagesz, rounded_bytes, RETURN_ADDRESS (0));
 
   arena_get(ar_ptr, bytes + 2*pagesz + MINSIZE);
@@ -3144,7 +3144,7 @@ __libc_calloc(size_t n, size_t elem_size)
   bytes = n * elem_size;
 #define HALF_INTERNAL_SIZE_T \
   (((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2))
-  if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) {
+  if (__glibc_unlikely ((n | elem_size) >= HALF_INTERNAL_SIZE_T))       {
     if (elem_size != 0 && bytes / elem_size != n) {
       __set_errno (ENOMEM);
       return 0;
@@ -3153,7 +3153,7 @@ __libc_calloc(size_t n, size_t elem_size)
 
   void *(*hook) (size_t, const void *) =
     force_reg (__malloc_hook);
-  if (__builtin_expect (hook != NULL, 0)) {
+  if (__glibc_unlikely (hook != NULL))       {
     sz = bytes;
     mem = (*hook)(sz, RETURN_ADDRESS (0));
     if(mem == 0)
@@ -3206,7 +3206,7 @@ __libc_calloc(size_t n, size_t elem_size)
   /* Two optional cases in which clearing not necessary */
   if (chunk_is_mmapped (p))
     {
-      if (__builtin_expect (perturb_byte, 0))
+      if (__glibc_unlikely (perturb_byte))
 	MALLOC_ZERO (mem, sz);
       return mem;
     }
@@ -3309,7 +3309,7 @@ _int_malloc(mstate av, size_t bytes)
     while ((pp = catomic_compare_and_exchange_val_acq (fb, victim->fd, victim))
 	   != victim);
     if (victim != 0) {
-      if (__builtin_expect (fastbin_index (chunksize (victim)) != idx, 0))
+      if (__glibc_unlikely (fastbin_index (chunksize (victim)) != idx))
 	{
 	  errstr = "malloc(): memory corruption (fast)";
 	errout:
@@ -3318,7 +3318,7 @@ _int_malloc(mstate av, size_t bytes)
 	}
       check_remalloced_chunk(av, victim, nb);
       void *p = chunk2mem(victim);
-      if (__builtin_expect (perturb_byte, 0))
+      if (__glibc_unlikely (perturb_byte))
 	alloc_perturb (p, bytes);
       return p;
     }
@@ -3341,7 +3341,7 @@ _int_malloc(mstate av, size_t bytes)
 	malloc_consolidate(av);
       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;
@@ -3354,7 +3354,7 @@ _int_malloc(mstate av, size_t bytes)
 	  victim->size |= NON_MAIN_ARENA;
 	check_malloced_chunk(av, victim, nb);
 	void *p = chunk2mem(victim);
-	if (__builtin_expect (perturb_byte, 0))
+	if (__glibc_unlikely (perturb_byte))
 	  alloc_perturb (p, bytes);
 	return p;
       }
@@ -3434,7 +3434,7 @@ _int_malloc(mstate av, size_t bytes)
 
 	check_malloced_chunk(av, victim, nb);
 	void *p = chunk2mem(victim);
-	if (__builtin_expect (perturb_byte, 0))
+	if (__glibc_unlikely (perturb_byte))
 	  alloc_perturb (p, bytes);
 	return p;
       }
@@ -3451,7 +3451,7 @@ _int_malloc(mstate av, size_t bytes)
 	  victim->size |= NON_MAIN_ARENA;
 	check_malloced_chunk(av, victim, nb);
 	void *p = chunk2mem(victim);
-	if (__builtin_expect (perturb_byte, 0))
+	if (__glibc_unlikely (perturb_byte))
 	  alloc_perturb (p, bytes);
 	return p;
       }
@@ -3555,7 +3555,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;
@@ -3576,7 +3576,7 @@ _int_malloc(mstate av, size_t bytes)
 	}
 	check_malloced_chunk(av, victim, nb);
 	void *p = chunk2mem(victim);
-	if (__builtin_expect (perturb_byte, 0))
+	if (__glibc_unlikely (perturb_byte))
 	  alloc_perturb (p, bytes);
 	return p;
       }
@@ -3655,7 +3655,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;
@@ -3680,7 +3680,7 @@ _int_malloc(mstate av, size_t bytes)
 	}
 	check_malloced_chunk(av, victim, nb);
 	void *p = chunk2mem(victim);
-	if (__builtin_expect (perturb_byte, 0))
+	if (__glibc_unlikely (perturb_byte))
 	  alloc_perturb (p, bytes);
 	return p;
       }
@@ -3715,7 +3715,7 @@ _int_malloc(mstate av, size_t bytes)
 
       check_malloced_chunk(av, victim, nb);
       void *p = chunk2mem(victim);
-      if (__builtin_expect (perturb_byte, 0))
+      if (__glibc_unlikely (perturb_byte))
 	alloc_perturb (p, bytes);
       return p;
     }
@@ -3780,7 +3780,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;
@@ -3829,7 +3829,7 @@ _int_free(mstate av, mchunkptr p, int have_lock)
 	  }
       }
 
-    if (__builtin_expect (perturb_byte, 0))
+    if (__glibc_unlikely (perturb_byte))
       free_perturb (chunk2mem(p), size - 2 * SIZE_SZ);
 
     set_fastchunks(av);
@@ -3843,7 +3843,7 @@ _int_free(mstate av, mchunkptr p, int have_lock)
       {
 	/* Another simple check: make sure the top of the bin is not the
 	   record we are going to add (i.e., double free).  */
-	if (__builtin_expect (old == p, 0))
+	if (__glibc_unlikely (old == p))
 	  {
 	    errstr = "double free or corruption (fasttop)";
 	    goto errout;
@@ -3884,7 +3884,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;
@@ -3898,7 +3898,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;
@@ -3912,7 +3912,7 @@ _int_free(mstate av, mchunkptr p, int have_lock)
 	goto errout;
       }
 
-    if (__builtin_expect (perturb_byte, 0))
+    if (__glibc_unlikely (perturb_byte))
       free_perturb (chunk2mem(p), size - 2 * SIZE_SZ);
 
     /* consolidate backward */
@@ -3942,7 +3942,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;
@@ -4965,7 +4965,7 @@ __posix_memalign (void **memptr, size_t alignment, size_t size)
      and not posix_memalign itself.  */
   void *(*hook) (size_t, size_t, const void *) =
     force_reg (__memalign_hook);
-  if (__builtin_expect (hook != NULL, 0))
+  if (__glibc_unlikely (hook != NULL))
     mem = (*hook)(alignment, size, RETURN_ADDRESS (0));
   else
     mem = __libc_memalign (alignment, size);
diff --git a/malloc/memusage.c b/malloc/memusage.c
index e32f6ba..55cfa79 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;
@@ -381,7 +381,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;
@@ -473,7 +473,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;
@@ -522,7 +522,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;
@@ -573,7 +573,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;
@@ -625,7 +625,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;
@@ -682,7 +682,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;
@@ -742,7 +742,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;
@@ -757,7 +757,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 ac8ff3d..5ee5bbb 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 5b9e1f4..6362a94 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 bcb0b4c..944443b 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 123ab30..4b3e2ef 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 4da0a0d..4becd13 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 0713565..c82fb8e 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 54be9f9..930c65b 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 0a08b95..69a8de9 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 8c4b894..3e04e84 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 9bb5e01..6a2a08d 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 05b146e..d12457d 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 62bf83c..81f6a67 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 18d3df0..9f1057d 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 40e0e51..d9b863a 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 7c42205..ab64c91 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 0c35603..2424f14 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 77ccd0a..d6b87bd 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 c55a462..b32e850 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 56bf0ef..934b7f3 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 b4c48b7..dc7d27c 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 008970e..f770d66 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 4923b10..01f2917 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 6d28e4c..00908b1 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 a3dcf9d..123d8b4 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 5a98f67..287a348 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 3658805..033487d 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 54a13fd..c48a970 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 4d6ce3d..99e3804 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 992f733..d29bf5f 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 e66b1cd..ffbdf7c 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 f729b7c..92ef2c6 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 c6565c0..2597705 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 e08571b..fd08782 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 cfc71ec..533b43c 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 d37d5bb..7e18097 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 135e987..b2f76a6 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 a22e30a..b1c432e 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 d86833b..64a1445 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 918c76c..9f8fcc3 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 901caba..76d5332 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 9688691..79a36ca 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 01070f6..ca08922 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 148cdc2..2f41ec9 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 408a1ab..caa3ffe 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 59c444b..353ed88 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 b97f8a1..dead693 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 ca58ccf..83d8d70 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 aecc1ed..6b20ee7 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 df8317a..ed071e3 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 c5269c2..aec23ff 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 54840ab..b9a4336 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 5cf187e..d21fb01 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 a03600d..78b98e3 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 0ca40db..b8abdfa 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 10c913c..af7747b 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 72a9a7a..907c662 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 cf924c4..89f5943 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 f934fb2..6cf6f13 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 e854b28..522bf82 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 1d84d29..0cbe398 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 3f9d03e..b8852da 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 5176354..7c2688145 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 8302856..c8ea1ca 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 87ceca2..65dcc8f 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 20dcd04..adc8494 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 ba84555..abd5368 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 cfe6709..ae4218a 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 244e464..7fdbcb9 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 8df6dd3..f04a8d5 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 d9ad063..10191f8 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 a63e8e9..d218768 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 1cc1200..3be4f5c 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 aa96524..0915cb2 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 59b2f80..ef6d3fc 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 ad07642..cc7fe3b 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 9c7a0b7..ef1b8ce 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 b54c53d..9c103b4 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 7413c44..902b740 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 ddc6612..d74a8c5 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 d493e57..817b1a6 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 e62a84b..2305d30 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 477cdb2..d257e08 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 5bf296a..0744b92 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 7469d3b..65f7d3a 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/allocatestack.c b/nptl/allocatestack.c
index 1e0fe1f..680b582 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 be504e0..5c54db1 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 170623d..82c0809 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 d9035fd..426e7bf 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 4e99a38..9c0e398 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 b456b41..88a86b8 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 cafcb8b..ab36575 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 6d2910e..d7a33a4 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 0a2d092..9510782 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 01d42d7..79205a1 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 7f714f8..a0bae93 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 88ac072..43def8a 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 2cedc39..3925f29 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 047985a..5d46018 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 ad96597..461dc3e 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 174d900..b4a4d39 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 76dd903..cf9bace 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 689cefa..83bd136 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 24fb052..0ec860a 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 6914503..6bbf728 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 f74e33a..9c81143 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 86a1d29..416e405 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 1e1e958..393944c 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 935ac87..087b3ca 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 cd49bd2..60f8d82 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 b88ba11..b514419 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 6679a2e..41d852c 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, &param) == -1, 0))
+  if (__glibc_unlikely (sched_setparam (pd->tid, &param) == -1))
     result = errno;
   else
     {
diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c
index b054299..bb8b0f9 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 fd02ef3..634e44c 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 83b2fdf..40b0ef3 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -73,10 +73,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 3374851..d0ef5c2 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 d24136b..acb2fd8 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 8cc1212..6baed1d 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 c483a32..a2623a9 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 9718606..0f5da67 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 723b137..028ad00 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 ecb7663..4c216be 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 6bc34ba..ed0f2a8 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 f33f703..4c10e01 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 5edea5e..4346c30 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 04e9b65..c72ae77 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 987604c..3b3511a 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 ba9abc5..783b291 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 cbcb5a3..bba136d 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 3dab05e..bab1d89 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 5ee8f6d..77b054f 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 28920d9..c196cd9 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 8c434ea..f402edc 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 3d38324..877a715 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 47904dd..2cdbfb1 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 e8011b6..fe46930 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 713e41a..4f8e8cd 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 699447a..6c2a95f 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 e54d4f2..fd914b9 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 5658792..32e9d62 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 0d421fc..fbfddc9 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 4580884..c24346b 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 392fe5b..c116b04 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 a607dda..2abeece 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -71,7 +71,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);
@@ -372,7 +372,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);
@@ -469,7 +469,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!"),
@@ -506,7 +506,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 360852b..6f03d27 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 236c939..a3b8567 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 dbcaac9..15e1b9f 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 e07f622..58e7c3d 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 46a9108..66ea2bd 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 c9c890c..a41153d 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 8587e45..f6517ba 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 19e3d79..0e57561 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 acb2c81..18879eb 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 4f3fb41..26213b2 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 0866c44..c70bfcb 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 b7738a7..ff2cf47 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 082d1ea..a835545 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -229,7 +229,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 0f26a2e..e31f78f 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 5497fc4..97c77a5 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 85237c2..64a58ba 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 96ce8a4..5c1d746 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 9018bb9..92b107c 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 3c4db7e..2243a74 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 edb7fc3..e9c19e3 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 4232ce4..40f74d2 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 2b93e6c..1a10c7e 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 82ff80a..1c3b4db 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 78dc2fc..c8a910c 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)
@@ -2332,7 +2332,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))
@@ -2372,7 +2372,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
@@ -2408,7 +2408,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
 
@@ -2416,7 +2416,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
@@ -2528,7 +2528,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));
@@ -2611,13 +2611,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 ();
 
@@ -2643,7 +2643,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
@@ -2752,7 +2752,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);
@@ -2815,7 +2815,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 ();
 
@@ -2909,9 +2909,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)
@@ -2926,7 +2926,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 2ee890f..c862778 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 dfd4c7e..5b5158f 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 c9b289f..03edb38 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 a6f585b..8f02b43 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 63c995b..c003dee 100644
--- a/stdlib/setenv.c
+++ b/stdlib/setenv.c
@@ -181,17 +181,17 @@ __add_to_environ (name, value, combined, replace)
 # endif
 
 	  new_environ[size] = KNOWN_VALUE (new_value);
-	  if (__builtin_expect (new_environ[size] == NULL, 1))
+	  if (__glibc_likely (new_environ[size] == NULL))
 #endif
 	    {
 #ifdef USE_TSEARCH
-	      if (__builtin_expect (! use_alloca, 0))
+	      if (__glibc_unlikely (! use_alloca))
 		new_environ[size] = new_value;
 	      else
 #endif
 		{
 		  new_environ[size] = (char *) malloc (varlen);
-		  if (__builtin_expect (new_environ[size] == NULL, 0))
+		  if (__glibc_unlikely (new_environ[size] == NULL))
 		    {
 		      UNLOCK;
 		      return -1;
@@ -255,17 +255,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 90541cd..666685b 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 dc47608..1666906 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 <locale.h>.  */
   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 1ff6442..62c54cc 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 9123c39..1e6235d 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 2363350..f13c125 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 d98ede7..6f65481 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 df845cd..4dc8c40 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 270d762..d96e8ab 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 b6fc805..9a0ff92 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 958e937..93e6e33 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 e1ba940..5dd128d 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 13e389d..38d121e 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 9f4321e..3001da1 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 */
 	{
@@ -89,7 +89,7 @@ __ieee754_hypot (double x, double y)
       SET_HIGH_WORD (a, ha);
       SET_HIGH_WORD (b, hb);
     }
-  if (__builtin_expect (hb < 0x20b00000, 0))            /* b < 2**-500 */
+  if (__glibc_unlikely (hb < 0x20b00000))                  /* b < 2**-500 */
     {
       if (hb <= 0x000fffff)             /* subnormal b or 0 */
 	{
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 a7ab544..98cdf81 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 06c0d2a..9a790c7 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<x<0.41422 */
     }
-  else if (__builtin_expect (hx >= 0x7ff00000, 0))
+  else if (__glibc_unlikely (hx >= 0x7ff00000))
     return x + x;
   if (k != 0)
     {
diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index 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<x<2 */
       double t = x - one;
       return __log1p (t + __ieee754_sqrt (2.0 * t + t * t));
     }
-  else if (__builtin_expect (hx == INT64_C (0x3ff0000000000000), 1))
+  else if (__glibc_likely (hx == INT64_C (0x3ff0000000000000)))
     return 0.0;				/* acosh(1) = 0 */
   else					/* x < 1 */
     return (x - x) / (x - x);
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
index dcb7b58..4f5a816 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
@@ -64,16 +64,16 @@ __ieee754_log10 (double x)
   k = 0;
   if (hx < INT64_C(0x0010000000000000))
     {				/* x < 2**-1022  */
-      if (__builtin_expect ((hx & UINT64_C(0x7fffffffffffffff)) == 0, 0))
+      if (__glibc_unlikely ((hx & UINT64_C(0x7fffffffffffffff)) == 0))
 	return -two54 / (x - x);	/* log(+-0)=-inf */
-      if (__builtin_expect (hx < 0, 0))
+      if (__glibc_unlikely (hx < 0))
 	return (x - x) / (x - x);	/* log(-#) = NaN */
       k -= 54;
       x *= two54;		/* subnormal number, scale up x */
       EXTRACT_WORDS64 (hx, x);
     }
   /* scale up resulted in a NaN number  */
-  if (__builtin_expect (hx >= UINT64_C(0x7ff0000000000000), 0))
+  if (__glibc_unlikely (hx >= UINT64_C(0x7ff0000000000000)))
     return x + x;
   k += (hx >> 52) - 1023;
   i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63;
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c
index 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 59dafe8..a3f5afa 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 42349bd..414afdf 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 29e6287..8e6d877 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 bea7960..2d2ce73 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 e87e34e..fe804a2 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 f58f4c8..5b72958 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 5ec0a06..88a1cc4 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 8560349..846c2e3 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 c402b08..1086b7b 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 e140288..ac3ec33 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 588098d..eae0578 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 c9f2e20..8ce8247 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 7cb3e85..73c7279 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 58a9107..0dd454c 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)
@@ -299,11 +299,11 @@ __ieee754_ynl (int n, long double x)
   GET_LDOUBLE_WORDS (se, i0, i1, x);
   ix = se & 0x7fff;
   /* if Y(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 (__builtin_expect ((ix | i0 | i1) == 0, 0))
+  if (__glibc_unlikely ((ix | i0 | i1) == 0))
     return -HUGE_VALL + x;  /* -inf and overflow exception.  */
-  if (__builtin_expect (se & 0x8000, 0))
+  if (__glibc_unlikely (se & 0x8000))
     return zero / (zero * x);
   sign = 1;
   if (n < 0)
@@ -315,7 +315,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 88b902f..7b76d74 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 a1cc0fd..bc9a198 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 5d898e4..2c94aba 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 4e0c39d..9c4eb72 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 0f4b885..6f7952e 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -470,7 +470,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';
@@ -2600,7 +2600,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 fc05b0f..5d4557a 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 8805978..a9270e0 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 c49a42e..77cb691 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -113,7 +113,7 @@
 # include <hp-timing.h>
 # if HP_TIMING_AVAIL
 #  define RANDOM_BITS(Var) \
-  if (__builtin_expect (value == UINT64_C (0), 0))			      \
+  if (__glibc_unlikely (value == UINT64_C (0)))     			      \
     {									      \
       /* If this is the first time this function is used initialize	      \
 	 the variable we accumulate the value in to some somewhat	      \
diff --git a/sysdeps/powerpc/powerpc32/dl-irel.h b/sysdeps/powerpc/powerpc32/dl-irel.h
index fcc1608..7145702 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 aba3618..3adc639 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 597afd7..290f9cc 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/powerpc32/power7/fpu/s_logb.c b/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c
index da2e6b9..c5f789f 100644
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c
+++ b/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c
@@ -35,7 +35,7 @@ __logb (double x)
 {
   double ret;
 
-  if (__builtin_expect (x == 0.0, 0))
+  if (__glibc_unlikely (x == 0.0))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
     return -1.0 / __builtin_fabs (x);
 
@@ -47,10 +47,10 @@ __logb (double x)
     : "f" (x), "f" (mask.d));
   /* ret = (ret >> 52) - 1023.0;  */
   ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two10m1, 0))
+  if (__glibc_unlikely (ret > -two10m1))
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (x * x);
-  else if (__builtin_expect (ret == two10m1, 0))
+  else if (__glibc_unlikely (ret == two10m1))
     {
       /* POSIX specifies that denormal numbers are treated as
          though they were normalized.  */
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbf.c b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbf.c
index 05726f2..a101600 100644
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbf.c
+++ b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbf.c
@@ -37,7 +37,7 @@ __logbf (float x)
   /* VSX operation are all done internally as double.  */
   double ret;
 
-  if (__builtin_expect (x == 0.0, 0))
+  if (__glibc_unlikely (x == 0.0))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
     return -1.0 / __builtin_fabsf (x);
 
@@ -49,7 +49,7 @@ __logbf (float x)
     : "f" (x), "f" (mask.d));
   /* ret = (ret >> 52) - 1023.0, since ret is double.  */
   ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two7m1, 0))
+  if (__glibc_unlikely (ret > -two7m1))
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (x * x);
   /* Since operations are done with double we don't need
diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c
index 1c82577..02ef446 100644
--- a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c
+++ b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c
@@ -38,7 +38,7 @@ __logbl (long double x)
   double xh;
   double ret;
 
-  if (__builtin_expect (x == 0.0L, 0))
+  if (__glibc_unlikely (x == 0.0L))
     /* Raise FE_DIVBYZERO and return -HUGE_VAL[LF].  */
     return -1.0L / __builtin_fabsl (x);
 
@@ -51,10 +51,10 @@ __logbl (long double x)
     : "f" (xh), "f" (mask.d));
   /* ret = (ret >> 52) - 1023.0;  */
   ret = (ret * two1div52) + two10m1;
-  if (__builtin_expect (ret > -two10m1, 0))
+  if (__glibc_unlikely (ret > -two10m1))
     /* Multiplication is used to set logb (+-INF) = INF.  */
     return (xh * xh);
-  else if (__builtin_expect (ret == two10m1, 0))
+  else if (__glibc_unlikely (ret == two10m1))
     {
       /* POSIX specifies that denormal number is treated as
          though it were normalized.  */
diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h
index d85c614..9d0ce4a 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 18cf157..051b73e 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -574,7 +574,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
@@ -599,13 +599,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/powerpc/powerpc64/power4/fpu/w_sqrt.c b/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrt.c
index 78bba57..3fa91cc 100644
--- a/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrt.c
+++ b/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrt.c
@@ -33,10 +33,10 @@ __sqrt (double x)		/* wrapper sqrt */
 #ifdef _IEEE_LIBM
   return z;
 #else
-  if (__builtin_expect (_LIB_VERSION == _IEEE_, 0))
+  if (__glibc_unlikely (_LIB_VERSION == _IEEE_))
     return z;
 
-  if (__builtin_expect (x != x, 0))
+  if (__glibc_unlikely (x != x))
     return z;
 
   if  (__builtin_expect (x < 0.0, 0))
diff --git a/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrtf.c b/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrtf.c
index 12d9f62..8008142 100644
--- a/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrtf.c
+++ b/sysdeps/powerpc/powerpc64/power4/fpu/w_sqrtf.c
@@ -36,10 +36,10 @@ __sqrtf (float x)		/* wrapper sqrtf */
 		: "=f" (z)
 		: "f" (x));
 
-  if (__builtin_expect (_LIB_VERSION == _IEEE_, 0))
+  if (__glibc_unlikely (_LIB_VERSION == _IEEE_))
     return z;
 
-  if (__builtin_expect (x != x, 0))
+  if (__glibc_unlikely (x != x))
     return z;
 
   if  (__builtin_expect (x < 0.0, 0))
diff --git a/sysdeps/pthread/aio_notify.c b/sysdeps/pthread/aio_notify.c
index deedd2d..798e267 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 137c973..2ccd0e3 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 32a9f3f..5d8bf23 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 aa8f1a5..23ab5d4 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
     {
@@ -315,7 +315,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;
@@ -447,7 +447,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;
@@ -456,10 +456,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 32f7a2c..565b44f 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 0df436b..322f9a0 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 1f959d9..3e94334 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 462d1c5..3bdf49c 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 da7b9c1..33c8d3a 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 4b2b6a6..f233569 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 30f9246..3eba0f6 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 6916667..a801f67 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 3bce5d1..51b6a78 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 10d111e..dee0101 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 d46057a..c654295 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 6605e9e..bb52ad6 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 431be85..2e94938 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 b20f297..42e0cb6 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 9052aaf..eb84f82 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 34c2146..692a74f 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 9dad8e6..7219c6c 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 fcb2dc8..1fb28ca 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 1093cab..fd8def1 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 acb9c25..79bb912 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 1b8a937..2889d19 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 b8bd8a5..ea7e0a4 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 abd39ea..7086ae6 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 aaaa6a6..37a786b 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 c3ba3b0..29d8c1a 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 4a8288b..95f5298 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 7ecbbe0..9296982 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 18241b2..0c81580 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 2bba876..6b5637d 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 6bec1d5..57043fa 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 e43e177..71dff75 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 684fe27..1b5ff24 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 89fda15..52664da 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 f10f8e1..9c44db1 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 b4a089e..63ba24a 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 1a1909f..837b916 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 6e838df..b9a456d 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 f6c96f9..e3691ba 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 5fd90d7..521bb06 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 88f535f..6b5daba 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 5e88b83..45587fa 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 d08a133..f27317e 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 1a0badc..e39aabc 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 cba7615..5dfaf05 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 18a7ad4..6e108e6 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 3eea5c9..6d4de69 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 be12757..f5a7a6b 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 616d7f2..a050172 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 41d9315..236fd29 100644
--- a/sysdeps/unix/sysv/linux/shm_open.c
+++ b/sysdeps/unix/sysv/linux/shm_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;
     }
@@ -204,7 +204,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 7d0ac93..c5f0daa 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 8ac5895..de8d530 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 0ca8fd9..c35c9fc 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 daf2b32..ec6aee4 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 d91dcc1..5e8c69a 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 cb9d8d1..7c104f2 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 73a2e87..91e0133 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 abf3021..4687388 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 d68112a..4ef829b 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 8cb9021..52edbdd 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 c988927..05e9461 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 116fed1..c14f359 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/sysdeps/x86_64/multiarch/strstr.c b/sysdeps/x86_64/multiarch/strstr.c
index cd63b68..6dd912e 100644
--- a/sysdeps/x86_64/multiarch/strstr.c
+++ b/sysdeps/x86_64/multiarch/strstr.c
@@ -89,7 +89,7 @@
 static __m128i
 __m128i_strloadu (const unsigned char * p, __m128i zero)
 {
-  if (__builtin_expect ((int) ((size_t) p & 0xfff) > 0xff0, 0))
+  if (__glibc_unlikely ((int) ((size_t) p & 0xfff) > 0xff0))
     {
       size_t offset = ((size_t) p & (16 - 1));
       __m128i a = _mm_load_si128 ((__m128i *) (p - offset));
@@ -169,14 +169,14 @@ STRSTR_SSE42 (const unsigned char *s1, const unsigned char *s2)
   const unsigned char *p2 = s2;
 
 #ifndef STRCASESTR_NONASCII
-  if (__builtin_expect (p2[0] == '\0', 0))
+  if (__glibc_unlikely (p2[0] == '\0'))
     return (char *) p1;
 
-  if (__builtin_expect (p1[0] == '\0', 0))
+  if (__glibc_unlikely (p1[0] == '\0'))
     return NULL;
 
   /* Check if p1 length is 1 byte long.  */
-  if (__builtin_expect (p1[1] == '\0', 0))
+  if (__glibc_unlikely (p1[1] == '\0'))
     return p2[1] == '\0' && CMPBYTE (p1[0], p2[0]) ? (char *) p1 : NULL;
 #endif
 
diff --git a/time/asctime.c b/time/asctime.c
index b4bc78d..47e7dce 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 3ea3051..23da72c 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 4f8af8d..168a502 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 24c7fed..8b0cded 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 6476445..442d233 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 52e65a0..4eaaf2d 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 2402776..b41f7aa 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);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]