hotspot/src/os/linux/vm/os_linux.inline.hpp
author fparain
Wed, 19 Feb 2014 16:22:15 +0000
changeset 22891 1f5d1fff23fa
parent 18025 b7bcf7497f93
child 24351 61b33cc6d3cf
permissions -rw-r--r--
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler Reviewed-by: dholmes, dcubed
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: 18025
diff changeset
     2
 * Copyright (c) 1999, 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_LINUX_VM_OS_LINUX_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define OS_LINUX_VM_OS_LINUX_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"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/os.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13963
diff changeset
    30
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#ifdef TARGET_OS_ARCH_linux_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
# include "orderAccess_linux_x86.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#ifdef TARGET_OS_ARCH_linux_sparc
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
# include "orderAccess_linux_sparc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#ifdef TARGET_OS_ARCH_linux_zero
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
# include "orderAccess_linux_zero.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#endif
8107
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    40
#ifdef TARGET_OS_ARCH_linux_arm
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    41
# include "orderAccess_linux_arm.inline.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    42
#endif
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    43
#ifdef TARGET_OS_ARCH_linux_ppc
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    44
# include "orderAccess_linux_ppc.inline.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7458
diff changeset
    45
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    47
// System includes
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    48
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    49
#include <unistd.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    50
#include <sys/socket.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    51
#include <sys/poll.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    52
#include <netdb.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    53
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
inline void* os::thread_local_storage_at(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  return pthread_getspecific((pthread_key_t)index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
inline const char* os::file_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  return "/";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
inline const char* os::line_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  return "\n";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
inline const char* os::path_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  return ":";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// File names are case-sensitive on windows only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
inline int os::file_name_strcmp(const char* s1, const char* s2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  return strcmp(s1, s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
inline bool os::obsolete_option(const JavaVMOption *option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
inline bool os::uses_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
inline bool os::allocate_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  assert(uses_stack_guard_pages(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// On Linux, 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
    90
inline void os::pd_split_reserved_memory(char *base, size_t size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                                      size_t split, bool realloc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// Bang the shadow pages if they need to be touched to be mapped.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
inline void os::bang_stack_shadow_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    99
inline void os::dll_unload(void *lib) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   100
  ::dlclose(lib);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   101
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   102
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   103
inline const int os::default_file_open_flags() { return 0;}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   104
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
inline DIR* os::opendir(const char* dirname)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  assert(dirname != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  return ::opendir(dirname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
inline int os::readdir_buf_size(const char *path)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  return NAME_MAX + sizeof(dirent) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   116
inline jlong os::lseek(int fd, jlong offset, int whence) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   117
  return (jlong) ::lseek64(fd, offset, whence);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   118
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   119
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   120
inline int os::fsync(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   121
  return ::fsync(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   122
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   123
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   124
inline char* os::native_path(char *path) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   125
  return path;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   126
}
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
inline int os::ftruncate(int fd, jlong length) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   129
  return ::ftruncate64(fd, length);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   130
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   131
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  dirent* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  int status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  assert(dirp != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // version. Here is the doc for this function:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    errno = status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   149
inline int os::closedir(DIR *dirp) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   150
  assert(dirp != NULL, "argument is NULL");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  return ::closedir(dirp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// macros for restartable system calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
#define RESTARTABLE(_cmd, _result) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    _result = _cmd; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  } while(((int)_result == OS_ERR) && (errno == EINTR))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
#define RESTARTABLE_RETURN_INT(_cmd) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  int _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  RESTARTABLE(_cmd, _result); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  return _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
} while(false)
388
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   165
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   166
inline bool os::numa_has_static_binding()   { return true; }
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   167
inline bool os::numa_has_group_homing()     { return false;  }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   168
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   169
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   170
  size_t res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   171
  RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   172
  return res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   173
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   174
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   175
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   176
  size_t res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   177
  RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   178
  return res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   179
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   180
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   181
inline int os::close(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   182
  return ::close(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   183
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   184
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   185
inline int os::socket_close(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   186
  return ::close(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   187
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   188
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   189
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
   190
  return ::socket(domain, type, protocol);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   191
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   192
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   193
inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   194
  RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   195
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   196
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   197
inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   198
  RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   199
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   200
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   201
inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   202
  return os::send(fd, buf, nBytes, flags);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   203
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   204
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   205
inline int os::timeout(int fd, long timeout) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   206
  julong prevtime,newtime;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   207
  struct timeval t;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   208
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   209
  gettimeofday(&t, NULL);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   210
  prevtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   211
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   212
  for(;;) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   213
    struct pollfd pfd;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   214
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   215
    pfd.fd = fd;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   216
    pfd.events = POLLIN | POLLERR;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   217
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   218
    int res = ::poll(&pfd, 1, timeout);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   219
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   220
    if (res == OS_ERR && errno == EINTR) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   221
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   222
      // On Linux any value < 0 means "forever"
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   223
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   224
      if(timeout >= 0) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   225
        gettimeofday(&t, NULL);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   226
        newtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   227
        timeout -= newtime - prevtime;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   228
        if(timeout <= 0)
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   229
          return OS_OK;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   230
        prevtime = newtime;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   231
      }
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   232
    } else
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   233
      return res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   234
  }
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   235
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   236
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   237
inline int os::listen(int fd, int count) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   238
  return ::listen(fd, count);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   239
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   240
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   241
inline int os::connect(int fd, struct sockaddr* him, socklen_t len) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   242
  RESTARTABLE_RETURN_INT(::connect(fd, him, len));
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   243
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   244
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   245
inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   246
  // Linux doc says this can't return EINTR, unlike accept() on Solaris.
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   247
  // But see attachListener_linux.cpp, LinuxAttachListener::dequeue().
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   248
  return (int)::accept(fd, him, len);
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   249
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   250
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   251
inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   252
                        sockaddr* from, socklen_t* fromlen) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   253
  RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen));
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   254
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   255
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   256
inline int os::sendto(int fd, char* buf, size_t len, uint flags,
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   257
                      struct sockaddr* to, socklen_t tolen) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   258
  RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen));
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   259
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   260
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   261
inline int os::socket_shutdown(int fd, int howto) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   262
  return ::shutdown(fd, howto);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   263
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   264
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   265
inline int os::bind(int fd, struct sockaddr* him, socklen_t len) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   266
  return ::bind(fd, him, len);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   267
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   268
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   269
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: 8921
diff changeset
   270
  return ::getsockname(fd, him, len);
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   271
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   272
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   273
inline int os::get_host_name(char* name, int namelen) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   274
  return ::gethostname(name, namelen);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   275
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   276
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   277
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
   278
  return ::gethostbyname(name);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   279
}
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   280
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   281
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: 8921
diff changeset
   282
                            char* optval, socklen_t* optlen) {
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   283
  return ::getsockopt(fd, level, optname, optval, optlen);
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   284
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   285
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   286
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: 8921
diff changeset
   287
                            const char* optval, socklen_t optlen) {
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   288
  return ::setsockopt(fd, level, optname, optval, optlen);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   289
}
15855
2ac9ebea17f3 8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents: 15228
diff changeset
   290
22891
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18025
diff changeset
   291
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: 18025
diff changeset
   292
  return Linux::_clock_gettime != NULL;
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18025
diff changeset
   293
}
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18025
diff changeset
   294
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   295
#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP