diff options
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/Buffer.cpp | 12 | ||||
-rw-r--r-- | src/DabMod.cpp | 7 | ||||
-rw-r--r-- | src/Flowgraph.cpp | 6 | ||||
-rw-r--r-- | src/FormatConverter.cpp | 1 | ||||
-rw-r--r-- | src/FrequencyInterleaver.cpp | 8 | ||||
-rw-r--r-- | src/Resampler.cpp | 7 |
7 files changed, 16 insertions, 28 deletions
diff --git a/configure.ac b/configure.ac index 23369c9..d260f9e 100644 --- a/configure.ac +++ b/configure.ac @@ -154,8 +154,7 @@ AS_IF([test "x$enable_debug" != "xno"], )]) # Checks for header files. -AC_CHECK_HEADERS([fcntl.h limits.h malloc.h memory.h netinet/in.h stdint.h stdlib.h string.h sys/time.h sys/timeb.h unistd.h]) -AC_CHECK_DECLS([_mm_malloc], [], [], [#include <mm_malloc.h>]) +AC_CHECK_HEADERS([fcntl.h limits.h memory.h netinet/in.h stdint.h stdlib.h string.h sys/time.h sys/timeb.h unistd.h]) AC_HEADER_STDC # Checks for typedefs, structures, and compiler characteristics. diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8631c42..6b14561 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -30,13 +30,6 @@ #include <stdlib.h> #include <string.h> -#include <malloc.h> -#if HAVE_DECL__MM_MALLOC -# include <mm_malloc.h> -#else -# define memalign(a, b) malloc(b) -#endif - Buffer::Buffer(size_t len, const void *data) @@ -92,7 +85,10 @@ void Buffer::setLength(size_t len) void *tmp = data; /* Align to 32-byte boundary for AVX. */ - data = memalign(32, len); + const int ret = posix_memalign(&data, 32, len); + if (ret != 0) { + throw std::runtime_error("memory allocation failed: " + std::to_string(ret)); + } if (tmp != NULL) { memcpy(data, tmp, this->len); diff --git a/src/DabMod.cpp b/src/DabMod.cpp index af3adde..1625a82 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -64,13 +64,6 @@ # include <netinet/in.h> #endif -#if HAVE_DECL__MM_MALLOC -# include <mm_malloc.h> -#else -# define memalign(a, b) malloc(b) -#endif - - /* UHD requires the input I and Q samples to be in the interval * [-1.0,1.0], otherwise they get truncated, which creates very * wide-spectrum spikes. Depending on the Transmission Mode, the diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 6ee7b81..4870534 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -29,12 +29,6 @@ #include <memory> #include <algorithm> #include <sstream> - -#if HAVE_DECL__MM_MALLOC -# include <mm_malloc.h> -#else -# define memalign(a, b) malloc(b) -#endif #include <sys/types.h> #include <stdexcept> #include <assert.h> diff --git a/src/FormatConverter.cpp b/src/FormatConverter.cpp index 6826972..60c0545 100644 --- a/src/FormatConverter.cpp +++ b/src/FormatConverter.cpp @@ -29,7 +29,6 @@ #include "FormatConverter.h" #include "PcDebug.h" -#include <malloc.h> #include <sys/types.h> #include <string.h> #include <stdexcept> diff --git a/src/FrequencyInterleaver.cpp b/src/FrequencyInterleaver.cpp index 29d54bb..bd5042c 100644 --- a/src/FrequencyInterleaver.cpp +++ b/src/FrequencyInterleaver.cpp @@ -24,7 +24,7 @@ #include <stdio.h> #include <stdexcept> -#include <malloc.h> +#include <stdlib.h> #include <complex> typedef std::complex<float> complexf; @@ -68,7 +68,11 @@ FrequencyInterleaver::FrequencyInterleaver(size_t mode) : break; } - d_indexes = (size_t*)memalign(16, d_carriers * sizeof(size_t)); + const int ret = posix_memalign((void**)(&d_indexes), 16, d_carriers * sizeof(size_t)); + if (ret != 0) { + throw std::runtime_error("memory allocation failed: " + std::to_string(ret)); + } + size_t* index = d_indexes; size_t perm = 0; PDEBUG("i: %4u, R: %4u\n", 0, 0); diff --git a/src/Resampler.cpp b/src/Resampler.cpp index 8069a61..2be753e 100644 --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -27,7 +27,7 @@ #include "Resampler.h" #include "PcDebug.h" -#include <malloc.h> +#include <stdlib.h> #include <sys/types.h> #include <string.h> #include <stdexcept> @@ -81,7 +81,10 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : myFactor = 1.0f / myFftSizeOut * outputRate / inputRate; } - myWindow = (float*)memalign(16, myFftSizeIn * sizeof(float)); + const int ret = posix_memalign((void**)(&myWindow), 16, myFftSizeIn * sizeof(float)); + if (ret != 0) { + throw std::runtime_error("memory allocation failed: " + std::to_string(ret)); + } for (size_t i = 0; i < myFftSizeIn; ++i) { myWindow[i] = (float)(0.5 * (1.0 - cos(2.0 * M_PI * i / (myFftSizeIn - 1)))); PDEBUG("Window[%zu] = %f\n", i, myWindow[i]); |