System dependent 64 bit integer suffixes

Added macros SDL_SINT64_C() and SDL_UINT64_C().
Integer suffixes of SDL_MAX_SINT64, SDL_MIN_SINT64, SDL_MAX_UINT64
and SDL_MIN_UINT64 are now system dependent.
This commit is contained in:
Petar Popovic 2024-05-05 00:59:38 +02:00 committed by Sam Lantinga
parent d7d3028765
commit 45ac1a09d9
2 changed files with 13 additions and 7 deletions

View File

@ -136,6 +136,12 @@ void *alloca(size_t);
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
/**
* Append the 64 bit integer suffix to an integer literal.
*/
#define SDL_SINT64_C(c) INT64_C(c)
#define SDL_UINT64_C(c) UINT64_C(c)
/**
* \name Basic data types
*/
@ -228,8 +234,8 @@ typedef uint32_t Uint32;
*
* \since This macro is available since SDL 3.0.0.
*/
#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
#define SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */
#define SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */
typedef int64_t Sint64;
/**
@ -237,8 +243,8 @@ typedef int64_t Sint64;
*
* \since This macro is available since SDL 3.0.0.
*/
#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */
#define SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */
#define SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */
typedef uint64_t Uint64;
/**

View File

@ -39,9 +39,9 @@ SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT32, SDL_MIN_SINT32 == ~0x7fffffff); /* Inste
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT32, SDL_MAX_UINT32 == 4294967295u);
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT32, SDL_MIN_UINT32 == 0);
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT64, SDL_MAX_SINT64 == 9223372036854775807ll);
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT64, SDL_MIN_SINT64 == ~0x7fffffffffffffffll); /* Instead of -9223372036854775808, which is treated as unsigned by compilers */
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT64, SDL_MAX_UINT64 == 18446744073709551615ull);
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT64, SDL_MAX_SINT64 == INT64_C(9223372036854775807));
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT64, SDL_MIN_SINT64 == ~INT64_C(0x7fffffffffffffff)); /* Instead of -9223372036854775808, which is treated as unsigned by compilers */
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT64, SDL_MAX_UINT64 == UINT64_C(18446744073709551615));
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT64, SDL_MIN_UINT64 == 0);
static int TestTypes(SDL_bool verbose)