diff options
-rw-r--r-- | autoconf/aclocal.m4 | 119 | ||||
-rw-r--r-- | autoconf/configure.ac | 4 | ||||
-rw-r--r-- | include/Support/hash_map | 33 | ||||
-rw-r--r-- | include/Support/hash_set | 39 |
4 files changed, 129 insertions, 66 deletions
diff --git a/autoconf/aclocal.m4 b/autoconf/aclocal.m4 index da725af8a4..aca868ab12 100644 --- a/autoconf/aclocal.m4 +++ b/autoconf/aclocal.m4 @@ -5892,61 +5892,109 @@ fi # Check for hash_map extension. This is from # http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_map.html # -AC_DEFUN([AC_CXX_HAVE_EXT_HASH_MAP], -[AC_CACHE_CHECK(whether the compiler has ext/hash_map, -ac_cv_cxx_have_ext_hash_map, -[AC_REQUIRE([AC_CXX_NAMESPACES]) +AC_DEFUN([AC_CXX_HAVE_STD_EXT_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has <ext/hash_map> defining template class std::hash_map], + ac_cv_cxx_have_std_ext_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <ext/hash_map> #ifdef HAVE_NAMESPACES using namespace std; -#endif],[hash_map<int, int> t; return 0;], - ac_cv_cxx_have_ext_hash_map=std, ac_cv_cxx_have_ext_hash_map=no) +#endif],[hash_map<int, int> t;], + [ac_cv_cxx_have_std_ext_hash_map=yes], [ac_cv_cxx_have_std_ext_hash_map=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_std_ext_hash_map" = yes; then + AC_DEFINE(HAVE_STD_EXT_HASH_MAP,,[Define if the compiler has a header <ext/hash_map> that defines template class std::hash_map.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has <ext/hash_map> defining template class __gnu_cxx::hash_map], + ac_cv_cxx_have_gnu_ext_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <ext/hash_map> #ifdef HAVE_NAMESPACES using namespace __gnu_cxx; -#endif],[hash_map<int, int> t; return 0;], - ac_cv_cxx_have_ext_hash_map=gnu, ac_cv_cxx_have_ext_hash_map=no) - AC_LANG_RESTORE -]) -if test "$ac_cv_cxx_have_ext_hash_map" = std; then - AC_DEFINE(HAVE_STD_EXT_HASH_MAP,,[define if the compiler has ext/hash_map]) -fi -if test "$ac_cv_cxx_have_ext_hash_map" = gnu; then - AC_DEFINE(HAVE_GNU_EXT_HASH_MAP,,[define if the compiler has ext/hash_map]) -fi -]) - +#endif],[hash_map<int,int> t; ], + [ac_cv_cxx_have_gnu_ext_hash_map=yes],[ac_cv_cxx_have_gnu_ext_hash_map=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_gnu_ext_hash_map" = yes; then + AC_DEFINE(HAVE_GNU_EXT_HASH_MAP,,[Define if the compiler has a header <ext/hash_map> that defines template class __gnu_cxx::hash_map.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has <hash_map> defining template class ::hash_map], + ac_cv_cxx_have_global_hash_map, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include <hash_map>],[hash_map<int,int> t; ], + [ac_cv_cxx_have_global_hash_map=yes], [ac_cv_cxx_have_global_hash_map=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_global_hash_map" = yes; then + AC_DEFINE(HAVE_GLOBAL_HASH_MAP,,[Define if the compiler has a header <hash_map> that defines template class ::hash_map.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_HASH_MAP], +[AC_CXX_HAVE_STD_EXT_HASH_MAP + AC_CXX_HAVE_GNU_EXT_HASH_MAP + AC_CXX_HAVE_GLOBAL_HASH_MAP]) # # Check for hash_set extension. This is modified from # http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_hash_set.html # -AC_DEFUN([AC_CXX_HAVE_EXT_HASH_SET], -[AC_CACHE_CHECK(whether the compiler has ext/hash_set, -ac_cv_cxx_have_ext_hash_set, -[AC_REQUIRE([AC_CXX_NAMESPACES]) +AC_DEFUN([AC_CXX_HAVE_STD_EXT_HASH_SET], +[AC_CACHE_CHECK([whether the compiler has <ext/hash_set> defining template class std::hash_set], + ac_cv_cxx_have_std_ext_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <ext/hash_set> #ifdef HAVE_NAMESPACES using namespace std; -#endif],[hash_set<int> t; return 0;], - ac_cv_cxx_have_ext_hash_set=std, ac_cv_cxx_have_ext_hash_set=no) +#endif],[hash_set<int> t; ], + [ac_cv_cxx_have_std_ext_hash_set=yes], [ac_cv_cxx_have_std_ext_hash_set=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_std_ext_hash_set" = yes; then + AC_DEFINE(HAVE_STD_EXT_HASH_SET,,[Define if the compiler has a header <ext/hash_set> that defines template class std::hash_set.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_SET], +[AC_CACHE_CHECK( + [whether the compiler has <ext/hash_set> defining template class __gnu_cxx::hash_set], + ac_cv_cxx_have_gnu_ext_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <ext/hash_set> #ifdef HAVE_NAMESPACES using namespace __gnu_cxx; -#endif],[hash_set<int> t; return 0;], - ac_cv_cxx_have_ext_hash_set=gnu, ac_cv_cxx_have_ext_hash_set=no) - AC_LANG_RESTORE -]) -if test "$ac_cv_cxx_have_ext_hash_set" = std; then - AC_DEFINE(HAVE_STD_EXT_HASH_SET,,[define if the compiler has ext/hash_set in std]) -fi -if test "$ac_cv_cxx_have_ext_hash_set" = gnu; then - AC_DEFINE(HAVE_GNU_EXT_HASH_SET,,[define if the compiler has ext/hash_set in __gnu_cc]) -fi -]) +#endif],[hash_set<int> t; ], + [ac_cv_cxx_have_gnu_ext_hash_set=yes], [ac_cv_cxx_have_gnu_ext_hash_set=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_gnu_ext_hash_set" = yes; then + AC_DEFINE(HAVE_GNU_EXT_HASH_SET,,[Define if the compiler has a header <ext/hash_set> that defines template class __gnu_cxx::hash_set.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_SET], +[AC_CACHE_CHECK([whether the compiler has <hash_set> defining template class ::hash_set], + ac_cv_cxx_have_global_hash_set, + [AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include <hash_set>],[hash_set<int> t; return 0;], + [ac_cv_cxx_have_global_hash_set=yes], [ac_cv_cxx_have_global_hash_set=no]) + AC_LANG_RESTORE]) + if test "$ac_cv_cxx_have_global_hash_set" = yes; then + AC_DEFINE(HAVE_GLOBAL_HASH_SET,,[Define if the compiler has a header <hash_set> that defines template class ::hash_set.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_HASH_SET], +[AC_CXX_HAVE_STD_EXT_HASH_SET + AC_CXX_HAVE_GNU_EXT_HASH_SET + AC_CXX_HAVE_GLOBAL_HASH_SET]) # # Check for standard iterator extension. This is modified from @@ -6196,3 +6244,4 @@ AC_DEFUN([AC_C_PRINTF_A], fi ]) + diff --git a/autoconf/configure.ac b/autoconf/configure.ac index f613de0a26..1ae8c1cdd8 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -460,8 +460,8 @@ dnl Check for various C features AC_C_PRINTF_A dnl Check for C++ extensions -AC_CXX_HAVE_EXT_HASH_MAP -AC_CXX_HAVE_EXT_HASH_SET +AC_CXX_HAVE_HASH_MAP +AC_CXX_HAVE_HASH_SET AC_CXX_HAVE_EXT_SLIST AC_CXX_HAVE_STD_ITERATOR AC_CXX_HAVE_BI_ITERATOR diff --git a/include/Support/hash_map b/include/Support/hash_map index 95ef0e5cdc..de3b3f5ea5 100644 --- a/include/Support/hash_map +++ b/include/Support/hash_map @@ -29,23 +29,30 @@ #ifdef HAVE_GNU_EXT_HASH_MAP // This is for GCC-3.1+ which puts hash in ext/hash_map -#include <ext/hash_map> -#define HASH_NAMESPACE __gnu_cxx +# include <ext/hash_map> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE __gnu_cxx +# endif -#else +// GCC 3.0.x puts hash_map in <ext/hash_map> and in the std namespace. +#elif defined(HAVE_STD_EXT_HASH_MAP) +# include <ext/hash_map> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE std +# endif -// This is for GCC-3.0.x which puts hashmap in the `ext' directory. -#ifdef HAVE_STD_EXT_HASH_MAP -#include <ext/hash_map> -#define HASH_NAMESPACE std +// Older compilers such as GCC before version 3.0 do not keep +// extensions in the `ext' directory, and ignore the `std' namespace. +#elif defined(HAVE_GLOBAL_HASH_MAP) +# include <hash_map> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE std +# endif +// Give a warning if we couldn't find it, instead of (or in addition to) +// randomly doing something dumb. #else -// This handles older, pre-3.0 GCC which do not have the extentions in the `ext' -// directory, and ignore the `std' namespace. -#include <hash_map> -#define HASH_NAMESPACE std -#endif - +# warning "Autoconfiguration failed to find the hash_map header file." #endif using HASH_NAMESPACE::hash_map; diff --git a/include/Support/hash_set b/include/Support/hash_set index 620dd33667..fa68a8bb73 100644 --- a/include/Support/hash_set +++ b/include/Support/hash_set @@ -28,26 +28,33 @@ #include "Config/config.h" -#ifdef HAVE_GNU_EXT_HASH_SET +// GCC versions 3.1 and later put hash_set in <ext/hash_set> and in +// the __gnu_cxx namespace. +#if defined(HAVE_GNU_EXT_HASH_SET) +# include <ext/hash_set> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE __gnu_cxx +# endif -// This is for GCC-3.1+ which puts hashset in ext/hash_set -#include <ext/hash_set> -#define HASH_NAMESPACE __gnu_cxx +// GCC 3.0.x puts hash_set in <ext/hash_set> and in the std namespace. +#elif defined(HAVE_STD_EXT_HASH_SET) +# include <ext/hash_set> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE std +# endif -#else - -// This is for GCC-3.0.x which puts hashmap in the `ext' directory. -#ifdef HAVE_STD_EXT_HASH_SET -#include <ext/hash_set> -#define HASH_NAMESPACE std +// Older compilers such as GCC before version 3.0 do not keep +// extensions in the `ext' directory, and ignore the `std' namespace. +#elif defined(HAVE_GLOBAL_HASH_SET) +# include <hash_set> +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE std +# endif +// Give a warning if we couldn't find it, instead of (or in addition to) +// randomly doing something dumb. #else -// This handles older, pre-3.0 GCC which do not have the extentions in the `ext' -// directory, and ignore the `std' namespace. -#include <hash_set> -#define HASH_NAMESPACE std -#endif - +# warning "Autoconfiguration failed to find the hash_set header file." #endif using HASH_NAMESPACE::hash_set; |