41
42 class Bsd {
43 friend class os;
44
45 // For signal-chaining
46 #define MAXSIGNUM 32
47 static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
48 static unsigned int sigs; // mask of signals that have
49 // preinstalled signal handlers
50 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
51 // __sigaction(), signal() is loaded
52 static struct sigaction *(*get_signal_action)(int);
53 static struct sigaction *get_preinstalled_handler(int);
54 static void save_preinstalled_handler(int, struct sigaction&);
55
56 static void check_signal_handler(int sig);
57
58 // For signal flags diagnostics
59 static int sigflags[MAXSIGNUM];
60
61 static int (*_clock_gettime)(clockid_t, struct timespec *);
62
63 static GrowableArray<int>* _cpu_to_node;
64
65 protected:
66
67 static julong _physical_memory;
68 static pthread_t _main_thread;
69 static int _page_size;
70
71 static julong available_memory();
72 static julong physical_memory() { return _physical_memory; }
73 static void initialize_system_info();
74
75 static bool supports_variable_stack_size();
76
77 static void rebuild_cpu_to_node_map();
78 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
79
80 static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
81
118 static sigset_t* unblocked_signals();
119 static sigset_t* vm_signals();
120 static sigset_t* allowdebug_blocked_signals();
121
122 // For signal-chaining
123 static struct sigaction *get_chained_signal_action(int sig);
124 static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
125
126 // Minimum stack size a thread can be created with (allowing
127 // the VM to completely create the thread and enter user code)
128 static size_t min_stack_allowed;
129
130 // Return default stack size or guard size for the specified thread type
131 static size_t default_stack_size(os::ThreadType thr_type);
132 static size_t default_guard_size(os::ThreadType thr_type);
133
134 // Real-time clock functions
135 static void clock_init(void);
136
137 static inline bool supports_monotonic_clock() {
138 return _clock_gettime != NULL;
139 }
140
141 static int clock_gettime(clockid_t clock_id, struct timespec *tp) {
142 return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
143 }
144
145 // Stack repair handling
146
147 // none present
148
149 // BsdThreads work-around for 6292965
150 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
151
152 private:
153 typedef int (*sched_getcpu_func_t)(void);
154 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
155 typedef int (*numa_max_node_func_t)(void);
156 typedef int (*numa_available_func_t)(void);
157 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
158 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
159
160 static sched_getcpu_func_t _sched_getcpu;
161 static numa_node_to_cpus_func_t _numa_node_to_cpus;
162 static numa_max_node_func_t _numa_max_node;
|
41
42 class Bsd {
43 friend class os;
44
45 // For signal-chaining
46 #define MAXSIGNUM 32
47 static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
48 static unsigned int sigs; // mask of signals that have
49 // preinstalled signal handlers
50 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
51 // __sigaction(), signal() is loaded
52 static struct sigaction *(*get_signal_action)(int);
53 static struct sigaction *get_preinstalled_handler(int);
54 static void save_preinstalled_handler(int, struct sigaction&);
55
56 static void check_signal_handler(int sig);
57
58 // For signal flags diagnostics
59 static int sigflags[MAXSIGNUM];
60
61 #ifdef __APPLE__
62 // mach_absolute_time
63 static mach_timebase_info_data_t _timebase_info;
64 static volatile uint64_t _max_abstime;
65 #else
66 static int (*_clock_gettime)(clockid_t, struct timespec *);
67 #endif
68
69 static GrowableArray<int>* _cpu_to_node;
70
71 protected:
72
73 static julong _physical_memory;
74 static pthread_t _main_thread;
75 static int _page_size;
76
77 static julong available_memory();
78 static julong physical_memory() { return _physical_memory; }
79 static void initialize_system_info();
80
81 static bool supports_variable_stack_size();
82
83 static void rebuild_cpu_to_node_map();
84 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
85
86 static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
87
124 static sigset_t* unblocked_signals();
125 static sigset_t* vm_signals();
126 static sigset_t* allowdebug_blocked_signals();
127
128 // For signal-chaining
129 static struct sigaction *get_chained_signal_action(int sig);
130 static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
131
132 // Minimum stack size a thread can be created with (allowing
133 // the VM to completely create the thread and enter user code)
134 static size_t min_stack_allowed;
135
136 // Return default stack size or guard size for the specified thread type
137 static size_t default_stack_size(os::ThreadType thr_type);
138 static size_t default_guard_size(os::ThreadType thr_type);
139
140 // Real-time clock functions
141 static void clock_init(void);
142
143 static inline bool supports_monotonic_clock() {
144 #ifdef __APPLE__
145 return true;
146 #else
147 return _clock_gettime != NULL;
148 #endif
149 }
150
151 // Stack repair handling
152
153 // none present
154
155 // BsdThreads work-around for 6292965
156 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
157
158 private:
159 typedef int (*sched_getcpu_func_t)(void);
160 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
161 typedef int (*numa_max_node_func_t)(void);
162 typedef int (*numa_available_func_t)(void);
163 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
164 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
165
166 static sched_getcpu_func_t _sched_getcpu;
167 static numa_node_to_cpus_func_t _numa_node_to_cpus;
168 static numa_max_node_func_t _numa_max_node;
|