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