[ovs-dev] [PATCH] ovs-atomic: Add C++ compatible implementation.
blp at ovn.org
Tue Oct 17 23:53:34 UTC 2017
On Tue, Oct 17, 2017 at 02:56:58PM -0700, Yi-Hung Wei wrote:
> On Tue, Oct 17, 2017 at 1:35 PM, Ben Pfaff <blp at ovn.org> wrote:
> > On Mon, Oct 16, 2017 at 05:08:34PM -0700, Yi-Hung Wei wrote:
> >> Thanks for the patch. I can verify that it works great with C++14 support.
> >> One minor problem is that it may run into some compiler errors if the
> >> C++ compiler does not support C++14 or the support is not enabled.
> >> There was a patch that hit similar issue:
> >> https://patchwork.ozlabs.org/patch/813112/
> > This is a good point. What if we fold in the following incremental?
> Thanks, I think it resolves the aforementioned issue. Just a few minor
> picks below.
> Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>
> > I'm also appending the full patch.
> > diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h
> > index 5e4a9c1775b3..c5299fd08512 100644
> > --- a/lib/ovs-atomic.h
> > +++ b/lib/ovs-atomic.h
> > @@ -325,11 +325,11 @@
> > #include "ovs-atomic-pthreads.h"
> > #elif __has_extension(c_atomic)
> > #include "ovs-atomic-clang.h"
> > - #elif defined(__cplusplus) && HAVE_ATOMIC
> > + #elif HAVE_ATOMIC && __cplusplus >= 201103L
> > #include "ovs-atomic-c++.h"
> > - #elif HAVE_STDATOMIC_H
> > + #elif HAVE_STDATOMIC_H && !defined(__cplusplus)
> > #include "ovs-atomic-c11.h"
> > - #elif __GNUC__ >= 5
> > + #elif __GNUC__ >= 5 && !defined(__cplusplus)
> > #error "GCC 5+ should have <stdatomic.h>"
> > #elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
> > #include "ovs-atomic-gcc4.7+.h"
> Not sure if it's worth to append this changes.
> - #elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
> + #elif (defined(__cplusplus) && __GNUC__ >= 5) || \
> + (__GNUC__ >= 4 && __GNUC_MINOR__ >= 7)
Thanks. I decided to use:
#elif __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 7)
I fixed up the other typos you pointed out (thanks!) and applied this to
More information about the dev