-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[libc] Add dlfcn.h
headers
#97772
Merged
Merged
[libc] Add dlfcn.h
headers
#97772
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: Izaak Schroeder (izaakschroeder) ChangesDoes what it says on the box. Split out per request from @SchrodingerZhu Full diff: https://github.com/llvm/llvm-project/pull/97772.diff 7 Files Affected:
diff --git a/libc/config/linux/aarch64/headers.txt b/libc/config/linux/aarch64/headers.txt
index 7d25877cefcc8..8f898f0150905 100644
--- a/libc/config/linux/aarch64/headers.txt
+++ b/libc/config/linux/aarch64/headers.txt
@@ -1,6 +1,7 @@
set(TARGET_PUBLIC_HEADERS
libc.include.assert
libc.include.ctype
+ libc.include.dlfcn
libc.include.errno
libc.include.features
libc.include.fenv
diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index 44d640b75e2bf..df276894246c4 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.assert
libc.include.ctype
libc.include.dirent
+ libc.include.dlfcn
libc.include.errno
libc.include.fcntl
libc.include.features
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 3ab7817d8568b..f8ef35078a8c4 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -51,6 +51,15 @@ add_gen_header(
.llvm_libc_common_h
)
+add_gen_header(
+ dlfcn
+ DEF_FILE dlfcn.h.def
+ GEN_HDR dlfcn.h
+ DEPENDS
+ .llvm-libc-macros.dlfcn_macros
+ .llvm_libc_common_h
+)
+
add_gen_header(
features
DEF_FILE features.h.def
diff --git a/libc/include/dlfcn.h.def b/libc/include/dlfcn.h.def
new file mode 100644
index 0000000000000..31395871c6b97
--- /dev/null
+++ b/libc/include/dlfcn.h.def
@@ -0,0 +1,17 @@
+//===-- 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/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index f6af11abd4dd7..5bf573e4e98df 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -277,3 +277,9 @@ add_macro_header(
HDR
stdckdint-macros.h
)
+
+add_macro_header(
+ dlfcn_macros
+ HDR
+ dlfcn-macros.h
+)
\ No newline at end of file
diff --git a/libc/include/llvm-libc-macros/dlfcn-macros.h b/libc/include/llvm-libc-macros/dlfcn-macros.h
new file mode 100644
index 0000000000000..dcd202b9ab435
--- /dev/null
+++ b/libc/include/llvm-libc-macros/dlfcn-macros.h
@@ -0,0 +1,23 @@
+//===-- 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
diff --git a/libc/spec/posix.td b/libc/spec/posix.td
index d14047548e104..1878b1ee2ae41 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -222,6 +222,40 @@ def POSIX : StandardSpec<"POSIX"> {
[] // Functions
>;
+ HeaderSpec DlFcn = HeaderSpec<
+ "dlfcn.h",
+ [
+ Macro<"RTLD_LAZY">,
+ Macro<"RTLD_NOW">,
+ Macro<"RTLD_GLOBAL">,
+ Macro<"RTLD_LOCAL">,
+ ],
+ [], // Types
+ [], // Enumerations
+ [
+ FunctionSpec<
+ "dlclose",
+ RetValSpec<IntType>,
+ [ArgSpec<VoidPtr>]
+ >,
+ FunctionSpec<
+ "dlerror",
+ RetValSpec<CharPtr>,
+ []
+ >,
+ FunctionSpec<
+ "dlopen",
+ RetValSpec<VoidPtr>,
+ [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
+ >,
+ FunctionSpec<
+ "dlsym",
+ RetValSpec<VoidPtr>,
+ [ArgSpec<VoidRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>]
+ >,
+ ]
+ >;
+
HeaderSpec FCntl = HeaderSpec<
"fcntl.h",
[], // Macros
@@ -1690,6 +1724,7 @@ def POSIX : StandardSpec<"POSIX"> {
ArpaInet,
CType,
Dirent,
+ DlFcn,
Errno,
FCntl,
PThread,
|
0dd0cdd
to
10722bf
Compare
lntue
reviewed
Jul 5, 2024
10722bf
to
b38d575
Compare
SchrodingerZhu
approved these changes
Jul 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Does what it says on the box. Split out per request from @SchrodingerZhu