diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-09-18 12:35:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-18 12:35:07 +0200 |
| commit | b1b56fd04551e20fc05b28e92bfa2b5d2641c8ac (patch) | |
| tree | 4c88080c9ecf503f8677fe559fc64c65dba83251 /core/math/math_funcs.h | |
| parent | 2d9b409103f8bb0ee565b40cc3d4709939862e56 (diff) | |
| parent | 413ff7938df54c6c0bf6dc3ecd86c2c713f6f43a (diff) | |
Merge pull request #42157 from akien-mga/math-RANDOM_MAX-netbsd
Linux/BSD: Fix support for NetBSD
Diffstat (limited to 'core/math/math_funcs.h')
| -rw-r--r-- | core/math/math_funcs.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 9f8d4da5b3..24b42790f0 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -46,7 +46,8 @@ class Math { public: Math() {} // useless to instance - static const uint64_t RANDOM_MAX = 0xFFFFFFFF; + // Not using 'RANDOM_MAX' to avoid conflict with system headers on some OSes (at least NetBSD). + static const uint64_t RANDOM_32BIT_MAX = 0xFFFFFFFF; static _ALWAYS_INLINE_ double sin(double p_x) { return ::sin(p_x); } static _ALWAYS_INLINE_ float sin(float p_x) { return ::sinf(p_x); } @@ -283,8 +284,8 @@ public: static void randomize(); static uint32_t rand_from_seed(uint64_t *seed); static uint32_t rand(); - static _ALWAYS_INLINE_ double randd() { return (double)rand() / (double)Math::RANDOM_MAX; } - static _ALWAYS_INLINE_ float randf() { return (float)rand() / (float)Math::RANDOM_MAX; } + static _ALWAYS_INLINE_ double randd() { return (double)rand() / (double)Math::RANDOM_32BIT_MAX; } + static _ALWAYS_INLINE_ float randf() { return (float)rand() / (float)Math::RANDOM_32BIT_MAX; } static double random(double from, double to); static float random(float from, float to); |