1 ?RCS: $Id: d_NOFILE.U,v 3.0.1.1 1994/10/29 16:08:38 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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 3.0.
11 ?RCS: $Log: d_NOFILE.U,v $
12 ?RCS: Revision 3.0.1.1 1994/10/29 16:08:38 ram
13 ?RCS: patch36: added ?F: line for metalint file checking
15 ?RCS: Revision 3.0 1993/08/18 12:05:39 ram
16 ?RCS: Baseline for dist 3.0 netwide release.
18 ?MAKE:nofile d_gettblsz tablesize: Compile Myread Guess cat \
19 test rm Csym +cc +ccflags +optimize +ldflags +libs
20 ?MAKE: -pick add $@ %<
22 ?S: This variable contains the number of file descriptors available to the
26 ?S: This variable conditionally handles remapping of the getdtablesize()
27 ?S: subroutine to ulimit(4,0), or the NOFILE manifest constant.
30 ?S: This variable contains either the 'NOFILE' constant or 'ulimit(4, 0L)'
31 ?S: and is used as the remapped value for the getdtablesize() macro.
34 ?C: This catches use of the getdtablesize() subroutine, and remaps it
35 ?C: to either ulimit(4,0) or NOFILE, if getdtablesize() isn't available.
38 ?C: This symbol contains the number of file descriptors available to the
39 ?C: process, as determined at configuration time. Unless a static constant
40 ?C: is needed, you should rely on getdtablesize() to obtain that number.
42 ?H:#$d_gettblsz getdtablesize() $tablesize /**/
43 ?H:#define VAL_NOFILE $nofile /* Number of file descriptors */
47 : see if getdtablesize exists
49 ?X: Revert logical value (d_gettblsz is undef iff getdtablesize is present)
51 $define) d_gettblsz="$undef";;
52 $undef) d_gettblsz="$define";;
54 if set getdtablesize val -f d_gettblsz; eval $csym; $val; then
55 echo 'getdtablesize() found.' >&4
58 @if VAL_NOFILE || nofile
59 $cat >nofile.c <<'EOCP'
63 printf("%d\n", getdtablesize());
68 if eval $compile_ok; then
69 nofile=`./nofile 2>/dev/null`
71 if $test "$nofile"; then
72 echo "(You have $nofile file descriptors available per process.)"
78 echo "(Hmm... Let's say you have $nofile file descriptors available.)"
82 echo 'getdtablesize() NOT found...' >&4
83 if set ulimit val -f; eval $csym; $val; then
84 echo 'Maybe ulimit(4,0) will work...'
85 $cat >nofile.c <<'EOCP'
88 #include <sys/param.h>
102 if $cc $optimize $ccflags -DGETPARAM_H $ldflags -o nofile nofile.c $libs >/dev/null 2>&1 \
103 || $cc $optimize $ccflags $ldflags -o nofile nofile.c $libs >/dev/null 2>&1 ; then
107 if $test "$d_ulimit4" -lt 0; then
108 echo "Your ulimit() call doesn't tell me what I want to know."
109 echo "We'll just use NOFILE in this case."
114 if $test "$d_gettblsz" -gt 0; then
115 echo "Your system defines NOFILE to be $d_gettblsz, and" >&4
117 echo "I had trouble getting NOFILE from your system, but" >&4
119 echo "ulimit returns $d_ulimit4 as the number of available file descriptors." >&4
122 rp='Should I use ulimit to get the number of available file descriptors?'
128 tablesize='ulimit(4, 0L)'
129 echo "Using ulimit(4,0)."
140 echo "Strange, I couldn't get my test program to compile."
141 echo "We'll just use NOFILE in this case."
147 echo 'Using NOFILE instead.'
153 @if VAL_NOFILE || nofile
156 $cat >nofile.c <<'EOCP'
159 #include <sys/param.h>
173 if $cc $ccflags -DGETPARAM_H nofile.c -o nofile $libs >/dev/null 2>&1 \
174 || $cc $ccflags nofile.c -o nofile $libs >/dev/null 2>&1 ; then
175 nofile=`./nofile 2>/dev/null`
177 if $test "$nofile"; then
178 echo "(You have $nofile file descriptors available per process.)"
184 echo "(Hmm... Let's say you have $nofile file descriptors available.)"