diff --git a/libc/test/IntegrationTest/CMakeLists.txt b/libc/test/IntegrationTest/CMakeLists.txt index 235e9fe2f55ee..3afe354eca986 100644 --- a/libc/test/IntegrationTest/CMakeLists.txt +++ b/libc/test/IntegrationTest/CMakeLists.txt @@ -13,6 +13,5 @@ add_object_library( DEPENDS libc.hdr.stdint_proxy libc.src.__support.OSUtil.osutil - libc.src.__support.CPP.atomic ${arch_specific_deps} ) diff --git a/libc/test/IntegrationTest/test.cpp b/libc/test/IntegrationTest/test.cpp index ec45e28a4e7a6..8baf74637b309 100644 --- a/libc/test/IntegrationTest/test.cpp +++ b/libc/test/IntegrationTest/test.cpp @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #include "hdr/stdint_proxy.h" -#include "src/__support/CPP/atomic.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" #include @@ -65,19 +65,14 @@ int atexit(void (*func)(void)) { return LIBC_NAMESPACE::atexit(func); } static constexpr uint64_t MEMORY_SIZE = 16384; static uint8_t memory[MEMORY_SIZE]; -static LIBC_NAMESPACE::cpp::Atomic used = 0; +static uint8_t *ptr = memory; extern "C" { -// For simple test purposes. void *malloc(size_t s) { - // Emulate the alignment of std::max_align_t. - constexpr size_t DEFAULT_ALIGNMENT = alignof(long double); - s += (-s) & (DEFAULT_ALIGNMENT - 1); // Align to default alignment. - auto res = used.fetch_add(s, LIBC_NAMESPACE::cpp::MemoryOrder::RELAXED); - if (res + s > MEMORY_SIZE) - return nullptr; // Out of memory. - return &memory[res]; + void *mem = ptr; + ptr += s; + return static_cast(ptr - memory) >= MEMORY_SIZE ? nullptr : mem; } void free(void *) {}