mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-12 19:20:36 +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,
|
||||
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>
|
||||
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
|
||||
#ifdef _MSC_VER
|
||||
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
|
||||
void_result = _mm_malloc(size*sizeof(T), 16);
|
||||
#endif
|
||||
@ -71,7 +73,7 @@ inline T* ei_aligned_malloc(size_t size)
|
||||
// and this type has a custom operator new, then we want to honor this operator new!
|
||||
// so when we use C functions to allocate memory, we must be careful to call manually the constructor using
|
||||
// the special placement-new syntax.
|
||||
return new(void_result) T[size];
|
||||
return new(void_result) T[size];
|
||||
}
|
||||
else
|
||||
return new T[size]; // here we really want a new, not a malloc. Justification: if the user uses Eigen on
|
||||
@ -95,6 +97,8 @@ inline void ei_aligned_free(T* ptr, size_t size)
|
||||
while(size) ptr[--size].~T();
|
||||
#if defined(__linux)
|
||||
free(ptr);
|
||||
#elif defined(__APPLE__)
|
||||
free(ptr);
|
||||
#elif defined(_MSC_VER)
|
||||
_aligned_free(ptr);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user