diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-10-01 14:36:03 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-12-15 11:03:33 +0530 |
commit | 41868acc3a55bad110e79a7a40c030b39c5480bb (patch) | |
tree | 9153591b1d908064b0533a33abb65bad7f99f3f3 /scripts/gen-conf.awk | |
parent | 67cf3c6ed0b1119bbddc1c6f46af486fc1ad2432 (diff) | |
download | glibc-siddhesh/posix-wundef.tar.gz glibc-siddhesh/posix-wundef.tar.xz glibc-siddhesh/posix-wundef.zip |
Use conf.list to generate spec array siddhesh/posix-wundef
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.
Diffstat (limited to 'scripts/gen-conf.awk')
-rw-r--r-- | scripts/gen-conf.awk | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/gen-conf.awk b/scripts/gen-conf.awk index 45a4d44333..1370646f58 100644 --- a/scripts/gen-conf.awk +++ b/scripts/gen-conf.awk @@ -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" } |