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