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) /* ; */
54 ac_cv_func_which_gethostbyname_r=no)
61 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
65 [[#include <netdb.h>]],
67 char *name = "www.gnu.org";
68 struct hostent ret, *retp;
72 (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
74 ac_cv_func_which_gethostbyname_r=six)
83 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
87 [[#include <netdb.h>]],
89 char *name = "www.gnu.org";
94 (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
96 ac_cv_func_which_gethostbyname_r=five)
102 # (e.g. AIX, HP-UX, Tru64)
105 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
109 [[#include <netdb.h>]],
111 char *name = "www.gnu.org";
113 struct hostent_data data;
114 (void)gethostbyname_r(name, &ret, &data) /* ; */
116 ac_cv_func_which_gethostbyname_r=three)
120 ################################################################
122 ]) dnl end AC_CACHE_VAL
124 case "$ac_cv_func_which_gethostbyname_r" in
126 AC_MSG_RESULT([three])
127 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
131 AC_MSG_RESULT([five])
132 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
137 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
141 AC_MSG_RESULT([cannot find function declaration in netdb.h])
145 AC_MSG_RESULT([can't tell])
149 AC_MSG_ERROR([internal error])