This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 2 Nov 2017 11:31:55 -0200
- Subject: Re: [PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert
- Authentication-results: sourceware.org; auth=none
- References: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> <1509038067-18532-2-git-send-email-adhemerval.zanella@linaro.org> <6a4bf79e-2cda-243d-9ff3-b496dd42d479@redhat.com>
On 02/11/2017 10:44, Florian Weimer wrote:
> On 10/26/2017 07:14 PM, Adhemerval Zanella wrote:
>> +#define ASSERT_TYPE_SIZE(__type, __size) \
>> + _Static_assert (sizeof (__type) == __size, \
>> + "sizeof (" #__type ") != " #__size)
>> +
>> +#define ASSERT_PTHREAD_INTERNAL_SIZE(__type, __internal) \
>> + _Static_assert (sizeof ((__type *) 0)->__size >= sizeof (__internal), \
>> + "sizeof (" #__type ".__size) > sizeof (" #__internal ")")
>
> No __ prefixes are need for macro arguments because there cannot be a name clash. For the second macro, there is an operator discrepancy >= vs >.
Ack.
>
> I think ((__type) { 0 }).__size is vaguely more portable than the null pointer dereference.
Ack.
>
> Regarding the structure of this patch, I wonder if it would be better to have all the checks in a central place, so that it is easier to see if any are missing. But if you prefer the current approach, this is fine as well.
I think it is more logical to add each possible tests on the implementation
file for the referred type (I used a similar strategy for C11 threads).
>
> I still have to double-check if the current coverage is adequate.
Right.