summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-12-07 22:04:26 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-12-07 22:04:26 +0300
commit710b43b7670e49d03323997955911192dd6c6f42 (patch)
tree11c5845de040c005a4fde946f97d3a8076e41244 /pthread_support.c
parentf78736b75a077f3bbbb90c784a809241af20fec9 (diff)
downloadbdwgc-710b43b7670e49d03323997955911192dd6c6f42.tar.gz
Remove main_altstack group of static variables
(refactoring) * pthread_support.c [!GC_WIN32_THREADS] (main_normstack, main_altstack, main_normstack_size, main_altstack_size): Remove static field. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack): If me is NULL then set me to &first_thread; do not store values to main_normstack, main_altstack, main_normstack_size, main_altstack_size. * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set normstack, normstack_size, altstack, altstack_size fields of me.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 9818d6ce..1c51e6b1 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -917,11 +917,6 @@ GC_API int GC_CALL GC_thread_is_registered(void)
return me != NULL;
}
-#ifndef GC_WIN32_THREADS
- static void *main_normstack, *main_altstack;
- static word main_normstack_size, main_altstack_size;
-#endif
-
GC_API void GC_CALL GC_register_altstack(void *normstack,
GC_word normstack_size, void *altstack, GC_word altstack_size)
{
@@ -938,18 +933,14 @@ GC_API void GC_CALL GC_register_altstack(void *normstack,
LOCK();
me = GC_lookup_thread(self_id);
- if (EXPECT(me != NULL, TRUE)) {
- me -> normstack = (ptr_t)normstack;
- me -> normstack_size = normstack_size;
- me -> altstack = (ptr_t)altstack;
- me -> altstack_size = altstack_size;
- } else {
- /* This happens if we are called before GC_thr_init. */
- main_normstack = normstack;
- main_normstack_size = normstack_size;
- main_altstack = altstack;
- main_altstack_size = altstack_size;
+ if (EXPECT(NULL == me, FALSE)) {
+ /* We are called before GC_thr_init. */
+ me = &first_thread;
}
+ me -> normstack = (ptr_t)normstack;
+ me -> normstack_size = normstack_size;
+ me -> altstack = (ptr_t)altstack;
+ me -> altstack_size = altstack_size;
UNLOCK();
#endif
}
@@ -1708,12 +1699,6 @@ GC_INNER void GC_thr_init(void)
GC_ASSERT(NULL == GC_lookup_thread(self_id));
me = GC_register_my_thread_inner(&sb, self_id);
me -> flags = DETACHED | MAIN_THREAD;
-
- /* Copy the alt-stack information if set. */
- me -> normstack = (ptr_t)main_normstack;
- me -> normstack_size = main_normstack_size;
- me -> altstack = (ptr_t)main_altstack;
- me -> altstack_size = main_altstack_size;
}
}