From e1eaea7e7818b3a78f0ce50096e3411299958ccd Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 9 Nov 2014 10:24:36 -0500 Subject: [PATCH] Port offsetof "fix" from sdk2013. --- public/datamap.h | 4 ---- public/studio.h | 4 ---- public/tier0/platform.h | 11 +++++++++++ public/vgui_controls/MessageMap.h | 4 ---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/public/datamap.h b/public/datamap.h index de3b3e93..537936ab 100644 --- a/public/datamap.h +++ b/public/datamap.h @@ -120,10 +120,6 @@ DECLARE_FIELD_SIZE( FIELD_MODELINDEX, sizeof(int) ) DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) ) -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - #define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0])) #define SIZE_OF_ARRAY(p) _ARRAYSIZE(p) diff --git a/public/studio.h b/public/studio.h index f7612ae5..848b967f 100644 --- a/public/studio.h +++ b/public/studio.h @@ -28,10 +28,6 @@ #include "localflexcontroller.h" -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - #define STUDIO_ENABLE_PERF_COUNTERS #define STUDIO_SEQUENCE_ACTIVITY_LOOKUPS_ARE_SLOW 0 diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 1fad3681..6f46723a 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -252,6 +252,17 @@ typedef void * HINSTANCE; #define MAX_PATH 260 #endif + +#ifdef GNUC +#undef offsetof +//#define offsetof( type, var ) __builtin_offsetof( type, var ) +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#else +#undef offsetof +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#endif + + #define ALIGN_VALUE( val, alignment ) ( ( val + alignment - 1 ) & ~( alignment - 1 ) ) // need macro for constant expression // Used to step into the debugger diff --git a/public/vgui_controls/MessageMap.h b/public/vgui_controls/MessageMap.h index 63eee288..7f0f5c51 100644 --- a/public/vgui_controls/MessageMap.h +++ b/public/vgui_controls/MessageMap.h @@ -22,10 +22,6 @@ namespace vgui ////////////// MESSAGEMAP DEFINITIONS ////////////// -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - #ifndef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) #endif