diff options
author | Chris Robinson <[email protected]> | 2019-01-07 04:06:40 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-01-07 04:06:40 -0800 |
commit | 4d047e2bc166e8155dd9714e53efda09def2b6ef (patch) | |
tree | c4fd18bb468987043322f59a31297bf55844fda8 /OpenAL32/Include/alMain.h | |
parent | 67c9cf81748422b6a96945c6e0508a61f83f12f6 (diff) |
Use user-defined literals for 64-bit literals
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r-- | OpenAL32/Include/alMain.h | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index ab0c6206..f0771386 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -63,25 +63,8 @@ constexpr inline size_t countof(const T(&)[N]) noexcept using ALint64 = ALint64SOFT; using ALuint64 = ALuint64SOFT; -#ifndef U64 -#if defined(_MSC_VER) -#define U64(x) ((ALuint64)(x##ui64)) -#elif SIZEOF_LONG == 8 -#define U64(x) ((ALuint64)(x##ul)) -#elif SIZEOF_LONG_LONG == 8 -#define U64(x) ((ALuint64)(x##ull)) -#endif -#endif - -#ifndef I64 -#if defined(_MSC_VER) -#define I64(x) ((ALint64)(x##i64)) -#elif SIZEOF_LONG == 8 -#define I64(x) ((ALint64)(x##l)) -#elif SIZEOF_LONG_LONG == 8 -#define I64(x) ((ALint64)(x##ll)) -#endif -#endif +inline constexpr int64_t operator "" _i64(unsigned long long int n) noexcept { return static_cast<int64_t>(n); } +inline constexpr uint64_t operator "" _u64(unsigned long long int n) noexcept { return static_cast<uint64_t>(n); } /* Define CTZ macros (count trailing zeros), and POPCNT macros (population * count/count 1 bits), for 32- and 64-bit integers. The CTZ macros' results @@ -174,10 +157,10 @@ inline int fallback_ctz32(ALuint value) inline int fallback_popcnt64(ALuint64 v) { - v = v - ((v >> 1) & U64(0x5555555555555555)); - v = (v & U64(0x3333333333333333)) + ((v >> 2) & U64(0x3333333333333333)); - v = (v + (v >> 4)) & U64(0x0f0f0f0f0f0f0f0f); - return (int)((v * U64(0x0101010101010101)) >> 56); + v = v - ((v >> 1) & 0x5555555555555555_u64); + v = (v & 0x3333333333333333_u64) + ((v >> 2) & 0x3333333333333333_u64); + v = (v + (v >> 4)) & 0x0f0f0f0f0f0f0f0f_u64; + return (int)((v * 0x0101010101010101_u64) >> 56); } #define POPCNT64 fallback_popcnt64 inline int fallback_ctz64(ALuint64 value) @@ -775,7 +758,7 @@ struct ALCdevice { /* Nanosecond resolution for the device clock time. */ -#define DEVICE_CLOCK_RES U64(1000000000) +#define DEVICE_CLOCK_RES 1000000000_u64 /* Must be less than 15 characters (16 including terminating null) for |