source: trunk/lib/mmalloc.hpp @ 3148

Last change on this file since 3148 was 2616, checked in by ksherdy, 7 years ago

Added sizeof(BitBlock?) aligned STL allocator and memory alignment allocation/deallocation template methods.

File size: 831 bytes
Line 
1#ifndef ALIGNED_MMALLOC_HPP
2#define ALIGNED_MMALLOC_HPP
3/*=============================================================================
4  allocator.hpp - Platform independent aligned memory allocation.
5  Created on: 06-December-2011
6  Author: Ken Herdy
7
8        Description:   
9
10        TODO -  Wrap routines inside a class scope and/or C++ custom namespace.
11
12=============================================================================*/
13
14#include "bitblock.hpp"
15
16#if defined USE_NEON
17        #error "Neon aligned memory allocation not implemented. Aborting compilation."
18#else // USE_SSE
19
20        template <class T> T * simd_malloc(uint32_t n) 
21        {
22                return (T*)_mm_malloc(n*sizeof(T), sizeof(BitBlock));           
23        }
24
25        template <class T> void simd_free(T* p) 
26        {
27                if(p != NULL) 
28                { 
29                        _mm_free(p); 
30                        p = NULL;                       
31                }
32
33        }
34#endif
35
36#endif // ALIGNED_MMALLOC_HPP
Note: See TracBrowser for help on using the repository browser.