1 ########################################################################
3 # This software is part of the ast package #
4 # Copyright (c) 1985-2010 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Common Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
13 # Information and Software Systems Research #
17 # Glenn Fowler <gsf@research.att.com> #
18 # David Korn <dgk@research.att.com> #
19 # Phong Vo <kpv@research.att.com> #
21 ########################################################################
22 : generate getconf and limits info
24 # @(#)conf.sh (AT&T Research) 2008-01-31
26 # this script generates these files from the table file in the first arg
27 # the remaining args are the C compiler name and flags
29 # conflim.h supplemental limits.h definitions
30 # conftab.h readonly string table definitions
31 # conftab.c readonly string table data
33 # you may think it should be simpler
34 # but you shall be confused anyway
37 case $
-:$BASH_VERSION in
38 *x
*:[0123456789]*) : bash
set -x is broken
:; set +ex
;;
46 shell
=`eval 'x=123&&integer n=\${#x}\${x#1?}&&((n==330/(10)))&&echo ksh' 2>/dev/null`
58 -c*) keep_call
=${1#-?} ;;
61 -n*) keep_name
=${1#-?} ;;
64 -*) echo "Usage: $command [-a] [-ccall-pattern] [-dN] [-l] [-nname_pattern] [-t] [-v] conf.tab" >&2; exit 2 ;;
69 head='#include "FEATURE/standards"
70 #include "FEATURE/common"'
71 tail='#include "FEATURE/param"'
72 generated
="/* : : generated by $command from $1 : : */"
81 sym
=[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_
]*
83 case $verbose:$debug$trace in
84 1:?
*) echo "$command: debug=$debug trace=$trace keep_call=$keep_call keep_name=$keep_name" >&2 ;;
87 1) PS4
='+$LINENO+ '; set -x ;;
92 0) echo "$command: table argument expected" >&2
101 then echo "$command: $tab: cannot read" >&2
113 '') trap "code=\$?; rm -f $tmp.*; exit \$code" 0 1 2 ;;
116 # determine the intmax_t printf format
130 if $cc -o $tmp.exe
$tmp.c
>/dev
/null
2>&1 && .
/$tmp.exe
135 # determine the intmax_t constant suffix
145 _ast_intmax_t s
= 0x7fffffffffffffffLL
;
146 unsigned _ast_intmax_t u
= 0xffffffffffffffffLL
;
152 if $cc -o $tmp.exe
$tmp.c
>/dev
/null
2>&1
160 # set up the names and keys
165 case $append$extra in
167 1) echo "$command: read $tab" >&2 ;;
199 eval script='$'script_
$1
203 "sh{") script="# $name" ;;
213 script=$script$nl$line
220 *) f
=`echo $1 | sed 's,\.h$,,'` ;;
224 headers
=$headers$nl#include$sp'<'$1'>'
228 *) if iffe
-n - hdr
$f |
grep _hdr_
$f >/dev
/null
230 headers
=$headers$nl#include$sp'<'$1'>'
236 *) values
=$values$sp$1
238 $sym) echo "$1" >> $tmp.v
;;
243 case " $standards " in
246 *) standards
="$standards $standard"
251 VERSION
)flags
="${flags}S" ;;
254 *VERSION
*)key
=${standard}${section} ;;
258 ''|
*_
) key
=${key}${name} ;;
259 *) key
=${key}_
${name} ;;
261 eval sys
='$'CONF_call_
${key}
271 eval CONF_name_
${key}='$'name
272 eval CONF_standard_
${key}='$'standard
273 eval CONF_call_
${key}='$'call
274 eval CONF_section_
${key}='$'section
275 eval CONF_flags_
${key}='$'flags
276 eval CONF_define_
${key}='$'define
277 eval CONF_values_
${key}='$'values
278 eval CONF_script_
${key}='$'script
279 eval CONF_args_
${key}='$'args
280 eval CONF_headers_
${key}='$'headers
281 eval CONF_keys_
${name}=\"'$'CONF_keys_
${name} '$'key
\"
288 -d1) for key
in $keys
289 do eval name
=\"'$'CONF_name_
$key\"
291 ?
*) eval standard
=\"'$'CONF_standard_
$key\"
292 eval call
=\"'$'CONF_call_
$key\"
293 eval section
=\"'$'CONF_section_
$key\"
294 eval flags
=\"'$'CONF_flags_
$key\"
295 eval define
=\"'$'CONF_define_
$key\"
296 eval values
=\"'$'CONF_values_
$key\"
297 eval script=\"'$'CONF_script_
$key\"
298 eval args
=\"'$'CONF_args_
$key\"
299 eval headers
=\"'$'CONF_headers_
$key\"
300 printf "%29s %35s %8s %2s %1d %5s %s$nl" "$name" "$key" "$standard" "$call" "$section" "$flags" "$define${values:+$sp=$values}${headers:+$sp$headers$nl}${script:+$sp$ob$script$nl$cb}"
309 #if !defined(SYS_NMLEN)
312 #include <sys/systeminfo.h>'
313 echo "$systeminfo" > $tmp.c
314 $cc -E $tmp.c
>/dev
/null
2>&1 || systeminfo
=
316 # check for native getconf(1)
320 for d
in /usr
/bin
/bin
/usr
/sbin
/sbin
321 do if test -x $d/getconf
322 then case `$d/getconf --?-version 2>&1` in
324 : presumably an implementation also configured from conf.tab
326 *) CONF_getconf
=$d/getconf
327 if $CONF_getconf -a >/dev
/null
2>&1
328 then CONF_getconf_a
=-a
335 export CONF_getconf CONF_getconf_a
338 1) echo "$command: check ${CONF_getconf:+$CONF_getconf(1),}confstr(2),pathconf(2),sysconf(2),sysinfo(2) configuration names" >&2 ;;
341 echo "#include <unistd.h>$systeminfo
346 -e '/^#[^0123456789]*1[ ]*".*".*/!d' \
347 -e 's/^#[^0123456789]*1[ ]*"\(.*\)".*/\1/' |
351 -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \
352 -e 's/[ ][ ]*/\n/g' \
353 `cat $tmp.f` 2>/dev
/null |
354 egrep '^(SI|_(CS|PC|SC|SI))_.'
355 case $CONF_getconf_a in
356 ?
*) $CONF_getconf $CONF_getconf_a |
sed 's,[=: ].*,,'
358 *) case $CONF_getconf in
359 ?
*) for v
in `strings $CONF_getconf | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZ_][ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$'`
360 do if $CONF_getconf $v >/dev
/null
369 egrep -v '^_[ABCDEFGHIJKLMNOPQRSTUVWXYZ]+_(COUNT|LAST|N|STR)$' |
380 HOST
=`package | sed -e 's,[0123456789.].*,,' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
425 standard
=${standard}_
$1
433 _
*) standard
=`echo $standard | sed 's,^_*,,'` ;;
435 case " $standards " in
444 eval `echo $standard | sed 's,\(.*\)\([0123456789]*\),standard=\1 section=\2,'`
455 *) case " $standards " in
493 POSIX|XOPEN
) part
=$section ;;
504 *) name
=${name}_
$1 ;;
510 CONFORMANCE|FS_3D|HOSTTYPE|LIBPATH|LIBPREFIX|LIBSUFFIX|PATH_ATTRIBUTES|PATH_RESOLVE|UNIVERSE
)
517 V
[123456789]_
*|V
[123456789][0123456789]_
*) underscore
=VW
;;
524 *VERSION
*)key
=${key}_${standard}${part} ;;
527 eval x
='$'CONF_keys_
$name
529 '') eval x
='$'CONF_name_
$key
535 ?
*) flags
=${flags}${underscore} ;;
539 *VERSION
*)old
=${old}_${standard}${part} ;;
542 eval x
='$'CONF_name_
$old
544 ?
*) eval CONF_name_
$old=
545 eval flags
='$'flags
'$'CONF_flags_
$old
546 eval values
='$'CONF_values_
$old
547 eval script='$'CONF_script_
$old
548 eval args
='$'CONF_args_
$old
549 eval headers
='$'CONF_headers_
$old
553 eval CONF_name_
${key}='$'name
554 eval CONF_standard_
${key}='$'standard
555 eval CONF_call_
${key}='$'call
556 eval CONF_section_
${key}='$'section
557 eval CONF_flags_
${key}=d
'$'flags
558 eval CONF_define_
${key}='$'define
559 eval CONF_values_
${key}='$'values
560 eval CONF_script_
${key}='$'script
561 eval CONF_args_
${key}='$'args
562 eval CONF_headers_
${key}='$'headers
564 *) eval x
='$'CONF_define_
$key
567 CS
) eval x
='$'CONF_call_
$key
579 ?
*) eval CONF_define_
${key}='$'define
580 eval CONF_call_
${key}='$'call
581 eval x
='$'CONF_call_
${key}
593 eval CONF_flags_
${key}=d
'$'flags
'$'CONF_flags_
${key}
598 *VERSION
*)old
=${old}_${standard}${part} ;;
605 do eval x
='$'CONF_call_
${key}
607 XX
) eval CONF_call_
${key}=QQ
608 eval CONF_flags_
${key}=S
'$'CONF_flags_
${key}
619 keys
=`for key in $keys
620 do eval echo '$'CONF_name_$key '$'key
621 done | sort -u | sed 's,.* ,,'`
623 -d3) for key
in $keys
624 do eval name
=\"'$'CONF_name_
$key\"
626 ?
*) eval standard
=\"'$'CONF_standard_
$key\"
627 eval call
=\"'$'CONF_call_
$key\"
628 eval section
=\"'$'CONF_section_
$key\"
629 eval flags
=\"'$'CONF_flags_
$key\"
630 eval define
=\"'$'CONF_define_
$key\"
631 eval values
=\"'$'CONF_values_
$key\"
632 eval script=\"'$'CONF_script_
$key\"
633 eval headers
=\"'$'CONF_headers_
$key\"
634 printf "%29s %35s %8s %2s %1d %5s %s$nl" "$name" "$key" "$standard" "$call" "$section" "$flags" "$define${values:+$sp=$values}${headers:+$sp$headers$nl}${script:+$sp$ob$script$nl$cb}"
642 # mark the dups CONF_PREFIXED
647 do eval name
=\"'$'CONF_name_
$key\"
652 eval p
='$'CONF_flags_
${prev_key}
653 eval c
='$'CONF_flags_
${key}
660 eval CONF_flags_
${prev_key}=$p
661 eval CONF_flags_
${key}=$c
668 # collect all the macros/enums
671 do eval name
=\"'$'CONF_name_
$key\"
677 eval call
=\"'$'CONF_call_
$key\"
682 eval standard
=\"'$'CONF_standard_
$key\"
683 eval section
=\"'$'CONF_section_
$key\"
684 eval flags
=\"'$'CONF_flags_
$key\"
685 eval define
=\"'$'CONF_define_
$key\"
686 eval values
=\"'$'CONF_values_
$key\"
687 eval script=\"'$'CONF_script_
$key\"
688 eval args
=\"'$'CONF_args_
$key\"
689 eval headers
=\"'$'CONF_headers_
$key\"
695 *S
*) case $section in
696 1) eval x
='$'CONF_call_
${c}_${standard}_${name} ;;
697 *) eval x
='$'CONF_call_
${c}_${standard}${section}_${name} ;;
700 *) eval x
='$'CONF_call_
${c}_
${name}
710 XX
) for c
in SC PC CS
711 do echo "_${c}_${name}"
713 *S
*) case $section in
714 1) echo "_${c}_${standard}_${name}" ;;
715 *) echo "_${c}_${standard}${section}_${name}" ;;
727 *) echo "$command: $name: $call: invalid call" >&2
732 *[ABEGHIJQTYZabcefghijklmnopqrstuvwxyz_123456789
]*)
733 echo "$command: $name: $flags: invalid flag(s)" >&2
741 *) name
=${section}_
${name} ;;
743 standard
=${standard}${section}
749 *d
*) conf_op
=${define} ;;
750 *O
*) conf_op
=${call}_
${name} ;;
751 *R
*) conf_op
=_
${standard}_${call}_${name} ;;
752 *S
*) conf_op
=_
${call}_${standard}_${name} ;;
753 *) conf_op
=_
${call}_
${name} ;;
758 case $standard:$flags in
760 *:*L
*) echo "${conf_name}"
761 echo "_${standard}_${conf_name}"
763 *:*M
*) case $section in
764 1) echo "_${standard}_${conf_name}" ;;
765 *) echo "_${standard}${section}_${conf_name}" ;;
770 sort -u < $tmp.q
> $tmp.t
772 sort -u < $tmp.v
> $tmp.t
778 # test all the macros in a few batches (some compilers have an error limit)
780 defined
() # list-file
787 #include <sys/types.h>
789 #include <unistd.h>$systeminfo$headers
792 unsigned int conf
[] = {
797 [ -f $tmp.1.c
] ||
cp $tmp.c
$tmp.1.c
798 if $cc -c $tmp.c
> $tmp.e
2>&1
801 [ -f $tmp.1.e
] ||
cp $tmp.e
$tmp.1.e
804 sed "s/[^_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789][^_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]*/${snl}/g" $tmp.e |
805 grep '^[_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz][_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]*$' |
807 cmp -s $tmp.n
$tmp.p
&& break
808 fgrep
-x -v -f $tmp.n
$1 > $tmp.y
815 #include <sys/types.h>
817 #include <unistd.h>$systeminfo$headers
821 sed 's/.*/conf "&" = &/' $1
823 $cc -E $tmp.c
2>/dev
/null |
824 sed -e '/conf[ ]*".*"[ ]*=[ ]*/!d' -e '/[_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789][ ]*(/!d' -e 's/.*"\(.*\)".*/\1/' > $tmp.n
826 then fgrep
-x -v -f $tmp.n
$1 > $tmp.y
832 1) echo "$command: check macros/enums as static initializers" >&2 ;;
840 # mark the constant macros/enums
844 do eval CONF_const_
${line}=1
848 do eval CONF_const_
${line}=1
851 # mark the string literal values
856 #include <sys/types.h>
858 #include <unistd.h>$systeminfo$headers
862 sed 's/.*/conf "&" = &/' $tmp.q
864 $cc -E $tmp.c
2>/dev
/null |
865 sed -e '/conf[ ]*".*"[ ]*=[ ]*"/!d' -e 's/.*"\([^"]*\)".*/\1/' > $tmp.e
868 do eval CONF_string_
${line}=1
871 # walk through the table
874 ksh
) integer len name_max
;;
877 export tmp name standard call cc
881 do eval name
=\"'$'CONF_name_
$key\"
887 eval call
=\"'$'CONF_call_
$key\"
892 eval standard
=\"'$'CONF_standard_
$key\"
893 eval section
=\"'$'CONF_section_
$key\"
894 eval flags
=\"'$'CONF_flags_
$key\"
895 eval define
=\"'$'CONF_define_
$key\"
896 eval values
=\"'$'CONF_values_
$key\"
897 eval script=\"'$'CONF_script_
$key\"
898 eval args
=\"'$'CONF_args_
$key\"
899 eval headers
=\"'$'CONF_headers_
$key\"
905 *S
*) case $section in
906 1) eval x
='$'CONF_call_
${c}_${standard}_${name} ;;
907 *) eval x
='$'CONF_call_
${c}_${standard}${section}_${name} ;;
910 *) eval x
='$'CONF_call_
${c}_
${name}
920 XX
) for c
in SC PC CS
922 *S
*) case $section in
923 1) eval x
='$'CONF_const__
${c}_${standard}_${name} ;;
924 *) eval x
='$'CONF_const__
${c}_${standard}${section}_${name} ;;
927 *) eval x
='$'CONF_const__
${c}_
${name}
939 XX
) case $standard in
950 case " $standards " in
953 *) standards
="$standards $standard"
956 conf_standard
=CONF_
${standard}
958 CS
) conf_call
=CONF_confstr
960 PC
) conf_call
=CONF_pathconf
962 SC
) conf_call
=CONF_sysconf
964 SI
) conf_call
=CONF_sysinfo
966 XX
) conf_call
=CONF_nop
970 for s
in _
${call}_${standard}${section}_${name} _${call}_${standard}_${name} _${call}_${section}_${name} _${call}_${name} ${call}_${name}
971 do eval x
='$'CONF_const_
${s}
978 conf_section
=$section
981 *C
*) conf_flags
="${conf_flags}|CONF_DEFER_CALL" ;;
984 *D
*) conf_flags
="${conf_flags}|CONF_DEFER_MM" ;;
987 *F
*) conf_flags
="${conf_flags}|CONF_FEATURE" ;;
990 *L
*) conf_flags
="${conf_flags}|CONF_LIMIT" ;;
993 *M
*) conf_flags
="${conf_flags}|CONF_MINMAX" ;;
996 *N
*) conf_flags
="${conf_flags}|CONF_NOSECTION" ;;
999 *P
*) conf_flags
="${conf_flags}|CONF_PREFIXED" ;;
1002 *S
*) conf_flags
="${conf_flags}|CONF_STANDARD" ;;
1005 *U
*) conf_flags
="${conf_flags}|CONF_UNDERSCORE" ;;
1008 *V
*) conf_flags
="${conf_flags}|CONF_NOUNDERSCORE" ;;
1011 *W
*) conf_flags
="${conf_flags}|CONF_PREFIX_ONLY" ;;
1014 ?
*) case $standard in
1021 echo "$command: test: $sep$standard $call $name" >&2
1025 CS|SI
) conf_flags
="${conf_flags}|CONF_STRING"
1028 *) eval string
='$'CONF_string_
${key}
1034 case ${conf_name} in
1038 *) eval x
='$'CONF_const_
${conf_name}
1042 '') for s
in ${values}
1044 $sym) eval x
='$'CONF_const_
${s}
1046 1) eval a
='$'CONF_const_
${standard}_
${s}
1055 [0123456789]*|
[-+][0123456789]*)
1061 case ${x:+1}:$flags:$conf_op in
1064 1) echo "$command: probe for ${conf_name} <limits.h> value" >&2 ;;
1067 case $CONF_getconf in
1068 ?
*) if $CONF_getconf $conf_name > $tmp.x
2>/dev
/null
1078 '#'*) echo "$script" > $tmp.sh
1080 x
=`./$tmp.sh 2>/dev/null`
1082 '') case $conf_name in
1085 t
="unsigned _ast_intmax_t"
1087 *) f
="%${LL_format}d"
1094 #include <sys/types.h>
1096 #include <unistd.h>$systeminfo$headers
1101 printf("$f\n", ($t)$conf_name);
1108 #include <sys/types.h>
1110 #include <unistd.h>$systeminfo$headers
1118 *) eval set '""' '"'$args'"'; shift ;;
1122 '#'*) .
/$tmp.sh
$a > $tmp.x
2>/dev
/null
1125 *) $cc $a -o $tmp.exe
$tmp.c
>/dev
/null
2>&1 && .
/$tmp.exe
> $tmp.x
2>/dev
/null
1147 case ${x:+1}:$flags:$conf_op in
1152 *) conf_flags
="${conf_flags}|CONF_LIMIT" ;;
1154 conf_flags
="${conf_flags}|CONF_LIMIT_DEF"
1156 1:*) cat >> $tmp.l
<<!
1157 printf("#ifndef ${conf_name}\n");
1158 printf("#define ${conf_name} \"${x}\"\n");
1162 *:U
*) cat >> $tmp.l
<<!
1163 printf("#ifndef ${conf_name}\n");
1164 printf("#ifndef ${x}\n");
1165 printf("#define ${x} %lu\n", ${x});
1167 printf("#define ${conf_name} ${x}\n");
1171 *:$sym) cat >> $tmp.l
<<!
1172 printf("#ifndef ${conf_name}\n");
1173 printf("#ifndef ${x}\n");
1174 printf("#define ${x} %ld\n", ${x});
1176 printf("#define ${conf_name} ${x}\n");
1180 *) cat >> $tmp.l
<<!
1181 printf("#ifndef ${conf_name}\n");
1182 printf("#define ${conf_name} ${x}\n");
1197 *) name
=${section}_
${name} ;;
1199 standard
=${standard}${section}
1203 case $call:$standard:$flags in
1204 *:C
:*M
*)for s
in _
${standard}_${conf_name} ${values}
1208 conf_flags
="${conf_flags}|CONF_MINMAX_DEF"
1215 [CPSX
][CSX
]:*:*[FM
]*)
1217 for s
in _
${standard}_${conf_name} ${values}
1219 $sym) eval x
='$'CONF_const_
${s} ;;
1225 *M
*) conf_flags
="${conf_flags}|CONF_MINMAX_DEF" ;;
1231 case ${x:+1}:${script:+1} in
1232 :1) case $verbose in
1233 1) echo "$command: probe for _${standard}_${conf_name} minmax value" >&2 ;;
1235 case $CONF_getconf in
1236 ?
*) if $CONF_getconf _
${standard}_
${conf_name} > $tmp.x
2>/dev
/null
1246 '#'*) echo "$script" > $tmp.sh
1248 x
=`./$tmp.sh 2>/dev/null`
1252 #include <sys/types.h>
1254 #include <unistd.h>$systeminfo$headers
1262 *) eval set '""' "$args"; shift ;;
1266 '#'*) .
/$tmp.sh
$a > $tmp.x
2>/dev
/null
1269 *) $cc $a -o $tmp.exe
$tmp.c
>/dev
/null
2>&1 && .
/$tmp.exe
> $tmp.x
2>/dev
/null
1289 *M
*) conf_flags
="${conf_flags}|CONF_MINMAX_DEF" ;;
1298 1) conf_limit
="{ 0, $conf_limit }" conf_minmax
="{ 0, $conf_minmax }"
1300 *) case $conf_limit in
1301 0[xX
]*|
-*|
+*|
[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_
]*)
1303 *[!0123456789abcdefABCDEF
]*)
1307 conf_limit
=0x
$conf_limit
1310 case $conf_minmax in
1311 0[xX
]*|
-*|
+*|
[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_
]*)
1313 *[!0123456789abcdefABCDEF
]*)
1317 conf_minmax
=0x
$conf_minmax
1325 ??
) case $conf_limit in
1326 *[!lL
][lL
]|
*[!lL
][lL
][uU
])
1327 conf_limit
=${conf_limit}L
1335 ksh
) p
=${conf_limit%?}
1339 *) eval `echo '' $conf_limit | sed 's/ *\(.*\)\(.\) */p=\1 s=\2/'`
1343 conf_limit
=${p}${s}${LL_suffix}-1${LL_suffix}
1345 0[xX
]*[abcdefABCDEF
])
1346 conf_limit
=${conf_limit}${LL_suffix}
1349 conf_limit
=${conf_limit}${LL_suffix}
1352 conf_limit
=${conf_limit}U
${LL_suffix}
1355 case $conf_minmax in
1360 ??
) case $conf_minmax in
1361 *[!lL
][lL
]|
*[!lL
][lL
][uU
])
1362 conf_minmax
=${conf_minmax}L
1370 ksh
) p
=${conf_minmax%?}
1374 *) eval `echo '' $conf_minmax | sed 's/ *\(.*\)\(.\) */p=\1 s=\2/'`
1378 conf_minmax
=${p}${s}${LL_suffix}-1${LL_suffix}
1380 0[xX
]*[abcdefABCDEF
])
1381 conf_minmax
=${conf_minmax}${LL_suffix}
1384 conf_minmax
=${conf_minmax}${LL_suffix}
1387 conf_minmax
=${conf_minmax}U
${LL_suffix}
1390 conf_limit
="{ $conf_limit, 0 }" conf_minmax
="{ $conf_minmax, 0 }"
1394 '0|'*) case $shell in
1395 ksh
) conf_flags
=${conf_flags#0?} ;;
1396 *) conf_flags
=`echo "$conf_flags" | sed 's/^0.//'` ;;
1400 echo "{ \"$conf_name\", $conf_limit, $conf_minmax, $conf_flags, $conf_standard, $conf_section, $conf_call, $conf_op },"
1402 ksh
) len
=${#conf_name}
1403 if ((len
>=name_max
))
1404 then ((name_max
=len
+1))
1407 *) len
=`echo ${conf_name} | wc -c`
1408 if expr \
( $len - 1 \
) \
>= ${name_max} >/dev
/null
1423 1) echo "$command: generate ${base}.h string table header" >&2 ;;
1426 ksh
) ((name_max
=name_max
+3)); ((name_max
=name_max
/4*4)) ;; # bsd /bin/sh !
1427 *) name_max
=`expr \( $name_max + 3 \) / 4 \* 4` ;;
1437 #if !defined(const) && !defined(__STDC__) && !defined(__cplusplus) && !defined(c_plusplus)
1441 #define conf _ast_conf_data
1442 #define conf_elements _ast_conf_ndata
1444 #define prefix _ast_conf_prefix
1445 #define prefix_elements _ast_conf_nprefix
1448 #define CONF_confstr 1
1449 #define CONF_pathconf 2
1450 #define CONF_sysconf 3
1451 #define CONF_sysinfo 4
1455 for standard
in $standards
1456 do echo "#define CONF_${standard} ${index}"
1458 ksh
) ((index
=index
+1)) ;;
1459 *) index
=`expr ${index} + 1` ;;
1462 echo "#define CONF_call ${index}"
1463 case $CONF_getconf in
1465 echo "#define _pth_getconf \"$CONF_getconf\""
1466 case $CONF_getconf_a in
1467 ?
*) echo "#define _pth_getconf_a \"$CONF_getconf_a\"" ;;
1473 #define CONF_DEFER_CALL 0x0001
1474 #define CONF_DEFER_MM 0x0002
1475 #define CONF_FEATURE 0x0004
1476 #define CONF_LIMIT 0x0008
1477 #define CONF_LIMIT_DEF 0x0010
1478 #define CONF_MINMAX 0x0020
1479 #define CONF_MINMAX_DEF 0x0040
1480 #define CONF_NOSECTION 0x0080
1481 #define CONF_NOUNDERSCORE 0x0100
1482 #define CONF_PREFIX_ONLY 0x0200
1483 #define CONF_PREFIXED 0x0400
1484 #define CONF_STANDARD 0x0800
1485 #define CONF_STRING 0x1000
1486 #define CONF_UNDERSCORE 0x2000
1487 #define CONF_USER 0x4000
1489 struct Conf_s
; typedef struct Conf_s Conf_t
;
1491 typedef struct Value_s
1499 const char name
[${name_max}];
1509 typedef struct Prefix_s
1511 const char name
[16];
1517 extern const Conf_t conf
[];
1518 extern int conf_elements
;
1520 extern const Prefix_t prefix
[];
1521 extern int prefix_elements
;
1527 -d7) echo $command: $tmp.2 ${base}.h
;;
1528 *) cmp -s $tmp.2 ${base}.h
2>/dev
/null ||
mv $tmp.2 ${base}.h
;;
1532 1) echo "$command: generate ${base}.c string table" >&2 ;;
1537 #include <sys/types.h>
1539 #include <unistd.h>$systeminfo$headers
1541 #include "${base}.h"
1546 * prefix
strings -- the first few are indexed by Conf_t.standard
1549 const Prefix_t prefix
[] =
1552 for standard
in $standards
1554 ksh
) len
=${#standard} ;;
1555 *) len
=`echo ${standard} | wc -c`; len
=`expr $len - 1` ;;
1557 echo " \"${standard}\", ${len}, CONF_${standard}, -1,"
1560 "XX", 2, CONF_POSIX
, CONF_nop
,
1561 "CS", 2, CONF_POSIX
, CONF_confstr
,
1562 "PC", 2, CONF_POSIX
, CONF_pathconf
,
1563 "SC", 2, CONF_POSIX
, CONF_sysconf
,
1564 "SI", 2, CONF_SVID
, CONF_sysinfo
,
1567 int prefix_elements
= (int
)sizeof
(prefix
) / (int
)sizeof
(prefix
[0]);
1570 * conf
strings sorted
in ascending order
1573 const Conf_t conf
[] =
1580 int conf_elements
= (int
)sizeof
(conf
) / (int
)sizeof
(conf
[0]);
1584 -d7) echo $command: $tmp.4 ${base}.c
;;
1585 *) cmp -s $tmp.4 ${base}.c
2>/dev
/null ||
mv $tmp.4 ${base}.c
;;
1588 # limits.h generation code
1592 1) echo "$command: generate ${base}.h supplemental <limits.h> values" >&2 ;;
1599 * supplemental
<limits.h
> values
1603 test -f $tmp.l
&& cat $tmp.l
1606 -d7) echo $command: $tmp.5 ${base}.h
;;
1607 *) cmp -s $tmp.5 ${base}.h
2>/dev
/null ||
mv $tmp.5 ${base}.h
;;