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 22:42:41 -0500 [thread overview]
Message-ID: <1112586161.7087.3.camel@mulgrave> (raw)
In-Reply-To: <20050317104744.4be7e550.davem@davemloft.net>
I just got around to checking this on parisc, and I'm afraid we have a
toolchain cockup: Our gcc can't optimise the sizeof() if the user is an
inline function. It can, however if the functions are made #defines
instead.
Would the attached be OK with everyone? It works fine for us.
Thanks,
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 21:17:14 -05:00
@@ -12,14 +12,6 @@
#include <linux/types.h>
-/*
- * The main single-value unaligned transfer routines.
- */
-#define get_unaligned(ptr) \
- ((__typeof__(*(ptr)))__get_unaligned((ptr), sizeof(*(ptr))))
-#define put_unaligned(x,ptr) \
- __put_unaligned((unsigned long)(x), (ptr), sizeof(*(ptr)))
-
/*
* This function doesn't actually exist. The idea is that when
* someone uses the macros below with an unsupported size (datatype),
@@ -76,46 +68,44 @@
ptr->x = val;
}
-static inline unsigned long __get_unaligned(const void *ptr, size_t size)
-{
- unsigned long val;
- switch (size) {
- case 1:
- val = *(const __u8 *)ptr;
- break;
- case 2:
- val = __uldw((const __u16 *)ptr);
- break;
- case 4:
- val = __uldl((const __u32 *)ptr);
- break;
- case 8:
- val = __uldq((const __u64 *)ptr);
- break;
- default:
- bad_unaligned_access_length();
- };
- return val;
-}
-
-static inline void __put_unaligned(unsigned long val, void *ptr, size_t size)
-{
- switch (size) {
- case 1:
- *(__u8 *)ptr = val;
- break;
- case 2:
- __ustw(val, (__u16 *)ptr);
- break;
- case 4:
- __ustl(val, (__u32 *)ptr);
- break;
- case 8:
- __ustq(val, (__u64 *)ptr);
- break;
- default:
- bad_unaligned_access_length();
- };
-}
+#define get_unaligned(ptr) ({ \
+ unsigned long val; \
+ switch (sizeof(*(ptr))) { \
+ case 1: \
+ val = *(const __u8 *)(ptr); \
+ break; \
+ case 2: \
+ val = __uldw((const __u16 *)(ptr)); \
+ break; \
+ case 4: \
+ val = __uldl((const __u32 *)(ptr)); \
+ break; \
+ case 8: \
+ val = __uldq((const __u64 *)(ptr)); \
+ break; \
+ default: \
+ bad_unaligned_access_length(); \
+ }; \
+ (__typeof__(*(ptr)))val; \
+})
+
+#define put_unaligned(val, ptr) ({ \
+ switch (sizeof(*(ptr))) { \
+ case 1: \
+ *(__u8 *)(ptr) = (val); \
+ break; \
+ case 2: \
+ __ustw(val, (__u16 *)(ptr)); \
+ break; \
+ case 4: \
+ __ustl(val, (__u32 *)(ptr)); \
+ break; \
+ case 8: \
+ __ustq(val, (__u64 *)(ptr)); \
+ break; \
+ default: \
+ bad_unaligned_access_length(); \
+ }; \
+})
#endif /* _ASM_GENERIC_UNALIGNED_H */
===== 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 3:42 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 [this message]
2005-04-04 4:02 ` David S. Miller
2005-04-04 4:15 ` James Bottomley
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=1112586161.7087.3.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