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


_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to