types.h: define __aligned_u64 and expose to userspace
PATCH 1/1 types.h: define __aligned_u64 and expose to userspace
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.
---
include/linux/types.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/types.h +5 -0
@@ -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 ;
Quoted 8 lines · Eric Paris
We currently have a kernel internal type called
aligned_u64which 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_u64which does the same thing but which is exposed to userspace rather than being kernel internal.Based-on-patch-by Andreas Gruenbacher <[email protected]>Signed-off-by Eric Paris <[email protected]>
but only if you:
Quoted 1 line
+/* 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
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 12 lines · On Fri, 15 Oct 2010 10:43:11 +0200 Andi Kleen <[email protected]> wrote:
Quoted 8 lines · Eric Paris
We currently have a kernel internal type called
aligned_u64which 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_u64which does the same thing but which is exposed to userspace rather than being kernel internal.Based-on-patch-by Andreas Gruenbacher <[email protected]>Signed-off-by Eric Paris <[email protected]>Acked-by Andi Kleen <[email protected]>
Quoted 9 lines
but only if you:
Quoted 1 line
+/* 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?
Quoted 8 lines · On Friday 15 October 2010 06:24:55 Eric Paris wrote:
We currently have a kernel internal type called
aligned_u64which 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_u64which does the same thing but which is exposed to userspace rather than being kernel internal.Based-on-patch-by Andreas Gruenbacher <[email protected]>Signed-off-by Eric Paris <[email protected]>
We should have done this long ago.
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