Does Address::getLong()
provide the digital representation of an address?
#979
-
I am working with TeaVM and trying to emulate a C structure in Java using struct S {
uint8_t *x;
size_t y;
}; This structure would occupy 16 bytes (assuming 64-bit pointers). In Java, I attempt to create a similar structure using // I have a buffer
byte[] buff = new byte[1024];
// Create ByteBuffer for the structure
ByteBuffer S = ByteBuffer.allocateDirect(16);
S.order(ByteOrder.nativeOrder());
// Populate the structure
S.putLong(0, (Address.ofData(buff)).getLong()); // Address as a long
S.putLong(8, (long) 1024); // Buffer length I am unsure whether the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sure, it's physical memory address, both in C and WebAssembly backends. However, note, that if you obtain |
Beta Was this translation helpful? Give feedback.
Sure, it's physical memory address, both in C and WebAssembly backends. However, note, that if you obtain
Address.ofData
, you can't rely on the fact that this is permanent address, since GC can move array into another location.