From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Ingo Molnar <mingo@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>, Michal Marek <mmarek@suse.cz>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
arcml <linux-snps-arc@lists.infradead.org>
Subject: Re: using IS_ENABLED(CONFIG_xyz) effectively
Date: Mon, 16 Nov 2015 08:35:05 +0000 [thread overview]
Message-ID: <C2D7FE5348E1B147BCA15975FBA23075F44D1969@IN01WEMBXA.internal.synopsys.com> (raw)
In-Reply-To: CAMuHMdVEK041TFY3JJ1kvYE_e_C72+FcRu3ewDipLPi-kN-h=A@mail.gmail.com
Hi Geert,
On Monday 16 November 2015 01:58 PM, Geert Uytterhoeven wrote:
> Hi Vineet,
>
> On Mon, Nov 16, 2015 at 9:00 AM, Vineet Gupta
> <Vineet.Gupta1@synopsys.com> wrote:
>> I've been using IS_ENABLED for some time and once in a while run into an issue
>> which prevents seamless use. Hence posing this question to experts in the area.
>>
>> C macro processor evaluates the ensuing control block even if IS_ENABLED evaluates
>> to false. This requires dummy #defines or worse still removing usage of IS_ENABLED
>> altogether.
>>
>> e.g. In example below even for ARCOMPACT builds, we need the ARCV2 specific define
>> ARCV2_IRQ_DEF_PRIO.
>>
>> void arch_cpu_idle(void)
>> {
>> if (is_isa_arcompact()) { <---- IS_ENABLED(CONFIG_ISA_ARCOMPACT)
>> __asm__("sleep 0x3");
>> } else {
>> const int arg = 0x10 | ARCV2_IRQ_DEF_PRIO;
>> __asm__("sleep 0x10");
>> }
>> }
>>
>> One could argue that the interface needs to be cleanly defined to not have such
>> specific #defines in common code in first place. However sometime that becomes
>> just too tedious.
>>
>> Is there a way to get around by this ?
> Use #ifdef CONFIG_...?
>
> The advantage of IS_ENABLED() over #ifdef is that it allows compile-testing of
> the disabled code path. Of course it should only be compiled if it makes
> sense. And that's exactly what you're running into.
And I thought it was to de-uglify the code with same semantics - which doesn't
seem to be the case !
Oh well !
Thx,
-Vineet
next prev parent reply other threads:[~2015-11-16 8:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 12:29 [PATCH 1/2] x86: dumpstack, use pr_cont Jiri Slaby
2015-10-06 12:29 ` [PATCH 2/2] x86: text_poke, check if text_mutex is held Jiri Slaby
2015-10-06 16:00 ` [PATCH 1/2] x86: dumpstack, use pr_cont Rasmus Villemoes
2015-10-06 16:16 ` Jiri Slaby
2015-10-06 21:05 ` [PATCH 1/2] linux/kconfig.h: generalize IS_ENABLED logic Rasmus Villemoes
2015-10-06 21:05 ` [PATCH 2/2] x86: dumpstack: eliminate some #ifdefs Rasmus Villemoes
2015-10-07 7:03 ` Ingo Molnar
2016-03-26 20:40 ` [PATCH] x86: dumpstack: combine some printks Rasmus Villemoes
2016-04-01 6:37 ` [tip:x86/debug] x86/dumpstack: Combine some printk()s tip-bot for Rasmus Villemoes
2015-10-07 6:57 ` [PATCH 1/2] linux/kconfig.h: generalize IS_ENABLED logic Ingo Molnar
2015-10-07 8:15 ` Michal Marek
2015-10-07 21:33 ` Rasmus Villemoes
2015-10-08 11:40 ` Michal Marek
2015-11-16 8:00 ` using IS_ENABLED(CONFIG_xyz) effectively Vineet Gupta
2015-11-16 8:28 ` Geert Uytterhoeven
2015-11-16 8:35 ` Vineet Gupta [this message]
2015-11-16 8:52 ` Arnd Bergmann
2015-11-16 10:03 ` Vineet Gupta
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=C2D7FE5348E1B147BCA15975FBA23075F44D1969@IN01WEMBXA.internal.synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=akpm@linux-foundation.org \
--cc=geert@linux-m68k.org \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=paul.gortmaker@windriver.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).