1 # Generate dl-tunable-list.h from dl-tunables.list
6 min_of["INT_32"]="INT32_MIN"
7 max_of["INT_32"]="INT32_MAX"
9 max_of["UINT_64"]="UINT64_MAX"
11 max_of["SIZE_T"]="SIZE_MAX"
19 # Skip over blank lines and comments.
28 # Beginning of either a top namespace, tunable namespace or a tunable, decided
29 # on the current value of TUNABLE, NS or TOP_NS.
37 else if (tunable == "") {
41 printf ("Unexpected occurrence of '{': %s:%d\n", FILENAME, FNR)
48 # End of either a top namespace, tunable namespace or a tunable.
51 # Tunables definition ended, now fill in default attributes.
52 if (!types[top_ns,ns,tunable]) {
53 types[top_ns,ns,tunable] = "STRING"
55 if (!minvals[top_ns,ns,tunable]) {
56 minvals[top_ns,ns,tunable] = min_of[types[top_ns,ns,tunable]]
58 if (!maxvals[top_ns,ns,tunable]) {
59 maxvals[top_ns,ns,tunable] = max_of[types[top_ns,ns,tunable]]
61 if (!env_alias[top_ns,ns,tunable]) {
62 env_alias[top_ns,ns,tunable] = "{0}"
64 len = length(top_ns"."ns"."tunable)
65 if (len > max_name_len)
73 else if (top_ns != "") {
77 printf ("syntax error: extra }: %s:%d\n", FILENAME, FNR)
83 # Everything else, which could either be a tunable without any attributes or a
87 printf("Line %d: Invalid tunable outside a namespace: %s\n", NR, $0)
92 # We encountered a tunable without any attributes, so note it with a
94 types[top_ns,ns,$1] = "STRING"
98 # Otherwise, we have encountered a tunable attribute.
100 attr = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[1])
101 val = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[2])
103 if (attr == "type") {
104 types[top_ns,ns,tunable] = val
106 else if (attr == "minval") {
107 minvals[top_ns,ns,tunable] = val
109 else if (attr == "maxval") {
110 maxvals[top_ns,ns,tunable] = val
112 else if (attr == "env_alias") {
113 env_alias[top_ns,ns,tunable] = sprintf("\"%s\"", val)
115 if (len > max_alias_len)
118 else if (attr == "default") {
119 if (types[top_ns,ns,tunable] == "STRING") {
120 default_val[top_ns,ns,tunable] = sprintf(".strval = \"%s\"", val);
123 default_val[top_ns,ns,tunable] = sprintf(".numval = %s", val)
130 print "Unterminated namespace. Is a closing brace missing?"
134 print "/* AUTOGENERATED by gen-tunables.awk. */"
135 print "#ifndef _TUNABLES_H_"
136 print "# error \"Do not include this file directly.\""
137 print "# error \"Include tunables.h instead.\""
139 print "#include <dl-procinfo.h>\n"
141 # Now, the enum names
142 print "\ntypedef enum"
145 split (tnm, indices, SUBSEP);
149 printf (" TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m);
151 print "} tunable_id_t;\n"
153 print "\n#ifdef TUNABLES_INTERNAL"
154 # Internal definitions.
155 print "# define TUNABLE_NAME_MAX " (max_name_len + 1)
156 print "# define TUNABLE_ALIAS_MAX " (max_alias_len + 1)
157 print "# include \"dl-tunable-types.h\""
158 # Finally, the tunable list.
159 print "static tunable_t tunable_list[] attribute_relro = {"
161 split (tnm, indices, SUBSEP);
165 printf (" {TUNABLE_NAME_S(%s, %s, %s)", t, n, m)
166 printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, {%s}, false, %s},\n",
167 types[t,n,m], minvals[t,n,m], maxvals[t,n,m], default_val[t,n,m],
168 default_val[t,n,m], env_alias[t,n,m]);