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