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