]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Mark various conditions as unlikely
authorSergey Bugaev <bugaevc@gmail.com>
Sat, 29 Apr 2023 13:13:50 +0000 (16:13 +0300)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 29 Apr 2023 14:52:45 +0000 (16:52 +0200)
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-3-bugaevc@gmail.com>

hurd/hurd/fd.h
hurd/hurd/signal.h

index f6139544c56667fceff776c308b21403348fd589..472753513795d6d9a0a0dcdef6308cb3177d724d 100644 (file)
@@ -73,18 +73,18 @@ _hurd_fd_get (int fd)
 
   HURD_CRITICAL_BEGIN;
   __mutex_lock (&_hurd_dtable_lock);
-  if (fd < 0 || fd >= _hurd_dtablesize)
+  if (__glibc_unlikely (fd < 0 || fd >= _hurd_dtablesize))
     descriptor = NULL;
   else
     {
       struct hurd_fd *cell = _hurd_dtable[fd];
-      if (cell == NULL)
+      if (__glibc_unlikely (cell == NULL))
        /* No descriptor allocated at this index.  */
        descriptor = NULL;
       else
        {
          __spin_lock (&cell->port.lock);
-         if (cell->port.port == MACH_PORT_NULL)
+         if (__glibc_unlikely (cell->port.port == MACH_PORT_NULL))
            /* The descriptor at this index has no port in it.
               This happens if it existed before but was closed.  */
            descriptor = NULL;
@@ -107,7 +107,7 @@ _hurd_fd_get (int fd)
 
 #define        HURD_FD_USE(fd, expr)                                                 \
   ({ struct hurd_fd *descriptor = _hurd_fd_get (fd);                         \
-     descriptor == NULL ? EBADF : (expr); })
+     __glibc_unlikely (descriptor == NULL) ? EBADF : (expr); })
 
 /* Evaluate EXPR with the variable `port' bound to the port to FD, and
    `ctty' bound to the ctty port.  */
@@ -125,7 +125,7 @@ _hurd_fd_get (int fd)
      io_t port, ctty;                                                        \
      void *crit = _hurd_critical_section_lock ();                            \
      __spin_lock (&__d->port.lock);                                          \
-     if (__d->port.port == MACH_PORT_NULL)                                   \
+     if (__glibc_unlikely (__d->port.port == MACH_PORT_NULL))                \
        {                                                                     \
         __spin_unlock (&__d->port.lock);                                     \
         _hurd_critical_section_unlock (crit);                                \
index b8af6f289a3a1f8f4efa51f1d930cdc2ee8d3f1f..89cf7ac87c25ed648e3704f01880a756d9dc49ef 100644 (file)
@@ -254,9 +254,9 @@ _hurd_critical_section_unlock (void *our_lock)
       sigset_t pending;
       _hurd_sigstate_lock (ss);
       __spin_unlock (&ss->critical_section_lock);
-      pending = _hurd_sigstate_pending(ss) & ~ss->blocked;
+      pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
       _hurd_sigstate_unlock (ss);
-      if (! __sigisemptyset (&pending))
+      if (__glibc_unlikely (!__sigisemptyset (&pending)))
        /* There are unblocked signals pending, which weren't
           delivered because we were in the critical section.
           Tell the signal thread to deliver them now.  */