Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/aix/vm/os_aix.inline.hpp
32284 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* Copyright 2012, 2013 SAP AG. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef OS_AIX_VM_OS_AIX_INLINE_HPP26#define OS_AIX_VM_OS_AIX_INLINE_HPP2728#include "runtime/atomic.inline.hpp"29#include "runtime/orderAccess.inline.hpp"30#include "runtime/os.hpp"3132// System includes3334#include <unistd.h>35#include <sys/socket.h>36#include <sys/poll.h>37#include <sys/ioctl.h>38#include <netdb.h>3940// Defined in the system headers included above.41#undef rem_size4243inline void* os::thread_local_storage_at(int index) {44return pthread_getspecific((pthread_key_t)index);45}4647inline const char* os::file_separator() {48return "/";49}5051inline const char* os::line_separator() {52return "\n";53}5455inline const char* os::path_separator() {56return ":";57}5859// File names are case-sensitive on windows only60inline int os::file_name_strcmp(const char* s1, const char* s2) {61return strcmp(s1, s2);62}6364inline bool os::obsolete_option(const JavaVMOption *option) {65return false;66}6768inline bool os::uses_stack_guard_pages() {69return true;70}7172inline bool os::allocate_stack_guard_pages() {73assert(uses_stack_guard_pages(), "sanity check");74return true;75}767778// On Aix, reservations are made on a page by page basis, nothing to do.79inline void os::pd_split_reserved_memory(char *base, size_t size,80size_t split, bool realloc) {81}828384// Bang the shadow pages if they need to be touched to be mapped.85inline void os::bang_stack_shadow_pages() {86}8788inline void os::dll_unload(void *lib) {89::dlclose(lib);90}9192inline const int os::default_file_open_flags() { return 0;}9394inline jlong os::lseek(int fd, jlong offset, int whence) {95return (jlong) ::lseek64(fd, offset, whence);96}9798inline int os::fsync(int fd) {99return ::fsync(fd);100}101102inline char* os::native_path(char *path) {103return path;104}105106inline int os::ftruncate(int fd, jlong length) {107return ::ftruncate64(fd, length);108}109110// macros for restartable system calls111112#define RESTARTABLE(_cmd, _result) do { \113_result = _cmd; \114} while(((int)_result == OS_ERR) && (errno == EINTR))115116#define RESTARTABLE_RETURN_INT(_cmd) do { \117int _result; \118RESTARTABLE(_cmd, _result); \119return _result; \120} while(false)121122// We don't have NUMA support on Aix, but we need this for compilation.123inline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; }124inline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; }125126inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {127size_t res;128RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);129return res;130}131132inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {133size_t res;134RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);135return res;136}137138inline int os::close(int fd) {139return ::close(fd);140}141142inline int os::socket_close(int fd) {143return ::close(fd);144}145146inline int os::socket(int domain, int type, int protocol) {147return ::socket(domain, type, protocol);148}149150inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {151RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));152}153154inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {155RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));156}157158inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {159return os::send(fd, buf, nBytes, flags);160}161162inline int os::timeout(int fd, long timeout) {163julong prevtime,newtime;164struct timeval t;165166gettimeofday(&t, NULL);167prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;168169for(;;) {170struct pollfd pfd;171172pfd.fd = fd;173pfd.events = POLLIN | POLLERR;174175int res = ::poll(&pfd, 1, timeout);176177if (res == OS_ERR && errno == EINTR) {178179// On Linux any value < 0 means "forever"180181if(timeout >= 0) {182gettimeofday(&t, NULL);183newtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;184timeout -= newtime - prevtime;185if(timeout <= 0)186return OS_OK;187prevtime = newtime;188}189} else190return res;191}192}193194inline int os::listen(int fd, int count) {195return ::listen(fd, count);196}197198inline int os::connect(int fd, struct sockaddr* him, socklen_t len) {199RESTARTABLE_RETURN_INT(::connect(fd, him, len));200}201202inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {203// Linux doc says this can't return EINTR, unlike accept() on Solaris.204// But see attachListener_linux.cpp, LinuxAttachListener::dequeue().205return (int)::accept(fd, him, len);206}207208inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,209sockaddr* from, socklen_t* fromlen) {210RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen));211}212213inline int os::sendto(int fd, char* buf, size_t len, uint flags,214struct sockaddr* to, socklen_t tolen) {215RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen));216}217218inline int os::socket_shutdown(int fd, int howto) {219return ::shutdown(fd, howto);220}221222inline int os::bind(int fd, struct sockaddr* him, socklen_t len) {223return ::bind(fd, him, len);224}225226inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {227return ::getsockname(fd, him, len);228}229230inline int os::get_host_name(char* name, int namelen) {231return ::gethostname(name, namelen);232}233234inline struct hostent* os::get_host_by_name(char* name) {235return ::gethostbyname(name);236}237238inline int os::get_sock_opt(int fd, int level, int optname,239char* optval, socklen_t* optlen) {240return ::getsockopt(fd, level, optname, optval, optlen);241}242243inline int os::set_sock_opt(int fd, int level, int optname,244const char* optval, socklen_t optlen) {245return ::setsockopt(fd, level, optname, optval, optlen);246}247#endif // OS_AIX_VM_OS_AIX_INLINE_HPP248249250