[build] switch to c++11

Conflicts:
	Makefile.in
	chunker/cache_stream.cc
	chunker/cache_stream.h
	thin-provisioning/thin_archive.cc
	thin-provisioning/thin_show_duplicates.cc
	unit-tests/Makefile.in
This commit is contained in:
Joe Thornber
2016-02-04 09:02:42 +00:00
parent 639af9c3bf
commit 767c39cf71
14 changed files with 31 additions and 30 deletions

View File

@ -105,7 +105,7 @@ TOP_DIR:=@top_srcdir@
TOP_BUILDDIR:=@top_builddir@ TOP_BUILDDIR:=@top_builddir@
CFLAGS+=-g -Wall -O3 CFLAGS+=-g -Wall -O3
CFLAGS+=@LFS_FLAGS@ CFLAGS+=@LFS_FLAGS@
CXXFLAGS+=-g -Wall -fno-strict-aliasing -std=gnu++98 CXXFLAGS+=-g -Wall -fno-strict-aliasing -std=c++11
CXXFLAGS+=@CXXOPTIMISE_FLAG@ CXXFLAGS+=@CXXOPTIMISE_FLAG@
CXXFLAGS+=@CXXDEBUG_FLAG@ CXXFLAGS+=@CXXDEBUG_FLAG@
CXXFLAGS+=@CXX_STRERROR_FLAG@ CXXFLAGS+=@CXX_STRERROR_FLAG@

View File

@ -63,16 +63,16 @@ namespace {
//---------------------------------------------------------------- //----------------------------------------------------------------
std::auto_ptr<base::progress_monitor> std::unique_ptr<base::progress_monitor>
base::create_progress_bar(std::string const &title) base::create_progress_bar(std::string const &title)
{ {
return auto_ptr<progress_monitor>(new progress_bar(title)); return unique_ptr<progress_monitor>(new progress_bar(title));
} }
std::auto_ptr<base::progress_monitor> std::unique_ptr<base::progress_monitor>
base::create_quiet_progress_monitor() base::create_quiet_progress_monitor()
{ {
return auto_ptr<progress_monitor>(new quiet_progress()); return unique_ptr<progress_monitor>(new quiet_progress());
} }
//---------------------------------------------------------------- //----------------------------------------------------------------

View File

@ -15,8 +15,8 @@ namespace base {
virtual void update_percent(unsigned) = 0; virtual void update_percent(unsigned) = 0;
}; };
std::auto_ptr<progress_monitor> create_progress_bar(std::string const &title); std::unique_ptr<progress_monitor> create_progress_bar(std::string const &title);
std::auto_ptr<progress_monitor> create_quiet_progress_monitor(); std::unique_ptr<progress_monitor> create_quiet_progress_monitor();
} }
//---------------------------------------------------------------- //----------------------------------------------------------------

View File

@ -14,7 +14,7 @@ xml_parser::parse(std::string const &backup_file, bool quiet)
persistent_data::check_file_exists(backup_file); persistent_data::check_file_exists(backup_file);
ifstream in(backup_file.c_str(), ifstream::in); ifstream in(backup_file.c_str(), ifstream::in);
std::auto_ptr<base::progress_monitor> monitor = create_monitor(quiet); std::unique_ptr<base::progress_monitor> monitor = create_monitor(quiet);
size_t total = 0; size_t total = 0;
size_t input_length = get_file_length(backup_file); size_t input_length = get_file_length(backup_file);
@ -53,7 +53,7 @@ xml_parser::get_file_length(string const &file) const
return info.st_size; return info.st_size;
} }
auto_ptr<base::progress_monitor> unique_ptr<base::progress_monitor>
xml_parser::create_monitor(bool quiet) xml_parser::create_monitor(bool quiet)
{ {
if (!quiet && isatty(fileno(stdout))) if (!quiet && isatty(fileno(stdout)))

View File

@ -37,7 +37,7 @@ namespace xml_utils {
private: private:
size_t get_file_length(string const &file) const; size_t get_file_length(string const &file) const;
auto_ptr<base::progress_monitor> create_monitor(bool quiet); unique_ptr<base::progress_monitor> create_monitor(bool quiet);
XML_Parser parser_; XML_Parser parser_;
}; };

View File

@ -305,7 +305,7 @@ block_cache::find_unused_clean_block()
if (b.ref_count_) if (b.ref_count_)
continue; continue;
block_set_.remove_node(b); b.unlink_set();
b.unlink(); b.unlink();
return &b; return &b;
} }

