Skip to content

Commit

Permalink
ovs-atomic: Prefer Clang intrinsics over <stdatomic.h>.
Browse files Browse the repository at this point in the history
On my Debian "jessie" system, <stdatomic.h> provided by GCC 4.9 is busted
when Clang 3.5 tries to use it.  Even a trivial program like this:

    #include <stdatomic.h>

    void
    foo(void)
    {
         _Atomic(int) x;
         atomic_fetch_add(&x, 1);
}

yields:

     atomic.c:7:5: error: address argument to atomic operation must be a
        pointer to integer or pointer ('_Atomic(int) *' invalid)

The Clang-specific version of ovs-atomic.h stills works, though, so this
commit works around the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
  • Loading branch information
blp committed Jul 2, 2015
1 parent 6b05f2f commit 5c62757
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ovs-atomic.h
Expand Up @@ -248,10 +248,10 @@
#if __CHECKER__
/* sparse doesn't understand some GCC extensions we use. */
#include "ovs-atomic-pthreads.h"
#elif HAVE_STDATOMIC_H
#include "ovs-atomic-c11.h"
#elif __has_extension(c_atomic)
#include "ovs-atomic-clang.h"
#elif HAVE_STDATOMIC_H
#include "ovs-atomic-c11.h"
#elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
#include "ovs-atomic-gcc4.7+.h"
#elif HAVE_GCC4_ATOMICS
Expand Down

0 comments on commit 5c62757

Please sign in to comment.