~ubuntu-branches/debian/squeeze/ffcall/squeeze

« back to all changes in this revision

Viewing changes to src/m4/select.m4

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2010-06-26 15:29:30 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100626152930-c09y01gk3szcnykn
Tags: 1.10+cvs20100619-2
Ship to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
dnl -*- Autoconf -*-
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.
8
 
 
9
 
dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
10
 
 
11
 
AC_PREREQ(2.57)
12
 
 
13
 
AC_DEFUN([RL_SELECT],
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>
17
 
]AC_LANG_EXTERN[
18
 
#ifdef __cplusplus
19
 
int select(int, fd_set*, fd_set*, fd_set*, struct timeval *);
20
 
#else
21
 
int select();
22
 
#endif
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,
28
 
[#ifdef __BEOS__
29
 
#include <sys/socket.h>
30
 
#endif
31
 
#include <sys/time.h>
32
 
#include <sys/select.h>], ,
33
 
AC_DEFINE(HAVE_SYS_SELECT_H,,[have <sys/select.h>?]))dnl
34
 
fi
35
 
])
36
 
 
37
 
AC_DEFUN([CL_SELECT],
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, [
41
 
AC_TRY_LINK([
42
 
#ifdef __BEOS__
43
 
#include <sys/socket.h>
44
 
#endif
45
 
#include <sys/time.h>
46
 
]AC_LANG_EXTERN[
47
 
#ifdef __cplusplus
48
 
int select(int, fd_set*, fd_set*, fd_set*, struct timeval *);
49
 
#else
50
 
int select();
51
 
#endif
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,
57
 
[#ifdef __BEOS__
58
 
#include <sys/socket.h>
59
 
#endif
60
 
#include <sys/time.h>
61
 
#include <sys/select.h>], ,
62
 
AC_DEFINE(HAVE_SYS_SELECT_H,,[have <sys/select.h>?]))dnl
63
 
CL_PROTO([select], [
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
68
 
CL_PROTO_TRY([
69
 
#include <stdlib.h>
70
 
#ifdef HAVE_UNISTD_H
71
 
#include <unistd.h>
72
 
#endif
73
 
#include <sys/types.h>
74
 
#ifdef __BEOS__
75
 
#include <sys/socket.h>
76
 
#endif
77
 
#include <sys/time.h>
78
 
#ifdef HAVE_SYS_SELECT_H
79
 
#include <sys/select.h>
80
 
#endif
81
 
], [int select ($x width, $y * readfds, $y * writefds, $y * exceptfds, $z struct timeval * timeout);],
82
 
[int select();], [
83
 
cl_cv_proto_select_arg1="$x"
84
 
cl_cv_proto_select_arg2="$y"
85
 
cl_cv_proto_select_arg5="$z"
86
 
have_select=1])
87
 
fi
88
 
done
89
 
done
90
 
done
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
95
 
  exit 1
96
 
fi
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, [
104
 
AC_TRY_RUN([
105
 
/* Declare select(). */
106
 
#include <stdlib.h>
107
 
#ifdef HAVE_UNISTD_H
108
 
#include <unistd.h>
109
 
#endif
110
 
#include <sys/types.h>
111
 
#ifdef __BEOS__
112
 
#include <sys/socket.h>
113
 
#endif
114
 
#include <sys/time.h>
115
 
#ifdef HAVE_SYS_SELECT_H
116
 
#include <sys/select.h>
117
 
#endif
118
 
]AC_LANG_EXTERN[
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 *);
121
 
#else
122
 
int select();
123
 
#endif
124
 
/* Declare open(). */
125
 
#include <fcntl.h>
126
 
#ifdef OPEN_NEEDS_SYS_FILE_H
127
 
#include <sys/file.h>
128
 
#endif
129
 
int main ()
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;
133
 
  fd_set handle_set;
134
 
  struct timeval zero_time;
135
 
  {
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);
140
 
  }
141
 
  {
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);
146
 
  }
147
 
  lseek(fd,0,SEEK_END);
148
 
  {
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);
153
 
  }
154
 
  {
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);
159
 
  }
160
 
  exit(!(correct_readability_nonempty && correct_readability_empty
161
 
         && correct_writability_nonempty && correct_writability_empty));
162
 
}],
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")
166
 
])
167
 
case "$cl_cv_func_select_reliable" in
168
 
  *yes) AC_DEFINE(HAVE_RELIABLE_SELECT,,[have select() and it works reliably on files]) ;;
169
 
  *no) ;;
170
 
esac
171
 
fi
172
 
])