Skip to content

[libc] Combine the function prototype int (*compar)(const void *, const void *) #134238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025

Conversation

c8ef
Copy link
Contributor

@c8ef c8ef commented Apr 3, 2025

Closes #134118.

@c8ef c8ef marked this pull request as ready for review April 3, 2025 12:33
@llvmbot llvmbot added the libc label Apr 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2025

@llvm/pr-subscribers-libc

Author: Connector Switch (c8ef)

Changes

Closes #134118.


Full diff: https://github.com/llvm/llvm-project/pull/134238.diff

6 Files Affected:

  • (modified) libc/include/CMakeLists.txt (+10-10)
  • (modified) libc/include/llvm-libc-types/CMakeLists.txt (+1-2)
  • (removed) libc/include/llvm-libc-types/__lsearchcompare_t.h (-14)
  • (renamed) libc/include/llvm-libc-types/__search_compare_t.h (+5-5)
  • (modified) libc/include/search.yaml (+5-5)
  • (modified) libc/include/stdlib.yaml (+3-3)
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index d1e116ac547d7..e407de2f16959 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -240,13 +240,13 @@ add_header_macro(
   ../libc/include/search.yaml
   search.h
   DEPENDS
-    .llvm_libc_common_h
     .llvm-libc-types.ACTION
     .llvm-libc-types.ENTRY
-    .llvm-libc-types.struct_hsearch_data
-    .llvm-libc-types.size_t
     .llvm-libc-types.VISIT
-    .llvm-libc-types.__lsearchcompare_t
+    .llvm-libc-types.__search_compare_t
+    .llvm-libc-types.size_t
+    .llvm-libc-types.struct_hsearch_data
+    .llvm_libc_common_h
 )
 
 add_header_macro(
@@ -343,17 +343,17 @@ add_header_macro(
   ../libc/include/stdlib.yaml
   stdlib.h
   DEPENDS
-    .llvm_libc_common_h
     .llvm-libc-macros.stdlib_macros
+    .llvm-libc-types.__atexithandler_t
+    .llvm-libc-types.__qsortcompare_t
+    .llvm-libc-types.__qsortrcompare_t
+    .llvm-libc-types.__search_compare_t
     .llvm-libc-types.div_t
     .llvm-libc-types.ldiv_t
     .llvm-libc-types.lldiv_t
-    .llvm-libc-types.size_t
-    .llvm-libc-types.__bsearchcompare_t
-    .llvm-libc-types.__qsortcompare_t
-    .llvm-libc-types.__qsortrcompare_t
-    .llvm-libc-types.__atexithandler_t
     .llvm-libc-types.locale_t
+    .llvm-libc-types.size_t
+    .llvm_libc_common_h
 )
 
 add_header_macro(
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 66e8527701873..9ed39bcd05190 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -2,8 +2,7 @@ add_header(off64_t HDR off64_t.h)
 add_header(size_t HDR size_t.h)
 add_header(ssize_t HDR ssize_t.h)
 add_header(__atfork_callback_t HDR __atfork_callback_t.h)
-add_header(__bsearchcompare_t HDR __bsearchcompare_t.h)
-add_header(__lsearchcompare_t HDR __lsearchcompare_t.h)
+add_header(__search_compare_t HDR __search_compare_t.h)
 add_header(__call_once_func_t HDR __call_once_func_t.h)
 add_header(__dl_iterate_phdr_callback_t HDR __dl_iterate_phdr_callback_t.h DEPENDS .size_t)
 add_header(__exec_argv_t HDR __exec_argv_t.h)
diff --git a/libc/include/llvm-libc-types/__lsearchcompare_t.h b/libc/include/llvm-libc-types/__lsearchcompare_t.h
deleted file mode 100644
index 08dc2db274d0c..0000000000000
--- a/libc/include/llvm-libc-types/__lsearchcompare_t.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//===-- Definition of type __lsearchcompare_t -----------------------------===//
-//
-// 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_TYPES___LSEARCHCOMPARE_T_H
-#define LLVM_LIBC_TYPES___LSEARCHCOMPARE_T_H
-
-typedef int (*__lsearchcompare_t)(const void *, const void *);
-
-#endif // LLVM_LIBC_TYPES___LSEARCHCOMPARE_T_H
diff --git a/libc/include/llvm-libc-types/__bsearchcompare_t.h b/libc/include/llvm-libc-types/__search_compare_t.h
similarity index 53%
rename from libc/include/llvm-libc-types/__bsearchcompare_t.h
rename to libc/include/llvm-libc-types/__search_compare_t.h
index 0b1987be1fdd6..7033fef49b49a 100644
--- a/libc/include/llvm-libc-types/__bsearchcompare_t.h
+++ b/libc/include/llvm-libc-types/__search_compare_t.h
@@ -1,4 +1,4 @@
-//===-- Definition of type __bsearchcompare_t -----------------------------===//
+//===-- Definition of type __search_compare_t -----------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_TYPES___BSEARCHCOMPARE_T_H
-#define LLVM_LIBC_TYPES___BSEARCHCOMPARE_T_H
+#ifndef LLVM_LIBC_TYPES___SEARCH_COMPARE_T_H
+#define LLVM_LIBC_TYPES___SEARCH_COMPARE_T_H
 
-typedef int (*__bsearchcompare_t)(const void *, const void *);
+typedef int (*__search_compare_t)(const void *, const void *);
 
-#endif // LLVM_LIBC_TYPES___BSEARCHCOMPARE_T_H
+#endif // LLVM_LIBC_TYPES___SEARCH_COMPARE_T_H
diff --git a/libc/include/search.yaml b/libc/include/search.yaml
index e2e711cc93f4d..e0247afad2cd6 100644
--- a/libc/include/search.yaml
+++ b/libc/include/search.yaml
@@ -2,11 +2,11 @@ header: search.h
 header_template: search.h.def
 macros: []
 types:
-  - type_name: struct_hsearch_data
-  - type_name: ENTRY
   - type_name: ACTION
+  - type_name: ENTRY
   - type_name: VISIT
-  - type_name: __lsearchcompare_t
+  - type_name: __search_compare_t
+  - type_name: struct_hsearch_data
 enums: []
 objects: []
 functions:
@@ -69,7 +69,7 @@ functions:
       - type: const void *
       - type: size_t *
       - type: size_t
-      - type: __lsearchcompare_t
+      - type: __search_compare_t
   - name: lsearch
     standards:
       - POSIX
@@ -79,4 +79,4 @@ functions:
       - type: void *
       - type: size_t *
       - type: size_t
-      - type: __lsearchcompare_t
+      - type: __search_compare_t
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index a6204ce3afee3..5690a942e2570 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -7,9 +7,9 @@ merge_yaml_files:
 macros: []
 types:
   - type_name: __atexithandler_t
-  - type_name: __qsortrcompare_t
   - type_name: __qsortcompare_t
-  - type_name: __bsearchcompare_t
+  - type_name: __qsortrcompare_t
+  - type_name: __search_compare_t
   - type_name: div_t
   - type_name: ldiv_t
   - type_name: lldiv_t
@@ -87,7 +87,7 @@ functions:
       - type: const void *
       - type: size_t
       - type: size_t
-      - type: __bsearchcompare_t
+      - type: __search_compare_t
   - name: div
     standards:
       - stdc

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@c8ef c8ef merged commit b738b82 into llvm:main Apr 3, 2025
19 checks passed
@c8ef c8ef deleted the compare_fn branch April 3, 2025 16:36
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] Combine the function prototype int (*compar)(const void *, const void *)?
4 participants