Methods Summary |
---|
public void | flush(int addr, long size)
flushImpl(addr, size);
|
private native int | flushImpl(int l, long size)
|
public native void | free(int address)Deallocates space for a memory block that was previously allocated by a
call to {@link #malloc(int) malloc(int)}. The number of bytes freed is
identical to the number of bytes acquired when the memory block was
allocated. If address is zero the method does nothing.
Freeing a pointer to a memory block that was not allocated by
malloc() has unspecified effect.
|
public native int | getAddress(int address)Gets the value of the platform pointer at the given address.
The length of the platform pointer is defined by
POINTER_SIZE .
The behavior is unspecified if
(address ... address + POINTER_SIZE) is not wholly within
the range that was previously allocated using malloc() .
|
public native byte | getByte(int address)Gets the value of the single byte at the given address.
The behavior is unspecified if address is not in the range
that was previously allocated using malloc() .
|
public native void | getByteArray(int address, byte[] bytes, int offset, int length)Copies length bytes from the memory block at
address into the byte array bytes starting
at element offset within the byte array.
The behavior of this method is undefined if the range
(address ... address + length) is not within a memory
block that was allocated using {@link #malloc(int) malloc(int)}.
|
public native double | getDouble(int address)Gets the value of the IEEE754-format eight-byte float stored in platform
byte order at the given address.
The behavior is unspecified if (address ... address + 8)
is not wholly within the range that was previously allocated using
malloc() .
|
public double | getDouble(int address, Endianness endianness)
if (endianness == NATIVE_ORDER) {
return getDouble(address);
}
long doubleBits = swap(getLong(address));
return Double.longBitsToDouble(doubleBits);
|
public native float | getFloat(int address)Gets the value of the IEEE754-format four-byte float stored in platform
byte order at the given address.
The behavior is unspecified if (address ... address + 4)
is not wholly within the range that was previously allocated using
malloc() .
|
public float | getFloat(int address, Endianness endianness)
if (endianness == NATIVE_ORDER) {
return getFloat(address);
}
int floatBits = swap(getInt(address));
return Float.intBitsToFloat(floatBits);
|
public native int | getInt(int address)Gets the value of the signed four-byte integer stored in platform
byte-order at the given address.
The behavior is unspecified if (address ... address + 4)
is not wholly within the range that was previously allocated using
malloc() .
|
public int | getInt(int address, Endianness endianness)
return (endianness == NATIVE_ORDER) ? getInt(address)
: swap(getInt(address));
|
public native long | getLong(int address)Gets the value of the signed eight-byte integer stored in platform byte
order at the given address.
The behavior is unspecified if (address ... address + 8)
is not wholly within the range that was previously allocated using
malloc() .
|
public long | getLong(int address, Endianness endianness)
return (endianness == NATIVE_ORDER) ? getLong(address)
: swap(getLong(address));
|
public Endianness | getNativeOrder()Returns the natural byte order for this machine.
return NATIVE_ORDER;
|
public static org.apache.harmony.luni.platform.OSMemory | getOSMemory()
POINTER_SIZE = getPointerSizeImpl();
if (isLittleEndianImpl()) {
NATIVE_ORDER = Endianness.LITTLE_ENDIAN;
} else {
NATIVE_ORDER = Endianness.BIG_ENDIAN;
}
return singleton;
|
public int | getPointerSize()
return POINTER_SIZE;
|
private static native int | getPointerSizeImpl()Returns the size of a native pointer type for the underlying platform.
|
public native short | getShort(int address)Gets the value of the signed two-byte integer stored in platform byte
order at the given address.
The behavior is unspecified if (address ... address + 2)
is not wholly within the range that was previously allocated using
malloc() .
|
public short | getShort(int address, Endianness endianness)
return (endianness == NATIVE_ORDER) ? getShort(address)
: swap(getShort(address));
|
public boolean | isLittleEndian()
return isLittleEndianImpl();
|
private static native boolean | isLittleEndianImpl()Returns whether the byte order of this machine is little endian or not..
|
public boolean | isLoaded(int addr, long size)
return size == 0 ? true : isLoadedImpl(addr, size);
|
private native boolean | isLoadedImpl(int l, long size)
|
public void | load(int addr, long size)
loadImpl(addr, size);
|
private native int | loadImpl(int l, long size)
|
public native int | malloc(int length)Allocates and returns a pointer to space for a memory block of
length bytes. The space is uninitialized and may be larger
than the number of bytes requested; however, the guaranteed usable memory
block is exactly length bytes int.
|
public native void | memmove(int destAddress, int srcAddress, long length)Copies length bytes from srcAddress to
destAddress . Where any part of the source memory block
and the destination memory block overlap memmove() ensures
that the original source bytes in the overlapping region are copied
before being overwritten.
The behavior is unspecified if
(srcAddress ... srcAddress + length) and
(destAddress ... destAddress + length) are not both wholly
within the range that was previously allocated using
malloc() .
|
public native void | memset(int address, byte value, long length)Places value into first length bytes of the
memory block starting at address .
The behavior is unspecified if
(address ... address + length) is not wholly within the
range that was previously allocated using malloc() .
|
public int | mmap(int fileDescriptor, long alignment, long size, int mapMode)
int address = mmapImpl(fileDescriptor, alignment, size, mapMode);
if (address == -1) {
throw new IOException();
}
return address;
|
private native int | mmapImpl(int fileDescriptor, long alignment, long size, int mapMode)
|
public native void | setAddress(int address, int value)Sets the value of the platform pointer at the given address.
The length of the platform pointer is defined by
POINTER_SIZE . This method only sets
POINTER_SIZE bytes at the given address.
The behavior is unspecified if
(address ... address + POINTER_SIZE) is not wholly within
the range that was previously allocated using malloc() .
|
public native void | setByte(int address, byte value)Sets the given single byte value at the given address.
The behavior is unspecified if address is not in the range
that was previously allocated using malloc() .
|
public native void | setByteArray(int address, byte[] bytes, int offset, int length)Copies length bytes from the byte array bytes
into the memory block at address , starting at element
offset within the byte array.
The behavior of this method is undefined if the range
(address ... address + length) is not within a memory
block that was allocated using {@link #malloc(int) malloc(int)}.
|
public native void | setDouble(int address, double value)Sets the value of the IEEE754-format eight-byte float store in platform
byte order at the given address.
The behavior is unspecified if (address ... address + 8)
is not wholly within the range that was previously allocated using
malloc() .
|
public void | setDouble(int address, double value, Endianness endianness)
if (endianness == NATIVE_ORDER) {
setDouble(address, value);
} else {
long doubleBits = Double.doubleToLongBits(value);
setLong(address, swap(doubleBits));
}
|
public native void | setFloat(int address, float value)Sets the value of the IEEE754-format four-byte float stored in platform
byte order at the given address.
The behavior is unspecified if (address ... address + 4)
is not wholly within the range that was previously allocated using
malloc() .
|
public void | setFloat(int address, float value, Endianness endianness)
if (endianness == NATIVE_ORDER) {
setFloat(address, value);
} else {
int floatBits = Float.floatToIntBits(value);
setInt(address, swap(floatBits));
}
|
public native void | setInt(int address, int value)Sets the value of the signed four-byte integer at the given address in
platform byte order.
The behavior is unspecified if (address ... address + 4)
is not wholly within the range that was previously allocated using
malloc() .
|
public void | setInt(int address, int value, Endianness endianness)
if (endianness == NATIVE_ORDER) {
setInt(address, value);
} else {
setInt(address, swap(value));
}
|
public native void | setIntArray(int address, int[] ints, int offset, int length, boolean swap)Copies length ints from the int array ints
into the memory block at address , starting at element
offset within the int array.
The behavior of this method is undefined if the range
(address ... address + 2*length) is not within a memory
block that was allocated using {@link #malloc(int) malloc(int)}.
|
public native void | setLong(int address, long value)Sets the value of the signed eight-byte integer at the given address in
the platform byte order.
The behavior is unspecified if (address ... address + 8)
is not wholly within the range that was previously allocated using
malloc() .
|
public void | setLong(int address, long value, Endianness endianness)
if (endianness == NATIVE_ORDER) {
setLong(address, value);
} else {
setLong(address, swap(value));
}
|
public native void | setShort(int address, short value)Sets the value of the signed two-byte integer at the given address in
platform byte order.
The behavior is unspecified if (address ... address + 2)
is not wholly within the range that was previously allocated using
malloc() .
|
public void | setShort(int address, short value, Endianness endianness)
if (endianness == NATIVE_ORDER) {
setShort(address, value);
} else {
setShort(address, swap(value));
}
|
public native void | setShortArray(int address, short[] shorts, int offset, int length, boolean swap)Copies length shorts from the short array shorts
into the memory block at address , starting at element
offset within the short array.
The behavior of this method is undefined if the range
(address ... address + 2*length) is not within a memory
block that was allocated using {@link #malloc(int) malloc(int)}.
|
private short | swap(short value)
int topEnd = value << 8;
int btmEnd = (value >> 8) & 0xFF;
return (short) (topEnd | btmEnd);
|
private int | swap(int value)
short left = (short) (value >> 16);
short right = (short) value;
int topEnd = swap(right) << 16;
int btmEnd = swap(left) & 0xFFFF;
return topEnd | btmEnd;
|
private long | swap(long value)
int left = (int) (value >> 32);
int right = (int) value;
long topEnd = ((long) swap(right)) << 32;
long btmEnd = swap(left) & 0xFFFFFFFFL;
return topEnd | btmEnd;
|
public void | unmap(int addr, long size)
unmapImpl(addr, size);
|
private native void | unmapImpl(int addr, long size)
|