summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-18 23:59:53 +0100
committerMichael Bien <[email protected]>2010-01-18 23:59:53 +0100
commitd17e416ba518b3095e863197509c37f0708f1934 (patch)
treed3d0a38749b3bd0444d848d7a8c5f1861a50c8c2
parentf65d7a7987ae4b30ef38069b3dffefa4441403f8 (diff)
is32Bit field is now immutable to help hotspot with inlining.
code cleanup.
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/CPU.java68
1 files changed, 27 insertions, 41 deletions
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java
index ee6c9f5..8c6d500 100755
--- a/src/java/com/sun/gluegen/runtime/CPU.java
+++ b/src/java/com/sun/gluegen/runtime/CPU.java
@@ -38,28 +38,24 @@
*/
package com.sun.gluegen.runtime;
-import java.security.*;
/** Provides information to autogenerated struct accessors about what
kind of data model (32- or 64-bit) is being used by the currently
running process. */
public class CPU {
- private static boolean is32Bit;
+
+ private final static boolean is32Bit;
static {
- NativeLibrary.ensureNativeLibLoaded();
- boolean done=false;
+ NativeLibrary.ensureNativeLibLoaded();
// Try to use Sun's sun.arch.data.model first ..
int bits = getPointerSizeInBits();
if ( 32 == bits || 64 == bits ) {
is32Bit = ( 32 == bits );
- done = true ;
- }
-
- if(!done) {
+ }else {
// We don't seem to need an AccessController.doPrivileged() block
// here as these system properties are visible even to unsigned
// applets
@@ -67,39 +63,29 @@ public class CPU {
String os = System.getProperty("os.name").toLowerCase();
String cpu = System.getProperty("os.arch").toLowerCase();
- if(!done) {
- if ((os.startsWith("windows") && cpu.equals("x86")) ||
- (os.startsWith("windows") && cpu.equals("arm")) ||
- (os.startsWith("linux") && cpu.equals("i386")) ||
- (os.startsWith("linux") && cpu.equals("x86")) ||
- (os.startsWith("mac os") && cpu.equals("ppc")) ||
- (os.startsWith("mac os") && cpu.equals("i386")) ||
- (os.startsWith("darwin") && cpu.equals("ppc")) ||
- (os.startsWith("darwin") && cpu.equals("i386")) ||
- (os.startsWith("sunos") && cpu.equals("sparc")) ||
- (os.startsWith("sunos") && cpu.equals("x86")) ||
- (os.startsWith("freebsd") && cpu.equals("i386")) ||
- (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
- is32Bit = true;
- done = true;
- }
- }
-
- if(!done) {
- if ((os.startsWith("windows") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("x86_64")) ||
- (os.startsWith("linux") && cpu.equals("ia64")) ||
- (os.startsWith("mac os") && cpu.equals("x86_64")) ||
- (os.startsWith("darwin") && cpu.equals("x86_64")) ||
- (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
- (os.startsWith("sunos") && cpu.equals("amd64"))) {
- is32Bit = false;
- done = true;
- }
- }
-
- if(!done) {
+ if ((os.startsWith("windows") && cpu.equals("x86")) ||
+ (os.startsWith("windows") && cpu.equals("arm")) ||
+ (os.startsWith("linux") && cpu.equals("i386")) ||
+ (os.startsWith("linux") && cpu.equals("x86")) ||
+ (os.startsWith("mac os") && cpu.equals("ppc")) ||
+ (os.startsWith("mac os") && cpu.equals("i386")) ||
+ (os.startsWith("darwin") && cpu.equals("ppc")) ||
+ (os.startsWith("darwin") && cpu.equals("i386")) ||
+ (os.startsWith("sunos") && cpu.equals("sparc")) ||
+ (os.startsWith("sunos") && cpu.equals("x86")) ||
+ (os.startsWith("freebsd") && cpu.equals("i386")) ||
+ (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
+ is32Bit = true;
+ }else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
+ (os.startsWith("linux") && cpu.equals("amd64")) ||
+ (os.startsWith("linux") && cpu.equals("x86_64")) ||
+ (os.startsWith("linux") && cpu.equals("ia64")) ||
+ (os.startsWith("mac os") && cpu.equals("x86_64")) ||
+ (os.startsWith("darwin") && cpu.equals("x86_64")) ||
+ (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
+ (os.startsWith("sunos") && cpu.equals("amd64"))) {
+ is32Bit = false;
+ }else{
throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
}
}