Re: [PATCH kvm-unit-tests] api: remove boost::thread dependency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paolo Bonzini <pbonzini@xxxxxxxxxx> 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@xxxxxxxxxx>

Tested-by: Bandan Das <bsd@xxxxxxxxxx>

> ---
>  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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux