/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_BSD_VM_OS_BSD_HPP
#define OS_BSD_VM_OS_BSD_HPP
// Bsd_OS defines the interface to Bsd operating systems
/* pthread_getattr_np comes with BsdThreads-0.9-7 on RedHat 7.1 */
#ifdef __APPLE__
// Mac OS X doesn't support clock_gettime. Stub out the type, it is
// unused
typedef int clockid_t;
#endif
class Bsd {
friend class os;
// For signal-chaining
// preinstalled signal handlers
// __sigaction(), signal() is loaded
static struct sigaction *get_preinstalled_handler(int);
static void save_preinstalled_handler(int, struct sigaction&);
static void check_signal_handler(int sig);
// For signal flags diagnostics
#ifndef _ALLBSD_SOURCE
static const char *_glibc_version;
static const char *_libpthread_version;
static bool _is_floating_stack;
static bool _is_NPTL;
static bool _supports_fast_thread_cpu_time;
#endif
protected:
#ifndef _ALLBSD_SOURCE
#endif
static int _page_size;
static julong available_memory();
static void initialize_system_info();
#ifndef _ALLBSD_SOURCE
#endif
static bool supports_variable_stack_size();
#ifndef _ALLBSD_SOURCE
#endif
static void rebuild_cpu_to_node_map();
public:
static void init_thread_fpu_state();
#ifndef _ALLBSD_SOURCE
static int get_fpu_control_word();
static void set_fpu_control_word(int fpu_control);
#endif
#ifndef _ALLBSD_SOURCE
// returns kernel thread id (similar to LWP id on Solaris), which can be
// used to access /proc
#endif
#ifndef _ALLBSD_SOURCE
#endif
static bool is_initial_thread(void);
// For Analyzer Forte AsyncGetCallTrace profiling support:
//
// This interface should be declared in os_bsd_i486.hpp, but
// that file provides extensions to the os class and not the
// Bsd class.
// This boolean allows users to forward their own non-matching signals
// to JVM_handle_bsd_signal, harmlessly.
static bool signal_handlers_are_installed;
static int get_our_sigflags(int);
static void set_our_sigflags(int, int);
static void signal_sets_init();
static void install_signal_handlers();
static void set_signal_handler(int, bool);
static bool is_sig_ignored(int sig);
static sigset_t* unblocked_signals();
static sigset_t* vm_signals();
static sigset_t* allowdebug_blocked_signals();
// For signal-chaining
#ifndef _ALLBSD_SOURCE
// GNU libc and libpthread version strings
// NPTL or BsdThreads?
// NPTL is always floating stack. BsdThreads could be using floating
// stack or fixed stack.
static void libpthread_init();
static bool libnuma_init();
#endif
// Minimum stack size a thread can be created with (allowing
// the VM to completely create the thread and enter user code)
// Return default stack size or guard size for the specified thread type
#ifndef _ALLBSD_SOURCE
// Stack overflow handling
static int max_register_window_saves_before_flushing();
#endif
// Real-time clock functions
static void clock_init(void);
#ifndef _ALLBSD_SOURCE
// fast POSIX clocks support
static void fast_thread_clock_init(void);
#endif
static inline bool supports_monotonic_clock() {
return _clock_gettime != NULL;
}
}
#ifndef _ALLBSD_SOURCE
}
static bool supports_fast_thread_cpu_time() {
return _supports_fast_thread_cpu_time;
}
#endif
// Stack repair handling
// none present
// BsdThreads work-around for 6292965
static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
private:
typedef int (*sched_getcpu_func_t)(void);
typedef int (*numa_max_node_func_t)(void);
typedef int (*numa_available_func_t)(void);
static unsigned long* _numa_all_nodes;
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
public:
}
}
}
}
static int get_node_by_cpu(int cpu_id);
};
private:
volatile int _Event ;
volatile int _nParked ;
public: // TODO-FIXME: make dtor private
public:
PlatformEvent() {
int status;
_Event = 0 ;
_nParked = 0 ;
}
// Use caution with reset() and fired() -- they may require MEMBARs
void park () ;
void unpark () ;
int TryPark () ;
};
protected:
public: // TODO-FIXME: make dtor private
public:
PlatformParker() {
int status;
}
};
#endif // OS_BSD_VM_OS_BSD_HPP