mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-08 10:09:43 +00:00
compiler: add a sizeof_field() macro
Determining the size of a field is useful when you don't have a struct variable handy. Open-coding this is ugly. This patch adds the sizeof_field() macro, which is similar to typeof_field(). Existing instances are updated to use the macro. Backports commit f18793b096e69c7acfce66cded483ba9fc01762a from qemu
This commit is contained in:
parent
a63e549673
commit
e8b92838fe
|
@ -28,6 +28,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define sizeof_field(type, field) sizeof(((type *)0)->field)
|
||||
|
||||
static double rint( double x )
|
||||
{
|
||||
|
@ -166,6 +167,8 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define sizeof_field(type, field) sizeof(((type *)0)->field)
|
||||
|
||||
/* Convert from a base type to a parent type, with compile time checking. */
|
||||
#ifdef __GNUC__
|
||||
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
|
||||
|
|
Loading…
Reference in a new issue