[libc-commits] [libc] [libc] Add proxy header for hsearch_data (PR #241000)
Sachin 🗲 via libc-commits
libc-commits at lists.llvm.org
Wed Nov 11 07:47:44 PST 2026
https://github.com/s4chinjha updated https://github.com/llvm/llvm-project/pull/241000
>From 67fbdd05979e70987c1376a5ca3e2a584d448299 Mon Sep 17 00:00:00 2001
From: s4chinjha <s4chinjha at gmail.com>
Date: Wed, 11 Nov 2026 02:15:20 +0530
Subject: [PATCH 1/4] [libc] Add proxy header for hsearch_data
---
libc/hdr/types/CMakeLists.txt | 8 +++++++
libc/hdr/types/hsearch_data.h | 22 +++++++++++++++++++
.../llvm-libc-types/struct_hsearch_data.h | 1 -
libc/src/search/CMakeLists.txt | 6 ++---
libc/src/search/hcreate_r.h | 3 ++-
libc/src/search/hdestroy_r.h | 2 +-
libc/src/search/hsearch_r.h | 2 +-
7 files changed, 37 insertions(+), 7 deletions(-)
create mode 100644 libc/hdr/types/hsearch_data.h
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index f038bcfb380004..bb4e96324a642d 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -1318,6 +1318,14 @@ add_proxy_header_library(
libc.include.llvm-libc-types.VISIT
)
+add_proxy_header_library(
+ hsearch_data
+ HDRS
+ hsearch_data.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.struct_hsearch_data
+)
+
add_proxy_header_library(
glob_t
HDRS
diff --git a/libc/hdr/types/hsearch_data.h b/libc/hdr/types/hsearch_data.h
new file mode 100644
index 00000000000000..e3736830fa3a53
--- /dev/null
+++ b/libc/hdr/types/hsearch_data.h
@@ -0,0 +1,22 @@
+//===-- Proxy header for hsearch_data -------------------------------------===//
+//
+// 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_HSEARCH_DATA_H
+#define LLVM_LIBC_HDR_TYPES_HSEARCH_DATA_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_hsearch_data.h"
+
+#else // Overlay mode
+
+#include <search.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_HSEARCH_DATA_H
diff --git a/libc/include/llvm-libc-types/struct_hsearch_data.h b/libc/include/llvm-libc-types/struct_hsearch_data.h
index cdb1d0c5da14c4..5bb52cd1d412cb 100644
--- a/libc/include/llvm-libc-types/struct_hsearch_data.h
+++ b/libc/include/llvm-libc-types/struct_hsearch_data.h
@@ -11,7 +11,6 @@
struct hsearch_data {
void *__opaque;
- unsigned int __unused[2];
};
#endif // LLVM_LIBC_TYPES_STRUCT_HSEARCH_DATA_H
diff --git a/libc/src/search/CMakeLists.txt b/libc/src/search/CMakeLists.txt
index a872515b9af45f..7b90061d576555 100644
--- a/libc/src/search/CMakeLists.txt
+++ b/libc/src/search/CMakeLists.txt
@@ -24,7 +24,7 @@ add_entrypoint_object(
libc.src.__support.HashTable.table
libc.src.__support.HashTable.randomness
libc.src.errno.errno
- libc.include.search
+ libc.hdr.types.hsearch_data
)
add_entrypoint_object(
@@ -51,7 +51,7 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.ACTION
libc.hdr.types.ENTRY
- libc.include.llvm-libc-types.struct_hsearch_data
+ libc.hdr.types.hsearch_data
libc.src.__support.HashTable.table
libc.src.errno.errno
)
@@ -77,7 +77,7 @@ add_entrypoint_object(
DEPENDS
libc.src.errno.errno
libc.src.__support.HashTable.table
- libc.include.search
+ libc.hdr.types.hsearch_data
)
add_entrypoint_object(
diff --git a/libc/src/search/hcreate_r.h b/libc/src/search/hcreate_r.h
index 9606077b3e8304..29171a25a7d519 100644
--- a/libc/src/search/hcreate_r.h
+++ b/libc/src/search/hcreate_r.h
@@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
#define LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
+#include "hdr/types/hsearch_data.h"
+#include <stddef.h> // size_t
#include "src/__support/macros/config.h"
-#include <search.h>
namespace LIBC_NAMESPACE_DECL {
int hcreate_r(size_t capacity, struct hsearch_data *htab);
diff --git a/libc/src/search/hdestroy_r.h b/libc/src/search/hdestroy_r.h
index c9a4ddf018f386..ca0a6f4d57bba6 100644
--- a/libc/src/search/hdestroy_r.h
+++ b/libc/src/search/hdestroy_r.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SEARCH_HDESTROY_R_H
#define LLVM_LIBC_SRC_SEARCH_HDESTROY_R_H
+#include "hdr/types/hsearch_data.h"
#include "src/__support/macros/config.h"
-#include <search.h>
namespace LIBC_NAMESPACE_DECL {
void hdestroy_r(struct hsearch_data *htab);
diff --git a/libc/src/search/hsearch_r.h b/libc/src/search/hsearch_r.h
index 692bc3cb5f370a..375ad600f1dcba 100644
--- a/libc/src/search/hsearch_r.h
+++ b/libc/src/search/hsearch_r.h
@@ -11,7 +11,7 @@
#include "hdr/types/ACTION.h"
#include "hdr/types/ENTRY.h"
-#include "include/llvm-libc-types/struct_hsearch_data.h"
+#include "hdr/types/hsearch_data.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
>From ab01399d1cb924deb37ddad513249fc31b1c095a Mon Sep 17 00:00:00 2001
From: s4chinjha <s4chinjha at gmail.com>
Date: Wed, 11 Nov 2026 02:34:26 +0530
Subject: [PATCH 2/4] fix: reorder
---
libc/src/search/hcreate_r.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/search/hcreate_r.h b/libc/src/search/hcreate_r.h
index 29171a25a7d519..5b86d5a6b8fddd 100644
--- a/libc/src/search/hcreate_r.h
+++ b/libc/src/search/hcreate_r.h
@@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
#include "hdr/types/hsearch_data.h"
-#include <stddef.h> // size_t
#include "src/__support/macros/config.h"
+#include <stddef.h> // size_t
namespace LIBC_NAMESPACE_DECL {
int hcreate_r(size_t capacity, struct hsearch_data *htab);
>From f9ed013fb09c2ec420473f6fdc00b23fe4c592a3 Mon Sep 17 00:00:00 2001
From: s4chinjha <s4chinjha at gmail.com>
Date: Wed, 11 Nov 2026 11:01:45 +0530
Subject: [PATCH 3/4] [libc] address review comments
---
libc/hdr/types/hsearch_data.h | 7 ++++++-
libc/include/llvm-libc-types/struct_hsearch_data.h | 1 +
libc/src/search/hcreate_r.h | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/libc/hdr/types/hsearch_data.h b/libc/hdr/types/hsearch_data.h
index e3736830fa3a53..72b7aa7f77f375 100644
--- a/libc/hdr/types/hsearch_data.h
+++ b/libc/hdr/types/hsearch_data.h
@@ -1,10 +1,15 @@
-//===-- Proxy header for hsearch_data -------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Proxy header for hsearch_data.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_HDR_TYPES_HSEARCH_DATA_H
#define LLVM_LIBC_HDR_TYPES_HSEARCH_DATA_H
diff --git a/libc/include/llvm-libc-types/struct_hsearch_data.h b/libc/include/llvm-libc-types/struct_hsearch_data.h
index 5bb52cd1d412cb..cdb1d0c5da14c4 100644
--- a/libc/include/llvm-libc-types/struct_hsearch_data.h
+++ b/libc/include/llvm-libc-types/struct_hsearch_data.h
@@ -11,6 +11,7 @@
struct hsearch_data {
void *__opaque;
+ unsigned int __unused[2];
};
#endif // LLVM_LIBC_TYPES_STRUCT_HSEARCH_DATA_H
diff --git a/libc/src/search/hcreate_r.h b/libc/src/search/hcreate_r.h
index 5b86d5a6b8fddd..930f8093657e27 100644
--- a/libc/src/search/hcreate_r.h
+++ b/libc/src/search/hcreate_r.h
@@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
#include "hdr/types/hsearch_data.h"
+#include "hdr/types/size_t.h"
#include "src/__support/macros/config.h"
-#include <stddef.h> // size_t
namespace LIBC_NAMESPACE_DECL {
int hcreate_r(size_t capacity, struct hsearch_data *htab);
>From c0915585776397b1c6aad09dc26295c9ec636d1c Mon Sep 17 00:00:00 2001
From: s4chinjha <s4chinjha at gmail.com>
Date: Wed, 11 Nov 2026 21:17:03 +0530
Subject: [PATCH 4/4] [libc] rename hsearch_data.h to struct_hsearch_data.h
---
libc/hdr/types/CMakeLists.txt | 2 +-
libc/hdr/types/{hsearch_data.h => struct_hsearch_data.h} | 0
libc/src/search/hcreate_r.h | 2 +-
libc/src/search/hdestroy_r.h | 2 +-
libc/src/search/hsearch_r.h | 2 +-
5 files changed, 4 insertions(+), 4 deletions(-)
rename libc/hdr/types/{hsearch_data.h => struct_hsearch_data.h} (100%)
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index bb4e96324a642d..15260624233888 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -1321,7 +1321,7 @@ add_proxy_header_library(
add_proxy_header_library(
hsearch_data
HDRS
- hsearch_data.h
+ struct_hsearch_data.h
FULL_BUILD_DEPENDS
libc.include.llvm-libc-types.struct_hsearch_data
)
diff --git a/libc/hdr/types/hsearch_data.h b/libc/hdr/types/struct_hsearch_data.h
similarity index 100%
rename from libc/hdr/types/hsearch_data.h
rename to libc/hdr/types/struct_hsearch_data.h
diff --git a/libc/src/search/hcreate_r.h b/libc/src/search/hcreate_r.h
index 930f8093657e27..939fa3a09ad030 100644
--- a/libc/src/search/hcreate_r.h
+++ b/libc/src/search/hcreate_r.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
#define LLVM_LIBC_SRC_SEARCH_HCREATE_R_H
-#include "hdr/types/hsearch_data.h"
#include "hdr/types/size_t.h"
+#include "hdr/types/struct_hsearch_data.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/search/hdestroy_r.h b/libc/src/search/hdestroy_r.h
index ca0a6f4d57bba6..32eae0a4d89484 100644
--- a/libc/src/search/hdestroy_r.h
+++ b/libc/src/search/hdestroy_r.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SEARCH_HDESTROY_R_H
#define LLVM_LIBC_SRC_SEARCH_HDESTROY_R_H
-#include "hdr/types/hsearch_data.h"
+#include "hdr/types/struct_hsearch_data.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/search/hsearch_r.h b/libc/src/search/hsearch_r.h
index 375ad600f1dcba..28eec31e5fe656 100644
--- a/libc/src/search/hsearch_r.h
+++ b/libc/src/search/hsearch_r.h
@@ -11,7 +11,7 @@
#include "hdr/types/ACTION.h"
#include "hdr/types/ENTRY.h"
-#include "hdr/types/hsearch_data.h"
+#include "hdr/types/struct_hsearch_data.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
More information about the libc-commits
mailing list