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
117
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 int clock_gettime(clockid_t clock_id, struct timespec *tp) {
138 return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
139 }
140
141 // Stack repair handling
142
143 // none present
144
145 // BsdThreads work-around for 6292965
146 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
147
148 private:
149 typedef int (*sched_getcpu_func_t)(void);
150 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
151 typedef int (*numa_max_node_func_t)(void);
152 typedef int (*numa_available_func_t)(void);
153 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
154 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
155
156 static sched_getcpu_func_t _sched_getcpu;
157 static numa_node_to_cpus_func_t _numa_node_to_cpus;
158 static numa_max_node_func_t _numa_max_node;
159 static numa_available_func_t _numa_available;
160 static numa_tonode_memory_func_t _numa_tonode_memory;
|
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
123
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 // Stack repair handling
144
145 // none present
146
147 // BsdThreads work-around for 6292965
148 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
149
150 private:
151 typedef int (*sched_getcpu_func_t)(void);
152 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
153 typedef int (*numa_max_node_func_t)(void);
154 typedef int (*numa_available_func_t)(void);
155 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
156 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
157
158 static sched_getcpu_func_t _sched_getcpu;
159 static numa_node_to_cpus_func_t _numa_node_to_cpus;
160 static numa_max_node_func_t _numa_max_node;
161 static numa_available_func_t _numa_available;
162 static numa_tonode_memory_func_t _numa_tonode_memory;
|