2 using System.Runtime.InteropServices;
10 public partial class NativeModule
12 private const int RTLD_NOW = 0x002;
13 // Currently we are using GLOBAL due to issues
14 // with the way evas modules are built.
15 private const int RTLD_GLOBAL = 0x100;
17 [DllImport(efl.Libs.Libdl)]
18 private static extern IntPtr dlopen(string fileName, int flag);
19 [DllImport(efl.Libs.Libdl)]
20 private static extern int dlclose(IntPtr handle);
22 ///<summary>Closes the library handle.</summary>
23 ///<param name="handle">The handle to the library.</param>
24 public static void UnloadLibrary(IntPtr handle)
29 ///<summary>Loads the given library.
31 ///It attempts to load using the following list of names based on the <c>filename</c>
34 ///<list type="bullet">
36 ///<description><c>filename</c></description>
39 ///<description><c>libfilename</c></description>
42 ///<description><c>filename.so</c></description>
45 ///<description><c>libfilename.so</c></description>
49 ///<param name="filename">The name to search for.</param>
50 ///<returns>The loaded library handle or <see cref="System.IntPtr.Zero"/> on failure.</returns>
51 public static IntPtr LoadLibrary(string filename)
53 Eina.Log.Debug($"Loading library {filename}");
54 var r = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
57 r = dlopen("lib" + filename, RTLD_NOW | RTLD_GLOBAL);
60 r = dlopen(filename + ".so", RTLD_NOW | RTLD_GLOBAL);
63 r = dlopen("lib" + filename + ".so", RTLD_NOW | RTLD_GLOBAL);