Skip to content
reentrant.m4 29.4 KiB
Newer Older
  fi
])


dnl CHECK_NEED_REENTRANT_FUNCTIONS_R
dnl -------------------------------------------------
dnl Checks if the preprocessor _REENTRANT definition
dnl makes several _r functions compiler visible.
dnl Internal macro for CONFIGURE_REENTRANT.

AC_DEFUN([CHECK_NEED_REENTRANT_FUNCTIONS_R], [
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_STRERROR_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_STRTOK_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_LOCALTIME_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_GMTIME_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_INET_NTOA_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
  fi
  if test "$ac_cv_need_reentrant" = "no"; then
    CHECK_NEED_REENTRANT_GETSERVBYPORT_R
  fi
])

AC_DEFUN([CHECK_NEED_REENTRANT_FUNCTIONS_R_DEBUG], [
    CHECK_NEED_REENTRANT_STRERROR_R
    CHECK_NEED_REENTRANT_STRTOK_R
    CHECK_NEED_REENTRANT_LOCALTIME_R
    CHECK_NEED_REENTRANT_GMTIME_R
    CHECK_NEED_REENTRANT_INET_NTOA_R
    CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
    CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
    CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
    CHECK_NEED_REENTRANT_GETSERVBYPORT_R
])


dnl CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
dnl -------------------------------------------------
dnl This macro ensures that configuration tests done
dnl after this will execute with preprocessor symbol
dnl _REENTRANT defined. This macro also ensures that
dnl the generated config file will equally define it.
dnl Internal macro for CONFIGURE_REENTRANT.

AC_DEFUN([CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
AH_VERBATIM([NEED_REENTRANT],
[/* Configure process defines NEED_REENTRANT to 1 when it finds out that */
/* _REENTRANT is required or already defined for proper configuration.  */
@%:@undef NEED_REENTRANT
@%:@if defined(NEED_REENTRANT) && !defined(_REENTRANT)
@%:@ define _REENTRANT
@%:@endif])
cat >>confdefs.h <<_ACEOF
[@%:@ifndef _REENTRANT
@%:@ define _REENTRANT
@%:@endif]
_ACEOF
AC_DEFINE(NEED_REENTRANT, 1, [])
])


dnl CONFIGURE_REENTRANT
dnl -------------------------------------------------
dnl This first checks if the preprocessor _REENTRANT
dnl symbol is already defined. If it isn't currently
dnl defined a set of checks are performed to verify
dnl if its definition is required to make visible to
dnl the compiler a set of *_r functions. Finally, if
dnl _REENTRANT is already defined or needed it takes
dnl care of making adjustments necessary to ensure
dnl that it is defined equally for further configure
dnl tests and generated config file.

AC_DEFUN([CONFIGURE_REENTRANT], [
  #
  AC_MSG_CHECKING([if _REENTRANT is already defined])
  AC_COMPILE_IFELSE([
    AC_LANG_PROGRAM([[
    ]],[[
#ifdef _REENTRANT
      int dummy=1;
#else
      force compilation error
#endif
    ]])
  ],[
    AC_MSG_RESULT([yes])
    tmp_reentrant_initially_defined="yes"
  ],[
    AC_MSG_RESULT([no])
    tmp_reentrant_initially_defined="no"
  ])
  #
  if test "$tmp_reentrant_initially_defined" = "no"; then
    AC_MSG_CHECKING([if _REENTRANT is actually needed])
    ac_cv_need_reentrant="no"
    CHECK_NEED_REENTRANT_FUNCTIONS_R_DEBUG
    if test "$ac_cv_need_reentrant" = "yes"; then
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no])
    fi
  fi
  #
  AC_MSG_CHECKING([if _REENTRANT is onwards defined])
  if test "$tmp_reentrant_initially_defined" = "yes" ||
    test "$ac_cv_need_reentrant" = "yes"; then
    CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
    AC_MSG_RESULT([yes])
  else
    AC_MSG_RESULT([no])
  fi
  #
])