Blame SOURCES/glibc-rh1505492-undef-51.patch

00db10
commit 50cbbaa935e92dc570fc899a17669cd6782b09cd
00db10
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
00db10
Date:   Mon Dec 29 17:40:47 2014 +0530
00db10
00db10
    Use posix-conf-vars.list to generate spec array
00db10
    
00db10
    This patch adds support to generate the spec array in getconf from the
00db10
    conf.list.  The generated code is mostly unchanged.  the only changes
00db10
    are due to the change in layout of the spec and val arrays in the ELF.
00db10
    
00db10
    The val array can also be auto-generated from posix-conf-vars.list
00db10
    once the remaining macros are added to it.
00db10
    
00db10
            * posix/posix-conf-vars.list (SPEC:XBS5): Add sysconf prefix.
00db10
            * posix/confstr.c: Define NEED_SPEC_ARRAY to 0.
00db10
            * posix/posix-envs.def: Likewise.
00db10
            * sysdeps/posix/sysconf.c: Likewise.
00db10
            * posix/getconf.c: Define NEED_SPEC_ARRAY to 1.
00db10
            (specs): Remove array.
00db10
            * scripts/gen-posix-conf-vars.awk: Support generation of specs
00db10
            array.
00db10
00db10
diff --git a/posix/confstr.c b/posix/confstr.c
00db10
index 5b03986a3678e007..0233ea94707ee627 100644
00db10
--- a/posix/confstr.c
00db10
+++ b/posix/confstr.c
00db10
@@ -21,6 +21,8 @@
00db10
 #include <string.h>
00db10
 #include <confstr.h>
00db10
 #include "../version.h"
00db10
+
00db10
+#define NEED_SPEC_ARRAY 0
00db10
 #include <posix-conf-vars.h>
00db10
 
00db10
 /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
00db10
diff --git a/posix/getconf.c b/posix/getconf.c
00db10
index 9cb8f29be28466ff..bd844dead16e9400 100644
00db10
--- a/posix/getconf.c
00db10
+++ b/posix/getconf.c
00db10
@@ -26,6 +26,9 @@
00db10
 #include "../version.h"
00db10
 #define PACKAGE _libc_intl_domainname
00db10
 
00db10
+#define NEED_SPEC_ARRAY 1
00db10
+#include <posix-conf-vars.h>
00db10
+
00db10
 struct conf
00db10
   {
00db10
     const char *name;
00db10
@@ -1008,23 +1011,6 @@ static const struct conf vars[] =
00db10
   };
00db10
 
00db10
 
