Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Warn unimplemented loadLibrary on Android #206

Open
wants to merge 1 commit into
base: ldc
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/core/runtime.d
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,42 @@ else
import core.internal.execinfo;

/// C interface for Runtime.loadLibrary
extern (C) void* rt_loadLibrary(const char* name);
version(Android)
{
pragma(lib, "log"); //Necessary for the __android_log_print
private extern(C) @system nothrow @nogc int __android_log_print(int prio, const(char)* tag, const(char)* fmt, ...);

extern(C) void* rt_loadLibrary(const char* name)
{
import core.sys.posix.dlfcn : dlopen, RTLD_LAZY;
enum ANDROID_LOG_WARN = 5;
__android_log_print(5, "DRuntime", "rt_loadLibrary is unimplemented for Android, returning dlopen()");
return dlopen(name, RTLD_LAZY);
}
}
else
{
extern (C) void* rt_loadLibrary(const char* name);
}
/// ditto
version (Windows) extern (C) void* rt_loadLibraryW(const wchar* name);

/// C interface for Runtime.unloadLibrary, returns 1/0 instead of bool
extern (C) int rt_unloadLibrary(void* ptr);

version(Android)
{
extern(C) void* rt_unloadLibrary(void* ptr)
{
import core.sys.posix.dlfcn : dlclose;
enum ANDROID_LOG_WARN = 5;
__android_log_print(5, "DRuntime", "rt_unloadLibrary is unimplemented for Android, returning dlclose()");
return dlclose(ptr);
}
}
else
{
/// C interface for Runtime.unloadLibrary, returns 1/0 instead of bool
extern (C) int rt_unloadLibrary(void* ptr);
}

/// C interface for Runtime.initialize, returns 1/0 instead of bool
extern(C) int rt_init();
Expand Down