1 /**
2 * D header file for POSIX.
3 *
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 */
9
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)
14 */
15 module core.sys.posix.dlfcn;
16
17 import core.sys.posix.config;
18
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;
27
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;
43
version(Posix)44 version (Posix):
45 extern (C):
46 nothrow:
47 @nogc:
48 @system:
49
50 //
51 // XOpen (XSI)
52 //
53 /*
54 RTLD_LAZY
55 RTLD_NOW
56 RTLD_GLOBAL
57 RTLD_LOCAL
58
59 int dlclose(void*);
60 char* dlerror();
61 void* dlopen(const scope char*, int);
62 void* dlsym(void*, const scope char*);
63 */
64
65 version (CRuntime_Glibc)
66 {
67 version (X86_Any)
68 {
69 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
70 enum RTLD_LAZY = 0x00001;
71 enum RTLD_NOW = 0x00002;
72 enum RTLD_BINDING_MASK = 0x3;
73 enum RTLD_NOLOAD = 0x00004;
74 enum RTLD_DEEPBIND = 0x00008;
75 enum RTLD_GLOBAL = 0x00100;
76 enum RTLD_LOCAL = 0x00000;
77 enum RTLD_NODELETE = 0x01000;
78 }
79 else version (HPPA_Any)
80 {
81 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h
82 enum RTLD_LAZY = 0x0001;
83 enum RTLD_NOW = 0x0002;
84 enum RTLD_BINDING_MASK = 0x3;
85 enum RTLD_NOLOAD = 0x00004;
86 enum RTLD_DEEPBIND = 0x00008;
87 enum RTLD_GLOBAL = 0x0100;
88 enum RTLD_LOCAL = 0;
89 enum RTLD_NODELETE = 0x01000;
90 }
91 else version (MIPS_Any)
92 {
93 // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
94 enum RTLD_LAZY = 0x0001;
95 enum RTLD_NOW = 0x0002;
96 enum RTLD_BINDING_MASK = 0x3;
97 enum RTLD_NOLOAD = 0x00008;
98 enum RTLD_DEEPBIND = 0x00010;
99 enum RTLD_GLOBAL = 0x0004;
100 enum RTLD_LOCAL = 0;
101 enum RTLD_NODELETE = 0x01000;
102 }
103 else version (PPC_Any)
104 {
105 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
106 enum RTLD_LAZY = 0x00001;
107 enum RTLD_NOW = 0x00002;
108 enum RTLD_BINDING_MASK = 0x3;
109 enum RTLD_NOLOAD = 0x00004;
110 enum RTLD_DEEPBIND = 0x00008;
111 enum RTLD_GLOBAL = 0x00100;
112 enum RTLD_LOCAL = 0;
113 enum RTLD_NODELETE = 0x01000;
114 }
115 else version (ARM_Any)
116 {
117 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
118 enum RTLD_LAZY = 0x00001;
119 enum RTLD_NOW = 0x00002;
120 enum RTLD_BINDING_MASK = 0x3;
121 enum RTLD_NOLOAD = 0x00004;
122 enum RTLD_DEEPBIND = 0x00008;
123 enum RTLD_GLOBAL = 0x00100;
124 enum RTLD_LOCAL = 0;
125 enum RTLD_NODELETE = 0x01000;
126 }
127 else version (RISCV_Any)
128 {
129 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
130 enum RTLD_LAZY = 0x00001;
131 enum RTLD_NOW = 0x00002;
132 enum RTLD_BINDING_MASK = 0x3;
133 enum RTLD_NOLOAD = 0x00004;
134 enum RTLD_DEEPBIND = 0x00008;
135 enum RTLD_GLOBAL = 0x00100;
136 enum RTLD_LOCAL = 0;
137 enum RTLD_NODELETE = 0x01000;
138 }
139 else version (SPARC_Any)
140 {
141 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
142 enum RTLD_LAZY = 0x00001;
143 enum RTLD_NOW = 0x00002;
144 enum RTLD_BINDING_MASK = 0x3;
145 enum RTLD_NOLOAD = 0x00004;
146 enum RTLD_DEEPBIND = 0x00008;
147 enum RTLD_GLOBAL = 0x00100;
148 enum RTLD_LOCAL = 0;
149 enum RTLD_NODELETE = 0x01000;
150
151 }
152 else version (IBMZ_Any)
153 {
154 // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
155 enum RTLD_LAZY = 0x00001;
156 enum RTLD_NOW = 0x00002;
157 enum RTLD_BINDING_MASK = 0x3;
158 enum RTLD_NOLOAD = 0x00004;
159 enum RTLD_DEEPBIND = 0x00008;
160 enum RTLD_GLOBAL = 0x00100;
161 enum RTLD_LOCAL = 0;
162 enum RTLD_NODELETE = 0x01000;
163 }
164 else
165 static assert(0, "unimplemented");
166
167 int dlclose(void*);
168 char* dlerror();
169 void* dlopen(const scope char*, int);
170 void* dlsym(void*, const scope char*);
171 int dladdr(const scope void*, Dl_info*);
172
173 struct Dl_info
174 {
175 const(char)* dli_fname;
176 void* dli_fbase;
177 const(char)* dli_sname;
178 void* dli_saddr;
179 }
180 }
181 else version (Darwin)
182 {
183 enum RTLD_LAZY = 0x00001;
184 enum RTLD_NOW = 0x00002;
185 enum RTLD_NOLOAD = 0x10;
186 enum RTLD_NODELETE = 0x80;
187 enum RTLD_GLOBAL = 0x00100;
188 enum RTLD_LOCAL = 0x00000;
189 enum RTLD_FIRST = 0x100;
190
191 int dlclose(void*);
192 char* dlerror();
193 void* dlopen(const scope char*, int);
194 void* dlsym(void*, const scope char*);
195 int dladdr(scope const void* addr, Dl_info* info);
196
197 struct Dl_info
198 {
199 const(char)* dli_fname;
200 void* dli_fbase;
201 const(char)* dli_sname;
202 void* dli_saddr;
203 }
204 }
205 else version (FreeBSD)
206 {
207 enum RTLD_LAZY = 1;
208 enum RTLD_NOW = 2;
209 enum RTLD_MODEMASK = 0x3;
210 enum RTLD_GLOBAL = 0x100;
211 enum RTLD_LOCAL = 0;
212 enum RTLD_TRACE = 0x200;
213 enum RTLD_NODELETE = 0x01000;
214 enum RTLD_NOLOAD = 0x02000;
215
216 int dlclose(void*);
217 char* dlerror();
218 void* dlopen(const scope char*, int);
219 void* dlsym(void*, const scope char*);
220 int dladdr(const(void)* addr, Dl_info* info);
221
222 struct Dl_info
223 {
224 const(char)* dli_fname;
225 void* dli_fbase;
226 const(char)* dli_sname;
227 void* dli_saddr;
228 }
229 }
230 else version (NetBSD)
231 {
232 enum RTLD_LAZY = 1;
233 enum RTLD_NOW = 2;
234 enum RTLD_GLOBAL = 0x100;
235 enum RTLD_LOCAL = 0x200;
236 enum RTLD_NODELETE = 0x01000; /* Do not remove members. */
237 enum RTLD_NOLOAD = 0x02000;
238
239 int dlclose(void*);
240 char* dlerror();
241 void* dlopen(const scope char*, int);
242 void* dlsym(void*, const scope char*);
243 int dladdr(const(void)* addr, Dl_info* info);
244
245 struct Dl_info
246 {
247 const(char)* dli_fname;
248 void* dli_fbase;
249 const(char)* dli_sname;
250 void* dli_saddr;
251 }
252 }
253 else version (OpenBSD)
254 {
255 enum RTLD_LAZY = 1;
256 enum RTLD_NOW = 2;
257 enum RTLD_GLOBAL = 0x100;
258 enum RTLD_LOCAL = 0;
259 enum RTLD_TRACE = 0x200;
260 enum RTLD_NODELETE = 0x400;
261
262 int dlclose(void*);
263 char* dlerror();
264 void* dlopen(const scope char*, int);
265 void* dlsym(void*, const scope char*);
266 int dladdr(const(void)* addr, Dl_info* info);
267
268 struct Dl_info
269 {
270 const(char)* dli_fname;
271 void* dli_fbase;
272 const(char)* dli_sname;
273 void* dli_saddr;
274 }
275 }
276 else version (DragonFlyBSD)
277 {
278 enum RTLD_LAZY = 1;
279 enum RTLD_NOW = 2;
280 enum RTLD_MODEMASK = 0x3;
281 enum RTLD_GLOBAL = 0x100;
282 enum RTLD_LOCAL = 0;
283 enum RTLD_TRACE = 0x200;
284 enum RTLD_NODELETE = 0x01000;
285 enum RTLD_NOLOAD = 0x02000;
286
287 int dlclose(void*);
288 char* dlerror();
289 void* dlopen(const scope char*, int);
290 void* dlsym(void*, const scope char*);
291 int dladdr(const(void)* addr, Dl_info* info);
292
293 struct Dl_info
294 {
295 const(char)* dli_fname;
296 void* dli_fbase;
297 const(char)* dli_sname;
298 void* dli_saddr;
299 }
300 }
301 else version (Solaris)
302 {
303 enum RTLD_LAZY = 1;
304 enum RTLD_NOW = 2;
305 enum RTLD_NOLOAD = 0x00004;
306 enum RTLD_DEEPBIND = 0x00008;
307 enum RTLD_GLOBAL = 0x100;
308 enum RTLD_LOCAL = 0;
309 enum RTLD_PARENT = 0x00200;
310 enum RTLD_GROUP = 0x00400;
311 enum RTLD_WORLD = 0x00800;
312 enum RTLD_NODELETE = 0x01000;
313 enum RTLD_FIRST = 0x02000;
314 enum RTLD_CONFGEN = 0x10000;
315
316 int dlclose(void*);
317 char* dlerror();
318 void* dlopen(const scope char*, int);
319 void* dlsym(void*, const scope char*);
320 int dladdr(const(void)* addr, Dl_info* info);
321
322 struct Dl_info
323 {
324 const(char)* dli_fname;
325 void* dli_fbase;
326 const(char)* dli_sname;
327 void* dli_saddr;
328 }
329 }
330 else version (CRuntime_Bionic)
331 {
332 enum
333 {
334 RTLD_NOW = 0,
335 RTLD_LAZY = 1,
336 RTLD_LOCAL = 0,
337 RTLD_GLOBAL = 2
338 }
339
340 int dladdr(const scope void*, Dl_info*);
341 int dlclose(void*);
342 const(char)* dlerror();
343 void* dlopen(const scope char*, int);
344 void* dlsym(void*, const scope char*);
345
346 struct Dl_info
347 {
348 const(char)* dli_fname;
349 void* dli_fbase;
350 const(char)* dli_sname;
351 void* dli_saddr;
352 }
353 }
354 else version (CRuntime_Musl)
355 {
356 enum {
357 RTLD_LAZY = 1,
358 RTLD_NOW = 2,
359 RTLD_NOLOAD = 4,
360 RTLD_NODELETE = 4096,
361 RTLD_GLOBAL = 256,
362 RTLD_LOCAL = 0,
363 }
364 int dlclose(void*);
365 const(char)* dlerror();
366 void* dlopen(const scope char*, int);
367 void* dlsym(void*, const scope char*);
368
369 int dladdr(scope const void *addr, Dl_info *info);
370 struct Dl_info
371 {
372 const(char)* dli_fname;
373 void* dli_fbase;
374 const(char)* dli_sname;
375 void* dli_saddr;
376 }
377 }
378 else version (CRuntime_UClibc)
379 {
380 version (X86_64)
381 {
382 enum RTLD_LAZY = 0x0001;
383 enum RTLD_NOW = 0x0002;
384 enum RTLD_BINDING_MASK = 0x3;
385 enum RTLD_NOLOAD = 0x00004;
386 enum RTLD_GLOBAL = 0x00100;
387 enum RTLD_LOCAL = 0;
388 enum RTLD_NODELETE = 0x01000;
389 }
390 else version (MIPS_Any)
391 {
392 enum RTLD_LAZY = 0x0001;
393 enum RTLD_NOW = 0x0002;
394 enum RTLD_BINDING_MASK = 0x3;
395 enum RTLD_NOLOAD = 0x00008;
396 enum RTLD_GLOBAL = 0x0004;
397 enum RTLD_LOCAL = 0;
398 enum RTLD_NODELETE = 0x01000;
399 }
400 else version (ARM)
401 {
402 enum RTLD_LAZY = 0x0001;
403 enum RTLD_NOW = 0x0002;
404 enum RTLD_BINDING_MASK = 0x3;
405 enum RTLD_NOLOAD = 0x00004;
406 enum RTLD_GLOBAL = 0x00100;
407 enum RTLD_LOCAL = 0;
408 enum RTLD_NODELETE = 0x01000;
409 }
410 else
411 static assert(0, "unimplemented");
412
413 int dlclose(void*);
414 char* dlerror();
415 void* dlopen(const scope char*, int);
416 void* dlsym(void*, const scope char*);
417 int dladdr(const scope void*, Dl_info*);
418
419 struct Dl_info
420 {
421 const(char)* dli_fname;
422 void* dli_fbase;
423 const(char)* dli_sname;
424 void* dli_saddr;
425 }
426 }
427