diff options
author | Sven Gothel <[email protected]> | 2013-06-25 09:04:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-25 09:04:16 +0200 |
commit | 72f60a534db7c0b731d4dca83481679817ad7574 (patch) | |
tree | 1935d80740007bd251088d31bc6521004d24d003 /src/java/jogamp/common/os/UnixDynamicLinkerImpl.java | |
parent | 5e01e993aeba4e95fc8aa6e75b3e295011e27bbb (diff) |
UnixDynamicLinkerImpl: Unify impl. of openLibraryLocal(..), openLibraryGlobal(..) and lookupSymbolGlobal(..) - removing duplicate code.
Diffstat (limited to 'src/java/jogamp/common/os/UnixDynamicLinkerImpl.java')
-rw-r--r-- | src/java/jogamp/common/os/UnixDynamicLinkerImpl.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java index 25f4072..7f10d8a 100644 --- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -27,6 +27,8 @@ */ package jogamp.common.os; +import com.jogamp.common.util.SecurityUtil; + /* pp */ abstract class UnixDynamicLinkerImpl extends DynamicLinkerImpl { // @@ -47,6 +49,26 @@ package jogamp.common.os; /** Interface to C language function: <br> <code> void * dlsym(void * , const char * ); </code> */ protected static native long dlsym(long arg0, java.lang.String arg1); + protected final long openLibraryImpl(String pathname, int dlSymFlags, boolean debug) throws SecurityException { + SecurityUtil.checkLinkPermission(pathname); + final long handle = dlopen(pathname, dlSymFlags); + if( 0 != handle ) { + incrLibRefCount(handle, pathname); + } else if ( DEBUG || debug ) { + System.err.println("dlopen \""+pathname+"\" failed, error: "+dlerror()); + } + return handle; + } + + protected final long lookupSymbolGlobalImpl(long dlSymGlobalFlag, String symbolName) throws SecurityException { + SecurityUtil.checkAllLinkPermission(); + final long addr = dlsym(dlSymGlobalFlag, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; + } + @Override public final long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException { if( null == getLibRef( libraryHandle ) ) { |