arch-add-ports
authorOpenJDK Team <openjdk-21@packages.debian.org>
Mon, 9 Sep 2024 13:29:08 +0000 (15:29 +0200)
committerMatthias Klose <doko@ubuntu.com>
Mon, 9 Sep 2024 13:29:08 +0000 (15:29 +0200)
Gbp-Pq: Name arch-add-ports.diff

src/java.base/share/classes/jdk/internal/util/Architecture.java
src/java.base/share/classes/jdk/internal/util/PlatformProps.java.template
test/jdk/jdk/internal/util/ArchTest.java

index 5c86190274378226673c68be61e13420367bd9d2..0743206379e59e98dc3ac27e131bb6bc26d1809d 100644 (file)
@@ -46,6 +46,13 @@ public enum Architecture {
     LOONGARCH64(64, ByteOrder.LITTLE_ENDIAN),
     MIPSEL(32, ByteOrder.LITTLE_ENDIAN),
     MIPS64EL(64, ByteOrder.LITTLE_ENDIAN),
+    ALPHA(64, ByteOrder.LITTLE_ENDIAN),
+    ARC(32, ByteOrder.LITTLE_ENDIAN),
+    HPPA(32, ByteOrder.BIG_ENDIAN),
+    IA64(64, ByteOrder.LITTLE_ENDIAN),
+    M68K(32, ByteOrder.BIG_ENDIAN),
+    SH(32, ByteOrder.LITTLE_ENDIAN),
+    X32(32, ByteOrder.LITTLE_ENDIAN),
     OTHER(is64bit() ? 64 : 32, ByteOrder.nativeOrder()),
     PPC(32, ByteOrder.BIG_ENDIAN),
     PPC64(64, ByteOrder.BIG_ENDIAN),
@@ -180,6 +187,69 @@ public enum Architecture {
         return PlatformProps.TARGET_ARCH_IS_PPC64LE;
     }
 
+    /**
+     * {@return {@code true} if the current architecture is ALPHA}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isALPHA() {
+        return PlatformProps.TARGET_ARCH_IS_ALPHA;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is ARC}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isARC() {
+        return PlatformProps.TARGET_ARCH_IS_ARC;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is HPPA}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isHPPA() {
+        return PlatformProps.TARGET_ARCH_IS_HPPA;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is IA64}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isIA64() {
+        return PlatformProps.TARGET_ARCH_IS_IA64;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is X32}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isX32() {
+        return PlatformProps.TARGET_ARCH_IS_X32;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is SH}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isSH() {
+        return PlatformProps.TARGET_ARCH_IS_SH;
+    }
+
+    /**
+     * {@return {@code true} if the current architecture is M68K}
+     * Use {@link #isLittleEndian()} to determine big or little endian.
+     */
+    @ForceInline
+    public static boolean isM68K() {
+        return PlatformProps.TARGET_ARCH_IS_M68K;
+    }
+
     /**
      * {@return {@code true} if the current architecture is ARM}
      */
index 9c2a2c84511fc0b57ff72563544e57190eb95604..d40958a86dc856bc86a448b811ec495ab3ba9103 100644 (file)
@@ -65,5 +65,12 @@ class PlatformProps {
     static final boolean TARGET_ARCH_IS_SPARCV9 = "@@OPENJDK_TARGET_CPU@@" == "sparcv9";
     static final boolean TARGET_ARCH_IS_X86     = "@@OPENJDK_TARGET_CPU@@" == "x86";
     static final boolean TARGET_ARCH_IS_X64     = "@@OPENJDK_TARGET_CPU@@" == "x64";
+    static final boolean TARGET_ARCH_IS_ALPHA   = "@@OPENJDK_TARGET_CPU@@" == "alpha";
+    static final boolean TARGET_ARCH_IS_ARC     = "@@OPENJDK_TARGET_CPU@@" == "arc";
+    static final boolean TARGET_ARCH_IS_HPPA    = "@@OPENJDK_TARGET_CPU@@" == "hppa";
+    static final boolean TARGET_ARCH_IS_IA64    = "@@OPENJDK_TARGET_CPU@@" == "ia64";
+    static final boolean TARGET_ARCH_IS_M68K    = "@@OPENJDK_TARGET_CPU@@" == "m68k";
+    static final boolean TARGET_ARCH_IS_SH      = "@@OPENJDK_TARGET_CPU@@" == "sh";
+    static final boolean TARGET_ARCH_IS_X32     = "@@OPENJDK_TARGET_CPU@@" == "x32";
 
 }
index 8097eabe89229e6f056b2cfc6b9261ad4e7612f8..516a8a678a3340cba12aea27ff46da92700c5c9d 100644 (file)
@@ -41,6 +41,13 @@ import static jdk.internal.util.Architecture.S390;
 import static jdk.internal.util.Architecture.SPARCV9;
 import static jdk.internal.util.Architecture.X64;
 import static jdk.internal.util.Architecture.X86;
+import static jdk.internal.util.Architecture.ALPHA;
+import static jdk.internal.util.Architecture.ARC;
+import static jdk.internal.util.Architecture.HPPA;
+import static jdk.internal.util.Architecture.IA64;
+import static jdk.internal.util.Architecture.SH;
+import static jdk.internal.util.Architecture.X32;
+import static jdk.internal.util.Architecture.M68K;
 
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -91,7 +98,14 @@ public class ArchTest {
                 Arguments.of("sparcv9", SPARCV9, 64, ByteOrder.BIG_ENDIAN, Architecture.isSPARCV9()),
                 Arguments.of("x64", X64, 64, ByteOrder.LITTLE_ENDIAN, Architecture.isX64()),
                 Arguments.of("x86", X86, 32, ByteOrder.LITTLE_ENDIAN, Architecture.isX86()),
-                Arguments.of("x86_64", X64, 64, ByteOrder.LITTLE_ENDIAN, Architecture.isX64())
+                Arguments.of("x86_64", X64, 64, ByteOrder.LITTLE_ENDIAN, Architecture.isX64()),
+                Arguments.of("alpha", ALPHA, 64, ByteOrder.LITTLE_ENDIAN, Architecture.isALPHA()),
+                Arguments.of("arc", ARC, 32, ByteOrder.LITTLE_ENDIAN, Architecture.isARC()),
+                Arguments.of("hppa", HPPA, 32, ByteOrder.BIG_ENDIAN, Architecture.isHPPA()),
+                Arguments.of("ia64", IA64, 64, ByteOrder.LITTLE_ENDIAN, Architecture.isIA64()),
+                Arguments.of("m68k", M68K, 32, ByteOrder.BIG_ENDIAN, Architecture.isM68K()),
+                Arguments.of("sh", SH, 32, ByteOrder.LITTLE_ENDIAN, Architecture.isSH()),
+                Arguments.of("x32", X32, 32, ByteOrder.LITTLE_ENDIAN, Architecture.isX32())
         );
     }