PageRenderTime 59ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/carrot-jdk6-jnlp-macosx/src/plugin/share/classes/sun/plugin2/gluegen/runtime/CPU.java

https://github.com/carrot-garden/carrot-jnlper
Java | 79 lines | 29 code | 5 blank | 45 comment | 18 complexity | 17bc471f511a8c99874814d429910745 MD5 | raw file
  1. /*
  2. * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * - Redistribution of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * - Redistribution in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * Neither the name of Oracle or the names of
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * This software is provided "AS IS," without a warranty of any kind. ALL
  20. * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
  21. * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
  22. * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
  23. * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
  24. * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  25. * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
  26. * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
  27. * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
  28. * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
  29. * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
  30. * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  31. *
  32. * You acknowledge that this software is not designed or intended for use
  33. * in the design, construction, operation or maintenance of any nuclear
  34. * facility.
  35. *
  36. * Sun gratefully acknowledges that this software was originally authored
  37. * and developed by Kenneth Bradley Russell and Christopher John Kline.
  38. */
  39. package sun.plugin2.gluegen.runtime;
  40. /** Provides information to autogenerated struct accessors about what
  41. kind of data model (32- or 64-bit) is being used by the currently
  42. running process. */
  43. public class CPU {
  44. private static boolean is32Bit;
  45. static {
  46. // We don't seem to need an AccessController.doPrivileged() block
  47. // here as these system properties are visible even to unsigned
  48. // applets
  49. // Note: this code is replicated in StructLayout.java
  50. String os = System.getProperty("os.name").toLowerCase();
  51. String cpu = System.getProperty("os.arch").toLowerCase();
  52. if ((os.startsWith("windows") && cpu.equals("x86")) ||
  53. (os.startsWith("linux") && cpu.equals("i386")) ||
  54. (os.startsWith("mac os") && cpu.equals("ppc")) ||
  55. (os.startsWith("mac os") && cpu.equals("i386")) ||
  56. (os.startsWith("sunos") && cpu.equals("sparc")) ||
  57. (os.startsWith("sunos") && cpu.equals("x86")) ||
  58. (os.startsWith("freebsd") && cpu.equals("i386")) ||
  59. (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
  60. is32Bit = true;
  61. } else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
  62. (os.startsWith("linux") && cpu.equals("amd64")) ||
  63. (os.startsWith("linux") && cpu.equals("x86_64")) ||
  64. (os.startsWith("linux") && cpu.equals("ia64")) ||
  65. (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
  66. (os.startsWith("sunos") && cpu.equals("amd64"))) {
  67. } else {
  68. throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
  69. }
  70. }
  71. public static boolean is32Bit() {
  72. return is32Bit;
  73. }
  74. }