1 /*
   2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_WINDOWS_VM_HPI_WINDOWS_HPP
  26 #define OS_WINDOWS_VM_HPI_WINDOWS_HPP
  27 
  28 // Win32 delegates these to the HPI.  Solaris provides its own
  29 // implementation without using the HPI (for Interrupitble I/O).
  30 
  31 // HPI_FileInterface
  32 
  33 HPIDECL(close, "close", _file, Close, int, "%d",
  34         (int fd),
  35         ("fd = %d", fd),
  36         (fd));
  37 
  38 HPIDECL(read, "read", _file, Read, size_t, "%ld",
  39         (int fd, void *buf, unsigned int nBytes),
  40         ("fd = %d, buf = %p, nBytes = %u", fd, buf, nBytes),
  41         (fd, buf, nBytes));
  42 
  43 HPIDECL(write, "write", _file, Write, size_t, "%ld",
  44         (int fd, const void *buf, unsigned int nBytes),
  45         ("fd = %d, buf = %p, nBytes = %u", fd, buf, nBytes),
  46         (fd, buf, nBytes));
  47 
  48 
  49 // HPI_SocketInterface
  50 
  51 HPIDECL(socket_close, "socket_close", _socket, Close, int, "%d",
  52         (int fd),
  53         ("fd = %d", fd),
  54         (fd));
  55 
  56 HPIDECL(socket_available, "socket_available", _socket, Available,
  57         int, "%d",
  58         (int fd, jint *pbytes),
  59         ("fd = %d, pbytes = %p", fd, pbytes),
  60         (fd, pbytes));
  61 
  62 HPIDECL(socket, "socket", _socket, Socket, int, "%d",
  63         (int domain, int type, int protocol),
  64         ("domain = %d, type = %d, protocol = %d", domain, type, protocol),
  65         (domain, type, protocol));
  66 
  67 HPIDECL(listen, "listen", _socket, Listen, int, "%d",
  68         (int fd, int count),
  69         ("fd = %d, count = %d", fd, count),
  70         (fd, count));
  71 
  72 HPIDECL(connect, "connect", _socket, Connect, int, "%d",
  73         (int fd, struct sockaddr *him, int len),
  74         ("fd = %d, him = %p, len = %d", fd, him, len),
  75         (fd, him, len));
  76 
  77 HPIDECL(accept, "accept", _socket, Accept, int, "%d",
  78         (int fd, struct sockaddr *him, int *len),
  79         ("fd = %d, him = %p, len = %p", fd, him, len),
  80         (fd, him, len));
  81 
  82 HPIDECL(sendto, "sendto", _socket, SendTo, int, "%d",
  83         (int fd, char *buf, int len, int flags,
  84          struct sockaddr *to, int tolen),
  85         ("fd = %d, buf = %p, len = %d, flags = %d, to = %p, tolen = %d",
  86          fd, buf, len, flags, to, tolen),
  87         (fd, buf, len, flags, to, tolen));
  88 
  89 HPIDECL(recvfrom, "recvfrom", _socket, RecvFrom, int, "%d",
  90         (int fd, char *buf, int nbytes, int flags,
  91          struct sockaddr *from, int *fromlen),
  92         ("fd = %d, buf = %p, len = %d, flags = %d, frm = %p, frmlen = %d",
  93          fd, buf, nbytes, flags, from, fromlen),
  94         (fd, buf, nbytes, flags, from, fromlen));
  95 
  96 HPIDECL(recv, "recv", _socket, Recv, int, "%d",
  97         (int fd, char *buf, int nBytes, int flags),
  98         ("fd = %d, buf = %p, nBytes = %d, flags = %d",
  99          fd, buf, nBytes, flags),
 100         (fd, buf, nBytes, flags));
 101 
 102 HPIDECL(send, "send", _socket, Send, int, "%d",
 103         (int fd, char *buf, int nBytes, int flags),
 104         ("fd = %d, buf = %p, nBytes = %d, flags = %d",
 105          fd, buf, nBytes, flags),
 106         (fd, buf, nBytes, flags));
 107 
 108 inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
 109   return send(fd, buf, nBytes, flags);
 110 }
 111 
 112 HPIDECL(timeout, "timeout", _socket, Timeout, int, "%d",
 113         (int fd, long timeout),
 114         ("fd = %d, timeout = %ld", fd, timeout),
 115         (fd, timeout));
 116 
 117 HPIDECL(get_host_by_name, "get_host_by_name", _socket, GetHostByName,
 118         struct hostent *, "(struct hostent *)%p",
 119         (char *name),
 120         ("%s", name),
 121         (name));
 122 
 123 HPIDECL(socket_shutdown, "socket_shutdown", _socket, SocketShutdown,
 124         int, "%d",
 125         (int fd, int howto),
 126         ("fd = %d, howto = %d", fd, howto),
 127         (fd, howto));
 128 
 129 HPIDECL(bind, "bind", _socket, Bind,
 130         int, "%d",
 131         (int fd, struct sockaddr *him, int len),
 132         ("fd = %d, him = %p, len = %d",
 133          fd, him, len),
 134         (fd, him, len));
 135 
 136 HPIDECL(get_sock_name, "get_sock_name", _socket, GetSocketName,
 137         int, "%d",
 138         (int fd, struct sockaddr *him, int *len),
 139         ("fd = %d, him = %p, len = %p",
 140          fd, him, len),
 141         (fd, him, len));
 142 
 143 HPIDECL(get_host_name, "get_host_name", _socket, GetHostName, int, "%d",
 144         (char *hostname, int namelen),
 145         ("hostname = %p, namelen = %d",
 146          hostname, namelen),
 147         (hostname, namelen));
 148 
 149 HPIDECL(get_host_by_addr, "get_host_by_addr", _socket, GetHostByAddr,
 150         struct hostent *, "(struct hostent *)%p",
 151         (const char* name, int len, int type),
 152         ("name = %p, len = %d, type = %d",
 153          name, len, type),
 154         (name, len, type));
 155 
 156 HPIDECL(get_sock_opt, "get_sock_opt", _socket, SocketGetOption, int, "%d",
 157         (int fd, int level, int optname, char *optval, int* optlen),
 158         ("fd = %d, level = %d, optname = %d, optval = %p, optlen = %p",
 159          fd, level, optname, optval, optlen),
 160         (fd, level, optname, optval, optlen));
 161 
 162 HPIDECL(set_sock_opt, "set_sock_opt", _socket, SocketSetOption, int, "%d",
 163         (int fd, int level, int optname, const char *optval, int optlen),
 164         ("fd = %d, level = %d, optname = %d, optval = %p, optlen = %d",
 165          fd, level, optname, optval, optlen),
 166         (fd, level, optname, optval, optlen));
 167 
 168 HPIDECL(get_proto_by_name, "get_proto_by_name", _socket, GetProtoByName,
 169         struct protoent *, "(struct protoent *)%p",
 170         (char* name),
 171         ("name = %p",
 172          name),
 173         (name));
 174 
 175 #endif // OS_WINDOWS_VM_HPI_WINDOWS_HPP