* [PATCH] types.h: define __aligned_u64 and expose to userspace
@ 2010-10-15 4:24 Eric Paris
2010-10-15 8:43 ` Andi Kleen
2010-10-15 8:51 ` Arnd Bergmann
0 siblings, 2 replies; 4+ messages in thread
From: Eric Paris @ 2010-10-15 4:24 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, jengelh, davem, andi
We currently have a kernel internal type called aligned_u64 which aligns
__u64's on 8 bytes boundaries even on systems which would normally align
them on 4 byte boundaries. This patch creates a new type __aligned_u64
which does the same thing but which is exposed to userspace rather than
being kernel internal.
Based-on-patch-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
---
include/linux/types.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/linux/types.h b/include/linux/types.h
index 01a082f..194e90b 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -178,6 +178,11 @@ typedef __u64 __bitwise __be64;
typedef __u16 __bitwise __sum16;
typedef __u32 __bitwise __wsum;
+/* this is a special 64bit data type that is 8-byte aligned */
+#define __aligned_u64 __u64 __attribute__((aligned(8)))
+#define __aligned_be64 __be64 __attribute__((aligned(8)))
+#define __aligned_le64 __le64 __attribute__((aligned(8)))
+
#ifdef __KERNEL__
typedef unsigned __bitwise__ gfp_t;
typedef unsigned __bitwise__ fmode_t;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] types.h: define __aligned_u64 and expose to userspace
2010-10-15 4:24 [PATCH] types.h: define __aligned_u64 and expose to userspace Eric Paris
@ 2010-10-15 8:43 ` Andi Kleen
2010-10-15 9:03 ` Andrew Morton
2010-10-15 8:51 ` Arnd Bergmann
1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2010-10-15 8:43 UTC (permalink / raw)
To: Eric Paris; +Cc: linux-kernel, akpm, jengelh, davem, andi
On Fri, Oct 15, 2010 at 12:24:55AM -0400, Eric Paris wrote:
> We currently have a kernel internal type called aligned_u64 which aligns
> __u64's on 8 bytes boundaries even on systems which would normally align
> them on 4 byte boundaries. This patch creates a new type __aligned_u64
> which does the same thing but which is exposed to userspace rather than
> being kernel internal.
>
> Based-on-patch-by: Andreas Gruenbacher <agruen@suse.de>
> Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
but only if you:
> +/* this is a special 64bit data type that is 8-byte aligned */
Expand this comment a bit that that using this type as a
replacement for u64 is recommended
for any user visible 64bit value in a structure and that it
avoids problem with the compat layer on x86-64.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] types.h: define __aligned_u64 and expose to userspace
2010-10-15 4:24 [PATCH] types.h: define __aligned_u64 and expose to userspace Eric Paris
2010-10-15 8:43 ` Andi Kleen
@ 2010-10-15 8:51 ` Arnd Bergmann
1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2010-10-15 8:51 UTC (permalink / raw)
To: Eric Paris; +Cc: linux-kernel, akpm, jengelh, davem, andi
On Friday 15 October 2010 06:24:55 Eric Paris wrote:
> We currently have a kernel internal type called aligned_u64 which aligns
> __u64's on 8 bytes boundaries even on systems which would normally align
> them on 4 byte boundaries. This patch creates a new type __aligned_u64
> which does the same thing but which is exposed to userspace rather than
> being kernel internal.
>
> Based-on-patch-by: Andreas Gruenbacher <agruen@suse.de>
> Signed-off-by: Eric Paris <eparis@redhat.com>
We should have done this long ago.
Acked-by: Arnd Bergmann <arnd@arndb.de>
BTW, why a define, not a typedef? Probably doesn't really matter in the end,
I just wonder if the define has any advantages here.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] types.h: define __aligned_u64 and expose to userspace
2010-10-15 8:43 ` Andi Kleen
@ 2010-10-15 9:03 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2010-10-15 9:03 UTC (permalink / raw)
To: Andi Kleen; +Cc: Eric Paris, linux-kernel, jengelh, davem
On Fri, 15 Oct 2010 10:43:11 +0200 Andi Kleen <andi@firstfloor.org> wrote:
> On Fri, Oct 15, 2010 at 12:24:55AM -0400, Eric Paris wrote:
> > We currently have a kernel internal type called aligned_u64 which aligns
> > __u64's on 8 bytes boundaries even on systems which would normally align
> > them on 4 byte boundaries. This patch creates a new type __aligned_u64
> > which does the same thing but which is exposed to userspace rather than
> > being kernel internal.
> >
> > Based-on-patch-by: Andreas Gruenbacher <agruen@suse.de>
> > Signed-off-by: Eric Paris <eparis@redhat.com>
>
> Acked-by: Andi Kleen <ak@linux.intel.com>
>
> but only if you:
>
> > +/* this is a special 64bit data type that is 8-byte aligned */
>
> Expand this comment a bit that that using this type as a
> replacement for u64 is recommended
> for any user visible 64bit value in a structure and that it
> avoids problem with the compat layer on x86-64.
>
Well yes, I was actually about to write that comment. But it should
describe the compat problems fully?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-15 9:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 4:24 [PATCH] types.h: define __aligned_u64 and expose to userspace Eric Paris
2010-10-15 8:43 ` Andi Kleen
2010-10-15 9:03 ` Andrew Morton
2010-10-15 8:51 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox