From 50cbbaa935e92dc570fc899a17669cd6782b09cd Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 29 Dec 2014 17:40:47 +0530 Subject: Use posix-conf-vars.list to generate spec array 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. --- scripts/gen-posix-conf-vars.awk | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'scripts') diff --git a/scripts/gen-posix-conf-vars.awk b/scripts/gen-posix-conf-vars.awk index 16e20fc100..0eca55d536 100644 --- a/scripts/gen-posix-conf-vars.awk +++ b/scripts/gen-posix-conf-vars.awk @@ -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" } -- cgit 1.4.1