28 #ifndef VC_COMMON_MALLOC_H_ 
   29 #define VC_COMMON_MALLOC_H_ 
   31 #ifndef Vc_VECTOR_DECLARED_ 
   32 #error "Incorrect inclusion order. This header must be included from Vc/vector.h only." 
   35 #if defined _WIN32 || defined _WIN64 
   43 namespace Vc_VERSIONED_NAMESPACE
 
   48 template <
size_t X> 
static constexpr 
size_t nextMultipleOf(
size_t value)
 
   50     return (value % X) > 0 ? value + X - (value % X) : value;
 
   53 template <std::
size_t alignment> Vc_INTRINSIC 
void *aligned_malloc(std::size_t n)
 
   56     return _mm_malloc(nextMultipleOf<alignment>(n), alignment);
 
   59     return __mingw_aligned_malloc(nextMultipleOf<alignment>(n), alignment);
 
   61     return _aligned_malloc(nextMultipleOf<alignment>(n), alignment);
 
   65     if (0 == posix_memalign(&ptr, alignment < 
sizeof(
void *) ? 
sizeof(
void *) : alignment,
 
   66                             nextMultipleOf<alignment>(n))) {
 
   73 template <Vc::MallocAlignment A> Vc_ALWAYS_INLINE 
void *
malloc(
size_t n)
 
   77         return aligned_malloc<Vc::VectorAlignment>(n);
 
   80         return aligned_malloc<64>(n);
 
   83         return aligned_malloc<4096>(n);
 
   88 Vc_ALWAYS_INLINE 
void free(
void *p)
 
   94     return __mingw_aligned_free(p);
 
   96     return _aligned_free(p);
 
  106 #endif // VC_COMMON_MALLOC_H_ 
void free(T *p)
Frees memory that was allocated with Vc::malloc. 
 
Align on boundary of page sizes (e.g. 
 
Align on boundary of cache line sizes (e.g. 
 
T * malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access. 
 
Align on boundary of vector sizes (e.g.