From: Jens Axboe <axboe@kernel.dk>
To: Alireza Haghdoost <haghdoost@gmail.com>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>
Subject: Re: competime_assert failure without -O3 optimization flag expected ?
Date: Mon, 29 Jun 2015 11:50:16 -0600 [thread overview]
Message-ID: <55918558.8090006@kernel.dk> (raw)
In-Reply-To: <CAB-428=ToOGYb=5r6VhORWiFqXoHk6N8tMX8HbUr2_Cctf9oWw@mail.gmail.com>
On 06/29/2015 11:42 AM, Alireza Haghdoost wrote:
> Jens,
>
> Sounds like the compiletime_assert() method was not function and is
> relying on the optimizer performing dead code elimination to remove
> the call to prefix ## suffix
>
> How about this solution: I guess we have to work around it to make it
> more portable since it works with C11.
>
> diff --git a/fio-arh/compiler/compiler.h b/fio-arh/compiler/compiler.h
> index 40e857c..7c9ba57 100644
> --- a/fio-arh/compiler/compiler.h
> +++ b/fio-arh/compiler/compiler.h
> @@ -33,26 +33,6 @@
> 1; \
> })
>
> -#ifndef __compiletime_error
> -#define __compiletime_error(message)
> -#endif
> -#ifndef __compiletime_error_fallback
> -#define __compiletime_error_fallback(condition) do { } while (0)
> -#endif
> -
> -#define __compiletime_assert(condition, msg, prefix, suffix) \
> - do { \
> - int __cond = !(condition); \
> - extern void prefix ## suffix(void) __compiletime_error(msg); \
> - if (__cond) \
> - prefix ## suffix(); \
> - __compiletime_error_fallback(__cond); \
> - } while (0)
> -
> -#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__)
> +#define compiletime_assert(condition, msg) _Static_assert(condition, msg)
>
> #endif
But now it's more compiler dependent, which is worse than before. At
least it only broke if people fiddled with the optimizations before,
otherwise it was fine.
Add a configure test for this, use _Static_assert() if it's available,
the old method if not.
--
Jens Axboe
next prev parent reply other threads:[~2015-06-29 17:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-29 14:46 competime_assert failure without -O3 optimization flag expected ? Alireza Haghdoost
2015-06-29 15:47 ` Jens Axboe
2015-06-29 15:53 ` Alireza Haghdoost
2015-06-29 15:55 ` Jens Axboe
2015-06-29 16:04 ` Jens Axboe
2015-06-29 17:42 ` Alireza Haghdoost
2015-06-29 17:50 ` Jens Axboe [this message]
2015-06-29 18:25 ` Alireza Haghdoost
2015-06-29 18:29 ` Jens Axboe
2015-06-29 18:58 ` Alireza Haghdoost
2015-06-29 19:11 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55918558.8090006@kernel.dk \
--to=axboe@kernel.dk \
--cc=fio@vger.kernel.org \
--cc=haghdoost@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox