mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 10:14:52 +00:00
os: osdep: add macro for compile-time type size assert
usage: __size_assert(typename, size); if the type's size (calculated by sizeof) doesn't match the asserted size, an illegal dummy type will be constructed, thus compilation fails. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
b1edd361a0
commit
f0cc20eb68
@@ -222,4 +222,10 @@ Ones(unsigned long mask)
|
||||
|
||||
#define LIMITCLIENTS 256 /* Must be a power of 2 and <= MAXCLIENTS */
|
||||
|
||||
/* static assert for protocol structure sizes */
|
||||
#ifndef __size_assert
|
||||
#define __size_assert(what, howmuch) \
|
||||
typedef char what##_size_wrong_[( !!(sizeof(what) == howmuch) )*2-1 ]
|
||||
#endif
|
||||
|
||||
#endif /* _OSDEP_H_ */
|
||||
|
||||
Reference in New Issue
Block a user