Skip to content

Commit 33012d8

Browse files
[libc] Add dlfcn.h placeholder
1 parent ccf357f commit 33012d8

File tree

13 files changed

+230
-0
lines changed

13 files changed

+230
-0
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
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.dlclose
22+
libc.src.dlfcn.dlerror
23+
libc.src.dlfcn.dlopen
24+
libc.src.dlfcn.dlsym
25+
2026
# errno.h entrypoints
2127
libc.src.errno.errno
2228

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
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.dlclose
22+
libc.src.dlfcn.dlerror
23+
libc.src.dlfcn.dlopen
24+
libc.src.dlfcn.dlsym
25+
2026
# errno.h entrypoints
2127
libc.src.errno.errno
2228

libc/spec/posix.td

Lines changed: 35 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

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

libc/src/dlfcn/dlclose.cpp

Lines changed: 17 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
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)