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