From d8e159772635061504356d85cddba2d885235889 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 26 Feb 2026 05:59:42 +0500 Subject: [PATCH] common: xash3d_types: add Quake's link_t definition and offsetof macro --- common/const.h | 5 ----- common/xash3d_types.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/common/const.h b/common/const.h index 349c62a8..f6189d03 100644 --- a/common/const.h +++ b/common/const.h @@ -735,11 +735,6 @@ typedef struct unsigned r, g, b, a; } colorVec; -typedef struct link_s -{ - struct link_s *prev, *next; -} link_t; - typedef struct edict_s edict_t; typedef struct diff --git a/common/xash3d_types.h b/common/xash3d_types.h index 7e92b118..b82f1fd0 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -50,6 +50,12 @@ typedef ssize_t fs_size_t; typedef unsigned int uint; typedef void *(*pfnCreateInterface_t)( const char *, int * ); +// Quake definition +typedef struct link_s +{ + struct link_s *prev, *next; +} link_t; + #undef true #undef false @@ -109,10 +115,15 @@ typedef int qboolean; #define ALLOC_CHECK( x ) __attribute__(( alloc_size( x ))) #define WARN_UNUSED_RESULT __attribute__(( warn_unused_result )) #define RENAME_SYMBOL( x ) asm( x ) + #if !defined( offsetof ) + #define offsetof( s, m ) __builtin_offsetof( s, m ) + #endif // !defined( offsetof ) #elif defined( _MSC_VER ) #define EXPORT __declspec( dllexport ) #endif +#define ARRAYSIZE( p ) ( sizeof(( p ))/ sizeof(( p )[0] )) + #if defined( __SANITIZE_ADDRESS__ ) #define USE_ASAN 1 @@ -196,6 +207,10 @@ typedef int qboolean; #define XASH_RESTRICT #endif +#if !defined( offsetof ) + #define offsetof( s, m ) (size_t)&(((s *)0)->m ) +#endif // !defined( offsetof ) + #if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword #define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y ) #define STATIC_ASSERT static_assert