aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2014-02-10 14:45:42 +0100
committerOndřej Bílka <neleai@seznam.cz>2014-02-10 15:07:12 +0100
commita1ffb40e32741f992c743e7b16c061fefa3747ac (patch)
tree246a29a87b26cfd5d07b17070f85eb3785018de9 /elf
parent1448f3244714a9dabb5240ec18b094f100887d5c (diff)
downloadglibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.xz
glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-cache.c4
-rw-r--r--elf/dl-close.c18
-rw-r--r--elf/dl-conflict.c2
-rw-r--r--elf/dl-deps.c12
-rw-r--r--elf/dl-dst.h2
-rw-r--r--elf/dl-fini.c10
-rw-r--r--elf/dl-fptr.c2
-rw-r--r--elf/dl-hwcaps.c2
-rw-r--r--elf/dl-init.c6
-rw-r--r--elf/dl-libc.c6
-rw-r--r--elf/dl-load.c50
-rw-r--r--elf/dl-lookup.c28
-rw-r--r--elf/dl-minimal.c2
-rw-r--r--elf/dl-open.c30
-rw-r--r--elf/dl-reloc.c6
-rw-r--r--elf/dl-runtime.c4
-rw-r--r--elf/dl-sym.c8
-rw-r--r--elf/dl-tls.c16
-rw-r--r--elf/dl-version.c10
-rw-r--r--elf/dl-writev.h2
-rw-r--r--elf/ldconfig.c4
-rw-r--r--elf/rtld.c40
-rw-r--r--elf/setup-vdso.h2
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. */