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

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