summaryrefslogtreecommitdiff
path: root/mcon/U/voidflags.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/voidflags.U')
-rw-r--r--mcon/U/voidflags.U180
1 files changed, 180 insertions, 0 deletions
diff --git a/mcon/U/voidflags.U b/mcon/U/voidflags.U
new file mode 100644
index 0000000..0e0f49c
--- /dev/null
+++ b/mcon/U/voidflags.U
@@ -0,0 +1,180 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
+?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 License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: voidflags.U,v $
+?RCS: Revision 3.0.1.2 1997/02/28 16:27:58 ram
+?RCS: patch61: don't prompt them if the void support is high enough for us
+?RCS:
+?RCS: Revision 3.0.1.1 1995/01/11 15:37:44 ram
+?RCS: patch45: cosmetic change to avoid spurious blank lines when using -s
+?RCS:
+?RCS: Revision 3.0 1993/08/18 12:10:01 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?RCS:
+?MAKE:voidflags defvoidused: cat sed rm rm_try contains +cc +ccflags package \
+ Oldconfig Myread
+?MAKE: -pick add $@ %<
+?S:voidflags:
+?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.
+?S:.
+?S:defvoidused:
+?S: This variable contains the default value of the VOIDUSED symbol (15).
+?S:.
+?X: Exceptionally, we have to explicitly alias the symbol name for
+?X: config_h.SH, otherwise the comment would not appear.
+?C:VOIDFLAGS ~ %<:
+?C: This symbol indicates how much support of the void type is given by this
+?C: compiler. What various bits mean:
+?C:
+?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:
+?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.
+?C:.
+?H:?%<:#ifndef VOIDUSED
+?H:?%<:#define VOIDUSED $defvoidused
+?H:?%<:#endif
+?H:?%<:#define VOIDFLAGS $voidflags
+?H:?%<:#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
+?H:?%<:#define void int /* is void to be avoided? */
+?H:?%<:#define M_VOID /* Xenix strikes again */
+?H:?%<:#endif
+?H:.
+?W:%<:void
+?F:!.out !try.c !flags
+?LINT:usefile .out flags try.c
+?INIT:: full support for void wanted by default
+?INIT:defvoidused=15
+?INIT:
+?LINT:known void M_VOID VOIDUSED
+: check for void type
+echo " "
+echo "Checking to see how well your C compiler groks the void type..." >&4
+$cat >flags <<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.
+
+EOM
+case "$voidflags" in
+'')
+ $cat >try.c <<'EOCP'
+extern int doit();
+#if TRY & 1
+void sub() {
+#else
+sub() {
+#endif
+ extern void moo(); /* function returning void */
+ void (*goo)(); /* ptr to func returning void */
+#if TRY & 2
+ static void (*foo[10])();
+#endif
+#if TRY & 8
+ void *hue; /* generic ptr */
+ char buf[] = "buf";
+ int *iptr;
+#endif
+
+#if TRY & 2
+ if (doit()) {
+ foo[0] = moo;
+ (*foo[0])();
+ }
+#endif
+#if TRY & 4
+ if (doit())
+ goo = moo;
+ if (goo == moo)
+ doit();
+#endif
+#if TRY & 8
+ hue = buf;
+ if (doit())
+ iptr = hue;
+#endif
+ doit();
+}
+EOCP
+?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 "Good. It appears to support void to the level $package wants."
+ if $contains warning .out >/dev/null 2>&1; then
+ echo "However, you might get some warnings that look like this:"
+ $sed -e 's/^/ /' .out
+ fi
+ else
+echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
+ $cat >&4 flags
+ $rm -f flags
+ 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
+esac
+?X: Only prompt user if support does not match the level we want
+case "$voidflags" in
+"$defvoidused") ;;
+*)
+ dflt="$voidflags";
+ test -f flags && $cat flags
+ rp="Your void support flags add up to what?"
+ . ./myread
+ voidflags="$ans"
+ ;;
+esac
+$rm_try flags
+