use of org.graalvm.nativeimage.c.type.CIntPointer in project graal by oracle.
the class NativeClosure method invokeClosureBufferRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureBufferRet(@SuppressWarnings("unused") ffi_cif cif, Pointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
NativeClosure closure = lookup(user);
ByteBuffer retBuffer = closure.createRetBuffer(ret);
Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches patches = (Target_com_oracle_truffle_nfi_impl_LibFFIClosure_RetPatches) closure.call(args, retBuffer);
if (patches != null) {
for (int i = 0; i < patches.count; i++) {
Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag tag = getTag(patches.patches[i]);
int offset = getOffset(patches.patches[i]);
Object obj = patches.objects[i];
if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.OBJECT) {
WordBase handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj);
ret.writeWord(offset, handle);
} else if (tag == Target_com_oracle_truffle_nfi_impl_NativeArgumentBuffer_TypeTag.STRING) {
ret.writeWord(offset, serializeStringRet(obj));
} else {
// nothing to do
}
}
}
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of org.graalvm.nativeimage.c.type.CIntPointer in project graal by oracle.
the class NativeClosure method invokeClosureVoidRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureVoidRet(@SuppressWarnings("unused") ffi_cif cif, @SuppressWarnings("unused") WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
lookup(user).call(args, null);
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of org.graalvm.nativeimage.c.type.CIntPointer in project graal by oracle.
the class NativeClosure method invokeClosureObjectRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureObjectRet(@SuppressWarnings("unused") ffi_cif cif, WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
Object obj = lookup(user).call(args, null);
if (obj == null) {
ret.write(WordFactory.zero());
} else {
TruffleObjectHandle handle = ImageSingletons.lookup(TruffleNFISupport.class).createGlobalHandle(obj);
ret.write(handle);
}
} finally {
Errno.set_errno(errnoMirror.read());
}
}
use of org.graalvm.nativeimage.c.type.CIntPointer in project graal by oracle.
the class NativeClosure method invokeClosureStringRet.
@CEntryPoint
@CEntryPointOptions(prologue = EnterClosureDataIsolatePrologue.class, publishAs = Publish.NotPublished, include = CEntryPointOptions.NotIncludedAutomatically.class)
static void invokeClosureStringRet(@SuppressWarnings("unused") ffi_cif cif, WordPointer ret, WordPointer args, ClosureData user) {
CIntPointer errnoMirror = ErrnoMirror.getErrnoMirrorLocation();
errnoMirror.write(Errno.errno());
try {
Object retValue = lookup(user).call(args, null);
ret.write(serializeStringRet(retValue));
} finally {
Errno.set_errno(errnoMirror.read());
}
}
Aggregations