summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono/NativeModule_Unix.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/mono/eo_mono/NativeModule_Unix.cs')
-rw-r--r--src/bindings/mono/eo_mono/NativeModule_Unix.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/bindings/mono/eo_mono/NativeModule_Unix.cs b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
new file mode 100644
index 0000000..6f69395
--- /dev/null
+++ b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
@@ -0,0 +1,46 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace Efl { namespace Eo {
5
6public partial class NativeModule
7{
8 public const int RTLD_NOW = 0x002;
9 // Currently we are using GLOBAL due to issues
10 // with the way evas modules are built.
11 public const int RTLD_GLOBAL = 0x100;
12
13 [DllImport(efl.Libs.Libdl)]
14 public static extern IntPtr dlopen(string fileName, int flag);
15 [DllImport(efl.Libs.Libdl)]
16 public static extern int dlclose(IntPtr handle);
17
18 public static void UnloadLibrary(IntPtr handle)
19 {
20 dlclose(handle);
21 }
22
23 public static IntPtr LoadLibrary(string filename)
24 {
25 Eina.Log.Debug($"Loading library {filename}");
26 var r = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
27 if (r == IntPtr.Zero)
28 {
29 r = dlopen("lib" + filename, RTLD_NOW | RTLD_GLOBAL);
30 if (r == IntPtr.Zero)
31 {
32 r = dlopen(filename + ".so", RTLD_NOW | RTLD_GLOBAL);
33 if (r == IntPtr.Zero)
34 {
35 r = dlopen("lib" + filename + ".so", RTLD_NOW | RTLD_GLOBAL);
36 }
37 }
38 }
39 return r;
40 }
41}
42
43
44
45
46} }