Skip to content

Commit

Permalink
[libcxx] [test] Fix mismatches between _aligned_malloc and free() on …
Browse files Browse the repository at this point in the history
…Windows

This allows getting rid of one case of LIBCXX-WINDOWS-FIXME. The fixme
comment was inaccurate; aligned allocation functions are provided these
days, but the test kept failing as it was using mismatched allocation
and free functions.

A similar issue was fixed earlier, in
6596778. That test was fixed by
overriding the aligned `operator new` too, and returning a dummy fixed
allocation instead. As this test is libcxx specific, it can use the
internal `std::__libcpp_aligned_free()` instead, to match libcxx's
internal aligned `operator new`.

Differential Revision: https://reviews.llvm.org/D118190
  • Loading branch information
mstorsjo committed Jan 26, 2022
1 parent bec4e86 commit a2aea71
Showing 1 changed file with 2 additions and 6 deletions.
Expand Up @@ -9,10 +9,6 @@
// test libc++'s implementation of align_val_t, and the relevant new/delete
// overloads in all dialects when -faligned-allocation is present.

// Libc++ defers to the underlying MSVC library to provide the new/delete
// definitions, which does not yet provide aligned allocation
// XFAIL: LIBCXX-WINDOWS-FIXME

// XFAIL: LIBCXX-AIX-FIXME

// The dylibs shipped before macosx10.13 do not contain the aligned allocation
Expand Down Expand Up @@ -115,14 +111,14 @@ void operator delete(void* p, size_t n)TEST_NOEXCEPT {

#ifndef NO_ALIGN
void operator delete(void* p, std::align_val_t a)TEST_NOEXCEPT {
::free(p);
std::__libcpp_aligned_free(p);
stats.aligned_called++;
stats.last_align = static_cast<int>(a);
stats.last_size = -1;
}

void operator delete(void* p, size_t n, std::align_val_t a)TEST_NOEXCEPT {
::free(p);
std::__libcpp_aligned_free(p);
stats.aligned_sized_called++;
stats.last_align = static_cast<int>(a);
stats.last_size = n;
Expand Down

0 comments on commit a2aea71

Please sign in to comment.