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/dl-load.c | |
parent | 1448f3244714a9dabb5240ec18b094f100887d5c (diff) | |
download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.bz2 |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r-- | elf/dl-load.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c index 1be7a3c..6501ff2 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -333,7 +333,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, do { - if (__builtin_expect (*name == '$', 0)) + if (__glibc_unlikely (*name == '$')) { const char *repl = NULL; size_t len; @@ -565,7 +565,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, dirp->status[cnt] = init_val; dirp->what = what; - if (__builtin_expect (where != NULL, 1)) + if (__glibc_likely (where != NULL)) dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1 + (ncapstr * sizeof (enum r_dir_status)), where, where_len); @@ -836,7 +836,7 @@ _dl_init_paths (const char *llp) #ifdef SHARED /* Expand DSTs. */ size_t cnt = DL_DST_COUNT (llp, 1); - if (__builtin_expect (cnt == 0, 1)) + if (__glibc_likely (cnt == 0)) llp_tmp = strdupa (llp); else { @@ -935,7 +935,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, bool make_consistent = false; /* Get file information. */ - if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st) < 0, 0)) + if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &st) < 0)) { errstring = N_("cannot stat shared object"); call_lose_errno: @@ -999,7 +999,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("file=%s [%lu]; generating link map\n", name, nsid); /* This is the ELF header. We read it in `open_verify'. */ @@ -1057,7 +1057,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Enter the new object in the list of loaded objects. */ l = _dl_new_object (realname, name, l_type, loader, mode, nsid); - if (__builtin_expect (l == NULL, 0)) + if (__glibc_unlikely (l == NULL)) { #ifdef SHARED fail_new: @@ -1226,7 +1226,7 @@ cannot allocate TLS data structures for initial thread"); /* Now we install the TCB in the thread register. */ errstring = TLS_INIT_TP (tcb, 0); - if (__builtin_expect (errstring == NULL, 1)) + if (__glibc_likely (errstring == NULL)) { /* Now we are all good. */ l->l_tls_modid = ++GL(dl_tls_max_dtv_idx); @@ -1256,7 +1256,7 @@ cannot allocate TLS data structures for initial thread"); break; } - if (__builtin_expect (nloadcmds == 0, 0)) + if (__glibc_unlikely (nloadcmds == 0)) { /* This only happens for a bogus object that will be caught with another error below. But we don't want to go through the @@ -1294,7 +1294,7 @@ cannot allocate TLS data structures for initial thread"); c->prot, MAP_COPY|MAP_FILE, fd, c->mapoff); - if (__builtin_expect ((void *) l->l_map_start == MAP_FAILED, 0)) + if (__glibc_unlikely ((void *) l->l_map_start == MAP_FAILED)) { map_error: errstring = N_("failed to map segment from shared object"); @@ -1321,7 +1321,7 @@ cannot allocate TLS data structures for initial thread"); /* This object is loaded at a fixed address. This must never happen for objects loaded with dlopen(). */ - if (__builtin_expect ((mode & __RTLD_OPENEXEC) == 0, 0)) + if (__glibc_unlikely ((mode & __RTLD_OPENEXEC) == 0)) { errstring = N_("cannot dynamically load executable"); goto call_lose; @@ -1379,7 +1379,7 @@ cannot allocate TLS data structures for initial thread"); if (zeropage > zero) { /* Zero the final part of the last page of the segment. */ - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) { /* Dag nab it. */ if (__mprotect ((caddr_t) (zero @@ -1391,7 +1391,7 @@ cannot allocate TLS data structures for initial thread"); } } memset ((void *) zero, '\0', zeropage - zero); - if (__builtin_expect ((c->prot & PROT_WRITE) == 0, 0)) + if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0)) __mprotect ((caddr_t) (zero & ~(GLRO(dl_pagesize) - 1)), GLRO(dl_pagesize), c->prot); } @@ -1403,7 +1403,7 @@ cannot allocate TLS data structures for initial thread"); mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage, c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0); - if (__builtin_expect (mapat == MAP_FAILED, 0)) + if (__glibc_unlikely (mapat == MAP_FAILED)) { errstring = N_("cannot map zero-fill pages"); goto call_lose_errno; @@ -1417,7 +1417,7 @@ cannot allocate TLS data structures for initial thread"); if (l->l_ld == 0) { - if (__builtin_expect (type == ET_DYN, 0)) + if (__glibc_unlikely (type == ET_DYN)) { errstring = N_("object file has no dynamic section"); goto call_lose; @@ -1467,7 +1467,7 @@ cannot allocate TLS data structures for initial thread"); /* Adjust the PT_PHDR value by the runtime load address. */ l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr); - if (__builtin_expect ((stack_flags &~ GL(dl_stack_flags)) & PF_X, 0)) + if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X)) { if (__builtin_expect (__check_caller (RETURN_ADDRESS (0), allow_ldso), 0) != 0) @@ -1490,7 +1490,7 @@ cannot allocate TLS data structures for initial thread"); const uintptr_t relro_end = ((m->l_addr + m->l_relro_addr + m->l_relro_size) & -GLRO(dl_pagesize)); - if (__builtin_expect (p + s <= relro_end, 1)) + if (__glibc_likely (p + s <= relro_end)) { /* The variable lies in the region protected by RELRO. */ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0) @@ -1526,7 +1526,7 @@ cannot enable executable stack as shared object requires"); l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr; /* We are done mapping in the file. We no longer need the descriptor. */ - if (__builtin_expect (__close (fd) != 0, 0)) + if (__glibc_unlikely (__close (fd) != 0)) { errstring = N_("cannot close file descriptor"); goto call_lose_errno; @@ -1539,7 +1539,7 @@ cannot enable executable stack as shared object requires"); l->l_entry += l->l_addr; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) _dl_debug_printf ("\ dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n", @@ -1754,7 +1754,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader, ehdr = (ElfW(Ehdr) *) fbp->buf; /* Now run the tests. */ - if (__builtin_expect (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)), 0)) + if (__glibc_unlikely (fbp->len < (ssize_t) sizeof (ElfW(Ehdr)))) { errval = errno; errstring = (errval == 0 @@ -1939,7 +1939,7 @@ open_path (const char *name, size_t namelen, int secure, const char *current_what = NULL; int any = 0; - if (__builtin_expect (dirs == NULL, 0)) + if (__glibc_unlikely (dirs == NULL)) /* We're called before _dl_init_paths when loading the main executable given on the command line when rtld is run directly. */ return -1; @@ -1977,7 +1977,7 @@ open_path (const char *name, size_t namelen, int secure, - buf); /* Print name we try if this is wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf (" trying file=%s\n", buf); fd = open_verify (buf, fbp, loader, whatcode, found_other_class, @@ -2059,7 +2059,7 @@ open_path (const char *name, size_t namelen, int secure, while (*++dirs != NULL); /* Remove the whole path if none of the directories exists. */ - if (__builtin_expect (! any, 0)) + if (__glibc_unlikely (! any)) { /* Paths which were allocated using the minimal malloc() in ld.so must not be freed using the general free() in libc. */ @@ -2165,7 +2165,7 @@ _dl_map_object (struct link_map *loader, const char *name, size_t namelen = strlen (name) + 1; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("find library=%s [%lu]; searching\n", name, nsid); fd = -1; @@ -2268,7 +2268,7 @@ _dl_map_object (struct link_map *loader, const char *name, fd = open_verify (cached, &fb, loader ?: GL(dl_ns)[nsid]._ns_loaded, LA_SER_CONFIG, &found_other_class, false); - if (__builtin_expect (fd != -1, 1)) + if (__glibc_likely (fd != -1)) { realname = local_strdup (cached); if (realname == NULL) @@ -2291,7 +2291,7 @@ _dl_map_object (struct link_map *loader, const char *name, &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); /* Add another newline when we are tracing the library loading. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\n"); } else |