From e092e7c30464555b3fb81adc8f2f479e892b0786 Mon Sep 17 00:00:00 2001 From: Hans-Christian Egtvedt Date: Wed, 16 Dec 2009 13:12:00 +0100 Subject: check if USE_TLS is defined before use This patch will convert all the #ifdef USE_TLS and #if USE_TLS to #if defined(USE_TLS) && USE_TLS. By checking if the USE_TLS is defined before checking its value will result in correct behavior for architectures not defining this config symbol. Signed-off-by: Hans-Christian Egtvedt Acked-by: Carmelo AMOROSO --- ldso/libdl/libdl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ldso/libdl') diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 22b622d28..05a68ddcc 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -39,14 +39,14 @@ #include #endif -#if USE_TLS +#if defined(USE_TLS) && USE_TLS #include extern void (*_dl_init_static_tls) (struct link_map *); extern void _dl_add_to_slotinfo(struct link_map *l); #endif #ifdef SHARED -# if USE_TLS +# if defined(USE_TLS) && USE_TLS # include extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid); # endif @@ -112,7 +112,7 @@ struct r_debug *_dl_debug_addr = NULL; #include "../ldso/dl-debug.c" -# if USE_TLS +# if defined(USE_TLS) && USE_TLS /* * Giving this initialized value preallocates some surplus bytes in the * static TLS area, see __libc_setup_tls (libc-tls.c). @@ -166,7 +166,7 @@ static const char *const dl_error_names[] = { }; -#if USE_TLS +#if defined(USE_TLS) && USE_TLS #ifdef SHARED /* * Systems which do not have tls_index also probably have to define @@ -284,7 +284,7 @@ void *dlopen(const char *libname, int flag) unsigned int nlist, i; struct elf_resolve **init_fini_list; static bool _dl_init; -#if USE_TLS +#if defined(USE_TLS) && USE_TLS bool any_tls = false; #endif @@ -519,7 +519,7 @@ void *dlopen(const char *libname, int flag) /* TODO: Should we set the protections of all pages back to R/O now ? */ -#if USE_TLS +#if defined(USE_TLS) && USE_TLS for (i=0; i < nlist; i++) { struct elf_resolve *tmp_tpnt = init_fini_list[i]; @@ -670,7 +670,7 @@ void *dlsym(void *vhandle, const char *name) tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ ret = _dl_find_hash(name2, handle, NULL, 0, &tls_tpnt); -#if defined USE_TLS && defined SHARED +#if defined(USE_TLS) && USE_TLS && defined SHARED if (tls_tpnt) { /* The found symbol is a thread-local storage variable. Return the address for to the current thread. */ @@ -709,7 +709,7 @@ static int do_dlclose(void *vhandle, int need_fini) struct dyn_elf *handle; unsigned int end; unsigned int i, j; -#if USE_TLS +#if defined(USE_TLS) && USE_TLS bool any_tls = false; size_t tls_free_start = NO_TLS_OFFSET; size_t tls_free_end = NO_TLS_OFFSET; @@ -771,7 +771,7 @@ static int do_dlclose(void *vhandle, int need_fini) end = ppnt->p_vaddr + ppnt->p_memsz; } -#if USE_TLS +#if defined(USE_TLS) && USE_TLS /* Do the cast to make things easy. */ tls_lmap = (struct link_map *) tpnt; @@ -924,7 +924,7 @@ static int do_dlclose(void *vhandle, int need_fini) free(handle->init_fini.init_fini); free(handle); -#if USE_TLS +#if defined(USE_TLS) && USE_TLS /* If we removed any object which uses TLS bump the generation counter. */ if (any_tls) { if (__builtin_expect(++_dl_tls_generation == 0, 0)) { -- cgit v1.2.3