]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: rename bswap64 to pdns_bswap64.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 20 Jun 2025 10:44:48 +0000 (12:44 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 20 Jun 2025 10:44:48 +0000 (12:44 +0200)
Using bswap64 causes infinite reursion if your system has a #define bswap64 __builtin_bswap64

Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
ext/lmdb-safe/lmdb-safe.hh

index 07148ecb0d0c4c2849e4e6a018beeba156564672..ce9c86aea664acb8cccffd82c975bd637d8ce442 100644 (file)
@@ -123,7 +123,9 @@ struct MDBOutVal; // forward declaration because of how the functions below tie
 namespace LMDBLS {
   class __attribute__((__packed__)) LSheader {
   private:
-    static auto bswap64(uint64_t value) -> uint64_t
+    // Some systems #define bswap64 to __builtin_bswap64, and the body below would cause inifinite
+    // recursion if we would name the function bswap64
+    static auto pdns_bswap64(uint64_t value) -> uint64_t
     {
 #if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__) || !defined(__ORDER_BIG_ENDIAN__)
 #error "your compiler does not define byte order macros"
@@ -147,8 +149,8 @@ namespace LMDBLS {
 
     // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
     LSheader(uint64_t timestamp, uint64_t txnid, uint8_t flags = 0, uint8_t version = 0, uint8_t numextra = 0) :
-      d_timestamp(bswap64(timestamp)),
-      d_txnid(bswap64(txnid)),
+      d_timestamp(pdns_bswap64(timestamp)),
+      d_txnid(pdns_bswap64(txnid)),
       d_version(version),
       d_flags(flags),
       d_numextra(htons(numextra))
@@ -160,7 +162,7 @@ namespace LMDBLS {
     }
 
     [[nodiscard]] uint64_t getTimestamp() const {
-      return bswap64(d_timestamp);
+      return pdns_bswap64(d_timestamp);
     }
   };