Appease some UBSan complaints (#720)

This commit is contained in:
YAMAMOTO Takashi
2021-09-04 11:09:30 +09:00
committed by GitHub
parent 4e4d48e72b
commit 79f163d08b
2 changed files with 25 additions and 19 deletions

View File

@ -80,8 +80,13 @@ int BH_VPRINTF(const char *format, va_list ap);
/* Return the offset of the given field in the given type */
#ifndef offsetof
/* GCC 4.0 and later has the builtin. */
#if defined(__GNUC__) && __GNUC__ >= 4
#define offsetof(Type, field) __builtin_offsetof(Type, field)
#else
#define offsetof(Type, field) ((size_t)(&((Type *)0)->field))
#endif
#endif
typedef uint8_t uint8;
typedef int8_t int8;