From 06b0a1bdab419436a2b8c596629c241faee99e63 Mon Sep 17 00:00:00 2001 From: dsl Date: Sun, 16 Sep 2007 22:35:01 +0000 Subject: [PATCH] Define netbsd32_uint64 for 64bit integers with the alignment requirement of the corresponding 32bit architecture. Use it for the 64bit items in netbsd32_statvfs so that the structure doesn't collect 8byte alignment (and 4 bytes of trailing padding). This replaces the 'packed' attribute which wasn't architecture specific and would cause massive overheads accessing every member of sparc64. Should allow the MIPS64 port do DTRT. --- sys/arch/amd64/include/netbsd32_machdep.h | 5 ++++- sys/arch/powerpc/include/netbsd32_machdep.h | 5 ++++- sys/arch/sparc64/include/netbsd32_machdep.h | 5 ++++- sys/compat/netbsd32/netbsd32.h | 23 +++++++++++++++------ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/sys/arch/amd64/include/netbsd32_machdep.h b/sys/arch/amd64/include/netbsd32_machdep.h index c0a837c338ca..5ca0c457d05b 100644 --- a/sys/arch/amd64/include/netbsd32_machdep.h +++ b/sys/arch/amd64/include/netbsd32_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.h,v 1.12 2007/03/16 22:23:30 dsl Exp $ */ +/* $NetBSD: netbsd32_machdep.h,v 1.13 2007/09/16 22:35:01 dsl Exp $ */ #ifndef _MACHINE_NETBSD32_H_ #define _MACHINE_NETBSD32_H_ @@ -10,6 +10,9 @@ #define NETBSD32_POINTER_TYPE uint32_t typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; +/* i386 has 32bit aligned 64bit integers */ +#define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) + typedef netbsd32_pointer_t netbsd32_sigcontextp_t; struct netbsd32_sigcontext13 { diff --git a/sys/arch/powerpc/include/netbsd32_machdep.h b/sys/arch/powerpc/include/netbsd32_machdep.h index 4de3aec8a3dd..5fb1f8556516 100644 --- a/sys/arch/powerpc/include/netbsd32_machdep.h +++ b/sys/arch/powerpc/include/netbsd32_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.h,v 1.2 2003/04/16 08:58:18 dsl Exp $ */ +/* $NetBSD: netbsd32_machdep.h,v 1.3 2007/09/16 22:35:01 dsl Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -41,6 +41,9 @@ typedef u_int32_t netbsd32_pointer_t; */ #define NETBSD32PTR64(p32) ((void *)(u_long)(u_int)(p32)) +/* ppc32 has 32bit aligned 64bit integers */ +#define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) + #include #include diff --git a/sys/arch/sparc64/include/netbsd32_machdep.h b/sys/arch/sparc64/include/netbsd32_machdep.h index ea5e639310b6..c858cc492dd1 100644 --- a/sys/arch/sparc64/include/netbsd32_machdep.h +++ b/sys/arch/sparc64/include/netbsd32_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.h,v 1.22 2007/03/16 22:24:49 dsl Exp $ */ +/* $NetBSD: netbsd32_machdep.h,v 1.23 2007/09/16 22:35:02 dsl Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -39,6 +39,9 @@ struct proc; #define NETBSD32_POINTER_TYPE uint32_t typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; +/* sparc32 has 32bit aligned 64bit integers */ +#define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) + /* from */ typedef uint32_t netbsd32_sigcontextp_t; diff --git a/sys/compat/netbsd32/netbsd32.h b/sys/compat/netbsd32/netbsd32.h index c4c2593831ac..285fadbe83a2 100644 --- a/sys/compat/netbsd32/netbsd32.h +++ b/sys/compat/netbsd32/netbsd32.h @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32.h,v 1.66 2007/07/17 20:36:11 christos Exp $ */ +/* $NetBSD: netbsd32.h,v 1.67 2007/09/16 22:35:02 dsl Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -64,6 +64,8 @@ typedef int32_t netbsd32_key_t; typedef int32_t netbsd32_intptr_t; typedef u_int32_t netbsd32_uintptr_t; +/* netbsd32_[u]int64 are machine dependant and defined below */ + /* * machine depedant section; must define: * netbsd32_pointer_t @@ -119,6 +121,15 @@ NETBSD32IPTR64(NETBSD32_POINTER_TYPE p32) { return (void *)(intptr_t)p32; } /* Nothing should be using the raw type, so kill it */ #undef NETBSD32_POINTER_TYPE +/* + * 64 bit integers only have 4-byte alignment on some 32 bit ports, + * but always have 8-byte alignment on 64 bit systems. + * NETBSD32_INT64_ALIGN may be __attribute__((__aligned__(4))) + */ +typedef int64_t netbsd32_int64 NETBSD32_INT64_ALIGN; +typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN; +#undef NETBSD32_INT64_ALIGN + /* * all pointers are netbsd32_pointer_t (defined in ) */ @@ -577,10 +588,10 @@ struct netbsd32_statvfs { fsfilcnt_t f_ffree; /* free file nodes in file system */ fsfilcnt_t f_favail; /* free file nodes avail to non-root */ fsfilcnt_t f_fresvd; /* file nodes reserved for root */ - uint64_t f_syncreads; /* count of sync reads since mount */ - uint64_t f_syncwrites; /* count of sync writes since mount */ - uint64_t f_asyncreads; /* count of async reads since mount */ - uint64_t f_asyncwrites; /* count of async writes since mount */ + netbsd32_uint64 f_syncreads; /* count of sync reads since mount */ + netbsd32_uint64 f_syncwrites; /* count of sync writes since mount */ + netbsd32_uint64 f_asyncreads; /* count of async reads since mount */ + netbsd32_uint64 f_asyncwrites; /* count of async writes since mount */ fsid_t f_fsidx; /* NetBSD compatible fsid */ netbsd32_u_long f_fsid; /* Posix compatible fsid */ netbsd32_u_long f_namemax; /* maximum filename length */ @@ -589,7 +600,7 @@ struct netbsd32_statvfs { char f_fstypename[_VFS_NAMELEN]; /* fs type name */ char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */ char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */ -} __attribute__((packed)); +}; /* from */ typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;