[ovs-dev] [clang 1/4] ovs-thread: Mark lock and unlock functions as no_thread_safety_analysis.

Ethan Jackson ethan at nicira.com
Wed Aug 21 21:35:14 UTC 2013


Acked-by: Ethan Jackson <ethan at nicira.com>


On Wed, Aug 21, 2013 at 1:01 PM, Ben Pfaff <blp at nicira.com> wrote:
> 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 at nicira.com>
> ---
>  lib/compiler.h   |    3 +++
>  lib/ovs-thread.c |    3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/lib/compiler.h b/lib/compiler.h
> index 519b832..fb4d46c 100644
> --- a/lib/compiler.h
> +++ b/lib/compiler.h
> @@ -128,6 +128,8 @@
>  #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(...)
> @@ -145,6 +147,7 @@
>  #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
> diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
> index e9366e2..b3a87bb 100644
> --- a/lib/ovs-thread.c
> +++ b/lib/ovs-thread.c
> @@ -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; \
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list