summaryrefslogtreecommitdiff
path: root/libdw/dwarf_error.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-10 18:02:05 -0800
committerUlrich Drepper <drepper@redhat.com>2009-01-10 18:02:05 -0800
commit7e678fa3f6051f7ef24b4610c9a66cab858b6b6e (patch)
treefed33d7f4b2d3fe6651bf016e8cabcf26bbb1e42 /libdw/dwarf_error.c
parenta4b1a95434b90ed147e33363d92e24a035b6b775 (diff)
downloadelfutils-7e678fa3f6051f7ef24b4610c9a66cab858b6b6e.tar.gz
Require __thread support in compiler.
Rename --enable-tls to more appropriate --enable-thread-safety.
Diffstat (limited to 'libdw/dwarf_error.c')
-rw-r--r--libdw/dwarf_error.c83
1 files changed, 3 insertions, 80 deletions
diff --git a/libdw/dwarf_error.c b/libdw/dwarf_error.c
index fe916641..86ff8213 100644
--- a/libdw/dwarf_error.c
+++ b/libdw/dwarf_error.c
@@ -1,5 +1,5 @@
/* Retrieve ELF descriptor used for DWARF access.
- Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -58,46 +58,14 @@
#include "libdwP.h"
-#ifdef USE_TLS
/* The error number. */
static __thread int global_error;
-#else
-/* This is the key for the thread specific memory. */
-static tls_key_t key;
-
-/* The error number. Used in non-threaded programs. */
-static int global_error;
-static bool threaded;
-/* We need to initialize the thread-specific data. */
-once_define (static, once);
-
-/* The initialization and destruction functions. */
-static void init (void);
-static void free_key_mem (void *mem);
-#endif /* TLS */
int
dwarf_errno (void)
{
- int result;
-
-#ifndef USE_TLS
- /* If we have not yet initialized the buffer do it now. */
- once_execute (once, init);
-
- if (threaded)
- {
- /* We do not allocate memory for the data. It is only a word.
- We can store it in place of the pointer. */
- result = (intptr_t) getspecific (key);
-
- setspecific (key, (void *) (intptr_t) DWARF_E_NOERROR);
- return result;
- }
-#endif /* TLS */
-
- result = global_error;
+ int result = global_error;
global_error = DWARF_E_NOERROR;
return result;
}
@@ -151,16 +119,6 @@ void
__libdw_seterrno (value)
int value;
{
-#ifndef USE_TLS
- /* If we have not yet initialized the buffer do it now. */
- once_execute (once, init);
-
- if (threaded)
- /* We do not allocate memory for the data. It is only a word.
- We can store it in place of the pointer. */
- setspecific (key, (void *) (intptr_t) value);
-#endif /* TLS */
-
global_error = (value >= 0 && value < (int) nerrmsgs
? value : DWARF_E_UNKNOWN_ERROR);
}
@@ -170,19 +128,7 @@ const char *
dwarf_errmsg (error)
int error;
{
- int last_error;
-
-#ifndef USE_TLS
- /* If we have not yet initialized the buffer do it now. */
- once_execute (once, init);
-
- if ((error == 0 || error == -1) && threaded)
- /* We do not allocate memory for the data. It is only a word.
- We can store it in place of the pointer. */
- last_error = (intptr_t) getspecific (key);
- else
-#endif /* TLS */
- last_error = global_error;
+ int last_error = global_error;
if (error == 0)
return last_error != 0 ? _(errmsgs[last_error]) : NULL;
@@ -192,26 +138,3 @@ dwarf_errmsg (error)
return _(errmsgs[error == -1 ? last_error : error]);
}
INTDEF(dwarf_errmsg)
-
-
-#ifndef USE_TLS
-/* Free the thread specific data, this is done if a thread terminates. */
-static void
-free_key_mem (void *mem __attribute__ ((unused)))
-{
- setspecific (key, NULL);
-}
-
-
-/* Initialize the key for the global variable. */
-static void
-init (void)
-{
- // XXX Screw you, gcc4, the unused function attribute does not work.
- __asm ("" :: "r" (free_key_mem));
-
- if (key_create (&key, free_key_mem) == 0)
- /* Creating the key succeeded. */
- threaded = true;
-}
-#endif /* TLS */