From 4e8eb14eec0ad1f09477f45bfd7fd0480fc78668 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 18 Aug 2016 00:27:08 +0200 Subject: [PATCH] Add non-POSIX dlfcn extensions for Darwin, add const to dladdr --- src/core/sys/darwin/dlfcn.d | 40 +++++++++++++++++++++++++++++++++++++ src/core/sys/linux/dlfcn.d | 2 +- src/core/sys/posix/dlfcn.d | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/core/sys/darwin/dlfcn.d diff --git a/src/core/sys/darwin/dlfcn.d b/src/core/sys/darwin/dlfcn.d new file mode 100644 index 0000000000..6666769bb3 --- /dev/null +++ b/src/core/sys/darwin/dlfcn.d @@ -0,0 +1,40 @@ +/** + * D header file for Darwin. + * + * $(LINK2 https://opensource.apple.com/source/dyld/dyld-360.22/include/dlfcn.h, Apple dyld/dlfcn.h) + * + * Copyright: Copyright David Nadlinger 2016. + * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * Authors: David Nadlinger + */ +module core.sys.darwin.dlfcn; + +version (OSX) + version = Darwin; +else version (iOS) + version = Darwin; +else version (TVOS) + version = Darwin; +else version (WatchOS) + version = Darwin; + +version (Darwin): +extern(C): +nothrow: +@nogc: + +public import core.sys.posix.dlfcn; + +struct Dl_info +{ + const(char)* dli_fname; + void* dli_fbase; + const(char)* dli_sname; + void* dli_saddr; +} + +int dladdr(in void* addr, Dl_info* info); + +enum RTLD_NOLOAD = 0x10; +enum RTLD_NODELETE = 0x80; +enum RTLD_FIRST = 0x100; diff --git a/src/core/sys/linux/dlfcn.d b/src/core/sys/linux/dlfcn.d index a3293c3956..7abf6ddde5 100644 --- a/src/core/sys/linux/dlfcn.d +++ b/src/core/sys/linux/dlfcn.d @@ -265,7 +265,7 @@ static if (__USE_GNU) void* dli_saddr; } - int dladdr(void* __address, Dl_info* __info); + int dladdr(in void* __address, Dl_info* __info); int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags); enum diff --git a/src/core/sys/posix/dlfcn.d b/src/core/sys/posix/dlfcn.d index 4dc27aec16..0ce8dda1bf 100644 --- a/src/core/sys/posix/dlfcn.d +++ b/src/core/sys/posix/dlfcn.d @@ -120,7 +120,7 @@ version( CRuntime_Glibc ) deprecated("Please use core.sys.linux.dlfcn for non-POSIX extensions") { - int dladdr(void* addr, Dl_info* info); + int dladdr(in void* addr, Dl_info* info); void* dlvsym(void* handle, in char* symbol, in char* version_); struct Dl_info