# # # patch "ChangeLog" # from [ded05d45d4a81d422c2bf583586469cc2850bc20] # to [9bd732e927aec824f33708f16502d405cfb9f61c] # # patch "basic_io.hh" # from [7199964d5427709350a247c326a78686fbc09fa8] # to [f3f011170676902c459bd3b714a0f4110daaad7a] # # patch "cmd_list.cc" # from [852a8765a58e4cea31fe527ee1cc3f0b431184eb] # to [a7078d1e2228cc75e5aaad58f29010b9f88ed6e7] # # patch "database.cc" # from [3bc4262aa2cf230fa35529ceb8d0987492b1e332] # to [241842d74b2d914cb261c24db82faa8b1203da17] # # patch "hash_map.hh" # from [3485ec0bd41210543b7b415c188f5ef6f21a16dd] # to [b3b399890667ee2a3f32ee586393030476d35320] # # patch "interner.hh" # from [a8d437360e4e6e069cb5ed9bea59a066cf975ea9] # to [70ca14f55628cab86911c21d846931cb64d3319d] # # patch "merkle_tree.hh" # from [ac7370ade9ce9d2acce480349671d52061eea41f] # to [b521fb7e79fb73eb780abc2225363917982b4e96] # # patch "rcs_file.cc" # from [ae0f12cfaa2788a212bc9d3f1ec843ce8ba49cc8] # to [f5dde1d6e49f0472b11704c24d36a0bcb161f257] # # patch "rcs_import.cc" # from [0de2b62e2c973f4c94592cff4990f0a43eb70294] # to [38060f4ed9c1b336fb1467be0f2006e3d4aac487] # # patch "unix/fs.cc" # from [e353582dd31c2d083e95fba1aa3c7321761a3843] # to [8c6fe727ef9e240274689f7ef2d08836f73f703b] # # patch "vocab.cc" # from [c3824a3441b679e4e8c2c8f29fa412bcf2d2d1c3] # to [7cf1d84a1a30eebaeb5edfbb8c3a46d1598d56a4] # # patch "xdelta.cc" # from [eba5a931daaa288450f3d69e927e662108bdc7e5] # to [21dd536e55a0e81ccd7c781eb692141782100cbf] # ============================================================ --- ChangeLog ded05d45d4a81d422c2bf583586469cc2850bc20 +++ ChangeLog 9bd732e927aec824f33708f16502d405cfb9f61c @@ -1,3 +1,17 @@ +2006-04-27 Timothy Brownawell + + * hash_map.hh: Do things a little differently. Should make + instantiating different types of hash_map (like merkle_tree.hh does) + easier, slightly less dependent on the compiler/library. (Currently, + this should mostly be useful in the .visualc8 branch.) + * basic_io.hh cmd_list.hh rcs_file.cc rcs_import.cc unix/fs.cc: These + wouldn't compile with g++/stlport. Add includes, replace a + const_iterator with an iterator in rcs_import.cc + * database.cc interner.hh merkle_tree.hh vocab.cc xdelta.cc: Adjust + to match the new hash_map. + Compile-tested on g++ and g++ with stlport. Won't link when using + stlport, because my boost was compiled against g++'s normal stl. + 2006-04-26 Timothy Brownawell * netsync.cc (serve_connections): Cycle through all results before ============================================================ --- basic_io.hh 7199964d5427709350a247c326a78686fbc09fa8 +++ basic_io.hh f3f011170676902c459bd3b714a0f4110daaad7a @@ -19,6 +19,8 @@ #include "paths.hh" #include "sanity.hh" +#include + namespace basic_io { ============================================================ --- cmd_list.cc 852a8765a58e4cea31fe527ee1cc3f0b431184eb +++ cmd_list.cc a7078d1e2228cc75e5aaad58f29010b9f88ed6e7 @@ -15,6 +15,8 @@ using std::set; #include using std::map; +#include +using std::sort; static void ls_certs(string const & name, app_state & app, vector const & args) ============================================================ --- database.cc 3bc4262aa2cf230fa35529ceb8d0987492b1e332 +++ database.cc 241842d74b2d914cb261c24db82faa8b1203da17 @@ -2726,7 +2726,7 @@ } -typedef hashmap::hash_multimap ancestry_map; +typedef hashmap::hash_multimap ancestry_map; static void transitive_closure(string const & x, ============================================================ --- hash_map.hh 3485ec0bd41210543b7b415c188f5ef6f21a16dd +++ hash_map.hh b3b399890667ee2a3f32ee586393030476d35320 @@ -1,8 +1,29 @@ #ifndef __HASHMAP_HH #define __HASHMAP_HH #include "config.h" +#include +namespace hashmap { + template + class equal_to : public std::equal_to<_T> + {}; + + template + struct hash + { +// size_t operator()(_T const & t) const; + }; + template<> + struct hash + { + size_t operator()(unsigned int t) const + { + return t; + } + }; +} + #ifdef HAVE_GNUCXX_HASHMAP #define HASHMAP_PRESENT #include @@ -10,18 +31,35 @@ #include namespace hashmap { - using __gnu_cxx::hash_map; - using __gnu_cxx::hash_set; - using __gnu_cxx::hash_multimap; + template<> + struct hash + { + size_t operator()(std::string const & s) const + { + return __gnu_cxx::__stl_hash_string(s.c_str()); + } + }; + + template + class hash_map : public __gnu_cxx::hash_map<_Key, + _Value, + hash<_Key>, + equal_to<_Key> > + {}; + + template + class hash_set : public __gnu_cxx::hash_set<_Key, + hash<_Key>, + equal_to<_Key> > + {}; + + template + class hash_multimap : public __gnu_cxx::hash_multimap<_Key, + _Value, + hash<_Key>, + equal_to<_Key> > + {}; - struct string_hash - { - size_t operator()(std::string const & s) const - { - return __gnu_cxx::__stl_hash_string(s.c_str()); - } - }; - } #endif @@ -33,21 +71,39 @@ #include namespace hashmap { - using std::hash_map; - using std::hash_set; - using std::hash_multimap; + template<> + struct hash + { + size_t operator()(std::string const & s) const + { + const char* s2=s.c_str(); + unsigned long h = 0; + for ( ; *s2; ++s2) + h = 5*h + *s2; + return size_t(h); + } + }; - struct string_hash - { - size_t operator()(std::string const & s) const - { - const char* s2=s.c_str(); - unsigned long h = 0; - for ( ; *s2; ++s2) - h = 5*h + *s2; - return size_t(h); - } - }; + template + class hash_map : public std::hash_map<_Key, + _Value, + hash<_Key>, + equal_to<_Key> > + {}; + + template + class hash_set : public std::hash_set<_Key, + hash<_Key>, + equal_to<_Key> > + {}; + + template + class hash_multimap : public std::hash_multimap<_Key, + _Value, + hash<_Key>, + equal_to<_Key> > + {}; + } #endif ============================================================ --- interner.hh a8d437360e4e6e069cb5ed9bea59a066cf975ea9 +++ interner.hh 70ca14f55628cab86911c21d846931cb64d3319d @@ -11,22 +11,11 @@ #include "hash_map.hh" #include "sanity.hh" -struct string_eq -{ - bool operator()(std::string const & a, - std::string const & b) const - { - return a == b; - } -}; - template struct interner { - typedef typename hashmap::hash_map hmap; + typedef typename hashmap::hash_map hmap; hmap fwd; std::vector rev; ============================================================ --- merkle_tree.hh ac7370ade9ce9d2acce480349671d52061eea41f +++ merkle_tree.hh b521fb7e79fb73eb780abc2225363917982b4e96 @@ -105,26 +105,26 @@ */ typedef std::pair merkle_node_id; namespace hashmap { - struct merkle_node_id_hash - { - string_hash sh; - size_t operator()(merkle_node_id const & m) const - { - return sh(m.first()) + m.second; - } - }; -} -struct merkle_node_id_eq -{ - bool operator()(merkle_node_id const & a, - merkle_node_id const & b) const + template<> + struct hash { - return a.second == b.second && a.first == b.first; - } -}; -typedef hashmap::hash_map merkle_table; + hash sh; + size_t operator()(merkle_node_id const & m) const + { + return sh(m.first()) + m.second; + } + }; + template<> + struct equal_to + { + bool operator()(merkle_node_id const & a, + merkle_node_id const & b) const + { + return a.second == b.second && a.first == b.first; + } + }; +} +typedef hashmap::hash_map merkle_table; size_t prefix_length_in_bits(size_t level); ============================================================ --- rcs_file.cc ae0f12cfaa2788a212bc9d3f1ec843ce8ba49cc8 +++ rcs_file.cc f5dde1d6e49f0472b11704c24d36a0bcb161f257 @@ -29,6 +29,7 @@ #include "rcs_file.hh" #include "sanity.hh" +#include #ifdef HAVE_MMAP struct ============================================================ --- rcs_import.cc 0de2b62e2c973f4c94592cff4990f0a43eb70294 +++ rcs_import.cc 38060f4ed9c1b336fb1467be0f2006e3d4aac487 @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -1082,7 +1083,7 @@ // have passed the window size while (!clusters.empty()) { - cluster_set::const_iterator j = clusters.begin(); + cluster_set::iterator j = clusters.begin(); if ((*j)->first_time + constants::cvs_window < i->time) { L(FL("expiring cluster\n")); ============================================================ --- unix/fs.cc e353582dd31c2d083e95fba1aa3c7321761a3843 +++ unix/fs.cc 8c6fe727ef9e240274689f7ef2d08836f73f703b @@ -9,6 +9,7 @@ #include #include #include +#include #include #include ============================================================ --- vocab.cc c3824a3441b679e4e8c2c8f29fa412bcf2d2d1c3 +++ vocab.cc 7cf1d84a1a30eebaeb5edfbb8c3a46d1598d56a4 @@ -161,9 +161,9 @@ struct symtab_impl { - typedef hashmap::hash_set hset; + typedef hashmap::hash_set hset; hset vals; - symtab_impl() : vals(1024) {} + symtab_impl() : vals() {} void clear() { vals.clear(); } std::string const & unique(std::string const & in) { ============================================================ --- xdelta.cc eba5a931daaa288450f3d69e927e662108bdc7e5 +++ xdelta.cc 21dd536e55a0e81ccd7c781eb692141782100cbf @@ -184,7 +184,7 @@ vector & delta) { string::size_type blocksz = 64; - match_table matches ((a.size() / blocksz) * 2); + match_table matches; init_match_table(a, blocksz, matches); if (b.size() < blocksz)