Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions include/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ Then you can use another oneliner to query all variables:
#undef XASH_PSVITA
#undef XASH_WASI
#undef XASH_WASM
#undef XASH_SPARC

//================================================================
//
// PLATFORM DETECTION CODE
// PLATFORM DETECTION CODE
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless change.

Really, just uninstall your code editor.

//
//================================================================
#if defined _WIN32
Expand Down Expand Up @@ -159,7 +160,7 @@ Then you can use another oneliner to query all variables:

//================================================================
//
// ENDIANNESS DEFINES
// ENDIANNESS DEFINES
//
//================================================================

Expand Down Expand Up @@ -195,7 +196,7 @@ Then you can use another oneliner to query all variables:

//================================================================
//
// CPU ARCHITECTURE DEFINES
// CPU ARCHITECTURE DEFINES
//
//================================================================
#if defined __x86_64__ || defined _M_X64
Expand Down Expand Up @@ -265,6 +266,11 @@ Then you can use another oneliner to query all variables:
#define XASH_64BIT 1
#endif
#define XASH_WASM 1
#elif defined __sparc__
#define XASH_SPARC 1
#if defined __arch64__
#define XASH_64BIT 1
#endif
#else
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
#endif
Expand Down
75 changes: 39 additions & 36 deletions include/buildenums.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ For more information, please refer to <http://unlicense.org/>

//================================================================
//
// OPERATING SYSTEM DEFINES
// OPERATING SYSTEM DEFINES
//
//================================================================
#define PLATFORM_WIN32 1
#define PLATFORM_LINUX 2
#define PLATFORM_FREEBSD 3
#define PLATFORM_ANDROID 4
#define PLATFORM_APPLE 5
#define PLATFORM_NETBSD 6
#define PLATFORM_OPENBSD 7
#define PLATFORM_WIN32 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's much worse now. Revert all of this. Only keep your own SPARC related changes.

#define PLATFORM_LINUX 2
#define PLATFORM_FREEBSD 3
#define PLATFORM_ANDROID 4
#define PLATFORM_APPLE 5
#define PLATFORM_NETBSD 6
#define PLATFORM_OPENBSD 7
#define PLATFORM_EMSCRIPTEN 8
#define PLATFORM_DOS4GW 9
#define PLATFORM_HAIKU 10
#define PLATFORM_SERENITY 11
#define PLATFORM_IRIX 12
#define PLATFORM_NSWITCH 13
#define PLATFORM_PSVITA 14
#define PLATFORM_WASI 15
#define PLATFORM_SUNOS 16
#define PLATFORM_HURD 17
#define PLATFORM_PSP 18
#define PLATFORM_DOS4GW 9
#define PLATFORM_HAIKU 10
#define PLATFORM_SERENITY 11
#define PLATFORM_IRIX 12
#define PLATFORM_NSWITCH 13
#define PLATFORM_PSVITA 14
#define PLATFORM_WASI 15
#define PLATFORM_SUNOS 16
#define PLATFORM_HURD 17
#define PLATFORM_PSP 18

#if XASH_WIN32
#define XASH_PLATFORM PLATFORM_WIN32
Expand Down Expand Up @@ -102,18 +102,19 @@ For more information, please refer to <http://unlicense.org/>

//================================================================
//
// CPU ARCHITECTURE DEFINES
// CPU ARCHITECTURE DEFINES
//
//================================================================
#define ARCHITECTURE_X86 1
#define ARCHITECTURE_AMD64 2
#define ARCHITECTURE_ARM 3
#define ARCHITECTURE_MIPS 4
#define ARCHITECTURE_JS 6
#define ARCHITECTURE_E2K 7
#define ARCHITECTURE_RISCV 8
#define ARCHITECTURE_PPC 9
#define ARCHITECTURE_WASM 10
#define ARCHITECTURE_X86 1
#define ARCHITECTURE_AMD64 2
#define ARCHITECTURE_ARM 3
#define ARCHITECTURE_MIPS 4
#define ARCHITECTURE_JS 6
#define ARCHITECTURE_E2K 7
#define ARCHITECTURE_RISCV 8
#define ARCHITECTURE_PPC 9
#define ARCHITECTURE_WASM 10
#define ARCHITECTURE_SPARC 11

