Date: Tue, 04 Nov 2014 10:50:29 -0700 From: Ian Lepore <ian@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r274088 - head/sys/kern Message-ID: <1415123429.1200.75.camel@revolution.hippie.lan> In-Reply-To: <20141105023323.O1105@besplex.bde.org> References: <201411041129.sA4BTnwX030600@svn.freebsd.org> <20141104114041.GA21297@dft-labs.eu> <20141105023323.O1105@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2014-11-05 at 03:19 +1100, Bruce Evans wrote: > [...] > Another unsuitable alignment is by the MD ALIGNBYTES macro. This is > (sizeof(register_t) - 1) on all arches except mips 32-bit where it is 7 > sparc64 where it is 15. On arm, it is 3, but arm also has > STACKALIGNBYTES = 7. The register size is really too small to use for > malloc() on 32-bit arches. Its technical correctness depends on no > C objects having more than 32-bit alignment. On i386, int64_t and > double should have 64-bit alignment, but this is not required unless > CFLAGS includes -malign-double which breaks the ABI in userland and > is irrelevant for the kernel. > In arm/include/_align.h we have: /* * Round p (pointer or byte index) up to a correctly-aligned value * for all data types (int, long, ...). [more words snipped] */ #define _ALIGNBYTES (sizeof(int) - 1) So that's clearly wrong, because int64_t and double types require 8-byte alignment. When it comes to fixing it, I could: * include _types.h and use sizeof(__int64_t) * use sizeof(long long) * use sizeof(double) * just hardcode '7' with a comment that says why What are the pros and cons of the various options? Is one of them preferable? Is there something even better I overlooked? -- Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1415123429.1200.75.camel>