1
# -- acinclude start --
3
AC_DEFUN(L_UNCON_SELECT,
4
[AC_MSG_CHECKING(for correct select behaviour on unconnected sockets)
7
* ftp.inet.no:/pub/home/michaels/stuff/unconnectedsocket-select.c
8
* $ cc unconnectedsocket-select.c && uname -a && ./a.out
9
* Modified by Eric Anderson <anderse@hpl.hp.com>
12
#include <sys/types.h>
14
#include <sys/socket.h>
15
#include <netinet/in.h>
16
#include <arpa/inet.h>
36
act.sa_handler = SIG_IGN;
37
sigaction(SIGPIPE,&act,NULL);
38
fprintf(stderr, "testing with a normal, unconnected socket:\n");
39
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
43
fprintf(stderr, " created socket, select() returned %d\n",
46
fprintf(stderr, " read() returned %d, errno = %d (%s)\n", p, errno, (strerror(errno)));
48
fprintf(stderr, " write() returned %d, errno = %d (%s)\n", p, errno, (strerror(errno)));
50
fprintf(stderr, "testing with a non-blocking, unconnected socket:\n");
51
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
55
if ((p = fcntl(s, F_GETFL, 0)) == -1
56
|| fcntl(s, F_SETFL, p | O_NONBLOCK) == -1) {
61
fprintf(stderr, " socket nonblocking, select() returned %d\n", res);
64
fprintf(stderr, " read() returned %d, errno = %d (%s)\n", p, errno, (strerror(errno)));
65
p = write(s, &foo, 5);
66
fprintf(stderr, " write() returned %d, errno = %d (%s)\n", p, errno, (strerror(errno)));
69
return 0; /* correct behaviour */
71
return 1; /* incorrect behaviour */
78
fd_set rset, wset, xset;
79
struct timeval timeout;
90
ret = select(s + 1, &rset, &wset, &xset, &timeout);
91
if (FD_ISSET(s,&rset)) {
92
fprintf(stderr, " socket is readable\n");
94
if (FD_ISSET(s,&wset)) {
95
fprintf(stderr, " socket is writeable\n");
97
if (FD_ISSET(s,&xset)) {
98
fprintf(stderr, " socket has an exception\n");
101
}], [AC_MSG_RESULT(yes)
106
#can it really be this simple?
107
#nope, doesn't handle coff files which also have no underscore
108
AC_DEFUN(L_SYMBOL_UNDERSCORE,
109
[AC_MSG_CHECKING(for object file type)
111
/* look for ELF identification header at the start of argv[0] */
118
* ELF header, from ELF standard (Portable Formats Specification,
121
char elfheader[] = { 0x7f, 'E', 'L', 'F' };
129
int len = sizeof(elfheader);
132
if ((fd = open(argv[0], O_RDONLY, 0)) == -1) {
136
if (read(fd, header, len) != len) {
140
if (memcmp(header, elfheader, len) == 0)
141
exit(0); /* pointy ears */
145
], [AC_MSG_RESULT(elf)
146
AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)],
148
#XXX exceptions for coff platforms, should be detected automatically
151
AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
154
*-*-hpux*) #XXX apparently does not use underscore
155
AC_DEFINE(HAVE_NO_SYMBOL_UNDERSCORE)
156
AC_MSG_RESULT(a.out?)
174
cat ${_param} | egrep "^${val}" > /dev/null
175
test $? -eq 0 && _nofunc="" && break
178
if test "x${_nofunc}" = xt; then
179
if test "x[$$6]" != x; then
182
[$6]="[$$6] ${_func} (${_arg}): (`cat ${_param}`)"
184
AC_DEFINE_UNQUOTED(HAVE_PROT_${_ucfunc}_${_arg}, ${val})
189
dnl #attempt to speed up runtime by avoiding subshells
190
AC_DEFUN(L_SOCKPROTO,
192
dnl this function is not very generic, and only supports nine arguments
193
syscmd(if test $# -gt 9; then exit 1;fi) dnl
194
ifelse(sysval, 0, , [errprint(__file__:__line__: error in acinclude.m4: too many arguments to function [$0]
199
paramcnt=decr(decr([$#]))
202
dnl func=translit([$1], ` ')
203
dnl ucfunc=translit(translit([$1], ` '), `a-z', `A-Z')
205
syscmd(echo '$1' | grep "\." > /dev/null)dnl
206
func=ifelse(sysval, 0, [esyscmd(echo '$1' | cut -d. -f1)dnl], translit([$1], ` '))
207
syscmd(echo '$1' | grep "\." > /dev/null)dnl
208
dnl ucfunc=ifelse(sysval, 0, esyscmd(echo '$1' | cut -d. -f2), translit(translit([$1], ` '), `a-z', `A-Z'))
209
ucfunc=translit(ifelse(sysval, 0, esyscmd(echo '$1' | cut -d. -f2), translit([$1], ` ')), `a-z', `A-Z')
211
dnl func=translit([$SYS_NAME], ` ')
212
dnl ucfunc=translit(translit([$REAL_NAME], ` '), `a-z', `A-Z')
214
AC_MSG_CHECKING([prototypes for $func])
218
cat > conftest.$ac_ext <<EOF
219
#include "confdefs.h"
220
#include <sys/types.h>
221
#include <sys/socket.h>
227
changequote(<<, >>)dnl
228
${CPP} ${CPPFLAGS} ${CPPFLAG_STDC} conftest.$ac_ext | $AWK "{ if (/[^a-z0-9_]${func}[^a-z0-9_]/) { s=10 }; if ( s > 0 ) { s -= 1; print; } }" | egrep -v '^#' | tr '\n' ' ' | tr -s '/' | tr ';' '\n' | grep -v "__${func}" | egrep "[^a-z0-9_]${func}[^a-z0-9_]" | tr -s '[:blank:]' | sed -e 's/extern//' > conftest.out_proto
231
while test $cnt -lt $paramcnt; do
232
if test $cnt -eq 0; then
233
cat conftest.out_proto | sed -e "s/${func}.*//" | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//g' > conftest.out_param
235
cat conftest.out_proto | sed -e "s/.*${func}//" | sed -e "s/[\(\)]//g" | cut -d, -f $cnt | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//g' > conftest.out_param
237
dnl XXXstrip whatever's behind any *?
239
cat conftest.out_param | tr -s '[:blank:]' > conftest.out_nospace
240
if test -s conftest.out_nospace; then
241
cp -f conftest.out_param conftest.out_param_${cnt}
244
echo "not found" > conftest.out_param_${cnt}
245
echo "warning: found no argument"
269
testparam([$3], 0, conftest.out_param_0, $func, $ucfunc, failure)dnl
274
testparam([$4], 1, conftest.out_param_1, $func, $ucfunc, failure)dnl
279
testparam([$5], 2, conftest.out_param_2, $func, $ucfunc, failure)dnl
284
testparam([$6], 3, conftest.out_param_3, $func, $ucfunc, failure)dnl
289
testparam([$7], 4, conftest.out_param_4, $func, $ucfunc, failure)dnl
294
testparam([$8], 5, conftest.out_param_5, $func, $ucfunc, failure)dnl
299
testparam([$9], 6, conftest.out_param_6, $func, $ucfunc, failure)dnl
304
testparam([$10], 7, conftest.out_param_7, $func, $ucfunc, failure)dnl
308
if test "x$failure" != x; then
309
AC_MSG_RESULT(failure)
311
echo "$failure" | tr '|' '\n'
322
# -- acinclude end --
b'\\ No newline at end of file'