diff options
author | Zack Weinberg <zackw@panix.com> | 2018-06-01 12:53:59 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2018-06-02 17:19:45 -0400 |
commit | e5ad85ddb460a199771b9993a00d2ece48385e23 (patch) | |
tree | f5d6e17fdf73c3078f3618f0ff93b7ef162daaa3 /elf/dl-runtime.c | |
parent | 7938a423898d6daeb17c339698c581d0558272df (diff) | |
download | glibc-e5ad85ddb460a199771b9993a00d2ece48385e23.tar.gz |
Convert __builtin_expect to __glibc_(un)likely throughout elf/.zack/no-cancellation-in-ldso-2
In the previous patch I didn't change a use of __builtin_expect to
__glibc_(un)likely that happened to be right next to the code I was
actually working on; Andreas asked why not, and I said that there were
a bunch more uses of __builtin_expect in that file and I would convert
them all in a separate patch. This is that patch, converting all of
elf/.
I would appreciate someone checking over this patch very carefully
indeed. In a whole bunch of places, __builtin_expect was used in a
way that did not map mechanically to the newer convention. The test
suite caught one mistake; I'm not confident I didn't make any more.
Writing this patch gave me a deeper appreciation for why we _want_ to
switch to __glibc_(un)likely, but also for how difficult it can be. I
now think that people should _not_ be asked to change existing uses of
__builtin_expect in a patch whose purpose is something else.
* elf/dl-addr.c, elf/dl-cache.c, elf/dl-close.c, elf/dl-deps.c
* elf/dl-environ.c, elf/dl-error-skeleton.c, elf/dl-fini.c
* elf/dl-fptr.c, elf/dl-init.c, elf/dl-libc.c, elf/dl-minimal.c
* elf/dl-open.c, elf/dl-reloc.c, elf/dl-runtime.c
* elf/dl-sysdep.c, elf/dl-tls.c, elf/dl-version.c, elf/ldconfig.c
* elf/rtld.c: Replace __builtin_expect with __glibc_likely or
__glibc_unlikely, as appropriate, throughout.
Diffstat (limited to 'elf/dl-runtime.c')
-rw-r--r-- | elf/dl-runtime.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 63bbc89776..17d691ceb9 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -81,7 +81,7 @@ _dl_fixup ( /* Look up the target symbol. If the normal lookup rules are not used don't look in the global scope. */ - if (__builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) + if (__glibc_likely (ELFW(ST_VISIBILITY) (sym->st_other) == 0)) { const struct r_found_version *version = NULL; @@ -138,7 +138,7 @@ _dl_fixup ( value = elf_machine_plt_value (l, reloc, value); if (sym != NULL - && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)) + && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)) value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value)); /* Finally, fix up the plt itself. */ @@ -204,7 +204,7 @@ _dl_profile_fixup ( /* Look up the target symbol. If the symbol is marked STV_PROTECTED don't look in the global scope. */ - if (__builtin_expect (ELFW(ST_VISIBILITY) (refsym->st_other), 0) == 0) + if (__glibc_likely (ELFW(ST_VISIBILITY) (refsym->st_other) == 0)) { const struct r_found_version *version = NULL; @@ -243,8 +243,8 @@ _dl_profile_fixup ( SYMBOL_ADDRESS (result, defsym, false)); if (defsym != NULL - && __builtin_expect (ELFW(ST_TYPE) (defsym->st_info) - == STT_GNU_IFUNC, 0)) + && __glibc_unlikely (ELFW(ST_TYPE) (defsym->st_info) + == STT_GNU_IFUNC)) value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value)); } else @@ -253,8 +253,8 @@ _dl_profile_fixup ( address) is also known. */ value = DL_FIXUP_MAKE_VALUE (l, SYMBOL_ADDRESS (l, refsym, true)); - if (__builtin_expect (ELFW(ST_TYPE) (refsym->st_info) - == STT_GNU_IFUNC, 0)) + if (__glibc_unlikely (ELFW(ST_TYPE) (refsym->st_info) + == STT_GNU_IFUNC)) value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value)); result = l; |