diff options
author | Chris Robinson <[email protected]> | 2020-05-19 08:13:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-05-19 08:13:13 -0700 |
commit | 463591663c2421b3436edc446d173380d6a6e106 (patch) | |
tree | f8e738f589a63fc7392eb2ea5e1570672bb24bac /common/almalloc.cpp | |
parent | 400a108eade05d616ed0560024b7fd6f5be5fd1d (diff) |
Check that aligned_alloc is available with cmake
Some compilers support C++17 even on targets that lack required functions.
Projects that want to force C++17 will then run into a problem with
std::aligned_alloc not existing on those targets, so it needs to be explicitly
checked for. The alternative is to simply never use it even when it would be
available.
Diffstat (limited to 'common/almalloc.cpp')
-rw-r--r-- | common/almalloc.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/almalloc.cpp b/common/almalloc.cpp index 5b679b75..806cb4ab 100644 --- a/common/almalloc.cpp +++ b/common/almalloc.cpp @@ -17,7 +17,7 @@ void *al_malloc(size_t alignment, size_t size) assert((alignment & (alignment-1)) == 0); alignment = std::max(alignment, alignof(std::max_align_t)); -#if __cplusplus >= 201703L +#if defined(HAVE_STD_ALIGNED_ALLOC) size = (size+(alignment-1))&~(alignment-1); return std::aligned_alloc(alignment, size); #elif defined(HAVE_POSIX_MEMALIGN) @@ -48,7 +48,7 @@ void *al_calloc(size_t alignment, size_t size) void al_free(void *ptr) noexcept { -#if (__cplusplus >= 201703L) || defined(HAVE_POSIX_MEMALIGN) +#if defined(HAVE_STD_ALIGNED_ALLOC) || defined(HAVE_POSIX_MEMALIGN) std::free(ptr); #elif defined(HAVE__ALIGNED_MALLOC) _aligned_free(ptr); |