about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
Diffstat (limited to 'nscd')
-rw-r--r--nscd/aicache.c4
-rw-r--r--nscd/cache.c16
-rw-r--r--nscd/connections.c20
-rw-r--r--nscd/grpcache.c4
-rw-r--r--nscd/hstcache.c4
-rw-r--r--nscd/initgrcache.c4
-rw-r--r--nscd/mem.c12
-rw-r--r--nscd/netgroupcache.c8
-rw-r--r--nscd/nscd-client.h4
-rw-r--r--nscd/nscd_getai.c4
-rw-r--r--nscd/nscd_getgr_r.c12
-rw-r--r--nscd/nscd_gethst_r.c6
-rw-r--r--nscd/nscd_getpw_r.c8
-rw-r--r--nscd/nscd_getserv_r.c4
-rw-r--r--nscd/nscd_helper.c18
-rw-r--r--nscd/nscd_initgroups.c2
-rw-r--r--nscd/nscd_netgroup.c4
-rw-r--r--nscd/pwdcache.c4
-rw-r--r--nscd/selinux.c2
-rw-r--r--nscd/servicescache.c4
20 files changed, 72 insertions, 72 deletions
diff --git a/nscd/aicache.c b/nscd/aicache.c
index d6b928cf2d..98d40a1c55 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -77,7 +77,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
     char strdata[0];
   } *dataset = NULL;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in hosts cache!"), (char *) key);
@@ -434,7 +434,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
 	      struct dataset *newp
 		= (struct dataset *) mempool_alloc (db, total + req->key_len,
 						    1);
