fix src/util/hash.h to specialize GNU's hash template for <uint64_t> on platforms...
authorMorgan Deters <mdeters@gmail.com>
Tue, 21 Feb 2012 22:13:05 +0000 (22:13 +0000)
committerMorgan Deters <mdeters@gmail.com>
Tue, 21 Feb 2012 22:13:05 +0000 (22:13 +0000)
configure.ac
src/expr/pickler.h
src/util/hash.h

index 6f5568bd2f173ec5cabdcbbbc37898ee2e42f8cb..4b079facfe399fe545537d3baac0dda797984abe 100644 (file)
@@ -676,6 +676,19 @@ if test "$enable_profiling" = yes; then
   CVC4LDFLAGS="${CVC4LDFLAGS:+$CVC4LDFLAGS }-pg"
 fi
 
+# Check to see if this version/architecture of GNU C++ explicitly
+# instantiates __gnu_cxx::hash<uint64_t> or not.  Some do, some don't.
+# See src/util/hash.h.
+AC_MSG_CHECKING([whether __gnu_cxx::hash<uint64_t> is already specialized])
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE(AC_LANG_SOURCE([
+#include <stdint.h>
+#include <ext/hash_map>
+namespace __gnu_cxx { template<> struct hash<uint64_t> {}; }]),
+                  [AC_MSG_RESULT([no]); CVC4CPPFLAGS="${CVC4CPPFLAGS:+$CVC4CPPFLAGS }-DCVC4_NEED_HASH_UINT64_T"],
+                  [AC_MSG_RESULT([yes])])
+AC_LANG_POP([C++])
+
 # Check for ANTLR runantlr script (defined in config/antlr.m4)
 AC_PROG_ANTLR
 
index 264ae0e4b93611de542cd01b39855da7f67e57f9..6e79d6997329705465b01ecf1cd443572cc142d1 100644 (file)
@@ -50,7 +50,7 @@ public:
   Pickle();
   Pickle(const Pickle& p);
   ~Pickle();
-  Pickle& operator = (const Pickle& other);
+  Pickle& operator=(const Pickle& other);
 };/* class Pickle */
 
 class CVC4_PUBLIC PicklingException : public Exception {
@@ -116,11 +116,11 @@ public:
 protected:
 
   virtual uint64_t variableToMap(uint64_t x) const
-    throw(AssertionException, PicklingException){
+    throw(AssertionException, PicklingException) {
     VarMap::const_iterator i = d_toMap.find(x);
-    if(i != d_toMap.end()){
+    if(i != d_toMap.end()) {
       return i->second;
-    }else{
+    } else {
       throw PicklingException();
     }
   }
index 5f0189d442b205279e0d8971f4032805243fd412..fdfbf4087b6da8ed7aa453214ae0a084186f6b54 100644 (file)
@@ -29,15 +29,16 @@ namespace __gnu_cxx {}
 
 namespace __gnu_cxx {
 
-#if __WORDSIZE == 32
-// on 32-bit, we need a specialization of hash for 64-bit values
+#ifdef CVC4_NEED_HASH_UINT64_T
+// on some versions and architectures of GNU C++, we need a
+// specialization of hash for 64-bit values
 template <>
 struct hash<uint64_t> {
   size_t operator()(uint64_t v) const {
     return v;
   }
 };/* struct hash<uint64_t> */
-#endif /* 32-bit */
+#endif /* CVC4_NEED_HASH_UINT64_T */
 
 }/* __gnu_cxx namespace */