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