2 # This comes from the official Autoconf macro archive at
3 # <http://research.cys.de/autoconf-archive/>
4 # (I removed the $ before the Id CVS keyword below.)
7 dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
9 dnl Checks the data types of the three arguments to accept(). Results are
10 dnl placed into the symbols ACCEPT_TYPE_RETURN and ACCEPT_TYPE_ARG[123],
11 dnl consistent with the following example:
13 dnl #define ACCEPT_TYPE_RETURN int
14 dnl #define ACCEPT_TYPE_ARG1 int
15 dnl #define ACCEPT_TYPE_ARG2 struct sockaddr *
16 dnl #define ACCEPT_TYPE_ARG3 socklen_t
18 dnl This macro requires AC_CHECK_HEADERS to have already verified the
19 dnl presence or absence of sys/types.h and sys/socket.h.
21 dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
22 dnl macro. Credit for that one goes to David MacKenzie et. al.
24 dnl @version Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
25 dnl @author Daniel Richard G. <skunk@mit.edu>
28 # PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
29 # is a pointer type. That's kind of useless because then you can't
30 # use the macro to define a corresponding variable. We also make the
31 # reasonable(?) assumption that you can use arg3 for getsocktype etc.
32 # as well (i.e., anywhere POSIX.2 has socklen_t).
34 # arg2 can also be `const' (e.g., RH 4.2). Change the order of tests
35 # for arg3 so that `int' is first, in case there is no prototype at all.
37 # Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t'
38 # which is *not* 'socklen_t *'). If we detect that, then we assume
39 # 'int' as the result, because that ought to work best.
41 # On Win32, accept() returns 'unsigned int PASCAL'
43 AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
44 [AC_MSG_CHECKING([types of arguments for accept()])
45 AC_CACHE_VAL(ac_cv_func_accept_return,dnl
46 [AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
47 [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
48 [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
49 [for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do
50 for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
51 for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
52 for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
54 [#ifdef HAVE_SYS_TYPES_H
55 #include <sys/types.h>
57 #ifdef HAVE_SYS_SOCKET_H
58 #include <sys/socket.h>
60 extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
61 [], [ac_not_found=no; break 4], [ac_not_found=yes])
66 if test "$ac_not_found" = yes; then
67 AC_MSG_ERROR([could not determine argument types])
69 if test "$ac_cv_func_accept_arg3" = "void"; then
70 ac_cv_func_accept_arg3=int
76 AC_MSG_RESULT([$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
77 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_RETURN, $ac_cv_func_accept_return,
78 [Define to the return type of 'accept'])
79 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1, $ac_cv_func_accept_arg1,
80 [Define to the type of arg 1 of 'accept'])
81 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2, $ac_cv_func_accept_arg2,
82 [Define to the type of arg 2 of 'accept'])
83 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3, $ac_cv_func_accept_arg3,
84 [Define to the type of arg 3 of 'accept'])