mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-30 02:05:18 +08:00
use ei_aligned_malloc and ei_aligned_free also in WithAlignedOperatorNew, so this too should now work with MSVC.
This commit is contained in:
parent
9b1a3d6e19
commit
763f0a2434
@ -27,9 +27,11 @@
|
|||||||
#define EIGEN_MEMORY_H
|
#define EIGEN_MEMORY_H
|
||||||
|
|
||||||
#ifdef EIGEN_VECTORIZE
|
#ifdef EIGEN_VECTORIZE
|
||||||
|
#ifndef _MSC_VER
|
||||||
// it seems we cannot assume posix_memalign is defined in the stdlib header
|
// it seems we cannot assume posix_memalign is defined in the stdlib header
|
||||||
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
|
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* Static array automatically aligned if the total byte size is a multiple of 16
|
* Static array automatically aligned if the total byte size is a multiple of 16
|
||||||
@ -165,24 +167,16 @@ struct WithAlignedOperatorNew
|
|||||||
|
|
||||||
void *operator new(size_t size) throw()
|
void *operator new(size_t size) throw()
|
||||||
{
|
{
|
||||||
void* ptr = 0;
|
return ei_aligned_malloc<char>(size);
|
||||||
if (posix_memalign(&ptr, 16, size)==0)
|
|
||||||
return ptr;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *operator new[](size_t size) throw()
|
void *operator new[](size_t size) throw()
|
||||||
{
|
{
|
||||||
void* ptr = 0;
|
return ei_aligned_malloc<char>(size);
|
||||||
if (posix_memalign(&ptr, 16, size)==0)
|
|
||||||
return ptr;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete(void * ptr) { free(ptr); }
|
void operator delete(void * ptr) { ei_aligned_free(static_cast<char *>(ptr)); }
|
||||||
void operator delete[](void * ptr) { free(ptr); }
|
void operator delete[](void * ptr) { ei_aligned_free(static_cast<char *>(ptr)); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user