d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / libphobos / libdruntime / core / sys / posix / dlfcn.d
blobf457c1f22b776aba714ee18d14f9503748585514
1 /**
2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Sean Kelly, Alex Rønne Petersen
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
15 module core.sys.posix.dlfcn;
17 import core.sys.posix.config;
19 version (OSX)
20 version = Darwin;
21 else version (iOS)
22 version = Darwin;
23 else version (TVOS)
24 version = Darwin;
25 else version (WatchOS)
26 version = Darwin;
28 version (ARM) version = ARM_Any;
29 version (AArch64) version = ARM_Any;
30 version (HPPA) version = HPPA_Any;
31 version (MIPS32) version = MIPS_Any;
32 version (MIPS64) version = MIPS_Any;
33 version (PPC) version = PPC_Any;
34 version (PPC64) version = PPC_Any;
35 version (RISCV32) version = RISCV_Any;
36 version (RISCV64) version = RISCV_Any;
37 version (S390) version = IBMZ_Any;
38 version (SPARC) version = SPARC_Any;
39 version (SPARC64) version = SPARC_Any;
40 version (SystemZ) version = IBMZ_Any;
41 version (X86) version = X86_Any;
42 version (X86_64) version = X86_Any;
44 version (Posix):
45 extern (C):
46 nothrow:
47 @nogc:
50 // XOpen (XSI)
53 RTLD_LAZY
54 RTLD_NOW
55 RTLD_GLOBAL
56 RTLD_LOCAL
58 int dlclose(void*);
59 char* dlerror();
60 void* dlopen(const scope char*, int);
61 void* dlsym(void*, const scope char*);
64 version (CRuntime_Glibc)
66 version (X86_Any)
68 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
69 enum RTLD_LAZY = 0x00001;
70 enum RTLD_NOW = 0x00002;
71 enum RTLD_BINDING_MASK = 0x3;
72 enum RTLD_NOLOAD = 0x00004;
73 enum RTLD_DEEPBIND = 0x00008;
74 enum RTLD_GLOBAL = 0x00100;
75 enum RTLD_LOCAL = 0x00000;
76 enum RTLD_NODELETE = 0x01000;
78 else version (HPPA_Any)
80 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
81 enum RTLD_LAZY = 0x0001;
82 enum RTLD_NOW = 0x0002;
83 enum RTLD_BINDING_MASK = 0x3;
84 enum RTLD_NOLOAD = 0x00004;
85 enum RTLD_DEEPBIND = 0x00008;
86 enum RTLD_GLOBAL = 0x0100;
87 enum RTLD_LOCAL = 0;
88 enum RTLD_NODELETE = 0x01000;
90 else version (MIPS_Any)
92 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
93 enum RTLD_LAZY = 0x0001;
94 enum RTLD_NOW = 0x0002;
95 enum RTLD_BINDING_MASK = 0x3;
96 enum RTLD_NOLOAD = 0x00008;
97 enum RTLD_DEEPBIND = 0x00010;
98 enum RTLD_GLOBAL = 0x0004;
99 enum RTLD_LOCAL = 0;
100 enum RTLD_NODELETE = 0x01000;
102 else version (PPC_Any)
104 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
105 enum RTLD_LAZY = 0x00001;
106 enum RTLD_NOW = 0x00002;
107 enum RTLD_BINDING_MASK = 0x3;
108 enum RTLD_NOLOAD = 0x00004;
109 enum RTLD_DEEPBIND = 0x00008;
110 enum RTLD_GLOBAL = 0x00100;
111 enum RTLD_LOCAL = 0;
112 enum RTLD_NODELETE = 0x01000;
114 else version (ARM_Any)
116 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
117 enum RTLD_LAZY = 0x00001;
118 enum RTLD_NOW = 0x00002;
119 enum RTLD_BINDING_MASK = 0x3;
120 enum RTLD_NOLOAD = 0x00004;
121 enum RTLD_DEEPBIND = 0x00008;
122 enum RTLD_GLOBAL = 0x00100;
123 enum RTLD_LOCAL = 0;
124 enum RTLD_NODELETE = 0x01000;
126 else version (RISCV_Any)
128 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
129 enum RTLD_LAZY = 0x00001;
130 enum RTLD_NOW = 0x00002;
131 enum RTLD_BINDING_MASK = 0x3;
132 enum RTLD_NOLOAD = 0x00004;
133 enum RTLD_DEEPBIND = 0x00008;
134 enum RTLD_GLOBAL = 0x00100;
135 enum RTLD_LOCAL = 0;
136 enum RTLD_NODELETE = 0x01000;
138 else version (SPARC_Any)
140 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
141 enum RTLD_LAZY = 0x00001;
142 enum RTLD_NOW = 0x00002;
143 enum RTLD_BINDING_MASK = 0x3;
144 enum RTLD_NOLOAD = 0x00004;
145 enum RTLD_DEEPBIND = 0x00008;
146 enum RTLD_GLOBAL = 0x00100;
147 enum RTLD_LOCAL = 0;
148 enum RTLD_NODELETE = 0x01000;
151 else version (IBMZ_Any)
153 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
154 enum RTLD_LAZY = 0x00001;
155 enum RTLD_NOW = 0x00002;
156 enum RTLD_BINDING_MASK = 0x3;
157 enum RTLD_NOLOAD = 0x00004;
158 enum RTLD_DEEPBIND = 0x00008;
159 enum RTLD_GLOBAL = 0x00100;
160 enum RTLD_LOCAL = 0;
161 enum RTLD_NODELETE = 0x01000;
163 else version (LoongArch64)
165 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
166 enum RTLD_LAZY = 0x00001;
167 enum RTLD_NOW = 0x00002;
168 enum RTLD_BINDING_MASK = 0x3;
169 enum RTLD_NOLOAD = 0x00004;
170 enum RTLD_DEEPBIND = 0x00008;
171 enum RTLD_GLOBAL = 0x00100;
172 enum RTLD_LOCAL = 0;
173 enum RTLD_NODELETE = 0x01000;
175 else
176 static assert(0, "unimplemented");
178 int dlclose(void*);
179 char* dlerror();
180 void* dlopen(const scope char*, int);
181 void* dlsym(void*, const scope char*);
182 int dladdr(const scope void*, Dl_info*);
184 struct Dl_info
186 const(char)* dli_fname;
187 void* dli_fbase;
188 const(char)* dli_sname;
189 void* dli_saddr;
192 else
193 version (CRuntime_Musl)
195 enum RTLD_LAZY = 1;
196 enum RTLD_NOW = 2;
197 enum RTLD_NOLOAD = 4;
198 enum RTLD_NODELETE = 4096;
199 enum RTLD_GLOBAL = 256;
200 enum RTLD_LOCAL = 0;
202 enum RTLD_NEXT = cast(void *)-1;
203 enum RTLD_DEFAULT = cast(void *)0;
205 enum RTLD_DI_LINKMAP = 2;
207 int dlclose(void *);
208 char *dlerror();
209 void *dlopen(const(char) *, int);
211 pragma(mangle, muslRedirTime64Mangle!("dlsym", "__dlsym_time64"))
212 void *dlsym(void *__restrict, const(char) *__restrict);
214 struct Dl_info
216 const(char)* dli_fname;
217 void* dli_fbase;
218 const(char)* dli_sname;
219 void* dli_saddr;
221 int dladdr(const(void) *, Dl_info *);
222 int dlinfo(void *, int, void *);
224 else version (Darwin)
226 enum RTLD_LAZY = 0x00001;
227 enum RTLD_NOW = 0x00002;
228 enum RTLD_NOLOAD = 0x10;
229 enum RTLD_NODELETE = 0x80;
230 enum RTLD_GLOBAL = 0x00100;
231 enum RTLD_LOCAL = 0x00000;
232 enum RTLD_FIRST = 0x100;
234 int dlclose(void*);
235 char* dlerror();
236 void* dlopen(const scope char*, int);
237 void* dlsym(void*, const scope char*);
238 int dladdr(scope const void* addr, Dl_info* info);
240 struct Dl_info
242 const(char)* dli_fname;
243 void* dli_fbase;
244 const(char)* dli_sname;
245 void* dli_saddr;
248 else version (FreeBSD)
250 enum RTLD_LAZY = 1;
251 enum RTLD_NOW = 2;
252 enum RTLD_MODEMASK = 0x3;
253 enum RTLD_GLOBAL = 0x100;
254 enum RTLD_LOCAL = 0;
255 enum RTLD_TRACE = 0x200;
256 enum RTLD_NODELETE = 0x01000;
257 enum RTLD_NOLOAD = 0x02000;
259 int dlclose(void*);
260 char* dlerror();
261 void* dlopen(const scope char*, int);
262 void* dlsym(void*, const scope char*);
263 int dladdr(const(void)* addr, Dl_info* info);
265 struct Dl_info
267 const(char)* dli_fname;
268 void* dli_fbase;
269 const(char)* dli_sname;
270 void* dli_saddr;
273 else version (NetBSD)
275 enum RTLD_LAZY = 1;
276 enum RTLD_NOW = 2;
277 enum RTLD_GLOBAL = 0x100;
278 enum RTLD_LOCAL = 0x200;
279 enum RTLD_NODELETE = 0x01000; /* Do not remove members. */
280 enum RTLD_NOLOAD = 0x02000;
282 int dlclose(void*);
283 char* dlerror();
284 void* dlopen(const scope char*, int);
285 void* dlsym(void*, const scope char*);
286 int dladdr(const(void)* addr, Dl_info* info);
288 struct Dl_info
290 const(char)* dli_fname;
291 void* dli_fbase;
292 const(char)* dli_sname;
293 void* dli_saddr;
296 else version (OpenBSD)
298 enum RTLD_LAZY = 1;
299 enum RTLD_NOW = 2;
300 enum RTLD_GLOBAL = 0x100;
301 enum RTLD_LOCAL = 0;
302 enum RTLD_TRACE = 0x200;
303 enum RTLD_NODELETE = 0x400;
305 int dlclose(void*);
306 char* dlerror();
307 void* dlopen(const scope char*, int);
308 void* dlsym(void*, const scope char*);
309 int dladdr(const(void)* addr, Dl_info* info);
311 struct Dl_info
313 const(char)* dli_fname;
314 void* dli_fbase;
315 const(char)* dli_sname;
316 void* dli_saddr;
319 else version (DragonFlyBSD)
321 enum RTLD_LAZY = 1;
322 enum RTLD_NOW = 2;
323 enum RTLD_MODEMASK = 0x3;
324 enum RTLD_GLOBAL = 0x100;
325 enum RTLD_LOCAL = 0;
326 enum RTLD_TRACE = 0x200;
327 enum RTLD_NODELETE = 0x01000;
328 enum RTLD_NOLOAD = 0x02000;
330 int dlclose(void*);
331 char* dlerror();
332 void* dlopen(const scope char*, int);
333 void* dlsym(void*, const scope char*);
334 int dladdr(const(void)* addr, Dl_info* info);
336 struct Dl_info
338 const(char)* dli_fname;
339 void* dli_fbase;
340 const(char)* dli_sname;
341 void* dli_saddr;
344 else version (Solaris)
346 enum RTLD_LAZY = 1;
347 enum RTLD_NOW = 2;
348 enum RTLD_NOLOAD = 0x00004;
349 enum RTLD_DEEPBIND = 0x00008;
350 enum RTLD_GLOBAL = 0x100;
351 enum RTLD_LOCAL = 0;
352 enum RTLD_PARENT = 0x00200;
353 enum RTLD_GROUP = 0x00400;
354 enum RTLD_WORLD = 0x00800;
355 enum RTLD_NODELETE = 0x01000;
356 enum RTLD_FIRST = 0x02000;
357 enum RTLD_CONFGEN = 0x10000;
359 int dlclose(void*);
360 char* dlerror();
361 void* dlopen(const scope char*, int);
362 void* dlsym(void*, const scope char*);
363 int dladdr(const(void)* addr, Dl_info* info);
365 struct Dl_info
367 const(char)* dli_fname;
368 void* dli_fbase;
369 const(char)* dli_sname;
370 void* dli_saddr;
373 else version (CRuntime_Bionic)
375 enum
377 RTLD_NOW = 0,
378 RTLD_LAZY = 1,
379 RTLD_LOCAL = 0,
380 RTLD_GLOBAL = 2
383 int dladdr(const scope void*, Dl_info*);
384 int dlclose(void*);
385 const(char)* dlerror();
386 void* dlopen(const scope char*, int);
387 void* dlsym(void*, const scope char*);
389 struct Dl_info
391 const(char)* dli_fname;
392 void* dli_fbase;
393 const(char)* dli_sname;
394 void* dli_saddr;
397 else version (CRuntime_Musl)
399 enum {
400 RTLD_LAZY = 1,
401 RTLD_NOW = 2,
402 RTLD_NOLOAD = 4,
403 RTLD_NODELETE = 4096,
404 RTLD_GLOBAL = 256,
405 RTLD_LOCAL = 0,
407 int dlclose(void*);
408 const(char)* dlerror();
409 void* dlopen(const scope char*, int);
410 void* dlsym(void*, const scope char*);
412 int dladdr(scope const void *addr, Dl_info *info);
413 struct Dl_info
415 const(char)* dli_fname;
416 void* dli_fbase;
417 const(char)* dli_sname;
418 void* dli_saddr;
421 else version (CRuntime_UClibc)
423 version (X86_Any)
425 enum RTLD_LAZY = 0x0001;
426 enum RTLD_NOW = 0x0002;
427 enum RTLD_BINDING_MASK = 0x3;
428 enum RTLD_NOLOAD = 0x00004;
429 enum RTLD_GLOBAL = 0x00100;
430 enum RTLD_LOCAL = 0;
431 enum RTLD_NODELETE = 0x01000;
433 else version (MIPS_Any)
435 enum RTLD_LAZY = 0x0001;
436 enum RTLD_NOW = 0x0002;
437 enum RTLD_BINDING_MASK = 0x3;
438 enum RTLD_NOLOAD = 0x00008;
439 enum RTLD_GLOBAL = 0x0004;
440 enum RTLD_LOCAL = 0;
441 enum RTLD_NODELETE = 0x01000;
443 else version (ARM)
445 enum RTLD_LAZY = 0x0001;
446 enum RTLD_NOW = 0x0002;
447 enum RTLD_BINDING_MASK = 0x3;
448 enum RTLD_NOLOAD = 0x00004;
449 enum RTLD_GLOBAL = 0x00100;
450 enum RTLD_LOCAL = 0;
451 enum RTLD_NODELETE = 0x01000;
453 else
454 static assert(0, "unimplemented");
456 int dlclose(void*);
457 char* dlerror();
458 void* dlopen(const scope char*, int);
459 void* dlsym(void*, const scope char*);
460 int dladdr(const scope void*, Dl_info*);
462 struct Dl_info
464 const(char)* dli_fname;
465 void* dli_fbase;
466 const(char)* dli_sname;
467 void* dli_saddr;