-	      if (__builtin_expect (newp != NULL, 1))
+	      if (__glibc_likely (newp != NULL))
 		{
 		  /* Adjust pointer into the memory block.  */
 		  key_copy = (char *) newp + (key_copy - (char *) dataset);
diff --git a/nscd/cache.c b/nscd/cache.c
index 2c35a34943..5e8a42f596 100644
--- a/nscd/cache.c
+++ b/nscd/cache.c
@@ -138,7 +138,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet,
 	   bool first, struct database_dyn *table,
 	   uid_t owner, bool prune_wakeup)
 {
-  if (__builtin_expect (debug_level >= 2, 0))
+  if (__glibc_unlikely (debug_level >= 2))
     {
       const char *str;
       char buf[INET6_ADDRSTRLEN + 1];
@@ -311,7 +311,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
   bool *mark;
   size_t memory_needed = cnt * sizeof (bool);
   bool mark_use_alloca;
-  if (__builtin_expect (memory_needed <= MAX_STACK_USE, 1))
+  if (__glibc_likely (memory_needed <= MAX_STACK_USE))
     {
       mark = alloca (cnt * sizeof (bool));
       memset (mark, '\0', memory_needed);
@@ -327,7 +327,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
   char *const data = table->data;
   bool any = false;
 
-  if (__builtin_expect (debug_level > 2, 0))
+  if (__glibc_unlikely (debug_level > 2))
     dbg_log (_("pruning %s cache; time %ld"),
 	     dbnames[table - dbs], (long int) now);
 
@@ -343,7 +343,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
 	  struct datahead *dh = (struct datahead *) (data + runp->packet);
 
 	  /* Some debug support.  */
-	  if (__builtin_expect (debug_level > 2, 0))
+	  if (__glibc_unlikely (debug_level > 2))
 	    {
 	      char buf[INET6_ADDRSTRLEN];
 	      const char *str;
@@ -422,7 +422,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
     }
   while (cnt > 0);
 
-  if (__builtin_expect (fd != -1, 0))
+  if (__glibc_unlikely (fd != -1))
     {
       /* Reply to the INVALIDATE initiator that the cache has been
 	 invalidated.  */
@@ -436,7 +436,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
 
       /* Now we have to get the write lock since we are about to modify
 	 the table.  */
-      if (__builtin_expect (pthread_rwlock_trywrlock (&table->lock) != 0, 0))
+      if (__glibc_unlikely (pthread_rwlock_trywrlock (&table->lock) != 0))
 	{
 	  ++table->head->wrlockdelayed;
 	  pthread_rwlock_wrlock (&table->lock);
@@ -492,7 +492,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
 	       MS_ASYNC);
 
       /* One extra pass if we do debugging.  */
-      if (__builtin_expect (debug_level > 0, 0))
+      if (__glibc_unlikely (debug_level > 0))
 	{
 	  struct hashentry *runp = head;
 
@@ -517,7 +517,7 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
 	}
     }
 
-  if (__builtin_expect (! mark_use_alloca, 0))
+  if (__glibc_unlikely (! mark_use_alloca))
     free (mark);
 
   /* Run garbage collection if any entry has been removed or replaced.  */
diff --git a/nscd/connections.c b/nscd/connections.c
index f3732f5ef4..f463f45b86 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -999,7 +999,7 @@ register_traced_file (size_t dbidx, struct traced_file *finfo)
   if (! dbs[dbidx].enabled || ! dbs[dbidx].check_file)
     return;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     dbg_log (_("register trace file %s for database %s"),
 	     finfo->fname, dbnames[dbidx]);
 
@@ -1129,7 +1129,7 @@ send_ro_fd (struct database_dyn *db, char *key, int fd)
 #endif
   (void) TEMP_FAILURE_RETRY (sendmsg (fd, &msg, MSG_NOSIGNAL));
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     dbg_log (_("provide access to FD %d, for %s"), db->ro_fd, key);
 }
 #endif	/* SCM_RIGHTS */
@@ -1201,7 +1201,7 @@ request from '%s' [%ld] not handled due to missing permission"),
 	}
 
       /* Is this service enabled?  */
-      if (__builtin_expect (!db->enabled, 0))
+      if (__glibc_unlikely (!db->enabled))
 	{
 	  /* No, sent the prepared record.  */
 	  if (TEMP_FAILURE_RETRY (send (fd, db->disabled_iov->iov_base,
@@ -1220,7 +1220,7 @@ request from '%s' [%ld] not handled due to missing permission"),
 	}
 
       /* Be sure we can read the data.  */
-      if (__builtin_expect (pthread_rwlock_tryrdlock (&db->lock) != 0, 0))
+      if (__glibc_unlikely (pthread_rwlock_tryrdlock (&db->lock) != 0))
 	{
 	  ++db->head->rdlockdelayed;
 	  pthread_rwlock_rdlock (&db->lock);
@@ -1236,7 +1236,7 @@ request from '%s' [%ld] not handled due to missing permission"),
 	  ssize_t nwritten;
 
 #ifdef HAVE_SENDFILE
-	  if (__builtin_expect (db->mmap_used, 1))
+	  if (__glibc_likely (db->mmap_used))
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) cached->data > (char *) db->data);
@@ -1603,7 +1603,7 @@ nscd_run_prune (void *p)
   dbs[my_number].head->timestamp = now;
 
   struct timespec prune_ts;
-  if (__builtin_expect (clock_gettime (timeout_clock, &prune_ts) == -1, 0))
+  if (__glibc_unlikely (clock_gettime (timeout_clock, &prune_ts) == -1))
     /* Should never happen.  */
     abort ();
 
@@ -1656,7 +1656,7 @@ nscd_run_prune (void *p)
 	     we need to wake up occasionally to update the timestamp.
 	     Wait 90% of the update period.  */
 #define UPDATE_MAPPING_TIMEOUT (MAPPING_TIMEOUT * 9 / 10)
-	  if (__builtin_expect (! dont_need_update, 0))
+	  if (__glibc_unlikely (! dont_need_update))
 	    {
 	      next_wait = MIN (UPDATE_MAPPING_TIMEOUT, next_wait);
 	      dbs[my_number].head->timestamp = now;
@@ -1756,7 +1756,7 @@ nscd_run_worker (void *p)
 #ifdef SO_PEERCRED
       pid_t pid = 0;
 
-      if (__builtin_expect (debug_level > 0, 0))
+      if (__glibc_unlikely (debug_level > 0))
 	{
 	  struct ucred caller;
 	  socklen_t optlen = sizeof (caller);
@@ -1849,7 +1849,7 @@ fd_ready (int fd)
     }
 
   bool do_signal = true;
-  if (__builtin_expect (nready == 0, 0))
+  if (__glibc_unlikely (nready == 0))
     {
       ++client_queued;
       do_signal = false;
@@ -2264,7 +2264,7 @@ main_loop_epoll (int efd)
 						 sizeof (inev)));
 		if (nb < (ssize_t) sizeof (struct inotify_event))
 		  {
-		    if (__builtin_expect (nb == -1 && errno != EAGAIN, 0))
+		    if (__glibc_unlikely (nb == -1 && errno != EAGAIN))
 		      {
 			/* Something went wrong when reading the inotify
 			   data.  Better disable inotify.  */
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index 8f5d39b138..b5a33eb347 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -452,7 +452,7 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req,
   bool use_malloc = false;
   int errval = 0;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in group cache!"), keystr);
@@ -465,7 +465,7 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req,
     {
       errno = 0;
 
-      if (__builtin_expect (buflen > 32768, 0))
+      if (__glibc_unlikely (buflen > 32768))
 	{
 	  char *old_buffer = buffer;
 	  buflen *= 2;
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index abedf9a63e..a79b67aa7e 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -480,7 +480,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req,
   int errval = 0;
   int32_t ttl = INT32_MAX;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       const char *str;
       char buf[INET6_ADDRSTRLEN + 1];
@@ -502,7 +502,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req,
     {
       errno = 0;
 
-      if (__builtin_expect (buflen > 32768, 0))
+      if (__glibc_unlikely (buflen > 32768))
 	{
 	  char *old_buffer = buffer;
 	  buflen *= 2;
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index a727fa9c8b..1bf9f0d7f4 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -71,7 +71,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
     char strdata[0];
   } *dataset = NULL;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in group cache!"), (char *) key);
@@ -112,7 +112,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
      mempool_alloc.  */
   // XXX This really should use alloca.  need to change the backends.
   gid_t *groups = (gid_t *) malloc (size * sizeof (gid_t));
-  if (__builtin_expect (groups == NULL, 0))
+  if (__glibc_unlikely (groups == NULL))
     /* No more memory.  */
     goto out;
 
diff --git a/nscd/mem.c b/nscd/mem.c
index 0d09e21d5e..b4090fb6a5 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -124,11 +124,11 @@ gc (struct database_dyn *db)
   /* In prune_cache we are also using a dynamically allocated array.
      If the array in the caller is too large we have malloc'ed it.  */
   size_t stack_used = sizeof (bool) * db->head->module;
-  if (__builtin_expect (stack_used > MAX_STACK_USE, 0))
+  if (__glibc_unlikely (stack_used > MAX_STACK_USE))
     stack_used = 0;
   size_t nmark = (db->head->first_free / BLOCK_ALIGN + BITS - 1) / BITS;
   size_t memory_needed = nmark * sizeof (BITMAP_T);
-  if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1))
+  if (__glibc_likely (stack_used + memory_needed <= MAX_STACK_USE))
     {
       mark = (BITMAP_T *) alloca_account (memory_needed, stack_used);
       mark_use_malloc = false;
@@ -146,7 +146,7 @@ gc (struct database_dyn *db)
   struct hashentry **he;
   struct hashentry **he_data;
   bool he_use_malloc;
-  if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1))
+  if (__glibc_likely (stack_used + memory_needed <= MAX_STACK_USE))
     {
       he = alloca_account (memory_needed, stack_used);
       he_use_malloc = false;
@@ -421,7 +421,7 @@ gc (struct database_dyn *db)
 	}
       while (runp != moves->next);
 
-      if (__builtin_expect (debug_level >= 3, 0))
+      if (__glibc_unlikely (debug_level >= 3))
 	dbg_log (_("freed %zu bytes in %s cache"),
 		 db->head->first_free
 		 - ((char *) moves->to + moves->size - db->data),
@@ -432,7 +432,7 @@ gc (struct database_dyn *db)
       db->head->first_free = (char *) moves->to + moves->size - db->data;
 
       /* Consistency check.  */
-      if (__builtin_expect (debug_level >= 3, 0))
+      if (__glibc_unlikely (debug_level >= 3))
 	{
 	  for (size_t idx = 0; idx < db->head->module; ++idx)
 	    {
@@ -527,7 +527,7 @@ mempool_alloc (struct database_dyn *db, size_t len, int data_alloc)
  retry:
   res = db->data + db->head->first_free;
 
-  if (__builtin_expect (db->head->first_free + len > db->head->data_size, 0))
+  if (__glibc_unlikely (db->head->first_free + len > db->head->data_size))
     {
       if (! tried_resize)
 	{
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index be01fe8670..426d3c5e39 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -120,7 +120,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 		 const char *key, uid_t uid, struct hashentry *he,
 		 struct datahead *dh, struct dataset **resultp)
 {
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in netgroup cache!"), key);
@@ -398,7 +398,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
   {
     struct dataset *newp
       = (struct dataset *) mempool_alloc (db, total + req->key_len, 1);
-    if (__builtin_expect (newp != NULL, 1))
+    if (__glibc_likely (newp != NULL))
       {
 	/* Adjust pointer into the memory block.  */
 	key_copy = (char *) newp + (key_copy - buffer);
@@ -494,7 +494,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
     key = (char *) rawmemchr (key, '\0') + 1;
   const char *domain = *key++ ? key : NULL;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s (%s,%s,%s)\" in netgroup cache!"),
@@ -531,7 +531,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
 					    1);
   struct indataset dataset_mem;
   bool cacheable = true;
-  if (__builtin_expect (dataset == NULL, 0))
+  if (__glibc_unlikely (dataset == NULL))
     {
       cacheable = false;
       dataset = &dataset_mem;
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index b5c9f871a7..98f77e7901 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -331,7 +331,7 @@ __nscd_acquire_maplock (volatile struct locked_map_ptr *mapptr)
 								1, 0) != 0, 0))
     {
       // XXX Best number of rounds?
-      if (__builtin_expect (++cnt > 5, 0))
+      if (__glibc_unlikely (++cnt > 5))
 	return false;
 
       atomic_delay ();
@@ -369,7 +369,7 @@ __nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle)
   if (map != NO_MAPPING)
     {
       int now_cycle = map->head->gc_cycle;
-      if (__builtin_expect (now_cycle != *gc_cycle, 0))
+      if (__glibc_unlikely (now_cycle != *gc_cycle))
 	{
 	  /* We might have read inconsistent data.  */
 	  *gc_cycle = now_cycle;
diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c
index 155cfef2eb..328c2617da 100644
--- a/nscd/nscd_getai.c
+++ b/nscd/nscd_getai.c
@@ -42,7 +42,7 @@ extern int __nss_have_localdomain attribute_hidden;
 int
 __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
 {
-  if (__builtin_expect (__nss_have_localdomain >= 0, 0))
+  if (__glibc_unlikely (__nss_have_localdomain >= 0))
     {
       if (__nss_have_localdomain == 0)
 	__nss_have_localdomain = getenv ("LOCALDOMAIN") != NULL ? 1 : -1;
@@ -171,7 +171,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
     }
   else
     {
-      if (__builtin_expect (ai_resp.found == -1, 0))
+      if (__glibc_unlikely (ai_resp.found == -1))
 	{
 	  /* The daemon does not cache this database.  */
 	  __nss_not_use_nscd_hosts = 1;
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index ed5dc11159..d9b91a470f 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -143,7 +143,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
   /* No value found so far.  */
   *result = NULL;
 
-  if (__builtin_expect (gr_resp.found == -1, 0))
+  if (__glibc_unlikely (gr_resp.found == -1))
     {
       /* The daemon does not cache this database.  */
       __nss_not_use_nscd_group = 1;
@@ -164,7 +164,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	       & (__alignof__ (char *) - 1));
       total_len = (align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *)
 		   + gr_resp.gr_name_len + gr_resp.gr_passwd_len);
-      if (__builtin_expect (buflen < total_len, 0))
+      if (__glibc_unlikely (buflen < total_len))
 	{
 	no_room:
 	  __set_errno (ERANGE);
@@ -190,7 +190,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
       if (gr_name == NULL)
 	{
 	  /* Handle a simple, usual case: no group members.  */
-	  if (__builtin_expect (gr_resp.gr_mem_cnt == 0, 1))
+	  if (__glibc_likely (gr_resp.gr_mem_cnt == 0))
 	    {
 	      size_t n = gr_resp.gr_name_len + gr_resp.gr_passwd_len;
 	      if (__builtin_expect (__readall (sock, resultbuf->gr_name, n)
@@ -217,7 +217,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 
 	      /* Get this data.  */
 	      size_t n = __readvall (sock, vec, 2);
-	      if (__builtin_expect (n != total_len, 0))
+	      if (__glibc_unlikely (n != total_len))
 		goto out_close;
 	    }
 	}
@@ -239,7 +239,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	  p += len[cnt];
 	}
 
-      if (__builtin_expect (gr_name + gr_name_len + total_len > recend, 0))
+      if (__glibc_unlikely (gr_name + gr_name_len + total_len > recend))
 	{
 	  /* len array might contain garbage during nscd GC cycle,
 	     retry rather than fail in that case.  */
@@ -247,7 +247,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	    retval = -2;
 	  goto out_close;
 	}
-      if (__builtin_expect (total_len > buflen, 0))
+      if (__glibc_unlikely (total_len > buflen))
 	{
 	  /* len array might contain garbage during nscd GC cycle,
 	     retry rather than fail in that case.  */
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 3368fc4482..fe885ee320 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -140,7 +140,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
 	       struct hostent *resultbuf, char *buffer, size_t buflen,
 	       struct hostent **result, int *h_errnop)
 {
-  if (__builtin_expect (__nss_have_localdomain >= 0, 0))
+  if (__glibc_unlikely (__nss_have_localdomain >= 0))
     {
       if (__nss_have_localdomain == 0)
 	__nss_have_localdomain = getenv ("LOCALDOMAIN") != NULL ? 1 : -1;
@@ -232,7 +232,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
   /* No value found so far.  */
   *result = NULL;
 
-  if (__builtin_expect (hst_resp.found == -1, 0))
+  if (__glibc_unlikely (hst_resp.found == -1))
     {
       /* The daemon does not cache this database.  */
       __nss_not_use_nscd_hosts = 1;
@@ -377,7 +377,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
 	  goto out_close;
 	}
       /* See whether this would exceed the buffer capacity.  */
-      if (__builtin_expect (cp > buffer + buflen, 0))
+      if (__glibc_unlikely (cp > buffer + buflen))
 	{
 	  /* aliases_len array might contain garbage during nscd GC cycle,
 	     retry rather than fail in that case.  */
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index 5454ab62ad..278b9db8ff 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -134,7 +134,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
   /* No value found so far.  */
   *result = NULL;
 
-  if (__builtin_expect (pw_resp.found == -1, 0))
+  if (__glibc_unlikely (pw_resp.found == -1))
     {
       /* The daemon does not cache this database.  */
       __nss_not_use_nscd_passwd = 1;
@@ -165,9 +165,9 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
       p += pw_resp.pw_shell_len;
 
       ssize_t total = p - buffer;
-      if (__builtin_expect (pw_name + total > recend, 0))
+      if (__glibc_unlikely (pw_name + total > recend))
 	goto out_close;
-      if (__builtin_expect (buflen < total, 0))
+      if (__glibc_unlikely (buflen < total))
 	{
 	  __set_errno (ERANGE);
 	  retval = ERANGE;
@@ -179,7 +179,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
 	{
 	  ssize_t nbytes = __readall (sock, buffer, total);
 
-	  if (__builtin_expect (nbytes != total, 0))
+	  if (__glibc_unlikely (nbytes != total))
 	    {
 	      /* The `errno' to some value != ERANGE.  */
 	      __set_errno (ENOENT);
diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
index 38f159eecf..4e3f702b84 100644
--- a/nscd/nscd_getserv_r.c
+++ b/nscd/nscd_getserv_r.c
@@ -189,7 +189,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
   /* No value found so far.  */
   *result = NULL;
 
-  if (__builtin_expect (serv_resp.found == -1, 0))
+  if (__glibc_unlikely (serv_resp.found == -1))
     {
       /* The daemon does not cache this database.  */
       __nss_not_use_nscd_services = 1;
@@ -300,7 +300,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 	}
 
       /* See whether this would exceed the buffer capacity.  */
-      if (__builtin_expect (cp > buf + buflen, 0))
+      if (__glibc_unlikely (cp > buf + buflen))
 	{
 	  /* aliases_len array might contain garbage during nscd GC cycle,
 	     retry rather than fail in that case.  */
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index e4fb2e59f8..0d61643f10 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -110,7 +110,7 @@ __readvall (int fd, const struct iovec *iov, int iovcnt)
   ssize_t ret = TEMP_FAILURE_RETRY (__readv (fd, iov, iovcnt));
   if (ret <= 0)
     {
-      if (__builtin_expect (ret == 0 || errno != EAGAIN, 1))
+      if (__glibc_likely (ret == 0 || errno != EAGAIN))
 	/* A genuine error or no data to read.  */
 	return ret;
 
@@ -226,7 +226,7 @@ open_socket (request_type type, const char *key, size_t keylen)
       ssize_t wres = TEMP_FAILURE_RETRY (__send (sock, &reqdata,
 						 real_sizeof_reqdata,
 						 MSG_NOSIGNAL));
-      if (__builtin_expect (wres == (ssize_t) real_sizeof_reqdata, 1))
+      if (__glibc_likely (wres == (ssize_t) real_sizeof_reqdata))
 	/* We managed to send the request.  */
 	return sock;
 
@@ -339,13 +339,13 @@ __nscd_get_mapping (request_type type, const char *key,
   int *ip = (void *) CMSG_DATA (cmsg);
   mapfd = *ip;
 
-  if (__builtin_expect (n != keylen && n != keylen + sizeof (mapsize), 0))
+  if (__glibc_unlikely (n != keylen && n != keylen + sizeof (mapsize)))
     goto out_close;
 
-  if (__builtin_expect (strcmp (resdata, key) != 0, 0))
+  if (__glibc_unlikely (strcmp (resdata, key) != 0))
     goto out_close;
 
-  if (__builtin_expect (n == keylen, 0))
+  if (__glibc_unlikely (n == keylen))
     {
       struct stat64 st;
       if (__builtin_expect (fstat64 (mapfd, &st) != 0, 0)
@@ -358,7 +358,7 @@ __nscd_get_mapping (request_type type, const char *key,
 
   /* The file is large enough, map it now.  */
   void *mapping = __mmap (NULL, mapsize, PROT_READ, MAP_SHARED, mapfd, 0);
-  if (__builtin_expect (mapping != MAP_FAILED, 1))
+  if (__glibc_likely (mapping != MAP_FAILED))
     {
       /* Check whether the database is correct and up-to-date.  */
       struct database_pers_head *head = mapping;
@@ -383,7 +383,7 @@ __nscd_get_mapping (request_type type, const char *key,
 					       ALIGN)
 		     + head->data_size);
 
-      if (__builtin_expect (mapsize < size, 0))
+      if (__glibc_unlikely (mapsize < size))
 	goto out_unmap;
 
       /* Allocate a record for the mapping.  */
@@ -433,7 +433,7 @@ __nscd_get_map_ref (request_type type, const char *name,
 
   cur = mapptr->mapped;
 
-  if (__builtin_expect (cur != NO_MAPPING, 1))
+  if (__glibc_likely (cur != NO_MAPPING))
     {
       /* If not mapped or timestamp not updated, request new map.  */
       if (cur == NULL
@@ -443,7 +443,7 @@ __nscd_get_map_ref (request_type type, const char *name,
 	cur = __nscd_get_mapping (type, name,
 				  (struct mapped_database **) &mapptr->mapped);
 
-      if (__builtin_expect (cur != NO_MAPPING, 1))
+      if (__glibc_likely (cur != NO_MAPPING))
 	{
 	  if (__builtin_expect (((*gc_cyclep = cur->head->gc_cycle) & 1) != 0,
 				0))
diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c
index 8bc3e6ce3d..a11ef061fd 100644
--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -130,7 +130,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
     }
   else
     {
-      if (__builtin_expect (initgr_resp.found == -1, 0))
+      if (__glibc_unlikely (initgr_resp.found == -1))
 	{
 	  /* The daemon does not cache this database.  */
 	  __nss_not_use_nscd_group = 1;
diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c
index 4acb0be412..104bf21c30 100644
--- a/nscd/nscd_netgroup.c
+++ b/nscd/nscd_netgroup.c
@@ -124,7 +124,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
     }
   else
     {
-      if (__builtin_expect (netgroup_resp.found == -1, 0))
+      if (__glibc_unlikely (netgroup_resp.found == -1))
 	{
 	  /* The daemon does not cache this database.  */
 	  __nss_not_use_nscd_netgroup = 1;
@@ -248,7 +248,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user,
     retval = innetgroup_resp.result;
   else
     {
-      if (__builtin_expect (innetgroup_resp.found == -1, 0))
+      if (__glibc_unlikely (innetgroup_resp.found == -1))
 	{
 	  /* The daemon does not cache this database.  */
 	  __nss_not_use_nscd_netgroup = 1;
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 5adb8ad8e3..fa355c3891 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -430,7 +430,7 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req,
   bool use_malloc = false;
   int errval = 0;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in password cache!"), keystr);
@@ -443,7 +443,7 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req,
     {
       errno = 0;
 
-      if (__builtin_expect (buflen > 32768, 0))
+      if (__glibc_unlikely (buflen > 32768))
 	{
 	  char *old_buffer = buffer;
 	  buflen *= 2;
diff --git a/nscd/selinux.c b/nscd/selinux.c
index c0c8e22f5c..e477254251 100644
--- a/nscd/selinux.c
+++ b/nscd/selinux.c
@@ -212,7 +212,7 @@ preserve_capabilities (void)
 
   cap_free (tmp_caps);
 
-  if (__builtin_expect (res != 0, 0))
+  if (__glibc_unlikely (res != 0))
     {
       cap_free (new_caps);
       dbg_log (_("Failed to drop capabilities"));
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 52058a6e02..12ce9b2ca4 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -389,7 +389,7 @@ addservbyX (struct database_dyn *db, int fd, request_header *req,
   bool use_malloc = false;
   int errval = 0;
 
-  if (__builtin_expect (debug_level > 0, 0))
+  if (__glibc_unlikely (debug_level > 0))
     {
       if (he == NULL)
 	dbg_log (_("Haven't found \"%s\" in services cache!"), key);
@@ -402,7 +402,7 @@ addservbyX (struct database_dyn *db, int fd, request_header *req,
     {
       errno = 0;
 
-      if (__builtin_expect (buflen > 32768, 0))
+      if (__glibc_unlikely (buflen > 32768))
 	{
 	  char *old_buffer = buffer;
 	  buflen *= 2;