]> The Tcpdump Group git mirrors - libpcap/commitdiff
Restore two lowest_set_bit() optimizations.
authorDenis Ovsienko <[email protected]>
Thu, 1 Feb 2024 13:06:50 +0000 (13:06 +0000)
committerDenis Ovsienko <[email protected]>
Thu, 1 Feb 2024 15:47:36 +0000 (15:47 +0000)
Commit 4aa89c4 removed two variants optimized not just for DOS, but also
for most modern Unix-like OSes and specifically for HP-UX, restore the
part that is not specific to DOS.

optimize.c

index f045e7ad91e24485d6cc6fd79f20541e21f93ba0..8b0f5df37f066cce857f2eca993991bdf515b7d7 100644 (file)
@@ -141,6 +141,21 @@ lowest_set_bit(int mask)
                abort();        /* mask is zero */
        return (u_int)bit;
 }
+#elif defined(STRINGS_H_DECLARES_FFS)
+  /*
+   * A non-Windows OS that has <strings.h> and declares ffs() there (typically
+   * UN*X conforming to a sufficiently recent version of the Single UNIX
+   * Specification, but also Haiku).
+   */
+  #include <strings.h>
+  #define lowest_set_bit(mask) ((u_int)(ffs((mask)) - 1))
+#elif defined(__hpux)
+  /*
+   * HP-UX 11i v3, which declares ffs() in <string.h>, which we've already
+   * included.  Place this branch after the <strings.h> branch, in case a later
+   * release of HP-UX makes the declaration available via the standard header.
+   */
+  #define lowest_set_bit(mask) ((u_int)(ffs((mask)) - 1))
 #else
 /*
  * None of the above.