rev 13069 : imported patch Remove_GNU_SOURCE

   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. 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 it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 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 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
  26 #define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
  27 
  28 #include "runtime/os.hpp"
  29 
  30 // System includes
  31 #include <sys/param.h>
  32 #include <dlfcn.h>
  33 #include <sys/socket.h>
  34 #include <poll.h>
  35 #include <sys/filio.h>
  36 #include <unistd.h>
  37 #include <netdb.h>
  38 #include <setjmp.h>
  39 
  40 // File names are case-sensitive on windows only
  41 inline int os::file_name_strcmp(const char* s1, const char* s2) {
  42   return strcmp(s1, s2);
  43 }
  44 
  45 inline bool os::uses_stack_guard_pages() {
  46   return true;
  47 }
  48 
  49 inline bool os::must_commit_stack_guard_pages() {
  50   assert(uses_stack_guard_pages(), "sanity check");
  51   int r = thr_main() ;
  52   guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
  53   return r;
  54 }
  55 
  56 
  57 // On Solaris, reservations are made on a page by page basis, nothing to do.
  58 inline void os::pd_split_reserved_memory(char *base, size_t size,
  59                                       size_t split, bool realloc) {
  60 }
  61 
  62 
  63 // Bang the shadow pages if they need to be touched to be mapped.
  64 inline void os::map_stack_shadow_pages(address sp) {
  65 }
  66 
  67 inline void os::dll_unload(void *lib) { ::dlclose(lib); }
  68 
  69 inline const int os::default_file_open_flags() { return 0;}
  70 
  71 inline DIR* os::opendir(const char* dirname) {
  72   assert(dirname != NULL, "just checking");
  73   return ::opendir(dirname);
  74 }
  75 
  76 inline int os::readdir_buf_size(const char *path) {
  77   int size = pathconf(path, _PC_NAME_MAX);
  78   return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
  79 }
  80 
  81 inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) {
  82   assert(dirp != NULL, "just checking");
  83 #if defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
  84   dirent* p;
  85   int status;
  86 
  87   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
  88     errno = status;
  89     return NULL;
  90   } else
  91     return p;
  92 #else  // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
  93   return ::readdir_r(dirp, dbuf);
  94 #endif // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
  95 }
  96 
  97 inline int os::closedir(DIR *dirp) {
  98   assert(dirp != NULL, "argument is NULL");
  99   return ::closedir(dirp);
 100 }
 101 
 102 //////////////////////////////////////////////////////////////////////////////
 103 ////////////////////////////////////////////////////////////////////////////////
 104 
 105 // macros for restartable system calls
 106 
 107 #define RESTARTABLE(_cmd, _result) do { \
 108   do { \
 109     _result = _cmd; \
 110   } while((_result == OS_ERR) && (errno == EINTR)); \
 111 } while(false)
 112 
 113 #define RESTARTABLE_RETURN_INT(_cmd) do { \
 114   int _result; \
 115   RESTARTABLE(_cmd, _result); \
 116   return _result; \
 117 } while(false)
 118 
 119 inline bool os::numa_has_static_binding()   { return false; }
 120 inline bool os::numa_has_group_homing()     { return true;  }
 121 
 122 inline int    os::socket(int domain, int type, int protocol) {
 123   return ::socket(domain, type, protocol);
 124 }
 125 
 126 inline struct hostent* os::get_host_by_name(char* name) {
 127   return ::gethostbyname(name);
 128 }
 129 
 130 inline bool os::supports_monotonic_clock() {
 131   // javaTimeNanos() is monotonic on Solaris, see getTimeNanos() comments
 132   return true;
 133 }
 134 
 135 inline void os::exit(int num) {
 136   ::exit(num);
 137 }
 138 
 139 #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
--- EOF ---