[PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert
Florian Weimer
fweimer@redhat.com
Thu Nov 2 12:44:00 GMT 2017
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 >.
I think ((__type) { 0 }).__size is vaguely more portable than the null
pointer dereference.
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 still have to double-check if the current coverage is adequate.
Thanks,
Florian
More information about the Libc-alpha
mailing list