1 /*
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
124 inline int os::closedir(DIR *dirp) {
125 assert(dirp != NULL, "argument is NULL");
126 return ::closedir(dirp);
127 }
128
129 // macros for restartable system calls
130
131 #define RESTARTABLE(_cmd, _result) do { \
132 _result = _cmd; \
133 } while(((int)_result == OS_ERR) && (errno == EINTR))
134
135 #define RESTARTABLE_RETURN_INT(_cmd) do { \
136 int _result; \
137 RESTARTABLE(_cmd, _result); \
138 return _result; \
139 } while(false)
140
141 inline bool os::numa_has_static_binding() { return true; }
142 inline bool os::numa_has_group_homing() { return false; }
143
144 inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
145 size_t res;
146 RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
147 return res;
148 }
149
150 inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
151 size_t res;
152 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
153 return res;
154 }
155
156 inline int os::close(int fd) {
157 return ::close(fd);
158 }
159
160 inline int os::socket_close(int fd) {
161 return ::close(fd);
162 }
163
164 inline int os::socket(int domain, int type, int protocol) {
165 return ::socket(domain, type, protocol);
166 }
167
168 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
169 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
170 }
171
172 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
|
1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
124 inline int os::closedir(DIR *dirp) {
125 assert(dirp != NULL, "argument is NULL");
126 return ::closedir(dirp);
127 }
128
129 // macros for restartable system calls
130
131 #define RESTARTABLE(_cmd, _result) do { \
132 _result = _cmd; \
133 } while(((int)_result == OS_ERR) && (errno == EINTR))
134
135 #define RESTARTABLE_RETURN_INT(_cmd) do { \
136 int _result; \
137 RESTARTABLE(_cmd, _result); \
138 return _result; \
139 } while(false)
140
141 inline bool os::numa_has_static_binding() { return true; }
142 inline bool os::numa_has_group_homing() { return false; }
143
144 inline ssize_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
145 ssize_t res;
146 RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
147 return res;
148 }
149
150 inline ssize_t os::write(int fd, const void *buf, unsigned int nBytes) {
151 ssize_t res;
152 RESTARTABLE(::write(fd, buf, (size_t) nBytes), res);
153 return res;
154 }
155
156 inline int os::close(int fd) {
157 return ::close(fd);
158 }
159
160 inline int os::socket_close(int fd) {
161 return ::close(fd);
162 }
163
164 inline int os::socket(int domain, int type, int protocol) {
165 return ::socket(domain, type, protocol);
166 }
167
168 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
169 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
170 }
171
172 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
|