[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)

Kristof Beyls via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 5 00:53:23 PDT 2024


================
@@ -58,21 +38,15 @@
     v2 = ROTL(v2, 32);                                                         \
   } while (0)
 
-/*
-    Computes a SipHash value
-    *in: pointer to input data (read-only)
-    inlen: input data length in bytes (any size_t value)
-    *k: pointer to the key data (read-only), must be 16 bytes
-    *out: pointer to output data (write-only), outlen bytes must be allocated
-    outlen: length of the output in bytes, must be 8 or 16
-*/
-int siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
-            const size_t outlen) {
+template <int cROUNDS, int dROUNDS, class ResultTy>
+static inline ResultTy siphash(const unsigned char *in, uint64_t inlen,
----------------
kbeyls wrote:

Rather than using "static inline", wouldn't putting the `siphash` function in an anonymous namespace be the more C++-way of not making this function available to other translation units?
I'm also not fully sure if the `inline` keyword makes a meaningful difference?
(I'm not an expert on this, just wondering)

https://github.com/llvm/llvm-project/pull/94394


More information about the llvm-branch-commits mailing list