44 } else if (os.equals("OpenBSD")) {
45 return "bsd";
46 } else if (os.contains("Darwin") || os.contains("OS X")) {
47 return "darwin";
48 } else if (os.startsWith("Windows")) {
49 return "win32";
50 } else {
51 throw new UnsupportedPlatformException("Operating system " + os + " not yet supported");
52 }
53 }
54
55 /* Returns "sparc" for SPARC based platforms and "x86" for x86 based
56 platforms. Otherwise returns the value of os.arch. If the value
57 is not recognized as supported, an exception is thrown instead. */
58 public static String getCPU() throws UnsupportedPlatformException {
59 String cpu = System.getProperty("os.arch");
60 if (cpu.equals("i386") || cpu.equals("x86")) {
61 return "x86";
62 } else if (cpu.equals("sparc") || cpu.equals("sparcv9")) {
63 return "sparc";
64 } else if (cpu.equals("ia64") || cpu.equals("amd64") || cpu.equals("x86_64") || cpu.equals("ppc64")) {
65 return cpu;
66 } else {
67 try {
68 Class pic = Class.forName("sun.jvm.hotspot.utilities.PlatformInfoClosed");
69 AltPlatformInfo api = (AltPlatformInfo)pic.newInstance();
70 if (api.knownCPU(cpu)) {
71 return cpu;
72 }
73 } catch (Exception e) {}
74 throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported");
75 }
76 }
77
78 // this main is invoked from Makefile to make platform specific agent Makefile(s).
79 public static void main(String[] args) {
80 System.out.println(getOS());
81 }
82 }
|
44 } else if (os.equals("OpenBSD")) {
45 return "bsd";
46 } else if (os.contains("Darwin") || os.contains("OS X")) {
47 return "darwin";
48 } else if (os.startsWith("Windows")) {
49 return "win32";
50 } else {
51 throw new UnsupportedPlatformException("Operating system " + os + " not yet supported");
52 }
53 }
54
55 /* Returns "sparc" for SPARC based platforms and "x86" for x86 based
56 platforms. Otherwise returns the value of os.arch. If the value
57 is not recognized as supported, an exception is thrown instead. */
58 public static String getCPU() throws UnsupportedPlatformException {
59 String cpu = System.getProperty("os.arch");
60 if (cpu.equals("i386") || cpu.equals("x86")) {
61 return "x86";
62 } else if (cpu.equals("sparc") || cpu.equals("sparcv9")) {
63 return "sparc";
64 } else if (cpu.equals("ia64") || cpu.equals("amd64") || cpu.equals("x86_64") || cpu.equals("ppc64") || cpu.equals("aarch64")) {
65 return cpu;
66 } else {
67 try {
68 Class pic = Class.forName("sun.jvm.hotspot.utilities.PlatformInfoClosed");
69 AltPlatformInfo api = (AltPlatformInfo)pic.newInstance();
70 if (api.knownCPU(cpu)) {
71 return cpu;
72 }
73 } catch (Exception e) {}
74 throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported");
75 }
76 }
77
78 // this main is invoked from Makefile to make platform specific agent Makefile(s).
79 public static void main(String[] args) {
80 System.out.println(getOS());
81 }
82 }
|