Commit d0b9a143 by Mike Stump Committed by Jason Merrill

libgcc2.c (top_elt): Remove top_elt, it isn't thread safe.

	* libgcc2.c (top_elt): Remove top_elt, it isn't thread safe.
	The strategy we now use is to pre allocate the top_elt along
	with the EH context so that each thread has its own top_elt.
	This is necessary as the dynmanic cleanup chain is used on the
	top element of the stack and each thread MUST have its own.
	(eh_context_static): Likewise.
	(new_eh_context): Likewise.
	(__sjthrow): Likewise.

From-SVN: r23818
parent 8c8a9717
Mon Nov 23 20:28:02 1998 Mike Stump <mrs@wrs.com>
* libgcc2.c (top_elt): Remove top_elt, it isn't thread safe.
The strategy we now use is to pre allocate the top_elt along
with the EH context so that each thread has its own top_elt.
This is necessary as the dynmanic cleanup chain is used on the
top element of the stack and each thread MUST have its own.
(eh_context_static): Likewise.
(new_eh_context): Likewise.
(__sjthrow): Likewise.
Mon Nov 23 20:25:03 1998 Jason Merrill <jason@yorick.cygnus.com> Mon Nov 23 20:25:03 1998 Jason Merrill <jason@yorick.cygnus.com>
* i386/linux.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Wrap in do...while. * i386/linux.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Wrap in do...while.
......
...@@ -3067,10 +3067,6 @@ __empty () ...@@ -3067,10 +3067,6 @@ __empty ()
#include <stdio.h> #include <stdio.h>
#endif #endif
/* This is a safeguard for dynamic handler chain. */
static void *top_elt[2];
/* Allocate and return a new EH context structure. */ /* Allocate and return a new EH context structure. */
extern void __throw (); extern void __throw ();
...@@ -3078,15 +3074,26 @@ extern void __throw (); ...@@ -3078,15 +3074,26 @@ extern void __throw ();
static void * static void *
new_eh_context () new_eh_context ()
{ {
struct eh_context *eh = (struct eh_context *) malloc (sizeof *eh); struct eh_full_context {
if (! eh) struct eh_context c;
void *top_elt[2];
} *ehfc = (struct eh_full_context *) malloc (sizeof *ehfc);
if (! ehfc)
__terminate (); __terminate ();
memset (eh, 0, sizeof *eh); memset (ehfc, 0, sizeof *ehfc);
eh->dynamic_handler_chain = top_elt; ehfc->c.dynamic_handler_chain = (void **) ehfc->top_elt;
return eh; /* This should optimize out entirely. This should always be true,
but just in case it ever isn't, don't allow bogus code to be
generated. */
if ((void*)(&ehfc->c) != (void*)ehfc)
__terminate ();
return &ehfc->c;
} }
#if __GTHREADS #if __GTHREADS
...@@ -3180,6 +3187,8 @@ eh_context_static () ...@@ -3180,6 +3187,8 @@ eh_context_static ()
{ {
static struct eh_context eh; static struct eh_context eh;
static int initialized; static int initialized;
static void *top_elt[2];
if (! initialized) if (! initialized)
{ {
initialized = 1; initialized = 1;
...@@ -3290,7 +3299,7 @@ __sjthrow () ...@@ -3290,7 +3299,7 @@ __sjthrow ()
/* We must call terminate if we try and rethrow an exception, when /* We must call terminate if we try and rethrow an exception, when
there is no exception currently active and when there are no there is no exception currently active and when there are no
handlers left. */ handlers left. */
if (! eh->info || (*dhc) == top_elt) if (! eh->info || (*dhc)[0] == 0)
__terminate (); __terminate ();
/* Find the jmpbuf associated with the top element of the dynamic /* Find the jmpbuf associated with the top element of the dynamic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment