mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-31 17:22:07 +08:00
fix compilation on apple: _mm_malloc was undefined. the fix is to just use malloc since on apple it already returns aligned ptrs
This commit is contained in:
parent
e1ee876daa
commit
d316d4f393
@ -119,7 +119,7 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
|||||||
|
|
||||||
template<typename T, int Rows, int Cols, int Options,
|
template<typename T, int Rows, int Cols, int Options,
|
||||||
bool NeedsToAlign = ((Options&Matrix_AutoAlign) == Matrix_AutoAlign) && Rows!=Dynamic && Cols!=Dynamic && ((sizeof(T)*Rows*Cols)%16==0)>
|
bool NeedsToAlign = ((Options&Matrix_AutoAlign) == Matrix_AutoAlign) && Rows!=Dynamic && Cols!=Dynamic && ((sizeof(T)*Rows*Cols)%16==0)>
|
||||||
struct ei_matrix_with_aligned_operator_new : WithAlignedOperatorNew {};
|
struct ei_matrix_with_aligned_operator_new : public WithAlignedOperatorNew {};
|
||||||
|
|
||||||
template<typename T, int Rows, int Cols, int Options>
|
template<typename T, int Rows, int Cols, int Options>
|
||||||
struct ei_matrix_with_aligned_operator_new<T, Rows, Cols, Options, false> {};
|
struct ei_matrix_with_aligned_operator_new<T, Rows, Cols, Options, false> {};
|
||||||
|
@ -56,6 +56,8 @@ inline T* ei_aligned_malloc(size_t size)
|
|||||||
#else
|
#else
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
void_result = _aligned_malloc(size*sizeof(T), 16);
|
void_result = _aligned_malloc(size*sizeof(T), 16);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
void_result = malloc(size*sizeof(T)); // Apple's malloc() already returns aligned ptrs
|
||||||
#else
|
#else
|
||||||
void_result = _mm_malloc(size*sizeof(T), 16);
|
void_result = _mm_malloc(size*sizeof(T), 16);
|
||||||
#endif
|
#endif
|
||||||
@ -95,6 +97,8 @@ inline void ei_aligned_free(T* ptr, size_t size)
|
|||||||
while(size) ptr[--size].~T();
|
while(size) ptr[--size].~T();
|
||||||
#if defined(__linux)
|
#if defined(__linux)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
free(ptr);
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
_aligned_free(ptr);
|
_aligned_free(ptr);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user