1 /* 2 * Copyright (c) 1997, 2014, 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_SOLARIS_VM_OS_SOLARIS_INLINE_HPP 26 #define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP 27 28 #include "runtime/atomic.inline.hpp" 29 #include "runtime/orderAccess.inline.hpp" 30 #include "runtime/os.hpp" 31 32 // System includes 33 #include <sys/param.h> 34 #include <dlfcn.h> 35 #include <sys/socket.h> 36 #include <sys/poll.h> 37 #include <sys/filio.h> 38 #include <unistd.h> 39 #include <netdb.h> 40 #include <setjmp.h> 41 42 inline const char* os::file_separator() { return "/"; } 43 inline const char* os::line_separator() { return "\n"; } 44 inline const char* os::path_separator() { return ":"; } 45 46 // File names are case-sensitive on windows only 47 inline int os::file_name_strcmp(const char* s1, const char* s2) { 48 return strcmp(s1, s2); 49 } 50 51 inline bool os::uses_stack_guard_pages() { 52 return true; 53 } 54 55 inline bool os::allocate_stack_guard_pages() { 56 assert(uses_stack_guard_pages(), "sanity check"); 57 int r = thr_main() ; 58 guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ; 59 return r; 60 } 61 62 63 // On Solaris, reservations are made on a page by page basis, nothing to do. 64 inline void os::pd_split_reserved_memory(char *base, size_t size, 65 size_t split, bool realloc) { 66 } 67 68 69 // Bang the shadow pages if they need to be touched to be mapped. 70 inline void os::bang_stack_shadow_pages() { 71 } 72 inline void os::dll_unload(void *lib) { ::dlclose(lib); } 73 74 inline DIR* os::opendir(const char* dirname) { 75 assert(dirname != NULL, "just checking"); 76 return ::opendir(dirname); 77 } 78 79 inline int os::readdir_buf_size(const char *path) { 80 int size = pathconf(path, _PC_NAME_MAX); 81 return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1; 82 } 83 84 inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) { 85 assert(dirp != NULL, "just checking"); 86 #if defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64 87 dirent* p; 88 int status; 89 90 if((status = ::readdir_r(dirp, dbuf, &p)) != 0) { 91 errno = status; 92 return NULL; 93 } else 94 return p; 95 #else // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64 96 return ::readdir_r(dirp, dbuf); 97 #endif // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64 98 } 99 100 inline int os::closedir(DIR *dirp) { 101 assert(dirp != NULL, "argument is NULL"); 102 return ::closedir(dirp); 103 } 104 105 ////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////// 107 108 // macros for restartable system calls 109 110 #define RESTARTABLE(_cmd, _result) do { \ 111 do { \ 112 _result = _cmd; \ 113 } while((_result == OS_ERR) && (errno == EINTR)); \ 114 } while(false) 115 116 #define RESTARTABLE_RETURN_INT(_cmd) do { \ 117 int _result; \ 118 RESTARTABLE(_cmd, _result); \ 119 return _result; \ 120 } while(false) 121 122 inline bool os::numa_has_static_binding() { return false; } 123 inline bool os::numa_has_group_homing() { return true; } 124 125 inline int os::socket(int domain, int type, int protocol) { 126 return ::socket(domain, type, protocol); 127 } 128 129 inline int os::listen(int fd, int count) { 130 if (fd < 0) return OS_ERR; 131 132 return ::listen(fd, count); 133 } 134 135 inline int os::socket_shutdown(int fd, int howto){ 136 return ::shutdown(fd, howto); 137 } 138 139 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){ 140 return ::getsockname(fd, him, len); 141 } 142 143 inline int os::get_host_name(char* name, int namelen){ 144 return ::gethostname(name, namelen); 145 } 146 147 inline struct hostent* os::get_host_by_name(char* name) { 148 return ::gethostbyname(name); 149 } 150 151 inline int os::get_sock_opt(int fd, int level, int optname, 152 char* optval, socklen_t* optlen) { 153 return ::getsockopt(fd, level, optname, optval, optlen); 154 } 155 156 inline int os::set_sock_opt(int fd, int level, int optname, 157 const char *optval, socklen_t optlen) { 158 return ::setsockopt(fd, level, optname, optval, optlen); 159 } 160 161 inline bool os::supports_monotonic_clock() { 162 // javaTimeNanos() is monotonic on Solaris, see getTimeNanos() comments 163 return true; 164 } 165 166 #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP