From: Ben Collins <bcollins@debian.org>
To: "Sarda?ons, Eliel" <Eliel.Sardanons@philips.edu.ar>
Cc: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: Re: asm/unistd.h
Date: Thu, 5 Apr 2001 09:13:02 -0400 [thread overview]
Message-ID: <20010405091302.S17338@visi.net> (raw)
In-Reply-To: <A0C675E9DC2CD411A5870040053AEBA0284170@MAINSERVER>
In-Reply-To: <A0C675E9DC2CD411A5870040053AEBA0284170@MAINSERVER>; from Eliel.Sardanons@philips.edu.ar on Thu, Apr 05, 2001 at 09:58:43AM -0300
On Thu, Apr 05, 2001 at 09:58:43AM -0300, Sarda?ons, Eliel wrote:
> I'm taking a look at the linux code and I don't understand how do you
> programm...mmm (?) may be i'm a stupid why in include/asm/unistd.h in some
> macros you use this:
>
> do {
> ...
> } while (0)
Imagine a macro of several lines of code like:
#define FOO(x) \
printf("arg is %s\n", x); \
do_something_useful(x);
Now imagine using it like:
if (blah == 2)
FOO(blah);
This interprets to
if (blah == 2)
printf("arg is %s\n", blah);
do_something_useful(blah);;
As you can see, the "if" then only encompasses the printf, and the
do_something_useful() call is unconditional (not within the scope of the
if), like you wanted it.
So, by using a block like do{...}while(0), you would get this:
if (blah == 2)
do {
printf("arg is %s\n", blah);
do_something_useful(blah);
} while (0);
Which is exactly what you want.
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'
next prev parent reply other threads:[~2001-04-05 13:15 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 ` asm/unistd.h J . A . Magallon
2001-04-05 13:07 ` asm/unistd.h David S. Miller
2001-04-05 13:13 ` Ben Collins [this message]
-- 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=20010405091302.S17338@visi.net \
--to=bcollins@debian.org \
--cc=Eliel.Sardanons@philips.edu.ar \
--cc=linux-kernel@vger.kernel.org \
/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