diff options
author | Mike Stump <mrs@wrs.com> | 1998-11-23 15:37:20 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-11-23 15:37:20 -0500 |
commit | 4959c33f37bf36b50446f513787be99790cc40b1 (patch) | |
tree | 6fdaf40f4391f86cd73a7294d5a285dba1f521d0 | |
parent | 51b9a5d17eaa74a750922a380c8389770e83b749 (diff) |
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.
(new_eh_context): Likewise.
(__sjthrow): Likewise.
From-SVN: r23817
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/libgcc2.c | 27 |
2 files changed, 28 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e53213f0935..bd191ca7bb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +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. + (new_eh_context): Likewise. + (__sjthrow): Likewise. + Mon Nov 23 09:53:44 1998 Richard Henderson <rth@cygnus.com> * local-alloc.c (local_alloc): Use malloc not alloca for @@ -5,7 +15,7 @@ Mon Nov 23 09:53:44 1998 Richard Henderson <rth@cygnus.com> Mon Nov 23 09:49:49 1998 Andrew MacLeod <amacleod@cygnus.com> - *cplus-dem.c (demangle_prefix): Use the last "__" + * cplus-dem.c (demangle_prefix): Use the last "__" in the mangled name when looking for the signature. This allows template names to begin with "__". diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 7c26e6bc946..d1854edc8e4 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -3059,10 +3059,6 @@ __empty () #include "eh-common.h" -/* This is a safeguard for dynamic handler chain. */ - -static void *top_elt[2]; - /* Allocate and return a new EH context structure. */ extern void __throw (); @@ -3070,15 +3066,26 @@ extern void __throw (); static void * new_eh_context () { - struct eh_context *eh = (struct eh_context *) malloc (sizeof *eh); - if (! eh) + struct eh_full_context { + struct eh_context c; + void *top_elt[2]; + } *ehfc = (struct eh_full_context *) malloc (sizeof *ehfc); + + if (! ehfc) __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 @@ -3275,7 +3282,7 @@ __sjthrow () /* We must call terminate if we try and rethrow an exception, when there is no exception currently active and when there are no handlers left. */ - if (! eh->info || (*dhc) == top_elt) + if (! eh->info || (*dhc)[0] == 0) __terminate (); /* Find the jmpbuf associated with the top element of the dynamic |