1 /*
   2  * Copyright (c) 1997, 2019, 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_OS_SOLARIS_INLINE_HPP
  26 #define OS_SOLARIS_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 inline bool os::uses_stack_guard_pages() {
  41   return true;
  42 }
  43 
  44 inline bool os::must_commit_stack_guard_pages() {
  45   assert(uses_stack_guard_pages(), "sanity check");
  46   int r = thr_main() ;
  47   guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
  48   return r;
  49 }
  50 
  51 
  52 // On Solaris, 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 }
  56 
  57 
  58 // Bang the shadow pages if they need to be touched to be mapped.
  59 inline void os::map_stack_shadow_pages(address sp) {
  60 }
  61 
  62 inline void os::dll_unload(void *lib) { ::dlclose(lib); }
  63 
  64 //////////////////////////////////////////////////////////////////////////////
  65 ////////////////////////////////////////////////////////////////////////////////
  66 
  67 // macros for restartable system calls
  68 
  69 #define RESTARTABLE(_cmd, _result) do { \
  70   do { \
  71     _result = _cmd; \
  72   } while((_result == OS_ERR) && (errno == EINTR)); \
  73 } while(false)
  74 
  75 #define RESTARTABLE_RETURN_INT(_cmd) do { \
  76   int _result; \
  77   RESTARTABLE(_cmd, _result); \
  78   return _result; \
  79 } while(false)
  80 
  81 inline bool os::numa_has_static_binding()   { return false; }
  82 inline bool os::numa_has_group_homing()     { return true;  }
  83 
  84 inline int    os::socket(int domain, int type, int protocol) {
  85   return ::socket(domain, type, protocol);
  86 }
  87 
  88 inline struct hostent* os::get_host_by_name(char* name) {
  89   return ::gethostbyname(name);
  90 }
  91 
  92 inline bool os::supports_monotonic_clock() {
  93   // javaTimeNanos() is monotonic on Solaris, see getTimeNanos() comments
  94   return true;
  95 }
  96 
  97 inline void os::exit(int num) {
  98   ::exit(num);
  99 }
 100 
 101 #endif // OS_SOLARIS_OS_SOLARIS_INLINE_HPP