hotspot/src/os/solaris/vm/os_solaris.inline.hpp
author goetz
Tue, 29 Apr 2014 15:17:27 +0200
changeset 24351 61b33cc6d3cf
parent 23443 15e8ed68f73a
child 25468 5331df506290
permissions -rw-r--r--
8042195: Introduce umbrella header orderAccess.inline.hpp. Reviewed-by: dholmes, kvn, stefank, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22891
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13963
diff changeset
    28
#include "runtime/atomic.inline.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 23443
diff changeset
    29
#include "runtime/orderAccess.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/os.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13963
diff changeset
    31
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    32
// System includes
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    33
#include <sys/param.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    34
#include <dlfcn.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    35
#include <sys/socket.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    36
#include <sys/poll.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    37
#include <sys/filio.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    38
#include <unistd.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    39
#include <netdb.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    40
#include <setjmp.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    41
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
inline const char* os::file_separator() { return "/"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
inline const char* os::line_separator() { return "\n"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
inline const char* os::path_separator() { return ":"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// File names are case-sensitive on windows only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
inline int os::file_name_strcmp(const char* s1, const char* s2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  return strcmp(s1, s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
inline bool os::uses_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
inline bool os::allocate_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  assert(uses_stack_guard_pages(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int r = thr_main() ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  return r;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// On Solaris, reservations are made on a page by page basis, nothing to do.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11256
diff changeset
    64
inline void os::pd_split_reserved_memory(char *base, size_t size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
                                      size_t split, bool realloc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// Bang the shadow pages if they need to be touched to be mapped.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
inline void os::bang_stack_shadow_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
}
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    72
inline void os::dll_unload(void *lib) { ::dlclose(lib); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    74
inline DIR* os::opendir(const char* dirname) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  assert(dirname != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  return ::opendir(dirname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    79
inline int os::readdir_buf_size(const char *path) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  int size = pathconf(path, _PC_NAME_MAX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    84
inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  assert(dirp != NULL, "just checking");
18441
1f6241296fda 7122222: GC log is limited to 2G for 32-bit
tamao
parents: 15855
diff changeset
    86
#if defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  dirent* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    errno = status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    return p;
18441
1f6241296fda 7122222: GC log is limited to 2G for 32-bit
tamao
parents: 15855
diff changeset
    95
#else  // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  return ::readdir_r(dirp, dbuf);
18441
1f6241296fda 7122222: GC log is limited to 2G for 32-bit
tamao
parents: 15855
diff changeset
    97
#endif // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   100
inline int os::closedir(DIR *dirp) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   101
  assert(dirp != NULL, "argument is NULL");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  return ::closedir(dirp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//////////////////////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
////////////////////////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
23443
15e8ed68f73a 8036128: Remove deprecated VM flag UseVMInterruptibleIO
fparain
parents: 22891
diff changeset
   108
// macros for restartable system calls
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
#define RESTARTABLE(_cmd, _result) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    _result = _cmd; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  } while((_result == OS_ERR) && (errno == EINTR)); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
} while(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
#define RESTARTABLE_RETURN_INT(_cmd) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  int _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  RESTARTABLE(_cmd, _result); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  return _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
} while(false)
388
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   121
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   122
inline bool os::numa_has_static_binding()   { return false; }
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   123
inline bool os::numa_has_group_homing()     { return true;  }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   124
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   125
inline int    os::socket(int domain, int type, int protocol) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   126
  return ::socket(domain, type, protocol);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   127
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   128
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   129
inline int    os::listen(int fd, int count) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   130
  if (fd < 0) return OS_ERR;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   131
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   132
  return ::listen(fd, count);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   133
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   134
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   135
inline int os::socket_shutdown(int fd, int howto){
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   136
  return ::shutdown(fd, howto);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   137
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   138
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   139
inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   140
  return ::getsockname(fd, him, len);
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   141
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   142
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   143
inline int os::get_host_name(char* name, int namelen){
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   144
  return ::gethostname(name, namelen);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   145
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   146
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   147
inline struct hostent* os::get_host_by_name(char* name) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   148
  return ::gethostbyname(name);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   149
}
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   150
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   151
inline int os::get_sock_opt(int fd, int level, int optname,
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   152
                            char* optval, socklen_t* optlen) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   153
  return ::getsockopt(fd, level, optname, optval, optlen);
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   154
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   155
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   156
inline int os::set_sock_opt(int fd, int level, int optname,
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 7405
diff changeset
   157
                            const char *optval, socklen_t optlen) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   158
  return ::setsockopt(fd, level, optname, optval, optlen);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   159
}
22891
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   160
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   161
inline bool os::supports_monotonic_clock() {
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   162
  // javaTimeNanos() is monotonic on Solaris, see getTimeNanos() comments
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   163
  return true;
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   164
}
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18441
diff changeset
   165
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   166
#endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP