[ltt-dev] [PATCH v3 2/2] api: reimplement BUILD_BUG_ON in compiler.h

Mathieu Desnoyers compudj at krystal.dyndns.org
Wed Aug 17 05:32:14 EDT 2011


* Paolo Bonzini (pbonzini at redhat.com) wrote:
> Even though it's just two lines of code, I'm reimplementing it
> cleanly out of paranoia.

Merged, thanks!

Mathieu

> 
> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> ---
>  tests/api.h     |    4 +---
>  urcu/compiler.h |    3 +++
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/api.h b/tests/api.h
> index 49c96f7..c5d716f 100644
> --- a/tests/api.h
> +++ b/tests/api.h
> @@ -27,11 +27,9 @@
>   * to redistribute under later versions of GPL might not be available.
>   */
>  
> +#include <urcu/compiler.h>
>  #include <urcu/arch.h>
>  
> -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
> -#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
> -
>  /*
>   * Machine parameters.
>   */
> diff --git a/urcu/compiler.h b/urcu/compiler.h
> index 54904cc..489677b 100644
> --- a/urcu/compiler.h
> +++ b/urcu/compiler.h
> @@ -61,4 +61,7 @@
>  		(type *)((char *)__ptr - offsetof(type, member));	\
>  	})
>  
> +#define CAA_BUILD_BUG_ON_ZERO(cond) (sizeof(struct { int:-!!(cond); }))
> +#define CAA_BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
> +
>  #endif /* _URCU_COMPILER_H */
> -- 
> 1.7.6
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list