[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH gnumach 1/3] kern: improve assert
From: |
Samuel Thibault |
Subject: |
Re: [PATCH gnumach 1/3] kern: improve assert |
Date: |
Sat, 20 Dec 2014 23:44:19 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Fri 19 Dec 2014 02:48:56 +0100, a écrit :
> Use the ternary operator to implement `assert' like it is done in the
> glibc. The glibcs changelog does not mention the rationale behind
> this change, but it does improve our IPC performance.
Ack.
> * kern/assert.h (assert): Define macro using the ternary operator.
> ---
> kern/assert.h | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kern/assert.h b/kern/assert.h
> index b074fbb..bd2a8be 100644
> --- a/kern/assert.h
> +++ b/kern/assert.h
> @@ -39,10 +39,9 @@
> extern void Assert(const char *exp, const char *filename, int line)
> __attribute__ ((noreturn));
>
> #define assert(ex) \
> -MACRO_BEGIN \
> - if (!(ex)) \
> - Assert(#ex, __FILE__, __LINE__); \
> -MACRO_END
> + ((ex) \
> + ? (void) (0) \
> + : Assert (#ex, __FILE__, __LINE__))
>
> #define assert_static(x) assert(x)
>
> --
> 2.1.3
>
--
Samuel
<g> r: et la marmotte, elle écrit un papier IPDPS
Re: [PATCH gnumach 1/3] kern: improve assert,
Samuel Thibault <=