OSDN Git Service

Minor editing for README-SSI.
[pg-rex/syncrep.git] / config / ac_func_accept_argtypes.m4
1 # config/ac_func_accept_argtypes.m4
2 # This comes from the official Autoconf macro archive at
3 # <http://research.cys.de/autoconf-archive/>
4
5
6 dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
7 dnl
8 dnl Checks the data types of the three arguments to accept(). Results are
9 dnl placed into the symbols ACCEPT_TYPE_RETURN and ACCEPT_TYPE_ARG[123],
10 dnl consistent with the following example:
11 dnl
12 dnl       #define ACCEPT_TYPE_RETURN int
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 # Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t'
37 # which is *not* 'socklen_t *').  If we detect that, then we assume
38 # 'int' as the result, because that ought to work best.
39 #
40 # On Win32, accept() returns 'unsigned int PASCAL'
41 # Win64 uses SOCKET for return and arg1
42
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' 'SOCKET'; do
50       for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; 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
53          AC_TRY_COMPILE(
54 [#ifdef HAVE_SYS_TYPES_H
55 #include <sys/types.h>
56 #endif
57 #ifdef HAVE_SYS_SOCKET_H
58 #include <sys/socket.h>
59 #endif
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])
62        done
63       done
64      done
65     done
66     if test "$ac_not_found" = yes; then
67       AC_MSG_ERROR([could not determine argument types])
68     fi
69     if test "$ac_cv_func_accept_arg3" = "void"; then
70       ac_cv_func_accept_arg3=int
71     fi
72     ])dnl AC_CACHE_VAL
73    ])dnl AC_CACHE_VAL
74   ])dnl AC_CACHE_VAL
75  ])dnl AC_CACHE_VAL
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'])
85 ])