bca718
commit a10178bda190a62e7e3f56773f55f23cf06848a7
bca718
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
bca718
Date:   Thu Nov 20 12:03:11 2014 +0530
bca718
bca718
    Remove IN_LIB
bca718
    
bca718
    Replace with IS_IN and IS_IN_LIB macros instead.  This change results
bca718
    in a change in generated code, because it fixes a subtle bug.  The bug
bca718
    was introduced when systemtap probes were added to lowlevellock.h,
bca718
    which resulted in stap-probe.h being included in a number of places.
bca718
    stap-probe.h always defines IN_LIB, which breaks a check in errno.h
bca718
    and netdb.h since they rely on that macro to decide whether to
bca718
    implement an internal version of a declaration or an external one.
bca718
    
bca718
    The components that see a code change due to this are:
bca718
    
bca718
    iconv_prog
bca718
    libmemusage.so
bca718
    libpcprofile.so
bca718
    libSegFault.so
bca718
    libutil.so.1
bca718
    locale
bca718
    localedef
bca718
    nscd
bca718
    
bca718
    All other built components (i.e. libc, libpthread, etc.) remain
bca718
    unchanged by this on x86_64.
bca718
    
bca718
    	* elf/Makefile (CPPFLAGS-.os): Remove IN_LIB.
bca718
    	* elf/rtld-Rules (rtld-CPPFLAGS): Likewise.
bca718
    	* extra-lib.mk (CPPFLAGS-$(lib)): Likewise.
bca718
    	* include/libc-symbols.h (IS_IN_LIB): New macro.
bca718
    	* include/errno.h: Use IS_IN_LIB instead of IN_LIB.
bca718
    	* include/netdb.h: Likewise.
bca718
    	* include/stap-probe.h: Remove all uses of IN_LIB.
bca718
bca718
Index: glibc-2.17-c758a686/elf/Makefile
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/elf/Makefile
bca718
+++ glibc-2.17-c758a686/elf/Makefile
bca718
@@ -443,7 +443,7 @@ CFLAGS-cache.c = $(SYSCONF-FLAGS)
bca718
 CFLAGS-rtld.c = $(SYSCONF-FLAGS)
bca718
 
bca718
 CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
bca718
-		     -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
bca718
+		     -DNOT_IN_libc=1 -DIS_IN_rtld=1)
bca718
 
bca718
 # Disable any optimization which might result in function calls during early
bca718
 # dynamic loader startup. We disable -ftree-loop-distribute-patterns which
bca718
Index: glibc-2.17-c758a686/elf/rtld-Rules
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/elf/rtld-Rules
bca718
+++ glibc-2.17-c758a686/elf/rtld-Rules
bca718
@@ -134,6 +134,6 @@ lib := rtld
bca718
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
bca718
 
bca718
 # This here is the whole point of all the shenanigans.
bca718
-rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
bca718
+rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
bca718
 
bca718
 endif
bca718
Index: glibc-2.17-c758a686/extra-lib.mk
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/extra-lib.mk
bca718
+++ glibc-2.17-c758a686/extra-lib.mk
bca718
@@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
bca718
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
bca718
 endif
bca718
 
bca718
-CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
bca718
+CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
bca718
Index: glibc-2.17-c758a686/include/errno.h
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/include/errno.h
bca718
+++ glibc-2.17-c758a686/include/errno.h
bca718
@@ -17,7 +17,7 @@
bca718
 #  define errno rtld_errno
bca718
 extern int rtld_errno attribute_hidden;
bca718
 
bca718
-# elif !defined NOT_IN_libc || defined IN_LIB
bca718
+# elif !defined NOT_IN_libc || IS_IN_LIB
bca718
 
bca718
 #  include <tls.h>
bca718
 
bca718
@@ -29,7 +29,7 @@ extern int rtld_errno attribute_hidden;
bca718
 #  endif
bca718
 extern __thread int errno attribute_tls_model_ie;
bca718
 
bca718
-# endif	/* !NOT_IN_libc || IN_LIB */
bca718
+# endif	/* !NOT_IN_libc || IS_IN_LIB */
bca718
 
bca718
 # define __set_errno(val) (errno = (val))
bca718
 
bca718
Index: glibc-2.17-c758a686/include/libc-symbols.h
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/include/libc-symbols.h
bca718
+++ glibc-2.17-c758a686/include/libc-symbols.h
bca718
@@ -23,6 +23,11 @@
bca718
 #define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
bca718
 #define IS_IN(lib) (IN_MODULE == MODULE_##lib)
bca718
 
bca718
+/* Returns true if the current module is a versioned library.  Versioned
bca718
+   library names culled from shlib-versions files are assigned a MODULE_*
bca718
+   value lower than MODULE_LIBS_BEGIN.  */
bca718
+#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
bca718
+
bca718
 #define PASTE_NAME(a,b)      PASTE_NAME1 (a,b)
bca718
 #define PASTE_NAME1(a,b)     a##b
bca718
 
bca718
Index: glibc-2.17-c758a686/include/netdb.h
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/include/netdb.h
bca718
+++ glibc-2.17-c758a686/include/netdb.h
bca718
@@ -3,7 +3,7 @@
bca718
 
bca718
 #ifndef _ISOMAC
bca718
 /* Macros for accessing h_errno from inside libc.  */
bca718
-# if !defined NOT_IN_libc || defined IN_LIB
bca718
+# if !defined NOT_IN_libc || IS_IN_LIB
bca718
 #  undef  h_errno
bca718
 #  ifdef _LIBC_REENTRANT
bca718
 #   include <tls.h>
bca718
@@ -16,7 +16,7 @@ extern __thread int h_errno attribute_tl
bca718
 #  else
bca718
 extern int h_errno;
bca718
 #  endif	/* _LIBC_REENTRANT */
bca718
-# endif /* !NOT_IN_libc || IN_LIB */
bca718
+# endif /* !NOT_IN_libc || IS_IN_LIB */
bca718
 # define __set_h_errno(x) (h_errno = (x))
bca718
 
bca718
 libc_hidden_proto (hstrerror)
bca718
Index: glibc-2.17-c758a686/include/stap-probe.h
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/include/stap-probe.h
bca718
+++ glibc-2.17-c758a686/include/stap-probe.h
bca718
@@ -32,18 +32,6 @@
bca718
    STAP_PROBEn (provider, name, arg1, ..., argn).  For "provider" we paste
bca718
    in MODULE_NAME (libc, libpthread, etc.) automagically.  */
bca718
 
bca718
-# ifndef NOT_IN_libc
bca718
-#  define IN_LIB	libc
bca718
-# elif !defined IN_LIB
bca718
-/* This is intentionally defined with extra unquoted commas in it so
bca718
-   that macro substitution will bomb out when it is used.  We don't
bca718
-   just use #error here, so that this header can be included by
bca718
-   other headers that use LIBC_PROBE inside their own macros.  We
bca718
-   only want such headers to fail to compile if those macros are
bca718
-   actually used in a context where IN_LIB has not been defined.  */
bca718
-#  define IN_LIB	,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
bca718
-# endif
bca718
-
bca718
 # define LIBC_PROBE(name, n, ...)	\
bca718
   LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__)
bca718