From: Amos Jeffries Date: Fri, 22 May 2015 15:43:19 +0000 (-0700) Subject: Portability: Define C++11 uniform distributions if missing X-Git-Tag: merge-candidate-3-v1~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=249b93df9da7aa1d36203b3bba335bbfc9660f7f;p=thirdparty%2Fsquid.git Portability: Define C++11 uniform distributions if missing Older compilers standard libraries may not contain the uniform distribution templates now used. But we may be able to use the TR1 distributions instead. --- diff --git a/acinclude/ax_cxx_0x_types.m4 b/acinclude/ax_cxx_0x_types.m4 index 7439f3a6e0..f3ff94af55 100644 --- a/acinclude/ax_cxx_0x_types.m4 +++ b/acinclude/ax_cxx_0x_types.m4 @@ -47,3 +47,28 @@ AC_DEFUN([AX_CXX_TYPE_UNIQUE_PTR],[ fi AC_LANG_POP ]) + +## Hand crafted for Squid under GPL version 2 +AC_DEFUN([AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([whether std::uniform_int_distribution is supported]) + AC_TRY_COMPILE([#include ],[std::uniform_int_distribution c;], [ + HAVE_UNIFORM_INT_DISTRIBUTION=yes + AC_MSG_RESULT(yes)], [ + HAVE_UNIFORM_INT_DISTRIBUTION=no + AC_MSG_RESULT(no)]) + if test "x$HAVE_UNIFORM_INT_DISTRIBUTION" = xno; then + AC_DEFINE(uniform_int_distributon, tr1::uniform_int, [Leave undefined if std::uniform_int_distribution is supported]) + fi + AC_MSG_CHECKING([whether std::uniform_real_distribution is supported]) + AC_TRY_COMPILE([#include ],[std::uniform_real_distribution c;], [ + HAVE_UNIFORM_REAL_DISTRIBUTION=yes + AC_MSG_RESULT(yes)], [ + HAVE_UNIFORM_REAL_DISTRIBUTION=no + AC_MSG_RESULT(no)]) + if test "x$HAVE_UNIFORM_REAL_DISTRIBUTION" = xno; then + AC_DEFINE(uniform_real_distributon, tr1::uniform_real, [Leave undefined if std::uniform_real_distribution is supported]) + fi + AC_LANG_POP +]) diff --git a/configure.ac b/configure.ac index b9ad23949b..9957175173 100644 --- a/configure.ac +++ b/configure.ac @@ -2973,9 +2973,10 @@ AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(size_t) -dnl Some C++0x types we try to use +dnl Some C++11 types we try to use AX_CXX_TYPE_NULLPTR AX_CXX_TYPE_UNIQUE_PTR +AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS dnl On Solaris 9 x86, gcc may includes a "fixed" set of old system include files dnl that is incompatible with the updated Solaris header files.