You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to call madvise on a MappedByteBuffer via JNR-FFI.
According to the man page, both the pointer address and the size need to be page aligned but I am not sure how to do that using FFI? I can call long address = MemoryIO.getInstance().getDirectBufferAddress(buffer); but unsure how to use it in my interface to madvise how do I pass a long as a void pointer?
I can validate that my method fails if I hard code a negative size, but I am having a hard time parsing what FFI is doing to get the buffer address and whether it is already aligned the way I would do it in c?
The text was updated successfully, but these errors were encountered:
public interface NativeC {
int madvise(@size_t long address, @size_t long size, int advice);
int getpagesize();
}
...
long address = MemoryIO.getInstance().getDirectBufferAddress(buffer);
long alignedAddress = alignedAddress(address);
long alignedSize = alignedSize(alignedAddress, buffer.capacity());
int val = nativeC.madvise(alignedAddress, alignedSize, advice.value);
Trying to call madvise on a MappedByteBuffer via JNR-FFI.
According to the man page, both the pointer address and the size need to be page aligned but I am not sure how to do that using FFI? I can call
long address = MemoryIO.getInstance().getDirectBufferAddress(buffer);
but unsure how to use it in my interface to madvise how do I pass a long as a void pointer?I can validate that my method fails if I hard code a negative size, but I am having a hard time parsing what FFI is doing to get the buffer address and whether it is already aligned the way I would do it in c?
The text was updated successfully, but these errors were encountered: