mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 14:37:43 +01:00
Even more renames, start hiding some API internals
This commit is contained in:
@@ -5,27 +5,38 @@ traditional Java fallbacks.
|
||||
|
||||
## Compression
|
||||
|
||||
* **Supported platforms**: Linux x86_64 and aarch64, with Java 11 `ByteBuffer` API support as a fallback.
|
||||
* **Supported platforms**: Linux x86_64 and aarch64, with Java 11 `ByteBuffer` API support as a
|
||||
fallback.
|
||||
Compiled on CentOS 7.
|
||||
* **Rationale**: Using a native zlib wrapper, we can avoid multiple trips into Java just to copy memory around.
|
||||
* **Rationale**: Using a native zlib wrapper, we can avoid multiple trips into Java just to copy
|
||||
memory around.
|
||||
|
||||
## Encryption
|
||||
|
||||
* **Supported platforms**: Linux x86_64 (OpenSSL 1.0.x and OpenSSL 1.1.x) and aarch64 (OpenSSL 1.1.x only)
|
||||
* **Rationale**: Using a C library for encryption means we can limit memory copies. Prior to Java 7, this was the only
|
||||
way to use AES-NI extensions on modern processors, but this is less important since JDK 8 has native support.
|
||||
* OpenSSL is not included in Velocity. Every distribution provides it now. To deal with ABI incompatibilities,
|
||||
the native library (which only calls into OpenSSL and contains no cryptographic code) are available for
|
||||
CentOS 7 (OpenSSL 1.0.0-based), Debian 9 (OpenSSL 1.1.0-based) and Debian Bookworm (OpenSSL 3.0.0-based)
|
||||
* **Supported platforms**: Linux x86_64 (OpenSSL 1.0.x and OpenSSL 1.1.x) and aarch64 (OpenSSL 1.1.x
|
||||
only)
|
||||
* **Rationale**: Using a C library for encryption means we can limit memory copies. Prior to Java 7,
|
||||
this was the only
|
||||
way to use AES-NI extensions on modern processors, but this is less important since JDK 8 has
|
||||
native support.
|
||||
* OpenSSL is not included in Velocity. Every distribution provides it now. To deal with ABI
|
||||
incompatibilities,
|
||||
the native library (which only calls into OpenSSL and contains no cryptographic code) are
|
||||
available for
|
||||
CentOS 7 (OpenSSL 1.0.0-based), Debian 9 (OpenSSL 1.1.0-based) and Debian Bookworm (OpenSSL
|
||||
3.0.0-based)
|
||||
to provide the widest, most reasonable compatibility with most modern distributions.
|
||||
|
||||
## OS support
|
||||
|
||||
The natives intend to have the widest possible range of compatibility with modern Linux distributions
|
||||
The natives intend to have the widest possible range of compatibility with modern Linux
|
||||
distributions
|
||||
(defined as those being released in or after 2014).
|
||||
|
||||
In theory, these libraries can be compiled for any Unix-like system (in the past, we supported macOS),
|
||||
In theory, these libraries can be compiled for any Unix-like system (in the past, we supported
|
||||
macOS),
|
||||
but interest in other systems is minimal at best, thus we focus on Linux x86_64 and aarch64 as they
|
||||
are commonly used platforms.
|
||||
|
||||
Alpine Linux support is on a "best-effort" basis only. Using `apk add libc6-compat` may enable native support.
|
||||
Alpine Linux support is on a "best-effort" basis only. Using `apk add libc6-compat` may enable
|
||||
native support.
|
||||
@@ -23,5 +23,6 @@ import com.velocitypowered.natives.util.BufferPreference;
|
||||
* Generic interface for any Velocity native.
|
||||
*/
|
||||
public interface Native {
|
||||
|
||||
BufferPreference preferredBufferType();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
class CompressorUtils {
|
||||
|
||||
/**
|
||||
* The default preferred output buffer size for zlib.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,6 @@ class NativeZlibInflate {
|
||||
|
||||
static native long free(long ctx);
|
||||
|
||||
static native boolean process(long ctx, long sourceAddress, int sourceLength,
|
||||
static native boolean process(long ctx, long sourceAddress, int sourceLength,
|
||||
long destinationAddress, int destinationLength) throws DataFormatException;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.zip.DataFormatException;
|
||||
* implementation.
|
||||
*/
|
||||
public interface VelocityCompressor extends Disposable, Native {
|
||||
|
||||
void inflate(ByteBuf source, ByteBuf destination, int uncompressedSize)
|
||||
throws DataFormatException;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class JavaVelocityCipher implements VelocityCipher {
|
||||
that the output buffer needs more bytes than the input buffer. When we are working with
|
||||
AES-CFB8, the output size is equal to the input size. See the problem? */
|
||||
throw new AssertionError("Cipher update did not operate in place and requested a larger "
|
||||
+ "buffer than the source buffer");
|
||||
+ "buffer than the source buffer");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
* Additional utilities for {@link ByteBuf}.
|
||||
*/
|
||||
public class MoreByteBufUtils {
|
||||
|
||||
private MoreByteBufUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
@@ -34,9 +35,9 @@ public class MoreByteBufUtils {
|
||||
* is called, you should decrement the reference count on the {@code buf} with
|
||||
* {@link ByteBuf#release()}.
|
||||
*
|
||||
* @param alloc the {@link ByteBufAllocator} to use
|
||||
* @param alloc the {@link ByteBufAllocator} to use
|
||||
* @param nativeStuff the native we are working with
|
||||
* @param buf the buffer we are working with
|
||||
* @param buf the buffer we are working with
|
||||
* @return a buffer compatible with the native
|
||||
*/
|
||||
public static ByteBuf ensureCompatible(ByteBufAllocator alloc, Native nativeStuff, ByteBuf buf) {
|
||||
@@ -70,8 +71,8 @@ public class MoreByteBufUtils {
|
||||
* Creates a {@link ByteBuf} that will have the best performance with the specified
|
||||
* {@code nativeStuff}.
|
||||
*
|
||||
* @param alloc the {@link ByteBufAllocator} to use
|
||||
* @param nativeStuff the native we are working with
|
||||
* @param alloc the {@link ByteBufAllocator} to use
|
||||
* @param nativeStuff the native we are working with
|
||||
* @param initialCapacity the initial capacity to allocate
|
||||
* @return a buffer compatible with the native
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.function.BooleanSupplier;
|
||||
* Statically-computed constraints for native code.
|
||||
*/
|
||||
public class NativeConstraints {
|
||||
|
||||
private static final boolean NATIVES_ENABLED = !Boolean.getBoolean("velocity.natives-disabled");
|
||||
private static final boolean IS_AMD64;
|
||||
private static final boolean IS_AARCH64;
|
||||
|
||||
@@ -125,7 +125,7 @@ public class Natives {
|
||||
new NativeCodeLoader.Variant<>(NativeConstraints.MACOS_AARCH64,
|
||||
copyAndLoadNative("/macos_arm64/velocity-cipher.dylib"),
|
||||
"native (macOS ARM64 / Apple Silicon)",
|
||||
NativeVelocityCipher.FACTORY),
|
||||
NativeVelocityCipher.FACTORY),
|
||||
|
||||
new NativeCodeLoader.Variant<>(NativeCodeLoader.ALWAYS, () -> {
|
||||
}, "Java", JavaVelocityCipher.FACTORY)
|
||||
|
||||
Reference in New Issue
Block a user