This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / selecttype.U
CommitLineData
d8875586
MBT
1?RCS: $Id: selecttype.U 1 2006-08-24 12:32:52Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 4.0.
10?RCS:
11?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
12?RCS:
13?RCS: $Log: selecttype.U,v $
14?RCS: Revision 3.0.1.3 1997/02/28 16:20:09 ram
15?RCS: patch61: always include <sys/select.h> when available for test
16?RCS:
17?RCS: Revision 3.0.1.2 1995/07/25 14:14:06 ram
18?RCS: patch56: removed harmful spaces in assignment
19?RCS:
20?RCS: Revision 3.0.1.1 1994/06/20 07:06:31 ram
21?RCS: patch30: created by ADO
22?RCS:
23?MAKE:selecttype: cat +cc +ccflags rm Oldconfig Myread \
24 d_fd_set d_select d_socket i_systime i_sysselct
25?MAKE: -pick add $@ %<
26?S:selecttype:
27?S: This variable holds the type used for the 2nd, 3rd, and 4th
28?S: arguments to select. Usually, this is 'fd_set *', if HAS_FD_SET
29?S: is defined, and 'int *' otherwise. This is only useful if you
30?S: have select(), naturally.
31?S:.
32?C:Select_fd_set_t:
33?C: This symbol holds the type used for the 2nd, 3rd, and 4th
34?C: arguments to select. Usually, this is 'fd_set *', if HAS_FD_SET
35?C: is defined, and 'int *' otherwise. This is only useful if you
36?C: have select(), of course.
37?C:.
38?H:#define Select_fd_set_t $selecttype /**/
39?H:.
40?T:xxx yyy
41: check for type of arguments to select. This will only really
42: work if the system supports prototypes and provides one for
43: select.
44case "$d_select" in
45$define)
46 : Make initial guess
47 case "$selecttype" in
48 ''|' ')
49 case "$d_fd_set" in
50 $define) xxx='fd_set *' ;;
51 *) xxx='int *' ;;
52 esac
53 ;;
54 *) xxx="$selecttype"
55 ;;
56 esac
57 : backup guess
58 case "$xxx" in
59 'fd_set *') yyy='int *' ;;
60 'int *') yyy='fd_set *' ;;
61 esac
62
63 $cat <<EOM
64
65Checking to see what type of arguments are expected by select().
66EOM
67 $cat >try.c <<EOCP
68#$i_systime I_SYS_TIME
69#$i_sysselct I_SYS_SELECT
70#$d_socket HAS_SOCKET
71#include <sys/types.h>
72#ifdef HAS_SOCKET
73#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
74#endif
75#ifdef I_SYS_TIME
76#include <sys/time.h>
77#endif
78#ifdef I_SYS_SELECT
79#include <sys/select.h>
80#endif
81int main()
82{
83 int width;
84 Select_fd_set_t readfds;
85 Select_fd_set_t writefds;
86 Select_fd_set_t exceptfds;
87 struct timeval timeout;
88 select(width, readfds, writefds, exceptfds, &timeout);
89 exit(0);
90}
91EOCP
92 if $cc $ccflags -c -DSelect_fd_set_t="$xxx" try.c >/dev/null 2>&1 ; then
93 selecttype="$xxx"
94 echo "Your system uses $xxx for the arguments to select." >&4
95 elif $cc $ccflags -c -DSelect_fd_set_t="$yyy" try.c >/dev/null 2>&1 ; then
96 selecttype="$yyy"
97 echo "Your system uses $yyy for the arguments to select." >&4
98 else
99 rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
100 dflt="$xxx"
101 . ./myread
102 selecttype="$ans"
103 fi
104 $rm -f try.[co]
105 ;;
106*) selecttype='int *'
107 ;;
108esac
109