summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-10-17 20:57:02 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-10-19 11:06:43 +0300
commit5a8179a1c4af1521e5790f6e5aebcb33f02d88bd (patch)
tree27b5caa3d5c1d8cedf58eba1d7330db66439c8b9 /win32_threads.c
parented43cd40dd1a47b0950ec6580d9c19acec629485 (diff)
downloadbdwgc-5a8179a1c4af1521e5790f6e5aebcb33f02d88bd.tar.gz
Move pthread_atfork() call to a separate function
(refactoring) * pthread_support.c [CAN_HANDLE_FORK] (store_to_threads_table, GC_remove_all_threads_but_me): Move definition down (to be close to fork_prepare_proc). * pthread_support.c [CAN_HANDLE_FORK]: Reformat comment; adjust code indentation. * pthread_support.c [CAN_HANDLE_FORK] (GC_setup_atfork): New STATIC function (move code from GC_thr_init). * win32_threads.c [CAN_HANDLE_FORK] (GC_setup_atfork): Likewise. * pthread_support.c [CAN_HANDLE_FORK] (GC_thr_init): Call GC_setup_atfork(). * win32_threads.c [CAN_HANDLE_FORK] (GC_thr_init): Likewise.
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 4dc9c260..0611d603 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -1072,6 +1072,22 @@ GC_API void * GC_CALL GC_get_my_stackbottom(struct GC_stack_base *sb)
if (GC_handle_fork <= 0)
fork_child_proc();
}
+
+ /* Prepare for forks if requested. */
+ STATIC void GC_setup_atfork(void)
+ {
+ if (GC_handle_fork) {
+# ifdef CAN_CALL_ATFORK
+ if (pthread_atfork(fork_prepare_proc, fork_parent_proc,
+ fork_child_proc) == 0) {
+ /* Handlers successfully registered. */
+ GC_handle_fork = 1;
+ } else
+# endif
+ /* else */ if (GC_handle_fork != -1)
+ ABORT("pthread_atfork failed");
+ }
+ }
#endif /* CAN_HANDLE_FORK */
void GC_push_thread_structures(void)
@@ -2614,20 +2630,8 @@ GC_INNER void GC_thr_init(void)
# else
main_thread_id = GetCurrentThreadId();
# endif
-
# ifdef CAN_HANDLE_FORK
- /* Prepare for forks if requested. */
- if (GC_handle_fork) {
-# ifdef CAN_CALL_ATFORK
- if (pthread_atfork(fork_prepare_proc, fork_parent_proc,
- fork_child_proc) == 0) {
- /* Handlers successfully registered. */
- GC_handle_fork = 1;
- } else
-# endif
- /* else */ if (GC_handle_fork != -1)
- ABORT("pthread_atfork failed");
- }
+ GC_setup_atfork();
# endif
# ifdef WOW64_THREAD_CONTEXT_WORKAROUND