From 278a4ac6038a66535149b0ca163ddce06447e367 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Mon, 10 Nov 2003 03:06:09 +0000 Subject: [PATCH] Patch to fix PR102, contributed by Reid Spencer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9849 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/aclocal.m4 | 119 +++++++++++++++++++++++++++------------ autoconf/configure.ac | 4 +- include/Support/hash_map | 33 ++++++----- include/Support/hash_set | 39 +++++++------ 4 files changed, 129 insertions(+), 66 deletions(-) diff --git a/autoconf/aclocal.m4 b/autoconf/aclocal.m4 index da725af8a46..aca868ab123 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 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 #ifdef HAVE_NAMESPACES using namespace std; -#endif],[hash_map t; return 0;], - ac_cv_cxx_have_ext_hash_map=std, ac_cv_cxx_have_ext_hash_map=no) +#endif],[hash_map 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 that defines template class std::hash_map.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has 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 #ifdef HAVE_NAMESPACES using namespace __gnu_cxx; -#endif],[hash_map 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 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 that defines template class __gnu_cxx::hash_map.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_MAP], +[AC_CACHE_CHECK([whether the compiler has 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 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 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 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 #ifdef HAVE_NAMESPACES using namespace std; -#endif],[hash_set t; return 0;], - ac_cv_cxx_have_ext_hash_set=std, ac_cv_cxx_have_ext_hash_set=no) +#endif],[hash_set 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 that defines template class std::hash_set.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GNU_EXT_HASH_SET], +[AC_CACHE_CHECK( + [whether the compiler has 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 #ifdef HAVE_NAMESPACES using namespace __gnu_cxx; -#endif],[hash_set 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 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 that defines template class __gnu_cxx::hash_set.]) + fi]) + +AC_DEFUN([AC_CXX_HAVE_GLOBAL_HASH_SET], +[AC_CACHE_CHECK([whether the compiler has 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 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 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 f613de0a26c..1ae8c1cdd82 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 95ef0e5cdc9..de3b3f5ea5f 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 -#define HASH_NAMESPACE __gnu_cxx +# include +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE __gnu_cxx +# endif -#else +// GCC 3.0.x puts hash_map in and in the std namespace. +#elif defined(HAVE_STD_EXT_HASH_MAP) +# include +# 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 -#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 +# 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 -#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 620dd336671..fa68a8bb738 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 and in +// the __gnu_cxx namespace. +#if defined(HAVE_GNU_EXT_HASH_SET) +# include +# ifndef HASH_NAMESPACE +# define HASH_NAMESPACE __gnu_cxx +# endif -// This is for GCC-3.1+ which puts hashset in ext/hash_set -#include -#define HASH_NAMESPACE __gnu_cxx +// GCC 3.0.x puts hash_set in and in the std namespace. +#elif defined(HAVE_STD_EXT_HASH_SET) +# include +# 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 -#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 +# 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 -#define HASH_NAMESPACE std -#endif - +# warning "Autoconfiguration failed to find the hash_set header file." #endif using HASH_NAMESPACE::hash_set; -- 2.34.1