linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Jamie Lokier <jamie@shareable.org>,
	Nikita Danilov <Nikita@Namesys.COM>,
	linux-kernel@vger.kernel.org
Subject: Re: const versus __attribute__((const))
Date: Tue, 9 Dec 2003 08:44:08 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0312090837370.19936@home.osdl.org> (raw)
In-Reply-To: <3FD5ED77.6070505@zytor.com>



On Tue, 9 Dec 2003, H. Peter Anvin wrote:
>
> In some ways, this is rather unfortunate, too.  What it really means is
> that the gcc "m" constraint is overloaded; it would have been better if
> they would have created a new modifier (say "*") for "must be lvalue."

The thing is, most users of "m" (like 99%) actually mean "_THIS_ memory
location". So just fixing the "m" modifier was an easy way to make sure
that users get the behaviour they expect.

Also, I have this dim memory of there actually being a potential bug in
"m" handling inside gcc, and requiring the entry to be a lvalue was the
easiest way to fix it. Richard Henderson would have the details.  I think
it was the liveness analysis that got confused or something.

And the thing is, if you have a non-lvalue right now, you will (a) get a
nice warnign that tells you so, and (b) it will be trivial to fix. So
something like

	asm("xxxx" : :"m" (1+x));

can be trivially fixed to be

	{
		int tmp = 1+x;
		asm("xxxx" : : "m" (tmp));
	}

so it's not like it's a horribly undue burden on the programmer.

In the kernel, I don't think we had a _single_ case that needed this, but
I might remember that wrong. Anyway, it wasn't a problem - and the kernel
tends to be the single most active user of inline asm's of all
gcc-compiled projects.

			Linus

  reply	other threads:[~2003-12-09 16:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-08 15:46 const versus __attribute__((const)) Arnd Bergmann
2003-12-08 17:50 ` H. Peter Anvin
2003-12-08 18:27   ` Nikita Danilov
2003-12-08 18:31     ` H. Peter Anvin
2003-12-09  2:59       ` Jamie Lokier
2003-12-09  3:21         ` H. Peter Anvin
2003-12-09  3:49           ` Jamie Lokier
2003-12-09  5:37             ` H. Peter Anvin
2003-12-09  7:26               ` Linus Torvalds
2003-12-09  7:40                 ` H. Peter Anvin
2003-12-09 11:56                   ` Arnd Bergmann
2003-12-09 15:42                     ` H. Peter Anvin
2003-12-09 16:44                       ` Linus Torvalds [this message]
2003-12-09 16:51                         ` H. Peter Anvin
2003-12-09 19:15                           ` Jamie Lokier
2003-12-09  7:19             ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2003-12-08  1:19 H. Peter Anvin
2003-12-08 12:32 ` Nikita Danilov

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=Pine.LNX.4.58.0312090837370.19936@home.osdl.org \
    --to=torvalds@osdl.org \
    --cc=Nikita@Namesys.COM \
    --cc=arnd@arndb.de \
    --cc=hpa@zytor.com \
    --cc=jamie@shareable.org \
    --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;
as well as URLs for NNTP newsgroup(s).