diff options
author | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 14:45:42 +0100 |
---|---|---|
committer | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 15:07:12 +0100 |
commit | a1ffb40e32741f992c743e7b16c061fefa3747ac (patch) | |
tree | 246a29a87b26cfd5d07b17070f85eb3785018de9 /elf | |
parent | 1448f3244714a9dabb5240ec18b094f100887d5c (diff) | |
download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.xz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-cache.c | 4 | ||||
-rw-r--r-- | elf/dl-close.c | 18 | ||||
-rw-r--r-- | elf/dl-conflict.c | 2 | ||||
-rw-r--r-- | elf/dl-deps.c | 12 | ||||
-rw-r--r-- | elf/dl-dst.h | 2 | ||||
-rw-r--r-- | elf/dl-fini.c | 10 | ||||
-rw-r--r-- | elf/dl-fptr.c | 2 | ||||
-rw-r--r-- | elf/dl-hwcaps.c | 2 | ||||
-rw-r--r-- | elf/dl-init.c | 6 | ||||
-rw-r--r-- | elf/dl-libc.c | 6 | ||||
-rw-r--r-- | elf/dl-load.c | 50 | ||||
-rw-r--r-- | elf/dl-lookup.c | 28 | ||||
-rw-r--r-- | elf/dl-minimal.c | 2 | ||||
-rw-r--r-- | elf/dl-open.c | 30 | ||||
-rw-r--r-- | elf/dl-reloc.c | 6 | ||||
-rw-r--r-- | elf/dl-runtime.c | 4 | ||||
-rw-r--r-- | elf/dl-sym.c | 8 | ||||
-rw-r--r-- | elf/dl-tls.c | 16 | ||||
-rw-r--r-- | elf/dl-version.c | 10 | ||||
-rw-r--r-- | elf/dl-writev.h | 2 | ||||
-rw-r--r-- | elf/ldconfig.c | 4 | ||||
-rw-r--r-- | elf/rtld.c | 40 | ||||
-rw-r--r-- | elf/setup-vdso.h | 2 |
23 files changed, 133 insertions, 133 deletions
diff --git a/elf/dl-cache.c b/elf/dl-cache.c index d36623f09e..91fef9578e 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 5bf1de7d28..f36ea0f779 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -73,7 +73,7 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp, /* The entry might still be in its unused state if we are closing an object that wasn't fully set up. */ - if (__builtin_expect (old_map != NULL, 1)) + if (__glibc_likely (old_map != NULL)) { assert (old_map->l_tls_modid == idx); @@ -123,7 +123,7 @@ _dl_close_worker (struct link_map *map) dl_close_state = rerun; /* There are still references to this object. Do nothing more. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\nclosing file=%s; direct_opencount=%u\n", map->l_name, map->l_direct_opencount); @@ -280,7 +280,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we remove an object. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -452,7 +452,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we will start deleting objects. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct link_map *head = ns->_ns_loaded; struct audit_ifaces *afct = GLRO(dl_audit); @@ -536,7 +536,7 @@ _dl_close_worker (struct link_map *map) object. We can unmap it. */ /* Remove the object from the dtv slotinfo array if it uses TLS. */ - if (__builtin_expect (imap->l_tls_blocksize > 0, 0)) + if (__glibc_unlikely (imap->l_tls_blocksize > 0)) { any_tls = true; @@ -662,7 +662,7 @@ _dl_close_worker (struct link_map *map) free (imap->l_reldeps); /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\nfile=%s [%lu]; destroying link map\n", imap->l_name, imap->l_ns); @@ -704,7 +704,7 @@ _dl_close_worker (struct link_map *map) /* If we removed any object which uses TLS bump the generation counter. */ if (any_tls) { - if (__builtin_expect (++GL(dl_tls_generation) == 0, 0)) + if (__glibc_unlikely (++GL(dl_tls_generation) == 0)) _dl_fatal_printf ("TLS generation counter wrapped! Please report as described in "REPORT_BUGS_TO".\n"); if (tls_free_end == GL(dl_tls_static_used)) @@ -713,7 +713,7 @@ _dl_close_worker (struct link_map *map) #ifdef SHARED /* Auditing checkpoint: we have deleted all objects. */ - if (__builtin_expect (do_audit, 0)) + if (__glibc_unlikely (do_audit)) { struct link_map *head = ns->_ns_loaded; /* Do not call the functions for any auditing object. */ @@ -757,7 +757,7 @@ _dl_close (void *_map) struct link_map *map = _map; /* First see whether we can remove the object at all. */ - if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0)) + if (__glibc_unlikely (map->l_flags_1 & DF_1_NODELETE)) { assert (map->l_init_called); /* Nope. Do nothing. */ diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c index 8034077567..d0f25e3436 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 20c294e5b8..9c83c81779 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 a00e921583..cbc59d42dd 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 05bbd68aee..c35577565e 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 8088db3d4f..40cb40a3f1 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 86d9e9cd6d..e7c60f2fbf 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 28a6ff6d8a..598df3b4aa 100644 --- a/elf/dl-init.c +++ b/elf/dl-init.c @@ -52,7 +52,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env) return; /* Print a debug message if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS)) _dl_debug_printf ("\ncalling init: %s\n\n", DSO_FILENAME (l->l_name)); @@ -88,7 +88,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) ElfW(Dyn) *preinit_array_size = main_map->l_info[DT_PREINIT_ARRAYSZ]; unsigned int i; - if (__builtin_expect (GL(dl_initfirst) != NULL, 0)) + if (__glibc_unlikely (GL(dl_initfirst) != NULL)) { call_init (GL(dl_initfirst), argc, argv, env); GL(dl_initfirst) = NULL; @@ -102,7 +102,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) ElfW(Addr) *addrs; unsigned int cnt; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS)) _dl_debug_printf ("\ncalling preinit: %s\n\n", DSO_FILENAME (main_map->l_name)); diff --git a/elf/dl-libc.c b/elf/dl-libc.c index ceac3caeb2..6d1e9819dc 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 1be7a3ca96..6501ff2dca 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -333,7 +333,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, do { - if (__builtin_expect (*name == '$', 0)) + if (__glibc_unlikely (*name == '$')) { const char *repl = NULL; size_t len; @@ -565,7 +565,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, dirp->status[cnt] = init_val; dirp->what = what; - if (__builtin_expect (where != NULL, 1)) + if (__glibc_likely (where != NULL)) dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1 + (ncapstr * sizeof (enum r_dir_status)), where, where_len); @@ -836,7 +836,7 @@ _dl_init_paths (const char *llp) #ifdef SHARED /* Expand DSTs. */ size_t cnt = DL_DST_COUNT (llp, 1); - if (__builtin_expect (cnt == 0, 1)) + if (__glibc_likely (cnt == 0)) llp_tmp = strdupa (llp); else { @@ -935,7 +935,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, bool make_consistent = false; /* Get file information. */ - if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st) < 0, 0)) + if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &st) < 0)) { errstring = N_("cannot stat shared object"); call_lose_errno: @@ -999,7 +999,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("file=%s [%lu]; generating link map\n", name, nsid); /* This is the ELF header. We read it in `open_verify'. */ @@ -1057,7 +1057,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Enter the new object in the list of loaded objects. */ l = _dl_new_object (realname, name, l_type, loader, mode, nsid); - if (__builtin_expect (l == NULL, 0)) + if (__glibc_unlikely (l == NULL)) { #ifdef SHARED fail_new: @@ -1226,7 +1226,7 @@ cannot allocate TLS data structures for initial thread"); /* Now we install the TCB in the thread register. */ errstring = TLS_INIT_TP (tcb, 0); - if (__builtin_expect (errstring == NULL, 1)) + if (__glibc_likely (errstring == NULL)) { /* Now we are all good. */ l->l_tls_modid = ++GL(dl_tls_max_dtv_idx); @@ -1256,7 +1256,7 @@ cannot allocate TLS data structures for initial thread"); break; } - if (__builtin_expect (nloadcmds == 0, 0)) + if (__glibc_unlikely (nloadcmds == 0)) { /* This only happens for a bogus object that will be caught with another error below. But we don't want to go through the @@ -1294,7 +1294,7 @@ cannot allocate TLS data structures for initial thread"); c->prot, MAP_COPY|MAP_FILE, fd, c->mapoff); - if (__builtin_expect ((void *) l->l_map_start == MAP_FAILED, 0)) + if (__glibc_unlikely ((void *) l->l_map_start == MAP_FAILED)) { map_error: errstring = N_("failed to map segment from shared object"); @@ -1321,7 +1321,7 @@ cannot allocate TLS data structures for initial thread"); /* This object is loaded at a fixed address. This must never happen for objects loaded with dlopen(). */ - if (__builtin_expect ((mode & __RTLD_OPENEXEC) == 0, 0)) + if (__glibc_unlikely ((mode & __RTLD_OPENEXEC) == 0)) { errstring = N_("cannot dynamically load executable"); goto call_lose; @@ -1379,7 +1379,7 @@ cannot allocate TLS data structures for initial thread"); if (zeropage > zero) { /* Zero the final part of the last page of the segment. */ - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) { /* Dag nab it. */ if (__mprotect ((caddr_t) (zero @@ -1391,7 +1391,7 @@ cannot allocate TLS data structures for initial thread"); } } memset ((void *) zero, '\0', zeropage - zero); - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) __mprotect ((caddr_t) (zero & ~(GLRO(dl_pagesize) - 1)), GLRO(dl_pagesize), c->prot); } @@ -1403,7 +1403,7 @@ cannot allocate TLS data structures for initial thread"); mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage, c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0); - if (__builtin_expect (mapat == MAP_FAILED, 0)) + if (__glibc_unlikely (mapat == MAP_FAILED)) { errstring = N_("cannot map zero-fill pages"); goto call_lose_errno; @@ -1417,7 +1417,7 @@ cannot allocate TLS data structures for initial thread"); if (l->l_ld == 0) { - if (__builtin_expect (type == ET_DYN, 0)) + if (__glibc_unlikely (type == ET_DYN)) { errstring = N_("object file has no dynamic section"); goto call_lose; @@ -1467,7 +1467,7 @@ cannot allocate TLS data structures for initial thread"); /* Adjust the PT_PHDR value by the runtime load address. */ l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr); - if (__builtin_expect ((stack_flags &~ GL(dl_stack_flags)) & PF_X, 0)) + if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X)) { if (__builtin_expect (__check_caller (RETURN_ADDRESS (0), allow_ldso), 0) != 0) @@ -1490,7 +1490,7 @@ cannot allocate TLS data structures for initial thread"); const uintptr_t relro_end = ((m->l_addr + m->l_relro_addr + m->l_relro_size) & -GLRO(dl_pagesize)); - if (__builtin_expect (p + s <= relro_end, 1)) + if (__glibc_likely (p + s <= relro_end)) { /* The variable lies in the region protected by RELRO. */ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0) @@ -1526,7 +1526,7 @@ cannot enable executable stack as shared object requires"); l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr; /* We are done mapping in the file. We no longer need the descriptor. */ - if (__builtin_expect (__close (fd) != 0, 0)) + if (__glibc_unlikely (__close (fd) != 0)) { errstring = N_("cannot close file descriptor"); goto call_lose_errno; @@ -1539,7 +1539,7 @@ cannot enable executable stack as shared object requires"); l->l_entry += l->l_addr; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\ dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n", @@ -1754,7 +1754,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader, ehdr = (ElfW(Ehdr) *) fbp->buf; /* Now run the tests. */ - if (__builtin_expect (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)), 0)) + if (__glibc_unlikely (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)))) { errval = errno; errstring = (errval == 0 @@ -1939,7 +1939,7 @@ open_path (const char *name, size_t namelen, int secure, const char *current_what = NULL; int any = 0; - if (__builtin_expect (dirs == NULL, 0)) + if (__glibc_unlikely (dirs == NULL)) /* We're called before _dl_init_paths when loading the main executable given on the command line when rtld is run directly. */ return -1; @@ -1977,7 +1977,7 @@ open_path (const char *name, size_t namelen, int secure, - buf); /* Print name we try if this is wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf (" trying file=%s\n", buf); fd = open_verify (buf, fbp, loader, whatcode, found_other_class, @@ -2059,7 +2059,7 @@ open_path (const char *name, size_t namelen, int secure, while (*++dirs != NULL); /* Remove the whole path if none of the directories exists. */ - if (__builtin_expect (! any, 0)) + if (__glibc_unlikely (! any)) { /* Paths which were allocated using the minimal malloc() in ld.so must not be freed using the general free() in libc. */ @@ -2165,7 +2165,7 @@ _dl_map_object (struct link_map *loader, const char *name, size_t namelen = strlen (name) + 1; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("find library=%s [%lu]; searching\n", name, nsid); fd = -1; @@ -2268,7 +2268,7 @@ _dl_map_object (struct link_map *loader, const char *name, fd = open_verify (cached, &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded, LA_SER_CONFIG, &found_other_class, false); - if (__builtin_expect (fd != -1, 1)) + if (__glibc_likely (fd != -1)) { realname = local_strdup (cached); if (realname == NULL) @@ -2291,7 +2291,7 @@ _dl_map_object (struct link_map *loader, const char *name, &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); /* Add another newline when we are tracing the library loading. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\n"); } else diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index a58e5bc72a..690f4046c5 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 22d0b3c8af..20a672ae41 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 a9ca6b3b44..7cc4cc16e1 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 1f66fccee2..d2c6dac69e 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 655623b425..773cb42610 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 f00975de77..69671c172f 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 dbaea0aa91..9454d06d72 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 651d4cf4ed..525e9d52e5 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 ad67c1d82c..a5ce6c5166 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 46d295064f..4211f4c9cf 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 6dcbabc284..aa50cab0a9 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -344,7 +344,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) } #endif - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS)) { #ifndef HP_TIMING_NONAVAIL print_statistics (&rtld_total_time); @@ -517,7 +517,7 @@ _dl_start (void *arg) # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" # endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); @@ -779,7 +779,7 @@ cannot allocate TLS data structures for initial thread"); #else = TLS_INIT_TP (tcbp, 0); #endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); tls_init_tp_called = true; @@ -813,7 +813,7 @@ do_preload (char *fname, struct link_map *main_map, const char *where) unsigned int old_nloaded = GL(dl_ns)[LM_ID_BASE]._ns_nloaded; (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, &args); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) { _dl_error_printf ("\ ERROR: ld.so: object '%s' from %s cannot be preloaded (%s): ignored.\n", @@ -1067,7 +1067,7 @@ of this helper program; chances are you did not intend to run this program.\n\ args.mode = __RTLD_OPENEXEC; (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, &args); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) /* We don't free the returned string, the programs stops anyway. */ _exit (EXIT_FAILURE); @@ -1394,7 +1394,7 @@ of this helper program; chances are you did not intend to run this program.\n\ GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid (); /* If we have auditing DSOs to load, do it now. */ - if (__builtin_expect (audit_list != NULL, 0)) + if (__glibc_unlikely (audit_list != NULL)) { /* Iterate over all entries in the list. The order is important. */ struct audit_ifaces *last_audit = NULL; @@ -1428,7 +1428,7 @@ of this helper program; chances are you did not intend to run this program.\n\ bool malloced; (void) _dl_catch_error (&objname, &err_str, &malloced, dlmopen_doit, &dlmargs); - if (__builtin_expect (err_str != NULL, 0)) + if (__glibc_unlikely (err_str != NULL)) { not_loaded: _dl_error_printf ("\ @@ -1544,7 +1544,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", /* If we have any auditing modules, announce that we already have two objects loaded. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *ls[2] = { main_map, &GL(dl_rtld_map) }; @@ -1593,7 +1593,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", /* Auditing checkpoint: we are ready to signal that the initial map is being constructed. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct audit_ifaces *afct = GLRO(dl_audit); for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) @@ -1612,7 +1612,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", struct link_map **preloads = NULL; unsigned int npreloads = 0; - if (__builtin_expect (preloadlist != NULL, 0)) + if (__glibc_unlikely (preloadlist != NULL)) { /* The LD_PRELOAD environment variable gives list of libraries separated by white space or colons that are loaded before the @@ -1643,12 +1643,12 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", the work but this does not matter, since it is not for production use. */ static const char preload_file[] = "/etc/ld.so.preload"; - if (__builtin_expect (__access (preload_file, R_OK) == 0, 0)) + if (__glibc_unlikely (__access (preload_file, R_OK) == 0)) { /* Read the contents of the file. */ file = _dl_sysdep_read_whole_file (preload_file, &file_size, PROT_READ | PROT_WRITE); - if (__builtin_expect (file != MAP_FAILED, 0)) + if (__glibc_unlikely (file != MAP_FAILED)) { /* Parse the file. It contains names of libraries to be loaded, separated by white spaces or `:'. It may also contain @@ -1720,7 +1720,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", } } - if (__builtin_expect (*first_preload != NULL, 0)) + if (__glibc_unlikely (*first_preload != NULL)) { /* Set up PRELOADS with a vector of the preloaded libraries. */ struct link_map *l = *first_preload; @@ -1757,7 +1757,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", break; bool rtld_multiple_ref = false; - if (__builtin_expect (i < main_map->l_searchlist.r_nlist, 1)) + if (__glibc_likely (i < main_map->l_searchlist.r_nlist)) { /* Some DT_NEEDED entry referred to the interpreter object itself, so put it back in the list of visible objects. We insert it into the @@ -1815,7 +1815,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (tcbp == NULL) tcbp = init_tls (); - if (__builtin_expect (audit_list == NULL, 1)) + if (__glibc_likely (audit_list == NULL)) /* Initialize security features. But only if we have not done it earlier. */ security_init (); @@ -2099,7 +2099,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (r_list == r_listend && liblist == liblistend) prelinked = true; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\nprelink checking: %s\n", prelinked ? "ok" : "failed"); } @@ -2117,7 +2117,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", GLRO(dl_init_all_dirs) = GL(dl_all_dirs); /* Print scope information. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES)) { _dl_debug_printf ("\nInitial object scopes\n"); @@ -2215,7 +2215,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", this has to go here because the calls it makes should use the rtld versions of the functions (particularly calloc()), but it needs to have _dl_profile_map set up by the relocator. */ - if (__builtin_expect (GL(dl_profile_map) != NULL, 0)) + if (__glibc_unlikely (GL(dl_profile_map) != NULL)) /* We must prepare the profiling. */ _dl_start_profile (); } @@ -2238,7 +2238,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #else = TLS_INIT_TP (tcbp, 0); #endif - if (__builtin_expect (lossage != NULL, 0)) + if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); } @@ -2279,7 +2279,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #ifdef SHARED /* Auditing checkpoint: we have added all objects. */ - if (__builtin_expect (GLRO(dl_naudit) > 0, 0)) + if (__glibc_unlikely (GLRO(dl_naudit) > 0)) { struct link_map *head = GL(dl_ns)[LM_ID_BASE]._ns_loaded; /* Do not call the functions for any auditing object. */ diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h index f3716b693d..1057cf0003 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; |