[libc-commits] [libc] [libc] fix HashTable warnings and build problems (PR #74371)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Mon Dec 4 13:17:56 PST 2023


https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/74371

None

>From 7eb89f406bc94baebd53232b1183ad23518ed7e5 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Mon, 4 Dec 2023 16:17:31 -0500
Subject: [PATCH] [libc] fix HashTable warnings and build problems

---
 libc/src/__support/HashTable/bitmask.h                |  2 +-
 libc/src/__support/HashTable/generic/bitmask_impl.inc |  2 +-
 libc/test/src/__support/CMakeLists.txt                | 10 +++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h
index 8247161c449bd..821735e22f0a4 100644
--- a/libc/src/__support/HashTable/bitmask.h
+++ b/libc/src/__support/HashTable/bitmask.h
@@ -73,7 +73,7 @@ template <class BitMask> struct IteratableBitMaskAdaptor : public BitMask {
     return *this;
   }
   LIBC_INLINE IteratableBitMaskAdaptor begin() { return *this; }
-  LIBC_INLINE IteratableBitMaskAdaptor end() { return {0}; }
+  LIBC_INLINE IteratableBitMaskAdaptor end() { return {{0}}; }
   LIBC_INLINE bool operator==(const IteratableBitMaskAdaptor &other) {
     return this->word == other.word;
   }
diff --git a/libc/src/__support/HashTable/generic/bitmask_impl.inc b/libc/src/__support/HashTable/generic/bitmask_impl.inc
index b8d2bfc7a6ff2..623b51f238df5 100644
--- a/libc/src/__support/HashTable/generic/bitmask_impl.inc
+++ b/libc/src/__support/HashTable/generic/bitmask_impl.inc
@@ -98,7 +98,7 @@ struct Group {
     auto cmp = data ^ repeat_byte(byte);
     auto result = LIBC_NAMESPACE::Endian::to_little_endian(
         (cmp - repeat_byte(0x01)) & ~cmp & repeat_byte(0x80));
-    return {result};
+    return {{result}};
   }
 
   // Find out the lanes equal to EMPTY or DELETE (highest bit set) and
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 2b9fa93bb548e..6db0e53055b25 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -181,4 +181,12 @@ add_subdirectory(File)
 add_subdirectory(RPC)
 add_subdirectory(OSUtil)
 add_subdirectory(FPUtil)
-add_subdirectory(HashTable)
+
+list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch hsearch_index)
+list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch_r hsearch_r_index)
+
+if (${hsearch_index} EQUAL -1 AND ${hsearch_r_index} EQUAL -1)
+  message(STATUS "Skipping HashTable tests since hsearch and hsearch_r are not built.")
+else()
+  add_subdirectory(HashTable)
+endif()



More information about the libc-commits mailing list