use of java.nio.ByteOrder in project robovm by robovm.
the class ByteOrderTest method testNativeOrder.
public void testNativeOrder() {
ByteOrder o = ByteOrder.nativeOrder();
assertTrue(o == ByteOrder.BIG_ENDIAN || o == ByteOrder.LITTLE_ENDIAN);
}
use of java.nio.ByteOrder in project jdk8u_jdk by JetBrains.
the class ImageInputStreamImpl method readUTF.
public String readUTF() throws IOException {
this.bitOffset = 0;
// Fix 4494369: method ImageInputStreamImpl.readUTF()
// does not work as specified (it should always assume
// network byte order).
ByteOrder oldByteOrder = getByteOrder();
setByteOrder(ByteOrder.BIG_ENDIAN);
String ret;
try {
ret = DataInputStream.readUTF(this);
} catch (IOException e) {
// Restore the old byte order even if an exception occurs
setByteOrder(oldByteOrder);
throw e;
}
setByteOrder(oldByteOrder);
return ret;
}
use of java.nio.ByteOrder in project jdk8u_jdk by JetBrains.
the class AbstractPerfDataBufferPrologue method getMagic.
/**
* Get the magic number from the given byteBuffer.
*
* @return int - the magic number
*/
public static int getMagic(ByteBuffer bb) {
// save buffer state
int position = bb.position();
ByteOrder order = bb.order();
// the magic number is always stored in big-endian format
bb.order(ByteOrder.BIG_ENDIAN);
bb.position(PERFDATA_PROLOG_MAGIC_OFFSET);
int magic = bb.getInt();
// restore buffer state.
bb.order(order);
bb.position(position);
return magic;
}
use of java.nio.ByteOrder in project ignite by apache.
the class MurmurHash method hash64A.
/**
* @param buf The data to hash.
* @param seed The seed to start with.
*/
public static long hash64A(ByteBuffer buf, int seed) {
ByteOrder byteOrder = buf.order();
buf.order(ByteOrder.LITTLE_ENDIAN);
long m = 0xc6a4a7935bd1e995L;
int r = 47;
long h = seed ^ (buf.remaining() * m);
while (buf.remaining() >= 8) {
long k = buf.getLong();
k *= m;
k ^= k >>> r;
k *= m;
h ^= k;
h *= m;
}
if (buf.remaining() > 0) {
ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
finish.put(buf).rewind();
h ^= finish.getLong();
h *= m;
}
h ^= h >>> r;
h *= m;
h ^= h >>> r;
buf.order(byteOrder);
return h;
}
use of java.nio.ByteOrder in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerSecondHalf.
private void lowerSecondHalf(UnpackEndianHalfNode n) {
ByteOrder byteOrder = target.arch.getByteOrder();
n.lower(byteOrder);
}
Aggregations