Search in sources :

Example 21 with CIntPointer

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());
    }
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) WordBase(org.graalvm.word.WordBase) PinnedObject(org.graalvm.nativeimage.PinnedObject) ByteBuffer(java.nio.ByteBuffer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 22 with CIntPointer

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());
    }
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 23 with CIntPointer

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());
    }
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) PinnedObject(org.graalvm.nativeimage.PinnedObject) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 24 with CIntPointer

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());
    }
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) PinnedObject(org.graalvm.nativeimage.PinnedObject) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)24 Substitute (com.oracle.svm.core.annotate.Substitute)10 Socket (com.oracle.svm.core.posix.headers.Socket)7 SocketException (java.net.SocketException)7 ServerSocket (java.net.ServerSocket)6 PinnedObject (org.graalvm.nativeimage.PinnedObject)6 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)6 Util_java_io_FileDescriptor (com.oracle.svm.core.posix.PosixOSInterface.Util_java_io_FileDescriptor)5 FileDescriptor (java.io.FileDescriptor)5 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)4 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)4 IOException (java.io.IOException)3 InterruptedIOException (java.io.InterruptedIOException)3 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)2 InetAddress (java.net.InetAddress)2 SocketTimeoutException (java.net.SocketTimeoutException)2 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)2 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)2 SignedWord (org.graalvm.word.SignedWord)2 DIR (com.oracle.svm.core.posix.headers.Dirent.DIR)1