< prev index next >

src/os/linux/vm/os_linux.inline.hpp

Print this page
rev 13166 : read/write APIs in class os shall return ssize_t
   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  *


 116 inline int os::closedir(DIR *dirp) {
 117   assert(dirp != NULL, "argument is NULL");
 118   return ::closedir(dirp);
 119 }
 120 
 121 // macros for restartable system calls
 122 
 123 #define RESTARTABLE(_cmd, _result) do { \
 124     _result = _cmd; \
 125   } while(((int)_result == OS_ERR) && (errno == EINTR))
 126 
 127 #define RESTARTABLE_RETURN_INT(_cmd) do { \
 128   int _result; \
 129   RESTARTABLE(_cmd, _result); \
 130   return _result; \
 131 } while(false)
 132 
 133 inline bool os::numa_has_static_binding()   { return true; }
 134 inline bool os::numa_has_group_homing()     { return false;  }
 135 
 136 inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
 137   size_t res;
 138   RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
 139   return res;
 140 }
 141 
 142 inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
 143   size_t res;
 144   RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
 145   return res;
 146 }
 147 
 148 inline int os::close(int fd) {
 149   return ::close(fd);
 150 }
 151 
 152 inline int os::socket_close(int fd) {
 153   return ::close(fd);
 154 }
 155 
 156 inline int os::socket(int domain, int type, int protocol) {
 157   return ::socket(domain, type, protocol);
 158 }
 159 
 160 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
 161   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
 162 }
 163 
 164 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  *


 116 inline int os::closedir(DIR *dirp) {
 117   assert(dirp != NULL, "argument is NULL");
 118   return ::closedir(dirp);
 119 }
 120 
 121 // macros for restartable system calls
 122 
 123 #define RESTARTABLE(_cmd, _result) do { \
 124     _result = _cmd; \
 125   } while(((int)_result == OS_ERR) && (errno == EINTR))
 126 
 127 #define RESTARTABLE_RETURN_INT(_cmd) do { \
 128   int _result; \
 129   RESTARTABLE(_cmd, _result); \
 130   return _result; \
 131 } while(false)
 132 
 133 inline bool os::numa_has_static_binding()   { return true; }
 134 inline bool os::numa_has_group_homing()     { return false;  }
 135 
 136 inline ssize_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
 137   ssize_t res;
 138   RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
 139   return res;
 140 }
 141 
 142 inline ssize_t os::write(int fd, const void *buf, unsigned int nBytes) {
 143   ssize_t res;
 144   RESTARTABLE(::write(fd, buf, (size_t) nBytes), res);
 145   return res;
 146 }
 147 
 148 inline int os::close(int fd) {
 149   return ::close(fd);
 150 }
 151 
 152 inline int os::socket_close(int fd) {
 153   return ::close(fd);
 154 }
 155 
 156 inline int os::socket(int domain, int type, int protocol) {
 157   return ::socket(domain, type, protocol);
 158 }
 159 
 160 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
 161   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
 162 }
 163 
 164 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {


< prev index next >