1 # Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each
2 # configuration variable that getconf or sysconf may use. Currently it is
3 # equipped only to generate such macros for specification macros and for
4 # SYSCONF macros in the _POSIX namespace.
10 $
1 ~
/^
#/ || $0 ~ /^\s*$/ {
35 if (prefix ==
"" && type ==
"" && sc_prefix ==
"") {
36 printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr"
40 # The prefix and variable names are indices and the value indicates what type
41 # of variable it is. The possible options are:
42 # CONFSTR: A configuration string
43 # SYSCONF: A numeric value
44 # SPEC: A specification
46 sc_prefixes
[c
] = sc_prefix
52 print "/* AUTOGENERATED by gen-posix-conf-vars.awk. DO NOT EDIT. */\n"
54 # Generate macros that specify if a sysconf macro is defined and/or set.
55 for (c in prefix_conf
) {
56 printf "#ifndef _%s\n", c
57 printf "# define CONF_DEF_%s CONF_DEF_UNDEFINED\n", c
58 # CONFSTR have string values and they are not set or unset.
59 if (prefix_conf
[c
] != "CONFSTR") {
61 printf "# if _%s > 0\n", c
62 printf "# define CONF_DEF_%s CONF_DEF_DEFINED_SET\n", c
64 printf "# define CONF_DEF_%s CONF_DEF_DEFINED_UNSET\n", c
69 # Build a name -> sysconf number associative array to print a C array at
71 if (prefix_conf
[c
] ==
"SPEC")
72 spec
[c
] = sc_prefixes
[c
] "_" conf
[c
]
75 # Print the specification array. Define the macro NEED_SPEC_ARRAY before
76 # including posix-conf-vars.h to make it available in the compilation unit.
77 print "#if NEED_SPEC_ARRAY"
78 print "static const struct { const char *name; int num; } specs[] ="
81 printf " { \"%s\", %s },\n", s
, spec
[s
]
84 print "static const size_t nspecs = sizeof (specs) / sizeof (specs[0]);"