[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,235 @@
+//===-- Fix-sized Monotonic HashTable ---------------------------*- 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_table_H
+#define LLVM_LIBC_SRC___SUPPORT_HASHTABLE_table_H
+
+#include "include/llvm-libc-types/ENTRY.h"
+#include "src/__support/CPP/new.h"
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/HashTable/bitmask.h"
+#include "src/__support/bit.h"
+#include "src/__support/hash.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/memory_size.h"
+#include "src/string/memset.h"
+#include "src/string/strcmp.h"
+#include "src/string/strlen.h"
+#include <stddef.h>
+#include <stdint.h>
+
+namespace LIBC_NAMESPACE {
+namespace internal {
+
+LIBC_INLINE uint8_t secondary_hash(uint64_t hash) {
+  // top 7 bits of the hash.
+  return static_cast<uint8_t>((hash >> 57) & 0x7f);
----------------
nickdesaulniers wrote:

is the `& 0x7f` necessary if we just want the top 7b?

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


More information about the libc-commits mailing list