public: allow building as shared library

This commit is contained in:
Alibek Omarov 2023-10-28 15:20:11 +03:00
parent f07eea5073
commit 8a493ae7d2
5 changed files with 108 additions and 107 deletions

View File

@ -78,12 +78,13 @@ typedef uint64_t longtime_t;
#if defined(__GNUC__) #if defined(__GNUC__)
#ifdef __i386__ #ifdef __i386__
#define EXPORT __attribute__ ((visibility ("default"),force_align_arg_pointer)) #define EXPORT __attribute__((visibility ("default"),force_align_arg_pointer))
#define GAME_EXPORT __attribute((force_align_arg_pointer)) #define GAME_EXPORT __attribute((force_align_arg_pointer))
#else #else
#define EXPORT __attribute__ ((visibility ("default"))) #define EXPORT __attribute__ ((visibility ("default")))
#define GAME_EXPORT #define GAME_EXPORT
#endif #endif
#define SYM_EXPORT __attribute__((visibility("default")))
#define _format(x) __attribute__((format(printf, x, x+1))) #define _format(x) __attribute__((format(printf, x, x+1)))
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull)) #define NONNULL __attribute__((nonnull))

View File

@ -26,15 +26,15 @@ typedef struct
uint in[16]; uint in[16];
} MD5Context_t; } MD5Context_t;
void CRC32_Init( uint32_t *pulCRC ); void EXPORT CRC32_Init( uint32_t *pulCRC );
byte CRC32_BlockSequence( byte *base, int length, int sequence ); byte EXPORT CRC32_BlockSequence( byte *base, int length, int sequence );
void CRC32_ProcessBuffer( uint32_t *pulCRC, const void *pBuffer, int nBuffer ); void EXPORT CRC32_ProcessBuffer( uint32_t *pulCRC, const void *pBuffer, int nBuffer );
void CRC32_ProcessByte( uint32_t *pulCRC, byte ch ); void EXPORT CRC32_ProcessByte( uint32_t *pulCRC, byte ch );
uint32_t CRC32_Final( uint32_t pulCRC ); uint32_t EXPORT CRC32_Final( uint32_t pulCRC );
void MD5Init( MD5Context_t *ctx ); void EXPORT MD5Init( MD5Context_t *ctx );
void MD5Update( MD5Context_t *ctx, const byte *buf, uint len ); void EXPORT MD5Update( MD5Context_t *ctx, const byte *buf, uint len );
void MD5Final( byte digest[16], MD5Context_t *ctx ); void EXPORT MD5Final( byte digest[16], MD5Context_t *ctx );
uint COM_HashKey( const char *string, uint hashSize ); uint EXPORT COM_HashKey( const char *string, uint hashSize );
char *MD5_Print( byte hash[16] ); char EXPORT *MD5_Print( byte hash[16] );
#endif // CRCLIB_H #endif // CRCLIB_H

View File

@ -47,60 +47,60 @@ enum
// //
// build.c // build.c
// //
int Q_buildnum( void ); int EXPORT Q_buildnum( void );
int Q_buildnum_date( const char *date ); int EXPORT Q_buildnum_date( const char *date );
int Q_buildnum_compat( void ); int EXPORT Q_buildnum_compat( void );
const char *Q_PlatformStringByID( const int platform ); const char EXPORT *Q_PlatformStringByID( const int platform );
const char *Q_buildos( void ); const char EXPORT *Q_buildos( void );
const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int endianness, const qboolean is64 ); const char EXPORT *Q_ArchitectureStringByID( const int arch, const uint abi, const int endianness, const qboolean is64 );
const char *Q_buildarch( void ); const char EXPORT *Q_buildarch( void );
const char *Q_buildcommit( void ); const char EXPORT *Q_buildcommit( void );
// //
// crtlib.c // crtlib.c
// //
void Q_strnlwr( const char *in, char *out, size_t size_out ); void EXPORT Q_strnlwr( const char *in, char *out, size_t size_out );
#define Q_strlen( str ) (( str ) ? strlen(( str )) : 0 ) #define Q_strlen( str ) (( str ) ? strlen(( str )) : 0 )
size_t Q_colorstr( const char *string ); size_t EXPORT Q_colorstr( const char *string );
char Q_toupper( const char in ); char EXPORT Q_toupper( const char in );
char Q_tolower( const char in ); char EXPORT Q_tolower( const char in );
size_t Q_strncat( char *dst, const char *src, size_t siz ); size_t EXPORT Q_strncat( char *dst, const char *src, size_t siz );
qboolean Q_isdigit( const char *str ); qboolean EXPORT Q_isdigit( const char *str );
qboolean Q_isspace( const char *str ); qboolean EXPORT Q_isspace( const char *str );
int Q_atoi( const char *str ); int EXPORT Q_atoi( const char *str );
float Q_atof( const char *str ); float EXPORT Q_atof( const char *str );
void Q_atov( float *vec, const char *str, size_t siz ); void EXPORT Q_atov( float *vec, const char *str, size_t siz );
#define Q_strchr strchr #define Q_strchr strchr
#define Q_strrchr strrchr #define Q_strrchr strrchr
qboolean Q_stricmpext( const char *pattern, const char *text ); qboolean EXPORT Q_stricmpext( const char *pattern, const char *text );
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen ); qboolean EXPORT Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen ); const byte EXPORT *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen );
const char *Q_timestamp( int format ); const char EXPORT *Q_timestamp( int format );
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args ); int EXPORT Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
int Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 ); int EXPORT Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );
#define Q_strpbrk strpbrk #define Q_strpbrk strpbrk
void COM_StripColors( const char *in, char *out ); void EXPORT COM_StripColors( const char *in, char *out );
#define Q_memprint( val ) Q_pretifymem( val, 2 ) #define Q_memprint( val ) Q_pretifymem( val, 2 )
char *Q_pretifymem( float value, int digitsafterdecimal ); char EXPORT *Q_pretifymem( float value, int digitsafterdecimal );
void COM_FileBase( const char *in, char *out, size_t size ); void EXPORT COM_FileBase( const char *in, char *out, size_t size );
const char *COM_FileExtension( const char *in ); const char EXPORT *COM_FileExtension( const char *in );
void COM_DefaultExtension( char *path, const char *extension, size_t size ); void EXPORT COM_DefaultExtension( char *path, const char *extension, size_t size );
void COM_ReplaceExtension( char *path, const char *extension, size_t size ); void EXPORT COM_ReplaceExtension( char *path, const char *extension, size_t size );
void COM_ExtractFilePath( const char *path, char *dest ); void EXPORT COM_ExtractFilePath( const char *path, char *dest );
const char *COM_FileWithoutPath( const char *in ); const char EXPORT *COM_FileWithoutPath( const char *in );
void COM_StripExtension( char *path ); void EXPORT COM_StripExtension( char *path );
void COM_RemoveLineFeed( char *str ); void EXPORT COM_RemoveLineFeed( char *str );
void COM_FixSlashes( char *pname ); void EXPORT COM_FixSlashes( char *pname );
void COM_PathSlashFix( char *path ); void EXPORT COM_PathSlashFix( char *path );
char COM_Hex2Char( uint8_t hex ); char EXPORT COM_Hex2Char( uint8_t hex );
void COM_Hex2String( uint8_t hex, char *str ); void EXPORT COM_Hex2String( uint8_t hex, char *str );
// return 0 on empty or null string, 1 otherwise // return 0 on empty or null string, 1 otherwise
#define COM_CheckString( string ) ( ( !string || !*string ) ? 0 : 1 ) #define COM_CheckString( string ) ( ( !string || !*string ) ? 0 : 1 )
#define COM_CheckStringEmpty( string ) ( ( !*string ) ? 0 : 1 ) #define COM_CheckStringEmpty( string ) ( ( !*string ) ? 0 : 1 )
char *COM_ParseFileSafe( char *data, char *token, const int size, unsigned int flags, int *len, qboolean *quoted ); char EXPORT *COM_ParseFileSafe( char *data, char *token, const int size, unsigned int flags, int *len, qboolean *quoted );
#define COM_ParseFile( data, token, size ) COM_ParseFileSafe( data, token, size, 0, NULL, NULL ) #define COM_ParseFile( data, token, size ) COM_ParseFileSafe( data, token, size, 0, NULL, NULL )
int matchpattern( const char *in, const char *pattern, qboolean caseinsensitive ); int EXPORT matchpattern( const char *in, const char *pattern, qboolean caseinsensitive );
int matchpattern_with_separator( const char *in, const char *pattern, qboolean caseinsensitive, const char *separators, qboolean wildcard_least_one ); int EXPORT matchpattern_with_separator( const char *in, const char *pattern, qboolean caseinsensitive, const char *separators, qboolean wildcard_least_one );
// libc implementations // libc implementations
static inline int Q_strcmp( const char *s1, const char *s2 ) static inline int Q_strcmp( const char *s1, const char *s2 )

View File

@ -17,10 +17,10 @@ def configure(conf):
def build(bld): def build(bld):
bld(name = 'sdk_includes', export_includes = '. ../common ../pm_shared ../engine') bld(name = 'sdk_includes', export_includes = '. ../common ../pm_shared ../engine')
bld.stlib(source = bld.path.ant_glob('*.c'), bld.shlib(source = bld.path.ant_glob('*.c'),
target = 'public', target = 'public',
features = 'c', features = 'c',
use = 'sdk_includes', use = 'sdk_includes M',
subsystem = bld.env.MSVC_SUBSYSTEM) subsystem = bld.env.MSVC_SUBSYSTEM)
if bld.env.TESTS: if bld.env.TESTS:

View File

@ -179,33 +179,33 @@ static inline void SinCos( float radians, float *sine, float *cosine )
*cosine = cos(radians); *cosine = cos(radians);
} }
float rsqrt( float number ); float EXPORT rsqrt( float number );
float anglemod( float a ); float EXPORT anglemod( float a );
word FloatToHalf( float v ); word EXPORT FloatToHalf( float v );
float HalfToFloat( word h ); float EXPORT HalfToFloat( word h );
void RoundUpHullSize( vec3_t size ); void EXPORT RoundUpHullSize( vec3_t size );
int SignbitsForPlane( const vec3_t normal ); int EXPORT SignbitsForPlane( const vec3_t normal );
int PlaneTypeForNormal( const vec3_t normal ); int EXPORT PlaneTypeForNormal( const vec3_t normal );
int NearestPOW( int value, qboolean roundDown ); int EXPORT NearestPOW( int value, qboolean roundDown );
float VectorNormalizeLength2( const vec3_t v, vec3_t out ); float EXPORT VectorNormalizeLength2( const vec3_t v, vec3_t out );
qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon ); qboolean EXPORT VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon );
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up ); void EXPORT VectorVectors( const vec3_t forward, vec3_t right, vec3_t up );
void VectorAngles( const float *forward, float *angles ); void EXPORT VectorAngles( const float *forward, float *angles );
void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up ); void EXPORT AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up );
void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, vec3_t angles ); void EXPORT VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, vec3_t angles );
void PlaneIntersect( const struct mplane_s *plane, const vec3_t p0, const vec3_t p1, vec3_t out ); void EXPORT PlaneIntersect( const struct mplane_s *plane, const vec3_t p0, const vec3_t p1, vec3_t out );
void ClearBounds( vec3_t mins, vec3_t maxs ); void EXPORT ClearBounds( vec3_t mins, vec3_t maxs );
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); void EXPORT AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
qboolean BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 ); qboolean EXPORT BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 );
qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius ); qboolean EXPORT BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius );
qboolean SphereIntersect( const vec3_t vSphereCenter, float fSphereRadiusSquared, const vec3_t vLinePt, const vec3_t vLineDir ); qboolean EXPORT SphereIntersect( const vec3_t vSphereCenter, float fSphereRadiusSquared, const vec3_t vLinePt, const vec3_t vLineDir );
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); float EXPORT RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset ); void EXPORT ExpandBounds( vec3_t mins, vec3_t maxs, float offset );
void AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio ); void EXPORT AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio );
void QuaternionAngle( const vec4_t q, vec3_t angles ); void EXPORT QuaternionAngle( const vec4_t q, vec3_t angles );
void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt ); void EXPORT QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt );
// //
// matrixlib.c // matrixlib.c
@ -227,35 +227,35 @@ static inline void Matrix3x4_OriginFromMatrix( const matrix3x4 in, float *out )
out[2] = in[2][3]; out[2] = in[2][3];
} }
void Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[3] ); void EXPORT Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] ); void EXPORT Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_VectorRotate( const matrix3x4 in, const float v[3], float out[3] ); void EXPORT Matrix3x4_VectorRotate( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_VectorIRotate( const matrix3x4 in, const float v[3], float out[3] ); void EXPORT Matrix3x4_VectorIRotate( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matrix3x4 in2 ); void EXPORT Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matrix3x4 in2 );
void Matrix3x4_FromOriginQuat( matrix3x4 out, const vec4_t quaternion, const vec3_t origin ); void EXPORT Matrix3x4_FromOriginQuat( matrix3x4 out, const vec4_t quaternion, const vec3_t origin );
void Matrix3x4_CreateFromEntity( matrix3x4 out, const vec3_t angles, const vec3_t origin, float scale ); void EXPORT Matrix3x4_CreateFromEntity( matrix3x4 out, const vec3_t angles, const vec3_t origin, float scale );
void Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const vec3_t maxs, vec3_t absmin, vec3_t absmax ); void EXPORT Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const vec3_t maxs, vec3_t absmin, vec3_t absmax );
void Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out ); void EXPORT Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out );
#define Matrix4x4_LoadIdentity( mat ) Matrix4x4_Copy( mat, m_matrix4x4_identity ) #define Matrix4x4_LoadIdentity( mat ) Matrix4x4_Copy( mat, m_matrix4x4_identity )
#define Matrix4x4_Copy( out, in ) memcpy( out, in, sizeof( matrix4x4 )) #define Matrix4x4_Copy( out, in ) memcpy( out, in, sizeof( matrix4x4 ))
void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] ); void EXPORT Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] );
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] ); void EXPORT Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] );
void Matrix4x4_VectorRotate( const matrix4x4 in, const float v[3], float out[3] ); void EXPORT Matrix4x4_VectorRotate( const matrix4x4 in, const float v[3], float out[3] );
void Matrix4x4_VectorIRotate( const matrix4x4 in, const float v[3], float out[3] ); void EXPORT Matrix4x4_VectorIRotate( const matrix4x4 in, const float v[3], float out[3] );
void Matrix4x4_ConcatTransforms( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 ); void EXPORT Matrix4x4_ConcatTransforms( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 );
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale ); void EXPORT Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale );
void Matrix4x4_TransformPositivePlane( const matrix4x4 in, const vec3_t normal, float d, vec3_t out, float *dist ); void EXPORT Matrix4x4_TransformPositivePlane( const matrix4x4 in, const vec3_t normal, float d, vec3_t out, float *dist );
void Matrix4x4_ConvertToEntity( const matrix4x4 in, vec3_t angles, vec3_t origin ); void EXPORT Matrix4x4_ConvertToEntity( const matrix4x4 in, vec3_t angles, vec3_t origin );
void Matrix4x4_Invert_Simple( matrix4x4 out, const matrix4x4 in1 ); void EXPORT Matrix4x4_Invert_Simple( matrix4x4 out, const matrix4x4 in1 );
qboolean Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 ); qboolean EXPORT Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 );
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s ); void EXPORT R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s );
void R_StudioCalcBoneQuaternion( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec4_t q ); void EXPORT R_StudioCalcBoneQuaternion( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec4_t q );
void R_StudioCalcBonePosition( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const vec3_t adj, vec3_t pos ); void EXPORT R_StudioCalcBonePosition( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const vec3_t adj, vec3_t pos );
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p ); int EXPORT BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
#define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \ #define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \
((( p )->type < 3 ) ? \ ((( p )->type < 3 ) ? \
( \ ( \
@ -272,11 +272,11 @@ int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
: \ : \
BoxOnPlaneSide(( emins ), ( emaxs ), ( p ))) BoxOnPlaneSide(( emins ), ( emaxs ), ( p )))
extern vec3_t vec3_origin; extern vec3_t SYM_EXPORT vec3_origin;
extern int boxpnt[6][4]; extern int SYM_EXPORT boxpnt[6][4];
extern const matrix3x4 m_matrix3x4_identity; extern const matrix3x4 SYM_EXPORT m_matrix3x4_identity;
extern const matrix4x4 m_matrix4x4_identity; extern const matrix4x4 SYM_EXPORT m_matrix4x4_identity;
extern const float m_bytenormals[NUMVERTEXNORMALS][3]; extern const float SYM_EXPORT m_bytenormals[NUMVERTEXNORMALS][3];
#endif // XASH3D_MATHLIB_H #endif // XASH3D_MATHLIB_H