summaryrefslogtreecommitdiff
path: root/mcon/U/d_fd_set.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/d_fd_set.U')
-rw-r--r--mcon/U/d_fd_set.U138
1 files changed, 138 insertions, 0 deletions
diff --git a/mcon/U/d_fd_set.U b/mcon/U/d_fd_set.U
new file mode 100644
index 0000000..8e13de2
--- /dev/null
+++ b/mcon/U/d_fd_set.U
@@ -0,0 +1,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*
+
+