annotate src/os/linux/vm/os_linux.inline.hpp @ 7212:291ffc492eb6

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Fri, 14 Dec 2012 14:35:13 +0100
parents cd3d6a6b95d9
children 203f64878aab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 6197
diff changeset
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef OS_LINUX_VM_OS_LINUX_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define OS_LINUX_VM_OS_LINUX_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/atomic.hpp"
7199
cd3d6a6b95d9 8003240: x86: move MacroAssembler into separate file
twisti
parents: 6842
diff changeset
29 #include "runtime/atomic.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/os.hpp"
7199
cd3d6a6b95d9 8003240: x86: move MacroAssembler into separate file
twisti
parents: 6842
diff changeset
31
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #ifdef TARGET_OS_ARCH_linux_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 # include "orderAccess_linux_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #ifdef TARGET_OS_ARCH_linux_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 # include "orderAccess_linux_sparc.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #ifdef TARGET_OS_ARCH_linux_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 # include "orderAccess_linux_zero.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
41 #ifdef TARGET_OS_ARCH_linux_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
42 # include "orderAccess_linux_arm.inline.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
43 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
44 #ifdef TARGET_OS_ARCH_linux_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
45 # include "orderAccess_linux_ppc.inline.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2033
diff changeset
46 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
47
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
48 // System includes
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
49
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
50 #include <unistd.h>
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
51 #include <sys/socket.h>
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
52 #include <sys/poll.h>
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
53 #include <netdb.h>
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
54
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55 inline void* os::thread_local_storage_at(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return pthread_getspecific((pthread_key_t)index);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 inline const char* os::file_separator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return "/";
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 inline const char* os::line_separator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return "\n";
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 inline const char* os::path_separator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return ":";
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 inline const char* os::jlong_format_specifier() {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return "%lld";
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 inline const char* os::julong_format_specifier() {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return "%llu";
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // File names are case-sensitive on windows only
a61af66fc99e Initial load
duke
parents:
diff changeset
80 inline int os::file_name_strcmp(const char* s1, const char* s2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return strcmp(s1, s2);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 inline bool os::obsolete_option(const JavaVMOption *option) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 inline bool os::uses_stack_guard_pages() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 inline bool os::allocate_stack_guard_pages() {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(uses_stack_guard_pages(), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // On Linux, reservations are made on a page by page basis, nothing to do.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 4717
diff changeset
99 inline void os::pd_split_reserved_memory(char *base, size_t size,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100 size_t split, bool realloc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Bang the shadow pages if they need to be touched to be mapped.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 inline void os::bang_stack_shadow_pages() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
108 inline void os::dll_unload(void *lib) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
109 ::dlclose(lib);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
110 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
111
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
112 inline const int os::default_file_open_flags() { return 0;}
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
113
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 inline DIR* os::opendir(const char* dirname)
a61af66fc99e Initial load
duke
parents:
diff changeset
115 {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 assert(dirname != NULL, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return ::opendir(dirname);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 inline int os::readdir_buf_size(const char *path)
a61af66fc99e Initial load
duke
parents:
diff changeset
121 {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return NAME_MAX + sizeof(dirent) + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
125 inline jlong os::lseek(int fd, jlong offset, int whence) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
126 return (jlong) ::lseek64(fd, offset, whence);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
127 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
128
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
129 inline int os::fsync(int fd) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
130 return ::fsync(fd);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
131 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
132
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
133 inline char* os::native_path(char *path) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
134 return path;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
135 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
136
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
137 inline int os::ftruncate(int fd, jlong length) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
138 return ::ftruncate64(fd, length);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
139 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
140
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
a61af66fc99e Initial load
duke
parents:
diff changeset
142 {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 dirent* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int status;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(dirp != NULL, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // version. Here is the doc for this function:
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 errno = status;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return p;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
158 inline int os::closedir(DIR *dirp) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
159 assert(dirp != NULL, "argument is NULL");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return ::closedir(dirp);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // macros for restartable system calls
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 #define RESTARTABLE(_cmd, _result) do { \
a61af66fc99e Initial load
duke
parents:
diff changeset
166 _result = _cmd; \
a61af66fc99e Initial load
duke
parents:
diff changeset
167 } while(((int)_result == OS_ERR) && (errno == EINTR))
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 #define RESTARTABLE_RETURN_INT(_cmd) do { \
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int _result; \
a61af66fc99e Initial load
duke
parents:
diff changeset
171 RESTARTABLE(_cmd, _result); \
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return _result; \
a61af66fc99e Initial load
duke
parents:
diff changeset
173 } while(false)
141
fcbfc50865ab 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 0
diff changeset
174
fcbfc50865ab 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 0
diff changeset
175 inline bool os::numa_has_static_binding() { return true; }
fcbfc50865ab 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 0
diff changeset
176 inline bool os::numa_has_group_homing() { return false; }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
177
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
178 inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
179 size_t res;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
180 RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
181 return res;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
182 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
183
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
184 inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
185 size_t res;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
186 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
187 return res;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
188 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
189
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
190 inline int os::close(int fd) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
191 return ::close(fd);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
192 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
193
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
194 inline int os::socket_close(int fd) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
195 return ::close(fd);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
196 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
197
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
198 inline int os::socket(int domain, int type, int protocol) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
199 return ::socket(domain, type, protocol);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
200 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
201
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
202 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
203 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
204 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
205
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
206 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
207 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
208 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
209
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
210 inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
211 return os::send(fd, buf, nBytes, flags);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
212 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
213
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
214 inline int os::timeout(int fd, long timeout) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
215 julong prevtime,newtime;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
216 struct timeval t;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
217
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
218 gettimeofday(&t, NULL);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
219 prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
220
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
221 for(;;) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
222 struct pollfd pfd;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
223
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
224 pfd.fd = fd;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
225 pfd.events = POLLIN | POLLERR;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
226
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
227 int res = ::poll(&pfd, 1, timeout);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
228
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
229 if (res == OS_ERR && errno == EINTR) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
230
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
231 // On Linux any value < 0 means "forever"
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
232
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
233 if(timeout >= 0) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
234 gettimeofday(&t, NULL);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
235 newtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
236 timeout -= newtime - prevtime;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
237 if(timeout <= 0)
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
238 return OS_OK;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
239 prevtime = newtime;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
240 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
241 } else
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
242 return res;
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
243 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
244 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
245
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
246 inline int os::listen(int fd, int count) {
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
247 return ::listen(fd, count);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
248 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
249
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
250 inline int os::connect(int fd, struct sockaddr* him, socklen_t len) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
251 RESTARTABLE_RETURN_INT(::connect(fd, him, len));
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
252 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
253
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
254 inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
255 // Linux doc says this can't return EINTR, unlike accept() on Solaris.
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
256 // But see attachListener_linux.cpp, LinuxAttachListener::dequeue().
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
257 return (int)::accept(fd, him, len);
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
258 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
259
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
260 inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
261 sockaddr* from, socklen_t* fromlen) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
262 RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen));
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
263 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
264
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
265 inline int os::sendto(int fd, char* buf, size_t len, uint flags,
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
266 struct sockaddr* to, socklen_t tolen) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
267 RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen));
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
268 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
269
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
270 inline int os::socket_shutdown(int fd, int howto) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
271 return ::shutdown(fd, howto);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
272 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
273
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
274 inline int os::bind(int fd, struct sockaddr* him, socklen_t len) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
275 return ::bind(fd, him, len);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
276 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
277
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
278 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
279 return ::getsockname(fd, him, len);
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
280 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
281
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
282 inline int os::get_host_name(char* name, int namelen) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
283 return ::gethostname(name, namelen);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
284 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
285
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
286 inline struct hostent* os::get_host_by_name(char* name) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
287 return ::gethostbyname(name);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
288 }
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
289
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
290 inline int os::get_sock_opt(int fd, int level, int optname,
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
291 char* optval, socklen_t* optlen) {
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
292 return ::getsockopt(fd, level, optname, optval, optlen);
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
293 }
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
294
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
295 inline int os::set_sock_opt(int fd, int level, int optname,
4717
11c26bfcf8c7 7091417: recvfrom's 6th input should be of type socklen_t
phh
parents: 2426
diff changeset
296 const char* optval, socklen_t optlen) {
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
297 return ::setsockopt(fd, level, optname, optval, optlen);
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
298 }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
299 #endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP