]> granicus.if.org Git - postgresql/blob - config/ac_func_accept_argtypes.m4
Try to detect runtime unavailability of __builtin_mul_overflow(int64).
[postgresql] / 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 NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
18 dnl macro. Credit for that one goes to David MacKenzie et. al.
19 dnl
20 dnl @version $Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
21 dnl @author Daniel Richard G. <skunk@mit.edu>
22 dnl
23
24 # PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
25 # is a pointer type. That's kind of useless because then you can't
26 # use the macro to define a corresponding variable. We also make the
27 # reasonable(?) assumption that you can use arg3 for getsocktype etc.
28 # as well (i.e., anywhere POSIX.2 has socklen_t).
29 #
30 # arg2 can also be `const' (e.g., RH 4.2). Change the order of tests
31 # for arg3 so that `int' is first, in case there is no prototype at all.
32 #
33 # Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t'
34 # which is *not* 'socklen_t *').  If we detect that, then we assume
35 # 'int' as the result, because that ought to work best.
36 #
37 # On Win32, accept() returns 'unsigned int PASCAL'
38 # Win64 uses SOCKET for return and arg1
39
40 AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
41 [AC_MSG_CHECKING([types of arguments for accept()])
42  AC_CACHE_VAL(ac_cv_func_accept_return,dnl
43  [AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
44   [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
45    [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
46     [for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET WSAAPI'; do
47       for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
48        for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
49         for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
50          AC_COMPILE_IFELSE([AC_LANG_SOURCE(
51 [#include <sys/types.h>
52 #include <sys/socket.h>
53 extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);])],
54          [ac_not_found=no; break 4], [ac_not_found=yes])
55        done
56       done
57      done
58     done
59     if test "$ac_not_found" = yes; then
60       AC_MSG_ERROR([could not determine argument types])
61     fi
62     if test "$ac_cv_func_accept_arg3" = "void"; then
63       ac_cv_func_accept_arg3=int
64     fi
65     ])dnl AC_CACHE_VAL
66    ])dnl AC_CACHE_VAL
67   ])dnl AC_CACHE_VAL
68  ])dnl AC_CACHE_VAL
69  AC_MSG_RESULT([$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
70  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_RETURN, $ac_cv_func_accept_return,
71                     [Define to the return type of 'accept'])
72  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1, $ac_cv_func_accept_arg1,
73                     [Define to the type of arg 1 of 'accept'])
74  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2, $ac_cv_func_accept_arg2,
75                     [Define to the type of arg 2 of 'accept'])
76  AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3, $ac_cv_func_accept_arg3,
77                     [Define to the type of arg 3 of 'accept'])
78 ])