diff options
-rwxr-xr-x | src/java/com/sun/gluegen/runtime/CPU.java | 68 |
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 + ")"); } } |