1 /* 2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2012, 2018 SAP SE. 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_OS_AIX_INLINE_HPP 27 #define OS_AIX_OS_AIX_INLINE_HPP 28 29 #include "runtime/os.hpp" 30 #include "os_posix.inline.hpp" 31 32 // System includes 33 34 #include <unistd.h> 35 #include <sys/socket.h> 36 #include <poll.h> 37 #include <sys/ioctl.h> 38 #include <netdb.h> 39 40 inline bool os::uses_stack_guard_pages() { 41 return true; 42 } 43 44 // Whether or not calling code should/can commit/uncommit stack pages 45 // before guarding them. Answer for AIX is definitly no, because memory 46 // is automatically committed on touch. 47 inline bool os::must_commit_stack_guard_pages() { 48 assert(uses_stack_guard_pages(), "sanity check"); 49 return false; 50 } 51 52 // On Aix, reservations are made on a page by page basis, nothing to do. 53 inline void os::pd_split_reserved_memory(char *base, size_t size, 54 size_t split, bool realloc) { 55 // TODO: Determine whether Sys V memory is split. If yes, we need to treat 56 // this the same way Windows treats its VirtualAlloc allocations. 57 } 58 59 // Bang the shadow pages if they need to be touched to be mapped. 60 inline void os::map_stack_shadow_pages(address sp) { 61 } 62 63 inline void os::dll_unload(void *lib) { 64 ::dlclose(lib); 65 } 66 67 inline const int os::default_file_open_flags() { return 0;} 68 69 inline jlong os::lseek(int fd, jlong offset, int whence) { 70 return (jlong) ::lseek64(fd, offset, whence); 71 } 72 73 inline int os::fsync(int fd) { 74 return ::fsync(fd); 75 } 76 77 inline int os::ftruncate(int fd, jlong length) { 78 return ::ftruncate64(fd, length); 79 } 80 81 // macros for restartable system calls 82 83 #define RESTARTABLE(_cmd, _result) do { \ 84 _result = _cmd; \ 85 } while(((int)_result == OS_ERR) && (errno == EINTR)) 86 87 #define RESTARTABLE_RETURN_INT(_cmd) do { \ 88 int _result; \ 89 RESTARTABLE(_cmd, _result); \ 90 return _result; \ 91 } while(false) 92 93 // We don't have NUMA support on Aix, but we need this for compilation. 94 inline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; } 95 inline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; } 96 97 inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { 98 size_t res; 99 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); 100 return res; 101 } 102 103 inline int os::close(int fd) { 104 return ::close(fd); 105 } 106 107 inline int os::socket_close(int fd) { 108 return ::close(fd); 109 } 110 111 inline int os::socket(int domain, int type, int protocol) { 112 return ::socket(domain, type, protocol); 113 } 114 115 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { 116 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); 117 } 118 119 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { 120 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); 121 } 122 123 inline int os::raw_send(int fd, char *buf, size_t nBytes, uint flags) { 124 return os::send(fd, buf, nBytes, flags); 125 } 126 127 inline int os::connect(int fd, struct sockaddr *him, socklen_t len) { 128 RESTARTABLE_RETURN_INT(::connect(fd, him, len)); 129 } 130 131 inline struct hostent* os::get_host_by_name(char* name) { 132 return ::gethostbyname(name); 133 } 134 135 inline bool os::supports_monotonic_clock() { 136 // mread_real_time() is monotonic on AIX (see os::javaTimeNanos() comments) 137 return true; 138 } 139 140 inline void os::exit(int num) { 141 ::exit(num); 142 } 143 144 #endif // OS_AIX_OS_AIX_INLINE_HPP