diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-01-10 18:02:05 -0800 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-01-10 18:02:05 -0800 |
commit | 7e678fa3f6051f7ef24b4610c9a66cab858b6b6e (patch) | |
tree | fed33d7f4b2d3fe6651bf016e8cabcf26bbb1e42 /libasm | |
parent | a4b1a95434b90ed147e33363d92e24a035b6b775 (diff) | |
download | elfutils-7e678fa3f6051f7ef24b4610c9a66cab858b6b6e.tar.gz |
Require __thread support in compiler.
Rename --enable-tls to more appropriate --enable-thread-safety.
Diffstat (limited to 'libasm')
-rw-r--r-- | libasm/ChangeLog | 5 | ||||
-rw-r--r-- | libasm/Makefile.am | 4 | ||||
-rw-r--r-- | libasm/asm_error.c | 112 |
3 files changed, 11 insertions, 110 deletions
diff --git a/libasm/ChangeLog b/libasm/ChangeLog index c98deb64..d0d40396 100644 --- a/libasm/ChangeLog +++ b/libasm/ChangeLog @@ -1,3 +1,8 @@ +2009-01-10 Ulrich Drepper <drepper@redhat.com> + + * Makefile.am: Use USE_LOCKS instead of USE_TLS. + * asm_error.c: Always use __thread. Remove all !USE_TLS code. + 2008-12-03 Ulrich Drepper <drepper@redhat.com> * Makefile.am [USE_TLS]: Like libasm.so with libpthread. diff --git a/libasm/Makefile.am b/libasm/Makefile.am index 62b5ee29..7d5e25d1 100644 --- a/libasm/Makefile.am +++ b/libasm/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 2002, 2004, 2005, 2006, 2008 Red Hat, Inc. +## Copyright (C) 2002, 2004, 2005, 2006, 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 @@ -66,7 +66,7 @@ libasm_pic_a_SOURCES = am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os) libasm_so_LDLIBS = -if USE_TLS +if USE_LOCKS libasm_so_LDLIBS += -lpthread endif diff --git a/libasm/asm_error.c b/libasm/asm_error.c index 29c54cb0..4d249e9f 100644 --- a/libasm/asm_error.c +++ b/libasm/asm_error.c @@ -1,5 +1,5 @@ /* Error handling in libasm. - Copyright (C) 2002, 2004, 2005 Red Hat, Inc. + Copyright (C) 2002, 2004, 2005, 2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -36,50 +36,13 @@ /* 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); +static __thread int global_error; int asm_errno (void) { - int result; - - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if (threaded) - { - /* We have a key. Use it to get the thread-specific buffer. */ - int *buffer = getspecific (key); - if (buffer == NULL) - { - /* No buffer allocated so far. */ - buffer = (int *) malloc (sizeof (int)); - if (buffer == NULL) - /* No more memory available. We use the static buffer. */ - buffer = &global_error; - - setspecific (key, buffer); - - *buffer = 0; - } - - result = *buffer; - *buffer = ASM_E_NOERROR; - return result; - } - - result = global_error; + int result = global_error; global_error = ASM_E_NOERROR; return result; } @@ -89,27 +52,6 @@ void __libasm_seterrno (value) int value; { - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if (threaded) - { - /* We have a key. Use it to get the thread-specific buffer. */ - int *buffer = getspecific (key); - if (buffer == NULL) - { - /* No buffer allocated so far. */ - buffer = malloc (sizeof (int)); - if (buffer == NULL) - /* No more memory available. We use the static buffer. */ - buffer = &global_error; - - setspecific (key, buffer); - } - - *buffer = value; - } - global_error = value; } @@ -133,31 +75,7 @@ const char * asm_errmsg (error) int error; { - int last_error; - - /* If we have not yet initialized the buffer do it now. */ - once_execute (once, init); - - if ((error == 0 || error == -1) && threaded) - { - /* We have a key. Use it to get the thread-specific buffer. */ - int *buffer = (int *) getspecific (key); - if (buffer == NULL) - { - /* No buffer allocated so far. */ - buffer = (int *) malloc (sizeof (int)); - if (buffer == NULL) - /* No more memory available. We use the static buffer. */ - buffer = &global_error; - - setspecific (key, buffer); - *buffer = 0; - } - - last_error = *buffer; - } - else - last_error = global_error; + int last_error = global_error; if (error < -1) return _("unknown error"); @@ -173,25 +91,3 @@ asm_errmsg (error) return _(msgs[last_error]); } - - -/* Free the thread specific data, this is done if a thread terminates. */ -static void -free_key_mem (void *mem) -{ - free (mem); - 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; -} |