[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50A6CB55.7070706@att.net>
Date: Fri, 16 Nov 2012 17:25:09 -0600
From: Daniel Santos <danielfsantos@....net>
To: Borislav Petkov <bp@...en8.de>
CC: LKML <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Christopher Li <sparse@...isli.org>,
David Daney <david.daney@...ium.com>,
David Howells <dhowells@...hat.com>,
Joe Perches <joe@...ches.com>,
Josh Triplett <josh@...htriplett.org>,
Konstantin Khlebnikov <khlebnikov@...nvz.org>,
linux-sparse@...r.kernel.org,
Michel Lespinasse <walken@...gle.com>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Pavel Pisa <pisa@....felk.cvut.cz>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH v5 9/9] bug.h, compiler.h: Introduce compiletime_assert
& BUILD_BUG_ON_MSG
On 11/13/2012 04:13 PM, danielfsantos@....net wrote:
> +#define __compiletime_assert(condition, msg, __func) \
> + do { \
> + bool __cond = !(condition); \
> + extern void __func(void) __compiletime_error(msg); \
> + if (__cond) \
> + __func(); \
> + __compiletime_error_fallback(__cond); \
> + } while (0)
> +
> +#define _compiletime_assert(condition, msg, __func) \
> + __compiletime_assert(condition, msg, __func)
> +
> +/**
> + * compiletime_assert - break build and emit msg if condition is false
> + * @condition: a compile-time constant condition to check
> + * @msg: a message to emit if condition is false
> + *
> + * In tradition of POSIX assert, this macro will break the build if the
> + * supplied condition is *false*, emitting the supplied error message if the
> + * compiler has support to do so.
> + */
> +#define compiletime_assert(condition, msg) \
> + _compiletime_assert(condition, msg, __compiletime_assert_ ## __LINE__)
> +
Whoops, this implementation pastes the tokens before allowing them to
expand, it should be something like this:
#define __compiletime_assert(condition, msg, __func) .... stuff
#define _compiletime_assert(condition, msg, prefix, suffix) \
__compiletime_assert(condition, msg, prefix ## suffix)
#define compiletime_assert(condition, msg) \
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
I'll fix that as well.
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists