/* * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
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 { return 0;
}
} 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 { return 0;
}
} 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.