Mesa (main): util: use static_assert directly
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 07:49:47 UTC 2022
Module: Mesa
Branch: main
Commit: f1023571e8ce7ccb6ec7bc115240cb76aef3e5e5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1023571e8ce7ccb6ec7bc115240cb76aef3e5e5
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Tue May 31 10:24:38 2022 +0200
util: use static_assert directly
For some reason, Clang doesn't love the STATIC_ASSERT implementation
we're about switch to in this *one* particular case. Other cases seems
to work fine, so let's just use static_assert directly here.
It lets us give a better error string anyway, so yay.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16670>
---
src/util/macros.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/util/macros.h b/src/util/macros.h
index fafe59e04cc..b48e10667ef 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -104,9 +104,9 @@
__builtin_types_compatible_p(__typeof__(a), __typeof__(b))
# define container_of(ptr, type, member) ({ \
uint8_t *__mptr = (uint8_t *)(ptr); \
- STATIC_ASSERT(__same_type(*(ptr), ((type *)0)->member) || \
- __same_type(*(ptr), void) || \
- !"pointer type mismatch in container_of()"); \
+ static_assert(__same_type(*(ptr), ((type *)0)->member) || \
+ __same_type(*(ptr), void), \
+ "pointer type mismatch in container_of()"); \
((type *)(__mptr - offsetof(type, member))); \
})
#endif
More information about the mesa-commit
mailing list