Adjust _ALIGNBYTES to the proper value for arm and armv6 arches. Modern

compilers can emit arm instructions that require 8-byte alignment.  The
alignment-sensitive instructions were added in armv5, which has to be
supported by our combined v4/v5 kernels, so the value is set uncoditionally
for all arm architecture versions.

Also adjust the comment to explain in more detail why the macros have the
form and values they do.

Per advice from bde@, maintain the unsignedness of the value of _ALIGNBYTES
(but do so using his second choice of allowing sizeof() to supply the
unsignedness, rather than just hardcoding '8U', which in my mind would
require an even more verbose comment to explain why it's right).  Also
explain in the comment that the resulting type of _ALIGN() is equivelent
to uinptr_t on arm (32-bit unsigned int), but it's purposely spelled as
"unsigned" to avoid problems with including other header files.  Even
including machine/_types.h to allow use of __uintptr_t causes compilation
failures because of this header being included (indirectly) in asm code.

The discussion that led to this change (albeit at a glacial pace) is at
https://lists.freebsd.org/pipermail/svn-src-head/2014-November/064593.html
This commit is contained in:
Ian Lepore 2016-05-21 16:52:38 +00:00
parent bcf9fc28f6
commit da6da1575b

View File

@ -42,11 +42,11 @@
#define _ARM_INCLUDE__ALIGN_H_
/*
* Round p (pointer or byte index) up to a correctly-aligned value
* for all data types (int, long, ...). The result is unsigned int
* and must be cast to any desired pointer type.
* Round p (pointer or byte index) up to the hardware-required alignment which
* is sufficient for any data type, pointer or numeric. The resulting type
* is equivelent to arm's uintptr_t (but is purposely spelled "unsigned" here).
*/
#define _ALIGNBYTES (sizeof(int) - 1)
#define _ALIGNBYTES (sizeof(long long) - 1)
#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
#endif /* !_ARM_INCLUDE__ALIGN_H_ */