Skip to content

Commit 02a0b3e

Browse files
[libc] Add dlfcn.h placeholder
1 parent ccf357f commit 02a0b3e

File tree

13 files changed

+233
-0
lines changed

13 files changed

+233
-0
lines changed

libc/config/linux/aarch64/entrypoints.txt

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ set(TARGET_LIBC_ENTRYPOINTS
1717
libc.src.ctype.tolower
1818
libc.src.ctype.toupper
1919

20+
# dlfcn.h entrypoints
21+
libc.src.dlfcn.dlopen
22+
libc.src.dlfcn.dlsym
23+
libc.src.dlfcn.dlclose
24+
libc.src.dlfcn.dlerror
25+
2026
# errno.h entrypoints
2127
libc.src.errno.errno
2228

libc/config/linux/x86_64/entrypoints.txt

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ set(TARGET_LIBC_ENTRYPOINTS
1717
libc.src.ctype.tolower
1818
libc.src.ctype.toupper
1919

20+
# dlfcn.h entrypoints
21+
libc.src.dlfcn.dlopen
22+
libc.src.dlfcn.dlsym
23+
libc.src.dlfcn.dlclose
24+
libc.src.dlfcn.dlerror
25+
2026
# errno.h entrypoints
2127
libc.src.errno.errno
2228

libc/spec/posix.td

+35
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,40 @@ def POSIX : StandardSpec<"POSIX"> {
222222
[] // Functions
223223
>;
224224

225+
HeaderSpec DlFcn = HeaderSpec<
226+
"dlfcn.h",
227+
[
228+
Macro<"RTLD_LAZY">,
229+
Macro<"RTLD_NOW">,
230+
Macro<"RTLD_GLOBAL">,
231+
Macro<"RTLD_LOCAL">,
232+
],
233+
[], // Types
234+
[], // Enumerations
235+
[
236+
FunctionSpec<
237+
"dlclose",
238+
RetValSpec<IntType>,
239+
[ArgSpec<VoidPtr>]
240+
>,
241+
FunctionSpec<
242+
"dlerror",
243+
RetValSpec<CharPtr>,
244+
[]
245+
>,
246+
FunctionSpec<
247+
"dlopen",
248+
RetValSpec<VoidPtr>,
249+
[ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
250+
>,
251+
FunctionSpec<
252+
"dlsym",
253+
RetValSpec<VoidPtr>,
254+
[ArgSpec<VoidRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>]
255+
>,
256+
]
257+
>;
258+
225259
HeaderSpec FCntl = HeaderSpec<
226260
"fcntl.h",
227261
[], // Macros
@@ -1690,6 +1724,7 @@ def POSIX : StandardSpec<"POSIX"> {
16901724
ArpaInet,
16911725
CType,
16921726
Dirent,
1727+
DlFcn,
16931728
Errno,
16941729
FCntl,
16951730
PThread,

libc/src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_subdirectory(__support)
22

33
add_subdirectory(ctype)
4+
add_subdirectory(dlfcn)
45
add_subdirectory(errno)
56
add_subdirectory(fenv)
67
add_subdirectory(inttypes)

libc/src/dlfcn/CMakeLists.txt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
add_entrypoint_object(
2+
dlclose
3+
SRCS
4+
dlclose.cpp
5+
HDRS
6+
dlclose.h
7+
DEPENDS
8+
libc.include.dlfcn
9+
libc.src.errno.errno
10+
)
11+
12+
add_entrypoint_object(
13+
dlerror
14+
SRCS
15+
dlerror.cpp
16+
HDRS
17+
dlerror.h
18+
DEPENDS
19+
libc.include.dlfcn
20+
libc.src.errno.errno
21+
)
22+
23+
add_entrypoint_object(
24+
dlopen
25+
SRCS
26+
dlopen.cpp
27+
HDRS
28+
dlopen.h
29+
DEPENDS
30+
libc.include.dlfcn
31+
libc.src.errno.errno
32+
)
33+
34+
add_entrypoint_object(
35+
dlsym
36+
SRCS
37+
dlsym.cpp
38+
HDRS
39+
dlsym.h
40+
DEPENDS
41+
libc.include.dlfcn
42+
libc.src.errno.errno
43+
)

libc/src/dlfcn/dlclose.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Implementation of dlclose -----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "dlclose.h"
10+
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(int, dlclose, (void *)) { return -1; }
16+
17+
} // namespace LIBC_NAMESPACE

libc/src/dlfcn/dlclose.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header of dlclose ------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_DLFCN_DLCLOSE_H
10+
#define LLVM_LIBC_SRC_DLFCN_DLCLOSE_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
int dlclose(void *);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_DLFCN_DLCLOSE_H

libc/src/dlfcn/dlerror.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- Implementation of delerror ----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "dlerror.h"
10+
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(char *, dlerror, ()) {
16+
return const_cast<char *>("unsupported");
17+
}
18+
19+
} // namespace LIBC_NAMESPACE

libc/src/dlfcn/dlerror.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header of dlerror ------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_DLFCN_DLERROR_H
10+
#define LLVM_LIBC_SRC_DLFCN_DLERROR_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
char *dlerror();
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_DLFCN_DLERROR_H

libc/src/dlfcn/dlopen.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Implementation of dlopen -----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "dlopen.h"
10+
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(void *, dlopen, (const char *, int)) { return nullptr; }
16+
17+
} // namespace LIBC_NAMESPACE

libc/src/dlfcn/dlopen.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header of dlopen -------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_DLFCN_DLOPEN_H
10+
#define LLVM_LIBC_SRC_DLFCN_DLOPEN_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
void *dlopen(const char *, int);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_DLFCN_DLOPEN_H

libc/src/dlfcn/dlsym.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Implementation of dlsym ------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "dlsym.h"
10+
11+
#include "src/__support/common.h"
12+
13+
namespace LIBC_NAMESPACE {
14+
15+
LLVM_LIBC_FUNCTION(void *, dlsym, (void *, const char *)) { return nullptr; }
16+
17+
} // namespace LIBC_NAMESPACE

libc/src/dlfcn/dlsym.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header of dlsym --------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_DLFCN_DLSYM_H
10+
#define LLVM_LIBC_SRC_DLFCN_DLSYM_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
void *dlsym(void *, const char *);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_DLFCN_DLSYM_H

0 commit comments

Comments
 (0)