Skip to content

Commit beac708

Browse files
committed
Update ax_prototype.m4 and introduce ax_prototype_accept.m4
This also moves the accept() checking to libmongoc/FindDependencies.m4, since it is specific to libmongoc.
1 parent 550a33d commit beac708

File tree

5 files changed

+102
-34
lines changed

5 files changed

+102
-34
lines changed

config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ if test "$PHP_MONGODB" != "no"; then
347347
dnl Avoid using AC_CONFIG_MACRO_DIR, which might conflict with PHP
348348
_include([scripts/autotools/m4/ax_check_compile_flag.m4])
349349
_include([scripts/autotools/m4/ax_prototype.m4])
350+
_include([scripts/autotools/m4/ax_prototype_accept.m4])
350351
_include([scripts/autotools/m4/ax_pthread.m4])
351352
_include([scripts/autotools/m4/php_mongodb.m4])
352353
_include([scripts/autotools/m4/pkg.m4])

scripts/autotools/CheckCompiler.m4

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
6262
#endif
6363
])], [c_compiler="sun"], [])
6464

65-
# The type of parameters for accept, getpeername, getsockname, getsockopt
66-
# all vary the same way by platform.
67-
AX_PROTOTYPE(accept, [
68-
#include <sys/types.h>
69-
#include <sys/socket.h>
70-
], [
71-
int a = 0;
72-
ARG2 *b = 0;
73-
ARG3 *c = 0;
74-
accept (a, b, c);],
75-
ARG2, [struct sockaddr, void],
76-
ARG3, [socklen_t, size_t, int])
77-
78-
MONGOC_SOCKET_ARG2="$ACCEPT_ARG2"
79-
AC_SUBST(MONGOC_SOCKET_ARG2)
80-
MONGOC_SOCKET_ARG3="$ACCEPT_ARG3"
81-
AC_SUBST(MONGOC_SOCKET_ARG3)
82-
8365
AC_LANG_POP([C])
8466

8567
if test "$c_compiler" = "unknown"; then

