Skip to content

Commit 2758139

Browse files
committed
[libcxx] Use aligned_alloc for testing instead of posix_memalign
Summary: The `aligned_alloc` function is the C11 replacement for `posix_memalign`. We should favor the C standard over the POSIX standard so more C library implementations can run the tests.
1 parent 97f723b commit 2758139

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libcxx/test/libcxx/language.support/support.dynamic/new_faligned_allocation.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int main(int, char**) {
7676
test_allocations(64, 64);
7777
// Size being a multiple of alignment also needs to be supported.
7878
test_allocations(64, 32);
79-
// When aligned allocation is implemented using posix_memalign,
79+
// When aligned allocation is implemented using aligned_alloc,
8080
// that function requires a minimum alignment of sizeof(void*).
8181
// Check that we can also create overaligned allocations with
8282
// an alignment argument less than sizeof(void*).

libcxx/test/support/count_new.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ inline void* alocate_aligned_impl(std::size_t size, std::align_val_t align) {
461461
# ifdef USE_ALIGNED_ALLOC
462462
ret = _aligned_malloc(size, alignment);
463463
# else
464-
assert(posix_memalign(&ret, std::max(alignment, sizeof(void*)), size) != EINVAL);
464+
ret = aligned_alloc(alignment, size);
465465
# endif
466466
return ret;
467467
}

0 commit comments

Comments
 (0)