00db10
-static const struct { const char *name; int num; } specs[] =
00db10
-  {
00db10
-    { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 },
00db10
-    { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG },
00db10
-    { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 },
00db10
-    { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG },
00db10
-    { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
00db10
-    { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
00db10
-    { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
00db10
-    { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG },
00db10
-    { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 },
00db10
-    { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG },
00db10
-    { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 },
00db10
-    { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG },
00db10
-  };
00db10
-static const int nspecs = sizeof (specs) / sizeof (specs[0]);
00db10
-
00db10
 extern const char *__progname;
00db10
 
00db10
 
00db10
diff --git a/posix/posix-conf-vars.list b/posix/posix-conf-vars.list
00db10
index 3e7e7cdaa9c46c85..601bc2fd33f72f27 100644
00db10
--- a/posix/posix-conf-vars.list
00db10
+++ b/posix/posix-conf-vars.list
00db10
@@ -1,7 +1,8 @@
00db10
 # Configuration variables identified by getconf.  The heading of each section
00db10
-# is of the format TYPE PREFIX with the opening curly brace on the same line.
00db10
-# TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC.  Variable names are
00db10
-# put one on each line with a curly brace on its own line ending the section.
00db10
+# is of the format TYPE PREFIX SC_PREFIX with the opening curly brace on the
00db10
+# same line.  TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC.  In the
00db10
+# absence of SC_PREFIX, _SC is used as the SC_PREFIX.  Variable names are put
00db10
+# one on each line with a curly brace on its own line ending the section.
00db10
 
00db10
 SPEC POSIX {
00db10
   V6_ILP32_OFF32
00db10
@@ -104,7 +105,7 @@ SYSCONF POSIX {
00db10
   RAW_SOCKETS
00db10
 }
00db10
 
00db10
-SPEC XBS5 {
00db10
+SPEC XBS5 _SC_XBS5 {
00db10
   ILP32_OFF32
00db10
   ILP32_OFFBIG
00db10
   LP64_OFF64
00db10
diff --git a/posix/posix-envs.def b/posix/posix-envs.def
00db10
index e820e6dbe3fa3b61..428dbc23ceb7f64c 100644
00db10
--- a/posix/posix-envs.def
00db10
+++ b/posix/posix-envs.def
00db10
@@ -42,6 +42,7 @@
00db10
    defined.  These are called with arguments V5, V6, V7 before and
00db10
    after the relevant groups of environments.  */
00db10
 
00db10
+#define NEED_SPEC_ARRAY 0
00db10
 #include <posix-conf-vars.h>
00db10
 
00db10
 START_ENV_GROUP (V7)
00db10
diff --git a/scripts/gen-posix-conf-vars.awk b/scripts/gen-posix-conf-vars.awk
00db10
index 16e20fc1007bd2f5..0eca55d536bd7f70 100644
00db10
--- a/scripts/gen-posix-conf-vars.awk
00db10
+++ b/scripts/gen-posix-conf-vars.awk
00db10
@@ -15,12 +15,19 @@ $1 ~ /^#/ || $0 ~ /^\s*$/ {
00db10
 $NF == "{" {
00db10
   type = $1
00db10
   prefix = $2
00db10
+
00db10
+  if (NF == 4)
00db10
+    sc_prefix = $3
00db10
+  else
00db10
+    sc_prefix = "_SC"
00db10
+
00db10
   next
00db10
 }
00db10
 
00db10
 $1 == "}" {
00db10
   prefix = ""
00db10
   type = ""
00db10
+  sc_prefix = ""
00db10
   next
00db10
 }
00db10
 
00db10
@@ -35,6 +42,7 @@ $1 == "}" {
00db10
   # CONFSTR: A configuration string
00db10
   # SYSCONF: A numeric value
00db10
   # SPEC: A specification
00db10
+  sc_prefixes[prefix][$1] = sc_prefix
00db10
   conf[prefix][$1] = type
00db10
 }
00db10
 
00db10
@@ -56,6 +64,26 @@ END {
00db10
 	printf "# endif\n"
00db10
       }
00db10
       printf "#endif\n\n"
00db10
+
00db10
+      # Build a name -> sysconf number associative array to print a C array at
00db10
+      # the end.
00db10
+      if (conf[p][c] == "SPEC") {
00db10
+	name = sprintf ("%s_%s", p, c)
00db10
+	num = sprintf ("%s_%s", sc_prefixes[p][c], c)
00db10
+	spec[name] = num
00db10
+      }
00db10
     }
00db10
   }
00db10
+
00db10
+  # Print the specification array.  Define the macro NEED_SPEC_ARRAY before
00db10
+  # including posix-conf-vars.h to make it available in the compilation unit.
00db10
+  print "#if NEED_SPEC_ARRAY"
00db10
+  print "static const struct { const char *name; int num; } specs[] ="
00db10
+  print "  {"
00db10
+  for (s in spec) {
00db10
+    printf "    { \"%s\", %s },\n", s, spec[s]
00db10
+  }
00db10
+  print "  };"
00db10
+  print "static const int nspecs = sizeof (specs) / sizeof (specs[0]);"
00db10
+  print "#endif"
00db10
 }
00db10
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
00db10
index 1e9d4e099e94981c..88aa151422dc56f9 100644
00db10
--- a/sysdeps/posix/sysconf.c
00db10
+++ b/sysdeps/posix/sysconf.c
00db10
@@ -31,9 +31,9 @@
00db10
 #include <sys/types.h>
00db10
 #include <regex.h>
00db10
 
00db10
+#define NEED_SPEC_ARRAY 0
00db10
 #include <posix-conf-vars.h>
00db10
 
00db10
-
00db10
 #define NEED_CHECK_SPEC \
00db10
   (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
00db10
    || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \