improvements

This commit is contained in:
lax1dude 2024-04-12 23:20:09 -07:00
parent 42dc2db970
commit a44dfb36e6
10 changed files with 1743 additions and 837 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2024 lax1dude
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package net.lax1dude.unsafememcpy;
public class UnsafeArrays {
static {
UnsafeUtils.loadNatives();
}
public static final int JNI_COMMIT = 1;
public static final int JNI_ABORT = 2;
public static native long getBooleanArrayElements(boolean[] array);
public static native long getByteArrayElements(byte[] array);
public static native long getCharArrayElements(char[] array);
public static native long getShortArrayElements(short[] array);
public static native long getIntArrayElements(int[] array);
public static native long getLongArrayElements(long[] array);
public static native long getFloatArrayElements(float[] array);
public static native long getDoubleArrayElements(double[] array);
public static native long getBooleanArrayElements(boolean[] array, boolean[] isCopy);
public static native long getByteArrayElements(byte[] array, boolean[] isCopy);
public static native long getCharArrayElements(char[] array, boolean[] isCopy);
public static native long getShortArrayElements(short[] array, boolean[] isCopy);
public static native long getIntArrayElements(int[] array, boolean[] isCopy);
public static native long getLongArrayElements(long[] array, boolean[] isCopy);
public static native long getFloatArrayElements(float[] array, boolean[] isCopy);
public static native long getDoubleArrayElements(double[] array, boolean[] isCopy);
public static native void releaseBooleanArrayElements(boolean[] array, long ptr, int mode);
public static native void releaseByteArrayElements(byte[] array, long ptr, int mode);
public static native void releaseCharArrayElements(char[] array, long ptr, int mode);
public static native void releaseShortArrayElements(short[] array, long ptr, int mode);
public static native void releaseIntArrayElements(int[] array, long ptr, int mode);
public static native void releaseLongArrayElements(long[] array, long ptr, int mode);
public static native void releaseFloatArrayElements(float[] array, long ptr, int mode);
public static native void releaseDoubleArrayElements(double[] array, long ptr, int mode);
}

View File

