From: "J . A . Magallon" <jamagallon@able.es>
To: Andreas Schwab <schwab@suse.de>
Cc: Joseph Carter <knghtbrd@debian.org>,
Bart Trojanowski <bart@jukie.net>,
"'linux-kernel @ vger . kernel . org'"
<linux-kernel@vger.kernel.org>
Subject: Re: asm/unistd.h
Date: Thu, 5 Apr 2001 19:38:40 +0200 [thread overview]
Message-ID: <20010405193840.A5365@werewolf.able.es> (raw)
In-Reply-To: <A0C675E9DC2CD411A5870040053AEBA0284170@MAINSERVER> <Pine.LNX.4.30.0104050901500.13496-100000@localhost> <20010405072628.C22001@debian.org> <jevgojiew7.fsf@hawking.suse.de>
In-Reply-To: <jevgojiew7.fsf@hawking.suse.de>; from schwab@suse.de on Thu, Apr 05, 2001 at 16:45:44 +0200
On 04.05 Andreas Schwab wrote:
>
> Try this and watch your compiler complaining:
>
> #define foo() { }
> #define bar() do { } while (0)
> void mumble ()
> {
> if (1) foo(); else bar();
> if (2) bar(); else foo();
> }
>
Perhaps it is time to USE gcc, yet the kernel can be built only with gcc.
IE, use statement expressions.
Try this:
#define foo() ({ })
#define bar() do { } while (0)
void mumble ()
{
if (1) foo(); else bar();
if (2) bar(); else foo();
}
and see you compiler shutup.
You can even declare vars inside the ({ ... }) block,
so all the
#define bar(x) do { use_1(x); use_2(x); } while (0)
could be written like:
#define bar(x) ({ use_1(x); use_2(x); })
Even you can use <typeof>:
#define swap(a,b) \
({ typeof(a) tmp = a; \
a = b; \
b = tmp; \
})
int main()
{
int a,b;
double c,d;
swap(a,b);
swap(c,d);
}
Its correct in egcs-1.1.2 and up, so it is safe for use in kernel 2.4.
Do not know if previuous gcc eats it up.
--
J.A. Magallon # Let the source
mailto:jamagallon@able.es # be with you, Luke...
Linux werewolf 2.4.3-ac3 #1 SMP Thu Apr 5 00:28:45 CEST 2001 i686
next prev parent reply other threads:[~2001-04-05 17:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-05 12:58 asm/unistd.h Sardañons, Eliel
2001-04-05 13:06 ` asm/unistd.h Bart Trojanowski
2001-04-05 13:12 ` asm/unistd.h Tim Waugh
2001-04-05 14:26 ` asm/unistd.h Joseph Carter
2001-04-05 14:35 ` asm/unistd.h Bart Trojanowski
2001-04-05 14:35 ` asm/unistd.h Stephen Thomas
2001-04-05 14:45 ` asm/unistd.h Andreas Schwab
2001-04-05 17:38 ` J . A . Magallon [this message]
2001-04-05 13:07 ` asm/unistd.h David S. Miller
2001-04-05 13:13 ` asm/unistd.h Ben Collins
-- strict thread matches above, loose matches on Subject: below --
2001-04-05 15:23 asm/unistd.h Steve Grubb
2001-04-05 15:41 ` asm/unistd.h Bart Trojanowski
2001-04-05 15:45 ` asm/unistd.h David S. Miller
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=20010405193840.A5365@werewolf.able.es \
--to=jamagallon@able.es \
--cc=bart@jukie.net \
--cc=knghtbrd@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schwab@suse.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