# # # rename "sha1.hh" # to "Attic/sha1.hh" # # rename "sha1_engine.hh" # to "Attic/sha1_engine.hh" # # patch "Makefile.am" # from [f19330cbc59ea2c4e55178c6f4dc71405273ce47] # to [ea5a14d59e3302d3b3cb5cf65b7a5e489d19e548] # # patch "m4/botan.m4" # from [bb146cd55de685d93019400cdbbaf0eae60039e1] # to [079240fafb6bd2a80cbd0dd35501b76b1b3d362a] # # patch "monotone.cc" # from [999f30eda7b52b6b5f55c35f24b61b4f2959b6a5] # to [a056cecce3061cd85df559e3598c6e66f75db3e9] # # patch "sha1.cc" # from [233a3432e8469854a7840fc02bfd872379b2f40b] # to [5b5488b7d19a740f70bae5d82c709c9549c5f38d] # ============================================================ --- Makefile.am f19330cbc59ea2c4e55178c6f4dc71405273ce47 +++ Makefile.am ea5a14d59e3302d3b3cb5cf65b7a5e489d19e548 @@ -71,7 +71,7 @@ MOST_SOURCES = \ legacy.cc legacy.hh uri.cc uri.hh \ graph.cc graph.hh \ roster_delta.cc roster_delta.hh \ - sha1.hh sha1.cc sha1_engine.hh \ + sha1.cc \ pcrewrap.cc pcrewrap.hh \ rev_height.cc rev_height.hh \ asciik.cc asciik.hh \ ============================================================ --- m4/botan.m4 bb146cd55de685d93019400cdbbaf0eae60039e1 +++ m4/botan.m4 079240fafb6bd2a80cbd0dd35501b76b1b3d362a @@ -1,6 +1,6 @@ # Currently we accept botan version 1.6.3 and newer, limited to the # development branch 1.7, emitting a warning if the found botan is -# newer than 1.7.20. +# newer than 1.7.23. AC_DEFUN([MTN_FIND_BOTAN], [ @@ -36,7 +36,7 @@ AC_DEFUN([MTN_FIND_BOTAN], AC_PREPROC_IFELSE([ #include -#if BOTAN_VERSION_CODE > BOTAN_VERSION_CODE_FOR(1,7,20) +#if BOTAN_VERSION_CODE > BOTAN_VERSION_CODE_FOR(1,7,23) #error "Botan from the future" #endif], [botan_version_match=yes], ============================================================ --- monotone.cc 999f30eda7b52b6b5f55c35f24b61b4f2959b6a5 +++ monotone.cc a056cecce3061cd85df559e3598c6e66f75db3e9 @@ -30,7 +30,6 @@ #include "mt_version.hh" #include "option.hh" #include "paths.hh" -#include "sha1.hh" #include "simplestring_xform.hh" #include "platform.hh" #include "work.hh" ============================================================ --- sha1.cc 233a3432e8469854a7840fc02bfd872379b2f40b +++ sha1.cc 5b5488b7d19a740f70bae5d82c709c9549c5f38d @@ -11,107 +11,32 @@ // benchmark them. #include "base.hh" -#include -#include -#include +#include +#include -#include "sha1.hh" -#include "sha1_engine.hh" -#include "safe_map.hh" #include "sanity.hh" #include "ui.hh" #include "platform.hh" #include "cmd.hh" #include "transforms.hh" -using std::map; -using std::pair; -using std::make_pair; using std::string; -namespace -{ - map > & registry() - { - static map > the_registry; - return the_registry; - } - - void - register_sha1(int priority, std::string const & name, sha1_maker * maker) - { - // invert priority, so that high priority sorts first (could override the - // comparison function too, but this takes 1 character...) - safe_insert(registry(), make_pair(-priority, make_pair(name, maker))); - } - - sha1_maker * maker_to_be_benchmarked = 0; - - class Monotone_SHA1_Engine : public Botan::Engine - { - public: - Botan::HashFunction * find_hash(const std::string& name) const - { - if (name == "SHA-160") - { - if (maker_to_be_benchmarked) - { - // We are in the middle of a benchmark run, so call the maker we - // are supposed to be benchmarking. - Botan::HashFunction * retval = maker_to_be_benchmarked(); - maker_to_be_benchmarked = 0; - return retval; - } - else - { - I(!registry().empty()); - // Call the highest priority maker. - return registry().begin()->second.second(); - } - } - return 0; - } - }; - - // returning 0 from find_hash means that we don't want to handle this, and - // causes Botan to drop through to its built-in, portable engine. - Botan::HashFunction * botan_default_maker() - { - return 0; - } - sha1_registerer botan_default(0, "botan", &botan_default_maker); -} - -sha1_registerer::sha1_registerer(int priority, string const & name, sha1_maker * maker) -{ - register_sha1(priority, name, maker); -} - -void hook_botan_sha1() -{ - Botan::global_state().add_engine(new Monotone_SHA1_Engine); -} - CMD_HIDDEN(benchmark_sha1, "benchmark_sha1", "", CMD_REF(debug), "", - N_("Benchmarks SHA-1 cores"), + N_("Benchmarks botan's SHA-1 core"), "", options::opts::none) { - P(F("Benchmarking %s SHA-1 cores") % registry().size()); + P(F("Benchmarking botan's SHA-1 core")); int mebibytes = 100; string test_str(mebibytes << 20, 'a'); data test_data(test_str); - for (map >::const_iterator i = registry().begin(); - i != registry().end(); ++i) - { - maker_to_be_benchmarked = i->second.second; - id foo; - double start = cpu_now(); - calculate_ident(test_data, foo); - double end = cpu_now(); - double mebibytes_per_sec = mebibytes / (end - start); - P(F("%s: %s MiB/s") % i->second.first % mebibytes_per_sec); - } + id foo; + double start = cpu_now(); + calculate_ident(test_data, foo); + double end = cpu_now(); + double mebibytes_per_sec = mebibytes / (end - start); + P(F("%s MiB/s") % mebibytes_per_sec); }