@ -36,326 +36,392 @@ public class UnsafeMemcpy {
public static native void memcpy(long dstAddress, long srcAddress, int byteLength);
public static native void memcpy(long dstAddress, long srcAddress, long byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(Buffer dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(short[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(char[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(int[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(double[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, long srcAddress, int byteLength);
public static native void memcpy(float[] dstAddress, long dstOffset, long srcAddress, long byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, long srcAddress, int length);
public static native void memcpy(long dstAddress, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, long dstOffset, Buffer srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, Buffer srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, byte[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, byte[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long dstAddress, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long dstAddress, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(short[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, short[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, short[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(long dstAddress, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(long dstAddress, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(char[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, char[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, char[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long dstAddress, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long dstAddress, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, int[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(int[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, long[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, int[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(long dstAddress, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(Buffer dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(long dstAddress, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(char[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, double[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long dstAddress, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(long[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(long dstAddress, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(Buffer dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(byte[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(byte[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(short[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(short[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, long[] srcAddress, int srcOffset, int length);
public static native void memcpy(char[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(long dstAddress, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(int[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long dstAddress, double[] srcAddress, int srcOffset, int length);
public static native void memcpy(int[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(long[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpy(long[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(double[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpy(double[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpy(float[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpy(float[] dstAddress, long dstOffset, float[] srcAddress, long srcOffset, long byteLength);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(double[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, double[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(long dstAddress, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long dstAddress, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(Buffer dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(Buffer dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(byte[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(byte[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(short[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(short[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(short[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(char[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(char[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(char[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(int[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(int[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(int[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(long[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(long[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(long[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(double[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAlignSrc(double[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(double[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyUnaligned(float[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int byteLength);
public static native void memcpyAligned(float[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignSrc(float[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
public static native void memcpyAlignDst(float[] dstAddress, int dstOffset, float[] srcAddress, int srcOffset, int length);
}

View File

@ -45,6 +45,11 @@ public class UnsafeUtils {
}else {
System.loadLibrary("unsafememcpy");
}
int major = getVersionMajor();
int minor = getVersionMinor();
if(major != 1 || minor < 0) {
throw new UnsatisfiedLinkError("Invalid UnsafeMemcpy native library version: " + major + "." + minor + " (expected: 1.0)");
}
}
}

267
native/UnsafeArrays.c Normal file
View File

@ -0,0 +1,267 @@
/*
* Copyright (c) 2024 lax1dude
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "UnsafeArraysImpl.h"
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getBooleanArrayElements
* Signature: ([Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getBooleanArrayElements___3Z
(JNIEnv * jniHandle, jclass jniClass, jbooleanArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jboolean, GetBooleanArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getByteArrayElements
* Signature: ([B)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getByteArrayElements___3B
(JNIEnv * jniHandle, jclass jniClass, jbyteArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jbyte, GetByteArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getCharArrayElements
* Signature: ([C)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getCharArrayElements___3C
(JNIEnv * jniHandle, jclass jniClass, jcharArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jchar, GetCharArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getShortArrayElements
* Signature: ([S)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getShortArrayElements___3S
(JNIEnv * jniHandle, jclass jniClass, jshortArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jshort, GetShortArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getIntArrayElements
* Signature: ([I)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getIntArrayElements___3I
(JNIEnv * jniHandle, jclass jniClass, jintArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jint, GetIntArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getLongArrayElements
* Signature: ([J)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getLongArrayElements___3J
(JNIEnv * jniHandle, jclass jniClass, jlongArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jlong, GetLongArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getFloatArrayElements
* Signature: ([F)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getFloatArrayElements___3F
(JNIEnv * jniHandle, jclass jniClass, jfloatArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jfloat, GetFloatArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getDoubleArrayElements
* Signature: ([D)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getDoubleArrayElements___3D
(JNIEnv * jniHandle, jclass jniClass, jdoubleArray array) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, jdouble, GetDoubleArrayElements);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getBooleanArrayElements
* Signature: ([Z[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getBooleanArrayElements___3Z_3Z
(JNIEnv * jniHandle, jclass jniClass, jbooleanArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jboolean, GetBooleanArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getByteArrayElements
* Signature: ([B[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getByteArrayElements___3B_3Z
(JNIEnv * jniHandle, jclass jniClass, jbyteArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jbyte, GetByteArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getCharArrayElements
* Signature: ([C[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getCharArrayElements___3C_3Z
(JNIEnv * jniHandle, jclass jniClass, jcharArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jchar, GetCharArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getShortArrayElements
* Signature: ([S[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getShortArrayElements___3S_3Z
(JNIEnv * jniHandle, jclass jniClass, jshortArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jshort, GetShortArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getIntArrayElements
* Signature: ([I[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getIntArrayElements___3I_3Z
(JNIEnv * jniHandle, jclass jniClass, jintArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jint, GetIntArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getLongArrayElements
* Signature: ([J[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getLongArrayElements___3J_3Z
(JNIEnv * jniHandle, jclass jniClass, jlongArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jlong, GetLongArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getFloatArrayElements
* Signature: ([F[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getFloatArrayElements___3F_3Z
(JNIEnv * jniHandle, jclass jniClass, jfloatArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jfloat, GetFloatArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: getDoubleArrayElements
* Signature: ([D[Z)J
*/
JNIEXPORT jlong JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_getDoubleArrayElements___3D_3Z
(JNIEnv * jniHandle, jclass jniClass, jdoubleArray array, jbooleanArray isCopy) {
UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, jdouble, GetDoubleArrayElements, isCopy);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseBooleanArrayElements
* Signature: ([ZJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseBooleanArrayElements
(JNIEnv * jniHandle, jclass jniClass, jbooleanArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jboolean, ReleaseBooleanArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseByteArrayElements
* Signature: ([BJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseByteArrayElements
(JNIEnv * jniHandle, jclass jniClass, jbyteArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jbyte, ReleaseByteArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseCharArrayElements
* Signature: ([CJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseCharArrayElements
(JNIEnv * jniHandle, jclass jniClass, jcharArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jchar, ReleaseCharArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseShortArrayElements
* Signature: ([SJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseShortArrayElements
(JNIEnv * jniHandle, jclass jniClass, jshortArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jshort, ReleaseShortArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseIntArrayElements
* Signature: ([IJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseIntArrayElements
(JNIEnv * jniHandle, jclass jniClass, jintArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jint, ReleaseIntArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseLongArrayElements
* Signature: ([JJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseLongArrayElements
(JNIEnv * jniHandle, jclass jniClass, jlongArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jlong, ReleaseLongArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseFloatArrayElements
* Signature: ([FJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseFloatArrayElements
(JNIEnv * jniHandle, jclass jniClass, jfloatArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jfloat, ReleaseFloatArrayElements, mode);
}
/*
* Class: net_lax1dude_unsafememcpy_UnsafeArrays
* Method: releaseDoubleArrayElements
* Signature: ([DJI)V
*/
JNIEXPORT void JNICALL Java_net_lax1dude_unsafememcpy_UnsafeArrays_releaseDoubleArrayElements
(JNIEnv * jniHandle, jclass jniClass, jdoubleArray array, jlong ptr, jint mode) {
UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, jdouble, ReleaseDoubleArrayElements, mode);
}

54
native/UnsafeArraysImpl.h Normal file
View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 lax1dude
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <jni.h>
#include "utils.h"
#define UNSAFE_ARRAYS_GET_ELEMENTS_IMPL(jniHandle, array, elementType, getElementsFunction)\
elementType* srcArray = (*jniHandle)->getElementsFunction(jniHandle, array, NULL);\
if(!srcArray) {\
unsafeThrowOutOfMemory(jniHandle);\
return 0;\
}\
return (jlong)srcArray;\
#define UNSAFE_ARRAYS_GET_ELEMENTS_IMPL_IS_COPY(jniHandle, array, elementType, getElementsFunction, isCopy)\
jboolean wasCopied;\
elementType* srcArray = (*jniHandle)->getElementsFunction(jniHandle, array, NULL);\
if(isCopy) {\
(*jniHandle)->SetBooleanArrayRegion(jniHandle, isCopy, 0, 1, &wasCopied);\
}\
if(!srcArray) {\
unsafeThrowOutOfMemory(jniHandle);\
return 0;\
}\
return (jlong)srcArray;\
#define UNSAFE_ARRAYS_RELEASE_ELEMENTS_IMPL(jniHandle, array, ptr, elementType, releaseElementsFunction, mode)\
(*jniHandle)->releaseElementsFunction(jniHandle, array, (elementType*)ptr, mode);

40
native/UnsafeMallocImpl.h Normal file
View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 lax1dude
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <jni.h>
#include <stdlib.h>
#include "utils.h"
#define UNSAFE_MALLOC_IMPL(size) malloc((size_t)(size))
#define UNSAFE_CALLOC_IMPL(num, size) calloc((size_t)(num), (size_t)(size))
#define UNSAFE_REALLOC_IMPL(address, size) realloc((void*)(address), (size_t)(size))
#define UNSAFE_FREE_IMPL(address) free((void*)(address))

File diff suppressed because it is too large Load Diff

View File

@ -32,9 +32,12 @@
#include "utils.h"
// =============== UNALIGNED VERSIONS ===============
#define UNSAFE_MEMCPY_IMPL(dst, src, len) memcpy((void*)(dst), (const void*)(src), (size_t)(len))
#define UNSAFE_MEMCPY_ARRAY_TO_NATIVE_IMPL(jniHandle, dstAddress, srcAddress, srcOffset, byteLength)\
#define UNSAFE_MEMCPY_ARRAY_TO_NATIVE_IMPL(jniHandle, dstAddress, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, byteLength)\
uint64_t srcArray = (uint64_t)(*jniHandle)->GetPrimitiveArrayCritical(jniHandle, srcAddress, NULL);\
if(!srcArray) {\
unsafeThrowOutOfMemory(jniHandle);\
@ -72,7 +75,7 @@
}\
UNSAFE_MEMCPY_IMPL(dstBuffer + dstOffset, srcBuffer + srcOffset, byteLength);
#define UNSAFE_MEMCPY_ARRAY_TO_BUFFER_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, srcOffset, byteLength)\
#define UNSAFE_MEMCPY_ARRAY_TO_BUFFER_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, byteLength)\
uint64_t dstBuffer = (uint64_t)(*jniHandle)->GetDirectBufferAddress(jniHandle, dstAddress);\
if(!dstBuffer) {\
unsafeThrowNotDirectBuffer(jniHandle);\
@ -86,7 +89,7 @@
UNSAFE_MEMCPY_IMPL(dstBuffer + dstOffset, srcArray + srcOffset, byteLength);\
(*jniHandle)->ReleasePrimitiveArrayCritical(jniHandle, srcAddress, (void*)srcArray, JNI_ABORT);
#define UNSAFE_MEMCPY_NATIVE_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, byteLength)\
#define UNSAFE_MEMCPY_NATIVE_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, byteLength)\
uint64_t dstArray = (uint64_t)(*jniHandle)->GetPrimitiveArrayCritical(jniHandle, dstAddress, NULL);\
if(!dstArray) {\
unsafeThrowOutOfMemory(jniHandle);\
@ -95,7 +98,7 @@
UNSAFE_MEMCPY_IMPL(dstArray + dstOffset, srcAddress, byteLength);\
(*jniHandle)->ReleasePrimitiveArrayCritical(jniHandle, dstAddress, (void*)dstArray, JNI_COMMIT);
#define UNSAFE_MEMCPY_BUFFER_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, srcOffset, byteLength)\
#define UNSAFE_MEMCPY_BUFFER_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, byteLength)\
uint64_t srcBuffer = (uint64_t)(*jniHandle)->GetDirectBufferAddress(jniHandle, srcAddress);\
if(!srcBuffer) {\
unsafeThrowNotDirectBuffer(jniHandle);\
@ -109,7 +112,7 @@
UNSAFE_MEMCPY_IMPL(dstArray + dstOffset, srcBuffer + srcOffset, byteLength);\
(*jniHandle)->ReleasePrimitiveArrayCritical(jniHandle, dstAddress, (void*)dstArray, JNI_COMMIT);
#define UNSAFE_MEMCPY_ARRAY_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, srcOffset, byteLength)\
#define UNSAFE_MEMCPY_ARRAY_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, byteLength)\
uint64_t srcArray = (uint64_t)(*jniHandle)->GetPrimitiveArrayCritical(jniHandle, srcAddress, NULL);\
if(!srcArray) {\
unsafeThrowOutOfMemory(jniHandle);\
@ -124,3 +127,58 @@
UNSAFE_MEMCPY_IMPL(dstArray + dstOffset, srcArray + srcOffset, byteLength);\
(*jniHandle)->ReleasePrimitiveArrayCritical(jniHandle, dstAddress, (void*)dstArray, JNI_COMMIT);\
(*jniHandle)->ReleasePrimitiveArrayCritical(jniHandle, srcAddress, (void*)srcArray, JNI_ABORT);
// =============== ALIGNED SRC VERSIONS ===============
#define UNSAFE_MEMCPY_ARRAY_ALIGN_TO_NATIVE_IMPL(jniHandle, dstAddress, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, length, srcGetRegionFunction)\
(*jniHandle)->srcGetRegionFunction(jniHandle, srcAddress, srcOffset, length, (srcType*)dstAddress);
#define UNSAFE_MEMCPY_ARRAY_ALIGN_TO_BUFFER_IMPL(jniHandle, dstAddress, dstOffset, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, length, srcGetRegionFunction)\
uint64_t dstBuffer = (uint64_t)(*jniHandle)->GetDirectBufferAddress(jniHandle, dstAddress);\
if(!dstBuffer) {\
unsafeThrowNotDirectBuffer(jniHandle);\
return;\
}\
(*jniHandle)->srcGetRegionFunction(jniHandle, srcAddress, srcOffset, length, (srcType*)(dstBuffer + dstOffset));
#define UNSAFE_MEMCPY_ARRAY_ALIGN_TO_ARRAY_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, length, srcGetRegionFunction)\
uint64_t dstArray = (uint64_t)(*jniHandle)->dstGetElements(jniHandle, dstAddress, NULL);\
if(!dstArray) {\
unsafeThrowOutOfMemory(jniHandle);\
return;\
}\
(*jniHandle)->srcGetRegionFunction(jniHandle, srcAddress, srcOffset, length, (srcType*)(dstArray + dstOffset));\
(*jniHandle)->dstReleaseElements(jniHandle, dstAddress, (dstType*)dstArray, JNI_COMMIT);\
// =============== ALIGNED DST VERSIONS ===============
#define UNSAFE_MEMCPY_NATIVE_TO_ARRAY_ALIGN_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, length, dstSetRegionFunction)\
(*jniHandle)->dstSetRegionFunction(jniHandle, dstAddress, dstOffset, length, (const dstType*)srcAddress);
#define UNSAFE_MEMCPY_BUFFER_TO_ARRAY_ALIGN_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, length, dstSetRegionFunction)\
uint64_t srcBuffer = (uint64_t)(*jniHandle)->GetDirectBufferAddress(jniHandle, srcAddress);\
if(!srcBuffer) {\
unsafeThrowNotDirectBuffer(jniHandle);\
return;\
}\
(*jniHandle)->dstSetRegionFunction(jniHandle, dstAddress, dstOffset, length, (const dstType*)(srcBuffer + srcOffset));
#define UNSAFE_MEMCPY_ARRAY_TO_ARRAY_ALIGN_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, length, dstSetRegionFunction)\
uint64_t srcArray = (uint64_t)(*jniHandle)->srcGetElements(jniHandle, srcAddress, NULL);\
if(!srcArray) {\
unsafeThrowOutOfMemory(jniHandle);\
return;\
}\
(*jniHandle)->dstSetRegionFunction(jniHandle, dstAddress, dstOffset, length, (const dstType*)(srcArray + srcOffset));\
(*jniHandle)->srcReleaseElements(jniHandle, srcAddress, (void*)srcArray, JNI_ABORT);
// =============== FULLY ALIGNED VERSIONS ===============
#define UNSAFE_MEMCPY_ARRAY_ALIGN_TO_ARRAY_ALIGN_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, srcOffset, srcType, srcGetElements, srcReleaseElements, length, srcGetRegionFunction, dstSetRegionFunction)\
UNSAFE_MEMCPY_ARRAY_TO_ARRAY_ALIGN_IMPL(jniHandle, dstAddress, dstOffset, dstType, dstGetElements, dstReleaseElements, srcAddress, (srcOffset * (jsize)sizeof(srcType)), srcType, srcGetElements, srcReleaseElements, length, dstSetRegionFunction)