Skip to content

Commit 8cb0f69

Browse files
committed
fix compilation failure on macOS
1 parent 5bb1b06 commit 8cb0f69

6 files changed

Lines changed: 120 additions & 92 deletions

File tree

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.2] - 2023-10-31
4+
### Fixed
5+
- fix compilation failure on macOS
6+
37
## [2.2.1] - 2023-10-31
48
### Fixed
59
- fix wraparound issue in simd implementation of Jaro and Jaro Winkler

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.1)
35+
project(rapidfuzz LANGUAGES CXX VERSION 2.2.2)
3636

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

extras/rapidfuzz_amalgamated.hpp

Lines changed: 25 additions & 11 deletions
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-10-31 11:48:55.108653
4+
// Generated: 2023-11-01 00:20:18.570286
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -1629,6 +1629,24 @@ size_t remove_common_suffix(Range<InputIt1>& s1, Range<InputIt2>& s2);
16291629
template <typename InputIt, typename CharT = iter_value_t<InputIt>>
16301630
SplittedSentenceView<InputIt> sorted_split(InputIt first, InputIt last);
16311631

1632+
static inline void* rf_aligned_alloc(size_t alignment, size_t size)
1633+
{
1634+
#if defined(_WIN32)
1635+
return _aligned_malloc(size, alignment);
1636+
#else
1637+
return aligned_alloc(alignment, size);
1638+
#endif
1639+
}
1640+
1641+
static inline void rf_aligned_free(void* ptr)
1642+
{
1643+
#if defined(_WIN32)
1644+
_aligned_free(ptr);
1645+
#else
1646+
free(ptr);
1647+
#endif
1648+
}
1649+
16321650
/**@}*/
16331651

16341652
} // namespace rapidfuzz::detail
@@ -5823,15 +5841,12 @@ jaro_similarity_simd_long_s2(Range<double*> scores, const detail::BlockPatternMa
58235841
assert(static_cast<size_t>(s2.size()) > sizeof(VecType) * 8);
58245842

58255843
struct AlignedAlloc {
5826-
AlignedAlloc(size_t size)
5827-
{
5828-
// work around compilation failure in msvc
5829-
memory = operator new[](size, std::align_val_t(native_simd<VecType>::alignment));
5830-
}
5844+
AlignedAlloc(size_t size) : memory(rf_aligned_alloc(native_simd<VecType>::alignment, size))
5845+
{}
58315846

58325847
~AlignedAlloc()
58335848
{
5834-
::operator delete[](memory, std::align_val_t(native_simd<VecType>::alignment));
5849+
rf_aligned_free(memory);
58355850
}
58365851

58375852
void* memory = nullptr;
@@ -6199,15 +6214,14 @@ struct MultiJaro : public detail::MultiSimilarityBase<MultiJaro<MaxLen>, double,
61996214
/* align for avx2 so we can directly load into avx2 registers */
62006215
str_lens_size = result_count();
62016216

6202-
// work around compilation failure in msvc
6203-
str_lens = static_cast<VecType*>(operator new[](sizeof(VecType) * str_lens_size,
6204-
std::align_val_t(get_vec_alignment())));
6217+
str_lens = static_cast<VecType*>(
6218+
detail::rf_aligned_alloc(get_vec_alignment(), sizeof(VecType) * str_lens_size));
62056219
std::fill(str_lens, str_lens + str_lens_size, VecType(0));
62066220
}
62076221

62086222
~MultiJaro()
62096223
{
6210-
::operator delete[](str_lens, std::align_val_t(get_vec_alignment()));
6224+
detail::rf_aligned_free(str_lens);
62116225
}
62126226

62136227
/**

rapidfuzz/details/common.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ size_t remove_common_suffix(Range<InputIt1>& s1, Range<InputIt2>& s2);
7575
template <typename InputIt, typename CharT = iter_value_t<InputIt>>
7676
SplittedSentenceView<InputIt> sorted_split(InputIt first, InputIt last);
7777

78+
static inline void* rf_aligned_alloc(size_t alignment, size_t size)
79+
{
80+
#if defined(_WIN32)
81+
return _aligned_malloc(size, alignment);
82+
#else
83+
return aligned_alloc(alignment, size);
84+
#endif
85+
}
86+
87+
static inline void rf_aligned_free(void* ptr)
88+
{
89+
#if defined(_WIN32)
90+
_aligned_free(ptr);
91+
#else
92+
free(ptr);
93+
#endif
94+
}
95+
96+
7897
/**@}*/
7998

8099
} // namespace rapidfuzz::detail

rapidfuzz/distance/Jaro.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,15 @@ struct MultiJaro : public detail::MultiSimilarityBase<MultiJaro<MaxLen>, double,
118118
/* align for avx2 so we can directly load into avx2 registers */
119119
str_lens_size = result_count();
120120

121-
// work around compilation failure in msvc
122121
str_lens = static_cast<VecType*>(
123-
operator new[](sizeof(VecType) * str_lens_size, std::align_val_t(get_vec_alignment()))
122+
detail::rf_aligned_alloc(get_vec_alignment(), sizeof(VecType) * str_lens_size)
124123
);
125124
std::fill(str_lens, str_lens + str_lens_size, VecType(0));
126125
}
127126

128127
~MultiJaro()
129128
{
130-
::operator delete[] (str_lens, std::align_val_t(get_vec_alignment()));
129+
detail::rf_aligned_free(str_lens);
131130
}
132131

133132
/**

0 commit comments

Comments
 (0)