os_aix.inline.hpp revision 9665:ce87b1141c12
1/* 2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2012, 2015 SAP AG. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26#ifndef OS_AIX_VM_OS_AIX_INLINE_HPP 27#define OS_AIX_VM_OS_AIX_INLINE_HPP 28 29#include "runtime/os.hpp" 30 31// System includes 32 33#include <unistd.h> 34#include <sys/socket.h> 35#include <sys/poll.h> 36#include <sys/ioctl.h> 37#include <netdb.h> 38 39// File names are case-sensitive on windows only. 40inline int os::file_name_strcmp(const char* s1, const char* s2) { 41 return strcmp(s1, s2); 42} 43 44inline bool os::obsolete_option(const JavaVMOption *option) { 45 return false; 46} 47 48inline bool os::uses_stack_guard_pages() { 49 return true; 50} 51 52// Whether or not calling code should/can commit/uncommit stack pages 53// before guarding them. Answer for AIX is definitly no, because memory 54// is automatically committed on touch. 55inline bool os::allocate_stack_guard_pages() { 56 assert(uses_stack_guard_pages(), "sanity check"); 57 return false; 58} 59 60// On Aix, reservations are made on a page by page basis, nothing to do. 61inline void os::pd_split_reserved_memory(char *base, size_t size, 62 size_t split, bool realloc) { 63 // TODO: Determine whether Sys V memory is split. If yes, we need to treat 64 // this the same way Windows treats its VirtualAlloc allocations. 65} 66 67// Bang the shadow pages if they need to be touched to be mapped. 68inline void os::bang_stack_shadow_pages() { 69} 70 71inline void os::dll_unload(void *lib) { 72 ::dlclose(lib); 73} 74 75inline const int os::default_file_open_flags() { return 0;} 76 77inline DIR* os::opendir(const char* dirname) { 78 assert(dirname != NULL, "just checking"); 79 return ::opendir(dirname); 80} 81 82inline int os::readdir_buf_size(const char *path) { 83 // According to aix sys/limits, NAME_MAX must be retrieved at runtime. 84 const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX); 85 return my_NAME_MAX + sizeof(dirent) + 1; 86} 87 88inline jlong os::lseek(int fd, jlong offset, int whence) { 89 return (jlong) ::lseek64(fd, offset, whence); 90} 91 92inline int os::fsync(int fd) { 93 return ::fsync(fd); 94} 95 96inline char* os::native_path(char *path) { 97 return path; 98} 99 100inline int os::ftruncate(int fd, jlong length) { 101 return ::ftruncate64(fd, length); 102} 103 104inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) { 105 dirent* p; 106 int status; 107 assert(dirp != NULL, "just checking"); 108 109 // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX 110 // version. Here is the doc for this function: 111 // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html 112 113 if((status = ::readdir_r(dirp, dbuf, &p)) != 0) { 114 errno = status; 115 return NULL; 116 } else 117 return p; 118} 119 120inline int os::closedir(DIR *dirp) { 121 assert(dirp != NULL, "argument is NULL"); 122 return ::closedir(dirp); 123} 124 125// macros for restartable system calls 126 127#define RESTARTABLE(_cmd, _result) do { \ 128 _result = _cmd; \ 129 } while(((int)_result == OS_ERR) && (errno == EINTR)) 130 131#define RESTARTABLE_RETURN_INT(_cmd) do { \ 132 int _result; \ 133 RESTARTABLE(_cmd, _result); \ 134 return _result; \ 135} while(false) 136 137// We don't have NUMA support on Aix, but we need this for compilation. 138inline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; } 139inline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; } 140 141inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) { 142 size_t res; 143 RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res); 144 return res; 145} 146 147inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { 148 size_t res; 149 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); 150 return res; 151} 152 153inline int os::close(int fd) { 154 return ::close(fd); 155} 156 157inline int os::socket_close(int fd) { 158 return ::close(fd); 159} 160 161inline int os::socket(int domain, int type, int protocol) { 162 return ::socket(domain, type, protocol); 163} 164 165inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { 166 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); 167} 168 169inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { 170 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); 171} 172 173inline int os::raw_send(int fd, char *buf, size_t nBytes, uint flags) { 174 return os::send(fd, buf, nBytes, flags); 175} 176 177inline int os::connect(int fd, struct sockaddr *him, socklen_t len) { 178 RESTARTABLE_RETURN_INT(::connect(fd, him, len)); 179} 180 181inline struct hostent* os::get_host_by_name(char* name) { 182 return ::gethostbyname(name); 183} 184 185inline bool os::supports_monotonic_clock() { 186 // mread_real_time() is monotonic on AIX (see os::javaTimeNanos() comments) 187 return true; 188} 189 190inline void os::exit(int num) { 191 ::exit(num); 192} 193 194#endif // OS_AIX_VM_OS_AIX_INLINE_HPP 195