aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/pthread/unwind-forcedunwind.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/pthread/unwind-forcedunwind.c')
-rw-r--r--nptl/sysdeps/pthread/unwind-forcedunwind.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c
index b0f8487086..6792d719d3 100644
--- a/nptl/sysdeps/pthread/unwind-forcedunwind.c
+++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>.
@@ -31,13 +31,18 @@ static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
void
+__attribute_noinline__
pthread_cancel_init (void)
{
void *resume, *personality, *forcedunwind, *getcfa;
void *handle;
if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
- return;
+ {
+ /* Force gcc to reload all values. */
+ asm volatile ("" ::: "memory");
+ return;
+ }
handle = __libc_dlopen ("libgcc_s.so.1");
@@ -56,6 +61,10 @@ pthread_cancel_init (void)
libgcc_s_resume = resume;
libgcc_s_personality = personality;
libgcc_s_forcedunwind = forcedunwind;
+ /* Make sure libgcc_s_getcfa is written last. Otherwise,
+ pthread_cancel_init might return early even when the pointer the
+ caller is interested in is not initialized yet. */
+ atomic_write_barrier ();
libgcc_s_getcfa = getcfa;
}
@@ -64,6 +73,7 @@ _Unwind_Resume (struct _Unwind_Exception *exc)
{
if (__builtin_expect (libgcc_s_resume == NULL, 0))
pthread_cancel_init ();
+
libgcc_s_resume (exc);
}
@@ -75,6 +85,7 @@ __gcc_personality_v0 (int version, _Unwind_Action actions,
{
if (__builtin_expect (libgcc_s_personality == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_personality (version, actions, exception_class,
ue_header, context);
}
@@ -85,6 +96,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
{
if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_forcedunwind (exc, stop, stop_argument);
}
@@ -93,5 +105,6 @@ _Unwind_GetCFA (struct _Unwind_Context *context)
{
if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_getcfa (context);
}