src/java.base/windows/native/libnio/ch/nio_util.h
author michaelm
Tue, 29 Oct 2019 19:55:34 +0000
branchunixdomainchannels
changeset 58848 c3df0f8b6d93
parent 58801 119ac9128c1b
permissions -rw-r--r--
second part of cleanup reducing number of files touched in main line
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54154
1caf2daef7cf 8220738: (sc) Move ServerSocketChannelImpl remaining native method to Net
alanb
parents: 47216
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
22604
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    26
#include <winsock2.h>
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    27
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
5804
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    30
/**
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    31
 * The maximum buffer size for WSASend/WSARecv. Microsoft recommendation for
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    32
 * blocking operations is to use buffers no larger than 64k. We need the
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    33
 * maximum to be less than 128k to support asynchronous close on Windows
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    34
 * Server 2003 and newer editions of Windows.
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    35
 */
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    36
#define MAX_BUFFER_SIZE             ((128*1024)-1)
faf9bd47d6ce 6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents: 5506
diff changeset
    37
58848
c3df0f8b6d93 second part of cleanup reducing number of files touched in main line
michaelm
parents: 58801
diff changeset
    38
jint fdval(JNIEnv *env, jobject fdo);
c3df0f8b6d93 second part of cleanup reducing number of files touched in main line
michaelm
parents: 58801
diff changeset
    39
void setfdval(JNIEnv *env, jobject fdo, jint val);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
jlong handleval(JNIEnv *env, jobject fdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
jint convertReturnVal(JNIEnv *env, jint n, jboolean r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd);
58848
c3df0f8b6d93 second part of cleanup reducing number of files touched in main line
michaelm
parents: 58801
diff changeset
    44
jint handleSocketError(JNIEnv *env, int errorValue);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#ifdef _WIN64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
struct iovec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    jlong  iov_base;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    jint  iov_len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
struct iovec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    jint  iov_base;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    jint  iov_len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#endif
22604
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    61
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    62
#ifndef POLLIN
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    63
    /* WSAPoll()/WSAPOLLFD and the corresponding constants are only defined   */
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    64
    /* in Windows Vista / Windows Server 2008 and later. If we are on an      */
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    65
    /* older release we just use the Solaris constants as this was previously */
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    66
    /* done in PollArrayWrapper.java.                                         */
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    67
    #define POLLIN       0x0001
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    68
    #define POLLOUT      0x0004
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    69
    #define POLLERR      0x0008
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    70
    #define POLLHUP      0x0010
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    71
    #define POLLNVAL     0x0020
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    72
    #define POLLCONN     0x0002
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    73
#else
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    74
    /* POLLCONN must not equal any of the other constants (see winsock2.h).   */
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    75
    #define POLLCONN     0x2000
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 14342
diff changeset
    76
#endif