| java.lang.Object org.apache.harmony.luni.platform.OSComponent org.apache.harmony.luni.platform.OSMemory
OSMemory | final class OSMemory extends OSComponent implements IMemorySystem(Code) | | This class enables direct access to OS memory.
Methods that take OS addresses define such parameters as a Java
long . The long value is interpreted based on
the underlying platform pointer size, such that only the lowest significant
POINTER_SIZE bytes of the long value are used.
In practice this means that methods on 64-bit platforms use the full eight
bytes of the address parameter, and on 32-bit platforms the same methods are
truncated to use only the low four bytes.
Methods that return OS addresses define the return type to be a Java
long . If the platform pointer size is less than eight bytes
the OS address value is zero-extended to an eight-byte int to correspond to
the subsequent interpretation of that jlong as an OS address as defined
above.
|
Field Summary | |
final public static Endianness | NATIVE_ORDER Defines the natural byte order for this machine. | final public static int | POINTER_SIZE Defines the size, in bytes, of a native pointer type for the underlying
platform. |
Constructor Summary | |
| OSMemory() This class is not designed to be publically instantiated. |
Method Summary | |
public void | flush(long addr, long size) | native public void | free(long address) Deallocates space for a memory block that was previously allocated by a
call to
OSMemory.malloc(long) malloc(long) . | native public long | getAddress(long 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 ... | native public byte | getByte(long 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() .
Parameters: address - the platform address of the byte. | native public void | getByteArray(long 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 ... | native public double | getDouble(long 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 ... | public double | getDouble(long address, Endianness endianness) | native public float | getFloat(long 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 ... | public float | getFloat(long address, Endianness endianness) | native public int | getInt(long 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 ... | public int | getInt(long address, Endianness endianness) | native public long | getLong(long 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 ... | public long | getLong(long address, Endianness endianness) | public Endianness | getNativeOrder() Answers the natural byte order for this machine. | public static OSMemory | getOSMemory() | public int | getPointerSize() | native public short | getShort(long 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 ... | public short | getShort(long address, Endianness endianness) | public boolean | isLittleEndian() | native public static boolean | isLittleEndianImpl() Answers whether the byte order of this machine is little endian or not..
false for Big Endian, andtrue | public boolean | isLoaded(long addr, long size) | public void | load(long addr, long size) | public long | malloc(long length) Allocates and returns a pointer to space for a memory block of
length bytes. | native public void | memmove(long destAddress, long srcAddress, long length) Copies length bytes from srcAddress to
destAddress . | native public void | memset(long address, byte value, long length) Places value into first length bytes of the
memory block starting at address .
The behavior is unspecified if
(address ... | public long | mmap(long fileDescriptor, long alignment, long size, int mapMode) | native public void | setAddress(long address, long value) Sets the value of the platform pointer at the given address.
The length of the platform pointer is defined by
POINTER_SIZE . | native public void | setByte(long address, byte value) Sets the given single byte value at the given address. | native public void | setByteArray(long 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 ... | native public void | setDouble(long 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 ... | public void | setDouble(long address, double value, Endianness endianness) | native public void | setFloat(long 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 ... | public void | setFloat(long address, float value, Endianness endianness) | native public void | setInt(long 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 ... | public void | setInt(long address, int value, Endianness endianness) | native public void | setLong(long 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 ... | public void | setLong(long address, long value, Endianness endianness) | native public void | setShort(long 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 ... | public void | setShort(long address, short value, Endianness endianness) | public void | unmap(long addr, long size) |
NATIVE_ORDER | final public static Endianness NATIVE_ORDER(Code) | | Defines the natural byte order for this machine.
|
POINTER_SIZE | final public static int POINTER_SIZE(Code) | | Defines the size, in bytes, of a native pointer type for the underlying
platform. This will be 4 (for 32-bit machines) or 8 (for 64-bit
machines).
|
flush | public void flush(long addr, long size)(Code) | | |
free | native public void free(long address)(Code) | | Deallocates space for a memory block that was previously allocated by a
call to
OSMemory.malloc(long) malloc(long) . 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.
Parameters: address - the address of the memory block to deallocate. |
getAddress | native public long getAddress(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the platform pointer. the value of the platform pointer as a Java long . |
getByte | native public byte getByte(long address)(Code) | | 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() .
Parameters: address - the platform address of the byte. the byte value. |
getByteArray | native public void getByteArray(long address, byte[] bytes, int offset, int length) throws NullPointerException, IndexOutOfBoundsException(Code) | | 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
OSMemory.malloc(long) malloc(long) .
Parameters: address - the address of the OS memory block from which to copy bytes. Parameters: bytes - the byte array into which to copy the bytes. Parameters: offset - the index of the first element in bytes thatwill be overwritten. Parameters: length - the total number of bytes to copy into the byte array. throws: NullPointerException - if bytes is null . throws: IndexOutOfBoundsException - if offset + length > bytes.length . |
getDouble | native public double getDouble(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. the value of the eight-byte float as a Java double . |
getFloat | native public float getFloat(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. the value of the four-byte float as a Java float . |
getInt | native public int getInt(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the four-byte value. the value of the four-byte integer as a Java int . |
getLong | native public long getLong(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. the value of the eight-byte integer as a Java long . |
getNativeOrder | public Endianness getNativeOrder()(Code) | | Answers the natural byte order for this machine.
the native byte order for the current platform. |
getPointerSize | public int getPointerSize()(Code) | | |
getShort | native public short getShort(long address)(Code) | | 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() .
Parameters: address - the platform address of the start of the two-byte value. the value of the two-byte integer as a Java short . |
isLittleEndian | public boolean isLittleEndian()(Code) | | |
isLittleEndianImpl | native public static boolean isLittleEndianImpl()(Code) | | Answers whether the byte order of this machine is little endian or not..
false for Big Endian, andtrue |
isLoaded | public boolean isLoaded(long addr, long size)(Code) | | |
load | public void load(long addr, long size)(Code) | | |
malloc | public long malloc(long length) throws OutOfMemoryError(Code) | | 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 long.
Parameters: length - number of bytes requested. the address of the start of the memory block. throws: OutOfMemoryError - if the request cannot be satisfied. |
memmove | native public void memmove(long destAddress, long srcAddress, long length)(Code) | | 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() .
Parameters: destAddress - the address of the destination memory block. Parameters: srcAddress - the address of the source memory block. Parameters: length - the number of bytes to move. |
memset | native public void memset(long address, byte value, long length)(Code) | | 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() .
Parameters: address - the address of the first memory location. Parameters: value - the byte value to set at each location. Parameters: length - the number of byte-length locations to set. |
mmap | public long mmap(long fileDescriptor, long alignment, long size, int mapMode) throws IOException(Code) | | |
setAddress | native public void setAddress(long address, long value)(Code) | | 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() .
Parameters: address - the platform address of the start of the platform pointer. Parameters: value - the value of the platform pointer as a Java long . |
setByte | native public void setByte(long address, byte value)(Code) | | 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() .
Parameters: address - the address at which to set the byte value. Parameters: value - the value to set. |
setByteArray | native public void setByteArray(long address, byte[] bytes, int offset, int length) throws NullPointerException, IndexOutOfBoundsException(Code) | | 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
OSMemory.malloc(long) malloc(long) .
Parameters: address - the address of the OS memory block into which to copy thebytes. Parameters: bytes - the byte array from which to copy the bytes. Parameters: offset - the index of the first element in bytes thatwill be read. Parameters: length - the total number of bytes to copy from bytes into the memory block. throws: NullPointerException - if bytes is null . throws: IndexOutOfBoundsException - if offset + length > bytes.length . |
setDouble | native public void setDouble(long address, double value)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. Parameters: value - the value of the eight-byte float as a Javadouble . |
setDouble | public void setDouble(long address, double value, Endianness endianness)(Code) | | |
setFloat | native public void setFloat(long address, float value)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. Parameters: value - the value of the four-byte float as a Java float . |
setFloat | public void setFloat(long address, float value, Endianness endianness)(Code) | | |
setInt | native public void setInt(long address, int value)(Code) | | 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() .
Parameters: address - the platform address of the start of the four-byte value. Parameters: value - the value of the four-byte integer as a Java int . |
setLong | native public void setLong(long address, long value)(Code) | | 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() .
Parameters: address - the platform address of the start of the eight-byte value. Parameters: value - the value of the eight-byte integer as a Javalong . |
setLong | public void setLong(long address, long value, Endianness endianness)(Code) | | |
setShort | native public void setShort(long address, short value)(Code) | | 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() .
Parameters: address - the platform address of the start of the two-byte value. Parameters: value - the value of the two-byte integer as a Java short . |
setShort | public void setShort(long address, short value, Endianness endianness)(Code) | | |
unmap | public void unmap(long addr, long size)(Code) | | |
|
|