diff options
Diffstat (limited to 'src/common/Utilities/SFMTRand.cpp')
-rw-r--r-- | src/common/Utilities/SFMTRand.cpp | 77 |
1 files changed, 3 insertions, 74 deletions
diff --git a/src/common/Utilities/SFMTRand.cpp b/src/common/Utilities/SFMTRand.cpp index 63918fce710..e39cfa1bc46 100644 --- a/src/common/Utilities/SFMTRand.cpp +++ b/src/common/Utilities/SFMTRand.cpp @@ -22,44 +22,13 @@ #include <random> #include <ctime> -#if __has_include(<mm_malloc.h>) -#include <mm_malloc.h> -#elif __has_include(<malloc.h>) && TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT -#include <malloc.h> -#else -static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__)) -_mm_malloc(size_t __size, size_t __align) -{ - if (__align == 1) - { - return malloc(__size); - } - - if (!(__align & (__align - 1)) && __align < sizeof(void *)) - __align = sizeof(void *); - - void *__mallocedMemory; - - if (posix_memalign(&__mallocedMemory, __align, __size)) - return NULL; - - return __mallocedMemory; -} - -static __inline__ void __attribute__((__always_inline__, __nodebug__)) -_mm_free(void *__p) -{ - free(__p); -} -#endif - -SFMTRand::SFMTRand() +SFMTRand::SFMTRand() noexcept { std::random_device dev; if (dev.entropy() > 0) { std::array<uint32, SFMT_N32> seed; - std::generate(seed.begin(), seed.end(), std::ref(dev)); + std::ranges::generate(seed, std::ref(dev)); sfmt_init_by_array(&_state, seed.data(), seed.size()); } @@ -67,47 +36,7 @@ SFMTRand::SFMTRand() sfmt_init_gen_rand(&_state, uint32(time(nullptr))); } -uint32 SFMTRand::RandomUInt32() // Output random bits +uint32 SFMTRand::RandomUInt32() noexcept // Output random bits { return sfmt_genrand_uint32(&_state); } - -void* SFMTRand::operator new(size_t size, std::nothrow_t const&) -{ - return _mm_malloc(size, 16); -} - -void SFMTRand::operator delete(void* ptr, std::nothrow_t const&) -{ - _mm_free(ptr); -} - -void* SFMTRand::operator new(size_t size) -{ - return _mm_malloc(size, 16); -} - -void SFMTRand::operator delete(void* ptr) -{ - _mm_free(ptr); -} - -void* SFMTRand::operator new[](size_t size, std::nothrow_t const&) -{ - return _mm_malloc(size, 16); -} - -void SFMTRand::operator delete[](void* ptr, std::nothrow_t const&) -{ - _mm_free(ptr); -} - -void* SFMTRand::operator new[](size_t size) -{ - return _mm_malloc(size, 16); -} - -void SFMTRand::operator delete[](void* ptr) -{ - _mm_free(ptr); -} |