d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / libphobos / libdruntime / core / sys / linux / dlfcn.d
blob9d86d8915556e396e2b92ca7e55bc3ae32b99849
1 /**
2 * D header file for GNU/Linux
4 * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=dlfcn/dlfcn.h, glibc dlfcn/dlfcn.h)
5 */
6 module core.sys.linux.dlfcn;
8 version (linux):
9 extern (C):
10 nothrow:
11 @nogc:
13 version (ARM) version = ARM_Any;
14 version (AArch64) version = ARM_Any;
15 version (HPPA) version = HPPA_Any;
16 version (MIPS32) version = MIPS_Any;
17 version (MIPS64) version = MIPS_Any;
18 version (PPC) version = PPC_Any;
19 version (PPC64) version = PPC_Any;
20 version (RISCV32) version = RISCV_Any;
21 version (RISCV64) version = RISCV_Any;
22 version (S390) version = IBMZ_Any;
23 version (SPARC) version = SPARC_Any;
24 version (SPARC64) version = SPARC_Any;
25 version (SystemZ) version = IBMZ_Any;
26 version (X86) version = X86_Any;
27 version (X86_64) version = X86_Any;
29 public import core.sys.posix.dlfcn;
30 import core.sys.linux.config;
32 // <bits/dlfcn.h>
33 version (X86_Any)
35 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
36 static if (_GNU_SOURCE)
38 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
40 _dl_mcount_wrapper_check(cast(void*)fctp);
41 return fctp(args);
44 void _dl_mcount_wrapper_check(void* __selfpc);
47 else version (HPPA_Any)
49 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
50 static if (_GNU_SOURCE)
52 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
54 _dl_mcount_wrapper_check(cast(void*)fctp);
55 return fctp(args);
58 void _dl_mcount_wrapper_check(void* __selfpc);
61 else version (MIPS_Any)
63 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
64 static if (_GNU_SOURCE)
66 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
68 _dl_mcount_wrapper_check(cast(void*)fctp);
69 return fctp(args);
72 void _dl_mcount_wrapper_check(void* __selfpc);
75 else version (PPC_Any)
77 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
78 static if (_GNU_SOURCE)
80 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
82 _dl_mcount_wrapper_check(cast(void*)fctp);
83 return fctp(args);
86 void _dl_mcount_wrapper_check(void* __selfpc);
89 else version (ARM_Any)
91 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
92 static if (_GNU_SOURCE)
94 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
96 _dl_mcount_wrapper_check(cast(void*)fctp);
97 return fctp(args);
100 void _dl_mcount_wrapper_check(void* __selfpc);
103 else version (RISCV_Any)
105 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
106 static if (_GNU_SOURCE)
108 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
110 _dl_mcount_wrapper_check(cast(void*)fctp);
111 return fctp(args);
114 void _dl_mcount_wrapper_check(void* __selfpc);
117 else version (SPARC_Any)
119 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
120 static if (_GNU_SOURCE)
122 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
124 _dl_mcount_wrapper_check(cast(void*)fctp);
125 return fctp(args);
128 void _dl_mcount_wrapper_check(void* __selfpc);
131 else version (IBMZ_Any)
133 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
134 static if (_GNU_SOURCE)
136 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
138 _dl_mcount_wrapper_check(cast(void*)fctp);
139 return fctp(args);
142 void _dl_mcount_wrapper_check(void* __selfpc);
145 else version (LoongArch64)
147 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
148 static if (_GNU_SOURCE)
150 RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
152 _dl_mcount_wrapper_check(cast(void*)fctp);
153 return fctp(args);
156 void _dl_mcount_wrapper_check(void* __selfpc);
159 else
160 static assert(0, "unimplemented");
162 // <bits/dlfcn.h>
164 static if (_GNU_SOURCE)
166 enum RTLD_NEXT = cast(void *)-1L;
167 enum RTLD_DEFAULT = cast(void *)0;
168 alias c_long Lmid_t;
169 enum LM_ID_BASE = 0;
170 enum LM_ID_NEWLM = -1;
173 // void* dlopen(const scope char* __file, int __mode); // POSIX
174 // int dlclose(void* __handle); // POSIX
175 // void* dlsym(void* __handle, const scope char* __name); // POSIX
177 static if (_GNU_SOURCE)
179 void* dlmopen(Lmid_t __nsid, const scope char* __file, int __mode);
180 void* dlvsym(void* __handle, const scope char* __name, const scope char* __version);
183 // char* dlerror(); // POSIX
185 static if (_GNU_SOURCE)
187 int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);
189 enum
191 RTLD_DL_SYMENT = 1,
192 RTLD_DL_LINKMAP = 2,
195 int dlinfo(void* __handle, int __request, void* __arg);
197 enum
199 RTLD_DI_LMID = 1,
200 RTLD_DI_LINKMAP = 2,
201 RTLD_DI_CONFIGADDR = 3,
202 RTLD_DI_SERINFO = 4,
203 RTLD_DI_SERINFOSIZE = 5,
204 RTLD_DI_ORIGIN = 6,
205 RTLD_DI_PROFILENAME = 7,
206 RTLD_DI_PROFILEOUT = 8,
207 RTLD_DI_TLS_MODID = 9,
208 RTLD_DI_TLS_DATA = 10,
209 RTLD_DI_MAX = 10,
212 struct Dl_serpath
214 char* dls_name;
215 uint dls_flags;
218 struct Dl_serinfo
220 size_t dls_size;
221 uint dls_cnt;
222 Dl_serpath[1] dls_serpath;