summaryrefslogtreecommitdiff
path: root/mcon/U/d_fd_set.U
blob: 8e13de23d1633336dff485d108f6aa0a8e818066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS: 
?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 4.0.
?RCS:
?RCS: $Log: d_fd_set.U,v $
?RCS: Revision 3.0.1.3  1997/02/28  15:33:16  ram
?RCS: patch61: added ?F: metalint hint
?RCS:
?RCS: Revision 3.0.1.2  1994/06/20  06:57:23  ram
?RCS: patch30: extended scope for fd_set checks (ADO)
?RCS:
?RCS: Revision 3.0.1.1  1994/01/24  14:06:27  ram
?RCS: patch16: comments for HAS_FD_* symbols were not consistent
?RCS:
?RCS: Revision 3.0  1993/08/18  12:06:02  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_fd_set d_fd_macros d_fds_bits: cat +cc +ccflags rm Oldconfig \
	d_socket i_systime i_sysselct
?MAKE:	-pick add $@ %<
?S:d_fd_set:
?S:	This variable contains the eventual value of the HAS_FD_SET symbol,
?S:	which indicates if your C compiler knows about the fd_set typedef.
?S:.
?S:d_fd_macros:
?S:	This variable contains the eventual value of the HAS_FD_MACROS symbol,
?S:	which indicates if your C compiler knows about the macros which
?S:	manipulate an fd_set.
?S:.
?S:d_fds_bits:
?S:	This variable contains the eventual value of the HAS_FDS_BITS symbol,
?S:	which indicates if your fd_set typedef contains the fds_bits member.
?S:	If you have an fd_set typedef, but the dweebs who installed it did
?S:	a half-fast job and neglected to provide the macros to manipulate
?S:	an fd_set, HAS_FDS_BITS will let us know how to fix the gaffe.
?S:.
?C:HAS_FD_SET:
?C:	This symbol, when defined, indicates presence of the fd_set typedef
?C:	in <sys/types.h>
?C:.
?C:HAS_FD_MACROS:
?C:	This symbol, when defined,  indicates presence of the macros used to
?C:	manipulate an fd_set.
?C:.
?C:HAS_FDS_BITS:
?C:	This symbol, when defined, indicates presence of the fds_bits member in
?C:	fd_set.  This knowledge is useful if fd_set is available but the macros
?C:	aren't.
?C:.
?H:#$d_fd_set HAS_FD_SET	/**/
?H:#$d_fd_macros HAS_FD_MACROS	/**/
?H:#$d_fds_bits HAS_FDS_BITS	/**/
?H:.
?F:!fd_set
: check for fd_set items
$cat <<EOM

Checking to see how well your C compiler handles fd_set and friends ...
EOM
?X: The FD_SET macros can be in strange places.  On some SysV-based
?X: systems, they are in <sys/bsdtypes.h>, which is included (perhaps)
?X: by <sys/socket.h>.  We won't force people to include
?X: <sys/bsdtypes.h> because it might introduce other
?X: incompatibilities.
$cat >fd_set.c <<EOCP
#$i_systime I_SYS_TIME
#$i_sysselct I_SYS_SELECT
#$d_socket HAS_SOCKET
#include <sys/types.h>
#ifdef HAS_SOCKET
#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
#endif
#ifdef I_SYS_TIME
#include <sys/time.h>
#endif
#ifdef I_SYS_SELECT
#include <sys/select.h>
#endif
int main() {
	fd_set fds;

#ifdef TRYBITS
	if(fds.fds_bits);
#endif

#if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
	exit(0);
#else
	exit(1);
#endif
}
EOCP
if $cc $ccflags -DTRYBITS -o fd_set fd_set.c >fd_set.out 2>&1 ; then
	d_fds_bits="$define"
	d_fd_set="$define"
	echo "Well, your system knows about the normal fd_set typedef..." >&4
	if ./fd_set; then
		echo "and you have the normal fd_set macros (just as I'd expect)." >&4
		d_fd_macros="$define"
	else
		$cat >&4 <<'EOM'
but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
EOM
		d_fd_macros="$undef"
	fi
else
	$cat <<'EOM'
Hmm, your compiler has some difficulty with fd_set.  Checking further...
EOM
	if $cc $ccflags -o fd_set fd_set.c >fd_set.out 2>&1 ; then
		d_fds_bits="$undef"
		d_fd_set="$define"
		echo "Well, your system has some sort of fd_set available..." >&4
		if ./fd_set; then
			echo "and you have the normal fd_set macros." >&4
			d_fd_macros="$define"
		else
			$cat <<'EOM'
but not the normal fd_set macros!  Gross!  More work for me...
EOM
			d_fd_macros="$undef"
		fi
	else
	echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
		d_fd_set="$undef"
		d_fds_bits="$undef"
		d_fd_macros="$undef"
	fi
fi
$rm -f fd_set*