13
0
geforkt von Mirrors/Velocity

Check for AARCH64.

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-06-04 15:03:27 -04:00
Ursprung bb69481f99
Commit 31d1871bd5
2 geänderte Dateien mit 16 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -7,6 +7,7 @@ import java.util.function.BooleanSupplier;
public class NativeConstraints { public class NativeConstraints {
private static final boolean NATIVES_ENABLED = !Boolean.getBoolean("velocity.natives-disabled"); private static final boolean NATIVES_ENABLED = !Boolean.getBoolean("velocity.natives-disabled");
private static final boolean IS_AMD64; private static final boolean IS_AMD64;
private static final boolean IS_AARCH64;
private static final boolean CAN_GET_MEMORYADDRESS; private static final boolean CAN_GET_MEMORYADDRESS;
static { static {
@ -21,15 +22,23 @@ public class NativeConstraints {
// HotSpot on Intel macOS prefers x86_64, but OpenJ9 on macOS and HotSpot/OpenJ9 elsewhere // HotSpot on Intel macOS prefers x86_64, but OpenJ9 on macOS and HotSpot/OpenJ9 elsewhere
// give amd64. // give amd64.
IS_AMD64 = osArch.equals("amd64") || osArch.equals("x86_64"); IS_AMD64 = osArch.equals("amd64") || osArch.equals("x86_64");
IS_AARCH64 = osArch.equals("aarch64");
} }
static final BooleanSupplier LINUX = () -> { static final BooleanSupplier NATIVE_BASE = () -> NATIVES_ENABLED && CAN_GET_MEMORYADDRESS;
return NATIVES_ENABLED
&& CAN_GET_MEMORYADDRESS static final BooleanSupplier LINUX_X86_64 = () -> {
return NATIVE_BASE.getAsBoolean()
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux") && System.getProperty("os.name", "").equalsIgnoreCase("Linux")
&& IS_AMD64; && IS_AMD64;
}; };
static final BooleanSupplier LINUX_AARCH64 = () -> {
return NATIVE_BASE.getAsBoolean()
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
&& IS_AARCH64;
};
static final BooleanSupplier JAVA_11 = () -> { static final BooleanSupplier JAVA_11 = () -> {
return Double.parseDouble(System.getProperty("java.specification.version")) >= 11; return Double.parseDouble(System.getProperty("java.specification.version")) >= 11;
}; };

Datei anzeigen

@ -62,11 +62,11 @@ public class Natives {
public static final NativeCodeLoader<VelocityCompressorFactory> compress = new NativeCodeLoader<>( public static final NativeCodeLoader<VelocityCompressorFactory> compress = new NativeCodeLoader<>(
ImmutableList.of( ImmutableList.of(
new NativeCodeLoader.Variant<>(NativeConstraints.LINUX, new NativeCodeLoader.Variant<>(NativeConstraints.LINUX_X86_64,
copyAndLoadNative("/linux_x86_64/velocity-compress.so"), copyAndLoadNative("/linux_x86_64/velocity-compress.so"),
"libdeflate (Linux x86_64)", "libdeflate (Linux x86_64)",
LibdeflateVelocityCompressor.FACTORY), LibdeflateVelocityCompressor.FACTORY),
new NativeCodeLoader.Variant<>(NativeConstraints.LINUX, new NativeCodeLoader.Variant<>(NativeConstraints.LINUX_AARCH64,
copyAndLoadNative("/linux_aarch64/velocity-compress.so"), copyAndLoadNative("/linux_aarch64/velocity-compress.so"),
"libdeflate (Linux aarch64)", "libdeflate (Linux aarch64)",
LibdeflateVelocityCompressor.FACTORY), LibdeflateVelocityCompressor.FACTORY),
@ -79,10 +79,10 @@ public class Natives {
public static final NativeCodeLoader<VelocityCipherFactory> cipher = new NativeCodeLoader<>( public static final NativeCodeLoader<VelocityCipherFactory> cipher = new NativeCodeLoader<>(
ImmutableList.of( ImmutableList.of(
new NativeCodeLoader.Variant<>(NativeConstraints.LINUX, new NativeCodeLoader.Variant<>(NativeConstraints.LINUX_X86_64,
copyAndLoadNative("/linux_x86_64/velocity-cipher.so"), copyAndLoadNative("/linux_x86_64/velocity-cipher.so"),
"mbed TLS (Linux x86_64)", NativeVelocityCipher.FACTORY), "mbed TLS (Linux x86_64)", NativeVelocityCipher.FACTORY),
new NativeCodeLoader.Variant<>(NativeConstraints.LINUX, new NativeCodeLoader.Variant<>(NativeConstraints.LINUX_AARCH64,
copyAndLoadNative("/linux_aarch64/velocity-cipher.so"), copyAndLoadNative("/linux_aarch64/velocity-cipher.so"),
"mbed TLS (Linux aarch64)", NativeVelocityCipher.FACTORY), "mbed TLS (Linux aarch64)", NativeVelocityCipher.FACTORY),
new NativeCodeLoader.Variant<>(NativeCodeLoader.ALWAYS, () -> { new NativeCodeLoader.Variant<>(NativeCodeLoader.ALWAYS, () -> {