svn commit: r307756 - in head: include sys/sys

Dimitry Andric dim at FreeBSD.org
Sat Oct 22 14:00:13 UTC 2016


On 22 Oct 2016, at 02:00, Brooks Davis <brooks at freebsd.org> wrote:
> 
> On Fri, Oct 21, 2016 at 11:50:02PM +0000, John Baldwin wrote:
>> Author: jhb
>> Date: Fri Oct 21 23:50:02 2016
>> New Revision: 307756
>> URL: https://svnweb.freebsd.org/changeset/base/307756
>> 
>> Log:
>>  Define max_align_t for C11.
>> 
>>  libc++'s stddef.h includes an existing definition of max_align_t for
>>  C++11, but it is only defined for C++, not for C.  In addition, GCC and
>>  clang both define an alternate version of max_align_t that uses a
>>  union of multiple types rather than a plain long double as in libc++.
>>  This adds a __max_align_t to <sys/_types.h> that matches the GCC and
>>  clang definition that is mapped to max_align_t in <stddef.h>.
...
Modified: head/sys/sys/_types.h
>> ==============================================================================
>> --- head/sys/sys/_types.h	Fri Oct 21 21:55:50 2016	(r307755)
>> +++ head/sys/sys/_types.h	Fri Oct 21 23:50:02 2016	(r307756)
>> @@ -100,6 +100,11 @@ typedef	__uint_least32_t __char32_t;
>> #define	_CHAR32_T_DECLARED
>> #endif
>> 
>> +typedef struct {
> 
> Should this be union per the commit message?

You would be inclined to think so, but the strange way this is defined
is only to be compatible with gcc's definition, which was introduced
here in 2011:

https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/ginclude/stddef.h?r1=181048&r2=181047&pathrev=181048


> Ideally I'd add a void * as well since that will support systems like
> CHERI where pointers are the largest type.

Is void * larger than a struct with long long and long double?  I'd
think this would be at least 128 bits on almost all architectures?

In any case, if you want to change this definition, it is probably best
to first check it with upstream gcc, otherwise you'll end up with an
incompatibility.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20161022/95519f0c/attachment.sig>


More information about the svn-src-head mailing list