Skip to content

Commit 605a311

Browse files
committed
use _mm_malloc/_mm_free on macOS if aligned_alloc is unsupported
1 parent 8cb0f69 commit 605a311

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog
22

3+
## [2.2.3] - 2023-11-02
4+
### Fixed
5+
- use _mm_malloc/_mm_free on macOS if aligned_alloc is unsupported
6+
37
## [2.2.2] - 2023-10-31
48
### Fixed
59
- fix compilation failure on macOS

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3232
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
3333
endif()
3434

35-
project(rapidfuzz LANGUAGES CXX VERSION 2.2.2)
35+
project(rapidfuzz LANGUAGES CXX VERSION 2.2.3)
3636

3737
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
3838
include(GNUInstallDirs)

extras/rapidfuzz_amalgamated.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22
// SPDX-License-Identifier: MIT
33
// RapidFuzz v1.0.2
4-
// Generated: 2023-11-01 00:20:18.570286
4+
// Generated: 2023-11-02 10:29:38.300883
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -1567,6 +1567,10 @@ constexpr void unroll(F&& f)
15671567

15681568
#include <vector>
15691569

1570+
#if defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
1571+
# include <mm_malloc.h>
1572+
#endif
1573+
15701574
namespace rapidfuzz::detail {
15711575

15721576
template <typename InputIt1, typename InputIt2, typename InputIt3>
@@ -1633,6 +1637,8 @@ static inline void* rf_aligned_alloc(size_t alignment, size_t size)
16331637
{
16341638
#if defined(_WIN32)
16351639
return _aligned_malloc(size, alignment);
1640+
#elif defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
1641+
return _mm_malloc(size, alignment);
16361642
#else
16371643
return aligned_alloc(alignment, size);
16381644
#endif
@@ -1642,6 +1648,8 @@ static inline void rf_aligned_free(void* ptr)
16421648
{
16431649
#if defined(_WIN32)
16441650
_aligned_free(ptr);
1651+
#elif defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
1652+
_mm_free(ptr);
16451653
#else
16461654
free(ptr);
16471655
#endif

rapidfuzz/details/common.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <rapidfuzz/details/types.hpp>
1414
#include <vector>
1515

16+
#if defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
17+
# include <mm_malloc.h>
18+
#endif
19+
1620
namespace rapidfuzz::detail {
1721

1822
template <typename InputIt1, typename InputIt2, typename InputIt3>
@@ -79,6 +83,8 @@ static inline void* rf_aligned_alloc(size_t alignment, size_t size)
7983
{
8084
#if defined(_WIN32)
8185
return _aligned_malloc(size, alignment);
86+
#elif defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
87+
return _mm_malloc(size, alignment);
8288
#else
8389
return aligned_alloc(alignment, size);
8490
#endif
@@ -88,6 +94,8 @@ static inline void rf_aligned_free(void* ptr)
8894
{
8995
#if defined(_WIN32)
9096
_aligned_free(ptr);
97+
#elif defined(__APPLE__) && !defined(_LIBCPP_HAS_C11_FEATURES)
98+
_mm_free(ptr);
9199
#else
92100
free(ptr);
93101
#endif

0 commit comments

Comments
 (0)