#if XASH_AMD64
#define XASH_ARCHITECTURE ARCHITECTURE_AMD64
Expand All @@ -133,17 +134,19 @@ For more information, please refer to <http://unlicense.org/>
#define XASH_ARCHITECTURE ARCHITECTURE_PPC
#elif XASH_WASM
#define XASH_ARCHITECTURE ARCHITECTURE_WASM
#elif XASH_SPARC
#define XASH_ARCHITECTURE ARCHITECTURE_SPARC
#else
#error
#endif

//================================================================
//
// ENDIANNESS DEFINES
// ENDIANNESS DEFINES
//
//================================================================
#define ENDIANNESS_LITTLE 1
#define ENDIANNESS_BIG 2
#define ENDIANNESS_BIG 2

#if XASH_LITTLE_ENDIAN
#define XASH_ENDIANNESS ENDIANNESS_LITTLE
Expand All @@ -155,17 +158,17 @@ For more information, please refer to <http://unlicense.org/>

//================================================================
//
// APPLICATION BINARY INTERFACE
// APPLICATION BINARY INTERFACE
//
//================================================================
#define BIT( n ) ( 1U << ( n ))
#define BIT( n ) ( 1U << ( n ))
#define FBitSet( bit_vector, bits ) (( bit_vector ) & ( bits ))

#define ARCH_ARM_VER_MASK ( BIT( 5 ) - 1 )
#define ARCH_ARM_VER_SHIFT 0
#define ARCH_ARM_HARDFP BIT( 5 )
#define ARCH_ARM_VER_MASK ( BIT( 5 ) - 1 )
#define ARCH_ARM_VER_SHIFT 0
#define ARCH_ARM_HARDFP BIT( 5 )

#define ARCH_RISCV_FP_SOFT 0
#define ARCH_RISCV_FP_SOFT 0
#define ARCH_RISCV_FP_SINGLE 1
#define ARCH_RISCV_FP_DOUBLE 2

Expand Down
8 changes: 4 additions & 4 deletions include/library_suffix.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ const char *Q_buildarch( void ) RETURNS_NONNULL;
// <prefix><name>_<os>_<arch>.<ext>
// where
// - prefix: widely accepted DLL prefix. Currently only adds "lib" on Android
// - name: DLL name, without Intel suffix (like _i?86). You can strip it with COM_StripIntelSuffix
// - os: Q_buildos return value, omitted for win32, linux and osx
// - arch: Q_buildarch return value, omitted for 32-bit x86 on win32, linux and osx
// - ext: widely accepted DLL extension
// - name: DLL name, without Intel suffix (like _i?86). You can strip it with COM_StripIntelSuffix
// - os: Q_buildos return value, omitted for win32, linux and osx
// - arch: Q_buildarch return value, omitted for 32-bit x86 on win32, linux and osx
// - ext: widely accepted DLL extension
// return value: number of bytes written, excluding null terminator, or -1 on overflow
int COM_GenerateCommonLibraryName( const char *name, char *out, size_t size );

Expand Down
2 changes: 2 additions & 0 deletions src/library_suffix.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ const char *Q_ArchitectureStringByID( int arch, unsigned int abi, int endianness
break;
case ARCHITECTURE_WASM:
return is64 ? "wasm64" : "wasm32";
case ARCHITECTURE_SPARC:
return is64 ? "sparc64" : "sparc";
}

return is64 ?
Expand Down
4 changes: 4 additions & 0 deletions tests/test_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ static struct
{ ARCHITECTURE_RISCV, ARCH_RISCV_FP_SINGLE, -1, 0, "riscv32f" },
{ ARCHITECTURE_RISCV, ARCH_RISCV_FP_DOUBLE, -1, 1, "riscv64d" },
{ ARCHITECTURE_RISCV, ARCH_RISCV_FP_DOUBLE, -1, 0, "riscv32d" },

// SPARC
{ ARCHITECTURE_SPARC, 0, ENDIANNESS_BIG, 0, "sparc" },
{ ARCHITECTURE_SPARC, 0, ENDIANNESS_BIG, 1, "sparc64" }
};

static int TestPlatformString( void )
Expand Down