ax_func_which_gethostbyname_r.m4 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # m4/ax_func_which_gethostbyname_r.m4
  2. # Copyright © 2005 Caolan McNamara <caolan@skynet.ie>
  3. # Copyright © 2005 Daniel Richard G. <skunk@iskunk.org>
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful, but
  9. # WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. # 02111-1307, USA.
  16. # As a special exception, the respective Autoconf Macro's copyright
  17. # owner gives unlimited permission to copy, distribute and modify the
  18. # configure scripts that are the output of Autoconf when processing
  19. # the Macro. You need not follow the terms of the GNU General Public
  20. # License when using or distributing such scripts, even though
  21. # portions of the text of the Macro appear in them. The GNU General
  22. # Public License (GPL) does govern all other use of the material that
  23. # constitutes the Autoconf Macro.
  24. # This special exception to the GPL applies to versions of the
  25. # Autoconf Macro released by the Autoconf Macro Archive. When you make
  26. # and distribute a modified version of the Autoconf Macro, you may
  27. # extend this special exception to the GPL to apply to your modified
  28. # version as well.
  29. AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
  30. AC_LANG_PUSH(C)
  31. AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
  32. AC_CACHE_VAL(ac_cv_func_which_gethostbyname_r, [
  33. ################################################################
  34. ac_cv_func_which_gethostbyname_r=unknown
  35. #
  36. # ONE ARGUMENT (sanity check)
  37. #
  38. # This should fail, as there is no variant of gethostbyname_r() that takes
  39. # a single argument. If it actually compiles, then we can assume that
  40. # netdb.h is not declaring the function, and the compiler is thereby
  41. # assuming an implicit prototype. In which case, we're out of luck.
  42. #
  43. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  44. AC_LANG_PROGRAM(
  45. [[#include <netdb.h>]],
  46. [[
  47. char *name = "www.gnu.org";
  48. (void)gethostbyname_r(name) /* ; */
  49. ]])])],
  50. ac_cv_func_which_gethostbyname_r=no)
  51. #
  52. # SIX ARGUMENTS
  53. # (e.g. Linux)
  54. #
  55. if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
  56. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  57. AC_LANG_PROGRAM(
  58. [[#include <netdb.h>]],
  59. [[
  60. char *name = "www.gnu.org";
  61. struct hostent ret, *retp;
  62. char buf@<:@1024@:>@;
  63. int buflen = 1024;
  64. int my_h_errno;
  65. (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
  66. ]])])],
  67. ac_cv_func_which_gethostbyname_r=six)
  68. fi
  69. #
  70. # FIVE ARGUMENTS
  71. # (e.g. Solaris)
  72. #
  73. if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
  74. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  75. AC_LANG_PROGRAM(
  76. [[#include <netdb.h>]],
  77. [[
  78. char *name = "www.gnu.org";
  79. struct hostent ret;
  80. char buf@<:@1024@:>@;
  81. int buflen = 1024;
  82. int my_h_errno;
  83. (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
  84. ]])])],
  85. ac_cv_func_which_gethostbyname_r=five)
  86. fi
  87. #
  88. # THREE ARGUMENTS
  89. # (e.g. AIX, HP-UX, Tru64)
  90. #
  91. if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
  92. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  93. AC_LANG_PROGRAM(
  94. [[#include <netdb.h>]],
  95. [[
  96. char *name = "www.gnu.org";
  97. struct hostent ret;
  98. struct hostent_data data;
  99. (void)gethostbyname_r(name, &ret, &data) /* ; */
  100. ]])])],
  101. ac_cv_func_which_gethostbyname_r=three)
  102. fi
  103. ################################################################
  104. ]) dnl end AC_CACHE_VAL
  105. case "$ac_cv_func_which_gethostbyname_r" in
  106. three)
  107. AC_MSG_RESULT([three])
  108. AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_3], 1, [three-argument gethostbyname_r])
  109. ;;
  110. five)
  111. AC_MSG_RESULT([five])
  112. AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_5], 1, [five-argument gethostbyname_r])
  113. ;;
  114. six)
  115. AC_MSG_RESULT([six])
  116. AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_6], 1, [six-argument gethostbyname_r])
  117. ;;
  118. no)
  119. AC_MSG_RESULT([cannot find function declaration in netdb.h])
  120. ;;
  121. unknown)
  122. AC_MSG_RESULT([can't tell])
  123. ;;
  124. *)
  125. AC_MSG_ERROR([internal error])
  126. ;;
  127. esac
  128. AC_LANG_POP(C)
  129. ]) dnl end AC_DEFUN