Search in sources :

Example 16 with SignedWord

use of org.graalvm.word.SignedWord in project graal by oracle.

the class PosixJavaLangSubstitutions method readEntirely.

static SignedWord readEntirely(int fd, PointerBase buf, UnsignedWord count) {
    Pointer ptr = WordFactory.pointer(buf.rawValue());
    final Pointer end = ptr.add(count);
    SignedWord read;
    do {
        Errno.set_errno(0);
        read = Unistd.read(fd, ptr, end.subtract(ptr));
        if (read.equal(0)) {
            // EOF
            break;
        } else if (read.greaterThan(0)) {
            ptr = ptr.add((int) read.rawValue());
        }
    } while (ptr.notEqual(end) && (read.notEqual(-1) || Errno.errno() == Errno.EINTR()));
    if (ptr.notEqual(buf)) {
        return WordFactory.signed(ptr.rawValue() - buf.rawValue());
    }
    return read;
}
Also used : CIntPointer(org.graalvm.nativeimage.c.type.CIntPointer) CCharPointerPointer(org.graalvm.nativeimage.c.type.CCharPointerPointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) Dirent.direntPointer(com.oracle.svm.core.posix.headers.Dirent.direntPointer) Pointer(org.graalvm.word.Pointer) SignedWord(org.graalvm.word.SignedWord)

Aggregations

SignedWord (org.graalvm.word.SignedWord)16 IOException (java.io.IOException)9 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)7 Substitute (com.oracle.svm.core.annotate.Substitute)6 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)4 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)3 Pointer (org.graalvm.word.Pointer)3 UnsignedWord (org.graalvm.word.UnsignedWord)3 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)2 SubstrateObjectConstant (com.oracle.svm.core.meta.SubstrateObjectConstant)2 Dirent.direntPointer (com.oracle.svm.core.posix.headers.Dirent.direntPointer)2 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)2 Word (org.graalvm.compiler.word.Word)2 PinnedObject (org.graalvm.nativeimage.PinnedObject)2 Stat.fstat (com.oracle.svm.core.posix.headers.Stat.fstat)1 Stat.stat (com.oracle.svm.core.posix.headers.Stat.stat)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1