| 1 |
/** |
| 2 |
* D header file for GNU/Linux |
| 3 |
* |
| 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; |
| 7 |
|
| 8 |
version (linux): |
| 9 |
extern (C): |
| 10 |
nothrow: |
| 11 |
@nogc: |
| 12 |
|
| 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; |
| 28 |
|
| 29 |
public import core.sys.posix.dlfcn; |
| 30 |
import core.sys.linux.config; |
| 31 |
|
| 32 |
// <bits/dlfcn.h> |
| 33 |
version (X86_Any) |
| 34 |
{ |
| 35 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 36 |
static if (_GNU_SOURCE) |
| 37 |
{ |
| 38 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 39 |
{ |
| 40 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 41 |
return fctp(args); |
| 42 |
} |
| 43 |
|
| 44 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 45 |
} |
| 46 |
} |
| 47 |
else version (HPPA_Any) |
| 48 |
{ |
| 49 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h |
| 50 |
static if (_GNU_SOURCE) |
| 51 |
{ |
| 52 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 53 |
{ |
| 54 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 55 |
return fctp(args); |
| 56 |
} |
| 57 |
|
| 58 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 59 |
} |
| 60 |
} |
| 61 |
else version (MIPS_Any) |
| 62 |
{ |
| 63 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h |
| 64 |
static if (_GNU_SOURCE) |
| 65 |
{ |
| 66 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 67 |
{ |
| 68 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 69 |
return fctp(args); |
| 70 |
} |
| 71 |
|
| 72 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 73 |
} |
| 74 |
} |
| 75 |
else version (PPC_Any) |
| 76 |
{ |
| 77 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 78 |
static if (_GNU_SOURCE) |
| 79 |
{ |
| 80 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 81 |
{ |
| 82 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 83 |
return fctp(args); |
| 84 |
} |
| 85 |
|
| 86 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 87 |
} |
| 88 |
} |
| 89 |
else version (ARM_Any) |
| 90 |
{ |
| 91 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 92 |
static if (_GNU_SOURCE) |
| 93 |
{ |
| 94 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 95 |
{ |
| 96 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 97 |
return fctp(args); |
| 98 |
} |
| 99 |
|
| 100 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 101 |
} |
| 102 |
} |
| 103 |
else version (RISCV_Any) |
| 104 |
{ |
| 105 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 106 |
static if (_GNU_SOURCE) |
| 107 |
{ |
| 108 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 109 |
{ |
| 110 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 111 |
return fctp(args); |
| 112 |
} |
| 113 |
|
| 114 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 115 |
} |
| 116 |
} |
| 117 |
else version (SPARC_Any) |
| 118 |
{ |
| 119 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 120 |
static if (_GNU_SOURCE) |
| 121 |
{ |
| 122 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 123 |
{ |
| 124 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 125 |
return fctp(args); |
| 126 |
} |
| 127 |
|
| 128 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 129 |
} |
| 130 |
} |
| 131 |
else version (IBMZ_Any) |
| 132 |
{ |
| 133 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 134 |
static if (_GNU_SOURCE) |
| 135 |
{ |
| 136 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 137 |
{ |
| 138 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 139 |
return fctp(args); |
| 140 |
} |
| 141 |
|
| 142 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 143 |
} |
| 144 |
} |
| 145 |
else version (LoongArch64) |
| 146 |
{ |
| 147 |
// http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h |
| 148 |
static if (_GNU_SOURCE) |
| 149 |
{ |
| 150 |
RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) |
| 151 |
{ |
| 152 |
_dl_mcount_wrapper_check(cast(void*)fctp); |
| 153 |
return fctp(args); |
| 154 |
} |
| 155 |
|
| 156 |
void _dl_mcount_wrapper_check(void* __selfpc); |
| 157 |
} |
| 158 |
} |
| 159 |
else |
| 160 |
static assert(0, "unimplemented"); |
| 161 |
|
| 162 |
// <bits/dlfcn.h> |
| 163 |
|
| 164 |
static if (_GNU_SOURCE) |
| 165 |
{ |
| 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; |
| 171 |
} |
| 172 |
|
| 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 |
| 176 |
|
| 177 |
static if (_GNU_SOURCE) |
| 178 |
{ |
| 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); |
| 181 |
} |
| 182 |
|
| 183 |
// char* dlerror(); // POSIX |
| 184 |
|
| 185 |
static if (_GNU_SOURCE) |
| 186 |
{ |
| 187 |
int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags); |
| 188 |
|
| 189 |
enum |
| 190 |
{ |
| 191 |
RTLD_DL_SYMENT = 1, |
| 192 |
RTLD_DL_LINKMAP = 2, |
| 193 |
} |
| 194 |
|
| 195 |
int dlinfo(void* __handle, int __request, void* __arg); |
| 196 |
|
| 197 |
enum |
| 198 |
{ |
| 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, |
| 210 |
} |
| 211 |
|
| 212 |
struct Dl_serpath |
| 213 |
{ |
| 214 |
char* dls_name; |
| 215 |
uint dls_flags; |
| 216 |
} |
| 217 |
|
| 218 |
struct Dl_serinfo |
| 219 |
{ |
| 220 |
size_t dls_size; |
| 221 |
uint dls_cnt; |
| 222 |
Dl_serpath[1] dls_serpath; |
| 223 |
} |
| 224 |
} |