perl 5.0 alpha 8
[p5sagit/p5-mst-13.2.git] / U / voidflags.U
CommitLineData
2304df62 1?X: These units are based on the ones supplied with dist-3.0
2?X: patchlevel 22. They have been changed or enhanced to work with
3?X: perl5alpha. I would appreciate hearing about any changes,
4?X: corrections, or enhancements.
5?X: Andy Dougherty doughera@lafcol.lafayette.edu
6?X: Dept. of Physics
7?X: Lafayette College
8?X: Easton, PA 18042-1782
9?X: Sat Apr 2 15:45:17 EST 1994
10?RCS: $Id: voidflags.U,v 3.0 1993/08/18 12:10:01 ram Exp $
11?RCS:
12?RCS: Copyright (c) 1991-1993, Raphael Manfredi
13?RCS:
14?RCS: You may redistribute only under the terms of the Artistic Licence,
15?RCS: as specified in the README file that comes with the distribution.
16?RCS: You may reuse parts of this distribution only within the terms of
17?RCS: that same Artistic Licence; a copy of which may be found at the root
18?RCS: of the source tree for dist 3.0.
19?RCS:
20?RCS: $Log: voidflags.U,v $
21?RCS: Revision 3.0 1993/08/18 12:10:01 ram
22?RCS: Baseline for dist 3.0 netwide release.
23?RCS:
24?MAKE:voidflags defvoidused: cat rm contains cc package Oldconfig Myread
25?MAKE: -pick add $@ %<
26?S:voidflags:
27?S: This variable contains the eventual value of the VOIDFLAGS symbol,
28?S: which indicates how much support of the void type is given by this
29?S: compiler. See VOIDFLAGS for more info.
30?S:.
31?X: Exceptionally, we have to explicitely alias the symbol name for
32?X: config_h.SH, otherwise the comment would not appear.
33?C:VOIDFLAGS ~ %<:
34?C: This symbol indicates how much support of the void type is given by this
35?C: compiler. What various bits mean:
36?C:
37?C: 1 = supports declaration of void
38?C: 2 = supports arrays of pointers to functions returning void
39?C: 4 = supports comparisons between pointers to void functions and
40?C: addresses of void functions
41?C: 8 = suports declaration of generic void pointers
42?C:
43?C: The package designer should define VOIDUSED to indicate the requirements
44?C: of the package. This can be done either by #defining VOIDUSED before
45?C: including config.h, or by defining defvoidused in Myinit.U. If the
46?C: latter approach is taken, only those flags will be tested. If the
47?C: level of void support necessary is not present, defines void to int.
48?C:.
49?H:?%<:#ifndef VOIDUSED
50?H:?%<:# ifdef VOIDWANT
51?H:?%<:# define VOIDUSED VOIDWANT
52?H:?%<:# else
53?H:?%<:# define VOIDUSED $defvoidused
54?H:?%<:# endif
55?H:?%<:#endif
56?H:?%<:#define VOIDFLAGS $voidflags
57?H:?%<:#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
58?H:?%<:# define void int /* is void to be avoided? */
59?H:?%<:# define M_VOID /* Xenix strikes again */
60?H:?%<:# define VOID
61?H:?%<:#else
62?H:?%<:# define VOID void
63?H:?%<:#endif
64?H:.
65?W:%<:void VOID VOIDWANT
66?INIT:: full support for void wanted by default
67?INIT:defvoidused=15
68?INIT:
69?LINT:describe defvoidused
70?LINT:known void M_VOID VOIDUSED
71: check for void type
72echo " "
73$cat >&4 <<EOM
74Checking to see how well your C compiler groks the void type...
75
76 Support flag bits are:
77 1: basic void declarations.
78 2: arrays of pointers to functions returning void.
79 4: operations between pointers to and addresses of void functions.
80 8: generic void pointers.
81
82EOM
83case "$voidflags" in
84'')
85 $cat >try.c <<'EOCP'
86#if TRY & 1
87void main() {
88#else
89main() {
90#endif
91 extern void moo(); /* function returning void */
92 void (*goo)(); /* ptr to func returning void */
93#if TRY & 8
94 void *hue; /* generic ptr */
95#endif
96#if TRY & 2
97 void (*foo[10])();
98#endif
99
100#if TRY & 4
101 if(goo == moo) {
102 exit(0);
103 }
104#endif
105 exit(0);
106}
107EOCP
108?X: This unit used to use cc -S in those tests to try to speed up things, but
109?X: unfortunately, AIX 3.2 does not support this option.
110 if $cc -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
111 voidflags=$defvoidused
112 echo "It appears to support void to the level $package wants ($defvoidused)."
113 if $contains warning .out >/dev/null 2>&1; then
114 echo "However, you might get some warnings that look like this:"
115 $cat .out
116 fi
117 else
118echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
119 if $cc -c -DTRY=1 try.c >/dev/null 2>&1 ; then
120 echo "It supports 1..."
121 if $cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
122 echo "It also supports 2..."
123 if $cc -c -DTRY=7 try.c >/dev/null 2>&1 ; then
124 voidflags=7
125 echo "And it supports 4 but not 8 definitely."
126 else
127 echo "It doesn't support 4..."
128 if $cc -c -DTRY=11 try.c >/dev/null 2>&1 ; then
129 voidflags=11
130 echo "But it supports 8."
131 else
132 voidflags=3
133 echo "Neither does it support 8."
134 fi
135 fi
136 else
137 echo "It does not support 2..."
138 if $cc -c -DTRY=13 try.c >/dev/null 2>&1 ; then
139 voidflags=13
140 echo "But it supports 4 and 8."
141 else
142 if $cc -c -DTRY=5 try.c >/dev/null 2>&1 ; then
143 voidflags=5
144 echo "And it supports 4 but has not heard about 8."
145 else
146 echo "However it supports 8 but not 4."
147 fi
148 fi
149 fi
150 else
151 echo "There is no support at all for void."
152 voidflags=0
153 fi
154 fi
155esac
156dflt="$voidflags";
157rp="Your void support flags add up to what?"
158. ./myread
159voidflags="$ans"
160$rm -f try.* .out
161