PageRenderTime 81ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/engine_java/000_Engine_Core/lib/JavaOpenAL/joal-1.1.2-src/gluegen/src/java/com/sun/gluegen/runtime/CPU.java

http://cellengine.googlecode.com/
Java | 81 lines | 31 code | 5 blank | 45 comment | 20 complexity | ef1f5baa088cc10a957edb3c589a3509 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, BSD-3-Clause, AGPL-3.0, LGPL-2.1, Apache-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0
  1. /*
  2. * Copyright (c) 2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc. 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 com.sun.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("linux") && cpu.equals("x86")) ||
  55. (os.startsWith("mac os") && cpu.equals("ppc")) ||
  56. (os.startsWith("mac os") && cpu.equals("i386")) ||
  57. (os.startsWith("sunos") && cpu.equals("sparc")) ||
  58. (os.startsWith("sunos") && cpu.equals("x86")) ||
  59. (os.startsWith("freebsd") && cpu.equals("i386")) ||
  60. (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
  61. is32Bit = true;
  62. } else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
  63. (os.startsWith("linux") && cpu.equals("amd64")) ||
  64. (os.startsWith("linux") && cpu.equals("x86_64")) ||
  65. (os.startsWith("linux") && cpu.equals("ia64")) ||
  66. (os.startsWith("mac os") && cpu.equals("x86_64")) ||
  67. (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
  68. (os.startsWith("sunos") && cpu.equals("amd64"))) {
  69. } else {
  70. throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
  71. }
  72. }
  73. public static boolean is32Bit() {
  74. return is32Bit;
  75. }
  76. }