aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2014-12-29 17:37:54 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-12-29 17:37:54 +0530
commit4a6aca7bf8a70f1dc66a07c04aba2d7fd837602d (patch)
tree6f85eb5f9cba191e17cfb74c83d12c19b44a6a7a /scripts
parent0025b4cc84a0c1099b11a662acabce2709121be5 (diff)
downloadglibc-4a6aca7bf8a70f1dc66a07c04aba2d7fd837602d.zip
glibc-4a6aca7bf8a70f1dc66a07c04aba2d7fd837602d.tar.gz
glibc-4a6aca7bf8a70f1dc66a07c04aba2d7fd837602d.tar.bz2
Remove Wundef warnings for specification macros
This patch adds a file posix-conf-vars.list that is used to generate macros to determine if a macro is defined as set, unset or not defined. gen-posix-conf-vars.awk processes this file and generates a header (posix-conf-vars-def.h) with these macros. A new header posix-conf-vars.h includes this generated header and defines accessor macros for the generated macros. Tested on x86_64. * posix/Makefile (before-compile): Add posix-conf-vars-def.h. ($(objpfx)posix-conf-vars-def.h): New target. * posix/posix-conf-vars.list: New file. * posix/posix-conf-vars.h: New file. * posix/confstr.c: Include posix-conf-vars.h. (confstr): Use CONF_IS_* macros. * posix/posix-envs.def: Include posix-conf-vars.h. Use CONF_IS_* macros. * scripts/gen-posix-conf-vars.awk: New file.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen-posix-conf-vars.awk61
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/gen-posix-conf-vars.awk b/scripts/gen-posix-conf-vars.awk
new file mode 100644
index 0000000..16e20fc
--- /dev/null
+++ b/scripts/gen-posix-conf-vars.awk
@@ -0,0 +1,61 @@
+# Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each
+# configuration variable that getconf or sysconf may use. Currently it is
+# equipped only to generate such macros for specification macros and for
+# SYSCONF macros in the _POSIX namespace.
+
+BEGIN {
+ prefix = ""
+}
+
+$1 ~ /^#/ || $0 ~ /^\s*$/ {
+ next
+}
+
+# Begin a new prefix.
+$NF == "{" {
+ type = $1
+ prefix = $2
+ next
+}
+
+$1 == "}" {
+ prefix = ""
+ type = ""
+ next
+}
+
+{
+ if (prefix == "" && type == "" && sc_prefix == "") {
+ printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr"
+ exit 1
+ }
+
+ # The prefix and variable names are indices and the value indicates what type
+ # of variable it is. The possible options are:
+ # CONFSTR: A configuration string
+ # SYSCONF: A numeric value
+ # SPEC: A specification
+ conf[prefix][$1] = type
+}
+
+END {
+ print "/* AUTOGENERATED by gen-posix-conf-vars.awk. DO NOT EDIT. */\n"
+
+ # Generate macros that specify if a sysconf macro is defined and/or set.
+ for (p in conf) {
+ for (c in conf[p]) {
+ printf "#ifndef _%s_%s\n", p, c
+ printf "# define CONF_DEF_%s_%s CONF_DEF_UNDEFINED\n", p, c
+ # CONFSTR have string values and they are not set or unset.
+ if (conf[p][c] != "CONFSTR") {
+ printf "#else\n"
+ printf "# if _%s_%s > 0\n", p, c
+ printf "# define CONF_DEF_%s_%s CONF_DEF_DEFINED_SET\n", p, c
+ printf "# else\n"
+ printf "# define CONF_DEF_%s_%s CONF_DEF_DEFINED_UNSET\n", p, c
+ printf "# endif\n"
+ }
+ printf "#endif\n\n"
+ }
+ }
+}