os_aix.inline.hpp revision 9934:fd5d53ecf040
171088Sjasone/* 271088Sjasone * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. 371088Sjasone * Copyright 2012, 2015 SAP AG. All rights reserved. 471088Sjasone * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 571088Sjasone * 671088Sjasone * This code is free software; you can redistribute it and/or modify it 771088Sjasone * under the terms of the GNU General Public License version 2 only, as 871088Sjasone * published by the Free Software Foundation. 971088Sjasone * 1071088Sjasone * This code is distributed in the hope that it will be useful, but WITHOUT 1171088Sjasone * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1271088Sjasone * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1371088Sjasone * version 2 for more details (a copy is included in the LICENSE file that 1471088Sjasone * accompanied this code). 1571088Sjasone * 1671088Sjasone * You should have received a copy of the GNU General Public License version 1771088Sjasone * 2 along with this work; if not, write to the Free Software Foundation, 1871088Sjasone * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1971088Sjasone * 2071088Sjasone * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2171088Sjasone * or visit www.oracle.com if you need additional information or have any 2271088Sjasone * questions. 2371088Sjasone * 2471088Sjasone */ 2571088Sjasone 2671088Sjasone#ifndef OS_AIX_VM_OS_AIX_INLINE_HPP 27116182Sobrien#define OS_AIX_VM_OS_AIX_INLINE_HPP 28116182Sobrien 29116182Sobrien#include "runtime/os.hpp" 3071088Sjasone 3171088Sjasone// System includes 3271088Sjasone 3371088Sjasone#include <unistd.h> 3476166Smarkm#include <sys/socket.h> 3576166Smarkm#include <sys/poll.h> 3671088Sjasone#include <sys/ioctl.h> 3771088Sjasone#include <netdb.h> 3871088Sjasone 3971088Sjasone// File names are case-sensitive on windows only. 40109862Sjeffinline int os::file_name_strcmp(const char* s1, const char* s2) { 4171088Sjasone return strcmp(s1, s2); 42126326Sjhb} 4371088Sjasone 4471088Sjasoneinline bool os::obsolete_option(const JavaVMOption *option) { 4571088Sjasone return false; 4671088Sjasone} 4771088Sjasone 4871088Sjasoneinline bool os::uses_stack_guard_pages() { 4971088Sjasone return true; 5071088Sjasone} 5171088Sjasone 52167789Sjhb// Whether or not calling code should/can commit/uncommit stack pages 53250581Shiren// before guarding them. Answer for AIX is definitly no, because memory 54103216Sjulian// is automatically committed on touch. 5587594Sobrieninline bool os::allocate_stack_guard_pages() { 56167789Sjhb assert(uses_stack_guard_pages(), "sanity check"); 5771088Sjasone return false; 5871088Sjasone} 5971088Sjasone 6071088Sjasone// On Aix, reservations are made on a page by page basis, nothing to do. 6171088Sjasoneinline void os::pd_split_reserved_memory(char *base, size_t size, 6271088Sjasone size_t split, bool realloc) { 6371088Sjasone // TODO: Determine whether Sys V memory is split. If yes, we need to treat 6471088Sjasone // this the same way Windows treats its VirtualAlloc allocations. 6571088Sjasone} 6671088Sjasone 67127954Sjhb// Bang the shadow pages if they need to be touched to be mapped. 6871088Sjasoneinline void os::map_stack_shadow_pages() { 6971088Sjasone} 7071088Sjasone 7171088Sjasoneinline void os::dll_unload(void *lib) { 7271088Sjasone ::dlclose(lib); 7371088Sjasone} 7471088Sjasone 7571088Sjasoneinline const int os::default_file_open_flags() { return 0;} 7671088Sjasone 77126326Sjhbinline DIR* os::opendir(const char* dirname) { 78136445Sjhb assert(dirname != NULL, "just checking"); 7971088Sjasone return ::opendir(dirname); 80136445Sjhb} 81126326Sjhb 82126326Sjhbinline int os::readdir_buf_size(const char *path) { 83126326Sjhb // According to aix sys/limits, NAME_MAX must be retrieved at runtime. 84126326Sjhb const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX); 8571088Sjasone return my_NAME_MAX + sizeof(dirent) + 1; 8671088Sjasone} 8771088Sjasone 8883366Sjulianinline jlong os::lseek(int fd, jlong offset, int whence) { 8971088Sjasone return (jlong) ::lseek64(fd, offset, whence); 9083366Sjulian} 9171088Sjasone 9271088Sjasoneinline int os::fsync(int fd) { 9371088Sjasone return ::fsync(fd); 9471088Sjasone} 95167789Sjhb 9671088Sjasoneinline char* os::native_path(char *path) { 97167789Sjhb return path; 98167789Sjhb} 99167786Sjhb 100167789Sjhbinline int os::ftruncate(int fd, jlong length) { 10171088Sjasone return ::ftruncate64(fd, length); 102167786Sjhb} 103181394Sjhb 104167786Sjhbinline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) { 105167786Sjhb dirent* p = NULL; 106237719Sjhb assert(dirp != NULL, "just checking"); 107167786Sjhb 108167789Sjhb // AIX: slightly different from POSIX. 109167789Sjhb // On AIX, readdir_r returns 0 or != 0 and error details in errno. 110167786Sjhb if (::readdir_r(dirp, dbuf, &p) != 0) { 111167789Sjhb return NULL; 112153321Srodrigc } 113153321Srodrigc return p; 114153321Srodrigc} 115153321Srodrigc 116153321Srodrigcinline int os::closedir(DIR *dirp) { 117153321Srodrigc assert(dirp != NULL, "argument is NULL"); 118153321Srodrigc return ::closedir(dirp); 119153321Srodrigc} 120153321Srodrigc 121153321Srodrigc// macros for restartable system calls 122153321Srodrigc 123167786Sjhb#define RESTARTABLE(_cmd, _result) do { \ 124167786Sjhb _result = _cmd; \ 125167786Sjhb } while(((int)_result == OS_ERR) && (errno == EINTR)) 126183352Sjhb 127183352Sjhb#define RESTARTABLE_RETURN_INT(_cmd) do { \ 128167786Sjhb int _result; \ 129167786Sjhb RESTARTABLE(_cmd, _result); \ 130167789Sjhb return _result; \ 131181394Sjhb} while(false) 132181394Sjhb 133181394Sjhb// We don't have NUMA support on Aix, but we need this for compilation. 134183352Sjhbinline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; } 135181394Sjhbinline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; } 136181394Sjhb 137181394Sjhbinline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) { 138181394Sjhb size_t res; 139177085Sjeff RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res); 140167786Sjhb return res; 141167786Sjhb} 142167786Sjhb 143237719Sjhbinline size_t os::write(int fd, const void *buf, unsigned int nBytes) { 144167786Sjhb size_t res; 145167786Sjhb RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); 146181394Sjhb return res; 147181394Sjhb} 148181394Sjhb 149181394Sjhbinline int os::close(int fd) { 150153321Srodrigc return ::close(fd); 151153321Srodrigc} 152153321Srodrigc 153153321Srodrigcinline int os::socket_close(int fd) { 154153321Srodrigc return ::close(fd); 155153321Srodrigc} 156153321Srodrigc 157167789Sjhbinline int os::socket(int domain, int type, int protocol) { 158153321Srodrigc return ::socket(domain, type, protocol); 159167789Sjhb} 160153321Srodrigc 161153321Srodrigcinline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { 16283366Sjulian RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); 16371088Sjasone} 16497995Sjhb 165237719Sjhbinline int os::send(int fd, char* buf, size_t nBytes, uint flags) { 16671088Sjasone RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); 167167789Sjhb} 168167789Sjhb 169111883Sjhbinline int os::raw_send(int fd, char *buf, size_t nBytes, uint flags) { 170181394Sjhb return os::send(fd, buf, nBytes, flags); 171181394Sjhb} 172167789Sjhb 17371088Sjasoneinline int os::connect(int fd, struct sockaddr *him, socklen_t len) { 174126326Sjhb RESTARTABLE_RETURN_INT(::connect(fd, him, len)); 17571088Sjasone} 176100209Sgallatin 177100209Sgallatininline struct hostent* os::get_host_by_name(char* name) { 178100209Sgallatin return ::gethostbyname(name); 179100209Sgallatin} 18071088Sjasone 181167789Sjhbinline bool os::supports_monotonic_clock() { 18271088Sjasone // mread_real_time() is monotonic on AIX (see os::javaTimeNanos() comments) 18371088Sjasone return true; 18495322Shsu} 185136445Sjhb 18695322Shsuinline void os::exit(int num) { 187127954Sjhb ::exit(num); 18888900Sjhb} 18971088Sjasone 190167789Sjhb#endif // OS_AIX_VM_OS_AIX_INLINE_HPP 191169392Sjhb