Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG_ |
static int |
KILOBYTE |
static int |
MEGABYTE |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
Object |
createDataArray(Object templ,
int numElements)
Create an array of a particular type.
|
void |
formatSize(Address buffer,
int size)
Pretty print a size, converting from bytes to kilo- or mega-bytes as appropriate
|
Address |
formatSize(String format,
int bufsize,
int size)
Pretty print a size, converting from bytes to kilo- or mega-bytes as appropriate
|
void |
free(Address addr)
Free an array of bytes previously allocated with malloc
|
Address |
getBytes(String str)
Convert a String to a 0-terminated array of bytes
WARNING: we call out to String.length and String.charAt, both of
which are interruptible.
|
Address |
malloc(int size)
Allocate an array of bytes with malloc
|
int |
sprintf(Address str,
Address format,
Address value)
sprintf(char *str, char *format, char* value) |
dumpRange, numToBytes, numToBytes
private static final boolean DEBUG_
public static final int KILOBYTE
public static final int MEGABYTE
public Util()
public final Address malloc(int size)
Util
malloc
in class Util
size
- The size to allocateUtil.free(org.vmmagic.unboxed.Address)
public final void free(Address addr)
Util
free
in class Util
addr
- The address of some memory previously allocated with mallocUtil.malloc(int)
public final Address getBytes(String str)
WARNING: we call out to String.length and String.charAt, both of which are interruptible. We protect these calls with a swLock/swUnlock mechanism, as per VM.sysWrite on String.
public final void formatSize(Address buffer, int size)
Util
formatSize
in class Util
buffer
- The buffer (in C space) in which to place the formatted sizesize
- The size in bytespublic final Address formatSize(String format, int bufsize, int size)
Util
formatSize
in class Util
format
- A format stringbufsize
- The size of a buffer large enough to hold the formatted resultsize
- The size in bytespublic Object createDataArray(Object templ, int numElements)
Util
Foo[] x = (Foo [])Stream.createDataArray(new Foo[0], numElements);
createDataArray
in class Util
templ
- a data array to use as a templatenumElements
- number of elements in new array