1 # m4/ax_func_which_gethostbyname_r.m4
3 # Copyright © 2005 Caolan McNamara <caolan@skynet.ie>
4 # Copyright © 2005 Daniel Richard G. <skunk@iskunk.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # As a special exception, the respective Autoconf Macro's copyright
22 # owner gives unlimited permission to copy, distribute and modify the
23 # configure scripts that are the output of Autoconf when processing
24 # the Macro. You need not follow the terms of the GNU General Public
25 # License when using or distributing such scripts, even though
26 # portions of the text of the Macro appear in them. The GNU General
27 # Public License (GPL) does govern all other use of the material that
28 # constitutes the Autoconf Macro.
30 # This special exception to the GPL applies to versions of the
31 # Autoconf Macro released by the Autoconf Macro Archive. When you make
32 # and distribute a modified version of the Autoconf Macro, you may
33 # extend this special exception to the GPL to apply to your modified
37 AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
40 AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
42 AC_CACHE_VAL(ac_cv_func_which_gethostbyname_r, [
44 ################################################################
46 ac_cv_func_which_gethostbyname_r=unknown
49 # ONE ARGUMENT (sanity check)
52 # This should fail, as there is no variant of gethostbyname_r() that takes
53 # a single argument. If it actually compiles, then we can assume that
54 # netdb.h is not declaring the function, and the compiler is thereby
55 # assuming an implicit prototype. In which case, we're out of luck.
59 [[#include <netdb.h>]],
61 char *name = "www.gnu.org";
62 (void)gethostbyname_r(name) /* ; */
64 ac_cv_func_which_gethostbyname_r=no)
71 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
75 [[#include <netdb.h>]],
77 char *name = "www.gnu.org";
78 struct hostent ret, *retp;
82 (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
84 ac_cv_func_which_gethostbyname_r=six)
93 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
97 [[#include <netdb.h>]],
99 char *name = "www.gnu.org";
101 char buf@<:@1024@:>@;
104 (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
106 ac_cv_func_which_gethostbyname_r=five)
112 # (e.g. AIX, HP-UX, Tru64)
115 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
119 [[#include <netdb.h>]],
121 char *name = "www.gnu.org";
123 struct hostent_data data;
124 (void)gethostbyname_r(name, &ret, &data) /* ; */
126 ac_cv_func_which_gethostbyname_r=three)
130 ################################################################
132 ]) dnl end AC_CACHE_VAL
134 case "$ac_cv_func_which_gethostbyname_r" in
136 AC_MSG_RESULT([three])
137 AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_3], 1, [three-argument gethostbyname_r])
141 AC_MSG_RESULT([five])
142 AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_5], 1, [five-argument gethostbyname_r])
147 AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_6], 1, [six-argument gethostbyname_r])
151 AC_MSG_RESULT([cannot find function declaration in netdb.h])
155 AC_MSG_RESULT([can't tell])
159 AC_MSG_ERROR([internal error])