summaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/jogamp/common')
-rw-r--r--src/java/jogamp/common/Debug.java16
-rw-r--r--src/java/jogamp/common/jvm/JVMUtil.java14
-rw-r--r--src/java/jogamp/common/os/AndroidUtils.java28
-rw-r--r--src/java/jogamp/common/os/BionicDynamicLinkerImpl.java8
-rw-r--r--src/java/jogamp/common/os/DynamicLinkerImpl.java14
-rw-r--r--src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java6
-rw-r--r--src/java/jogamp/common/os/MachineDescriptionRuntime.java46
-rw-r--r--src/java/jogamp/common/os/PlatformPropsImpl.java104
-rw-r--r--src/java/jogamp/common/os/PosixDynamicLinkerImpl.java4
-rw-r--r--src/java/jogamp/common/os/UnixDynamicLinkerImpl.java12
-rw-r--r--src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java8
-rw-r--r--src/java/jogamp/common/os/elf/ElfHeader.java148
-rw-r--r--src/java/jogamp/common/os/elf/IOUtils.java54
-rw-r--r--src/java/jogamp/common/os/elf/Section.java6
-rw-r--r--src/java/jogamp/common/os/elf/SectionArmAttributes.java100
-rw-r--r--src/java/jogamp/common/os/elf/SectionHeader.java32
-rw-r--r--src/java/jogamp/common/util/locks/LockDebugUtil.java4
-rw-r--r--src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java54
-rw-r--r--src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java54
-rw-r--r--src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java6
-rw-r--r--src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java66
-rw-r--r--src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java14
-rw-r--r--src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java76
23 files changed, 437 insertions, 437 deletions
diff --git a/src/java/jogamp/common/Debug.java b/src/java/jogamp/common/Debug.java
index b826a06..460106b 100644
--- a/src/java/jogamp/common/Debug.java
+++ b/src/java/jogamp/common/Debug.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,11 +29,11 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
@@ -51,7 +51,7 @@ public class Debug extends PropertyAccess {
// Some common properties
private static final boolean verbose;
private static final boolean debugAll;
-
+
static {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
diff --git a/src/java/jogamp/common/jvm/JVMUtil.java b/src/java/jogamp/common/jvm/JVMUtil.java
index af74f08..e655654 100644
--- a/src/java/jogamp/common/jvm/JVMUtil.java
+++ b/src/java/jogamp/common/jvm/JVMUtil.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -64,9 +64,9 @@ public class JVMUtil {
}
}
- /** Kicks of one-time static initialization of this class. See {@link JVMUtil}. */
+ /** Kicks of one-time static initialization of this class. See {@link JVMUtil}. */
public static void initSingleton() { }
-
+
private JVMUtil() {}
private static native boolean initialize(java.nio.ByteBuffer buffer);
diff --git a/src/java/jogamp/common/os/AndroidUtils.java b/src/java/jogamp/common/os/AndroidUtils.java
index c6d5819..bb09ba9 100644
--- a/src/java/jogamp/common/os/AndroidUtils.java
+++ b/src/java/jogamp/common/os/AndroidUtils.java
@@ -38,7 +38,7 @@ public class AndroidUtils {
private static final Method androidGetPackageInfoVersionNameMethod;
private static final Method androidGetPackageInfoVersionCodeMethod;
private static final Method androidGetTempRootMethod;
-
+
static {
if(AndroidVersion.isAvailable) {
final ClassLoader cl = AndroidUtils.class.getClassLoader();
@@ -52,10 +52,10 @@ public class AndroidUtils {
androidGetTempRootMethod = null;
}
}
-
+
/**
- * @return null if platform is not Android or no Android Context is registered
- * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
+ * @return null if platform is not Android or no Android Context is registered
+ * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
* otherwise the found package version code of <code>packageName</code> is returned.
*/
public static final int getPackageInfoVersionCode(String packageName) {
@@ -64,10 +64,10 @@ public class AndroidUtils {
}
return -1;
}
-
+
/**
- * @return null if platform is not Android or no Android Context is registered
- * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
+ * @return null if platform is not Android or no Android Context is registered
+ * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
* otherwise the found package version name of <code>packageName</code> is returned.
*/
public static final String getPackageInfoVersionName(String packageName) {
@@ -76,18 +76,18 @@ public class AndroidUtils {
}
return null;
}
-
+
/**
- * @return null if platform is not Android or no Android Context is registered
- * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
- * otherwise the context relative world readable <code>temp</code> directory returned.
+ * @return null if platform is not Android or no Android Context is registered
+ * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)},
+ * otherwise the context relative world readable <code>temp</code> directory returned.
*/
public static File getTempRoot()
throws RuntimeException {
if(null != androidGetTempRootMethod) {
return (File) ReflectionUtil.callMethod(null, androidGetTempRootMethod);
}
- return null;
- }
-
+ return null;
+ }
+
}
diff --git a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
index 453f200..09057f8 100644
--- a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
@@ -37,7 +37,7 @@ package jogamp.common.os;
public final class BionicDynamicLinkerImpl extends UnixDynamicLinkerImpl {
private static final long RTLD_DEFAULT = 0xffffffffL;
// static final long RTLD_NEXT = 0xfffffffeL;
-
+
private static final int RTLD_LAZY = 0x00001;
// static final int RTLD_NOW = 0x00000;
private static final int RTLD_LOCAL = 0x00000;
@@ -52,10 +52,10 @@ public final class BionicDynamicLinkerImpl extends UnixDynamicLinkerImpl {
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
-
+
@Override
- public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
+ public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
}
-
+
}
diff --git a/src/java/jogamp/common/os/DynamicLinkerImpl.java b/src/java/jogamp/common/os/DynamicLinkerImpl.java
index 4686cd2..39c112e 100644
--- a/src/java/jogamp/common/os/DynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/DynamicLinkerImpl.java
@@ -37,9 +37,9 @@ import com.jogamp.common.util.LongObjectHashMap;
// and sealed jogamp.common.* package definition
// ensuring no abuse via subclassing.
//
-
+
private final LongObjectHashMap libHandle2Name = new LongObjectHashMap( 16 /* initialCapacity */ );
-
+
protected static final class LibRef {
public LibRef(String name) {
this.name = name;
@@ -48,18 +48,18 @@ import com.jogamp.common.util.LongObjectHashMap;
public final int incrRefCount() { return ++refCount; }
public final int decrRefCount() { return --refCount; }
public final int getRefCount() { return refCount; }
-
+
public final String getName() { return name; }
public final String toString() { return "LibRef["+name+", refCount "+refCount+"]"; }
-
+
private final String name;
private int refCount;
}
-
+
protected final synchronized LibRef getLibRef(long handle) {
return (LibRef) libHandle2Name.get(handle);
}
-
+
protected final synchronized LibRef incrLibRefCount(long handle, String libName) {
LibRef libRef = getLibRef(handle);
if( null == libRef ) {
@@ -73,7 +73,7 @@ import com.jogamp.common.util.LongObjectHashMap;
}
return libRef;
}
-
+
protected final synchronized LibRef decrLibRefCount(long handle) {
LibRef libRef = getLibRef(handle);
if( null != libRef ) {
diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
index 18dcf97..b2f0f31 100644
--- a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
@@ -45,15 +45,15 @@ public final class MacOSXDynamicLinkerImpl extends UnixDynamicLinkerImpl {
public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException {
return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug);
}
-
+
@Override
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
-
+
@Override
public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
}
-
+
}
diff --git a/src/java/jogamp/common/os/MachineDescriptionRuntime.java b/src/java/jogamp/common/os/MachineDescriptionRuntime.java
index a58accd..01559b9 100644
--- a/src/java/jogamp/common/os/MachineDescriptionRuntime.java
+++ b/src/java/jogamp/common/os/MachineDescriptionRuntime.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package jogamp.common.os;
import com.jogamp.common.os.MachineDescription;
@@ -39,7 +39,7 @@ public class MachineDescriptionRuntime {
static volatile boolean smdQueried = false;
static MachineDescription.StaticConfig smd = null;
-
+
public static MachineDescription.StaticConfig getStatic() {
if(!smdQueried) {
synchronized(MachineDescription.class) { // volatile dbl-checked-locking OK
@@ -50,8 +50,8 @@ public class MachineDescriptionRuntime {
}
}
return smd;
- }
-
+ }
+
private static boolean isCPUArch32Bit() throws RuntimeException {
switch( PlatformPropsImpl.CPU_ARCH ) {
case X86_32:
@@ -71,7 +71,7 @@ public class MachineDescriptionRuntime {
throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + PlatformPropsImpl.OS_lower + "/" + PlatformPropsImpl.ARCH_lower + "("+PlatformPropsImpl.CPU_ARCH+"))");
}
}
-
+
private static MachineDescription.StaticConfig getStaticImpl() {
if(isCPUArch32Bit()) {
if(PlatformPropsImpl.CPU_ARCH.getFamily() == Platform.CPUFamily.ARM && PlatformPropsImpl.LITTLE_ENDIAN) {
@@ -94,7 +94,7 @@ public class MachineDescriptionRuntime {
return StaticConfig.X86_64_UNIX;
}
}
-
+
static volatile boolean rmdQueried = false;
static MachineDescription rmd = null;
@@ -108,14 +108,14 @@ public class MachineDescriptionRuntime {
}
}
return rmd;
- }
+ }
private static MachineDescription getRuntimeImpl() {
try {
Platform.initSingleton(); // loads native gluegen-rt library
} catch (UnsatisfiedLinkError err) {
return null;
}
-
+
int pointerSizeInBytes = getPointerSizeInBytesImpl();
switch(pointerSizeInBytes) {
case 4:
@@ -129,25 +129,25 @@ public class MachineDescriptionRuntime {
if(Integer.MAX_VALUE < pageSizeL) {
throw new InternalError("PageSize exceeds integer value: " + pageSizeL);
}
-
+
// size: int, long, float, double, pointer, pageSize
// alignment: int8, int16, int32, int64, int, long, float, double, pointer
- return new MachineDescription(
+ return new MachineDescription(
true /* runtime validated */, PlatformPropsImpl.LITTLE_ENDIAN,
-
+
getSizeOfIntImpl(), getSizeOfLongImpl(),
- getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(),
+ getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(),
pointerSizeInBytes, (int)pageSizeL,
-
+
getAlignmentInt8Impl(), getAlignmentInt16Impl(), getAlignmentInt32Impl(), getAlignmentInt64Impl(),
- getAlignmentIntImpl(), getAlignmentLongImpl(),
- getAlignmentFloatImpl(), getAlignmentDoubleImpl(), getAlignmentLongDoubleImpl(),
- getAlignmentPointerImpl());
+ getAlignmentIntImpl(), getAlignmentLongImpl(),
+ getAlignmentFloatImpl(), getAlignmentDoubleImpl(), getAlignmentLongDoubleImpl(),
+ getAlignmentPointerImpl());
}
private static native int getPointerSizeInBytesImpl();
private static native long getPageSizeInBytesImpl();
-
+
private static native int getAlignmentInt8Impl();
private static native int getAlignmentInt16Impl();
private static native int getAlignmentInt32Impl();
@@ -162,7 +162,7 @@ public class MachineDescriptionRuntime {
private static native int getSizeOfLongImpl();
private static native int getSizeOfPointerImpl();
private static native int getSizeOfFloatImpl();
- private static native int getSizeOfDoubleImpl();
- private static native int getSizeOfLongDoubleImpl();
+ private static native int getSizeOfDoubleImpl();
+ private static native int getSizeOfLongDoubleImpl();
}
diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java
index 819fe9c..e632647 100644
--- a/src/java/jogamp/common/os/PlatformPropsImpl.java
+++ b/src/java/jogamp/common/os/PlatformPropsImpl.java
@@ -37,16 +37,16 @@ import com.jogamp.common.util.VersionNumber;
*/
public abstract class PlatformPropsImpl {
static final boolean DEBUG = Debug.debug("Platform");
-
+
//
// static initialization order:
//
-
+
/** Version 1.6. As a JVM version, it enables certain JVM 1. features. */
public static final VersionNumber Version16;
/** Version 1.7. As a JVM version, it enables certain JVM 1.7 features. */
public static final VersionNumber Version17;
-
+
public static final String OS;
public static final String OS_lower;
public static final String OS_VERSION;
@@ -62,17 +62,17 @@ public abstract class PlatformPropsImpl {
public static final String JAVA_RUNTIME_NAME;
/** True if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available. */
public static final boolean JAVA_SE;
- /** True if being compatible w/ language level 6, e.g. JRE 1.6. Implies {@link #JAVA_SE}. <i>Note</i>: We claim Android is compatible. */
+ /** True if being compatible w/ language level 6, e.g. JRE 1.6. Implies {@link #JAVA_SE}. <i>Note</i>: We claim Android is compatible. */
public static final boolean JAVA_6;
-
+
public static final String NEWLINE;
public static final boolean LITTLE_ENDIAN;
-
+
public static final CPUType CPU_ARCH;
public static final ABIType ABI_TYPE;
public static final OSType OS_TYPE;
public static final String os_and_arch;
-
+
static {
Version16 = new VersionNumber(1, 6, 0);
Version17 = new VersionNumber(1, 7, 0);
@@ -103,10 +103,10 @@ public abstract class PlatformPropsImpl {
JAVA_RUNTIME_NAME = getJavaRuntimeNameImpl();
JAVA_SE = initIsJavaSE();
JAVA_6 = JAVA_SE && ( AndroidVersion.isAvailable || JAVA_VERSION_NUMBER.compareTo(Version16) >= 0 ) ;
-
+
NEWLINE = System.getProperty("line.separator");
LITTLE_ENDIAN = queryIsLittleEndianImpl();
-
+
CPU_ARCH = getCPUTypeImpl(ARCH_lower);
OS_TYPE = getOSTypeImpl();
ABI_TYPE = queryABITypeImpl(OS_TYPE, CPU_ARCH);
@@ -114,7 +114,7 @@ public abstract class PlatformPropsImpl {
}
protected PlatformPropsImpl() {}
-
+
private static final String getJavaRuntimeNameImpl() {
// the fast path, check property Java SE instead of traversing through the ClassLoader
return AccessController.doPrivileged(new PrivilegedAction<String>() {
@@ -123,7 +123,7 @@ public abstract class PlatformPropsImpl {
}
});
}
-
+
private static final boolean initIsJavaSE() {
if( null != JAVA_RUNTIME_NAME && JAVA_RUNTIME_NAME.indexOf("Java SE") != -1) {
return true;
@@ -148,7 +148,7 @@ public abstract class PlatformPropsImpl {
tst_i.put(0, 0x0A0B0C0D);
return 0x0C0D == tst_s.get(0);
}
-
+
private static final CPUType getCPUTypeImpl(String archLower) {
if( archLower.equals("x86") ||
archLower.equals("i386") ||
@@ -181,10 +181,10 @@ public abstract class PlatformPropsImpl {
throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + archLower + ")");
}
}
-
+
@SuppressWarnings("unused")
private static final boolean contains(String data, String[] search) {
- if(null != data && null != search) {
+ if(null != data && null != search) {
for(int i=0; i<search.length; i++) {
if(data.indexOf(search[i]) >= 0) {
return true;
@@ -193,7 +193,7 @@ public abstract class PlatformPropsImpl {
}
return false;
}
-
+
/**
* Returns the {@link ABIType} of the current platform using given {@link CPUType cpuType}
* and {@link OSType osType} as a hint.
@@ -201,33 +201,33 @@ public abstract class PlatformPropsImpl {
* Note the following queries are performed:
* <ul>
* <li> not {@link CPUFamily#ARM} -> {@link ABIType#GENERIC_ABI} </li>
- * <li> else
- * <ul>
+ * <li> else
+ * <ul>
* <li> {@link OSType#ANDROID} -> {@link ABIType#EABI_GNU_ARMEL} (due to EACCES, Permission denied)</li>
- * <li> else
- * <ul>
+ * <li> else
+ * <ul>
* <li> Elf ARM Tags -> {@link ABIType#EABI_GNU_ARMEL}, {@link ABIType#EABI_GNU_ARMHF}</li>
* <li> On Error -> {@link ABIType#EABI_GNU_ARMEL}</li>
* </ul></li>
- * </ul></li>
+ * </ul></li>
* </ul>
* </p>
* <p>
- * For Elf parsing either the current executable is used (Linux) or a found java/jvm native library.
+ * For Elf parsing either the current executable is used (Linux) or a found java/jvm native library.
* </p>
* <p>
* Elf ARM Tags are read using {@link ElfHeader}, .. and {@link SectionArmAttributes#abiVFPArgsAcceptsVFPVariant(byte)}.
* </p>
* @param osType
* @param cpuType
- *
+ *
* @return
*/
private static final ABIType queryABITypeImpl(final OSType osType, final CPUType cpuType) {
if( CPUFamily.ARM != cpuType.family ) {
return ABIType.GENERIC_ABI;
}
- if( OSType.ANDROID == osType ) { // EACCES (Permission denied) - We assume a not rooted device!
+ if( OSType.ANDROID == osType ) { // EACCES (Permission denied) - We assume a not rooted device!
return ABIType.EABI_GNU_ARMEL;
}
return AccessController.doPrivileged(new PrivilegedAction<ABIType>() {
@@ -250,7 +250,7 @@ public abstract class PlatformPropsImpl {
if( null == file ) {
file = findSysLib("jvm");
}
- if( null != file ) {
+ if( null != file ) {
in = new RandomAccessFile(file, "r");
final ElfHeader eh = ElfHeader.read(in);
if(DEBUG) {
@@ -290,7 +290,7 @@ public abstract class PlatformPropsImpl {
res = abiVFPArgsAcceptsVFPVariant ? ABIType.EABI_GNU_ARMHF : ABIType.EABI_GNU_ARMEL;
} else {
res = ABIType.GENERIC_ABI;
- }
+ }
if(DEBUG) {
System.err.println("ELF: abiARM "+abiARM+", abiVFPArgsAcceptsVFPVariant "+abiVFPArgsAcceptsVFPVariant+" -> "+res);
}
@@ -302,7 +302,7 @@ public abstract class PlatformPropsImpl {
return file.isFile() && file.canRead();
} catch (Throwable t) { }
return false;
- }
+ }
private static File findSysLib(String libName) {
ClassLoader cl = PlatformPropsImpl.class.getClassLoader();
final List<String> possibleLibPaths = NativeLibrary.enumerateLibraryPaths(libName, libName, libName, true, cl);
@@ -321,29 +321,29 @@ public abstract class PlatformPropsImpl {
}
return null;
}
-
+
private static final OSType getOSTypeImpl() throws RuntimeException {
if ( AndroidVersion.isAvailable ) {
return OSType.ANDROID;
}
if ( OS_lower.startsWith("linux") ) {
- return OSType.LINUX;
+ return OSType.LINUX;
}
if ( OS_lower.startsWith("freebsd") ) {
- return OSType.FREEBSD;
+ return OSType.FREEBSD;
}
if ( OS_lower.startsWith("android") ) {
- return OSType.ANDROID;
+ return OSType.ANDROID;
}
if ( OS_lower.startsWith("mac os x") ||
OS_lower.startsWith("darwin") ) {
- return OSType.MACOS;
+ return OSType.MACOS;
}
if ( OS_lower.startsWith("sunos") ) {
- return OSType.SUNOS;
+ return OSType.SUNOS;
}
if ( OS_lower.startsWith("hp-ux") ) {
- return OSType.HPUX;
+ return OSType.HPUX;
}
if ( OS_lower.startsWith("windows") ) {
return OSType.WINDOWS;
@@ -351,18 +351,18 @@ public abstract class PlatformPropsImpl {
if ( OS_lower.startsWith("kd") ) {
return OSType.OPENKODE;
}
- throw new RuntimeException("Please port OS detection to your platform (" + OS_lower + "/" + ARCH_lower + ")");
+ throw new RuntimeException("Please port OS detection to your platform (" + OS_lower + "/" + ARCH_lower + ")");
}
/**
* kick off static initialization of <i>platform property information</i>
*/
- public static void initSingleton() { }
-
+ public static void initSingleton() { }
+
/**
* Returns the GlueGen common name for the given OSType and CPUType
* as implemented in the build system in 'gluegen-cpptasks-base.xml'.<br>
- *
+ *
* A list of currently supported <code>os.and.arch</code> strings:
* <ul>
* <li>freebsd-i586</li>
@@ -386,7 +386,7 @@ public abstract class PlatformPropsImpl {
*/
public static final String getOSAndArch(OSType osType, CPUType cpuType, ABIType abiType) {
String _os_and_arch;
-
+
switch( cpuType ) {
case X86_32:
_os_and_arch = "i586";
@@ -398,7 +398,7 @@ public abstract class PlatformPropsImpl {
_os_and_arch = "armv6"; // TODO: sync with gluegen-cpptasks-base.xml
break;
case SPARC_32:
- _os_and_arch = "sparc";
+ _os_and_arch = "sparc";
break;
case PPC:
_os_and_arch = "ppc"; // TODO: sync with gluegen-cpptasks-base.xml
@@ -410,10 +410,10 @@ public abstract class PlatformPropsImpl {
_os_and_arch = "ia64";
break;
case SPARCV9_64:
- _os_and_arch = "sparcv9";
+ _os_and_arch = "sparcv9";
break;
case PA_RISC2_0:
- _os_and_arch = "risc2.0"; // TODO: sync with gluegen-cpptasks-base.xml
+ _os_and_arch = "risc2.0"; // TODO: sync with gluegen-cpptasks-base.xml
break;
default:
throw new InternalError("Complete case block");
@@ -423,33 +423,33 @@ public abstract class PlatformPropsImpl {
}
switch( osType ) {
case ANDROID:
- _os_and_arch = "android-" + _os_and_arch;
+ _os_and_arch = "android-" + _os_and_arch;
break;
case MACOS:
- _os_and_arch = "macosx-universal";
+ _os_and_arch = "macosx-universal";
break;
case WINDOWS:
- _os_and_arch = "windows-" + _os_and_arch;
+ _os_and_arch = "windows-" + _os_and_arch;
break;
case OPENKODE:
- _os_and_arch = "openkode-" + _os_and_arch; // TODO: think about that
- break;
+ _os_and_arch = "openkode-" + _os_and_arch; // TODO: think about that
+ break;
case LINUX:
- _os_and_arch = "linux-" + _os_and_arch;
+ _os_and_arch = "linux-" + _os_and_arch;
break;
case FREEBSD:
- _os_and_arch = "freebsd-" + _os_and_arch;
+ _os_and_arch = "freebsd-" + _os_and_arch;
break;
case SUNOS:
- _os_and_arch = "solaris-" + _os_and_arch;
+ _os_and_arch = "solaris-" + _os_and_arch;
break;
case HPUX:
_os_and_arch = "hpux-hppa"; // TODO: really only hppa ?
- break;
+ break;
default:
throw new InternalError("Complete case block");
}
- return _os_and_arch;
+ return _os_and_arch;
}
-
+
}
diff --git a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
index fced97f..f0f366c 100644
--- a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
@@ -31,7 +31,7 @@ public final class PosixDynamicLinkerImpl extends UnixDynamicLinkerImpl {
private static final long RTLD_DEFAULT = 0;
// static final long RTLD_NEXT = -1L;
-
+
private static final int RTLD_LAZY = 0x00001;
// static final int RTLD_NOW = 0x00002;
private static final int RTLD_LOCAL = 0x00000;
@@ -46,7 +46,7 @@ public final class PosixDynamicLinkerImpl extends UnixDynamicLinkerImpl {
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
-
+
@Override
public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
index 7f10d8a..7a0e3b0 100644
--- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
@@ -36,7 +36,7 @@ import com.jogamp.common.util.SecurityUtil;
// and sealed jogamp.common.* package definition
// ensuring no abuse via subclassing.
//
-
+
/** Interface to C language function: <br> <code> int dlclose(void * ); </code> */
protected static native int dlclose(long arg0);
@@ -59,16 +59,16 @@ import com.jogamp.common.util.SecurityUtil;
}
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;
+ return addr;
}
-
+
@Override
public final long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException {
if( null == getLibRef( libraryHandle ) ) {
@@ -78,7 +78,7 @@ import com.jogamp.common.util.SecurityUtil;
if(DEBUG_LOOKUP) {
System.err.println("DynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> 0x"+Long.toHexString(addr));
}
- return addr;
+ return addr;
}
@Override
@@ -88,7 +88,7 @@ import com.jogamp.common.util.SecurityUtil;
}
dlclose(libraryHandle);
}
-
+
@Override
public final String getLastError() {
return dlerror();
diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java
index adb2492..76bb2f8 100644
--- a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java
@@ -49,7 +49,7 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl {
// Don't know .. so it's an alias for the time being
return openLibraryGlobal(libraryName, debug);
}
-
+
@Override
public final long openLibraryGlobal(String libraryName, boolean debug) throws SecurityException {
SecurityUtil.checkLinkPermission(libraryName);
@@ -62,7 +62,7 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl {
}
return handle;
}
-
+
@Override
public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
SecurityUtil.checkAllLinkPermission();
@@ -95,7 +95,7 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl {
}
return addr;
}
-
+
@Override
public final void closeLibrary(long libraryHandle) throws IllegalArgumentException {
if( null == decrLibRefCount( libraryHandle ) ) {
@@ -109,5 +109,5 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl {
final int err = GetLastError();
return "Last error: 0x"+Integer.toHexString(err)+" ("+err+")";
}
-
+
}
diff --git a/src/java/jogamp/common/os/elf/ElfHeader.java b/src/java/jogamp/common/os/elf/ElfHeader.java
index 88562cf..d76dbab 100644
--- a/src/java/jogamp/common/os/elf/ElfHeader.java
+++ b/src/java/jogamp/common/os/elf/ElfHeader.java
@@ -53,7 +53,7 @@ import static jogamp.common.os.elf.IOUtils.toHexString;
public class ElfHeader {
/** Size of e_ident array - {@value} */
public static int EI_NIDENT = 16;
-
+
/** ident byte #0 - {@value} */
public static final byte ELFMAG0 = 0x7f;
/** ident byte #1 - {@value} */
@@ -62,13 +62,13 @@ public class ElfHeader {
public static final byte ELFMAG2 = 'L';
/** ident byte #3 - {@value} */
public static final byte ELFMAG3 = 'F';
-
+
/** ident byte #4 */
public static final int EI_CLASS = 4;
public static final byte ELFCLASSNONE = 0;
public static final byte ELFCLASS32 = 1;
public static final byte ELFCLASS64 = 2;
-
+
/** ident byte #5 */
public static final int EI_DATA = 5;
public static final byte ELFDATANONE = 0;
@@ -79,7 +79,7 @@ public class ElfHeader {
public static final int EI_VERSION = 6;
public static final byte EV_NONE = 0;
public static final byte EV_CURRENT = 1;
-
+
/** ident byte #7 */
public static final int EI_OSABI = 7;
/** Unix System V ABI - {@value} */
@@ -114,29 +114,29 @@ public class ElfHeader {
/** Amiga Research OS ABI - {@value} **/
public static final byte ELFOSABI_AROS = 15;
/** The FenixOS highly scalable multi-core OS 64-255 Architecture-specific value range - {@value} */
- public static final byte ELFOSABI_FENIXOS = 16;
-
+ public static final byte ELFOSABI_FENIXOS = 16;
+
/** ident byte #8
* <p>
- * This byte identifies the version of the ABI to which the object is targeted.
- * This field is used to distinguish among incompatible versions of an ABI.
- * The interpretation of this version number is dependent on the ABI identified by the EI_OSABI field.
+ * This byte identifies the version of the ABI to which the object is targeted.
+ * This field is used to distinguish among incompatible versions of an ABI.
+ * The interpretation of this version number is dependent on the ABI identified by the EI_OSABI field.
* Applications conforming to this specification use the value 0.
- * </p>
+ * </p>
*/
public static final int EI_ABIVERSION = 8;
-
+
/**
* ident byte #9 .. ?
* <p>
- * Start of padding.
- * These bytes are reserved and set to zero.
- * Programs which read them should ignore them.
+ * Start of padding.
+ * These bytes are reserved and set to zero.
+ * Programs which read them should ignore them.
* The value for EI_PAD will change in the future if currently unused bytes are given meanings.
* </p>
*/
public static final int EI_PAD = 9;
-
+
/**
* This masks an 8-bit version number, the version of the ABI to which this
* ELF file conforms. This ABI is version 5. A value of 0 denotes unknown conformance.
@@ -144,27 +144,27 @@ public class ElfHeader {
*/
public static final int EF_ARM_ABIMASK = 0xFF000000;
public static final int EF_ARM_ABISHIFT = 24;
-
+
/**
* ARM ABI version 5.
* {@value}
*/
public static final int EF_ARM_ABI5 = 0x05000000;
-
+
/**
* The ELF file contains BE-8 code, suitable for execution on an ARM
* Architecture v6 processor. This flag must only be set on an executable file.
* {@value}
*/
public static final int EF_ARM_BE8 = 0x00800000;
-
+
/**
* Legacy code (ABI version 4 and earlier) generated by gcc-arm-xxx might
* use these bits.
* {@value}
*/
public static final int EF_ARM_GCCMASK = 0x00400FFF;
-
+
/**
* Set in executable file headers (e_type = ET_EXEC or ET_DYN) to note that
* the executable file was built to conform to the hardware floating-point
@@ -173,28 +173,28 @@ public class ElfHeader {
* Compatible with legacy (pre version 5) gcc use as EF_ARM_VFP_FLOAT.
* </p>
* <p>
- * Note: This is not used (anymore)
- * </p>
+ * Note: This is not used (anymore)
+ * </p>
* {@value}
*/
public static final int EF_ARM_ABI_FLOAT_HARD = 0x00000400;
-
+
/**
* Set in executable file headers (e_type = ET_EXEC or ET_DYN) to note
* explicitly that the executable file was built to conform to the software
* floating-point procedure-call standard (the base standard). If both
- * {@link #EF_ARM_ABI_FLOAT_HARD} and {@link #EF_ARM_ABI_FLOAT_SOFT} are clear,
+ * {@link #EF_ARM_ABI_FLOAT_HARD} and {@link #EF_ARM_ABI_FLOAT_SOFT} are clear,
* conformance to the base procedure-call standard is implied.
* <p>
* Compatible with legacy (pre version 5) gcc use as EF_ARM_SOFT_FLOAT.
* </p>
* <p>
- * Note: This is not used (anymore)
- * </p>
+ * Note: This is not used (anymore)
+ * </p>
* {@value}
*/
public static final int EF_ARM_ABI_FLOAT_SOFT = 0x00000200;
-
+
/** An unknown type - {@value} */
public static final short ET_NONE = 0;
/** A relocatable file - {@value} */
@@ -205,7 +205,7 @@ public class ElfHeader {
public static final short ET_DYN = 3;
/** A core file - {@value} */
public static final short ET_CORE = 4;
-
+
public static final short EM_NONE = 0;
public static final short EM_M32 = 1;
public static final short EM_SPARC = 2;
@@ -357,34 +357,34 @@ public class ElfHeader {
public static final short EM_TILEPRO = 188;
public static final short EM_MICROBLAZE = 189;
public static final short EM_CUDA = 190;
-
+
public static final boolean isIdentityValid(byte[] ident) {
return ELFMAG0 == ident[0] &&
ELFMAG1 == ident[1] &&
ELFMAG2 == ident[2] &&
ELFMAG3 == ident[3] ;
}
-
+
/** Public access to the raw elf header */
public final Ehdr d;
-
+
/** Public access to the {@link SectionHeader} */
- public final SectionHeader[] sht;
-
+ public final SectionHeader[] sht;
+
private final String string;
-
+
/**
* Note: The input stream shall stay untouch to be able to read sections!
- *
+ *
* @param in input stream of a binary file at position zero
* @return
- * @throws IOException if reading from the given input stream fails or less then ELF Header size bytes
+ * @throws IOException if reading from the given input stream fails or less then ELF Header size bytes
* @throws IllegalArgumentException if the given input stream does not represent an ELF Header
*/
public static ElfHeader read(RandomAccessFile in) throws IOException, IllegalArgumentException {
final int eh_sz = Ehdr.size();
final byte[] buf = new byte[eh_sz];
- readBytes (in, buf, 0, eh_sz);
+ readBytes (in, buf, 0, eh_sz);
final ElfHeader eh = new ElfHeader(ByteBuffer.wrap(buf, 0, buf.length), in);
return eh;
}
@@ -392,7 +392,7 @@ public class ElfHeader {
/**
* @param buf ELF Header bytes
* @throws IllegalArgumentException if the given buffer does not represent an ELF Header
- * @throws IOException
+ * @throws IOException
*/
ElfHeader(java.nio.ByteBuffer buf, RandomAccessFile in) throws IllegalArgumentException, IOException {
d = Ehdr.create(buf);
@@ -404,11 +404,11 @@ public class ElfHeader {
}
public final short getSize() { return d.getE_ehsize(); }
-
- /**
- * Returns the architecture class in bits,
- * 32 for {@link #ELFCLASS32}, 64 for {@link #ELFCLASS64}
- * and 0 for {@link #ELFCLASSNONE}.
+
+ /**
+ * Returns the architecture class in bits,
+ * 32 for {@link #ELFCLASS32}, 64 for {@link #ELFCLASS64}
+ * and 0 for {@link #ELFCLASSNONE}.
*/
public final int getArchClassBits() {
switch( d.getE_ident()[EI_CLASS] ) {
@@ -417,48 +417,48 @@ public class ElfHeader {
default: return 0;
}
}
-
- /**
- * Returns the processor's data encoding, i.e.
- * {@link #ELFDATA2LSB}, {@link #ELFDATA2MSB} or {@link #ELFDATANONE};
+
+ /**
+ * Returns the processor's data encoding, i.e.
+ * {@link #ELFDATA2LSB}, {@link #ELFDATA2MSB} or {@link #ELFDATANONE};
*/
public final byte getDataEncodingMode() {
return d.getE_ident()[EI_DATA];
}
-
+
/** Returns the ELF file version, should be {@link #EV_CURRENT}. */
public final byte getVersion() {
return d.getE_ident()[EI_VERSION];
}
-
+
/** Returns the operating system and ABI for this file, 3 == Linux. Note: Often not used. */
public final byte getOSABI() {
return d.getE_ident()[EI_OSABI];
}
-
+
/** Returns the version of the {@link #getOSABI() OSABI} for this file. */
public final byte getOSABIVersion() {
return d.getE_ident()[EI_ABIVERSION];
}
- /** Returns the object file type, e.g. {@link #ET_EXEC}, .. */
+ /** Returns the object file type, e.g. {@link #ET_EXEC}, .. */
public final short getType() {
return d.getE_type();
}
- /** Returns the required architecture for the file, e.g. {@link #EM_386}, .. */
+ /** Returns the required architecture for the file, e.g. {@link #EM_386}, .. */
public final short getMachine() {
- return d.getE_machine();
+ return d.getE_machine();
}
-
- /**
+
+ /**
* Returns true if {@link #getMachine() machine} is a 32 or 64 bit ARM CPU
* of type {@link #EM_ARM}. */
public final boolean isArm() {
return getMachine() == EM_ARM;
}
-
- /**
+
+ /**
* Returns true if {@link #getMachine() machine} is a 32 or 64 bit Intel CPU
* of type {@link #EM_386}, {@link #EM_486} or {@link #EM_X86_64}. */
public final boolean isIntel() {
@@ -467,30 +467,30 @@ public class ElfHeader {
EM_486 == m ||
EM_X86_64 == m;
}
-
+
/** Returns the processor-specific flags associated with the file. */
public final int getFlags() {
return d.getE_flags();
}
-
+
/** Returns the ARM EABI version from {@link #getFlags() flags}, maybe 0 if not an ARM EABI. */
public byte getArmABI() {
- return (byte) ( ( ( EF_ARM_ABIMASK & d.getE_flags() ) >> EF_ARM_ABISHIFT ) & 0xff );
+ return (byte) ( ( ( EF_ARM_ABIMASK & d.getE_flags() ) >> EF_ARM_ABISHIFT ) & 0xff );
}
-
+
/** Returns the ARM EABI legacy GCC {@link #getFlags() flags}, maybe 0 if not an ARM EABI or not having legacy GCC flags. */
public int getArmLegacyGCCFlags() {
final int f = d.getE_flags();
- return 0 != ( EF_ARM_ABIMASK & f ) ? ( EF_ARM_GCCMASK & f ) : 0;
+ return 0 != ( EF_ARM_ABIMASK & f ) ? ( EF_ARM_GCCMASK & f ) : 0;
}
-
- /**
+
+ /**
* Returns the ARM EABI float mode from {@link #getFlags() flags},
* i.e. 1 for {@link #EF_ARM_ABI_FLOAT_SOFT}, 2 for {@link #EF_ARM_ABI_FLOAT_HARD}
* or 0 for none.
* <p>
- * Note: This is not used (anymore)
- * </p>
+ * Note: This is not used (anymore)
+ * </p>
*/
public byte getArmFloatMode() {
final int f = d.getE_flags();
@@ -515,7 +515,7 @@ public class ElfHeader {
}
return null;
}
-
+
/** Returns the 1st occurence of matching SectionHeader {@link SectionHeader#getName() name}, or null if not exists. */
public final SectionHeader getSectionHeader(String name) {
for(int i=0; i<sht.length; i++) {
@@ -526,11 +526,11 @@ public class ElfHeader {
}
return null;
}
-
+
public final String toString() {
return string;
}
-
+
private final String toStringImpl() {
final String machineS;
if( isArm() ) {
@@ -553,13 +553,13 @@ public class ElfHeader {
armFlagsS=", arm[abi "+armABI+", lGCC "+getArmLegacyGCCFlags()+", float "+getArmFloatMode()+"]";
} else {
armFlagsS="";
- }
+ }
return "ElfHeader[vers "+getVersion()+", machine["+getMachine()+machineS+"], bits "+getArchClassBits()+", enc "+encS+
", abi[os "+getOSABI()+", vers "+getOSABIVersion()+"], flags["+toHexString(getFlags())+armFlagsS+"], type "+getType()+", sh-num "+sht.length+"]";
}
-
+
final SectionHeader[] readSectionHeaderTable(RandomAccessFile in) throws IOException, IllegalArgumentException {
- // positioning
+ // positioning
{
final long off = d.getE_shoff(); // absolute offset
if( 0 == off ) {
@@ -572,7 +572,7 @@ public class ElfHeader {
final int size = d.getE_shentsize();
final int num;
int i;
- if( 0 == d.getE_shnum() ) {
+ if( 0 == d.getE_shnum() ) {
// Read 1st table 1st and use it's sh_size
final byte[] buf0 = new byte[size];
readBytes(in, buf0, 0, size);
@@ -608,7 +608,7 @@ public class ElfHeader {
sht[i].initName(strS, sht[i].d.getSh_name());
}
}
-
+
return sht;
- }
+ }
}
diff --git a/src/java/jogamp/common/os/elf/IOUtils.java b/src/java/jogamp/common/os/elf/IOUtils.java
index 8308463..8c7bfd1 100644
--- a/src/java/jogamp/common/os/elf/IOUtils.java
+++ b/src/java/jogamp/common/os/elf/IOUtils.java
@@ -34,15 +34,15 @@ import java.nio.ByteOrder;
class IOUtils {
static final long MAX_INT_VALUE = ( (long) Integer.MAX_VALUE & 0xffffffffL ) ;
-
+
static String toHexString(int i) { return "0x"+Integer.toHexString(i); }
-
+
static String toHexString(long i) { return "0x"+Long.toHexString(i); }
-
+
static int shortToInt(short s) {
return (int)s & 0x0000ffff;
}
-
+
static int long2Int(final long v) {
if( MAX_INT_VALUE < v ) {
throw new IllegalArgumentException("Read uint32 value "+toHexString(v)+" > int32-max "+toHexString(MAX_INT_VALUE));
@@ -53,46 +53,46 @@ class IOUtils {
static void checkBounds(final byte[] sb, final int offset, final int remaining) {
if( offset + remaining > sb.length ) {
throw new IndexOutOfBoundsException("Buffer of size "+sb.length+" cannot hold offset "+offset+" + remaining "+remaining);
- }
+ }
}
-
- static void readBytes(final RandomAccessFile in, final byte[] out, final int offset, final int len)
- throws IOException, IllegalArgumentException
- {
+
+ static void readBytes(final RandomAccessFile in, final byte[] out, final int offset, final int len)
+ throws IOException, IllegalArgumentException
+ {
in.readFully(out, offset, len);
}
-
+
static void seek(final RandomAccessFile in, long newPos) throws IOException {
in.seek(newPos);
}
-
+
static int readUInt32(final byte[] in, final int offset) {
final int v = readInt32(in, offset);
if( 0 > v ) {
- throw new IllegalArgumentException("Read uint32 value "+toHexString(v)+" > int32-max "+toHexString(MAX_INT_VALUE));
+ throw new IllegalArgumentException("Read uint32 value "+toHexString(v)+" > int32-max "+toHexString(MAX_INT_VALUE));
}
return v;
/** Need to fix endian for below path ..
checkBounds(in, offset, 4);
- final byte[] uint = new byte[] { 0, 0, 0, 0, in[offset+0], in[offset+1], in[offset+2], in[offset+3] };
+ final byte[] uint = new byte[] { 0, 0, 0, 0, in[offset+0], in[offset+1], in[offset+2], in[offset+3] };
final ByteBuffer b = ByteBuffer.wrap(uint, 0, 8).order(ByteOrder.nativeOrder());
return b.asLongBuffer().get(0); */
}
-
+
static int readInt32(final byte[] in, final int offset) {
checkBounds(in, offset, 4);
final ByteBuffer b = ByteBuffer.wrap(in, offset, 4).order(ByteOrder.nativeOrder());
return b.asIntBuffer().get(0);
}
-
+
/**
* @param sb byte source buffer to parse
* @param offset offset within byte source buffer to start parsing
- * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
+ * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
* which shall not exceed <code>sb.length - offset</code>.
* @param offset_post optional integer array holding offset post parsing
* @return the parsed string
- * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
+ * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
*/
static String getString(final byte[] sb, final int offset, final int remaining, int[] offset_post) throws IndexOutOfBoundsException {
checkBounds(sb, offset, remaining);
@@ -104,14 +104,14 @@ class IOUtils {
}
return s;
}
-
+
/**
* @param sb byte source buffer to parse
* @param offset offset within byte source buffer to start parsing
- * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
+ * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
* which shall not exceed <code>sb.length - offset</code>.
* @return the number of parsed strings
- * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
+ * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
*/
static int getStringCount(final byte[] sb, int offset, final int remaining) throws IndexOutOfBoundsException {
checkBounds(sb, offset, remaining);
@@ -120,21 +120,21 @@ class IOUtils {
for(; i < remaining && sb[i + offset] != 0; i++) { }
strnum++;
}
- return strnum;
+ return strnum;
}
-
+
/**
* @param sb byte source buffer to parse
* @param offset offset within byte source buffer to start parsing
- * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
+ * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
* which shall not exceed <code>sb.length - offset</code>.
* @return the parsed strings
- * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
+ * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
*/
public static String[] getStrings(final byte[] sb, int offset, final int remaining) throws IndexOutOfBoundsException {
final int strnum = getStringCount(sb, offset, remaining);
// System.err.println("XXX: strnum "+strnum+", sb_off "+sb_off+", sb_len "+sb_len);
-
+
final String[] sa = new String[strnum];
final int[] io_off = new int[] { offset };
for(int i=0; i < strnum; i++) {
@@ -142,7 +142,7 @@ class IOUtils {
sa[i] = getString(sb, io_off[0], remaining - io_off[0], io_off);
// System.err.println(".. "+io_off[0]+"[ "+sa[i]);
}
- return sa;
+ return sa;
}
-
+
}
diff --git a/src/java/jogamp/common/os/elf/Section.java b/src/java/jogamp/common/os/elf/Section.java
index 99c762c..a653668 100644
--- a/src/java/jogamp/common/os/elf/Section.java
+++ b/src/java/jogamp/common/os/elf/Section.java
@@ -32,19 +32,19 @@ public class Section {
public byte[] data;
public int offset;
public int length;
-
+
Section(SectionHeader sh, byte[] data, int offset, int length) {
this.sh = sh;
this.data = data;
this.offset = offset;
this.length = length;
}
-
+
public String toString() {
return "Section["+toSubString()+"]";
}
String toSubString() {
return sh+", data[off "+offset+", len "+length+"/"+data.length+"]";
}
-
+
}
diff --git a/src/java/jogamp/common/os/elf/SectionArmAttributes.java b/src/java/jogamp/common/os/elf/SectionArmAttributes.java
index 7b85bb9..413250a 100644
--- a/src/java/jogamp/common/os/elf/SectionArmAttributes.java
+++ b/src/java/jogamp/common/os/elf/SectionArmAttributes.java
@@ -23,17 +23,17 @@ import java.util.List;
*/
public class SectionArmAttributes extends Section {
public static final byte FORMAT_VERSION_A = 0x41; // 'A';
-
+
public static enum Type {
/** No Value */
- None,
+ None,
/** A Sub-Section - following the 4 byte sub section total size (tag + size + content) - byte order of the ELF file */
SubSection,
/** Null Terminated Byte-String */
NTBS,
ULEB128,
}
-
+
/** ULEB128 Value for {@link Tag#ABI_VFP_args}: FP parameter/result passing conforms to AAPCS, BASE variant. */
public static final byte ABI_VFP_ARGS_IS_BASE_VARIANT = 0;
/** ULEB128 Value for {@link Tag#ABI_VFP_args}: FP parameter/result passing conforms to AAPCS, VFP variant. */
@@ -41,18 +41,18 @@ public class SectionArmAttributes extends Section {
/** ULEB128 Value for {@link Tag#ABI_VFP_args}: FP parameter/result passing conforms to custom toolchain. */
public static final byte ABI_VFP_ARGS_IS_CUSTOM_VARIANT = 2;
/** ULEB128 Value for {@link Tag#ABI_VFP_args}: FP parameter/result passing conforms to both , BASE and VFP variant. */
- public static final byte ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT = 3;
-
- /**
+ public static final byte ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT = 3;
+
+ /**
* Returns true if value is either {@link #ABI_VFP_ARGS_IS_VFP_VARIANT} or {@link #ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT}
* @param v ULEB128 Value from {@link Tag#ABI_VFP_args} attribute
*/
public static final boolean abiVFPArgsAcceptsVFPVariant(byte v) {
return ABI_VFP_ARGS_IS_VFP_VARIANT == v || ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT == v;
}
-
+
public static enum Tag {
- None(0, Type.None),
+ None(0, Type.None),
File(1, Type.SubSection), Section(2, Type.SubSection), Symbol(3, Type.SubSection),
CPU_raw_name( 4, Type.NTBS ),
CPU_name( 5, Type.NTBS ),
@@ -96,10 +96,10 @@ public class SectionArmAttributes extends Section {
undefined69( 69, Type.None ),
MPextension_use_legacy( 70, Type.ULEB128 )
;
-
+
public final int id;
- public final Type type;
-
+ public final Type type;
+
/** Slow O(n) transition of a native tag value to a Tag. */
public static Tag get(final int id) {
final Tag[] tags = Tag.values();
@@ -117,16 +117,16 @@ public class SectionArmAttributes extends Section {
this.type = type;
}
}
-
+
public static class Attribute {
public final Tag tag;
private final Object value;
-
+
Attribute(Tag tag, Object value) {
this.tag = tag;
this.value = value;
}
-
+
public final boolean isNTBS() {
return Type.NTBS == tag.type;
}
@@ -136,7 +136,7 @@ public class SectionArmAttributes extends Section {
}
throw new IllegalArgumentException("Not NTBS but "+tag.type);
}
-
+
public final boolean isULEB128() {
return Type.ULEB128 == tag.type;
}
@@ -146,41 +146,41 @@ public class SectionArmAttributes extends Section {
}
throw new IllegalArgumentException("Not ULEB128 but "+tag.type);
}
-
+
public String toString() {
return tag+" = "+value;
}
}
-
+
public static class VendorAttributes {
public final String vendor;
public final List<Attribute> attributes;
-
+
VendorAttributes(String vendor, List<Attribute> attributes) {
this.vendor = vendor;
- this.attributes = attributes;
+ this.attributes = attributes;
}
-
+
public String toString() {
return vendor + attributes.toString();
}
}
public final List<VendorAttributes> vendorAttributesList;
-
+
SectionArmAttributes(SectionHeader sh, byte[] data, int offset, int length) throws IndexOutOfBoundsException, IllegalArgumentException {
super(sh, data, offset, length);
this.vendorAttributesList = parse(data, offset, length);
}
-
+
public String toString() {
return "SectionArmAttributes["+super.toSubString()+", "+vendorAttributesList.toString()+"]";
}
-
+
public final Attribute get(Tag tag) {
for(int i=0; i<vendorAttributesList.size(); i++) {
final List<Attribute> attributes = vendorAttributesList.get(i).attributes;
for(int j=0; j<attributes.size(); j++) {
- final Attribute a = attributes.get(j);
+ final Attribute a = attributes.get(j);
if( a.tag == tag ) {
return a;
}
@@ -188,11 +188,11 @@ public class SectionArmAttributes extends Section {
}
return null;
}
-
+
public final List<Attribute> get(String vendor) {
return get(vendorAttributesList, vendor);
}
-
+
static final List<Attribute> get(final List<VendorAttributes> vendorAttributesList, String vendor) {
for(int i=0; i<vendorAttributesList.size(); i++) {
final VendorAttributes vas = vendorAttributesList.get(i);
@@ -202,14 +202,14 @@ public class SectionArmAttributes extends Section {
}
return null;
}
-
+
/**
* @param in byte source buffer to parse
* @param offset offset within byte source buffer to start parsing
- * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
+ * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
* which shall not exceed <code>sb.length - offset</code>.
- * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
- * @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
+ * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
+ * @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
*/
static List<VendorAttributes> parse(final byte[] in, final int offset, final int remaining) throws IndexOutOfBoundsException, IllegalArgumentException {
checkBounds(in, offset, remaining);
@@ -218,33 +218,33 @@ public class SectionArmAttributes extends Section {
throw new IllegalArgumentException("ShArmAttr: Not version A, but: "+toHexString(in[i]));
}
i++;
-
+
final List<VendorAttributes> vendorAttributesList = new ArrayList<VendorAttributes>();
-
+
while(i < remaining) {
- final int i_pre = i;
+ final int i_pre = i;
final int secLen = readUInt32(in, i); /* total section size: 4 + string + content, i.e. offset to next section */
i+=4;
-
+
final String vendor;
{
- int[] i_post = new int[] { 0 };
+ int[] i_post = new int[] { 0 };
vendor = getString(in, i, secLen - 4, i_post);
i = i_post[0];
}
-
+
final List<Attribute> attributes = new ArrayList<Attribute>();
-
+
while(i < secLen) {
- int[] i_post = new int[] { 0 };
- parseSub(in, i, secLen - i, i_post, attributes);
+ int[] i_post = new int[] { 0 };
+ parseSub(in, i, secLen - i, i_post, attributes);
i = i_post[0];
}
-
+
if( i_pre + secLen != i ) {
throw new IllegalArgumentException("ShArmAttr: Section length count mismatch, expected "+(i_pre + secLen)+", has "+i);
}
-
+
final List<Attribute> mergeAttribs = get(vendorAttributesList, vendor);
if( null != mergeAttribs ) {
mergeAttribs.addAll(attributes);
@@ -252,21 +252,21 @@ public class SectionArmAttributes extends Section {
vendorAttributesList.add(new VendorAttributes(vendor, attributes));
}
}
-
+
return vendorAttributesList;
}
-
+
/**
* @param in byte source buffer to parse
* @param offset offset within byte source buffer to start parsing
- * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
+ * @param remaining remaining numbers of bytes to parse beginning w/ <code>sb_off</code>,
* which shall not exceed <code>sb.length - offset</code>.
- * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
- * @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
+ * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
+ * @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
*/
static void parseSub(final byte[] in, final int offset, final int remaining, int[] offset_post, List<Attribute> attributes) throws IndexOutOfBoundsException, IllegalArgumentException {
checkBounds(in, offset, remaining);
-
+
// Starts w/ sub-section Tag
int i = offset;
final int i_sTag = in[i++];
@@ -274,7 +274,7 @@ public class SectionArmAttributes extends Section {
if( null == sTag ) {
throw new IllegalArgumentException("ShArmAttr: Invalid Sub-Section tag (NaT): "+i_sTag);
}
- final int subSecLen; // sub section total size (tag + size + content)
+ final int subSecLen; // sub section total size (tag + size + content)
switch(sTag) {
case File:
case Section:
@@ -295,7 +295,7 @@ public class SectionArmAttributes extends Section {
switch(tag.type) {
case NTBS:
{
- int[] i_post = new int[] { 0 };
+ int[] i_post = new int[] { 0 };
final String value = getString(in, i, subSecLen + offset - i, i_post);
attributes.add(new Attribute(tag, value));
i = i_post[0];
@@ -313,5 +313,5 @@ public class SectionArmAttributes extends Section {
}
}
offset_post[0] = offset + subSecLen;
- }
+ }
}
diff --git a/src/java/jogamp/common/os/elf/SectionHeader.java b/src/java/jogamp/common/os/elf/SectionHeader.java
index 18a3293..fd28d2a 100644
--- a/src/java/jogamp/common/os/elf/SectionHeader.java
+++ b/src/java/jogamp/common/os/elf/SectionHeader.java
@@ -120,7 +120,7 @@ public class SectionHeader {
* {@value}
*/
public static final int SHT_HIUSER = 0xffffffff;
-
+
/**
* {@value}
*/
@@ -141,7 +141,7 @@ public class SectionHeader {
* {@value}
*/
public static final int SHT_ARM_OVERLAYSECTION = 0x70000005;
-
+
/**
* {@value}
*/
@@ -169,14 +169,14 @@ public class SectionHeader {
/**
* {@value}
*/
- public static final short SHN_HIRESERVE = (short)0xffff;
-
+ public static final short SHN_HIRESERVE = (short)0xffff;
+
/** Public access to the raw elf section header */
public final Shdr d;
-
+
private int idx;
private String name;
-
+
SectionHeader(byte[] buf, int offset, int length, int sectionIdx) {
this( ByteBuffer.wrap(buf, 0, buf.length), sectionIdx );
}
@@ -185,11 +185,11 @@ public class SectionHeader {
this.idx = idx;
name = null;
}
-
+
public String toString() {
return "SectionHeader[idx "+idx+", name "+name+", type "+toHexString(getType())+", link "+d.getSh_link()+", info "+toHexString(d.getSh_info())+", flags "+toHexString(getFlags())+"]";
}
-
+
/**
* @param strS the {@link SectionHeader#SHT_STRTAB} section containing all strings
* @param nameOffset name offset within strS
@@ -202,7 +202,7 @@ public class SectionHeader {
public int getIndex() {
return idx;
}
-
+
/** Returns the type of this section. */
public int getType() {
return d.getSh_type();
@@ -212,7 +212,7 @@ public class SectionHeader {
public long getFlags() {
return d.getSh_flags();
}
-
+
/** Returns the size of this section. */
public long getSize() {
return d.getSh_size();
@@ -222,10 +222,10 @@ public class SectionHeader {
public String getName() {
return name;
}
-
+
/**
* Returns the Section referenced w/ this section header
- *
+ *
* @param in file owning the section
* @throws IOException if read error occurs
* @throws IllegalArgumentException if section offset or size mismatch including size &gt; {@link Integer#MAX_VALUE}
@@ -238,10 +238,10 @@ public class SectionHeader {
final byte[] s_buf = new byte[s_size];
return readSectionImpl(in, s_buf, 0, s_size);
}
-
+
/**
* Returns the Section referenced w/ this section header using given byte array.
- *
+ *
* @param in file owning the section
* @param b destination buffer
* @param b_off offset in destination buffer
@@ -260,7 +260,7 @@ public class SectionHeader {
}
return readSectionImpl(in, b, b_off, r_len);
}
-
+
Section readSectionImpl(RandomAccessFile in, byte[] b, int b_off, int r_len) throws IOException, IllegalArgumentException {
final long s_off = d.getSh_offset();
seek(in, s_off);
@@ -270,5 +270,5 @@ public class SectionHeader {
} else {
return new Section(this, b, b_off, r_len);
}
- }
+ }
}
diff --git a/src/java/jogamp/common/util/locks/LockDebugUtil.java b/src/java/jogamp/common/util/locks/LockDebugUtil.java
index 480b143..ee0a8e8 100644
--- a/src/java/jogamp/common/util/locks/LockDebugUtil.java
+++ b/src/java/jogamp/common/util/locks/LockDebugUtil.java
@@ -50,7 +50,7 @@ public class LockDebugUtil {
dummy = new ArrayList<Throwable>(0);
}
}
-
+
public static List<Throwable> getRecursiveLockTrace() {
if(Lock.DEBUG) {
ArrayList<Throwable> ls = tlsLockedStacks.get();
@@ -63,7 +63,7 @@ public class LockDebugUtil {
return dummy;
}
}
-
+
public static void dumpRecursiveLockTrace(PrintStream out) {
if(Lock.DEBUG) {
List<Throwable> ls = getRecursiveLockTrace();
diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
index 986a7fc..f49e406 100644
--- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
+++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java
@@ -36,7 +36,7 @@ import com.jogamp.common.util.locks.RecursiveLock;
/**
* Reentrance locking toolkit, impl a complete fair FIFO scheduler
- *
+ *
* <p>
* Sync object extends {@link AbstractOwnableSynchronizer}, hence monitoring is possible.</p>
*/
@@ -50,7 +50,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
final Thread thread;
boolean signaledByUnlock; // if true, it's also removed from queue
}
-
+
@SuppressWarnings("serial")
private static class Sync extends AbstractOwnableSynchronizer {
private Sync() {
@@ -68,7 +68,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
ls.remove(lockedStack);
} else {
ls.add(s);
- }
+ }
lockedStack = s;
}
/** lock count by same thread */
@@ -79,7 +79,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
private Throwable lockedStack = null;
}
private Sync sync = new Sync();
-
+
public RecursiveLockImpl01CompleteFair() {
}
@@ -119,7 +119,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
public final boolean isLockedByOtherThread() {
synchronized(sync) {
final Thread o = sync.getOwner();
- return null != o && Thread.currentThread() != o ;
+ return null != o && Thread.currentThread() != o ;
}
}
@@ -175,9 +175,9 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
}
return true;
}
-
+
if ( sync.getOwner() != null || ( 0<timeout && 0<sync.queue.size() ) ) {
-
+
if ( 0 >= timeout ) {
// locked by other thread and no waiting requested
if(TRACE_LOCK) {
@@ -185,7 +185,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
}
return false;
}
-
+
// enqueue at the start
WaitingThread wCur = new WaitingThread(cur);
sync.queue.add(0, wCur);
@@ -198,24 +198,24 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
if( !wCur.signaledByUnlock ) {
sync.queue.remove(wCur); // O(n)
throw e; // propagate interruption not send by unlock
- } else if( cur != sync.getOwner() ) {
+ } else if( cur != sync.getOwner() ) {
// Issued by unlock, but still locked by other thread
//
timeout -= System.currentTimeMillis() - t0;
-
+
if(TRACE_LOCK) {
System.err.println("+++ LOCK 1 "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms, signaled: "+wCur.signaledByUnlock);
}
-
+
if(0 < timeout) {
// not timed out, re-enque - lock was 'stolen'
wCur.signaledByUnlock = false;
sync.queue.add(sync.queue.size(), wCur);
}
- } // else: Issued by unlock, owning lock .. expected!
+ } // else: Issued by unlock, owning lock .. expected!
}
} while ( cur != sync.getOwner() && 0 < timeout ) ;
-
+
if( 0 >= timeout && cur != sync.getOwner() ) {
// timed out
if(!wCur.signaledByUnlock) {
@@ -226,7 +226,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
}
return false;
}
-
+
++sync.holdCount;
if(TRACE_LOCK) {
System.err.println("+++ LOCK X1 "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms");
@@ -237,7 +237,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
System.err.println("+++ LOCK X0 "+toString()+", cur "+threadName(cur));
}
}
-
+
sync.setOwner(cur);
if(DEBUG) {
sync.setLockedStack(new Throwable("Previously locked by "+toString()));
@@ -245,7 +245,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
return true;
}
}
-
+
@Override
public final void unlock() {
@@ -259,33 +259,33 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
synchronized(sync) {
validateLocked();
final Thread cur = Thread.currentThread();
-
+
--sync.holdCount;
-
+
if (sync.holdCount > 0) {
if(TRACE_LOCK) {
System.err.println("--- LOCK XR "+toString()+", cur "+threadName(cur));
}
return;
}
-
+
if(DEBUG) {
sync.setLockedStack(null);
}
if(null!=taskAfterUnlockBeforeNotify) {
taskAfterUnlockBeforeNotify.run();
}
-
+
if(sync.queue.size() > 0) {
// fair, wakeup the oldest one ..
// final WaitingThread oldest = queue.removeLast();
final WaitingThread oldest = sync.queue.remove(sync.queue.size()-1);
- sync.setOwner(oldest.thread);
-
+ sync.setOwner(oldest.thread);
+
if(TRACE_LOCK) {
System.err.println("--- LOCK X1 "+toString()+", cur "+threadName(cur)+", signal: "+threadName(oldest.thread));
}
-
+
oldest.signaledByUnlock = true;
oldest.thread.interrupt(); // Propagate SecurityException if it happens
} else {
@@ -293,24 +293,24 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock {
if(TRACE_LOCK) {
System.err.println("--- LOCK X0 "+toString()+", cur "+threadName(cur)+", signal any");
}
- sync.notify();
+ sync.notify();
}
}
}
-
+
@Override
public final int getQueueLength() {
synchronized(sync) {
return sync.queue.size();
}
}
-
+
@Override
public String toString() {
return syncName()+"[count "+sync.holdCount+
", qsz "+sync.queue.size()+", owner "+threadName(sync.getOwner())+"]";
}
-
+
private final String syncName() {
return "<"+Integer.toHexString(this.hashCode())+", "+Integer.toHexString(sync.hashCode())+">";
}
diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java
index e8fecb1..8c9f720 100644
--- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java
+++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java
@@ -37,9 +37,9 @@ import com.jogamp.common.util.locks.RecursiveLock;
* Reentrance locking toolkit, impl a non-complete fair FIFO scheduler.
* <p>
* Fair scheduling is not guaranteed due to the usage of {@link Object#notify()},
- * however new lock-applicants will wait if queue is not empty for {@link #lock()}
+ * however new lock-applicants will wait if queue is not empty for {@link #lock()}
* and {@link #tryLock(long) tryLock}(timeout>0).</p>
- *
+ *
* <p>
* Sync object extends {@link AbstractOwnableSynchronizer}, hence monitoring is possible.</p>
*/
@@ -49,19 +49,19 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
Thread getOwner();
boolean isOwner(Thread t);
void setOwner(Thread t);
-
+
Throwable getLockedStack();
void setLockedStack(Throwable s);
-
+
int getHoldCount();
void incrHoldCount(Thread t);
void decrHoldCount(Thread t);
-
+
int getQSz();
void incrQSz();
void decrQSz();
}
-
+
@SuppressWarnings("serial")
/* package */ static class SingleThreadSync extends AbstractOwnableSynchronizer implements Sync {
/* package */ SingleThreadSync() {
@@ -90,7 +90,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
ls.remove(lockedStack);
} else {
ls.add(s);
- }
+ }
lockedStack = s;
}
@Override
@@ -99,14 +99,14 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
public void incrHoldCount(Thread t) { holdCount++; }
@Override
public void decrHoldCount(Thread t) { holdCount--; }
-
+
@Override
public final int getQSz() { return qsz; }
@Override
public final void incrQSz() { qsz++; }
@Override
public final void decrQSz() { qsz--; }
-
+
/** lock count by same thread */
private int holdCount = 0;
/** queue size of waiting threads */
@@ -114,13 +114,13 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
/** stack trace of the lock, only used if DEBUG */
private Throwable lockedStack = null;
}
-
+
protected final Sync sync;
-
+
public RecursiveLockImpl01Unfairish(Sync sync) {
this.sync = sync;
}
-
+
public RecursiveLockImpl01Unfairish() {
this(new SingleThreadSync());
}
@@ -217,9 +217,9 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
}
return true;
}
-
+
if ( sync.getOwner() != null || ( 0<timeout && 0<sync.getQSz() ) ) {
-
+
if ( 0 >= timeout ) {
// locked by other thread and no waiting requested
if(TRACE_LOCK) {
@@ -227,7 +227,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
}
return false;
}
-
+
sync.incrQSz();
do {
final long t0 = System.currentTimeMillis();
@@ -235,7 +235,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
timeout -= System.currentTimeMillis() - t0;
} while (null != sync.getOwner() && 0 < timeout) ;
sync.decrQSz();
-
+
if( 0 >= timeout && sync.getOwner() != null ) {
// timed out
if(TRACE_LOCK) {
@@ -243,24 +243,24 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
}
return false;
}
-
+
if(TRACE_LOCK) {
System.err.println("+++ LOCK X1 "+toString()+", cur "+threadName(cur)+", left "+timeout+" ms");
}
} else if(TRACE_LOCK) {
System.err.println("+++ LOCK X0 "+toString()+", cur "+threadName(cur));
}
-
+
sync.setOwner(cur);
sync.incrHoldCount(cur);
-
+
if(DEBUG) {
sync.setLockedStack(new Throwable("Previously locked by "+toString()));
}
return true;
}
}
-
+
@Override
public final void unlock() {
@@ -274,16 +274,16 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
synchronized(sync) {
validateLocked();
final Thread cur = Thread.currentThread();
-
+
sync.decrHoldCount(cur);
-
+
if (sync.getHoldCount() > 0) {
if(TRACE_LOCK) {
System.err.println("--- LOCK XR "+toString()+", cur "+threadName(cur));
}
return;
}
-
+
sync.setOwner(null);
if(DEBUG) {
sync.setLockedStack(null);
@@ -291,27 +291,27 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock {
if(null!=taskAfterUnlockBeforeNotify) {
taskAfterUnlockBeforeNotify.run();
}
-
+
if(TRACE_LOCK) {
System.err.println("--- LOCK X0 "+toString()+", cur "+threadName(cur)+", signal any");
}
sync.notify();
}
}
-
+
@Override
public final int getQueueLength() {
synchronized(sync) {
return sync.getQSz();
}
}
-
+
@Override
public String toString() {
return syncName()+"[count "+sync.getHoldCount()+
", qsz "+sync.getQSz()+", owner "+threadName(sync.getOwner())+"]";
}
-
+
/* package */ final String syncName() {
return "<"+Integer.toHexString(this.hashCode())+", "+Integer.toHexString(sync.hashCode())+">";
}
diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java
index d9bc3df..f3dfa42 100644
--- a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java
+++ b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java
@@ -9,11 +9,11 @@ public class RecursiveLockImplJava5 implements RecursiveLock {
volatile Thread owner = null;
ReentrantLock lock;
-
+
public RecursiveLockImplJava5(boolean fair) {
lock = new ReentrantLock(fair);
}
-
+
@Override
public void lock() {
try {
@@ -49,7 +49,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock {
}
lock.unlock();
}
-
+
@Override
public boolean isLocked() {
return lock.isLocked();
diff --git a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java
index 6c43580..7a386d6 100644
--- a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java
+++ b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java
@@ -31,12 +31,12 @@ import java.util.Arrays;
import com.jogamp.common.util.locks.RecursiveThreadGroupLock;
-public class RecursiveThreadGroupLockImpl01Unfairish
- extends RecursiveLockImpl01Unfairish
- implements RecursiveThreadGroupLock
+public class RecursiveThreadGroupLockImpl01Unfairish
+ extends RecursiveLockImpl01Unfairish
+ implements RecursiveThreadGroupLock
{
/* package */ @SuppressWarnings("serial")
- static class ThreadGroupSync extends SingleThreadSync {
+ static class ThreadGroupSync extends SingleThreadSync {
/* package */ ThreadGroupSync() {
super();
threadNum = 0;
@@ -44,23 +44,23 @@ public class RecursiveThreadGroupLockImpl01Unfairish
holdCountAdditionOwner = 0;
}
@Override
- public final void incrHoldCount(Thread t) {
- super.incrHoldCount(t);
- if(!isOriginalOwner(t)) {
- holdCountAdditionOwner++;
- }
+ public final void incrHoldCount(Thread t) {
+ super.incrHoldCount(t);
+ if(!isOriginalOwner(t)) {
+ holdCountAdditionOwner++;
+ }
}
@Override
- public final void decrHoldCount(Thread t) {
- super.decrHoldCount(t);
- if(!isOriginalOwner(t)) {
- holdCountAdditionOwner--;
- }
+ public final void decrHoldCount(Thread t) {
+ super.decrHoldCount(t);
+ if(!isOriginalOwner(t)) {
+ holdCountAdditionOwner--;
+ }
}
public final int getAdditionalOwnerHoldCount() {
return holdCountAdditionOwner;
}
-
+
public final boolean isOriginalOwner(Thread t) {
return super.isOwner(t);
}
@@ -76,11 +76,11 @@ public class RecursiveThreadGroupLockImpl01Unfairish
}
return false;
}
-
+
public final int getAddOwnerCount() {
return threadNum;
}
- public final void addOwner(Thread t) throws IllegalArgumentException {
+ public final void addOwner(Thread t) throws IllegalArgumentException {
if(null == threads) {
if(threadNum>0) {
throw new InternalError("XXX");
@@ -98,15 +98,15 @@ public class RecursiveThreadGroupLockImpl01Unfairish
threads[threadNum] = t;
threadNum++;
}
-
+
public final void removeAllOwners() {
for(int i=threadNum-1; 0<=i; i--) {
threads[i]=null;
}
- threadNum=0;
+ threadNum=0;
}
-
- public final void removeOwner(Thread t) throws IllegalArgumentException {
+
+ public final void removeOwner(Thread t) throws IllegalArgumentException {
for (int i = 0 ; i < threadNum ; i++) {
if (threads[i] == t) {
threadNum--;
@@ -117,7 +117,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish
}
throw new IllegalArgumentException("Not an owner: "+t);
}
-
+
String addOwnerToString() {
StringBuilder sb = new StringBuilder();
for(int i=0; i<threadNum; i++) {
@@ -126,19 +126,19 @@ public class RecursiveThreadGroupLockImpl01Unfairish
}
sb.append(threads[i].getName());
}
- return sb.toString();
+ return sb.toString();
}
-
+
// lock count by addition owner threads
- private int holdCountAdditionOwner;
+ private int holdCountAdditionOwner;
private Thread[] threads;
private int threadNum;
}
-
+
public RecursiveThreadGroupLockImpl01Unfairish() {
super(new ThreadGroupSync());
}
-
+
@Override
public final boolean isOriginalOwner() {
return isOriginalOwner(Thread.currentThread());
@@ -164,13 +164,13 @@ public class RecursiveThreadGroupLockImpl01Unfairish
}
tgSync.addOwner(t);
}
-
+
@Override
public final void unlock(Runnable taskAfterUnlockBeforeNotify) {
synchronized(sync) {
final Thread cur = Thread.currentThread();
final ThreadGroupSync tgSync = (ThreadGroupSync)sync;
-
+
if( tgSync.getAddOwnerCount()>0 ) {
if(TRACE_LOCK) {
System.err.println("--- LOCK XR (tg) "+toString()+", cur "+threadName(cur)+" -> owner...");
@@ -193,23 +193,23 @@ public class RecursiveThreadGroupLockImpl01Unfairish
final Thread originalOwner = tgSync.getOwner();
if(originalOwner.getState() == Thread.State.WAITING) {
originalOwner.interrupt();
- }
+ }
}
}
if(TRACE_LOCK) {
System.err.println("++ unlock(X): currentThread "+cur.getName()+", lock: "+this.toString());
System.err.println("--- LOCK X0 (tg) "+toString()+", cur "+threadName(cur)+" -> unlock!");
}
- super.unlock(taskAfterUnlockBeforeNotify);
+ super.unlock(taskAfterUnlockBeforeNotify);
}
}
-
+
@Override
public final void removeOwner(Thread t) throws RuntimeException, IllegalArgumentException {
validateLocked();
((ThreadGroupSync)sync).removeOwner(t);
}
-
+
@Override
public String toString() {
final ThreadGroupSync tgSync = (ThreadGroupSync)sync;
diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java
index 42d125a..a3d3ac9 100644
--- a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java
+++ b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package jogamp.common.util.locks;
import java.io.File;
@@ -73,7 +73,7 @@ public class SingletonInstanceFileLock extends SingletonInstance {
@Override
public final String getName() { return file.getPath(); }
-
+
private void setupFileCleanup() {
file.deleteOnExit();
Runtime.getRuntime().addShutdownHook(new Thread() {
@@ -84,7 +84,7 @@ public class SingletonInstanceFileLock extends SingletonInstance {
}
unlock();
}
- });
+ });
}
@Override
diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java
index c4f9564..a1ca2ff 100644
--- a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java
+++ b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package jogamp.common.util.locks;
import java.io.IOException;
@@ -39,11 +39,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
private final Server singletonServer;
private final String fullName;
-
+
public SingletonInstanceServerSocket(long poll_ms, int portNumber) {
super(poll_ms);
-
- // Gather the local InetAddress, loopback is prioritized
+
+ // Gather the local InetAddress, loopback is prioritized
InetAddress ilh = null;
try {
ilh = InetAddress.getByName(null); // loopback
@@ -56,10 +56,10 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
}
if(null == ilh) {
try {
- ilh = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 } );
+ ilh = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 } );
if(null!=ilh && !ilh.isLoopbackAddress()) { ilh = null; }
} catch (UnknownHostException e) { }
- }
+ }
if(null == ilh) {
try {
ilh = InetAddress.getLocalHost();
@@ -68,15 +68,15 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
if(null == ilh) {
throw new RuntimeException(infoPrefix()+" EEE Could not determine local InetAddress");
}
-
+
fullName = ilh.toString()+":"+portNumber;
- singletonServer = new Server(ilh, portNumber);
+ singletonServer = new Server(ilh, portNumber);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
singletonServer.kill();
}
- });
+ });
}
public final InetAddress getLocalInetAddress() {
@@ -89,13 +89,13 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
@Override
public final String getName() { return fullName; }
-
+
@Override
protected boolean tryLockImpl() {
if( singletonServer.isRunning() ) {
return false; // same JVM .. server socket already installed !
}
-
+
// check if other JVM's locked the server socket ..
Socket clientSocket = singletonServer.connect();
if(null != clientSocket) {
@@ -104,11 +104,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
} catch (IOException e) { }
return false;
}
-
+
if( !singletonServer.start() ) {
return false;
}
-
+
return true;
}
@@ -119,26 +119,26 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
public class Server implements Runnable {
private final InetAddress localInetAddress;
- private final int portNumber;
-
- private volatile boolean shallQuit = false;
+ private final int portNumber;
+
+ private volatile boolean shallQuit = false;
private volatile boolean alive = false;
-
+
private Object syncOnStartStop = new Object();
private ServerSocket serverSocket = null;
private Thread serverThread = null; // allowing kill() to force-stop last server-thread
-
+
public Server(InetAddress localInetAddress, int portNumber) {
this.localInetAddress = localInetAddress;
this.portNumber = portNumber;
}
-
+
public final InetAddress getLocalInetAddress() { return localInetAddress; }
public final int getPortNumber() { return portNumber; }
-
+
public final boolean start() {
if(alive) return true;
-
+
synchronized (syncOnStartStop) {
serverThread = new Thread(this);
serverThread.setDaemon(true); // be a daemon, don't keep the JVM running
@@ -147,7 +147,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
syncOnStartStop.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
- }
+ }
}
boolean ok = isBound();
if(!ok) {
@@ -155,10 +155,10 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
}
return ok;
}
-
+
public final boolean shutdown() {
if(!alive) return true;
-
+
synchronized (syncOnStartStop) {
shallQuit = true;
connect();
@@ -166,7 +166,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
syncOnStartStop.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
- }
+ }
}
if(alive) {
System.err.println(infoPrefix()+" EEE "+getName()+" - Unable to remove lock: ServerThread still alive ?");
@@ -175,7 +175,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
return true;
}
- /**
+ /**
* Brutally kill server thread and close socket regardless.
* This is out last chance for JVM shutdown.
*/
@@ -196,11 +196,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
serverSocket = null;
ss.close();
} catch (Throwable t) { }
- }
+ }
}
-
+
public final boolean isRunning() { return alive; }
-
+
public final boolean isBound() {
return alive && null != serverSocket && serverSocket.isBound() ;
}
@@ -211,14 +211,14 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
} catch (Exception e) { }
return null;
}
-
+
@Override
public void run() {
{
final Thread currentThread = Thread.currentThread();
currentThread.setName(currentThread.getName() + " - SISock: "+getName());
if(DEBUG) {
- System.err.println(currentThread.getName()+" - started");
+ System.err.println(currentThread.getName()+" - started");
}
}
alive = false;
@@ -231,10 +231,10 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
System.err.println(infoPrefix()+" III - Unable to install ServerSocket: "+e.getMessage());
shallQuit = true;
} finally {
- syncOnStartStop.notifyAll();
+ syncOnStartStop.notifyAll();
}
}
-
+
while (!shallQuit) {
try {
final Socket clientSocket = serverSocket.accept();
@@ -243,7 +243,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance {
System.err.println(infoPrefix()+" EEE - Exception during accept: " + ioe.getMessage());
}
}
-
+
synchronized (syncOnStartStop) {
try {
if(null != serverSocket) {