From 6334b4a1882f251b5190c5c560e9b38a56d2dbc1 Mon Sep 17 00:00:00 2001 From: Tue Ly Date: Tue, 13 May 2025 14:51:47 +0000 Subject: [PATCH 1/2] [libc] Add proxy header for ENTRY type. --- libc/fuzzing/__support/CMakeLists.txt | 1 + libc/fuzzing/__support/hashtable_fuzz.cpp | 2 +- libc/hdr/types/CMakeLists.txt | 9 +++++++++ libc/hdr/types/ENTRY.h | 22 +++++++++++++++++++++ libc/include/llvm-libc-types/ENTRY.h | 2 +- libc/src/__support/HashTable/CMakeLists.txt | 2 +- libc/src/__support/HashTable/table.h | 2 +- libc/src/search/CMakeLists.txt | 4 ++-- libc/src/search/hsearch.h | 3 ++- libc/src/search/hsearch_r.h | 3 ++- 10 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 libc/hdr/types/ENTRY.h diff --git a/libc/fuzzing/__support/CMakeLists.txt b/libc/fuzzing/__support/CMakeLists.txt index cfe51605ed2aa..9c674d2fb0d65 100644 --- a/libc/fuzzing/__support/CMakeLists.txt +++ b/libc/fuzzing/__support/CMakeLists.txt @@ -19,6 +19,7 @@ add_libc_fuzzer( SRCS hashtable_fuzz.cpp DEPENDS + libc.hdr.types.ENTRY libc.src.__support.HashTable.table COMPILE_OPTIONS -D__LIBC_EXPLICIT_SIMD_OPT diff --git a/libc/fuzzing/__support/hashtable_fuzz.cpp b/libc/fuzzing/__support/hashtable_fuzz.cpp index 8ab5e3b55cfd4..a7a57624446df 100644 --- a/libc/fuzzing/__support/hashtable_fuzz.cpp +++ b/libc/fuzzing/__support/hashtable_fuzz.cpp @@ -9,7 +9,7 @@ /// Fuzzing test for llvm-libc hashtable implementations. /// //===----------------------------------------------------------------------===// -#include "include/llvm-libc-types/ENTRY.h" +#include "hdr/types/ENTRY.h" #include "src/__support/CPP/bit.h" #include "src/__support/CPP/string_view.h" #include "src/__support/HashTable/table.h" diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt index ac9fe40abf516..b2890871902f2 100644 --- a/libc/hdr/types/CMakeLists.txt +++ b/libc/hdr/types/CMakeLists.txt @@ -374,3 +374,12 @@ add_proxy_header_library( FULL_BUILD_DEPENDS libc.include.llvm-libc-types.cpu_set_t ) + +add_proxy_header_library( + ENTRY + HDRS + ENTRY.h + FULL_BUILD_DEPENDS + libc.include.llvm-libc-types.ENTRY + libc.include.search +) diff --git a/libc/hdr/types/ENTRY.h b/libc/hdr/types/ENTRY.h new file mode 100644 index 0000000000000..5f4aee4b30fe2 --- /dev/null +++ b/libc/hdr/types/ENTRY.h @@ -0,0 +1,22 @@ +//===-- Proxy header for ENTRY --------------------------------------------===// +// +// 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_HDR_TYPES_ENTRY_H +#define LLVM_LIBC_HDR_TYPES_ENTRY_H + +#ifdef LIBC_FULL_BUILD + +#include "include/llvm-libc-types/ENTRY.h" + +#else // Overlay mode + +#include + +#endif // LLVM_LIBC_FULL_BUILD + +#endif // LLVM_LIBC_HDR_TYPES_ENTRY_H diff --git a/libc/include/llvm-libc-types/ENTRY.h b/libc/include/llvm-libc-types/ENTRY.h index ccbd777e2475b..b007c8edba2f5 100644 --- a/libc/include/llvm-libc-types/ENTRY.h +++ b/libc/include/llvm-libc-types/ENTRY.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_TYPES_ENTRY_H #define LLVM_LIBC_TYPES_ENTRY_H -typedef struct { +typedef struct entry { char *key; void *data; } ENTRY; diff --git a/libc/src/__support/HashTable/CMakeLists.txt b/libc/src/__support/HashTable/CMakeLists.txt index c79ee9ab9f414..3c487e4f29264 100644 --- a/libc/src/__support/HashTable/CMakeLists.txt +++ b/libc/src/__support/HashTable/CMakeLists.txt @@ -25,7 +25,7 @@ add_header_library( table.h DEPENDS .bitmask - libc.include.llvm-libc-types.ENTRY + libc.hdr.types.ENTRY libc.src.__support.CPP.bit libc.src.__support.CPP.new libc.src.__support.hash diff --git a/libc/src/__support/HashTable/table.h b/libc/src/__support/HashTable/table.h index d50a9482ec4ce..13badb90dbfde 100644 --- a/libc/src/__support/HashTable/table.h +++ b/libc/src/__support/HashTable/table.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_HASHTABLE_TABLE_H #define LLVM_LIBC_SRC___SUPPORT_HASHTABLE_TABLE_H -#include "include/llvm-libc-types/ENTRY.h" +#include "hdr/types/ENTRY.h" #include "src/__support/CPP/bit.h" // bit_ceil #include "src/__support/CPP/new.h" #include "src/__support/HashTable/bitmask.h" diff --git a/libc/src/search/CMakeLists.txt b/libc/src/search/CMakeLists.txt index d78ea062342a1..6b7fe3ae5e123 100644 --- a/libc/src/search/CMakeLists.txt +++ b/libc/src/search/CMakeLists.txt @@ -34,11 +34,11 @@ add_entrypoint_object( HDRS hsearch.h DEPENDS + libc.hdr.types.ENTRY libc.src.search.hsearch.global libc.src.__support.HashTable.table libc.src.__support.HashTable.randomness libc.src.errno.errno - libc.include.search ) add_entrypoint_object( @@ -48,9 +48,9 @@ add_entrypoint_object( HDRS hsearch_r.h DEPENDS + libc.hdr.types.ENTRY libc.src.__support.HashTable.table libc.src.errno.errno - libc.include.search ) add_entrypoint_object( diff --git a/libc/src/search/hsearch.h b/libc/src/search/hsearch.h index 4d039850f25d0..6619451580940 100644 --- a/libc/src/search/hsearch.h +++ b/libc/src/search/hsearch.h @@ -9,8 +9,9 @@ #ifndef LLVM_LIBC_SRC_SEARCH_HSEARCH_H #define LLVM_LIBC_SRC_SEARCH_HSEARCH_H +#include "hdr/types/ENTRY.h" #include "src/__support/macros/config.h" -#include // ENTRY, ACTION +#include // ACTION namespace LIBC_NAMESPACE_DECL { ENTRY *hsearch(ENTRY item, ACTION action); diff --git a/libc/src/search/hsearch_r.h b/libc/src/search/hsearch_r.h index 6e9511035f6f2..db2f5a8d3cbe1 100644 --- a/libc/src/search/hsearch_r.h +++ b/libc/src/search/hsearch_r.h @@ -9,8 +9,9 @@ #ifndef LLVM_LIBC_SRC_SEARCH_HSEARCH_R_H #define LLVM_LIBC_SRC_SEARCH_HSEARCH_R_H +#include "hdr/types/ENTRY.h" #include "src/__support/macros/config.h" -#include // ENTRY, ACTION +#include // ACTION namespace LIBC_NAMESPACE_DECL { int hsearch_r(ENTRY item, ACTION action, ENTRY **retval, From c019ef3b1df194dba68335897b99d1f0c7407ae0 Mon Sep 17 00:00:00 2001 From: Tue Ly Date: Tue, 13 May 2025 16:08:44 +0000 Subject: [PATCH 2/2] Move `struct entry` fix to another PR. --- libc/include/llvm-libc-types/ENTRY.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/include/llvm-libc-types/ENTRY.h b/libc/include/llvm-libc-types/ENTRY.h index b007c8edba2f5..ccbd777e2475b 100644 --- a/libc/include/llvm-libc-types/ENTRY.h +++ b/libc/include/llvm-libc-types/ENTRY.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_TYPES_ENTRY_H #define LLVM_LIBC_TYPES_ENTRY_H -typedef struct entry { +typedef struct { char *key; void *data; } ENTRY;