1999-10-04 Mark Mitchell <mark@codesourcery.com>
[official-gcc.git] / boehm-gc / quick_threads.c
blobadc26da6d59419d26eaf4b44d2629846132d1892
1 /*
2 * Support code for cooperative coop/quick threads.
3 * Copyright (c) 1998, 1999 Cygnus Solutions.
4 */
6 #include "boehm-config.h"
8 #ifdef QUICK_THREADS
10 #include "gc_priv.h"
12 #include "coop.h"
14 void GC_push_all_stacks (void)
16 coop_t *t;
17 ptr_t lo, hi;
19 t = coop_first_thread ();
21 if (t == NULL)
23 /* Threads haven't started, so mark the real stack. */
24 #ifdef STACK_GROWS_DOWN
25 GC_push_all_stack( GC_approx_sp(), GC_stackbottom );
26 #else
27 GC_push_all_stack( GC_stackbottom, GC_approx_sp() );
28 #endif
30 else
32 for ( ; t != NULL; t = coop_next_thread (t))
34 if (t == coop_global_curr)
35 lo = GC_approx_sp ();
36 else
38 lo = t->top;
39 /* LO can be NULL when the new thread has not yet been
40 used. */
41 if (! lo)
42 continue;
44 hi = t->base;
46 #ifdef STACK_GROWS_DOWN
47 GC_push_all_stack (lo, hi);
48 #else
49 GC_push_all_stack (hi, lo);
50 #endif
55 #endif /* QUICK_THREADS */