X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=m4%2Fpandora_stl_hash.m4;h=30277d2f7aaee96e8cd1e3fe1d9204d300ba8835;hb=9c7e4d791a127f8ae46aaddc531319da1f34b5ba;hp=9cd92783d53b8f781e06fe932bcfdb13b04ff19c;hpb=d9dab0a24eebad142b33d00ccb0f87b083f02195;p=m6w6%2Flibmemcached diff --git a/m4/pandora_stl_hash.m4 b/m4/pandora_stl_hash.m4 index 9cd92783..30277d2f 100644 --- a/m4/pandora_stl_hash.m4 +++ b/m4/pandora_stl_hash.m4 @@ -1,107 +1,89 @@ -# We check two things: where the include file is for hash_map, and -# what namespace hash_map lives in within that include file. We +# We check two things: where the include file is for unordered_map, and +# what namespace unordered_map lives in within that include file. We # include AC_COMPILE_IFELSE for all the combinations we've seen in the -# wild. We define one of HAVE_HASH_MAP or HAVE_EXT_HASH_MAP depending -# on location, and HASH_NAMESPACE to be the namespace hash_map is -# defined in. -# -# Ideally we'd use AC_CACHE_CHECK, but that only lets us store one value -# at a time, and we need to store two (filename and namespace). -# prints messages itself, so we have to do the message-printing ourselves -# via AC_MSG_CHECKING + AC_MSG_RESULT. (TODO(csilvers): can we cache?) +# wild. We define HAVE_UNORDERED_MAP and HAVE_UNORDERED_SET if we have +# them, UNORDERED_MAP_H and UNORDERED_SET_H to their location and +# UNORDERED_NAMESPACE to be the namespace unordered_map is defined in. -AC_DEFUN([PANDORA_CXX_STL_HASH], - [AC_MSG_CHECKING(the location of hash_map) - AC_LANG_PUSH(C++) - ac_cv_cxx_hash_map="" - for location in "" "ext/" "tr1/" ; do - for namespace in __gnu_cxx "" std stdext; do - for classprefix in unordered hash; do - if test -z "$ac_cv_cxx_hash_map"; then - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include <${location}${classprefix}_map>]], - [[${namespace}::${classprefix}_map t]])], - [ac_cv_cxx_hash_map="<${location}${classprefix}_map>"; - ac_cv_cxx_hash_set="<${location}${classprefix}_set>"; - ac_cv_cxx_hash_namespace="$namespace"; - ac_cv_cxx_hash_map_class="${classprefix}_map"; - ac_cv_cxx_hash_set_class="${classprefix}_set"]) +AC_DEFUN([PANDORA_CXX_STL_UNORDERED],[ + save_CXXFLAGS="${CXXFLAGS}" + CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}" + AC_LANG_PUSH(C++) + AC_CACHE_CHECK([for STL unordered_map], + [pandora_cv_stl_unordered],[ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[std::unordered_map t]])], + [pandora_cv_stl_unordered="yes"], + [pandora_cv_stl_unordered="no"])]) - fi - done - done - done - - if test -n "$ac_cv_cxx_hash_map"; then - AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map]) - AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set]) - AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map, - [the location of ]) - AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set, - [the location of ]) - AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace, - [the namespace of hash_map/hash_set]) - AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class, - [the classname of hash_map]) - AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class, - [the classname of hash_set]) - AC_MSG_RESULT([$ac_cv_cxx_hash_map]) - else - AC_MSG_RESULT() - AC_MSG_WARN([could not find an STL hash_map]) - fi - AC_CACHE_CHECK( - [whether hash_map has rehash method], - [ac_cv_hash_map_has_rehash], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -#include HASH_MAP_H -using namespace HASH_NAMESPACE; - ]],[[ -HASH_MAP_CLASS test_hash; -test_hash.rehash(100); - ]])], - [ac_cv_hash_map_has_rehash=yes], - [ac_cv_hash_map_has_rehash=no])]) - AS_IF([test $ac_cv_hash_map_has_rehash = yes],[ - AC_DEFINE(HASH_MAP_HAS_REHASH, 1, [if hash_map<> hash rehash method]) - ]) - AC_CACHE_CHECK( - [whether hash_map has resize method], - [ac_cv_hash_map_has_resize], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -#include HASH_MAP_H -using namespace HASH_NAMESPACE; - ]],[[ -HASH_MAP_CLASS test_hash; -test_hash.resize(100); - ]])], - [ac_cv_hash_map_has_resize=yes], - [ac_cv_hash_map_has_resize=no])]) - AS_IF([test $ac_cv_hash_map_has_resize = yes],[ - AC_DEFINE(HASH_MAP_HAS_RESIZE, 1, [if hash_map<> hash resize method]) - ]) - AC_CACHE_CHECK( - [whether to redefine hash], - [ac_cv_redefine_hash_string], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -#include HASH_SET_H -#include -using namespace HASH_NAMESPACE; -using namespace std; - ]],[[ -string teststr("test"); -HASH_SET_CLASS test_hash; -HASH_SET_CLASS::iterator iter= test_hash.find(teststr); -if (iter != test_hash.end()) - return 1; + AS_IF([test "x${pandora_cv_stl_unordered}" != "xyes"],[ + AC_CACHE_CHECK([for tr1 unordered_map], + [pandora_cv_tr1_unordered],[ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +/* We put in this define because of a YACC symbol clash in Drizzle. + Seriously... I cannot believe the GCC guys defined a piece of the internals + of this named IF - and I can't believe that YACC generates a token define + called IF. Really? +*/ +#define IF 21; +#include + ]],[[ +std::tr1::unordered_map t ]])], - [ac_cv_redefine_hash_string=no], - [ac_cv_redefine_hash_string=yes])]) - AS_IF([test $ac_cv_redefine_hash_string = yes],[ - AC_DEFINE(REDEFINE_HASH_STRING, 1, [if hash needs to be defined]) - ]) - AC_LANG_POP() + [pandora_cv_tr1_unordered="yes"], + [pandora_cv_tr1_unordered="no"])]) + ]) + + AS_IF([test "x${pandora_cv_stl_unordered}" != "xyes" -a "x${pandora_cv_tr1_unordered}" != "xyes"],[ + AC_CACHE_CHECK([for boost unordered_map], + [pandora_cv_boost_unordered],[ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[boost::unordered_map t]])], + [pandora_cv_boost_unordered="yes"], + [pandora_cv_boost_unordered="no"])]) + ]) + + CXXFLAGS="${save_CXXFLAGS}" + AC_LANG_POP() + + AS_IF([test "x${pandora_cv_stl_unordered}" = "xyes"],[ + AC_DEFINE(HAVE_STD_UNORDERED_MAP, 1, + [if the compiler has std::unordered_map]) + AC_DEFINE(HAVE_STD_UNORDERED_SET, 1, + [if the compiler has std::unordered_set]) + pandora_has_unordered=yes + ]) + AS_IF([test "x${pandora_cv_tr1_unordered}" = "xyes"],[ + AC_DEFINE(HAVE_TR1_UNORDERED_MAP, 1, + [if the compiler has std::tr1::unordered_map]) + AC_DEFINE(HAVE_TR1_UNORDERED_SET, 1, + [if the compiler has std::tr1::unordered_set]) + pandora_has_unordered=yes + ]) + AS_IF([test "x${pandora_cv_boost_unordered}" = "xyes"],[ + AC_DEFINE(HAVE_BOOST_UNORDERED_MAP, 1, + [if the compiler has boost::unordered_map]) + AC_DEFINE(HAVE_BOOST_UNORDERED_SET, 1, + [if the compiler has boost::unordered_set]) + pandora_has_unordered=yes + ]) + + AS_IF([test "x${pandora_has_unordered}" != "xyes"],[ + AC_MSG_WARN([could not find an STL unordered_map]) + ]) +]) + +AC_DEFUN([PANDORA_HAVE_CXX_UNORDERED],[ + AC_REQUIRE([PANDORA_CXX_STL_UNORDERED]) +]) + +AC_DEFUN([PANDORA_REQUIRE_CXX_UNORDERED],[ + AC_REQUIRE([PANDORA_HAVE_CXX_UNORDERED]) + AS_IF([test "x${pandora_has_unordered}" != "xyes"],[ + AC_MSG_ERROR([An STL compliant unordered_map is required for ${PACKAGE}. + Implementations can be found in Recent versions of gcc and in boost]) + ]) ])