JNIEXPORT jlong JNICALL
Java_sun_nio_ch_IOUtil_writevMax(JNIEnv *env, jclass this)
{ #ifdefined(MACOSX) || defined(__linux__) // // The man pages of writev() on both Linux and macOS specify this // constraint on the sum of all byte lengths in the iovec array: // // [EINVAL] The sum of the iov_len values in the iov array // overflows a 32-bit integer. // // As of macOS 11 Big Sur, Darwin version 20, writev() started to // actually enforce the constraint which had been previously ignored. // // In practice on Linux writev() has been observed not to write more // than 0x7fff0000 (aarch64) or 0x7ffff000 (x64) bytes in one call. // return java_lang_Integer_MAX_VALUE; #else return java_lang_Long_MAX_VALUE; #endif
}
/* Declared in nio_util.h for use elsewhere in NIO */
jint
convertReturnVal(JNIEnv *env, jint n, jboolean reading)
{ if (n > 0) /* Number of bytes written */ return n; elseif (n == 0) { if (reading) { return IOS_EOF; /* EOF is -1 in javaland */
} else { return0;
}
} elseif (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; elseif (errno == EINTR) return IOS_INTERRUPTED; else { constchar *msg = reading ? "Read failed" : "Write failed";
JNU_ThrowIOExceptionWithLastError(env, msg); return IOS_THROWN;
}
}
/* Declared in nio_util.h for use elsewhere in NIO */
jlong
convertLongReturnVal(JNIEnv *env, jlong n, jboolean reading)
{ if (n > 0) /* Number of bytes written */ return n; elseif (n == 0) { if (reading) { return IOS_EOF; /* EOF is -1 in javaland */
} else { return0;
}
} elseif (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; elseif (errno == EINTR) return IOS_INTERRUPTED; else { constchar *msg = reading ? "Read failed" : "Write failed";
JNU_ThrowIOExceptionWithLastError(env, msg); return IOS_THROWN;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.