src/hotspot/os/linux/os_linux.inline.hpp
author kbarrett
Tue, 17 Jul 2018 15:59:47 -0400
changeset 51106 f605c91e5219
parent 50667 cc58f1fa0438
child 51989 7ac0ac1e57b6
permissions -rw-r--r--
8202353: os::readdir should use readdir instead of readdir_r 8202835: jfr/event/os/TestSystemProcess.java fails on missing events Summary: os::readdir uses POSIX readdir, drop buffer arg, fix JFR uses. Reviewed-by: coleenp, tschatzl, bsrbnd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 49957
diff changeset
     2
 * Copyright (c) 1999, 2018, 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
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/os.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13963
diff changeset
    29
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    30
// System includes
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    31
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    32
#include <unistd.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    33
#include <sys/socket.h>
46454
f090a0a198cd 8180003: Remove sys/ prefix from poll.h and signal.h includes
mikael
parents: 39390
diff changeset
    34
#include <poll.h>
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    35
#include <netdb.h>
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    36
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 49957
diff changeset
    37
// File names are case-insensitive on windows only
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 49957
diff changeset
    38
inline int os::file_name_strncmp(const char* s1, const char* s2, size_t num) {
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 49957
diff changeset
    39
  return strncmp(s1, s2, num);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
inline bool os::obsolete_option(const JavaVMOption *option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
inline bool os::uses_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 35479
diff changeset
    50
inline bool os::must_commit_stack_guard_pages() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  assert(uses_stack_guard_pages(), "sanity check");
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// 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
    57
inline void os::pd_split_reserved_memory(char *base, size_t size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                                      size_t split, bool realloc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// Bang the shadow pages if they need to be touched to be mapped.
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 35479
diff changeset
    63
inline void os::map_stack_shadow_pages(address sp) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    66
inline void os::dll_unload(void *lib) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    67
  ::dlclose(lib);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    68
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    69
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    70
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
    71
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    72
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
    73
  return (jlong) ::lseek64(fd, offset, whence);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    74
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    75
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    76
inline int os::fsync(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    77
  return ::fsync(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    78
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    79
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    80
inline int os::ftruncate(int fd, jlong length) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    81
  return ::ftruncate64(fd, length);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    82
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    83
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// macros for restartable system calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
#define RESTARTABLE(_cmd, _result) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    _result = _cmd; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  } while(((int)_result == OS_ERR) && (errno == EINTR))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#define RESTARTABLE_RETURN_INT(_cmd) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  int _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  RESTARTABLE(_cmd, _result); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  return _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
} while(false)
388
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
    95
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
    96
inline bool os::numa_has_static_binding()   { return true; }
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
    97
inline bool os::numa_has_group_homing()     { return false;  }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    98
7405
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
    99
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
   100
  size_t res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   101
  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
   102
  return res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   103
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   104
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   105
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
   106
  size_t res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   107
  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
   108
  return res;
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   109
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   110
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   111
inline int os::close(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   112
  return ::close(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   113
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   114
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   115
inline int os::socket_close(int fd) {
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   116
  return ::close(fd);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   117
}
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
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
   120
  return ::socket(domain, type, protocol);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   121
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   122
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   123
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
   124
  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
   125
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   126
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   127
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
   128
  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
   129
}
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   130
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   131
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
   132
  return os::send(fd, buf, nBytes, flags);
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
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   135
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
   136
  RESTARTABLE_RETURN_INT(::connect(fd, him, len));
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: 8921
diff changeset
   139
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
   140
  return ::gethostbyname(name);
e6fc8d3926f8 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 7397
diff changeset
   141
}
11256
025cd1741566 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 8921
diff changeset
   142
22891
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18025
diff changeset
   143
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
   144
  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
   145
}
1f5d1fff23fa 6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents: 18025
diff changeset
   146
26682
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
   147
inline void os::exit(int num) {
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
   148
  ::exit(num);
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
   149
}
f339669ba825 8057744: (process) Synchronize exiting of threads and process [win]
igerasim
parents: 25468
diff changeset
   150
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   151
#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP