ovs-thread: Mark lock and unlock functions as no_thread_safety_analysis.
authorBen Pfaff <blp@nicira.com>
Wed, 21 Aug 2013 18:24:49 +0000 (11:24 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 22 Aug 2013 16:41:48 +0000 (09:41 -0700)
I don't see any other way to make Clang realize that these are the real
mutex implementation functions.

I first noticed these warnings with Clang 1:3.4~svn188890-1~exp1.
I previously used version 1:3.4~svn187484-1~exp1.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
lib/compiler.h
lib/ovs-thread.c

index 519b832..fb4d46c 100644 (file)
 #define OVS_EXCLUDED(...) __attribute__((locks_excluded(__VA_ARGS__)))
 #define OVS_ACQ_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__)))
 #define OVS_ACQ_AFTER(...) __attribute__((acquired_after(__VA_ARGS__)))
+#define OVS_NO_THREAD_SAFETY_ANALYSIS \
+    __attribute__((no_thread_safety_analysis))
 #else  /* not Clang */
 #define OVS_LOCKABLE
 #define OVS_REQ_RDLOCK(...)
 #define OVS_RELEASES(...)
 #define OVS_ACQ_BEFORE(...)
 #define OVS_ACQ_AFTER(...)
+#define OVS_NO_THREAD_SAFETY_ANALYSIS
 #endif
 
 /* ISO C says that a C implementation may choose any integer type for an enum
index e9366e2..b3a87bb 100644 (file)
@@ -47,6 +47,7 @@ static bool multithreaded;
     void \
     ovs_##TYPE##_##FUN##_at(const struct ovs_##TYPE *l_, \
                             const char *where) \
+        OVS_NO_THREAD_SAFETY_ANALYSIS \
     { \
         struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
         int error = pthread_##TYPE##_##FUN(&l->lock); \
@@ -63,6 +64,7 @@ LOCK_FUNCTION(rwlock, wrlock);
     int \
     ovs_##TYPE##_##FUN##_at(const struct ovs_##TYPE *l_, \
                             const char *where) \
+        OVS_NO_THREAD_SAFETY_ANALYSIS \
     { \
         struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
         int error = pthread_##TYPE##_##FUN(&l->lock); \
@@ -81,6 +83,7 @@ TRY_LOCK_FUNCTION(rwlock, trywrlock);
 #define UNLOCK_FUNCTION(TYPE, FUN) \
     void \
     ovs_##TYPE##_##FUN(const struct ovs_##TYPE *l_) \
+        OVS_NO_THREAD_SAFETY_ANALYSIS \
     { \
         struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
         int error; \