2 * threads.c: Thread handles
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
19 #include <sys/types.h>
22 #include <mono/io-layer/wapi.h>
23 #include <mono/io-layer/wapi-private.h>
24 #include <mono/io-layer/timed-thread.h>
25 #include <mono/io-layer/handles-private.h>
26 #include <mono/io-layer/misc-private.h>
27 #include <mono/io-layer/mono-mutex.h>
28 #include <mono/io-layer/thread-private.h>
29 #include <mono/io-layer/mono-spinlock.h>
30 #include <mono/io-layer/mutex-private.h>
32 #if HAVE_VALGRIND_MEMCHECK_H
33 #include <valgrind/memcheck.h>
40 /* Hash threads with tids. I thought of using TLS for this, but that
41 * would have to set the data in the new thread, which is more hassle
43 static mono_once_t thread_hash_once = MONO_ONCE_INIT;
44 static mono_mutex_t thread_hash_mutex = MONO_MUTEX_INITIALIZER;
45 static GHashTable *thread_hash=NULL;
47 static gboolean thread_own (gpointer handle);
49 struct _WapiHandleOps _wapi_thread_ops = {
50 NULL, /* close_shared */
56 static mono_once_t thread_ops_once=MONO_ONCE_INIT;
58 #ifdef WITH_INCLUDED_LIBGC
59 static void gc_init (void);
62 static void thread_ops_init (void)
64 _wapi_handle_register_capabilities (WAPI_HANDLE_THREAD,
65 WAPI_HANDLE_CAP_WAIT);
67 #ifdef WITH_INCLUDED_LIBGC
72 static gboolean thread_own (gpointer handle)
74 struct _WapiHandle_thread *thread_handle;
78 g_message ("%s: owning thread handle %p", __func__, handle);
81 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
82 (gpointer *)&thread_handle);
84 g_warning ("%s: error looking up thread handle %p", __func__,
89 if (thread_handle->joined == FALSE) {
90 _wapi_timed_thread_join (thread_handle->thread, NULL, NULL);
91 thread_handle->joined = TRUE;
97 static void thread_exit(guint32 exitstatus, gpointer handle)
99 struct _WapiHandle_thread *thread_handle;
103 pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
105 thr_ret = _wapi_handle_lock_handle (handle);
106 g_assert (thr_ret == 0);
108 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
109 (gpointer *)&thread_handle);
111 g_warning ("%s: error looking up thread handle %p", __func__,
116 _wapi_mutex_check_abandoned (getpid (), thread_handle->thread->id);
119 g_message ("%s: Recording thread handle %p exit status", __func__,
123 thread_handle->exitstatus = exitstatus;
124 thread_handle->state = THREAD_STATE_EXITED;
126 _wapi_handle_set_signal_state (handle, TRUE, TRUE);
128 thr_ret = _wapi_handle_unlock_handle (handle);
129 g_assert (thr_ret == 0);
130 pthread_cleanup_pop (0);
133 g_message("%s: Recording thread handle %p id %ld status as %d",
134 __func__, handle, thread_handle->thread->id, exitstatus);
137 /* Remove this thread from the hash */
138 pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
139 (void *)&thread_hash_mutex);
140 thr_ret = mono_mutex_lock(&thread_hash_mutex);
141 g_assert (thr_ret == 0);
143 g_hash_table_remove (thread_hash, GUINT_TO_POINTER (thread_handle->thread->id));
145 thr_ret = mono_mutex_unlock(&thread_hash_mutex);
146 g_assert (thr_ret == 0);
147 pthread_cleanup_pop (0);
149 /* The thread is no longer active, so unref it */
150 _wapi_handle_unref (handle);
153 static void thread_hash_init(void)
155 thread_hash = g_hash_table_new (NULL, NULL);
160 * @security: Ignored for now.
161 * @stacksize: the size in bytes of the new thread's stack. Use 0 to
162 * default to the normal stack size. (Ignored for now).
163 * @start: The function that the new thread should start with
164 * @param: The parameter to give to @start.
165 * @create: If 0, the new thread is ready to run immediately. If
166 * %CREATE_SUSPENDED, the new thread will be in the suspended state,
167 * requiring a ResumeThread() call to continue running.
168 * @tid: If non-NULL, the ID of the new thread is stored here.
170 * Creates a new threading handle.
172 * Return value: a new handle, or NULL
174 gpointer CreateThread(WapiSecurityAttributes *security G_GNUC_UNUSED, guint32 stacksize,
175 WapiThreadStart start, gpointer param, guint32 create,
178 struct _WapiHandle_thread thread_handle = {0}, *thread_handle_p;
185 gpointer ct_ret = NULL;
187 mono_once (&thread_hash_once, thread_hash_init);
188 mono_once (&thread_ops_once, thread_ops_init);
194 thread_handle.state = THREAD_STATE_START;
195 thread_handle.owner_pid = getpid();
197 handle = _wapi_handle_new (WAPI_HANDLE_THREAD, &thread_handle);
198 if (handle == _WAPI_HANDLE_INVALID) {
199 g_warning ("%s: error creating thread handle", __func__);
200 SetLastError (ERROR_GEN_FAILURE);
205 pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
207 thr_ret = _wapi_handle_lock_handle (handle);
208 g_assert (thr_ret == 0);
210 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
211 (gpointer *)&thread_handle_p);
213 g_warning ("%s: error looking up thread handle %p", __func__,
215 SetLastError (ERROR_GEN_FAILURE);
220 /* Hold a reference while the thread is active, because we use
221 * the handle to store thread exit information
223 _wapi_handle_ref (handle);
225 /* Lock around the thread create, so that the new thread cant
226 * race us to look up the thread handle in GetCurrentThread()
228 pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
229 (void *)&thread_hash_mutex);
230 thr_ret = mono_mutex_lock(&thread_hash_mutex);
231 g_assert (thr_ret == 0);
233 /* Set a 2M stack size. This is the default on Linux, but BSD
234 * needs it. (The original bug report from Martin Dvorak <md@9ll.cz>
235 * set the size to 2M-4k. I don't know why it's short by 4k, so
236 * I'm leaving it as 2M until I'm told differently.)
238 thr_ret = pthread_attr_init(&attr);
239 g_assert (thr_ret == 0);
241 /* defaults of 2Mb for 32bits and 4Mb for 64bits */
242 /* temporarily changed to use 1 MB: this allows more threads
243 * to be used, as well as using less virtual memory and so
244 * more is available for the GC heap.
247 #if HAVE_VALGRIND_MEMCHECK_H
248 if (RUNNING_ON_VALGRIND) {
251 stacksize = (SIZEOF_VOID_P / 4) * 1024 * 1024;
254 stacksize = (SIZEOF_VOID_P / 4) * 1024 * 1024;
258 #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
259 thr_ret = pthread_attr_setstacksize(&attr, stacksize);
260 g_assert (thr_ret == 0);
263 ret = _wapi_timed_thread_create (&thread_handle_p->thread, &attr,
264 create, start, thread_exit, param,
268 g_message ("%s: Thread create error: %s", __func__,
272 /* Two, because of the reference we took above */
275 goto thread_hash_cleanup;
279 g_hash_table_insert (thread_hash,
280 GUINT_TO_POINTER (thread_handle_p->thread->id),
284 g_message("%s: Started thread handle %p thread %p ID %ld", __func__,
285 handle, thread_handle_p->thread,
286 thread_handle_p->thread->id);
290 #ifdef PTHREAD_POINTER_ID
291 *tid = GPOINTER_TO_UINT (thread_handle_p->thread->id);
293 *tid = thread_handle_p->thread->id;
298 thr_ret = mono_mutex_unlock (&thread_hash_mutex);
299 g_assert (thr_ret == 0);
300 pthread_cleanup_pop (0);
303 thr_ret = _wapi_handle_unlock_handle (handle);
304 g_assert (thr_ret == 0);
305 pthread_cleanup_pop (0);
307 /* Must not call _wapi_handle_unref() with the handle already
310 for (i = 0; i < unrefs; i++) {
311 _wapi_handle_unref (handle);
317 gpointer OpenThread (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, guint32 tid)
322 mono_once (&thread_hash_once, thread_hash_init);
323 mono_once (&thread_ops_once, thread_ops_init);
326 g_message ("%s: looking up thread %d", __func__, tid);
329 pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
330 (void *)&thread_hash_mutex);
331 thr_ret = mono_mutex_lock(&thread_hash_mutex);
332 g_assert (thr_ret == 0);
334 ret = g_hash_table_lookup (thread_hash, GUINT_TO_POINTER (tid));
336 thr_ret = mono_mutex_unlock(&thread_hash_mutex);
337 g_assert (thr_ret == 0);
338 pthread_cleanup_pop (0);
341 _wapi_handle_ref (ret);
345 g_message ("%s: returning thread handle %p", __func__, ret);
353 * @exitcode: Sets the thread's exit code, which can be read from
354 * another thread with GetExitCodeThread().
356 * Terminates the calling thread. A thread can also exit by returning
357 * from its start function. When the last thread in a process
358 * terminates, the process itself terminates.
360 void ExitThread(guint32 exitcode)
362 _wapi_timed_thread_exit(exitcode);
367 * @handle: The thread handle to query
368 * @exitcode: The thread @handle exit code is stored here
370 * Finds the exit code of @handle, and stores it in @exitcode. If the
371 * thread @handle is still running, the value stored is %STILL_ACTIVE.
373 * Return value: %TRUE, or %FALSE on error.
375 gboolean GetExitCodeThread(gpointer handle, guint32 *exitcode)
377 struct _WapiHandle_thread *thread_handle;
380 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
381 (gpointer *)&thread_handle);
383 g_warning ("%s: error looking up thread handle %p", __func__,
389 g_message ("%s: Finding exit status for thread handle %p id %ld",
390 __func__, handle, thread_handle->thread->id);
393 if (exitcode == NULL) {
395 g_message ("%s: Nowhere to store exit code", __func__);
400 if (thread_handle->state != THREAD_STATE_EXITED) {
402 g_message ("%s: Thread still active (state %d, exited is %d)",
403 __func__, thread_handle->state,
404 THREAD_STATE_EXITED);
406 *exitcode = STILL_ACTIVE;
410 *exitcode = thread_handle->exitstatus;
416 * GetCurrentThreadId:
418 * Looks up the thread ID of the current thread. This ID can be
419 * passed to OpenThread() to create a new handle on this thread.
421 * Return value: the thread ID.
423 guint32 GetCurrentThreadId(void)
425 pthread_t tid = pthread_self();
427 #ifdef PTHREAD_POINTER_ID
428 return(GPOINTER_TO_UINT(tid));
434 static gpointer thread_attach(guint32 *tid)
436 struct _WapiHandle_thread thread_handle = {0}, *thread_handle_p;
442 gpointer ta_ret = NULL;
444 mono_once (&thread_hash_once, thread_hash_init);
445 mono_once (&thread_ops_once, thread_ops_init);
447 thread_handle.state = THREAD_STATE_START;
448 thread_handle.owner_pid = getpid();
450 handle = _wapi_handle_new (WAPI_HANDLE_THREAD, &thread_handle);
451 if (handle == _WAPI_HANDLE_INVALID) {
452 g_warning ("%s: error creating thread handle", __func__);
454 SetLastError (ERROR_GEN_FAILURE);
458 pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
460 thr_ret = _wapi_handle_lock_handle (handle);
461 g_assert (thr_ret == 0);
463 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
464 (gpointer *)&thread_handle_p);
466 g_warning ("%s: error looking up thread handle %p", __func__,
469 SetLastError (ERROR_GEN_FAILURE);
473 /* Hold a reference while the thread is active, because we use
474 * the handle to store thread exit information
476 _wapi_handle_ref (handle);
478 /* Lock around the thread create, so that the new thread cant
479 * race us to look up the thread handle in GetCurrentThread()
481 pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
482 (void *)&thread_hash_mutex);
483 thr_ret = mono_mutex_lock(&thread_hash_mutex);
484 g_assert (thr_ret == 0);
486 ret = _wapi_timed_thread_attach (&thread_handle_p->thread, thread_exit,
490 g_message ("%s: Thread attach error: %s", __func__,
494 /* Two, because of the reference we took above */
497 goto thread_hash_cleanup;
501 g_hash_table_insert (thread_hash,
502 GUINT_TO_POINTER (thread_handle_p->thread->id),
506 g_message("%s: Attached thread handle %p thread %p ID %ld", __func__,
507 handle, thread_handle_p->thread,
508 thread_handle_p->thread->id);
512 #ifdef PTHREAD_POINTER_ID
513 *tid = GPOINTER_TO_UINT(thread_handle_p->thread->id);
515 *tid = thread_handle_p->thread->id;
520 thr_ret = mono_mutex_unlock (&thread_hash_mutex);
521 g_assert (thr_ret == 0);
522 pthread_cleanup_pop (0);
525 thr_ret = _wapi_handle_unlock_handle (handle);
526 g_assert (thr_ret == 0);
527 pthread_cleanup_pop (0);
529 /* Must not call _wapi_handle_unref() with the handle already
532 for (i = 0; i < unrefs; i++) {
533 _wapi_handle_unref (handle);
542 * Looks up the handle associated with the current thread. Under
543 * Windows this is a pseudohandle, and must be duplicated with
544 * DuplicateHandle() for some operations.
546 * Return value: The current thread handle, or %NULL on failure.
547 * (Unknown whether Windows has a possible failure here. It may be
548 * necessary to implement the pseudohandle-constant behaviour).
550 gpointer GetCurrentThread(void)
556 mono_once(&thread_hash_once, thread_hash_init);
557 mono_once (&thread_ops_once, thread_ops_init);
559 tid=GetCurrentThreadId();
561 pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
562 (void *)&thread_hash_mutex);
563 thr_ret = mono_mutex_lock(&thread_hash_mutex);
564 g_assert (thr_ret == 0);
566 ret = g_hash_table_lookup (thread_hash, GUINT_TO_POINTER (tid));
568 thr_ret = mono_mutex_unlock(&thread_hash_mutex);
569 g_assert (thr_ret == 0);
570 pthread_cleanup_pop (0);
573 ret = thread_attach (NULL);
581 * @handle: the thread handle to resume
583 * Decrements the suspend count of thread @handle. A thread can only
584 * run if its suspend count is zero.
586 * Return value: the previous suspend count, or 0xFFFFFFFF on error.
588 guint32 ResumeThread(gpointer handle)
590 struct _WapiHandle_thread *thread_handle;
593 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
594 (gpointer *)&thread_handle);
596 g_warning ("%s: error looking up thread handle %p", __func__,
602 if (thread_handle->thread == NULL) {
606 #ifdef WITH_INCLUDED_LIBGC
607 if (thread_handle->thread->suspend_count <= 1)
608 _wapi_timed_thread_resume (thread_handle->thread);
610 return (--thread_handle->thread->suspend_count));
612 /* This is still a kludge that only copes with starting a
613 * thread that was suspended on create, so don't bother with
614 * the suspend count crap yet
616 _wapi_timed_thread_resume (thread_handle->thread);
623 * @handle: the thread handle to suspend
625 * Increments the suspend count of thread @handle. A thread can only
626 * run if its suspend count is zero.
628 * Return value: the previous suspend count, or 0xFFFFFFFF on error.
630 guint32 SuspendThread(gpointer handle)
632 #ifdef WITH_INCLUDED_LIBGC
633 struct _WapiHandle_thread *thread_handle;
637 current = GetCurrentThread ();
638 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
639 (gpointer *)&thread_handle);
641 g_warning ("%s: error looking up thread handle %p", __func__,
646 if (thread_handle->thread == NULL) {
650 if (!thread_handle->thread->suspend_count) {
651 if (handle == current)
652 _wapi_timed_thread_suspend (thread_handle->thread);
654 pthread_kill (thread_handle->thread->id, SIGPWR);
655 while (MONO_SEM_WAIT (&thread_handle->thread->suspended_sem) != 0) {
656 if (errno != EINTR) {
663 return (thread_handle->thread->suspend_count++);
670 * We assume here that TLS_MINIMUM_AVAILABLE is less than
671 * PTHREAD_KEYS_MAX, allowing enough overhead for a few TLS keys for
674 * Currently TLS_MINIMUM_AVAILABLE is 64 and _POSIX_THREAD_KEYS_MAX
675 * (the minimum value for PTHREAD_KEYS_MAX) is 128, so we should be
679 static pthread_key_t TLS_keys[TLS_MINIMUM_AVAILABLE];
680 static gboolean TLS_used[TLS_MINIMUM_AVAILABLE]={FALSE};
681 static guint32 TLS_spinlock=0;
684 mono_pthread_key_for_tls (guint32 idx)
686 return (guint32)TLS_keys [idx];
692 * Allocates a Thread Local Storage (TLS) index. Any thread in the
693 * same process can use this index to store and retrieve values that
694 * are local to that thread.
696 * Return value: The index value, or %TLS_OUT_OF_INDEXES if no index
699 guint32 TlsAlloc(void)
704 MONO_SPIN_LOCK (TLS_spinlock);
706 for(i=0; i<TLS_MINIMUM_AVAILABLE; i++) {
707 if(TLS_used[i]==FALSE) {
709 thr_ret = pthread_key_create(&TLS_keys[i], NULL);
710 g_assert (thr_ret == 0);
712 MONO_SPIN_UNLOCK (TLS_spinlock);
715 g_message ("%s: returning key %d", __func__, i);
722 MONO_SPIN_UNLOCK (TLS_spinlock);
725 g_message ("%s: out of indices", __func__);
729 return(TLS_OUT_OF_INDEXES);
732 #define MAKE_GC_ID(idx) (GUINT_TO_POINTER((idx)|(GetCurrentThreadId()<<8)))
736 * @idx: The TLS index to free
738 * Releases a TLS index, making it available for reuse. This call
739 * will delete any TLS data stored under index @idx in all threads.
741 * Return value: %TRUE on success, %FALSE otherwise.
743 gboolean TlsFree(guint32 idx)
748 g_message ("%s: freeing key %d", __func__, idx);
751 MONO_SPIN_LOCK (TLS_spinlock);
753 if(TLS_used[idx]==FALSE) {
754 MONO_SPIN_UNLOCK (TLS_spinlock);
760 thr_ret = pthread_key_delete(TLS_keys[idx]);
761 g_assert (thr_ret == 0);
763 MONO_SPIN_UNLOCK (TLS_spinlock);
770 * @idx: The TLS index to retrieve
772 * Retrieves the TLS data stored under index @idx.
774 * Return value: The value stored in the TLS index @idx in the current
775 * thread, or %NULL on error. As %NULL can be a valid return value,
776 * in this case GetLastError() returns %ERROR_SUCCESS.
778 gpointer TlsGetValue(guint32 idx)
783 g_message ("%s: looking up key %d", __func__, idx);
786 ret=pthread_getspecific(TLS_keys[idx]);
789 g_message ("%s: returning %p", __func__, ret);
797 * @idx: The TLS index to store
798 * @value: The value to store under index @idx
800 * Stores @value at TLS index @idx.
802 * Return value: %TRUE on success, %FALSE otherwise.
804 gboolean TlsSetValue(guint32 idx, gpointer value)
809 g_message ("%s: setting key %d to %p", __func__, idx, value);
812 MONO_SPIN_LOCK (TLS_spinlock);
814 if(TLS_used[idx]==FALSE) {
816 g_message ("%s: key %d unused", __func__, idx);
819 MONO_SPIN_UNLOCK (TLS_spinlock);
824 ret=pthread_setspecific(TLS_keys[idx], value);
827 g_message ("%s: pthread_setspecific error: %s", __func__,
831 MONO_SPIN_UNLOCK (TLS_spinlock);
836 MONO_SPIN_UNLOCK (TLS_spinlock);
843 * @ms: The time in milliseconds to suspend for
844 * @alertable: if TRUE, the wait can be interrupted by an APC call
846 * Suspends execution of the current thread for @ms milliseconds. A
847 * value of zero causes the thread to relinquish its time slice. A
848 * value of %INFINITE causes an infinite delay.
850 guint32 SleepEx(guint32 ms, gboolean alertable)
852 struct timespec req, rem;
855 gpointer current_thread = NULL;
858 g_message("%s: Sleeping for %d ms", __func__, ms);
862 current_thread = GetCurrentThread ();
863 if (_wapi_thread_apc_pending (current_thread)) {
864 _wapi_thread_dispatch_apc_queue (current_thread);
865 return WAIT_IO_COMPLETION;
874 /* FIXME: check for INFINITE and sleep forever */
879 req.tv_nsec=ms_rem*1000000;
882 ret=nanosleep(&req, &rem);
884 if (alertable && _wapi_thread_apc_pending (current_thread)) {
885 _wapi_thread_dispatch_apc_queue (current_thread);
886 return WAIT_IO_COMPLETION;
890 /* Sleep interrupted with rem time remaining */
892 guint32 rems=rem.tv_sec*1000 + rem.tv_nsec/1000000;
894 g_message("%s: Still got %d ms to go", __func__, rems);
903 void Sleep(guint32 ms)
908 guint32 QueueUserAPC (WapiApcProc apc_callback, gpointer handle,
911 struct _WapiHandle_thread *thread_handle;
914 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
915 (gpointer *)&thread_handle);
917 g_warning ("%s: error looking up thread handle %p", __func__,
922 _wapi_timed_thread_queue_apc (thread_handle->thread, apc_callback,
927 gboolean _wapi_thread_cur_apc_pending (void)
929 return(_wapi_thread_apc_pending (GetCurrentThread ()));
932 gboolean _wapi_thread_apc_pending (gpointer handle)
934 struct _WapiHandle_thread *thread_handle;
937 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
938 (gpointer *)&thread_handle);
940 g_warning ("%s: error looking up thread handle %p", __func__,
945 return(_wapi_timed_thread_apc_pending (thread_handle->thread));
948 gboolean _wapi_thread_dispatch_apc_queue (gpointer handle)
950 struct _WapiHandle_thread *thread_handle;
953 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
954 (gpointer *)&thread_handle);
956 g_warning ("%s: error looking up thread handle %p", __func__,
961 _wapi_timed_thread_dispatch_apc_queue (thread_handle->thread);
967 #ifdef WITH_INCLUDED_LIBGC
969 static void GC_suspend_handler (int sig)
971 struct _WapiHandle_thread *thread_handle;
975 handle = GetCurrentThread ();
976 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
977 (gpointer *)&thread_handle);
979 g_warning ("%s: error looking up thread handle %p", __func__,
984 thread_handle->thread->stack_ptr = &ok;
985 MONO_SEM_POST (&thread_handle->thread->suspended_sem);
987 _wapi_timed_thread_suspend (thread_handle->thread);
989 thread_handle->thread->stack_ptr = NULL;
992 static void gc_init (void)
994 struct sigaction act;
996 act.sa_handler = GC_suspend_handler;
997 g_assert (sigaction (SIGPWR, &act, NULL) == 0);
1000 void mono_wapi_push_thread_stack (gpointer handle, gpointer stack_ptr)
1002 struct _WapiHandle_thread *thread_handle;
1005 ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
1006 (gpointer *)&thread_handle);
1008 g_warning ("%s: error looking up thread handle %p", __func__,
1013 GC_push_all_stack (thread_handle->thread->stack_ptr, stack_ptr);
1016 #endif /* WITH_INCLUDED_LIBGC */