OSDN Git Service

Add sys/types include for sockaddr test to configure
[pg-rex/syncrep.git] / config / ac_func_accept_argtypes.m4
1 # $Header: /cvsroot/pgsql/config/ac_func_accept_argtypes.m4,v 1.2 2000/08/26 21:11:45 petere Exp $
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.)
5
6
7 dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
8 dnl
9 dnl Checks the data types of the three arguments to accept(). Results are
10 dnl placed into the symbols ACCEPT_TYPE_ARG[123], consistent with the
11 dnl following example:
12 dnl
13 dnl       #define ACCEPT_TYPE_ARG1 int
14 dnl       #define ACCEPT_TYPE_ARG2 struct sockaddr *
15 dnl       #define ACCEPT_TYPE_ARG3 socklen_t
16 dnl
17 dnl This macro requires AC_CHECK_HEADERS to have already verified the
18 dnl presence or absence of sys/types.h and sys/socket.h.
19 dnl
20 dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
21 dnl macro. Credit for that one goes to David MacKenzie et. al.
22 dnl
23 dnl @version Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
24 dnl @author Daniel Richard G. <skunk@mit.edu>
25 dnl
26
27 # PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
28 # is a pointer type. That's kind of useless because then you can't
29 # use the macro to define a corresponding variable. We also make the
30 # reasonable(?) assumption that you can use arg3 for getsocktype etc.
31 # as well (i.e., anywhere POSIX.2 has socklen_t).
32 #
33 # arg2 can also be `const' (e.g., RH 4.2). Change the order of tests
34 # for arg3 so that `int' is first, in case there is no prototype at all.
35
36 AC_DEFUN(AC_FUNC_ACCEPT_ARGTYPES,
37 [AC_MSG_CHECKING([types of arguments for accept()])
38  AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
39  [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
40   [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
41    [for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
42      for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
43       for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int'; do
44        AC_TRY_COMPILE(
45 [#ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
47 #endif
48 #ifdef HAVE_SYS_SOCKET_H
49 #include <sys/socket.h>
50 #endif
51 extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
52         [], [ac_not_found=no; break 3], [ac_not_found=yes])
53       done
54      done
55     done
56     if test "$ac_not_found" = yes; then
57       AC_MSG_ERROR([could not determine argument types])
58     fi
59    ])dnl AC_CACHE_VAL
60   ])dnl AC_CACHE_VAL
61  ])dnl AC_CACHE_VAL
62  AC_MSG_RESULT([$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
63  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1,$ac_cv_func_accept_arg1)
64  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2,$ac_cv_func_accept_arg2)
65  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3,$ac_cv_func_accept_arg3)
66 ])