diff options
| author | Ulrich Drepper <[email protected]> | 2009-01-10 18:02:05 -0800 |
|---|---|---|
| committer | Ulrich Drepper <[email protected]> | 2009-01-10 18:02:05 -0800 |
| commit | 7e678fa3f6051f7ef24b4610c9a66cab858b6b6e (patch) | |
| tree | fed33d7f4b2d3fe6651bf016e8cabcf26bbb1e42 /libelf | |
| parent | a4b1a95434b90ed147e33363d92e24a035b6b775 (diff) | |
Require __thread support in compiler.
Rename --enable-tls to more appropriate --enable-thread-safety.
Diffstat (limited to 'libelf')
| -rw-r--r-- | libelf/ChangeLog | 5 | ||||
| -rw-r--r-- | libelf/Makefile.am | 4 | ||||
| -rw-r--r-- | libelf/elf_error.c | 83 |
3 files changed, 10 insertions, 82 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 9578f8bd..768346db 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2009-01-10 Ulrich Drepper <[email protected]> + + * Makefile.am: Use USE_LOCKS instead of USE_TLS. + * elf_error.c: Always use __thread. Remove all !USE_TLS code. + 2008-12-11 Roland McGrath <[email protected]> * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Handle diff --git a/libelf/Makefile.am b/libelf/Makefile.am index 2458ecbd..84b01a86 100644 --- a/libelf/Makefile.am +++ b/libelf/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2006, 2007, 2008 Red Hat, Inc. +## Copyright (C) 1996-2006, 2007, 2008, 2009 Red Hat, Inc. ## This file is part of Red Hat elfutils. ## ## Red Hat elfutils is free software; you can redistribute it and/or modify @@ -106,7 +106,7 @@ libelf_pic_a_SOURCES = am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os) libelf_so_LDLIBS = -if USE_TLS +if USE_LOCKS libelf_so_LDLIBS += -lpthread endif diff --git a/libelf/elf_error.c b/libelf/elf_error.c index 5e00372a..dc587828 100644 --- a/libelf/elf_error.c +++ b/libelf/elf_error.c @@ -1,5 +1,5 @@ /* Error handling in libelf. - Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. + Copyright (C) 1998,1999,2000,2002,2003,2004,2005,2006,2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <[email protected]>, 1998. @@ -61,46 +61,14 @@ #include "libelfP.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 elf_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) ELF_E_NOERROR); - return result; - } -#endif /* TLS */ - - result = global_error; + int result = global_error; global_error = ELF_E_NOERROR; return result; } @@ -339,16 +307,6 @@ void __libelf_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 < nmsgidx ? value : ELF_E_UNKNOWN_ERROR; } @@ -357,19 +315,7 @@ const char * elf_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) { @@ -382,26 +328,3 @@ elf_errmsg (error) assert (msgidx[error == -1 ? last_error : error] < sizeof (msgstr)); return _(msgstr + msgidx[error == -1 ? last_error : error]); } - - -#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 */ |
