summaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/common/os
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/jogamp/common/os')
-rwxr-xr-xsrc/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java66
-rwxr-xr-xsrc/java/jogamp/common/os/UnixDynamicLinkerImpl.java65
-rwxr-xr-xsrc/java/jogamp/common/os/WindowsDynamicLinkerImpl.java79
-rw-r--r--src/java/jogamp/common/os/android/GluegenVersionActivity.java4
4 files changed, 212 insertions, 2 deletions
diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
new file mode 100755
index 0000000..c1be2c2
--- /dev/null
+++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
@@ -0,0 +1,66 @@
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:27:00 PDT 2006 ----! */
+
+package jogamp.common.os;
+
+import com.jogamp.common.os.DynamicLinker;
+
+
+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;
+ public static final int RTLD_GLOBAL = 0x8;
+
+ /** Interface to C language function: <br> <code> int dlclose(void * __handle); </code> */
+ private static native int dlclose(long __handle);
+
+ /** Interface to C language function: <br> <code> char * dlerror(void); </code> */
+ private static native java.lang.String dlerror();
+
+ /** Interface to C language function: <br> <code> void * dlopen(const char * __path, int __mode); </code> */
+ private static native long dlopen(java.lang.String __path, int __mode);
+
+ /** Interface to C language function: <br> <code> void * dlsym(void * __handle, const char * __symbol); </code> */
+ private static native long dlsym(long __handle, java.lang.String __symbol);
+
+
+ // --- Begin CustomJavaCode .cfg declarations
+ public long openLibraryLocal(String pathname, boolean debug) {
+ // Note we use RTLD_LOCAL visibility to _NOT_ allow this functionality to
+ // be used to pre-resolve dependent libraries of JNI code without
+ // requiring that all references to symbols in those libraries be
+ // looked up dynamically via the ProcAddressTable mechanism; in
+ // other words, one can actually link against the library instead of
+ // having to dlsym all entry points. System.loadLibrary() uses
+ // RTLD_LOCAL visibility so can't be used for this purpose.
+ return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
+ }
+
+ public long openLibraryGlobal(String pathname, boolean debug) {
+ // Note we use RTLD_GLOBAL visibility to allow this functionality to
+ // be used to pre-resolve dependent libraries of JNI code without
+ // requiring that all references to symbols in those libraries be
+ // looked up dynamically via the ProcAddressTable mechanism; in
+ // other words, one can actually link against the library instead of
+ // having to dlsym all entry points. System.loadLibrary() uses
+ // RTLD_LOCAL visibility so can't be used for this purpose.
+ return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
+ }
+
+ 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);
+ }
+ // ---- End CustomJavaCode .cfg declarations
+
+} // end of class MacOSXDynamicLinkerImpl
diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
new file mode 100755
index 0000000..677df32
--- /dev/null
+++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
@@ -0,0 +1,65 @@
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */
+
+package jogamp.common.os;
+
+import com.jogamp.common.os.DynamicLinker;
+
+
+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_GLOBAL = 0x00100;
+ public static final int RTLD_LOCAL = 0x00000;
+
+ /** Interface to C language function: <br> <code> int dlclose(void * ); </code> */
+ private static native int dlclose(long arg0);
+
+ /** Interface to C language function: <br> <code> char * dlerror(void); </code> */
+ private static native java.lang.String dlerror();
+
+ /** Interface to C language function: <br> <code> void * dlopen(const char * , int); </code> */
+ private static native long dlopen(java.lang.String arg0, int arg1);
+
+ /** Interface to C language function: <br> <code> void * dlsym(void * , const char * ); </code> */
+ private static native long dlsym(long arg0, java.lang.String arg1);
+
+
+ // --- Begin CustomJavaCode .cfg declarations
+ public long openLibraryLocal(String pathname, boolean debug) {
+ // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to
+ // be used to pre-resolve dependent libraries of JNI code without
+ // requiring that all references to symbols in those libraries be
+ // looked up dynamically via the ProcAddressTable mechanism; in
+ // other words, one can actually link against the library instead of
+ // having to dlsym all entry points. System.loadLibrary() uses
+ // RTLD_LOCAL visibility so can't be used for this purpose.
+ return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
+ }
+
+ public long openLibraryGlobal(String pathname, boolean debug) {
+ // Note we use RTLD_GLOBAL visibility to allow this functionality to
+ // be used to pre-resolve dependent libraries of JNI code without
+ // requiring that all references to symbols in those libraries be
+ // looked up dynamically via the ProcAddressTable mechanism; in
+ // other words, one can actually link against the library instead of
+ // having to dlsym all entry points. System.loadLibrary() uses
+ // RTLD_LOCAL visibility so can't be used for this purpose.
+ return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
+ }
+
+ 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);
+ }
+ // ---- End CustomJavaCode .cfg declarations
+
+} // end of class UnixDynamicLinkerImpl
diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java
new file mode 100755
index 0000000..09f38df
--- /dev/null
+++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java
@@ -0,0 +1,79 @@
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */
+
+package jogamp.common.os;
+
+import java.security.*;
+
+import com.jogamp.common.os.DynamicLinker;
+
+public class WindowsDynamicLinkerImpl implements DynamicLinker {
+
+ private static boolean DEBUG;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ DEBUG = (System.getProperty("jogamp.debug.NativeLibrary") != null);
+ return null;
+ }
+ });
+ }
+
+ /** Interface to C language function: <br> <code> BOOL FreeLibrary(HANDLE hLibModule); </code> */
+ private static native int FreeLibrary(long hLibModule);
+
+ /** Interface to C language function: <br> <code> DWORD GetLastError(void); </code> */
+ private static native int GetLastError();
+
+ /** Interface to C language function: <br> <code> PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName); </code> */
+ private static native long GetProcAddressA(long hModule, java.lang.String lpProcName);
+
+ /** Interface to C language function: <br> <code> HANDLE LoadLibraryW(LPCWSTR lpLibFileName); </code> */
+ private static native long LoadLibraryW(java.lang.String lpLibFileName);
+
+
+ // --- Begin CustomJavaCode .cfg declarations
+ public long openLibraryLocal(String libraryName, boolean debug) {
+ // How does that work under Windows ?
+ // Don't know .. so it's an alias for the time being
+ return openLibraryGlobal(libraryName, debug);
+ }
+
+ public long openLibraryGlobal(String libraryName, boolean debug) {
+ long handle = LoadLibraryW(libraryName);
+ if(0==handle && debug) {
+ int err = GetLastError();
+ System.err.println("LoadLibraryW \""+libraryName+"\" failed, error code: 0x"+Integer.toHexString(err)+", "+err);
+ }
+ return handle;
+ }
+
+ public long lookupSymbol(long libraryHandle, String symbolName) {
+ String _symbolName = symbolName;
+ long addr = GetProcAddressA(libraryHandle, _symbolName);
+ if(0==addr) {
+ // __stdcall hack: try some @nn decorations,
+ // the leading '_' must not be added (same with cdecl)
+ final int argAlignment=4; // 4 byte alignment of each argument
+ final int maxArguments=12; // experience ..
+ for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
+ _symbolName = symbolName+"@"+(arg*argAlignment);
+ addr = GetProcAddressA(libraryHandle, _symbolName);
+ }
+ }
+ if(DEBUG) {
+ System.err.println("WindowsDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> "+_symbolName+", 0x"+Long.toHexString(addr));
+ }
+ return addr;
+ }
+
+ public long lookupSymbolGlobal(String symbolName) {
+ throw new RuntimeException("lookupSymbolGlobal: Not supported on Windows");
+ }
+
+ public void closeLibrary(long libraryHandle) {
+ FreeLibrary(libraryHandle);
+ }
+ // ---- End CustomJavaCode .cfg declarations
+
+} // end of class WindowsDynamicLinkerImpl
diff --git a/src/java/jogamp/common/os/android/GluegenVersionActivity.java b/src/java/jogamp/common/os/android/GluegenVersionActivity.java
index 34c6fb5..16222b6 100644
--- a/src/java/jogamp/common/os/android/GluegenVersionActivity.java
+++ b/src/java/jogamp/common/os/android/GluegenVersionActivity.java
@@ -43,7 +43,7 @@ public class GluegenVersionActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
Log.d(MD.TAG, "onCreate - S");
super.onCreate(savedInstanceState);
- PackageInfoUtil.setContext(this);
+ PackageInfoUtil.setContext(this.getApplicationContext());
tv = new TextView(this);
tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+Platform.NEWLINE);
setContentView(tv);
@@ -108,8 +108,8 @@ public class GluegenVersionActivity extends Activity {
if(null != tv) {
tv.append("> destroyed"+Platform.NEWLINE);
}
- PackageInfoUtil.setContext(null);
Log.d(MD.TAG, "onDestroy - x");
+ PackageInfoUtil.setContext(null);
super.onDestroy();
Log.d(MD.TAG, "onDestroy - X");
}