Skip to content

Commit

Permalink
Use fallback implementation for C++ aligned_alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
ddugovic authored and vondele committed Aug 9, 2020
1 parent add890a commit d7a2689
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ endif
endif

ifeq ($(KERNEL),Darwin)
CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.15
LDFLAGS += -arch $(arch) -mmacosx-version-min=10.15
CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.13
LDFLAGS += -arch $(arch) -mmacosx-version-min=10.13
endif

### Travis CI script uses COMPILER to overwrite CXX
Expand Down
8 changes: 4 additions & 4 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,19 @@ void prefetch(void* addr) {
///

void* std_aligned_alloc(size_t alignment, size_t size) {
#if defined(__APPLE__)
#if (defined(__APPLE__) && defined(_LIBCPP_HAS_C11_FEATURES)) || defined(__ANDROID__) || defined(__OpenBSD__) || (defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) )
return aligned_alloc(alignment, size);
#elif defined(_WIN32)
#elif (defined(_WIN32) || (defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)))
return _mm_malloc(size, alignment);
#else
return std::aligned_alloc(alignment, size);
#endif
}

void std_aligned_free(void* ptr) {
#if defined(__APPLE__)
#if (defined(__APPLE__) && defined(_LIBCPP_HAS_C11_FEATURES)) || defined(__ANDROID__) || defined(__OpenBSD__) || (defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) )
free(ptr);
#elif defined(_WIN32)
#elif (defined(_WIN32) || (defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)))
_mm_free(ptr);
#else
free(ptr);
Expand Down

0 comments on commit d7a2689

Please sign in to comment.