[libc-commits] [libc] [libc] [search] implement hcreate(_r)/hsearch(_r)/hdestroy(_r) (PR #73469)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Nov 27 13:24:33 PST 2023


================
@@ -0,0 +1,59 @@
+//===-- HashTable Randomness ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_HASHTABLE_RANDOMNESS_H
+#define LLVM_LIBC_SRC___SUPPORT_HASHTABLE_RANDOMNESS_H
+
+#include "src/__support/common.h"
+#include "src/__support/hash.h"
+#include "src/__support/macros/attributes.h"
+#if defined(LIBC_HASHTABLE_USE_GETRANDOM)
+#include "src/errno/libc_errno.h"
+#include "src/sys/random/getrandom.h"
+#endif
+
+namespace LIBC_NAMESPACE {
+namespace internal {
+namespace randomness {
+LIBC_INLINE_VAR thread_local HashState state = {
+    0x38049a7ea6f5a79b, 0x45cb02147c3f718a, 0x53eb431c12770718,
+    0x5b55742bd20a2fcb};
----------------
nickdesaulniers wrote:

Mind adding a comment about where these magic constants came from?

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


More information about the libc-commits mailing list