Mercurial > hg > CbC > CbC_llvm
diff libcxxabi/test/test_fallback_malloc.pass.cpp @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 79ff65ed7e25 |
children | 1f2b6ac9f198 |
line wrap: on
line diff
--- a/libcxxabi/test/test_fallback_malloc.pass.cpp Wed Jul 21 10:27:27 2021 +0900 +++ b/libcxxabi/test/test_fallback_malloc.pass.cpp Wed Nov 09 17:45:10 2022 +0900 @@ -1,4 +1,4 @@ -//===--------------------- test_fallback_malloc.cpp -----------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,21 +8,36 @@ #include <cstdio> #include <deque> +#include <cassert> #include <__threading_support> +// UNSUPPORTED: c++03 +// UNSUPPORTED: modules-build && no-threads + +// Necessary because we include a private source file of libc++abi, which +// only understands _LIBCXXABI_HAS_NO_THREADS. +#include "test_macros.h" +#ifdef TEST_HAS_NO_THREADS +# define _LIBCXXABI_HAS_NO_THREADS +#endif + typedef std::deque<void *> container; // #define DEBUG_FALLBACK_MALLOC #define INSTRUMENT_FALLBACK_MALLOC #include "../src/fallback_malloc.cpp" +void assertAlignment(void* ptr) { assert(reinterpret_cast<size_t>(ptr) % alignof(FallbackMaxAlignType) == 0); } + container alloc_series ( size_t sz ) { container ptrs; void *p; - while ( NULL != ( p = fallback_malloc ( sz ))) - ptrs.push_back ( p ); + while (NULL != (p = fallback_malloc(sz))) { + assertAlignment(p); + ptrs.push_back(p); + } return ptrs; } @@ -31,8 +46,9 @@ void *p; while ( NULL != ( p = fallback_malloc ( sz ))) { - ptrs.push_back ( p ); - sz *= growth; + assertAlignment(p); + ptrs.push_back(p); + sz *= growth; } return ptrs; @@ -46,6 +62,7 @@ for ( const size_t *iter = first; iter != last; ++iter ) { if ( NULL == (p = fallback_malloc ( *iter ))) break; + assertAlignment(p); ptrs.push_back ( p ); }