diff --git a/configure.ac b/configure.ac index a932568..cddac7b 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,12 @@ dnl Check for dl library (needed for GiNaC::compile). GINAC_EXCOMPILER AM_CONDITIONAL(CONFIG_EXCOMPILER, [test "x${CONFIG_EXCOMPILER}" = "xyes"]) +dnl Option to enable deterministic sorting +AC_ARG_ENABLE(determinism,[AS_HELP_STRING([--enable-determinism], + [Enable deterministic term ordering @<:@default=no@:>@])], + [], [enable_determinism=no]) +test "x$enable_determinism" == xyes && AC_DEFINE(DETERMINISTIC_ORDERING,1,[deterministic sorting]) + dnl Check for utilities needed by the different kinds of documentation. dnl Documentation needs only be built when extending it, so never mind if it dnl cannot find those helpers: diff --git a/ginac/hash_seed.h b/ginac/hash_seed.h index 32b057f..db255e7 100644 --- a/ginac/hash_seed.h +++ b/ginac/hash_seed.h @@ -23,6 +23,14 @@ #endif namespace GiNaC { +#ifdef DETERMINISTIC_ORDERING +static inline unsigned make_hash_seed(const std::type_info& tinfo) +{ + // deterministic ordering of different types is defined + // via typeid_this.before(typeid_other) in basic.cpp + return 0; +} +#else /* DETERMINISTIC_ORDERING */ #ifndef GINAC_HASH_USE_MANGLED_NAME static inline unsigned make_hash_seed(const std::type_info& tinfo) { @@ -32,13 +40,14 @@ static inline unsigned make_hash_seed(const std::type_info& tinfo) unsigned v = golden_ratio_hash((p_int)mangled_name_ptr); return v; } -#else +#else /* GINAC_HASH_USE_MANGLED_NAME */ static unsigned make_hash_seed(const std::type_info& tinfo) { const char* mangled_name = tinfo.name(); return crc32(mangled_name, std::strlen(mangled_name), 0); } -#endif +#endif /* GINAC_HASH_USE_MANGLED_NAME */ +#endif /* DETERMINISTIC_ORDERING */ } // namespace GiNaC #endif /* GINAC_HASH_SEED_H */