From: Sam Ravnborg <sam@ravnborg.org>
To: Abdel <draconux@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: macro _set_base - "do - while(0)" question
Date: Wed, 2 Jan 2008 12:49:56 +0100 [thread overview]
Message-ID: <20080102114956.GB8489@uranus.ravnborg.org> (raw)
In-Reply-To: <60d29d630801020345i200a2f72pe860b0d38b530a05@mail.gmail.com>
On Wed, Jan 02, 2008 at 12:45:39PM +0100, Abdel wrote:
> Hi,
>
> In file include/asm-i386/system.h, _set_base and _set_limit use an
> useless do ... while(0)
>
> Why is this needed ?
>
> exemple with _set_base from linux-2.6.23
>
> #define _set_base(addr,base) do { unsigned long __pr; \
> __asm__ __volatile__ ("movw %%dx,%1\n\t" \
> "rorl $16,%%edx\n\t" \
> "movb %%dl,%2\n\t" \
> "movb %%dh,%3" \
> :"=&d" (__pr) \
> :"m" (*((addr)+2)), \
> "m" (*((addr)+4)), \
> "m" (*((addr)+7)), \
> "0" (base) \
> ); } while(0)
>
Without the do {} while (0)
then
1) you could not define the variable __pr
2) You would be fooled when you did:
if (foo != bar)
set_base(addr,base);
Sam
next prev parent reply other threads:[~2008-01-02 11:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-02 11:45 Abdel
2008-01-02 11:49 ` Sam Ravnborg [this message]
2008-01-02 12:42 ` DervishD
[not found] <9HagT-66H-21@gated-at.bofh.it>
2008-01-02 12:15 ` Bodo Eggert
2008-01-02 13:22 Abdel
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=20080102114956.GB8489@uranus.ravnborg.org \
--to=sam@ravnborg.org \
--cc=draconux@gmail.com \
--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
all inboxes | Powered by JetHome®