3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00

Fix several issues with JNI compression

The libraries will require a recompile.
Dieser Commit ist enthalten in:
Andrew Steinborn 2022-06-08 00:53:15 -04:00
Ursprung 04d3ed6820
Commit 01c6777948
3 geänderte Dateien mit 12 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -27,7 +27,7 @@ Java_com_velocitypowered_natives_compression_NativeZlibDeflate_free(JNIEnv *env,
libdeflate_free_compressor((struct libdeflate_compressor *) ctx);
}
JNIEXPORT jboolean JNICALL
JNIEXPORT jlong JNICALL
Java_com_velocitypowered_natives_compression_NativeZlibDeflate_process(JNIEnv *env,
jclass clazz,
jlong ctx,

Datei anzeigen

@ -70,11 +70,13 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor {
destinationAddress, destination.writableBytes());
if (produced > 0) {
destination.writerIndex(destination.writerIndex() + produced);
return;
}
break;
} else if (produced == 0) {
// Insufficient room - enlarge the buffer.
destination.capacity(destination.capacity() * 2);
} else {
throw new DataFormatException("libdeflate returned unknown code " + produced);
}
}
}

Datei anzeigen

@ -39,7 +39,8 @@ public class NativeConstraints {
// HotSpot on Intel macOS prefers x86_64, but OpenJ9 on macOS and HotSpot/OpenJ9 elsewhere
// give amd64.
IS_AMD64 = osArch.equals("amd64") || osArch.equals("x86_64");
IS_AARCH64 = osArch.equals("aarch64");
IS_AARCH64 = osArch.equals("aarch64") || osArch.equals("arm64");
System.out.println(System.getProperty("os.name", ""));
}
static final BooleanSupplier NATIVE_BASE = () -> NATIVES_ENABLED && CAN_GET_MEMORYADDRESS;
@ -52,6 +53,7 @@ public class NativeConstraints {
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
&& IS_AARCH64;
static final BooleanSupplier JAVA_11 = () -> Double.parseDouble(
System.getProperty("java.specification.version")) >= 11;
static final BooleanSupplier MACOS_AARCH64 = () -> NATIVE_BASE.getAsBoolean()
&& System.getProperty("os.name", "").equalsIgnoreCase("Mac OS X")
&& IS_AARCH64;
}