Don't bother checking for std::aligned_alloc
This commit is contained in:
parent
1dcc6361fe
commit
f576a35363
@ -153,19 +153,9 @@ set(EXPORT_DECL "")
|
||||
# Require C++14
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
if(CMAKE_CXX14_EXTENSION_COMPILE_OPTION)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX14_EXTENSION_COMPILE_OPTION}")
|
||||
elseif(CMAKE_CXX14_STANDARD_COMPILE_OPTION)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
|
||||
endif()
|
||||
|
||||
# Prefer C11, but support C99 and C90 too.
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
if(CMAKE_C11_EXTENSION_COMPILE_OPTION)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C11_EXTENSION_COMPILE_OPTION}")
|
||||
elseif(CMAKE_C11_STANDARD_COMPILE_OPTION)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C11_STANDARD_COMPILE_OPTION}")
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
# Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
|
||||
@ -534,13 +524,6 @@ if(HAVE_INTRIN_H)
|
||||
}" HAVE_CPUID_INTRINSIC)
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("#include <cstdlib>
|
||||
int main()
|
||||
{
|
||||
void *ptr{std::aligned_alloc(alignof(int), sizeof(int))};
|
||||
std::free(ptr);
|
||||
return 0;
|
||||
}" HAVE_STD_ALIGNED_ALLOC)
|
||||
check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
|
||||
check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
|
||||
check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
|
||||
|
@ -18,10 +18,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 defined(HAVE_STD_ALIGNED_ALLOC)
|
||||
size = (size+(alignment-1))&~(alignment-1);
|
||||
return std::aligned_alloc(alignment, size);
|
||||
#elif defined(HAVE_POSIX_MEMALIGN)
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
void *ret{};
|
||||
if(posix_memalign(&ret, alignment, size) == 0)
|
||||
return ret;
|
||||
@ -53,7 +50,7 @@ void *al_calloc(size_t alignment, size_t size)
|
||||
|
||||
void al_free(void *ptr) noexcept
|
||||
{
|
||||
#if defined(HAVE_STD_ALIGNED_ALLOC) || defined(HAVE_POSIX_MEMALIGN)
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
std::free(ptr);
|
||||
#elif defined(HAVE__ALIGNED_MALLOC)
|
||||
_aligned_free(ptr);
|
||||
|
@ -5,9 +5,6 @@
|
||||
/* Define if HRTF data is embedded in the library */
|
||||
#cmakedefine ALSOFT_EMBED_HRTF_DATA
|
||||
|
||||
/* Define if we have the std::aligned_alloc function */
|
||||
#cmakedefine HAVE_STD_ALIGNED_ALLOC
|
||||
|
||||
/* Define if we have the posix_memalign function */
|
||||
#cmakedefine HAVE_POSIX_MEMALIGN
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user