Skip to content
Snippets Groups Projects
Commit 9bf512d9 authored by brinn's avatar brinn
Browse files

add: NativeData.getNativeByteOrder()

SVN: 15627
parent 27aeb39e
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
VCPPDIR=C:\Program Files\Microsoft Visual Studio 8\VC VCPPDIR=C:\Program Files\Microsoft Visual Studio 8\VC
# Directory where JDK is installed (We require JDK 1.5 or above), for example # Directory where JDK is installed (We require JDK 1.5 or above), for example
JAVADIR=C:\Program Files\Java\jdk1.5.0_15 JAVADIR=C:\Program Files\Java\jdk1.5.0_22
# Common parent directory # Common parent directory
PARENTDIR=C:\nativeData PARENTDIR=C:\nativeData
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
#============================================================================ #============================================================================
# Visual C++ directory, for example # Visual C++ directory, for example
VCPPDIR=C:\Program Files\Microsoft Visual Studio 8\VC VCPPDIR=C:\Program Files (x86)\Microsoft Visual Studio 8\VC
# Directory where JDK is installed (We require JDK 1.5 or above), for example # Directory where JDK is installed (We require JDK 1.5 or above), for example
JAVADIR=C:\Program Files\Java\jdk1.5.0_15 JAVADIR=C:\Program Files\Java\jdk1.5.0_22
# Common parent directory # Common parent directory
PARENTDIR=C:\nativeData PARENTDIR=C:\nativeData
......
...@@ -20,6 +20,17 @@ extern "C" { ...@@ -20,6 +20,17 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include "jni.h" #include "jni.h"
/*
* public static native boolean isLittleEndian();
*/
JNIEXPORT jboolean JNICALL Java_ch_systemsx_cisd_base_convert_NativeData_isLittleEndian
(JNIEnv *env,
jclass clss
)
{
return MACHINE_BYTE_ORDER == 1;
}
/* /*
* A fatal error in a JNI call * A fatal error in a JNI call
* Create and throw an 'InternalError' * Create and throw an 'InternalError'
......
...@@ -66,6 +66,12 @@ public class NativeData ...@@ -66,6 +66,12 @@ public class NativeData
BIG_ENDIAN, BIG_ENDIAN,
} }
/**
* Returns <code>true</code> if this platform is a little-endian platform and <code>false</code>
* , if it is a big-endian platform.
*/
static native boolean isLittleEndian();
/** /**
* Copies a range from an array of <code>int</code> into an array of <code>byte</code>. * Copies a range from an array of <code>int</code> into an array of <code>byte</code>.
* *
...@@ -234,6 +240,14 @@ public class NativeData ...@@ -234,6 +240,14 @@ public class NativeData
public static void ensureNativeLibIsLoaded() public static void ensureNativeLibIsLoaded()
{ {
} }
/**
* Returns the native byte order of the host running this JRE.
*/
public static ByteOrder getNativeByteOrder()
{
return isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
}
/** /**
* Converts a <code>byte[]</code> array into a <code>short[]</code> array. * Converts a <code>byte[]</code> array into a <code>short[]</code> array.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment