From patchwork Thu Aug 21 10:57:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 2489 Received: (qmail 16730 invoked by alias); 21 Aug 2014 10:58:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16662 invoked by uid 89); 21 Aug 2014 10:58:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: Siddhesh Poyarekar Subject: [PATCH 05/19] Remove IN_LIB Date: Thu, 21 Aug 2014 16:27:29 +0530 Message-Id: <1408618663-2281-6-git-send-email-siddhesh@redhat.com> In-Reply-To: <1408618663-2281-1-git-send-email-siddhesh@redhat.com> References: <1408618663-2281-1-git-send-email-siddhesh@redhat.com> Replace with IS_IN and IS_IN_LIB macros instead. This change results in a change in generated code, because it fixes a subtle bug. The bug was introduced when systemtap probes were added to lowlevellock.h, which resulted in stap-probe.h being included in a number of places. stap-probe.h always defines IN_LIB, which breaks a check in errno.h and netdb.h since they rely on that macro to decide whether to implement an internal version of a declaration or an external one. The components that see a code change due to this are: iconv_prog libmemusage.so libpcprofile.so libSegFault.so libutil.so.1 locale localedef nscd All other built components (i.e. libc, libpthread, etc.) remain unchanged by this on x86_64. * elf/Makefile (CPPFLAGS-.os): Remove IN_LIB. * elf/rtld-Rules (rtld-CPPFLAGS): Likewise. * extra-lib.mk (CPPFLAGS-$(lib)): Likewise. * include/libc-symbols.h (IS_IN_LIB): New macro. * include/errno.h: Use IS_IN_LIB instead of IN_LIB. * include/netdb.h: Likewise. * include/stap-probe.h: Remove all uses of IN_LIB. --- elf/Makefile | 2 +- elf/rtld-Rules | 2 +- extra-lib.mk | 2 +- include/errno.h | 4 ++-- include/libc-symbols.h | 5 +++++ include/netdb.h | 4 ++-- include/stap-probe.h | 12 ------------ 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index f7d384d..c25bec0 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -437,7 +437,7 @@ CFLAGS-cache.c = $(SYSCONF-FLAGS) CFLAGS-rtld.c = $(SYSCONF-FLAGS) CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\ - -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld) + -DNOT_IN_libc=1 -DIS_IN_rtld=1) cpp-srcs-left := $(all-rtld-routines:=.os) lib := rtld diff --git a/elf/rtld-Rules b/elf/rtld-Rules index 4d78d90..d106048 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -144,6 +144,6 @@ lib := rtld include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) # This here is the whole point of all the shenanigans. -rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld +rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 endif diff --git a/extra-lib.mk b/extra-lib.mk index fd8812c..c719bd9 100644 --- a/extra-lib.mk +++ b/extra-lib.mk @@ -106,4 +106,4 @@ ifneq (,$(cpp-srcs-left)) include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) endif -CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib) +CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 diff --git a/include/errno.h b/include/errno.h index dbf2a61..8e60288 100644 --- a/include/errno.h +++ b/include/errno.h @@ -22,7 +22,7 @@ # define errno rtld_errno extern int rtld_errno attribute_hidden; -# elif !defined NOT_IN_libc || defined IN_LIB +# elif !defined NOT_IN_libc || IS_IN_LIB # include @@ -34,7 +34,7 @@ extern int rtld_errno attribute_hidden; # endif extern __thread int errno attribute_tls_model_ie; -# endif /* !NOT_IN_libc || IN_LIB */ +# endif /* !NOT_IN_libc || IS_IN_LIB */ # define __set_errno(val) (errno = (val)) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 131d7eb..34702a7 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -24,6 +24,11 @@ #define IS_IN(lib) (IN_MODULE == MODULE_##lib) +/* Returns true if the current module is a versioned library. Versioned + library names are culled from shlib-versions files are assigned a MODULE_* + value lower than MODULE_OTHERS_BEGIN. */ +#define IS_IN_LIB (IN_MODULE < MODULE_OTHERS_BEGIN) + /* This file's macros are included implicitly in the compilation of every file in the C library by -imacros. diff --git a/include/netdb.h b/include/netdb.h index a7960eb..eccdbe6 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -4,7 +4,7 @@ #ifndef _ISOMAC /* Macros for accessing h_errno from inside libc. */ -# if !defined NOT_IN_libc || defined IN_LIB +# if !defined NOT_IN_libc || IS_IN_LIB # undef h_errno # ifndef NOT_IN_libc # define h_errno __libc_h_errno @@ -12,7 +12,7 @@ # define h_errno h_errno /* For #ifndef h_errno tests. */ # endif extern __thread int h_errno attribute_tls_model_ie; -# endif /* !NOT_IN_libc || IN_LIB */ +# endif /* !NOT_IN_libc || IS_IN_LIB */ # define __set_h_errno(x) (h_errno = (x)) libc_hidden_proto (hstrerror) diff --git a/include/stap-probe.h b/include/stap-probe.h index 150fc1e..6532b37 100644 --- a/include/stap-probe.h +++ b/include/stap-probe.h @@ -40,18 +40,6 @@ architecture specific and can be found in the gdb and SystemTap source code. */ -# ifndef NOT_IN_libc -# define IN_LIB libc -# elif !defined IN_LIB -/* This is intentionally defined with extra unquoted commas in it so - that macro substitution will bomb out when it is used. We don't - just use #error here, so that this header can be included by - other headers that use LIBC_PROBE inside their own macros. We - only want such headers to fail to compile if those macros are - actually used in a context where IN_LIB has not been defined. */ -# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,, -# endif - # define LIBC_PROBE(name, n, ...) \ LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__)