View File

@ -117,6 +117,10 @@ namespace bcache {
bc_->release(*this); bc_->release(*this);
} }
void unlink_set() {
set_hook_.unlink();
}
void unlink() { void unlink() {
list_hook_.unlink(); list_hook_.unlink();
} }
@ -131,7 +135,7 @@ namespace bcache {
void *data_; void *data_;
bi::list_member_hook<bi::link_mode<bi::auto_unlink>> list_hook_; bi::list_member_hook<bi::link_mode<bi::auto_unlink>> list_hook_;
bi::set_member_hook<> set_hook_; bi::set_member_hook<bi::link_mode<bi::auto_unlink>> set_hook_;
unsigned ref_count_; unsigned ref_count_;
@ -142,8 +146,6 @@ namespace bcache {
validator::ptr v_; validator::ptr v_;
}; };
<<<<<<< HEAD
=======
struct cmp_index { struct cmp_index {
bool operator()(block_address index, block const &b) const { bool operator()(block_address index, block const &b) const {
return index > b.index_; return index > b.index_;
@ -192,7 +194,6 @@ namespace bcache {
block *b_; block *b_;
}; };
>>>>>>> 7fadc34... [block-cache] convert to use boost::intrusive rather than kernel style lists.
//-------------------------------- //--------------------------------
block_cache(int fd, sector_t block_size, block_cache(int fd, sector_t block_size,
@ -282,7 +283,7 @@ namespace bcache {
block_list io_pending_; block_list io_pending_;
typedef bi::member_hook<block, typedef bi::member_hook<block,
bi::set_member_hook<>, bi::set_member_hook<bi::link_mode<bi::auto_unlink>>,
&block::set_hook_> block_option; &block::set_hook_> block_option;
typedef bi::set<block, block_option, typedef bi::set<block, block_option,
bi::constant_time_size<false>> block_set; bi::constant_time_size<false>> block_set;

View File

@ -32,7 +32,7 @@ namespace {
return info.st_size; return info.st_size;
} }
auto_ptr<progress_monitor> create_monitor(bool quiet) { unique_ptr<progress_monitor> create_monitor(bool quiet) {
if (!quiet && isatty(fileno(stdout))) if (!quiet && isatty(fileno(stdout)))
return create_progress_bar("Restoring"); return create_progress_bar("Restoring");
else else
@ -70,7 +70,7 @@ namespace {
check_file_exists(*fs.input); check_file_exists(*fs.input);
ifstream in(fs.input->c_str(), ifstream::in); ifstream in(fs.input->c_str(), ifstream::in);
auto_ptr<progress_monitor> monitor = create_monitor(fs.quiet); unique_ptr<progress_monitor> monitor = create_monitor(fs.quiet);
parse_xml(in, restorer, get_file_length(*fs.input), *monitor); parse_xml(in, restorer, get_file_length(*fs.input), *monitor);
} catch (std::exception &e) { } catch (std::exception &e) {

View File

@ -142,7 +142,7 @@ namespace {
bool device_exists(thin_dev_t dev) const { bool device_exists(thin_dev_t dev) const {
uint64_t key[1] = {dev}; uint64_t key[1] = {dev};
device_tree::maybe_value v = md_->details_->lookup(key); device_tree::maybe_value v = md_->details_->lookup(key);
return v; return !!v;
} }
metadata::ptr md_; metadata::ptr md_;

View File

@ -232,7 +232,7 @@ bool
thin_pool::device_exists(thin_dev_t dev) const thin_pool::device_exists(thin_dev_t dev) const
{ {
uint64_t key[1] = {dev}; uint64_t key[1] = {dev};
return md_->details_->lookup(key); return !!md_->details_->lookup(key);
} }
//---------------------------------------------------------------- //----------------------------------------------------------------

View File

@ -129,7 +129,7 @@ TEST_F(BtreeTests, insert_works)
tree->insert(key, value); tree->insert(key, value);
btree<1, uint64_traits>::maybe_value l = tree->lookup(key); btree<1, uint64_traits>::maybe_value l = tree->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(i)); ASSERT_THAT(*l, Eq(i));
} }
@ -153,7 +153,7 @@ TEST_F(BtreeTests, insert_does_not_insert_imaginary_values)
tree->insert(key, value); tree->insert(key, value);
l = tree->lookup(key); l = tree->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(100u)); ASSERT_THAT(*l, Eq(100u));
key[0] = 1; key[0] = 1;
@ -183,7 +183,7 @@ TEST_F(BtreeTests, clone)
uint64_t value = i * 7; uint64_t value = i * 7;
l = tree->lookup(key); l = tree->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(value)); ASSERT_THAT(*l, Eq(value));
} }
@ -200,11 +200,11 @@ TEST_F(BtreeTests, clone)
uint64_t value = i * 7; uint64_t value = i * 7;
l = tree->lookup(key); l = tree->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(value)); ASSERT_THAT(*l, Eq(value));
l = copy->lookup(key); l = copy->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(value)); ASSERT_THAT(*l, Eq(value));
} }
@ -216,7 +216,7 @@ TEST_F(BtreeTests, clone)
ASSERT_FALSE(l); ASSERT_FALSE(l);
l = copy->lookup(key); l = copy->lookup(key);
ASSERT_TRUE(l); ASSERT_TRUE(!!l);
ASSERT_THAT(*l, Eq(value)); ASSERT_THAT(*l, Eq(value));
} }

