mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Random: Use correct headers to obtain _mm_malloc definitions
This commit is contained in:
@@ -22,39 +22,35 @@
|
||||
#include <random>
|
||||
#include <ctime>
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#if defined(__clang__)
|
||||
#include <mm_malloc.h>
|
||||
#elif defined(__GNUC__)
|
||||
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);
|
||||
}
|
||||
#else
|
||||
#error aarch64 only on clang and gcc
|
||||
#endif
|
||||
#if __has_include(<mm_malloc.h>)
|
||||
#include <mm_malloc.h>
|
||||
#elif __has_include(<malloc.h>)
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <emmintrin.h>
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user