Commit 36ccf05a authored by Martin Reinecke's avatar Martin Reinecke
Browse files

sync with pocketfft sources

parent 7eb4e922
...@@ -56,9 +56,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -56,9 +56,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif #endif
#ifdef __GNUC__ #if defined(__GNUC__)
#define NOINLINE __attribute__((noinline)) #define NOINLINE __attribute__((noinline))
#define restrict __restrict__ #define restrict __restrict__
#elif defined(_MSC_VER)
#define NOINLINE __declspec(noinline)
#define restrict __restrict
#else #else
#define NOINLINE #define NOINLINE
#define restrict #define restrict
...@@ -97,29 +100,48 @@ template<typename T> class arr ...@@ -97,29 +100,48 @@ template<typename T> class arr
T *p; T *p;
size_t sz; size_t sz;
#if defined(POCKETFFT_NO_VECTORS)
static T *ralloc(size_t num) static T *ralloc(size_t num)
{ {
if (num==0) return nullptr; if (num==0) return nullptr;
#ifdef POCKETFFT_NO_VECTORS
void *res = malloc(num*sizeof(T)); void *res = malloc(num*sizeof(T));
if (!res) throw bad_alloc(); if (!res) throw bad_alloc();
#else return reinterpret_cast<T *>(res);
#if __cplusplus >= 201703L }
static void dealloc(T *ptr)
{ free(ptr); }
#elif __cplusplus >= 201703L
static T *ralloc(size_t num)
{
if (num==0) return nullptr;
void *res = aligned_alloc(64,num*sizeof(T)); void *res = aligned_alloc(64,num*sizeof(T));
if (!res) throw bad_alloc(); if (!res) throw bad_alloc();
return reinterpret_cast<T *>(res);
}
static void dealloc(T *ptr)
{ free(ptr); }
#elif defined(_WIN32) #elif defined(_WIN32)
static T *ralloc(size_t num)
{
if (num==0) return nullptr;
void *res = _aligned_malloc(num*sizeof(T), 64); void *res = _aligned_malloc(num*sizeof(T), 64);
if (!res) throw bad_alloc(); if (!res) throw bad_alloc();
return reinterpret_cast<T *>(res);
}
static void dealloc(T *ptr)
{ _aligned_free(ptr); }
#else #else
static T *ralloc(size_t num)
{
if (num==0) return nullptr;
void *res(nullptr); void *res(nullptr);
if (posix_memalign(&res, 64, num*sizeof(T))!=0) if (posix_memalign(&res, 64, num*sizeof(T))!=0)
throw bad_alloc(); throw bad_alloc();
#endif
#endif
return reinterpret_cast<T *>(res); return reinterpret_cast<T *>(res);
} }
static void dealloc(T *ptr) static void dealloc(T *ptr)
{ free(ptr); } { free(ptr); }
#endif
public: public:
arr() : p(0), sz(0) {} arr() : p(0), sz(0) {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment