[ovs-dev] [PATCH] ovs-atomic: Report error for contradictory configuration.

Ben Pfaff blp at ovn.org
Wed May 3 18:05:53 UTC 2017


A user reported that GCC 5.x was using the atomic fallback for GCC 4.x
because the test
     #elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
didn't include GCC 5.  However, GCC 5+ has <stdatomic.h> and shouldn't use
any of the GCC-specific cases at all.  I think that this user was actually
pulling our atomics out into third-party code that probably didn't define
HAVE_STDATOMIC_H properly, so this commit both avoids that problem for
them in the future and clarifies the intent of the ovs-atomic header.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/ovs-atomic.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h
index c8e616cb4c37..f1f2c384f1cd 100644
--- a/lib/ovs-atomic.h
+++ b/lib/ovs-atomic.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2013, 2014, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -325,6 +325,8 @@
         #include "ovs-atomic-clang.h"
     #elif HAVE_STDATOMIC_H
         #include "ovs-atomic-c11.h"
+    #elif __GNUC__ >= 5
+        #error "GCC 5+ should have <stdatomic.h>"
     #elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 7
         #include "ovs-atomic-gcc4.7+.h"
     #elif __GNUC__ && defined(__x86_64__)
-- 
2.10.2



More information about the dev mailing list