2
dnl Copyright (C) 1993-2004 Free Software Foundation, Inc.
3
dnl This file is free software, distributed under the terms of the GNU
4
dnl General Public License. As a special exception to the GNU General
5
dnl Public License, this file may be distributed as part of a program
6
dnl that contains a configuration script generated by Autoconf, under
7
dnl the same distribution terms as the rest of that program.
9
dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
14
[dnl Not AC_CHECK_FUNCS(select) because it doesn't work when CC=g++.
15
AC_CACHE_CHECK([for select], ac_cv_func_select, [
16
AC_TRY_LINK([#include <sys/time.h>
19
int select(int, fd_set*, fd_set*, fd_set*, struct timeval *);
23
], [select(0,(fd_set*)0,(fd_set*)0,(fd_set*)0,(struct timeval *)0);],
24
ac_cv_func_select=yes, ac_cv_func_select=no)])
25
if test $ac_cv_func_select = yes; then
26
AC_DEFINE(HAVE_SELECT, 1, [Define if you have the select() function.])
27
CL_COMPILE_CHECK([sys/select.h], cl_cv_header_sys_select_h,
29
#include <sys/socket.h>
32
#include <sys/select.h>], ,
33
AC_DEFINE(HAVE_SYS_SELECT_H,,[have <sys/select.h>?]))dnl
38
[AC_REQUIRE([CL_OPENFLAGS])dnl
39
dnl Not AC_CHECK_FUNCS(select) because it doesn't work when CC=g++.
40
AC_CACHE_CHECK([for select], ac_cv_func_select, [
43
#include <sys/socket.h>
48
int select(int, fd_set*, fd_set*, fd_set*, struct timeval *);
52
], [select(0,(fd_set*)0,(fd_set*)0,(fd_set*)0,(struct timeval *)0);],
53
ac_cv_func_select=yes, ac_cv_func_select=no)])
54
if test $ac_cv_func_select = yes; then
55
AC_DEFINE(HAVE_SELECT, 1, [Define if you have the select() function.])
56
CL_COMPILE_CHECK([sys/select.h], cl_cv_header_sys_select_h,
58
#include <sys/socket.h>
61
#include <sys/select.h>], ,
62
AC_DEFINE(HAVE_SYS_SELECT_H,,[have <sys/select.h>?]))dnl
64
for z in '' 'const'; do
65
for y in 'fd_set' 'int' 'void' 'struct fd_set'; do
66
for x in 'int' 'size_t'; do
67
if test -z "$have_select"; then
73
#include <sys/types.h>
75
#include <sys/socket.h>
78
#ifdef HAVE_SYS_SELECT_H
79
#include <sys/select.h>
81
], [int select ($x width, $y * readfds, $y * writefds, $y * exceptfds, $z struct timeval * timeout);],
83
cl_cv_proto_select_arg1="$x"
84
cl_cv_proto_select_arg2="$y"
85
cl_cv_proto_select_arg5="$z"
91
if test -z "$have_select"; then
92
echo "*** Missing autoconfiguration support for this platform." 1>&2
93
echo "*** Please report this as a bug to the CLISP developers." 1>&2
94
echo "*** When doing this, please also show your system's select() declaration." 1>&2
97
], [extern int select ($cl_cv_proto_select_arg1, $cl_cv_proto_select_arg2 *, $cl_cv_proto_select_arg2 *, $cl_cv_proto_select_arg2 *, $cl_cv_proto_select_arg5 struct timeval *);])
98
AC_DEFINE_UNQUOTED(SELECT_WIDTH_T,$cl_cv_proto_select_arg1,[type of `width' in select() declaration])
99
AC_DEFINE_UNQUOTED(SELECT_SET_T,$cl_cv_proto_select_arg2,[type of `* readfds', `* writefds', `* exceptfds' in select() declaration])
100
AC_DEFINE_UNQUOTED(SELECT_CONST,$cl_cv_proto_select_arg5,[declaration of select() needs const in the fifth argument])
101
# Now check whether select() works reliably on regular files, i.e. signals
102
# immediate readability and writability, both before EOF and at EOF.
103
AC_CACHE_CHECK([for reliable select()], cl_cv_func_select_reliable, [
105
/* Declare select(). */
110
#include <sys/types.h>
112
#include <sys/socket.h>
114
#include <sys/time.h>
115
#ifdef HAVE_SYS_SELECT_H
116
#include <sys/select.h>
119
#if defined(__STDC__) || defined(__cplusplus)
120
int select (SELECT_WIDTH_T, SELECT_SET_T*, SELECT_SET_T*, SELECT_SET_T*, SELECT_CONST struct timeval *);
124
/* Declare open(). */
126
#ifdef OPEN_NEEDS_SYS_FILE_H
127
#include <sys/file.h>
130
{ int fd = open("conftest.c",O_RDWR,0644);
131
int correct_readability_nonempty, correct_readability_empty;
132
int correct_writability_nonempty, correct_writability_empty;
134
struct timeval zero_time;
136
FD_ZERO(&handle_set); FD_SET(fd,&handle_set);
137
zero_time.tv_sec = 0; zero_time.tv_usec = 0;
138
correct_readability_nonempty =
139
(select(FD_SETSIZE,&handle_set,NULL,NULL,&zero_time) == 1);
142
FD_ZERO(&handle_set); FD_SET(fd,&handle_set);
143
zero_time.tv_sec = 0; zero_time.tv_usec = 0;
144
correct_writability_nonempty =
145
(select(FD_SETSIZE,NULL,&handle_set,NULL,&zero_time) == 1);
147
lseek(fd,0,SEEK_END);
149
FD_ZERO(&handle_set); FD_SET(fd,&handle_set);
150
zero_time.tv_sec = 0; zero_time.tv_usec = 0;
151
correct_readability_empty =
152
(select(FD_SETSIZE,&handle_set,NULL,NULL,&zero_time) == 1);
155
FD_ZERO(&handle_set); FD_SET(fd,&handle_set);
156
zero_time.tv_sec = 0; zero_time.tv_usec = 0;
157
correct_writability_empty =
158
(select(FD_SETSIZE,NULL,&handle_set,NULL,&zero_time) == 1);
160
exit(!(correct_readability_nonempty && correct_readability_empty
161
&& correct_writability_nonempty && correct_writability_empty));
163
cl_cv_func_select_reliable=yes, cl_cv_func_select_reliable=no,
164
dnl When cross-compiling, don't assume anything.
165
cl_cv_func_select_reliable="guessing no")
167
case "$cl_cv_func_select_reliable" in
168
*yes) AC_DEFINE(HAVE_RELIABLE_SELECT,,[have select() and it works reliably on files]) ;;