]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use posix-conf-vars.list to generate spec array
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 29 Dec 2014 12:10:47 +0000 (17:40 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 29 Dec 2014 14:26:27 +0000 (19:56 +0530)
This patch adds support to generate the spec array in getconf from the
conf.list.  The generated code is mostly unchanged.  the only changes
are due to the change in layout of the spec and val arrays in the ELF.

The val array can also be auto-generated from posix-conf-vars.list
once the remaining macros are added to it.

* posix/posix-conf-vars.list (SPEC:XBS5): Add sysconf prefix.
* posix/confstr.c: Define NEED_SPEC_ARRAY to 0.
* posix/posix-envs.def: Likewise.
* sysdeps/posix/sysconf.c: Likewise.
* posix/getconf.c: Define NEED_SPEC_ARRAY to 1.
(specs): Remove array.
* scripts/gen-posix-conf-vars.awk: Support generation of specs
array.

ChangeLog
posix/confstr.c
posix/getconf.c
posix/posix-conf-vars.list
posix/posix-envs.def
scripts/gen-posix-conf-vars.awk
sysdeps/posix/sysconf.c

index 94000ad7be70cd6471e392dec5285d46733f821d..ff4b532bfa81f8d436da833102d3881dbf5a48ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2014-12-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+       * posix/posix-conf-vars.list (SPEC:XBS5): Add sysconf prefix.
+       * posix/confstr.c: Define NEED_SPEC_ARRAY to 0.
+       * posix/posix-envs.def: Likewise.
+       * sysdeps/posix/sysconf.c: Likewise.
+       * posix/getconf.c: Define NEED_SPEC_ARRAY to 1.
+       (specs): Remove array.
+       * scripts/gen-posix-conf-vars.awk: Support generation of specs
+       array.
+
        * posix/posix-conf-vars.list: Add _POSIX sysconf namespace.
        * sysdeps/posix/sysconf.c: Include posix-conf-vars.h.
        (__sysconf): Use CONF_IS_* macros.
index e4e0f4bdecc66639f6609ec1ae258f23fa1669b7..244a25c93fbad0e1eb70b65b77b19a40837a9e42 100644 (file)
@@ -21,6 +21,8 @@
 #include <string.h>
 #include <confstr.h>
 #include "../version.h"
+
+#define NEED_SPEC_ARRAY 0
 #include <posix-conf-vars.h>
 
 /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
index 14d51d87acf7b08cfe7694190b3faa6049847d9f..bcde4c58a19fd38c51eba582ffdd85431fdfe3ba 100644 (file)
@@ -26,6 +26,9 @@
 #include "../version.h"
 #define PACKAGE _libc_intl_domainname
 
+#define NEED_SPEC_ARRAY 1
+#include <posix-conf-vars.h>
+
 struct conf
   {
     const char *name;
@@ -387,23 +390,6 @@ static const struct conf vars[] =
   };
 
 
-static const struct { const char *name; int num; } specs[] =
-  {
-    { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 },
-    { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG },
-    { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 },
-    { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG },
-    { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
-    { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
-    { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
-    { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG },
-    { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 },
-    { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG },
-    { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 },
-    { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG },
-  };
-static const int nspecs = sizeof (specs) / sizeof (specs[0]);
-
 extern const char *__progname;
 
 
index 3e7e7cdaa9c46c85e742ad186fb285c22c3d283c..601bc2fd33f72f271ec078075fa8935ae712c595 100644 (file)
@@ -1,7 +1,8 @@
 # Configuration variables identified by getconf.  The heading of each section
-# is of the format TYPE PREFIX with the opening curly brace on the same line.
-# TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC.  Variable names are
-# put one on each line with a curly brace on its own line ending the section.
+# is of the format TYPE PREFIX SC_PREFIX with the opening curly brace on the
+# same line.  TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC.  In the
+# absence of SC_PREFIX, _SC is used as the SC_PREFIX.  Variable names are put
+# one on each line with a curly brace on its own line ending the section.
 
 SPEC POSIX {
   V6_ILP32_OFF32
@@ -104,7 +105,7 @@ SYSCONF POSIX {
   RAW_SOCKETS
 }
 
-SPEC XBS5 {
+SPEC XBS5 _SC_XBS5 {
   ILP32_OFF32
   ILP32_OFFBIG
   LP64_OFF64
index 870d85a7db63262c2f4dff218cc3e4180a75c876..fa271bbfc4a15f2ac42e1bc23ccb70eae065a5ee 100644 (file)
@@ -42,6 +42,7 @@
    defined.  These are called with arguments V5, V6, V7 before and
    after the relevant groups of environments.  */
 
+#define NEED_SPEC_ARRAY 0
 #include <posix-conf-vars.h>
 
 START_ENV_GROUP (V7)
index 16e20fc1007bd2f50c212714481d9513311e2695..0eca55d536bd7f70e41f2179bf193c667a117d63 100644 (file)
@@ -15,12 +15,19 @@ $1 ~ /^#/ || $0 ~ /^\s*$/ {
 $NF == "{" {
   type = $1
   prefix = $2
+
+  if (NF == 4)
+    sc_prefix = $3
+  else
+    sc_prefix = "_SC"
+
   next
 }
 
 $1 == "}" {
   prefix = ""
   type = ""
+  sc_prefix = ""
   next
 }
 
@@ -35,6 +42,7 @@ $1 == "}" {
   # CONFSTR: A configuration string
   # SYSCONF: A numeric value
   # SPEC: A specification
+  sc_prefixes[prefix][$1] = sc_prefix
   conf[prefix][$1] = type
 }
 
@@ -56,6 +64,26 @@ END {
        printf "# endif\n"
       }
       printf "#endif\n\n"
+
+      # Build a name -> sysconf number associative array to print a C array at
+      # the end.
+      if (conf[p][c] == "SPEC") {
+       name = sprintf ("%s_%s", p, c)
+       num = sprintf ("%s_%s", sc_prefixes[p][c], c)
+       spec[name] = num
+      }
     }
   }
+
+  # Print the specification array.  Define the macro NEED_SPEC_ARRAY before
+  # including posix-conf-vars.h to make it available in the compilation unit.
+  print "#if NEED_SPEC_ARRAY"
+  print "static const struct { const char *name; int num; } specs[] ="
+  print "  {"
+  for (s in spec) {
+    printf "    { \"%s\", %s },\n", s, spec[s]
+  }
+  print "  };"
+  print "static const int nspecs = sizeof (specs) / sizeof (specs[0]);"
+  print "#endif"
 }
index 968c5cb36787e76ed76533745777dd265f942eaa..0ea5382ba0e7afb2a182a7deb25d97d5048bcff7 100644 (file)
@@ -31,9 +31,9 @@
 #include <sys/types.h>
 #include <regex.h>
 
+#define NEED_SPEC_ARRAY 0
 #include <posix-conf-vars.h>
 
-
 #define NEED_CHECK_SPEC \
   (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
    || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \