From: Bandan Das <bsd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH kvm-unit-tests] api: remove boost::thread dependency
Date: Tue, 09 May 2017 17:21:20 -0400 [thread overview]
Message-ID: <jpgefvxloa7.fsf@linux.bootlegged.copy> (raw)
In-Reply-To: <1494337233-7730-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Tue, 9 May 2017 15:40:33 +0200")
Paolo Bonzini <pbonzini@redhat.com> writes:
> Replace Boost threads with C++11. Both boost::ref and boost::thread::thread
> are not part of the standard C++ library.
>
> std::tr1::bind has also become std::bind in C++11.
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Bandan Das <bsd@redhat.com>
> ---
> api/dirty-log-perf.cc | 8 ++------
> api/dirty-log.cc | 19 ++++++++-----------
> x86/Makefile.common | 4 ++--
> 3 files changed, 12 insertions(+), 19 deletions(-)
>
> diff --git a/api/dirty-log-perf.cc b/api/dirty-log-perf.cc
> index 16990a6..89043b0 100644
> --- a/api/dirty-log-perf.cc
> +++ b/api/dirty-log-perf.cc
> @@ -2,7 +2,6 @@
> #include "exception.hh"
> #include "memmap.hh"
> #include "identity.hh"
> -#include <boost/thread/thread.hpp>
> #include <stdlib.h>
> #include <stdio.h>
> #include <sys/time.h>
> @@ -34,15 +33,12 @@ void write_mem(void* slot_head, int64_t nr_to_write, int64_t nr_pages)
> }
> }
>
> -using boost::ref;
> -using std::tr1::bind;
> -
> // Let the guest update nr_to_write pages selected from nr_pages pages.
> void do_guest_write(kvm::vcpu& vcpu, void* slot_head,
> int64_t nr_to_write, int64_t nr_pages)
> {
> - identity::vcpu guest_write_thread(vcpu, bind(write_mem, ref(slot_head),
> - nr_to_write, nr_pages));
> + identity::vcpu guest_write_thread(vcpu, std::bind(write_mem, slot_head,
> + nr_to_write, nr_pages));
> vcpu.run();
> }
>
> diff --git a/api/dirty-log.cc b/api/dirty-log.cc
> index 4e4bfc9..47fbac2 100644
> --- a/api/dirty-log.cc
> +++ b/api/dirty-log.cc
> @@ -2,7 +2,7 @@
> #include "exception.hh"
> #include "memmap.hh"
> #include "identity.hh"
> -#include <boost/thread/thread.hpp>
> +#include <thread>
> #include <stdlib.h>
> #include <stdio.h>
>
> @@ -46,9 +46,6 @@ void check_dirty_log(mem_slot& slot,
>
> }
>
> -using boost::ref;
> -using std::tr1::bind;
> -
> int test_main(int ac, char **av)
> {
> kvm::system sys;
> @@ -56,7 +53,7 @@ int test_main(int ac, char **av)
> mem_map memmap(vm);
> void* logged_slot_virt;
> posix_memalign(&logged_slot_virt, 4096, 4096);
> - int* shared_var = static_cast<int*>(logged_slot_virt);
> + volatile int* shared_var = static_cast<volatile int*>(logged_slot_virt);
> identity::hole hole(logged_slot_virt, 4096);
> identity::vm ident_vm(vm, memmap, hole);
> kvm::vcpu vcpu(vm, 0);
> @@ -65,13 +62,13 @@ int test_main(int ac, char **av)
> mem_slot logged_slot(memmap,
> reinterpret_cast<uintptr_t>(logged_slot_virt),
> 4096, logged_slot_virt);
> - boost::thread host_poll_thread(check_dirty_log, ref(logged_slot),
> - ref(running),
> - ref(shared_var), ref(nr_fail));
> + std::thread host_poll_thread(check_dirty_log, std::ref(logged_slot),
> + std::ref(running),
> + shared_var, std::ref(nr_fail));
> identity::vcpu guest_write_thread(vcpu,
> - bind(write_mem,
> - ref(running),
> - ref(shared_var)));
> + std::bind(write_mem,
> + std::ref(running),
> + shared_var));
> vcpu.run();
> host_poll_thread.join();
> printf("Dirty bitmap failures: %d\n", nr_fail);
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index fbab82c..ec50926 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -73,9 +73,9 @@ arch_clean:
> $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
> $(TEST_DIR)/.*.d lib/x86/.*.d
>
> -api/%.o: CFLAGS += -m32
> +api/%.o: CFLAGS += -m32 -std=gnu++11
>
> -api/%: LDLIBS += -lstdc++ -lboost_thread -lpthread -lrt
> +api/%: LDLIBS += -lstdc++ -lpthread -lrt
> api/%: LDFLAGS += -m32
>
> api/libapi.a: api/kvmxx.o api/identity.o api/exception.o api/memmap.o
prev parent reply other threads:[~2017-05-09 21:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 13:40 [PATCH kvm-unit-tests] api: remove boost::thread dependency Paolo Bonzini
2017-05-09 21:21 ` Bandan Das [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jpgefvxloa7.fsf@linux.bootlegged.copy \
--to=bsd@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox