1 dnl @synopsis AX_FUNC_WHICH_GETHOSTBYNAME_R
3 dnl Determines which historical variant of the gethostbyname_r() call
4 dnl (taking three, five, or six arguments) is available on the system
5 dnl and defines one of the following macros accordingly:
7 dnl HAVE_FUNC_GETHOSTBYNAME_R_6
8 dnl HAVE_FUNC_GETHOSTBYNAME_R_5
9 dnl HAVE_FUNC_GETHOSTBYNAME_R_3
11 dnl If used in conjunction with gethostname.c, the API demonstrated in
12 dnl test.c can be used regardless of which gethostbyname_r() is
13 dnl available. These example files can be found at
14 dnl http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
16 dnl based on David Arnold's autoconf suggestion in the threads faq
18 dnl Originally named "AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R". Rewritten
19 dnl for Autoconf 2.5x by Daniel Richard G.
21 dnl @category InstalledPackages
22 dnl @author Caolan McNamara <caolan@skynet.ie>
23 dnl @author Daniel Richard G. <skunk@iskunk.org>
24 dnl @version 2005-01-21
25 dnl @license GPLWithACException
27 AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
30 AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
32 AC_CACHE_VAL(ac_cv_func_which_gethostbyname_r, [
34 ################################################################
36 ac_cv_func_which_gethostbyname_r=unknown
39 # ONE ARGUMENT (sanity check)
42 # This should fail, as there is no variant of gethostbyname_r() that takes
43 # a single argument. If it actually compiles, then we can assume that
44 # netdb.h is not declaring the function, and the compiler is thereby
45 # assuming an implicit prototype. In which case, we're out of luck.
49 [[#include <netdb.h>]],
51 char *name = "www.gnu.org";
52 (void)gethostbyname_r(name) /* ; */
55 ac_cv_func_which_gethostbyname_r=no
63 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
67 [[#include <netdb.h>]],
69 char *name = "www.gnu.org";
70 struct hostent ret, *retp;
74 (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
77 ac_cv_func_which_gethostbyname_r=six
87 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
91 [[#include <netdb.h>]],
93 char *name = "www.gnu.org";
98 (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
101 ac_cv_func_which_gethostbyname_r=five
108 # (e.g. AIX, HP-UX, Tru64)
111 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
115 [[#include <netdb.h>]],
117 char *name = "www.gnu.org";
119 struct hostent_data data;
120 (void)gethostbyname_r(name, &ret, &data) /* ; */
123 ac_cv_func_which_gethostbyname_r=three
128 ################################################################
130 ]) dnl end AC_CACHE_VAL
132 case "$ac_cv_func_which_gethostbyname_r" in
134 AC_MSG_RESULT([three])
135 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
139 AC_MSG_RESULT([five])
140 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
145 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
149 AC_MSG_RESULT([cannot find function declaration in netdb.h])
153 AC_MSG_RESULT([can't tell])
157 AC_MSG_ERROR([internal error])