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

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Sun Nov 26 19:38:45 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 static HashState state = {
----------------
SchrodingerZhu wrote:

About `LIBC_INLINE(_VAR)`: it looks weird when I write something like `static LIBC_INLINE type function()`. However, I do remember that sometimes people prefer to put storage class in the first place. What is the preferred order?

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


More information about the libc-commits mailing list