diff options
Diffstat (limited to 'src/java/com/jogamp/common/os')
5 files changed, 25 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java index ef5d5dc..d67a38f 100755 --- a/src/java/com/jogamp/common/os/DynamicLinker.java +++ b/src/java/com/jogamp/common/os/DynamicLinker.java @@ -46,5 +46,6 @@ interface DynamicLinker { public long openLibraryGlobal(String pathname, boolean debug); public long openLibraryLocal(String pathname, boolean debug); public long lookupSymbol(long libraryHandle, String symbolName); + public long lookupSymbolGlobal(String symbolName); public void closeLibrary(long libraryHandle); } diff --git a/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java index 531bc5c..0e71d5d 100755 --- a/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java +++ b/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java @@ -5,6 +5,8 @@ package com.jogamp.common.os; public class MacOSXDynamicLinkerImpl implements DynamicLinker { + public static final long RTLD_DEFAULT = -2; + public static final int RTLD_LAZY = 0x1; public static final int RTLD_NOW = 0x2; public static final int RTLD_LOCAL = 0x4; @@ -50,6 +52,10 @@ public class MacOSXDynamicLinkerImpl implements DynamicLinker { return dlsym(libraryHandle, symbolName); } + public long lookupSymbolGlobal(String symbolName) { + return dlsym(RTLD_DEFAULT, symbolName); + } + public void closeLibrary(long libraryHandle) { dlclose(libraryHandle); } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 2de8bc9..897e240 100755 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -122,6 +122,10 @@ public class NativeLibrary implements DynamicLookupHelper { this.libraryPath = libraryPath; } + public String toString() { + return "NativeLibrary[" + libraryPath + ", 0x" + Long.toHexString(libraryHandle) + "]"; + } + /** Opens the given native library, assuming it has the same base name on all platforms, looking first in the system's search path, and in the context of the specified ClassLoader, which is @@ -209,6 +213,11 @@ public class NativeLibrary implements DynamicLookupHelper { return dynLink.lookupSymbol(libraryHandle, funcName); } + /** Looks up the given function name in all loaded libraries. */ + public static long dynamicLookupFunctionGlobal(String funcName) { + return dynLink.lookupSymbolGlobal(funcName); + } + /** Retrieves the low-level library handle from this NativeLibrary object. On the Windows platform this is an HMODULE, and on Unix and Mac OS X platforms the void* result of calling dlopen(). */ diff --git a/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java index 02bc828..d2970d6 100755 --- a/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -5,6 +5,7 @@ package com.jogamp.common.os; public class UnixDynamicLinkerImpl implements DynamicLinker { + public static final long RTLD_DEFAULT = 0; public static final int RTLD_LAZY = 0x00001; public static final int RTLD_NOW = 0x00002; public static final int RTLD_NOLOAD = 0x00004; @@ -55,6 +56,10 @@ public class UnixDynamicLinkerImpl implements DynamicLinker { public long lookupSymbol(long libraryHandle, String symbolName) { return dlsym(libraryHandle, symbolName); } + + public long lookupSymbolGlobal(String symbolName) { + return dlsym(RTLD_DEFAULT, symbolName); + } public void closeLibrary(long libraryHandle) { dlclose(libraryHandle); diff --git a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java index 2858f74..935f386 100755 --- a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ b/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -65,6 +65,10 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { return addr; } + public long lookupSymbolGlobal(String symbolName) { + throw new RuntimeException("lookupSymbolGlobal: Not supported on Windows"); + } + public void closeLibrary(long libraryHandle) { FreeLibrary(libraryHandle); } |