From: James Bottomley <James.Bottomley@steeleye.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: linux-arch@vger.kernel.org
Subject: Re: Consolidation of asm/unaligned.h
Date: Sun, 03 Apr 2005 23:15:36 -0500 [thread overview]
Message-ID: <1112588136.7087.17.camel@mulgrave> (raw)
In-Reply-To: <20050403210201.6ecd41aa.davem@davemloft.net>
On Sun, 2005-04-03 at 21:02 -0700, David S. Miller wrote:
> Please explain what you mean by "optimize"?
>
> If you are saying what I think you're saying (that gcc always
> emits the entire switch statement, not just the constant case
> we need) I bet it has to do with inlining or switch statement
> heuristics.
Precisely. Our current gcc doesn't optimise away the additional cases
even though sizeof(*ptr) should be a known constant. One of our
compiler people said they'd take a look at it, but even if they manage
to fix it, we need a current compiler to be able to build the kernel.
> In any event, I'd like to be better informed, because this means
> you're getting terrible code in a lot of places as this is
> a common technique in the kernel header files.
That wouldn't surprise me. However, all of our other uses of this
technique are in #defines, so this is the first time we've run into the
problem.
> I also don't want to make these macros, since if we do so we lose
> the type checking and we also get into the world of CPP macro arg
> multiple-evaluation crazyness.
Actually, Matthew Wilcox suggested an alternative: If the inline
function arguments for the size are consts, then the compiler seems to
behave correctly, so how about the attached?
James
===== include/asm-generic/unaligned.h 1.2 vs edited =====
--- 1.2/include/asm-generic/unaligned.h 2005-03-17 15:54:10 -06:00
+++ edited/include/asm-generic/unaligned.h 2005-04-03 23:09:27 -05:00
@@ -76,7 +76,7 @@
ptr->x = val;
}
-static inline unsigned long __get_unaligned(const void *ptr, size_t size)
+static inline unsigned long __get_unaligned(const void *ptr, const size_t size)
{
unsigned long val;
switch (size) {
@@ -98,7 +98,7 @@
return val;
}
-static inline void __put_unaligned(unsigned long val, void *ptr, size_t size)
+static inline void __put_unaligned(unsigned long val, void *ptr, const size_t size)
{
switch (size) {
case 1:
===== include/asm-parisc/unaligned.h 1.3 vs edited =====
--- 1.3/include/asm-parisc/unaligned.h 2005-03-17 15:54:10 -06:00
+++ edited/include/asm-parisc/unaligned.h 2005-04-03 16:14:55 -05:00
@@ -1,7 +1,7 @@
#ifndef _ASM_PARISC_UNALIGNED_H_
#define _ASM_PARISC_UNALIGNED_H_
-#include <asm-parisc/unaligned.h>
+#include <asm-generic/unaligned.h>
#ifdef __KERNEL__
struct pt_regs;
next prev parent reply other threads:[~2005-04-04 4:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-17 18:47 Consolidation of asm/unaligned.h David S. Miller
2005-03-17 21:33 ` Russell King
2005-03-17 21:51 ` David S. Miller
2005-03-17 21:57 ` Geert Uytterhoeven
2005-03-17 22:03 ` David S. Miller
2005-03-18 0:20 ` Richard Henderson
2005-03-18 4:13 ` David S. Miller
2005-03-17 23:27 ` Ralf Baechle
2005-03-18 0:25 ` David Woodhouse
2005-04-04 3:42 ` James Bottomley
2005-04-04 4:02 ` David S. Miller
2005-04-04 4:15 ` James Bottomley [this message]
2005-04-04 6:11 ` David S. Miller
2005-04-04 11:34 ` Matthew Wilcox
2005-04-04 10:47 ` Ralf Baechle
2005-04-05 14:10 ` James Bottomley
2005-04-05 14:15 ` Ralf Baechle
2005-04-05 15:02 ` Matthew Wilcox
2005-04-05 15:11 ` Ralf Baechle
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=1112588136.7087.17.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=davem@davemloft.net \
--cc=linux-arch@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