scripts/autotools/libmongoc/FindDependencies.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
2121
[AC_SUBST(MONGOC_HAVE_SS_FAMILY, 0)],
2222
[#include <sys/socket.h>])
2323

24+
AC_DEFINE([ACCEPT_ARG2], [], [Description])
25+
AC_DEFINE([ACCEPT_ARG3], [], [Description])
26+
AX_PROTOTYPE_ACCEPT
27+
AC_SUBST(MONGOC_SOCKET_ARG2, "$ACCEPT_ARG2")
28+
AC_SUBST(MONGOC_SOCKET_ARG3, "$ACCEPT_ARG3")
29+
2430
# Check for pthreads. libmongoc's original FindDependencies.m4 script did not
2531
# require pthreads, but it does appear to be necessary on non-Windows platforms
2632
# based on mongoc-openssl.c and mongoc-thread-private.h.

scripts/autotools/m4/ax_prototype.m4

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# values found in <values1>, <values2>, ... respectively. <values1>,
1414
# <values2>, ... contain a list of possible values for each corresponding
1515
# tag and all combinations are tested. When AC_TRY_COMPILE(include, code)
16-
# is successfull for a given substitution, the macro stops and defines the
16+
# is successful for a given substitution, the macro stops and defines the
1717
# following macros: FUNCTION_TAG1, FUNCTION_TAG2, ... using AC_DEFINE()
1818
# with values set to the current values of <TAG1>, <TAG2>, ... If no
19-
# combination is successfull the configure script is aborted with a
19+
# combination is successful the configure script is aborted with a
2020
# message.
2121
#
2222
# Intended purpose is to find which combination of argument types is
@@ -26,13 +26,13 @@
2626
#
2727
# Generic usage pattern:
2828
#
29-
# 1) add a call in configure.in
29+
# 1) add a call in configure.ac
3030
#
3131
# AX_PROTOTYPE(...)
3232
#
3333
# 2) call autoheader to see which symbols are not covered
3434
#
35-
# 3) add the lines in acconfig.h
35+
# 3) add the lines in config.h
3636
#
3737
# /* Type of Nth argument of function */
3838
# #undef FUNCTION_ARGN
@@ -41,7 +41,7 @@
4141
#
4242
# Complete example:
4343
#
44-
# 1) configure.in
44+
# 1) configure.ac
4545
#
4646
# AX_PROTOTYPE(getpeername,
4747
# [
@@ -59,10 +59,10 @@
5959
#
6060
# 2) call autoheader
6161
#
62-
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./acconfig.h
63-
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./acconfig.h
62+
# autoheader: Symbol `GETPEERNAME_ARG2' is not covered by ./config.h
63+
# autoheader: Symbol `GETPEERNAME_ARG3' is not covered by ./config.h
6464
#
65-
# 3) acconfig.h
65+
# 3) config.h
6666
#
6767
# /* Type of second argument of getpeername */
6868
# #undef GETPEERNAME_ARG2
@@ -114,7 +114,7 @@
114114
# modified version of the Autoconf Macro, you may extend this special
115115
# exception to the GPL to apply to your modified version as well.
116116

117-
#serial 6
117+
#serial 11
118118

119119
AU_ALIAS([AC_PROTOTYPE], [AX_PROTOTYPE])
120120
AC_DEFUN([AX_PROTOTYPE],[
@@ -148,7 +148,7 @@ AC_DEFUN([AX_PROTOTYPE_REVERSE],[ifelse($#,0,,$#,1,[[$1]],[AX_PROTOTYPE_REVERSE(
148148
dnl
149149
dnl AX_PROTOTYPE_SUBST(string, tag)
150150
dnl
151-
dnl Substitute all occurence of <tag> in <string> with <tag>_VAL.
151+
dnl Substitute all occurrence of <tag> in <string> with <tag>_VAL.
152152
dnl Assumes that tag_VAL is a macro containing the value associated to tag.
153153
dnl
154154
AC_DEFUN([AX_PROTOTYPE_SUBST],[ifelse($2,,[$1],[AX_PROTOTYPE_SUBST(patsubst([$1],[$2],[$2[]_VAL]),builtin([shift],builtin([shift],$@)))])])
@@ -168,9 +168,9 @@ dnl Assumes that function is a macro containing the name of the function in uppe
168168
dnl and that tag_VAL is a macro containing the value associated to tag.
169169
dnl
170170
AC_DEFUN([AX_PROTOTYPE_DEFINES],[ifelse($1,,[],
171-
[AC_DEFINE(function[]_$1, $1_VAL, [ ])
172-
AC_SUBST(function[]_$1, "$1_VAL")
173-
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])
171+
[AC_DEFINE(function[]_$1, $1_VAL)
172+
AC_SUBST(function[]_$1, "$1_VAL")
173+
AX_PROTOTYPE_DEFINES(builtin([shift],$@))])])
174174

175175
dnl
176176
dnl AX_PROTOTYPE_STATUS(tags)
@@ -217,13 +217,23 @@ dnl
217217
dnl Activate fatal warnings if possible, gives better guess
218218
dnl
219219
ac_save_CPPFLAGS="$CPPFLAGS"
220-
if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi
221-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[$1]])],[
220+
dnl ifelse(AC_LANG,CPLUSPLUS,if test "$GXX" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
221+
dnl ifelse(AC_LANG,C,if test "$GCC" = "yes" ; then CPPFLAGS="$CPPFLAGS -Werror" ; fi)
222+
dnl
223+
dnl Disable the 'unused-variable' warning in case e.g. -Wall was enabled,
224+
dnl otherwise the test may always fail.
225+
dnl
226+
if (test "x$GCC" = "xyes" || test "x$GXX" = "xyes" ); then
227+
CPPFLAGS="$CPPFLAGS -Werror -Wno-unused-variable" ;
228+
fi
229+
230+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$1])],
231+
[
222232
CPPFLAGS="$ac_save_CPPFLAGS"
223233
AC_MSG_RESULT(ok)
224234
AX_PROTOTYPE_DEFINES(tags)
225235
break;
226-
],[
236+
], [
227237
CPPFLAGS="$ac_save_CPPFLAGS"
228238
AC_MSG_RESULT(not ok)
229239
])
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_prototype_accept.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_PROTOTYPE_ACCEPT
8+
#
9+
# DESCRIPTION
10+
#
11+
# Requires the AX_PROTOTYPE macro. FIXME: Put this in the code!
12+
#
13+
# Find the type of argument two and three of accept. User must include the
14+
# following in acconfig.h:
15+
#
16+
# /* Type of second argument of accept */
17+
# #undef ACCEPT_ARG2
18+
#
19+
# /* Type of third argument of accept */
20+
# #undef ACCEPT_ARG3
21+
#
22+
# LICENSE
23+
#
24+
# Copyright (c) 2008 Loic Dachary <[email protected]>
25+
#
26+
# This program is free software; you can redistribute it and/or modify it
27+
# under the terms of the GNU General Public License as published by the
28+
# Free Software Foundation; either version 2 of the License, or (at your
29+
# option) any later version.
30+
#
31+
# This program is distributed in the hope that it will be useful, but
32+
# WITHOUT ANY WARRANTY; without even the implied warranty of
33+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34+
# Public License for more details.
35+
#
36+
# You should have received a copy of the GNU General Public License along
37+
# with this program. If not, see <https://www.gnu.org/licenses/>.
38+
#
39+
# As a special exception, the respective Autoconf Macro's copyright owner
40+
# gives unlimited permission to copy, distribute and modify the configure
41+
# scripts that are the output of Autoconf when processing the Macro. You
42+
# need not follow the terms of the GNU General Public License when using
43+
# or distributing such scripts, even though portions of the text of the
44+
# Macro appear in them. The GNU General Public License (GPL) does govern
45+
# all other use of the material that constitutes the Autoconf Macro.
46+
#
47+
# This special exception to the GPL applies to versions of the Autoconf
48+
# Macro released by the Autoconf Archive. When you make and distribute a
49+
# modified version of the Autoconf Macro, you may extend this special
50+
# exception to the GPL to apply to your modified version as well.
51+
52+
#serial 6
53+
54+
AU_ALIAS([AC_PROTOTYPE_ACCEPT], [AX_PROTOTYPE_ACCEPT])
55+
AC_DEFUN([AX_PROTOTYPE_ACCEPT],[
56+
AX_PROTOTYPE(accept,
57+
[
58+
#include <sys/types.h>
59+
#include <sys/socket.h>
60+
],
61+
[
62+
int a = 0;
63+
ARG2 * b = 0;
64+
ARG3 * c = 0;
65+
accept(a, b, c);
66+
],
67+
ARG2, [struct sockaddr, void],
68+
ARG3, [socklen_t, size_t, int, unsigned int, long unsigned int])
69+
])

0 commit comments

Comments
 (0)