&& (!is_path || name[len] != ':'))
return 0;
- if (__builtin_expect (secure, 0)
+ if (__glibc_unlikely (secure)
&& ((name[len] != '\0' && name[len] != '/'
&& (!is_path || name[len] != ':'))
|| (name != start + 1 && (!is_path || name[-2] != ':'))))
/* In SUID/SGID programs, after $ORIGIN expansion the
normalized path must be rooted in one of the trusted
directories. */
- if (__builtin_expect (check_for_trusted, false)
+ if (__glibc_unlikely (check_for_trusted)
&& !is_trusted_path_normalize (last_elem, wp - last_elem))
wp = last_elem;
else
/* In SUID/SGID programs, after $ORIGIN expansion the normalized
path must be rooted in one of the trusted directories. */
- if (__builtin_expect (check_for_trusted, false)
+ if (__glibc_unlikely (check_for_trusted)
&& !is_trusted_path_normalize (last_elem, wp - last_elem))
wp = last_elem;
cnt = DL_DST_COUNT (s, is_path);
/* If we do not have to replace anything simply copy the string. */
- if (__builtin_expect (cnt, 0) == 0)
+ if (__glibc_likely (cnt == 0))
return local_strdup (s);
/* Determine the length of the substituted string. */
cp[len++] = '/';
/* Make sure we don't use untrusted directories if we run SUID. */
- if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
+ if (__glibc_unlikely (check_trusted) && !is_trusted_path (cp, len))
{
free (to_free);
continue;
/* First see whether we must forget the RUNPATH and RPATH from this
object. */
- if (__builtin_expect (GLRO(dl_inhibit_rpath) != NULL, 0)
+ if (__glibc_unlikely (GLRO(dl_inhibit_rpath) != NULL)
&& !INTUSE(__libc_enable_secure))
{
const char *inhp = GLRO(dl_inhibit_rpath);
#ifdef SHARED
/* When loading into a namespace other than the base one we must
avoid loading ld.so since there can only be one copy. Ever. */
- if (__builtin_expect (nsid != LM_ID_BASE, 0)
+ if (__glibc_unlikely (nsid != LM_ID_BASE)
&& ((st.st_ino == GL(dl_rtld_map).l_ino
&& st.st_dev == GL(dl_rtld_map).l_dev)
|| _dl_name_match_p (name, &GL(dl_rtld_map))))
#ifdef SHARED
/* Auditing checkpoint: we are going to add new objects. */
if ((mode & __RTLD_AUDIT) == 0
- && __builtin_expect (GLRO(dl_naudit) > 0, 0))
+ && __glibc_unlikely (GLRO(dl_naudit) > 0))
{
struct link_map *head = GL(dl_ns)[nsid]._ns_loaded;
/* Do not call the functions for any auditing object. */
case PT_LOAD:
/* A load command tells us to map in part of the file.
We record the load commands and process them all later. */
- if (__builtin_expect ((ph->p_align & (GLRO(dl_pagesize) - 1)) != 0,
- 0))
+ if (__glibc_unlikely ((ph->p_align & (GLRO(dl_pagesize) - 1)) != 0))
{
errstring = N_("ELF load command alignment not page-aligned");
goto call_lose;
}
- if (__builtin_expect (((ph->p_vaddr - ph->p_offset)
- & (ph->p_align - 1)) != 0, 0))
+ if (__glibc_unlikely (((ph->p_vaddr - ph->p_offset)
+ & (ph->p_align - 1)) != 0))
{
errstring
= N_("ELF load command address/offset not properly aligned");
/* If not loading the initial set of shared libraries,
check whether we should permit loading a TLS segment. */
- if (__builtin_expect (l->l_type == lt_library, 1)
+ if (__glibc_likely (l->l_type == lt_library)
/* If GL(dl_tls_dtv_slotinfo_list) == NULL, then rtld.c did
not set up TLS data structures, so don't use them now. */
- || __builtin_expect (GL(dl_tls_dtv_slotinfo_list) != NULL, 1))
+ || __glibc_likely (GL(dl_tls_dtv_slotinfo_list) != NULL))
{
/* Assign the next available module ID. */
l->l_tls_modid = _dl_next_tls_modid ();
/* The first call allocates TLS bookkeeping data structures.
Then we allocate the TCB for the initial thread. */
- if (__builtin_expect (_dl_tls_setup (), 0)
- || __builtin_expect ((tcb = _dl_allocate_tls (NULL)) == NULL,
- 0))
+ if (__glibc_unlikely (_dl_tls_setup ())
+ || __glibc_unlikely ((tcb = _dl_allocate_tls (NULL)) == NULL))
{
errval = ENOMEM;
errstring = N_("\
/* Make sure we are not dlopen'ing an object that has the
DF_1_NOOPEN flag set. */
- if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
+ if (__glibc_unlikely (l->l_flags_1 & DF_1_NOOPEN)
&& (mode & __RTLD_DLOPEN))
{
/* We are not supposed to load this object. Free all resources. */
if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X))
{
- if (__builtin_expect (__check_caller (RETURN_ADDRESS (0), allow_ldso),
- 0) != 0)
+ if (__glibc_unlikely (__check_caller (RETURN_ADDRESS (0), allow_ldso) != 0))
{
errstring = N_("invalid caller");
goto call_lose;
/* If this object has DT_SYMBOLIC set modify now its scope. We don't
have to do this for the main map. */
if ((mode & RTLD_DEEPBIND) == 0
- && __builtin_expect (l->l_info[DT_SYMBOLIC] != NULL, 0)
+ && __glibc_unlikely (l->l_info[DT_SYMBOLIC] != NULL)
&& &l->l_searchlist != l->l_scope[0])
{
/* Create an appropriate searchlist. It contains only this map.
/* When we profile the SONAME might be needed for something else but
loading. Add it right away. */
- if (__builtin_expect (GLRO(dl_profile) != NULL, 0)
+ if (__glibc_unlikely (GLRO(dl_profile) != NULL)
&& l->l_info[DT_SONAME] != NULL)
add_name_to_object (l, ((const char *) D_PTR (l, l_info[DT_STRTAB])
+ l->l_info[DT_SONAME]->d_un.d_val));
#ifdef SHARED
/* Auditing checkpoint: we have a new object. */
- if (__builtin_expect (GLRO(dl_naudit) > 0, 0)
+ if (__glibc_unlikely (GLRO(dl_naudit) > 0)
&& !GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing)
{
struct audit_ifaces *afct = GLRO(dl_audit);
#ifdef SHARED
/* Give the auditing libraries a chance. */
- if (__builtin_expect (GLRO(dl_naudit) > 0, 0) && whatcode != 0
+ if (__glibc_unlikely (GLRO(dl_naudit) > 0) && whatcode != 0
&& loader->l_auditing == 0)
{
struct audit_ifaces *afct = GLRO(dl_audit);
break;
fbp->len += retlen;
}
- while (__builtin_expect (fbp->len < sizeof (ElfW(Ehdr)), 0));
+ while (__glibc_unlikely (fbp->len < sizeof (ElfW(Ehdr))));
/* This is where the ELF header is loaded. */
ehdr = (ElfW(Ehdr) *) fbp->buf;
goto call_lose;
}
- if (__builtin_expect (ehdr->e_version, EV_CURRENT) != EV_CURRENT)
+ if (__glibc_unlikely (ehdr->e_version != EV_CURRENT))
{
errstring = N_("ELF file version does not match current one");
goto call_lose;
errstring = N_("cannot dynamically load executable");
goto call_lose;
}
- else if (__builtin_expect (ehdr->e_phentsize, sizeof (ElfW(Phdr)))
- != sizeof (ElfW(Phdr)))
+ else if (__glibc_unlikely (ehdr->e_phentsize != sizeof (ElfW(Phdr))))
{
errstring = N_("ELF file's phentsize not the expected size");
goto call_lose;
/* If we are debugging the search for libraries print the path
now if it hasn't happened now. */
- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)
+ if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)
&& current_what != this_dir->what)
{
current_what = this_dir->what;
/* Remember whether we found any existing directory. */
here_any |= this_dir->status[cnt] != nonexisting;
- if (fd != -1 && __builtin_expect (mode & __RTLD_SECURE, 0)
+ if (fd != -1 && __glibc_unlikely (mode & __RTLD_SECURE)
&& INTUSE(__libc_enable_secure))
{
/* This is an extra security effort to make sure nobody can
/* If the requested name matches the soname of a loaded object,
use that object. Elide this check for names that have not
yet been opened. */
- if (__builtin_expect (l->l_faked, 0) != 0
+ if (__glibc_unlikely (l->l_faked != 0)
|| __builtin_expect (l->l_removed, 0) != 0)
continue;
if (!_dl_name_match_p (name, l))
{
const char *soname;
- if (__builtin_expect (l->l_soname_added, 1)
+ if (__glibc_likely (l->l_soname_added)
|| l->l_info[DT_SONAME] == NULL)
continue;
}
/* 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)
&& loader != NULL)
_dl_debug_printf ((mode & __RTLD_CALLMAP) == 0
? "\nfile=%s [%lu]; needed by %s [%lu]\n"
#ifdef SHARED
/* Give the auditing libraries a chance to change the name before we
try anything. */
- if (__builtin_expect (GLRO(dl_naudit) > 0, 0)
+ if (__glibc_unlikely (GLRO(dl_naudit) > 0)
&& (loader == NULL || loader->l_auditing == 0))
{
struct audit_ifaces *afct = GLRO(dl_audit);
if (fd == -1
&& (__builtin_expect (! (mode & __RTLD_SECURE), 1)
|| ! INTUSE(__libc_enable_secure))
- && __builtin_expect (GLRO(dl_inhibit_cache) == 0, 1))
+ && __glibc_likely (GLRO(dl_inhibit_cache) == 0))
{
/* Check the list of libraries in the file /etc/ld.so.cache,
for compatibility with Linux's ldconfig program. */
/* If the loader has the DF_1_NODEFLIB flag set we must not
use a cache entry from any of these directories. */
- if (__builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
+ if (__glibc_unlikely (l->l_flags_1 & DF_1_NODEFLIB))
{
const char *dirp = system_dirs;
unsigned int cnt = 0;
/* Finally, try the default path. */
if (fd == -1
&& ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
- || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
+ || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB)))
&& rtld_search_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, mode, &rtld_search_dirs,
&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
fd = open_verify (realname, &fb,
loader ?: GL(dl_ns)[nsid]._ns_loaded, 0, mode,
&found_other_class, true);
- if (__builtin_expect (fd, 0) == -1)
+ if (__glibc_unlikely (fd == -1))
free (realname);
}
}
if (mode & __RTLD_CALLMAP)
loader = NULL;
- if (__builtin_expect (fd, 0) == -1)
+ if (__glibc_unlikely (fd == -1))
{
if (trace_mode
- && __builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK, 0) == 0)
+ && __glibc_likely ((GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) == 0))
{
/* We haven't found an appropriate library. But since we
are only interested in the list of libraries this isn't