mirror of
https://github.com/PaperMC/Velocity.git
synced 2024-11-21 03:11:38 +08:00
Fix several issues with JNI compression
The libraries will require a recompile.
This commit is contained in:
parent
04d3ed6820
commit
01c6777948
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// Insufficient room - enlarge the buffer.
|
||||
destination.capacity(destination.capacity() * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user