[PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Nov 2 13:32:00 GMT 2017
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.
More information about the Libc-alpha
mailing list