From 7bcfce5a7a02a87e540c5416b09d2ea06b48741f Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 3 Oct 2021 04:26:40 +0300 Subject: [PATCH] ref_gl: use GCC provided offsetof implementation --- ref_gl/gl_local.h | 8 ++++++-- ref_soft/r_local.h | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ref_gl/gl_local.h b/ref_gl/gl_local.h index d3f49836..a50f7f0c 100644 --- a/ref_gl/gl_local.h +++ b/ref_gl/gl_local.h @@ -36,8 +36,12 @@ GNU General Public License for more details. #include "wadfile.h" #ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif // offsetof +#ifdef __GNUC__ +#define offsetof(s,m) __builtin_offsetof(s,m) +#else +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#endif +#endif #define ASSERT(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define Assert(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) diff --git a/ref_soft/r_local.h b/ref_soft/r_local.h index b75b072a..8a893bbb 100644 --- a/ref_soft/r_local.h +++ b/ref_soft/r_local.h @@ -36,10 +36,6 @@ typedef struct mip_s mip_t; typedef int fixed8_t; typedef int fixed16_t; -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif // offsetof - #define ASSERT(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define Assert(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )