This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch introduces TRY_STATIC_TLS, a macro that can be used to test whether a module's TLS block is in the static TLS block, or can be assigned there. If you use a sufficiently-recent version of GCC and never call TRY_STATIC_TLS, the new static intermediate function will be fully inlined into the single caller, without any performance hit whatsoever.
Index: ChangeLog 2004-11-10 Alexandre Oliva <aoliva@redhat.com> * elf/dl-reloc.c (_dl_try_allocate_static_tls): Move out of... (_dl_allocate_static_tls): ... this. (TRY_STATIC_TLS): New. Index: elf/dl-reloc.c --- elf/dl-reloc.c 2005-01-22 16:18:28.000000000 -0200 +++ elf/dl-reloc.c 2005-01-31 04:37:42.000000000 -0200 @@ -44,16 +44,14 @@ This function intentionally does not return any value but signals error directly, as static TLS should be rare and code handling it should not be inlined as much as possible. */ -void -internal_function __attribute_noinline__ -_dl_allocate_static_tls (struct link_map *map) +static int +_dl_try_allocate_static_tls (struct link_map *map) { /* If the alignment requirements are too high fail. */ if (map->l_tls_align > GL(dl_tls_static_align)) { fail: - _dl_signal_error (0, map->l_name, NULL, N_("\ -cannot allocate memory in static TLS block")); + return -1; } # if TLS_TCB_AT_TP @@ -107,6 +105,19 @@ } else map->l_need_tls_init = 1; + + return 0; +} + +void +internal_function __attribute_noinline__ +_dl_allocate_static_tls (struct link_map *map) +{ + if (_dl_try_allocate_static_tls (map)) + { + _dl_signal_error (0, map->l_name, NULL, N_("\ +cannot allocate memory in static TLS block")); + } } /* Initialize static TLS area and DTV for current (only) thread. @@ -258,6 +269,10 @@ _dl_allocate_static_tls (sym_map); \ } while (0) +#define TRY_STATIC_TLS(map, sym_map) \ + (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1) \ + || _dl_try_allocate_static_tls (sym_map) == 0) + #include "dynamic-link.h" ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
-- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |