Skip to content
Merged
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
21 changes: 19 additions & 2 deletions src/ObjCRuntime/Dlfcn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public enum RTLD {
MainOnly = -5
}

[Flags]
public enum Mode : int {
None = 0x0,
Lazy = 0x1,
Now = 0x2,
Local = 0x4,
Global = 0x8,
NoLoad = 0x10,
NoDelete = 0x80,
First = 0x100,
}

#if MONOMAC
[DllImport (Constants.libcLibrary)]
internal static extern int dladdr (IntPtr addr, out Dl_info info);
Expand All @@ -97,13 +109,18 @@ internal struct Dl_info
public static extern int dlclose (IntPtr handle);

[DllImport (Constants.libSystemLibrary, EntryPoint="dlopen")]
internal static extern IntPtr _dlopen (string? path, int mode /* this is int32, not nint */);
internal static extern IntPtr _dlopen (string? path, Mode mode /* this is int32, not nint */);

public static IntPtr dlopen (string? path, int mode)
{
return dlopen (path, mode, showWarning: true);
}

public static IntPtr dlopen (string? path, Mode mode)
{
return _dlopen (path, mode);
}

static bool warningShown;
// the linker can eliminate the body of this method (and the above static variable) on release builds
static void WarnOnce ()
Expand All @@ -115,7 +132,7 @@ static void WarnOnce ()

internal static IntPtr dlopen (string? path, int mode, bool showWarning)
{
var x = _dlopen (path, mode);
var x = _dlopen (path, (Mode) mode);
if (x != IntPtr.Zero)
return x;

Expand Down