From f50ac3549d6a7f1199fa012e4b03f581bc8d305b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Jun 2018 12:54:47 +0200 Subject: core, modules: modernize syntax only Use more C++17 features where this helps any. --- logic/pipeline.cpp | 18 +++++++----------- logic/pipeline.hpp | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'logic') diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index c36d1781..6c00acb0 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -638,29 +638,25 @@ void pipeline::set_zero(bool value) { set(f_zero, value); } void pipeline::toggle_zero() { negate(f_zero); } void pipeline::toggle_enabled() { negate(f_enabled_p); } -void bits::set(flags flag_, bool val_) +void bits::set(flags flag, bool val) { - const unsigned flag = unsigned(flag_); - const unsigned val = unsigned(val_); + const unsigned flag_ = unsigned(flag); + const unsigned val_ = unsigned(val); unsigned b_ = 0; for (;;) - { - if (b.compare_exchange_strong(b_, unsigned((b_ & ~flag) | (flag * val)))) + if (b.compare_exchange_weak(b_, unsigned((b_ & ~flag_) | (flag_ * val_)))) break; - } } -void bits::negate(flags flag_) +void bits::negate(flags flag) { - const unsigned flag = unsigned(flag_); + const unsigned flag_= flag; unsigned b_ = 0; for (;;) - { - if (b.compare_exchange_strong(b_, b_ ^ flag)) + if (b.compare_exchange_weak(b_, b_ ^ flag_)) break; - } } bool bits::get(flags flag) diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 606a7bf6..5db2a753 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -74,8 +74,8 @@ struct OTR_LOGIC_EXPORT bits std::atomic b; - void set(flags flag_, bool val); - void negate(flags flag_); + void set(flags flag, bool val); + void negate(flags flag); bool get(flags flag); bits(); }; -- cgit v1.2.3