diff options
author | sg215889 <[email protected]> | 2009-07-28 17:23:24 -0700 |
---|---|---|
committer | sg215889 <[email protected]> | 2009-07-28 17:23:24 -0700 |
commit | f607cdf272dffbd45e6389c5715a9596e85c2a90 (patch) | |
tree | efb871ce63d67ba4c741c863135cad82fb9a1a7a /src/java/com/sun/gluegen/runtime/CPU.java | |
parent | 53b16f758e0db510db420fabe6793e7921a9c407 (diff) |
Fix: Add sun.arch.data.model to determine 32bit arch
Diffstat (limited to 'src/java/com/sun/gluegen/runtime/CPU.java')
-rwxr-xr-x | src/java/com/sun/gluegen/runtime/CPU.java | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java index 0456e9f..c7e6bc1 100755 --- a/src/java/com/sun/gluegen/runtime/CPU.java +++ b/src/java/com/sun/gluegen/runtime/CPU.java @@ -47,35 +47,67 @@ public class CPU { private static boolean is32Bit; static { - // We don't seem to need an AccessController.doPrivileged() block - // here as these system properties are visible even to unsigned - // applets - // Note: this code is replicated in StructLayout.java - String os = System.getProperty("os.name").toLowerCase(); - String cpu = System.getProperty("os.arch").toLowerCase(); - 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"))) { - } else { - throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")"); + boolean done=false; + + // Try to use Sun's sun.arch.data.model first .. + int bits = 0; + try { + String bitS = + (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("sun.arch.data.model"); + } + }); + if(null!=bitS && bitS.length()>0) { + bits = Integer.parseInt(bitS); + is32Bit = ( 32 == bits ); + done = true ; + } + } catch (NumberFormatException nfe) {} + + if(!done) { + // We don't seem to need an AccessController.doPrivileged() block + // here as these system properties are visible even to unsigned + // applets + // Note: this code is replicated in StructLayout.java + 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) { + throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")"); + } } } |