src/os/aix/vm/os_aix.inline.hpp

Tue, 29 Apr 2014 15:17:27 +0200

author
goetz
date
Tue, 29 Apr 2014 15:17:27 +0200
changeset 6911
ce8f6bb717c9
parent 0
f90c822e73f8
child 9711
0f2fe7d37d8c
permissions
-rw-r--r--

8042195: Introduce umbrella header orderAccess.inline.hpp.
Reviewed-by: dholmes, kvn, stefank, twisti

     1 /*
     2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2013 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  */
    26 #ifndef OS_AIX_VM_OS_AIX_INLINE_HPP
    27 #define OS_AIX_VM_OS_AIX_INLINE_HPP
    29 #include "runtime/atomic.inline.hpp"
    30 #include "runtime/orderAccess.inline.hpp"
    31 #include "runtime/os.hpp"
    33 // System includes
    35 #include <unistd.h>
    36 #include <sys/socket.h>
    37 #include <sys/poll.h>
    38 #include <sys/ioctl.h>
    39 #include <netdb.h>
    41 // Defined in the system headers included above.
    42 #undef rem_size
    44 inline void* os::thread_local_storage_at(int index) {
    45   return pthread_getspecific((pthread_key_t)index);
    46 }
    48 inline const char* os::file_separator() {
    49   return "/";
    50 }
    52 inline const char* os::line_separator() {
    53   return "\n";
    54 }
    56 inline const char* os::path_separator() {
    57   return ":";
    58 }
    60 // File names are case-sensitive on windows only
    61 inline int os::file_name_strcmp(const char* s1, const char* s2) {
    62   return strcmp(s1, s2);
    63 }
    65 inline bool os::obsolete_option(const JavaVMOption *option) {
    66   return false;
    67 }
    69 inline bool os::uses_stack_guard_pages() {
    70   return true;
    71 }
    73 inline bool os::allocate_stack_guard_pages() {
    74   assert(uses_stack_guard_pages(), "sanity check");
    75   return true;
    76 }
    79 // On Aix, reservations are made on a page by page basis, nothing to do.
    80 inline void os::pd_split_reserved_memory(char *base, size_t size,
    81                                          size_t split, bool realloc) {
    82 }
    85 // Bang the shadow pages if they need to be touched to be mapped.
    86 inline void os::bang_stack_shadow_pages() {
    87 }
    89 inline void os::dll_unload(void *lib) {
    90   ::dlclose(lib);
    91 }
    93 inline const int os::default_file_open_flags() { return 0;}
    95 inline DIR* os::opendir(const char* dirname)
    96 {
    97   assert(dirname != NULL, "just checking");
    98   return ::opendir(dirname);
    99 }
   101 inline int os::readdir_buf_size(const char *path)
   102 {
   103   // according to aix sys/limits, NAME_MAX must be retrieved at runtime. */
   104   const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX);
   105   return my_NAME_MAX + sizeof(dirent) + 1;
   106 }
   108 inline jlong os::lseek(int fd, jlong offset, int whence) {
   109   return (jlong) ::lseek64(fd, offset, whence);
   110 }
   112 inline int os::fsync(int fd) {
   113   return ::fsync(fd);
   114 }
   116 inline char* os::native_path(char *path) {
   117   return path;
   118 }
   120 inline int os::ftruncate(int fd, jlong length) {
   121   return ::ftruncate64(fd, length);
   122 }
   124 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
   125 {
   126   dirent* p;
   127   int status;
   128   assert(dirp != NULL, "just checking");
   130   // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
   131   // version. Here is the doc for this function:
   132   // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
   134   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
   135     errno = status;
   136     return NULL;
   137   } else
   138     return p;
   139 }
   141 inline int os::closedir(DIR *dirp) {
   142   assert(dirp != NULL, "argument is NULL");
   143   return ::closedir(dirp);
   144 }
   146 // macros for restartable system calls
   148 #define RESTARTABLE(_cmd, _result) do { \
   149     _result = _cmd; \
   150   } while(((int)_result == OS_ERR) && (errno == EINTR))
   152 #define RESTARTABLE_RETURN_INT(_cmd) do { \
   153   int _result; \
   154   RESTARTABLE(_cmd, _result); \
   155   return _result; \
   156 } while(false)
   158 // We don't have NUMA support on Aix, but we need this for compilation.
   159 inline bool os::numa_has_static_binding()   { ShouldNotReachHere(); return true; }
   160 inline bool os::numa_has_group_homing()     { ShouldNotReachHere(); return false;  }
   162 inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
   163   size_t res;
   164   RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
   165   return res;
   166 }
   168 inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
   169   size_t res;
   170   RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
   171   return res;
   172 }
   174 inline int os::close(int fd) {
   175   return ::close(fd);
   176 }
   178 inline int os::socket_close(int fd) {
   179   return ::close(fd);
   180 }
   182 inline int os::socket(int domain, int type, int protocol) {
   183   return ::socket(domain, type, protocol);
   184 }
   186 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
   187   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
   188 }
   190 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
   191   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
   192 }
   194 inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
   195   return os::send(fd, buf, nBytes, flags);
   196 }
   198 inline int os::timeout(int fd, long timeout) {
   199   julong prevtime,newtime;
   200   struct timeval t;
   202   gettimeofday(&t, NULL);
   203   prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
   205   for(;;) {
   206     struct pollfd pfd;
   208     pfd.fd = fd;
   209     pfd.events = POLLIN | POLLERR;
   211     int res = ::poll(&pfd, 1, timeout);
   213     if (res == OS_ERR && errno == EINTR) {
   215       // On Linux any value < 0 means "forever"
   217       if(timeout >= 0) {
   218         gettimeofday(&t, NULL);
   219         newtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
   220         timeout -= newtime - prevtime;
   221         if(timeout <= 0)
   222           return OS_OK;
   223         prevtime = newtime;
   224       }
   225     } else
   226       return res;
   227   }
   228 }
   230 inline int os::listen(int fd, int count) {
   231   return ::listen(fd, count);
   232 }
   234 inline int os::connect(int fd, struct sockaddr* him, socklen_t len) {
   235   RESTARTABLE_RETURN_INT(::connect(fd, him, len));
   236 }
   238 inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
   239   // Linux doc says this can't return EINTR, unlike accept() on Solaris.
   240   // But see attachListener_linux.cpp, LinuxAttachListener::dequeue().
   241   return (int)::accept(fd, him, len);
   242 }
   244 inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
   245                         sockaddr* from, socklen_t* fromlen) {
   246   RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen));
   247 }
   249 inline int os::sendto(int fd, char* buf, size_t len, uint flags,
   250                       struct sockaddr* to, socklen_t tolen) {
   251   RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen));
   252 }
   254 inline int os::socket_shutdown(int fd, int howto) {
   255   return ::shutdown(fd, howto);
   256 }
   258 inline int os::bind(int fd, struct sockaddr* him, socklen_t len) {
   259   return ::bind(fd, him, len);
   260 }
   262 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
   263   return ::getsockname(fd, him, len);
   264 }
   266 inline int os::get_host_name(char* name, int namelen) {
   267   return ::gethostname(name, namelen);
   268 }
   270 inline struct hostent* os::get_host_by_name(char* name) {
   271   return ::gethostbyname(name);
   272 }
   274 inline int os::get_sock_opt(int fd, int level, int optname,
   275                             char* optval, socklen_t* optlen) {
   276   return ::getsockopt(fd, level, optname, optval, optlen);
   277 }
   279 inline int os::set_sock_opt(int fd, int level, int optname,
   280                             const char* optval, socklen_t optlen) {
   281   return ::setsockopt(fd, level, optname, optval, optlen);
   282 }
   283 #endif // OS_AIX_VM_OS_AIX_INLINE_HPP

mercurial