Skip to content

[libc] Convert dlfcn.h to pure YAML #149362

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 3 commits into from
Jul 17, 2025
Merged

[libc] Convert dlfcn.h to pure YAML #149362

merged 3 commits into from
Jul 17, 2025

Conversation

frobtech
Copy link
Contributor

Remove the unnecessary .h.def file and move all the macro
definitions directly into dlfcn.yaml.

Remove the unnecessary .h.def file and move all the macro
definitions directly into dlfcn.yaml.
@frobtech frobtech requested a review from Caslyn July 17, 2025 17:28
@frobtech frobtech marked this pull request as ready for review July 17, 2025 17:28
@llvmbot llvmbot added the libc label Jul 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2025

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

Changes

Remove the unnecessary .h.def file and move all the macro
definitions directly into dlfcn.yaml.


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

3 Files Affected:

  • (removed) libc/include/dlfcn.h.def (-17)
  • (modified) libc/include/dlfcn.yaml (+25-8)
  • (removed) libc/include/llvm-libc-macros/dlfcn-macros.h (-23)
diff --git a/libc/include/dlfcn.h.def b/libc/include/dlfcn.h.def
deleted file mode 100644
index 31395871c6b97..0000000000000
--- a/libc/include/dlfcn.h.def
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- C standard library header dlfcn.h ---------------------------------===//
-//
-// 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_DLFCN_H
-#define LLVM_LIBC_DLFCN_H
-
-#include "__llvm-libc-common.h"
-#include "llvm-libc-macros/dlfcn-macros.h"
-
-%%public_api()
-
-#endif // LLVM_LIBC_DLFCN_H
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 78bbeff4e60d9..28be34dbd95bd 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -1,17 +1,34 @@
 header: dlfcn.h
-header_template: dlfcn.h.def
+standards:
+  - posix
 macros:
+  # Note that macro values are quoted to keep the integer literals as
+  # written.  Without the quotes, YAML will normalize them to minimal
+  # decimal, which is less readable for humans seeing the generated header.
   - macro_name: RTLD_LAZY
-    macro_header: dlfcn-macros.h
+    macro_value: "0x00001"
   - macro_name: RTLD_NOW
-    macro_header: dlfcn-macros.h
+    macro_value: "0x00002"
   - macro_name: RTLD_GLOBAL
-    macro_header: dlfcn-macros.h
+    macro_value: "0x00100"
   - macro_name: RTLD_LOCAL
-    macro_header: dlfcn-macros.h
-types: []
-enums: []
-objects: []
+    macro_value: "0"
+  - macro_name: RTLD_BINDING_MASK
+    standards:
+      - gnu
+    macro_value: "0x00003"
+  - macro_name: RTLD_NOLOAD
+    standards:
+      - gnu
+    macro_value: "0x00004"
+  - macro_name: RTLD_DEEPBIND
+    standards:
+      - gnu
+    macro_value: "0x00008"
+  - macro_name: RTLD_NODELETE
+    standards:
+      - gnu
+    macro_value: "0x01000"
 functions:
   - name: dlclose
     standards:
diff --git a/libc/include/llvm-libc-macros/dlfcn-macros.h b/libc/include/llvm-libc-macros/dlfcn-macros.h
deleted file mode 100644
index dcd202b9ab435..0000000000000
--- a/libc/include/llvm-libc-macros/dlfcn-macros.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//===-- Definition of macros from dlfcn.h ---------------------------------===//
-//
-// 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_MACROS_DLFCN_MACROS_H
-#define LLVM_LIBC_MACROS_DLFCN_MACROS_H
-
-#define RTLD_LAZY 0x00001
-#define RTLD_NOW 0x00002
-#define RTLD_GLOBAL 0x00100
-#define RTLD_LOCAL 0
-
-// Non-standard stuff here
-#define RTLD_BINDING_MASK 0x3
-#define RTLD_NOLOAD 0x00004
-#define RTLD_DEEPBIND 0x00008
-#define RTLD_NODELETE 0x01000
-
-#endif // LLVM_LIBC_MACROS_DLFCN_MACROS_H

@frobtech frobtech merged commit 72a2d82 into llvm:main Jul 17, 2025
16 of 19 checks passed
@frobtech frobtech deleted the p/libc-dlfcn branch July 17, 2025 22:05
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.

3 participants