Between Solaris, HP-UX, AIX, Tru64 UNIX, and IRIX, there are three
possibilities for the number of arguments to gethostbyname_r: 3, 5, 6.

I think the test to determine the number of arguments in
apr_network.m4 is inadequate. The ones used by the cURL program
(http://curl.haxx.se) seem far more robust in that it uses AC_TRY_RUN
to determine the correct number of arguments rather than a modified
AC_TRY_COMPILE.

I'll try and have a patch over the weekend. The autoconf test used by
curl is attached (curl is dual licensed under the MPL and a
MIT/X-derivate so it's ok to steal).

-- 
albert chin ([EMAIL PROTECTED])

-- snip snip
AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
[
  dnl check for number of arguments to gethostbyname_r. it might take
  dnl either 3, 5, or 6 arguments.
  AC_CHECK_FUNCS(gethostbyname_r,[
    AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
    AC_TRY_RUN([
#include <string.h>
#include <sys/types.h>
#include <netdb.h>

int
main () {
struct hostent h;
struct hostent_data hdata;
char *name = "localhost";
int rc;
memset(&h, 0, sizeof(struct hostent));
memset(&hdata, 0, sizeof(struct hostent_data));
rc = gethostbyname_r(name, &h, &hdata);
exit (rc != 0 ? 1 : 0); }],[
      AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
      ac_cv_gethostbyname_args=3],[
      AC_MSG_RESULT(no)
      AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3
arguments)
      AC_TRY_RUN([
#define _REENTRANT

#include <string.h>
#include <sys/types.h>
#include <netdb.h>

int
main () {
struct hostent h;
struct hostent_data hdata;
char *name = "localhost";
int rc;
memset(&h, 0, sizeof(struct hostent));
memset(&hdata, 0, sizeof(struct hostent_data));
rc = gethostbyname_r(name, &h, &hdata);
exit (rc != 0 ? 1 : 0); }],[
        AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
        AC_DEFINE(NEED_REENTRANT)
        ac_cv_gethostbyname_args=3],[
        AC_MSG_RESULT(no)
        AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
        AC_TRY_RUN([
#include <sys/types.h>
#include <netdb.h>

int
main () {
struct hostent *hp;
struct hostent h;
char *name = "localhost";
char buffer[8192];
int h_errno;
hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
exit (hp == NULL ? 1 : 0); }],[
          AC_MSG_RESULT(yes)
          AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
          ac_cv_gethostbyname_args=5],[
          AC_MSG_RESULT(no)
          AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
          AC_TRY_RUN([
#include <sys/types.h>
#include <netdb.h>

int
main () {
struct hostent h;
struct hostent *hp;
char *name = "localhost";
char buf[8192];
int rc;
int h_errno;
rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
exit (rc != 0 ? 1 : 0); }],[
            AC_MSG_RESULT(yes)
            AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
            ac_cv_gethostbyname_args=6],[
            AC_MSG_RESULT(no)
            have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
            [ac_cv_gethostbyname_args=0])],
          [ac_cv_gethostbyname_args=0])],
        [ac_cv_gethostbyname_args=0])],
      [ac_cv_gethostbyname_args=0])])

Reply via email to