diff options
Diffstat (limited to 'mcon/U/selecttype.U')
-rw-r--r-- | mcon/U/selecttype.U | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/mcon/U/selecttype.U b/mcon/U/selecttype.U new file mode 100644 index 0000000..843dd36 --- /dev/null +++ b/mcon/U/selecttype.U @@ -0,0 +1,116 @@ +?RCS: $Id: selecttype.U 167 2013-05-08 17:58:00Z rmanfredi $ +?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: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu> +?RCS: +?RCS: $Log: selecttype.U,v $ +?RCS: Revision 3.0.1.3 1997/02/28 16:20:09 ram +?RCS: patch61: always include <sys/select.h> when available for test +?RCS: +?RCS: Revision 3.0.1.2 1995/07/25 14:14:06 ram +?RCS: patch56: removed harmful spaces in assignment +?RCS: +?RCS: Revision 3.0.1.1 1994/06/20 07:06:31 ram +?RCS: patch30: created by ADO +?RCS: +?MAKE:selecttype: cat +cc +ccflags rm Oldconfig Myread \ + d_fd_set d_select d_socket i_systime i_sysselct i_winsock2 i_syssock +?MAKE: -pick add $@ %< +?S:selecttype: +?S: This variable holds the type used for the 2nd, 3rd, and 4th +?S: arguments to select. Usually, this is 'fd_set *', if HAS_FD_SET +?S: is defined, and 'int *' otherwise. This is only useful if you +?S: have select(), naturally. +?S:. +?C:Select_fd_set_t: +?C: This symbol holds the type used for the 2nd, 3rd, and 4th +?C: arguments to select. Usually, this is 'fd_set *', if HAS_FD_SET +?C: is defined, and 'int *' otherwise. This is only useful if you +?C: have select(), of course. +?C:. +?H:#define Select_fd_set_t $selecttype /**/ +?H:. +?T:xxx yyy +: check for type of arguments to select. This will only really +: work if the system supports prototypes and provides one for +: select. +case "$d_select" in +$define) + : Make initial guess + case "$selecttype" in + ''|' ') + case "$d_fd_set" in + $define) xxx='fd_set *' ;; + *) xxx='int *' ;; + esac + ;; + *) xxx="$selecttype" + ;; + esac + : backup guess + case "$xxx" in + 'fd_set *') yyy='int *' ;; + 'int *') yyy='fd_set *' ;; + esac + + $cat <<EOM + +Checking to see what type of arguments are expected by select(). +EOM + $cat >try.c <<EOCP +#$i_systime I_SYS_TIME +#$i_sysselct I_SYS_SELECT +#$i_syssock I_SYS_SOCKET +#$i_winsock2 I_WINSOCK2 +#$d_socket HAS_SOCKET +#include <sys/types.h> +#ifdef HAS_SOCKET +#ifdef I_SYS_SOCKET +#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */ +#endif +#endif +#ifdef I_SYS_TIME +#include <sys/time.h> +#endif +#ifdef I_SYS_SELECT +#include <sys/select.h> +#endif +#ifdef I_WINSOCK2 +#include <Winsock2.h> +#endif +int main() +{ + int width; + Select_fd_set_t readfds; + Select_fd_set_t writefds; + Select_fd_set_t exceptfds; + struct timeval timeout; + select(width, readfds, writefds, exceptfds, &timeout); + exit(0); +} +EOCP + if $cc $ccflags -c -DSelect_fd_set_t="$xxx" try.c >/dev/null 2>&1 ; then + selecttype="$xxx" + echo "Your system uses $xxx for the arguments to select." >&4 + elif $cc $ccflags -c -DSelect_fd_set_t="$yyy" try.c >/dev/null 2>&1 ; then + selecttype="$yyy" + echo "Your system uses $yyy for the arguments to select." >&4 + else + rp='What is the type for the 2nd, 3rd, and 4th arguments to select?' + dflt="$xxx" + . ./myread + selecttype="$ans" + fi + $rm -f try.[co] + ;; +*) selecttype='int *' + ;; +esac + |