Core/Random: Use correct headers to obtain _mm_malloc definitions

This commit is contained in:
Shauren
2024-02-17 12:03:06 +01:00
parent ea68ead90d
commit b9c2dca59f

View File

@@ -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()