Debian Codegraph @

libphobos/libdruntime/core/sys/netbsd/dlfcn.d

raw
1 /**
2 * D header file for NetBSD.
3 *
4 * Copyright: Copyright Martin Nowak 2012.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Martin Nowak
7 *
8 * http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/include/dlfcn.h
9 */
10 module core.sys.netbsd.dlfcn;
11
12 public import core.sys.posix.dlfcn;
13
14 version (NetBSD):
15 extern (C):
16 nothrow:
17 @nogc:
18
19 enum __BSD_VISIBLE = true;
20
21 /*
22 * Request arguments for dlinfo().
23 */
24 enum RTLD_DI_LINKMAP = 3; /* Obtain link map. */
25 enum RTLD_DI_SERINFO = 5; /* Obtain search path info. */
26 enum RTLD_DI_SERINFOSIZE = 6; /* ... query for required space. */
27 enum RTLD_DI_ORIGIN = 7; /* Obtain object origin */
28 enum RTLD_DI_MAX = RTLD_DI_ORIGIN;
29
30 /*
31 * Special handle arguments for dlsym()/dlinfo().
32 */
33 enum RTLD_NEXT = cast(void *)-1; /* Search subsequent objects. */
34 enum RTLD_DEFAULT = cast(void *)-2; /* Use default search algorithm. */
35 enum RTLD_SELF = cast(void *)-3; /* Search the caller itself. */
36
37 static if (__BSD_VISIBLE)
38 {
39 /*-
40 * The actual type declared by this typedef is immaterial, provided that
41 * it is a function pointer. Its purpose is to provide a return type for
42 * dlfunc() which can be cast to a function pointer type without depending
43 * on behavior undefined by the C standard, which might trigger a compiler
44 * diagnostic. We intentionally declare a unique type signature to force
45 * a diagnostic should the application not cast the return value of dlfunc()
46 * appropriately.
47 */
48 struct __dlfunc_arg {
49 int __dlfunc_dummy;
50 }
51
52 alias dlfunc_t = void function(__dlfunc_arg);
53
54 /*
55 * Structures, returned by the RTLD_DI_SERINFO dlinfo() request.
56 */
57 struct Dl_serpath {
58 char * dls_name; /* single search path entry */
59 uint dls_flags; /* path information */
60 }
61
62 struct Dl_serinfo {
63 size_t dls_size; /* total buffer size */
64 uint dls_cnt; /* number of path entries */
65 Dl_serpath[1] dls_serpath; /* there may be more than one */
66 }
67 }
68
69 /* XSI functions first. */
70 extern(C) {
71 static assert(is(typeof(&dlclose) == int function(void*)));
72 static assert(is(typeof(&dlerror) == char* function()));
73 static assert(is(typeof(&dlopen) == void* function(const scope char*, int)));
74 static assert(is(typeof(&dlsym) == void* function(void*, const scope char*)));
75 }
76
77 static if (__BSD_VISIBLE)
78 {
79 int dlinfo(void*, int, void*);
80 void* dlvsym(void*, const(char)*, const(char)*);
81 }