Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/solaris/vm/os_solaris.inline.hpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP25#define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP2627#include "runtime/atomic.inline.hpp"28#include "runtime/orderAccess.inline.hpp"29#include "runtime/os.hpp"3031// System includes32#include <sys/param.h>33#include <dlfcn.h>34#include <sys/socket.h>35#include <sys/poll.h>36#include <sys/filio.h>37#include <unistd.h>38#include <netdb.h>39#include <setjmp.h>4041inline const char* os::file_separator() { return "/"; }42inline const char* os::line_separator() { return "\n"; }43inline const char* os::path_separator() { return ":"; }4445// File names are case-sensitive on windows only46inline int os::file_name_strcmp(const char* s1, const char* s2) {47return strcmp(s1, s2);48}4950inline bool os::uses_stack_guard_pages() {51return true;52}5354inline bool os::allocate_stack_guard_pages() {55assert(uses_stack_guard_pages(), "sanity check");56int r = thr_main() ;57guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;58return r;59}606162// On Solaris, reservations are made on a page by page basis, nothing to do.63inline void os::pd_split_reserved_memory(char *base, size_t size,64size_t split, bool realloc) {65}666768// Bang the shadow pages if they need to be touched to be mapped.69inline void os::bang_stack_shadow_pages() {70}71inline void os::dll_unload(void *lib) { ::dlclose(lib); }7273//////////////////////////////////////////////////////////////////////////////74////////////////////////////////////////////////////////////////////////////////7576// macros for interruptible io and system calls and system call restarting7778#define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \79do { \80_setup; \81_before; \82OSThread* _osthread = _thread->osthread(); \83if (_int_enable && _thread->has_last_Java_frame()) { \84/* this is java interruptible io stuff */ \85if (os::is_interrupted(_thread, _clear)) { \86os::Solaris::bump_interrupted_before_count(); \87_result = OS_INTRPT; \88} else { \89/* _cmd always expands to an assignment to _result */ \90if ((_cmd) < 0 && errno == EINTR \91&& os::is_interrupted(_thread, _clear)) { \92os::Solaris::bump_interrupted_during_count(); \93_result = OS_INTRPT; \94} \95} \96} else { \97/* this is normal blocking io stuff */ \98_cmd; \99} \100_after; \101} while(false)102103// Interruptible io support + restarting of interrupted system calls104105#ifndef ASSERT106107#define INTERRUPTIBLE(_cmd, _result, _clear) do { \108_INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \109} while((_result == OS_ERR) && (errno == EINTR))110111#else112113// This adds an assertion that it is only called from thread_in_native114// The call overhead is skipped for performance in product mode115#define INTERRUPTIBLE(_cmd, _result, _clear) do { \116_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \117} while((_result == OS_ERR) && (errno == EINTR))118119#endif120121// Used for calls from _thread_in_vm, not from _thread_in_native122#define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \123_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \124} while((_result == OS_ERR) && (errno == EINTR))125126/* Use NORESTART when the system call cannot return EINTR, when something other127than a system call is being invoked, or when the caller must do EINTR128handling. */129130#ifndef ASSERT131132#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \133_INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)134135#else136137// This adds an assertion that it is only called from thread_in_native138// The call overhead is skipped for performance in product mode139#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \140_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )141142#endif143144// Don't attend to UseVMInterruptibleIO. Always allow interruption.145// Also assumes that it is called from the _thread_blocked state.146// Used by os_sleep().147148#define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \149_INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )150151#define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \152int _result; \153do { \154INTERRUPTIBLE(_cmd, _result, _clear); \155} while((_result == OS_ERR) && (errno == EINTR)); \156return _result; \157} while(false)158159#define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \160int _result; \161do { \162INTERRUPTIBLE_VM(_cmd, _result, _clear); \163} while((_result == OS_ERR) && (errno == EINTR)); \164return _result; \165} while(false)166167#define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \168int _result; \169INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \170return _result; \171} while(false)172173/* Use the RESTARTABLE macros when interruptible io is not needed */174175#define RESTARTABLE(_cmd, _result) do { \176do { \177_result = _cmd; \178} while((_result == OS_ERR) && (errno == EINTR)); \179} while(false)180181#define RESTARTABLE_RETURN_INT(_cmd) do { \182int _result; \183RESTARTABLE(_cmd, _result); \184return _result; \185} while(false)186187inline bool os::numa_has_static_binding() { return false; }188inline bool os::numa_has_group_homing() { return true; }189190inline int os::socket(int domain, int type, int protocol) {191return ::socket(domain, type, protocol);192}193194inline int os::listen(int fd, int count) {195if (fd < 0) return OS_ERR;196197return ::listen(fd, count);198}199200inline int os::socket_shutdown(int fd, int howto){201return ::shutdown(fd, howto);202}203204inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){205return ::getsockname(fd, him, len);206}207208inline int os::get_host_name(char* name, int namelen){209return ::gethostname(name, namelen);210}211212inline struct hostent* os::get_host_by_name(char* name) {213return ::gethostbyname(name);214}215216inline int os::get_sock_opt(int fd, int level, int optname,217char* optval, socklen_t* optlen) {218return ::getsockopt(fd, level, optname, optval, optlen);219}220221inline int os::set_sock_opt(int fd, int level, int optname,222const char *optval, socklen_t optlen) {223return ::setsockopt(fd, level, optname, optval, optlen);224}225#endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP226227228