path: root/mcon/U/voidflags.U
diff options
Diffstat (limited to 'mcon/U/voidflags.U')
1 files changed, 159 insertions, 0 deletions
diff --git a/mcon/U/voidflags.U b/mcon/U/voidflags.U
new file mode 100644
index 0000000..4983c24
--- /dev/null
+++ b/mcon/U/voidflags.U
@@ -0,0 +1,159 @@
+?RCS: $Id: voidflags.U,v 1997/02/28 16:27:58 ram Exp $
+?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 3.0.
+?RCS: $Log: voidflags.U,v $
+?RCS: Revision 1997/02/28 16:27:58 ram
+?RCS: patch61: don't prompt them if the void support is high enough for us
+?RCS: Revision 1995/01/11 15:37:44 ram
+?RCS: patch45: cosmetic change to avoid spurious blank lines when using -s
+?RCS: Revision 3.0 1993/08/18 12:10:01 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?MAKE:voidflags defvoidused: cat rm contains +cc +ccflags package \
+ Oldconfig Myread
+?MAKE: -pick add $@ %<
+?S: This variable contains the eventual value of the VOIDFLAGS symbol,
+?S: which indicates how much support of the void type is given by this
+?S: compiler. See VOIDFLAGS for more info.
+?X: Exceptionally, we have to explicitely alias the symbol name for
+?X: config_h.SH, otherwise the comment would not appear.
+?C: This symbol indicates how much support of the void type is given by this
+?C: compiler. What various bits mean:
+?C: 1 = supports declaration of void
+?C: 2 = supports arrays of pointers to functions returning void
+?C: 4 = supports comparisons between pointers to void functions and
+?C: addresses of void functions
+?C: 8 = suports declaration of generic void pointers
+?C: The package designer should define VOIDUSED to indicate the requirements
+?C: of the package. This can be done either by #defining VOIDUSED before
+?C: including config.h, or by defining defvoidused in Myinit.U. If the
+?C: latter approach is taken, only those flags will be tested. If the
+?C: level of void support necessary is not present, defines void to int.
+?H:?%<:#ifndef VOIDUSED
+?H:?%<:#define VOIDUSED $defvoidused
+?H:?%<:#define VOIDFLAGS $voidflags
+?H:?%<:#define void int /* is void to be avoided? */
+?H:?%<:#define M_VOID /* Xenix strikes again */
+?INIT:: full support for void wanted by default
+?LINT:describe defvoidused
+: check for void type
+echo " "
+echo "Checking to see how well your C compiler groks the void type..." >&4
+echo " "
+$cat >&4 <<EOM
+ Support flag bits are:
+ 1: basic void declarations.
+ 2: arrays of pointers to functions returning void.
+ 4: operations between pointers to and addresses of void functions.
+ 8: generic void pointers.
+echo " "
+case "$voidflags" in
+ $cat >try.c <<'EOCP'
+#if TRY & 1
+void sub() {
+sub() {
+ extern void moo(); /* function returning void */
+ void (*goo)(); /* ptr to func returning void */
+#if TRY & 8
+ void *hue; /* generic ptr */
+#if TRY & 2
+ void (*foo[10])();
+#if TRY & 4
+ if(goo == moo) {
+ exit(0);
+ }
+ exit(0);
+main() { sub(); }
+?X: This unit used to use cc -S in those tests to try to speed up things, but
+?X: unfortunately, AIX 3.2 does not support this option.
+ if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
+ voidflags=$defvoidused
+ echo "It appears to support void to the level $package wants ($defvoidused)."
+ if $contains warning .out >/dev/null 2>&1; then
+ echo "However, you might get some warnings that look like this:"
+ $cat .out
+ fi
+ else
+echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
+ if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
+ echo "It supports 1..."
+ if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
+ echo "It also supports 2..."
+ if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
+ voidflags=7
+ echo "And it supports 4 but not 8 definitely."
+ else
+ echo "It doesn't support 4..."
+ if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
+ voidflags=11
+ echo "But it supports 8."
+ else
+ voidflags=3
+ echo "Neither does it support 8."
+ fi
+ fi
+ else
+ echo "It does not support 2..."
+ if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
+ voidflags=13
+ echo "But it supports 4 and 8."
+ else
+ if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
+ voidflags=5
+ echo "And it supports 4 but has not heard about 8."
+ else
+ echo "However it supports 8 but not 4."
+ fi
+ fi
+ fi
+ else
+ echo "There is no support at all for void."
+ voidflags=0
+ fi
+ fi
+?X: Only prompt user if support does not match the level we want
+case "$voidflags" in
+"$defvoidused") ;;
+ dflt="$voidflags";
+ rp="Your void support flags add up to what?"
+ . ./myread
+ voidflags="$ans"
+ ;;
+$rm -f try.* .out