This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]