annotate src/share/vm/runtime/hpi.hpp @ 1992:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children
rev   line source
duke@0 1 /*
stefank@1992 2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1563 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1563 20 * or visit www.oracle.com if you need additional information or have any
trims@1563 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1992 25 #ifndef SHARE_VM_RUNTIME_HPI_HPP
stefank@1992 26 #define SHARE_VM_RUNTIME_HPI_HPP
stefank@1992 27
stefank@1992 28 #include "prims/hpi_imported.h"
stefank@1992 29 #include "runtime/os.hpp"
stefank@1992 30 #include "utilities/globalDefinitions.hpp"
stefank@1992 31 #include "utilities/top.hpp"
stefank@1992 32
duke@0 33 //
duke@0 34 // C++ wrapper to HPI.
duke@0 35 //
duke@0 36
duke@0 37 class hpi : AllStatic {
duke@0 38
duke@0 39 private:
duke@0 40 static GetInterfaceFunc _get_interface;
duke@0 41 static HPI_FileInterface* _file;
duke@0 42 static HPI_SocketInterface* _socket;
duke@0 43 static HPI_LibraryInterface* _library;
duke@0 44 static HPI_SystemInterface* _system;
duke@0 45
duke@0 46 private:
duke@0 47 static void initialize_get_interface(vm_calls_t *callbacks);
duke@0 48
duke@0 49 public:
duke@0 50 // Load and initialize everything except sockets.
duke@0 51 static jint initialize();
duke@0 52
duke@0 53 // Socket library needs to be lazy intialized because eagerly
duke@0 54 // loading Winsock is known to cause "connect to your ISP"
duke@0 55 // dialog to show up. Or so goes the legend.
duke@0 56 static jint initialize_socket_library();
duke@0 57
duke@0 58 // HPI_FileInterface
duke@0 59 static inline char* native_path(char *path);
duke@0 60 static inline int file_type(const char *path);
duke@0 61 static inline int open(const char *name, int mode, int perm);
duke@0 62 static inline int close(int fd);
duke@0 63 static inline jlong lseek(int fd, jlong off, int whence);
duke@0 64 static inline int ftruncate(int fd, jlong length);
duke@0 65 static inline int fsync(int fd);
duke@0 66 static inline int available(int fd, jlong *bytes);
duke@0 67 static inline size_t read(int fd, void *buf, unsigned int nBytes);
duke@0 68 static inline size_t write(int fd, const void *buf, unsigned int nBytes);
duke@0 69 static inline int fsize(int fd, jlong *size);
duke@0 70
duke@0 71 // HPI_SocketInterface
duke@0 72 static inline int socket(int domain, int type, int protocol);
duke@0 73 static inline int socket_close(int fd);
duke@0 74 static inline int socket_shutdown(int fd, int howto);
duke@0 75 static inline int recv(int fd, char *buf, int nBytes, int flags);
duke@0 76 static inline int send(int fd, char *buf, int nBytes, int flags);
never@222 77 // Variant of send that doesn't support interruptible I/O
never@222 78 static inline int raw_send(int fd, char *buf, int nBytes, int flags);
duke@0 79 static inline int timeout(int fd, long timeout);
duke@0 80 static inline int listen(int fd, int count);
duke@0 81 static inline int connect(int fd, struct sockaddr *him, int len);
duke@0 82 static inline int bind(int fd, struct sockaddr *him, int len);
duke@0 83 static inline int accept(int fd, struct sockaddr *him, int *len);
duke@0 84 static inline int recvfrom(int fd, char *buf, int nbytes, int flags,
duke@0 85 struct sockaddr *from, int *fromlen);
duke@0 86 static inline int get_sock_name(int fd, struct sockaddr *him, int *len);
duke@0 87 static inline int sendto(int fd, char *buf, int len, int flags,
duke@0 88 struct sockaddr *to, int tolen);
duke@0 89 static inline int socket_available(int fd, jint *pbytes);
duke@0 90
duke@0 91 static inline int get_sock_opt(int fd, int level, int optname,
duke@0 92 char *optval, int* optlen);
duke@0 93 static inline int set_sock_opt(int fd, int level, int optname,
duke@0 94 const char *optval, int optlen);
duke@0 95 static inline int get_host_name(char* name, int namelen);
duke@0 96 static inline struct hostent* get_host_by_addr(const char* name, int len, int type);
duke@0 97 static inline struct hostent* get_host_by_name(char* name);
duke@0 98 static inline struct protoent* get_proto_by_name(char* name);
duke@0 99
duke@0 100 // HPI_LibraryInterface
phh@729 101 static inline void dll_build_name(char *buf, int buf_len, const char* path,
duke@0 102 const char *name);
duke@0 103 static inline void* dll_load(const char *name, char *ebuf, int ebuflen);
duke@0 104 static inline void dll_unload(void *lib);
duke@0 105 static inline void* dll_lookup(void *lib, const char *name);
duke@0 106
duke@0 107 // HPI_SystemInterface
duke@0 108 static inline int lasterror(char *buf, int len);
duke@0 109 };
duke@0 110
duke@0 111 //
duke@0 112 // Macros that provide inline bodies for the functions.
duke@0 113 //
duke@0 114
duke@0 115 #define HPIDECL(name, names, intf, func, ret_type, ret_fmt, arg_type, arg_print, arg) \
duke@0 116 inline ret_type hpi::name arg_type { \
duke@0 117 if (TraceHPI) { \
duke@0 118 tty->print("hpi::" names "("); \
duke@0 119 tty->print arg_print ; \
duke@0 120 tty->print(") = "); \
duke@0 121 } \
duke@0 122 ret_type result = (*intf->func) arg ; \
duke@0 123 if (TraceHPI) { \
duke@0 124 tty->print_cr(ret_fmt, result); \
duke@0 125 } \
duke@0 126 return result; \
duke@0 127 }
duke@0 128
duke@0 129 // Macro to facilitate moving HPI functionality into the vm.
duke@0 130 // See bug 6348631. The only difference between this macro and
duke@0 131 // HPIDECL is that we call a vm method rather than use the HPI
duke@0 132 // transfer vector. Ultimately, we'll replace HPIDECL with
duke@0 133 // VM_HPIDECL for all hpi methods.
duke@0 134 #define VM_HPIDECL(name, names, func, ret_type, ret_fmt, arg_type,arg_print, arg) \
duke@0 135 inline ret_type hpi::name arg_type { \
duke@0 136 if (TraceHPI) { \
duke@0 137 tty->print("hpi::" names "("); \
duke@0 138 tty->print arg_print ; \
duke@0 139 tty->print(") = "); \
duke@0 140 } \
duke@0 141 ret_type result = func arg ; \
duke@0 142 if (TraceHPI) { \
duke@0 143 tty->print_cr(ret_fmt, result); \
duke@0 144 } \
duke@0 145 return result; \
duke@0 146 }
duke@0 147
phh@729 148 #define VM_HPIDECL_VOID(name, names, func, arg_type, arg_print, arg) \
phh@729 149 inline void hpi::name arg_type { \
phh@729 150 if (TraceHPI) { \
phh@729 151 tty->print("hpi::" names "("); \
phh@729 152 tty->print arg_print; \
phh@729 153 tty->print(") = "); \
phh@729 154 } \
phh@729 155 func arg; \
phh@729 156 }
duke@0 157
duke@0 158 #define HPIDECL_VOID(name, names, intf, func, arg_type, arg_print, arg) \
duke@0 159 inline void hpi::name arg_type { \
duke@0 160 if (TraceHPI) { \
duke@0 161 tty->print("hpi::" names "("); \
duke@0 162 tty->print arg_print ; \
duke@0 163 tty->print_cr(") = void"); \
duke@0 164 } \
duke@0 165 (*intf->func) arg ; \
duke@0 166 }
duke@0 167
duke@0 168
duke@0 169 // The macro calls below realize into
duke@0 170 // inline char * hpi::native_path(...) { inlined_body; }
duke@0 171 // etc.
duke@0 172
duke@0 173 // HPI_FileInterface
duke@0 174
duke@0 175 HPIDECL(native_path, "native_path", _file, NativePath, char *, "%s",
duke@0 176 (char *path),
duke@0 177 ("path = %s", path),
duke@0 178 (path));
duke@0 179
duke@0 180 HPIDECL(file_type, "file_type", _file, FileType, int, "%d",
duke@0 181 (const char *path),
duke@0 182 ("path = %s", path),
duke@0 183 (path));
duke@0 184
duke@0 185 HPIDECL(open, "open", _file, Open, int, "%d",
duke@0 186 (const char *name, int mode, int perm),
duke@0 187 ("name = %s, mode = %d, perm = %d", name, mode, perm),
duke@0 188 (name, mode, perm));
duke@0 189
duke@0 190 HPIDECL(lseek, "seek", _file, Seek, jlong, "(a jlong)",
duke@0 191 (int fd, jlong off, int whence),
duke@0 192 ("fd = %d, off = (a jlong), whence = %d", fd, /* off, */ whence),
duke@0 193 (fd, off, whence));
duke@0 194
duke@0 195 HPIDECL(ftruncate, "ftruncate", _file, SetLength, int, "%d",
duke@0 196 (int fd, jlong length),
duke@0 197 ("fd = %d, length = (a jlong)", fd /*, length */),
duke@0 198 (fd, length));
duke@0 199
duke@0 200 HPIDECL(fsync, "fsync", _file, Sync, int, "%d",
duke@0 201 (int fd),
duke@0 202 ("fd = %d", fd),
duke@0 203 (fd));
duke@0 204
duke@0 205 HPIDECL(available, "available", _file, Available, int, "%d",
duke@0 206 (int fd, jlong *bytes),
duke@0 207 ("fd = %d, bytes = %p", fd, bytes),
duke@0 208 (fd, bytes));
duke@0 209
duke@0 210 HPIDECL(fsize, "fsize", _file, FileSizeFD, int, "%d",
duke@0 211 (int fd, jlong *size),
duke@0 212 ("fd = %d, size = %p", fd, size),
duke@0 213 (fd, size));
duke@0 214
duke@0 215 // HPI_LibraryInterface
phh@729 216 VM_HPIDECL_VOID(dll_build_name, "dll_build_name", os::dll_build_name,
phh@729 217 (char *buf, int buf_len, const char *path, const char *name),
phh@729 218 ("buf = %p, buflen = %d, path = %s, name = %s",
phh@729 219 buf, buf_len, path, name),
phh@729 220 (buf, buf_len, path, name));
duke@0 221
duke@0 222 VM_HPIDECL(dll_load, "dll_load", os::dll_load,
duke@0 223 void *, "(void *)%p",
duke@0 224 (const char *name, char *ebuf, int ebuflen),
duke@0 225 ("name = %s, ebuf = %p, ebuflen = %d", name, ebuf, ebuflen),
duke@0 226 (name, ebuf, ebuflen));
duke@0 227
duke@0 228 HPIDECL_VOID(dll_unload, "dll_unload", _library, UnloadLibrary,
duke@0 229 (void *lib),
duke@0 230 ("lib = %p", lib),
duke@0 231 (lib));
duke@0 232
duke@0 233 HPIDECL(dll_lookup, "dll_lookup", _library, FindLibraryEntry, void *, "%p",
duke@0 234 (void *lib, const char *name),
duke@0 235 ("lib = %p, name = %s", lib, name),
duke@0 236 (lib, name));
duke@0 237
duke@0 238 // HPI_SystemInterface
duke@0 239 HPIDECL(lasterror, "lasterror", _system, GetLastErrorString, int, "%d",
duke@0 240 (char *buf, int len),
duke@0 241 ("buf = %p, len = %d", buf, len),
duke@0 242 (buf, len));
stefank@1992 243
stefank@1992 244 #endif // SHARE_VM_RUNTIME_HPI_HPP