3 ?RCS: Copyright (c) 1998, Jarkko Hietaniemi
5 ?RCS: You may redistribute only under the terms of the Artistic License,
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 License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?MAKE:selectminbits: Compile cat rm_try Oldconfig d_select \
12 i_time i_systime i_systimek i_sysselct selecttype d_socket \
13 byteorder Myread Setvar run i_stdlib ptrsize
14 ?MAKE: -pick add $@ %<
16 ?S: This variable holds the minimum number of bits operated by select.
17 ?S: That is, if you do select(n, ...), how many bits at least will be
18 ?S: cleared in the masks if some activity is detected. Usually this
19 ?S: is either n or 32*ceil(n/32), especially many little-endians do
20 ?S: the latter. This is only useful if you have select(), naturally.
23 ?C: This symbol holds the minimum number of bits operated by select.
24 ?C: That is, if you do select(n, ...), how many bits at least will be
25 ?C: cleared in the masks if some activity is detected. Usually this
26 ?C: is either n or 32*ceil(n/32), especially many little-endians do
27 ?C: the latter. This is only useful if you have select(), naturally.
29 ?H:#define SELECT_MIN_BITS $selectminbits /**/
34 : check for the select 'width'
35 case "$selectminbits" in
36 '') safebits=`expr $ptrsize \* 8`
41 Checking to see on how many bits at a time your select() operates...
44 #include <sys/types.h>
46 #$i_systime I_SYS_TIME
47 #$i_systimek I_SYS_TIME_KERNEL
52 # ifdef I_SYS_TIME_KERNEL
55 # include <sys/time.h>
56 # ifdef I_SYS_TIME_KERNEL
60 #$i_sysselct I_SYS_SELECT
62 #include <sys/select.h>
66 # include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
74 #define S sizeof(*(b))
76 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
77 #define NBITS (NBYTES * 8)
79 char *s = (char *)malloc(NBYTES);
88 fp = fopen("try.c", "r");
95 for (i = 0; i < NBITS; i++)
99 select(fd + 1, b, 0, 0, &t);
100 for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
102 printf("%d\n", i + 1);
107 if eval $compile_ok; then
108 selectminbits=`$run ./try 2>/dev/null`
109 case "$selectminbits" in
111 Cannot figure out on how many bits at a time your select() operates.
112 I'll play safe and guess it is $safebits bits.
114 selectminbits=$safebits
115 bits="$safebits bits"
118 *) bits="$selectminbits bits" ;;
120 echo "Your select() operates on $bits at a time." >&4
122 rp='What is the minimum number of bits your select() operates on?'
134 *) : no select, so pick a harmless default
135 selectminbits=$safebits