← Back to team overview

dolfin team mailing list archive

Buggy unordered_set on Mac OS X

 

Please consider the attached patch which allows one (me) to force the
use of gcc's deprecated hash_set extension in an environment (Mac OS X)
which contains a buggy unordered_set implementation.

If someone else needs to do this, configure DOLFIN via:
scons configure enableHashset=yes

Harish
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: hnarayanan@xxxxxxxxx-20100205185425-jzui5vig88qwwqb5
# target_branch: lp:dolfin
# testament_sha1: fedfff60fce7b8225fc2dddeb91c48fda29103de
# timestamp: 2010-02-05 18:58:02 +0000
# base_revision_id: gnw20@xxxxxxxxx-20100205173702-yxi8dkhuhmtgx5s6
# 
# Begin patch
=== modified file 'SConstruct'
--- SConstruct	2010-02-04 00:03:02 +0000
+++ SConstruct	2010-02-05 18:54:25 +0000
@@ -106,6 +106,7 @@
     BoolVariable("enableLapack", "Compile with support for LAPACK", "yes"),
     BoolVariable("enablePython", "Compile the Python wrappers", "yes"),
     BoolVariable("enablePydolfin", "Compile the Python wrappers of DOLFIN *deprecated*", "yes"),
+    BoolVariable("enableHashset", "Force the use of gcc's deprecated hash_set extension", "no"),
     # some of the above may need extra options (like petscDir), should we
     # try to get that from pkg-config?
     # It may be neccessary to specify the installation path to the above packages.
@@ -299,6 +300,17 @@
     # try to use g++ as default:
     env["CXX"] = "g++"
 
+  if env['enableHashset']:
+    if configure.checkCxxHeader('ext/hash_set'):
+      env.Append(CPPDEFINES=["HAVE_HASH_SET"])  
+  else:
+    if configure.checkCxxHeader('unordered_set'):
+      env.Append(CPPDEFINES=["HAVE_UNORDERED_SET"])
+    elif configure.checkCxxHeader('tr1/unordered_set'):
+      env.Append(CPPDEFINES=["HAVE_TR1_UNORDERED_SET"])
+    elif configure.checkCxxHeader('ext/hash_set'):
+      env.Append(CPPDEFINES=["HAVE_HASH_SET"])
+
   # process list of packages to be included in allowed Dependencies.
   # Do we need this any more? I think we rather pick up (external) packages from
   # the scons.cfg files. Actually, I doubt usePackages is ever used?

=== modified file 'dolfin/fem/DofMapBuilder.h'
--- dolfin/fem/DofMapBuilder.h	2010-02-05 17:04:45 +0000
+++ dolfin/fem/DofMapBuilder.h	2010-02-05 18:54:25 +0000
@@ -10,9 +10,19 @@
 #define __DOF_MAP_BUILDER_H
 
 #include <set>
+//#include <boost/unordered_set.hpp>
+//#include <tr1/unordered_set>
+#ifdef HAVE_TR1_UNORDERED_SET
 #include <tr1/unordered_set>
-//#include <boost/unordered_set.hpp>
-
+#else 
+#ifdef HAVE_UNORDERED_SET
+#include <unordered_set>
+#else
+#ifdef HAVE_HASH_SET
+#include <ext/hash_set>
+#endif
+#endif
+#endif
 #include <dolfin/common/Set.h>
 
 namespace dolfin
@@ -32,8 +42,22 @@
     //typedef std::set<dolfin::uint>::const_iterator set_iterator;
     //typedef Set<dolfin::uint> set;
     //typedef Set<dolfin::uint>::const_iterator set_iterator;
+    #ifdef HAVE_TR1_UNORDERED_SET
     typedef std::tr1::unordered_set<dolfin::uint> set;
     typedef std::tr1::unordered_set<dolfin::uint>::const_iterator set_iterator;
+    #else
+    #ifdef HAVE_UNORDERED_SET
+    typedef std::unordered_set<dolfin::uint> set;
+    typedef std::unordered_set<dolfin::uint>::const_iterator set_iterator;
+    #else
+    #ifdef HAVE_HASH_SET
+    typedef __gnu_cxx::hash_set<dolfin::uint> set;
+    typedef __gnu_cxx::hash_set<dolfin::uint>::const_iterator set_iterator;
+    #endif
+    #endif
+    #endif
+    //typedef std::tr1::unordered_set<dolfin::uint> set;
+    //typedef std::tr1::unordered_set<dolfin::uint>::const_iterator set_iterator;
     //typedef boost::unordered_set<dolfin::uint> set;
     //typedef boost::unordered_set<dolfin::uint>::const_iterator set_iterator;
 

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWSau/PgAAuJfgFAQWOf//39j
30q////wYAZX3kJGqrVRaADRVHHGTJkxGJgBMmCZADRhGAIYBKQKZMZTJo1PJpqAAaAA0A0AGhxk
yZMRiYATJgmQA0YRgCG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