]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use conf.list to generate spec array siddhesh/posix-wundef
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Wed, 1 Oct 2014 09:06:03 +0000 (14:36 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 15 Dec 2014 05:33:33 +0000 (11:03 +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 conf.list once the
remaining macros are added to it.

* posix/conf.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-conf.awk: Support generation of specs array.

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

index 000b90893a506f876dd4a34b971a13ca263e6494..0a17666d8d91273391af9cd1d7fc2f42f296e750 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
@@ -103,7 +104,7 @@ SYSCONF:POSIX {
   RAW_SOCKETS
 }
 
-SPEC:XBS5 {
+SPEC:XBS5:_SC_XBS5 {
   ILP32_OFF32
   ILP32_OFFBIG
   LP64_OFF64
index 1accfeead0f62e3b3c0b489c8ae5f380370c471b..0400d7f247bc82f81e6ee88ce3636b23830d9c84 100644 (file)
@@ -21,7 +21,9 @@
 #include <string.h>
 #include <confstr.h>
 #include "../version.h"
-#include "confdefs.h"
+
+#define NEED_SPEC_ARRAY 0
+#include <confdefs.h>
 
 /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
    of BUF with the value corresponding to NAME and zero-terminate BUF.
index 14d51d87acf7b08cfe7694190b3faa6049847d9f..3c086880a2cdf26d8b9e4f8f2fff0fe49eaea3ff 100644 (file)
@@ -26,6 +26,9 @@
 #include "../version.h"
 #define PACKAGE _libc_intl_domainname
 
+#define NEED_SPEC_ARRAY 1
+#include <confdefs.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 9047d0ce89b0255a0e6bdb0676c212785e31820b..0b33e02884cb8e43147fa3903d75cda7a7acca0d 100644 (file)
@@ -42,7 +42,8 @@
    defined.  These are called with arguments V5, V6, V7 before and
    after the relevant groups of environments.  */
 
-#include "confdefs.h"
+#define NEED_SPEC_ARRAY 0
+#include <confdefs.h>
 
 START_ENV_GROUP (V7)
 
index 45a4d443334df45cc3d1741a5c11823d9fd1be73..1370646f585c293d3a0194ae19c406ea4dfb8f31 100644 (file)
@@ -17,12 +17,17 @@ $2 == "{" {
   split ($1, arr, ":")
   type = arr[1]
   prefix = arr[2]
+  if (arr[3] != "")
+    sc_prefix = arr[3]
+  else
+    sc_prefix = "_SC"
   next
 }
 
 $1 == "}" {
   prefix = ""
   type = ""
+  sc_prefix = ""
   next
 }
 
@@ -37,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
 }
 
@@ -58,6 +64,26 @@ ENDFILE {
        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 confdefs.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 c7b748b171c12a3a1562adca3f4da5f37c9cf962..bff59f4d4d39e178ed0f9f20b86aee59ef75a095 100644 (file)
@@ -31,6 +31,7 @@
 #include <sys/types.h>
 #include <regex.h>
 
+#define NEED_SPEC_ARRAY 0
 #include <confdefs.h>