[libcxx-commits] [libcxx] a2aea71 - [libcxx] [test] Fix mismatches between _aligned_malloc and free() on Windows

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 26 01:53:14 PST 2022


Author: Martin Storsjö
Date: 2022-01-26T11:52:32+02:00
New Revision: a2aea7199a5c99260d27ee37f3cda8f752478c02

URL: https://github.com/llvm/llvm-project/commit/a2aea7199a5c99260d27ee37f3cda8f752478c02
DIFF: https://github.com/llvm/llvm-project/commit/a2aea7199a5c99260d27ee37f3cda8f752478c02.diff

LOG: [libcxx] [test] Fix mismatches between _aligned_malloc and free() on 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
6596778b46ba69517191e7397289228168064ff4. 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

Added: 
    

Modified: 
    libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
index 1f663e05fc709..a90eaf2600e98 100644
--- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -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
@@ -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;


        


More information about the libcxx-commits mailing list