diff --git a/src/base/array/array.h b/src/base/array/array.h index 27760d2..2d2a9d2 100644 --- a/src/base/array/array.h +++ b/src/base/array/array.h @@ -12,7 +12,7 @@ BEGIN_C_LINKAGE #endif // !WP_PLATFORM_CPP -#define WP_ARRAY_MAGIC (u64)0x57415f415252 +#define WP_ARRAY_MAGIC wpU64Const(0x57415f415252) #define _calcArrayCount(TYPE, ...) wpMiscUtilsVaArgsCount(TYPE, __VA_ARGS__) #define _calcArrayCapacity(TYPE, ...) wpMiscUtilsU64RoundUpPow2(_calcArrayCount(TYPE, __VA_ARGS__) * 2) diff --git a/src/base/dbl_list/dbl_list.h b/src/base/dbl_list/dbl_list.h index 14d403e..9583453 100644 --- a/src/base/dbl_list/dbl_list.h +++ b/src/base/dbl_list/dbl_list.h @@ -11,8 +11,8 @@ BEGIN_C_LINKAGE #endif // !WP_PLATFORM_CPP -#define WP_DBL_LIST_MAGIC (u64)0x57415f444c5354 -#define WP_DBL_NODE_MAGIC (u64)0x57415f444e44 +#define WP_DBL_LIST_MAGIC wpU64Const(0x57415f444c5354) +#define WP_DBL_NODE_MAGIC wpU64Const(0x57415f444e44) typedef struct WpDblNode WpDblNode; diff --git a/src/base/hash/hasher/murmur3.c b/src/base/hash/hasher/murmur3.c index afe7426..2947f9a 100644 --- a/src/base/hash/hasher/murmur3.c +++ b/src/base/hash/hasher/murmur3.c @@ -5,8 +5,6 @@ #include "../../../common/assert/assert.h" #include "../../../common/misc/misc_utils.h" -#define _bigConstant(x) (x##LLU) - wp_intern inline void _validateIO(const WpMur3HasherIO *io); wp_intern inline u64 _fmix64(u64 k); @@ -19,8 +17,8 @@ void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) { u64 h1 = io->seed; u64 h2 = io->seed; - const u64 c1 = _bigConstant(0x87c37b91114253d5); - const u64 c2 = _bigConstant(0x4cf5ad432745937f); + const u64 c1 = wpU64Const(0x87c37b91114253d5); + const u64 c2 = wpU64Const(0x4cf5ad432745937f); //---------- // body @@ -103,9 +101,9 @@ wp_intern inline void _validateIO(const WpMur3HasherIO *io) { wp_intern inline u64 _fmix64(u64 k) { k ^= k >> 33; - k *= _bigConstant(0xff51afd7ed558ccd); + k *= wpU64Const(0xff51afd7ed558ccd); k ^= k >> 33; - k *= _bigConstant(0xc4ceb9fe1a85ec53); + k *= wpU64Const(0xc4ceb9fe1a85ec53); k ^= k >> 33; return k; diff --git a/src/base/hash/hasher/murmur3.h b/src/base/hash/hasher/murmur3.h index bc3818f..2dd16b5 100644 --- a/src/base/hash/hasher/murmur3.h +++ b/src/base/hash/hasher/murmur3.h @@ -16,7 +16,7 @@ BEGIN_C_LINKAGE #endif // !WP_PLATFORM_CPP -#define WP_MUR3_HASHER_MAGIC ((u64)0x57504d4841534833) +#define WP_MUR3_HASHER_MAGIC wpU64Const(0x57504d4841534833) typedef struct { u64 hash[2]; diff --git a/src/base/hash/hasher/siphash.c b/src/base/hash/hasher/siphash.c index cf0d600..b3610eb 100644 --- a/src/base/hash/hasher/siphash.c +++ b/src/base/hash/hasher/siphash.c @@ -4,7 +4,6 @@ #include "../../../common/aliases/aliases.h" #include "../../../common/assert/assert.h" #include "../../../common/misc/misc_utils.h" -#include wp_intern inline void _siphash(WpStream *bytes, const WpSipHasherParams *params, u8 *out, u64 outlen); wp_intern inline void _validate128IO(const WpSipHasher128IO *io); @@ -64,10 +63,10 @@ wp_intern inline void _siphash(WpStream *bytes, const WpSipHasherParams *params, wpRuntimeAssert((outlen == 8) || (outlen == 16), "outlen should be 8 or 16"); - u64 v0 = UINT64_C(0x736f6d6570736575); - u64 v1 = UINT64_C(0x646f72616e646f6d); - u64 v2 = UINT64_C(0x6c7967656e657261); - u64 v3 = UINT64_C(0x7465646279746573); + u64 v0 = wpU64Const(0x736f6d6570736575); + u64 v1 = wpU64Const(0x646f72616e646f6d); + u64 v2 = wpU64Const(0x6c7967656e657261); + u64 v3 = wpU64Const(0x7465646279746573); u64 k0 = _u8To64LE(kk); u64 k1 = _u8To64LE(kk + 8); u64 m; diff --git a/src/base/hash/hasher/siphash.h b/src/base/hash/hasher/siphash.h index 7112af6..bdef8cf 100644 --- a/src/base/hash/hasher/siphash.h +++ b/src/base/hash/hasher/siphash.h @@ -16,8 +16,8 @@ BEGIN_C_LINKAGE #endif // !WP_PLATFORM_CPP -#define WP_SIP_HASHER_128_MAGIC ((u64)0x5750534950313238) -#define WP_SIP_HASHER_64_MAGIC ((u64)0x57505349503634) +#define WP_SIP_HASHER_128_MAGIC wpU64Const(0x5750534950313238) +#define WP_SIP_HASHER_64_MAGIC wpU64Const(0x57505349503634) typedef struct { u64 lo; diff --git a/src/common/aliases/aliases.h b/src/common/aliases/aliases.h index 01d52c0..4a59cba 100644 --- a/src/common/aliases/aliases.h +++ b/src/common/aliases/aliases.h @@ -28,6 +28,11 @@ typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +#define wpU8Const UINT8_C +#define wpU16Const UINT16_C +#define wpU32Const UINT32_C +#define wpU64Const UINT64_C + typedef uint8_t b8; #ifndef WP_PLATFORM_CPP @@ -47,6 +52,11 @@ typedef int16_t i16; typedef int32_t i32; typedef int64_t i64; +#define wpI8Const INT8_C +#define wpI16Const INT16_C +#define wpI32Const INT32_C +#define wpI64Const INT64_C + typedef float f32; typedef double f64; typedef long double f128;