View File

@ -36,7 +36,7 @@ namespace {
TEST_F(RunSetTests, create) TEST_F(RunSetTests, create)
{ {
auto_ptr<run_set<unsigned> > rs(new run_set<unsigned>()); unique_ptr<run_set<unsigned> > rs(new run_set<unsigned>());
} }
TEST_F(RunSetTests, add_single_blocks) TEST_F(RunSetTests, add_single_blocks)

View File

@ -101,7 +101,7 @@ namespace {
for (unsigned i = 0; i < NR_BLOCKS; i++) { for (unsigned i = 0; i < NR_BLOCKS; i++) {
boost::optional<block_address> mb = sm->new_block(); boost::optional<block_address> mb = sm->new_block();
ASSERT_TRUE(mb); ASSERT_TRUE(!!mb);
ASSERT_THAT(sm->get_nr_free(), Eq(NR_BLOCKS - i - 1)); ASSERT_THAT(sm->get_nr_free(), Eq(NR_BLOCKS - i - 1));
} }
@ -137,7 +137,7 @@ namespace {
void test_not_allocated_twice(space_map::ptr sm) { void test_not_allocated_twice(space_map::ptr sm) {
boost::optional<block_address> mb = sm->new_block(); boost::optional<block_address> mb = sm->new_block();
ASSERT_TRUE(mb); ASSERT_TRUE(!!mb);
for (;;) { for (;;) {
boost::optional<block_address> b = sm->new_block(); boost::optional<block_address> b = sm->new_block();

View File

@ -111,7 +111,7 @@ namespace test {
throw std::runtime_error("system failed"); throw std::runtime_error("system failed");
} }
std::auto_ptr<with_directory> dir_; std::unique_ptr<with_directory> dir_;
}; };
//-------------------------------- //--------------------------------