rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / runtime / openjdk-24 / patches / illumos-port-21.patch
blob232a7477df20e1103d9d6dc3935119d056d88e59
1 --- a/src/java.base/solaris/classes/sun/nio/ch/FileDispatcherImpl.java Mon Oct 10 20:08:47 2022
2 +++ b/src/java.base/solaris/classes/sun/nio/ch/FileDispatcherImpl.java Mon Oct 10 19:39:09 2022
3 @@ -0,0 +1,45 @@
4 +/*
5 + * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 + *
8 + * This code is free software; you can redistribute it and/or modify it
9 + * under the terms of the GNU General Public License version 2 only, as
10 + * published by the Free Software Foundation. Oracle designates this
11 + * particular file as subject to the "Classpath" exception as provided
12 + * by Oracle in the LICENSE file that accompanied this code.
13 + *
14 + * This code is distributed in the hope that it will be useful, but WITHOUT
15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 + * version 2 for more details (a copy is included in the LICENSE file that
18 + * accompanied this code).
19 + *
20 + * You should have received a copy of the GNU General Public License version
21 + * 2 along with this work; if not, write to the Free Software Foundation,
22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 + *
24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25 + * or visit www.oracle.com if you need additional information or have any
26 + * questions.
27 + */
29 +package sun.nio.ch;
31 +import java.io.FileDescriptor;
33 +class FileDispatcherImpl extends UnixFileDispatcherImpl {
34 + FileDispatcherImpl() {
35 + super();
36 + }
38 + long transferTo(FileDescriptor src, long position, long count,
39 + FileDescriptor dst, boolean append) {
40 + return transferTo0(src, position, count, dst, append);
41 + }
43 + // -- Native methods --
45 + static native long transferTo0(FileDescriptor src, long position,
46 + long count, FileDescriptor dst,
47 + boolean append);
49 --- a/src/java.base/solaris/native/libnio/ch/FileDispatcherImpl.c Mon Oct 10 20:09:47 2022
50 +++ b/src/java.base/solaris/native/libnio/ch/FileDispatcherImpl.c Mon Oct 10 19:39:25 2022
51 @@ -0,0 +1,72 @@
52 +/*
53 + * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
54 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 + *
56 + * This code is free software; you can redistribute it and/or modify it
57 + * under the terms of the GNU General Public License version 2 only, as
58 + * published by the Free Software Foundation. Oracle designates this
59 + * particular file as subject to the "Classpath" exception as provided
60 + * by Oracle in the LICENSE file that accompanied this code.
61 + *
62 + * This code is distributed in the hope that it will be useful, but WITHOUT
63 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
64 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
65 + * version 2 for more details (a copy is included in the LICENSE file that
66 + * accompanied this code).
67 + *
68 + * You should have received a copy of the GNU General Public License version
69 + * 2 along with this work; if not, write to the Free Software Foundation,
70 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
71 + *
72 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73 + * or visit www.oracle.com if you need additional information or have any
74 + * questions.
75 + */
77 +#include <sys/sendfile.h>
78 +#include <dlfcn.h>
80 +#include "jni.h"
81 +#include "nio.h"
82 +#include "nio_util.h"
83 +#include "sun_nio_ch_FileDispatcherImpl.h"
85 +JNIEXPORT jlong JNICALL
86 +Java_sun_nio_ch_FileDispatcherImpl_transferTo0(JNIEnv *env, jobject this,
87 + jobject srcFDO,
88 + jlong position, jlong count,
89 + jobject dstFDO, jboolean append)
91 + jint srcFD = fdval(env, srcFDO);
92 + jint dstFD = fdval(env, dstFDO);
94 + sendfilevec64_t sfv;
95 + size_t numBytes = 0;
96 + jlong result;
98 + sfv.sfv_fd = srcFD;
99 + sfv.sfv_flag = 0;
100 + sfv.sfv_off = (off64_t)position;
101 + sfv.sfv_len = count;
103 + result = sendfilev64(dstFD, &sfv, 1, &numBytes);
105 + /* Solaris sendfilev() will return -1 even if some bytes have been
106 + * transferred, so we check numBytes first.
107 + */
108 + if (numBytes > 0)
109 + return numBytes;
110 + if (result < 0) {
111 + if (errno == EAGAIN)
112 + return IOS_UNAVAILABLE;
113 + if (errno == EOPNOTSUPP)
114 + return IOS_UNSUPPORTED_CASE;
115 + if ((errno == EINVAL) && ((ssize_t)count >= 0))
116 + return IOS_UNSUPPORTED_CASE;
117 + if (errno == EINTR)
118 + return IOS_INTERRUPTED;
119 + JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
120 + return IOS_THROWN;
122 + return result;