Get tools building with g++ 4.8.1

This commit is contained in:
Joe Thornber 2013-06-25 13:48:02 +01:00
parent 7b603183df
commit eb8d4c6f0b
11 changed files with 45 additions and 51 deletions

View File

@ -76,7 +76,6 @@ namespace persistent_data {
namespace btree_detail { namespace btree_detail {
using namespace base; using namespace base;
using namespace std; using namespace std;
using namespace boost;
uint32_t const BTREE_CSUM_XOR = 121107; uint32_t const BTREE_CSUM_XOR = 121107;
@ -164,7 +163,7 @@ namespace persistent_data {
// Various searches // Various searches
int bsearch(uint64_t key, int want_hi) const; int bsearch(uint64_t key, int want_hi) const;
optional<unsigned> exact_search(uint64_t key) const; boost::optional<unsigned> exact_search(uint64_t key) const;
int lower_bound(uint64_t key) const; int lower_bound(uint64_t key) const;
template <typename RefCounter> template <typename RefCounter>
@ -211,7 +210,7 @@ namespace persistent_data {
const_cast<unsigned char *>(b.data().raw()))); const_cast<unsigned char *>(b.data().raw())));
} }
class ro_spine : private noncopyable { class ro_spine : private boost::noncopyable {
public: public:
ro_spine(transaction_manager::ptr tm, ro_spine(transaction_manager::ptr tm,
typename block_manager<>::validator::ptr v) typename block_manager<>::validator::ptr v)
@ -232,7 +231,7 @@ namespace persistent_data {
std::list<block_manager<>::read_ref> spine_; std::list<block_manager<>::read_ref> spine_;
}; };
class shadow_spine : private noncopyable { class shadow_spine : private boost::noncopyable {
public: public:
typedef transaction_manager::read_ref read_ref; typedef transaction_manager::read_ref read_ref;
typedef transaction_manager::write_ref write_ref; typedef transaction_manager::write_ref write_ref;

View File

@ -294,17 +294,17 @@ namespace persistent_data {
} }
template <typename ValueTraits> template <typename ValueTraits>
optional<unsigned> boost::optional<unsigned>
node_ref<ValueTraits>::exact_search(uint64_t key) const node_ref<ValueTraits>::exact_search(uint64_t key) const
{ {
int i = bsearch(key, 0); int i = bsearch(key, 0);
if (i < 0 || static_cast<unsigned>(i) >= get_nr_entries()) if (i < 0 || static_cast<unsigned>(i) >= get_nr_entries())
return optional<unsigned>(); return boost::optional<unsigned>();
if (key != key_at(i)) if (key != key_at(i))
return optional<unsigned>(); return boost::optional<unsigned>();
return optional<unsigned>(i); return boost::optional<unsigned>(i);
} }
template <typename ValueTraits> template <typename ValueTraits>
@ -405,14 +405,14 @@ namespace persistent_data {
namespace { namespace {
template <typename ValueTraits> template <typename ValueTraits>
struct lower_bound_search { struct lower_bound_search {
static optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) { static boost::optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) {
return n.lower_bound(key); return n.lower_bound(key);
} }
}; };
template <typename ValueTraits> template <typename ValueTraits>
struct exact_search { struct exact_search {
static optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) { static boost::optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) {
return n.exact_search(key); return n.exact_search(key);
} }
}; };
@ -428,7 +428,7 @@ namespace persistent_data {
block_address root = root_; block_address root = root_;
for (unsigned level = 0; level < Levels - 1; ++level) { for (unsigned level = 0; level < Levels - 1; ++level) {
optional<block_address> mroot = boost::optional<block_address> mroot =
lookup_raw<block_traits, lower_bound_search<block_traits> >(spine, root, key[level]); lookup_raw<block_traits, lower_bound_search<block_traits> >(spine, root, key[level]);
if (!mroot) if (!mroot)
return maybe_value(); return maybe_value();
@ -535,7 +535,7 @@ namespace persistent_data {
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits, typename Search> template <typename ValueTraits, typename Search>
optional<typename ValueTraits::value_type> boost::optional<typename ValueTraits::value_type>
btree<Levels, _>:: btree<Levels, _>::
lookup_raw(ro_spine &spine, block_address block, uint64_t key) const lookup_raw(ro_spine &spine, block_address block, uint64_t key) const
{ {
@ -546,18 +546,18 @@ namespace persistent_data {
spine.step(block); spine.step(block);
node_ref<ValueTraits> leaf = spine.template get_node<ValueTraits>(); node_ref<ValueTraits> leaf = spine.template get_node<ValueTraits>();
optional<unsigned> mi; boost::optional<unsigned> mi;
if (leaf.get_type() == btree_detail::LEAF) { if (leaf.get_type() == btree_detail::LEAF) {
mi = Search::search(leaf, key); mi = Search::search(leaf, key);
if (!mi) if (!mi)
return optional<leaf_type>(); return boost::optional<leaf_type>();
return optional<leaf_type>(leaf.value_at(*mi)); return boost::optional<leaf_type>(leaf.value_at(*mi));
} }
mi = leaf.lower_bound(key); mi = leaf.lower_bound(key);
if (!mi || *mi < 0) if (!mi || *mi < 0)
return optional<leaf_type>(); return boost::optional<leaf_type>();
node_ref<block_traits> internal = spine.template get_node<block_traits>(); node_ref<block_traits> internal = spine.template get_node<block_traits>();
block = internal.value_at(*mi); block = internal.value_at(*mi);
@ -803,7 +803,7 @@ namespace persistent_data {
node_location loc2(loc); node_location loc2(loc);
loc2.push_key(o.key_at(i)); loc2.push_key(o.key_at(i));
loc2.key = optional<uint64_t>(); loc2.key = boost::optional<uint64_t>();
walk_tree(v, loc2, o.value_at(i)); walk_tree(v, loc2, o.value_at(i));
} }

View File

@ -97,7 +97,7 @@ namespace persistent_data {
check_max_entries(n) && check_max_entries(n) &&
check_nr_entries(n, loc.is_sub_root()) && check_nr_entries(n, loc.is_sub_root()) &&
check_ordered_keys(n) && check_ordered_keys(n) &&
check_parent_key(loc.is_sub_root() ? optional<uint64_t>() : loc.key, n)) { check_parent_key(loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key, n)) {
if (loc.is_sub_root()) if (loc.is_sub_root())
new_root(loc.level()); new_root(loc.level());
@ -115,7 +115,7 @@ namespace persistent_data {
check_max_entries(n) && check_max_entries(n) &&
check_nr_entries(n, loc.is_sub_root()) && check_nr_entries(n, loc.is_sub_root()) &&
check_ordered_keys(n) && check_ordered_keys(n) &&
check_parent_key(loc.is_sub_root() ? optional<uint64_t>() : loc.key, n)) { check_parent_key(loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key, n)) {
if (loc.is_sub_root()) if (loc.is_sub_root())
new_root(loc.level()); new_root(loc.level());

View File

@ -206,7 +206,7 @@ namespace persistent_data {
check_max_entries(n) && check_max_entries(n) &&
check_nr_entries(n, loc.is_sub_root()) && check_nr_entries(n, loc.is_sub_root()) &&
check_ordered_keys(n) && check_ordered_keys(n) &&
check_parent_key(loc.is_sub_root() ? optional<uint64_t>() : loc.key, n)) { check_parent_key(loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key, n)) {
if (loc.is_sub_root()) if (loc.is_sub_root())
new_root(loc.level()); new_root(loc.level());
@ -225,7 +225,7 @@ namespace persistent_data {
check_max_entries(n) && check_max_entries(n) &&
check_nr_entries(n, loc.is_sub_root()) && check_nr_entries(n, loc.is_sub_root()) &&
check_ordered_keys(n) && check_ordered_keys(n) &&
check_parent_key(loc.is_sub_root() ? optional<uint64_t>() : loc.key, n)) { check_parent_key(loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key, n)) {
if (loc.is_sub_root()) if (loc.is_sub_root())
new_root(loc.level()); new_root(loc.level());

View File

@ -26,12 +26,10 @@
#include "persistent-data/math_utils.h" #include "persistent-data/math_utils.h"
#include "persistent-data/transaction_manager.h" #include "persistent-data/transaction_manager.h"
using namespace boost;
using namespace persistent_data; using namespace persistent_data;
using namespace std; using namespace std;
using namespace sm_disk_detail; using namespace sm_disk_detail;
//---------------------------------------------------------------- //----------------------------------------------------------------
namespace { namespace {
@ -322,7 +320,7 @@ namespace {
unsigned bit_begin = (index == begin_index) ? (begin % ENTRIES_PER_BLOCK) : 0; unsigned bit_begin = (index == begin_index) ? (begin % ENTRIES_PER_BLOCK) : 0;
unsigned bit_end = (index == end_index - 1) ? (end % ENTRIES_PER_BLOCK) : ENTRIES_PER_BLOCK; unsigned bit_end = (index == end_index - 1) ? (end % ENTRIES_PER_BLOCK) : ENTRIES_PER_BLOCK;
optional<unsigned> maybe_b = bm.find_free(bit_begin, bit_end); boost::optional<unsigned> maybe_b = bm.find_free(bit_begin, bit_end);
if (maybe_b) { if (maybe_b) {
block_address b = (index * ENTRIES_PER_BLOCK) + *maybe_b; block_address b = (index * ENTRIES_PER_BLOCK) + *maybe_b;
return b; return b;
@ -474,7 +472,7 @@ namespace {
ref_t lookup_ref_count(block_address b) const { ref_t lookup_ref_count(block_address b) const {
uint64_t key[1] = {b}; uint64_t key[1] = {b};
optional<ref_t> mvalue = ref_counts_.lookup(key); boost::optional<ref_t> mvalue = ref_counts_.lookup(key);
if (!mvalue) if (!mvalue)
throw runtime_error("ref count not in tree"); throw runtime_error("ref count not in tree");
return *mvalue; return *mvalue;
@ -572,7 +570,7 @@ namespace {
virtual index_entry find_ie(block_address ie_index) const { virtual index_entry find_ie(block_address ie_index) const {
uint64_t key[1] = {ie_index}; uint64_t key[1] = {ie_index};
optional<index_entry> mindex = bitmaps_.lookup(key); boost::optional<index_entry> mindex = bitmaps_.lookup(key);
if (!mindex) if (!mindex)
throw runtime_error("Couldn't lookup bitmap"); throw runtime_error("Couldn't lookup bitmap");

View File

@ -189,9 +189,9 @@ namespace {
void void
thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, bool repair) thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, bool repair)
{ {
optional<uint64_t> md_snap = md->sb_.metadata_snap_ ? boost::optional<uint64_t> md_snap = md->sb_.metadata_snap_ ?
optional<uint64_t>(md->sb_.metadata_snap_) : boost::optional<uint64_t>(md->sb_.metadata_snap_) :
optional<uint64_t>(); boost::optional<uint64_t>();
e->begin_superblock("", md->sb_.time_, e->begin_superblock("", md->sb_.time_,
md->sb_.trans_id_, md->sb_.trans_id_,

View File

@ -19,7 +19,6 @@
#include "thin-provisioning/restore_emitter.h" #include "thin-provisioning/restore_emitter.h"
#include "thin-provisioning/superblock.h" #include "thin-provisioning/superblock.h"
using namespace boost;
using namespace std; using namespace std;
using namespace thin_provisioning; using namespace thin_provisioning;
@ -46,11 +45,11 @@ namespace {
uint64_t trans_id, uint64_t trans_id,
uint32_t data_block_size, uint32_t data_block_size,
uint64_t nr_data_blocks, uint64_t nr_data_blocks,
optional<uint64_t> metadata_snap) { boost::optional<uint64_t> metadata_snap) {
in_superblock_ = true; in_superblock_ = true;
nr_data_blocks_ = nr_data_blocks; nr_data_blocks_ = nr_data_blocks;
superblock &sb = md_->sb_; superblock &sb = md_->sb_;
memcpy(&sb.uuid_, &uuid, sizeof(&sb.uuid_)); memcpy(&sb.uuid_, &uuid, sizeof(sb.uuid_));
sb.time_ = time; sb.time_ = time;
sb.trans_id_ = trans_id; sb.trans_id_ = trans_id;
sb.data_block_size_ = data_block_size; sb.data_block_size_ = data_block_size;
@ -83,7 +82,7 @@ namespace {
md_->details_->insert(key, details); md_->details_->insert(key, details);
current_mapping_ = empty_mapping_->clone(); current_mapping_ = empty_mapping_->clone();
current_device_ = optional<uint32_t>(dev); current_device_ = boost::optional<uint32_t>(dev);
} }
virtual void end_device() { virtual void end_device() {
@ -92,7 +91,7 @@ namespace {
md_->mappings_top_level_->insert(key, current_mapping_->get_root()); md_->mappings_top_level_->insert(key, current_mapping_->get_root());
md_->mappings_->set_root(md_->mappings_top_level_->get_root()); // FIXME: ugly md_->mappings_->set_root(md_->mappings_top_level_->get_root()); // FIXME: ugly
current_device_ = optional<uint32_t>(); current_device_ = boost::optional<uint32_t>();
} }
virtual void begin_named_mapping(std::string const &name) { virtual void begin_named_mapping(std::string const &name) {
@ -147,7 +146,7 @@ namespace {
metadata::ptr md_; metadata::ptr md_;
bool in_superblock_; bool in_superblock_;
block_address nr_data_blocks_; block_address nr_data_blocks_;
optional<uint32_t> current_device_; boost::optional<uint32_t> current_device_;
single_mapping_tree::ptr current_mapping_; single_mapping_tree::ptr current_mapping_;
single_mapping_tree::ptr empty_mapping_; single_mapping_tree::ptr empty_mapping_;
}; };

View File

@ -73,7 +73,7 @@ void
thin::set_snapshot_time(uint32_t time) thin::set_snapshot_time(uint32_t time)
{ {
uint64_t key[1] = { dev_ }; uint64_t key[1] = { dev_ };
optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key); boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
if (!mdetail) if (!mdetail)
throw runtime_error("no such device"); throw runtime_error("no such device");
@ -85,7 +85,7 @@ block_address
thin::get_mapped_blocks() const thin::get_mapped_blocks() const
{ {
uint64_t key[1] = { dev_ }; uint64_t key[1] = { dev_ };
optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key); boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
if (!mdetail) if (!mdetail)
throw runtime_error("no such device"); throw runtime_error("no such device");
@ -96,7 +96,7 @@ void
thin::set_mapped_blocks(block_address count) thin::set_mapped_blocks(block_address count)
{ {
uint64_t key[1] = { dev_ }; uint64_t key[1] = { dev_ };
optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key); boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
if (!mdetail) if (!mdetail)
throw runtime_error("no such device"); throw runtime_error("no such device");
@ -138,7 +138,7 @@ thin_pool::create_snap(thin_dev_t dev, thin_dev_t origin)
uint64_t snap_key[1] = {dev}; uint64_t snap_key[1] = {dev};
uint64_t origin_key[1] = {origin}; uint64_t origin_key[1] = {origin};
optional<uint64_t> mtree_root = md_->mappings_top_level_->lookup(origin_key); boost::optional<uint64_t> mtree_root = md_->mappings_top_level_->lookup(origin_key);
if (!mtree_root) if (!mtree_root)
throw std::runtime_error("unknown origin"); throw std::runtime_error("unknown origin");
@ -186,7 +186,7 @@ thin_pool::get_metadata_snap() const
block_address block_address
thin_pool::alloc_data_block() thin_pool::alloc_data_block()
{ {
optional<block_address> mb = md_->data_sm_->new_block(); boost::optional<block_address> mb = md_->data_sm_->new_block();
if (!mb) if (!mb)
throw runtime_error("couldn't allocate new block"); throw runtime_error("couldn't allocate new block");
@ -221,7 +221,7 @@ thin::ptr
thin_pool::open_thin(thin_dev_t dev) thin_pool::open_thin(thin_dev_t dev)
{ {
uint64_t key[1] = {dev}; uint64_t key[1] = {dev};
optional<device_tree_detail::device_details> mdetails = md_->details_->lookup(key); boost::optional<device_tree_detail::device_details> mdetails = md_->details_->lookup(key);
if (!mdetails) if (!mdetails)
throw runtime_error("no such device"); throw runtime_error("no such device");

View File

@ -27,7 +27,6 @@
#include <stdexcept> #include <stdexcept>
#include <string.h> #include <string.h>
using namespace boost;
using namespace std; using namespace std;
using namespace thin_provisioning; using namespace thin_provisioning;
@ -51,7 +50,7 @@ namespace {
uint64_t trans_id, uint64_t trans_id,
uint32_t data_block_size, uint32_t data_block_size,
uint64_t nr_data_blocks, uint64_t nr_data_blocks,
optional<uint64_t> metadata_snap) { boost::optional<uint64_t> metadata_snap) {
indent(); indent();
out_ << "<superblock uuid=\"" << uuid << "\"" out_ << "<superblock uuid=\"" << uuid << "\""
<< " time=\"" << time << "\"" << " time=\"" << time << "\""
@ -178,17 +177,17 @@ namespace {
throw runtime_error(out.str()); throw runtime_error(out.str());
} }
return lexical_cast<T>(it->second); return boost::lexical_cast<T>(it->second);
} }
template <typename T> template <typename T>
optional<T> get_opt_attr(attributes const &attr, string const &key) { boost::optional<T> get_opt_attr(attributes const &attr, string const &key) {
typedef optional<T> rtype; typedef boost::optional<T> rtype;
attributes::const_iterator it = attr.find(key); attributes::const_iterator it = attr.find(key);
if (it == attr.end()) if (it == attr.end())
return rtype(); return rtype();
return rtype(lexical_cast<T>(it->second)); return rtype(boost::lexical_cast<T>(it->second));
} }
void parse_superblock(emitter *e, attributes const &attr) { void parse_superblock(emitter *e, attributes const &attr) {

View File

@ -24,7 +24,6 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
using namespace boost;
using namespace persistent_data; using namespace persistent_data;
using namespace testing; using namespace testing;

View File

@ -314,7 +314,7 @@ namespace {
transaction_manager::ptr tm_; transaction_manager::ptr tm_;
thing_traits::ref_counter rc_; thing_traits::ref_counter rc_;
optional<btree_layout> layout_; boost::optional<btree_layout> layout_;
value_visitor_mock value_visitor_; value_visitor_mock value_visitor_;
damage_visitor_mock damage_visitor_; damage_visitor_mock damage_visitor_;
@ -578,8 +578,8 @@ TEST_F(BTreeDamageVisitorTests, damaged_internal)
node_info n = layout_->random_node(is_internal); node_info n = layout_->random_node(is_internal);
optional<block_address> begin = n.keys.begin_; boost::optional<block_address> begin = n.keys.begin_;
optional<block_address> end = n.keys.end_; boost::optional<block_address> end = n.keys.end_;
trash_block(n.b); trash_block(n.b);