Commit 96790325 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Don't rely on the g++ version to include tr1/unordered_map and co.

The previous setup failed with clang++ 3.0.

* m4/stl.m4: New file.
* configure.ac: Call AC_HEADER_UNORDERED_MAP,
AC_HEADER_TR1_UNORDERED_MAP, and AC_HEADER_EXT_HASH_MAP.
* src/misc/hash.hh: Include _config.h, and used the
SPOT_HAVE_UNORDERED_MAP, SPOT_HAVE_TR1_UNORDERED_MAP,
or SPOT_HAVE_EXT_HASH_MAP defines to decide which
file to include.
parent a804c88e
2011-12-16 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Don't rely on the g++ version to include tr1/unordered_map and co.
The previous setup failed with clang++ 3.0.
* m4/stl.m4: New file.
* configure.ac: Call AC_HEADER_UNORDERED_MAP,
AC_HEADER_TR1_UNORDERED_MAP, and AC_HEADER_EXT_HASH_MAP.
* src/misc/hash.hh: Include _config.h, and used the
SPOT_HAVE_UNORDERED_MAP, SPOT_HAVE_TR1_UNORDERED_MAP,
or SPOT_HAVE_EXT_HASH_MAP defines to decide which
file to include.
2011-12-01 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Fix mkdir error in ajax/spot.in.
......@@ -4331,7 +4345,7 @@
Update to compile with the Intel compiler.
* m4/intel.m4: New file.
* m4/intel.m4: New file.
* configure.ac: Update.
* src/tgbaalgos/emptiness.cc (tgba_run): Modify s.s->clone() in
i->s->clone().
......
......@@ -46,6 +46,10 @@ AC_PROG_YACC
AC_LANG(C++)
AC_HEADER_UNORDERED_MAP
AC_HEADER_TR1_UNORDERED_MAP
AC_HEADER_EXT_HASH_MAP
AX_CHECK_BUDDY
AX_CHECK_LBTT
AX_CHECK_GSPNLIB
......
AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
AC_CACHE_CHECK([for ext/hash_map],
[ac_cv_cxx_ext_hash_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
AC_TRY_COMPILE([#include <ext/hash_map>], [using __gnu_cxx::hash_map;],
[ac_cv_cxx_ext_hash_map=yes], [ac_cv_cxx_ext_hash_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_ext_hash_map" = yes; then
AC_DEFINE([HAVE_EXT_HASH_MAP],, [Define if ext/hash_map is present.])
fi
])
AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
AC_CACHE_CHECK([for tr1/unordered_map],
[ac_cv_cxx_tr1_unordered_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
AC_TRY_COMPILE([#include <tr1/unordered_map>], [using std::tr1::unordered_map;],
[ac_cv_cxx_tr1_unordered_map=yes], [ac_cv_cxx_tr1_unordered_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
AC_DEFINE([HAVE_TR1_UNORDERED_MAP],, [Define if tr1/unordered_map is present.])
fi
])
AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
AC_CACHE_CHECK([for unordered_map],
[ac_cv_cxx_unordered_map],
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Werror"
AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;],
[ac_cv_cxx_unordered_map=yes], [ac_cv_cxx_unordered_map=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_unordered_map" = yes; then
AC_DEFINE([HAVE_UNORDERED_MAP],, [Define if unordered_map is present.])
fi
])
......@@ -26,11 +26,35 @@
# include <string>
# include <functional>
# include "hashfunc.hh"
# include "misc/hashfunc.hh"
# include "misc/_config.h"
// See the G++ FAQ for details about the following.
# ifdef __GNUC__
# if __GNUC__ < 3
#ifdef SPOT_HAVE_UNORDERED_MAP
# include <unordered_map>
# include <unordered_set>
namespace Sgi = std;
# define hash_map unordered_map
# define hash_multimap unordered_multimap
# define hash_set unordered_set
#else
#ifdef SPOT_HAVE_TR1_UNORDERED_MAP
# include <tr1/unordered_map>
# include <tr1/unordered_set>
namespace Sgi = std::tr1;
# define hash_map unordered_map
# define hash_multimap unordered_multimap
# define hash_set unordered_set
#else
#ifdef SPOT_HAVE_EXT_HASH_MAP
# include <ext/hash_map>
# include <ext/hash_set>
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
namespace Sgi = std; // GCC 3.0
# else
namespace Sgi = ::__gnu_cxx; // GCC 3.1 to 4.2
# endif
#else
# if defined(__GNUC__) && (__GNUC__ < 3)
# include <hash_map.h>
# include <hash_set.h>
namespace Sgi
......@@ -41,28 +65,13 @@
using ::hash;
}
# else
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
# include <tr1/unordered_set> // GCC 4.3
# include <tr1/unordered_map>
namespace Sgi = std::tr1;
# define hash_map unordered_map
# define hash_multimap unordered_multimap
# define hash_set unordered_set
# else
# include <ext/hash_map>
# include <ext/hash_set>
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
namespace Sgi = std; // GCC 3.0
# else
namespace Sgi = ::__gnu_cxx; // GCC 3.1 to 4.2
# endif
# endif
# endif
# else // ... there are other compilers, right?
# include <hash_map>
# include <hash_set>
namespace Sgi = std;
# endif
#endif
#endif
#endif
namespace spot
{
......@@ -83,9 +92,9 @@ namespace spot
/// \brief A hash function for strings.
/// \ingroup hash_funcs
/// @{
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
typedef std::tr1::hash<std::string> string_hash;
# else // GCC < 4.3
#if defined(SPOT_HAVE_UNORDERED_MAP) || defined(SPOT_HAVE_TR1_UNORDERED_MAP)
typedef Sgi::hash<std::string> string_hash;
#else // e.g. GCC < 4.3
struct string_hash:
public Sgi::hash<const char*>,
public std::unary_function<const std::string&, size_t>
......@@ -98,7 +107,7 @@ namespace spot
}
};
/// @}
# endif
#endif
/// \brief A hash function that returns identity
/// \ingroup hash_funcs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment