Skip to content

Commit 6393a9e

Browse files
authored
Revert "[libc] make integration test malloc work properly when threaded" (#152096)
Reverts #151622 This broke our libc on GPU bot: https://lab.llvm.org/buildbot/#/builders/10/builds/10864
1 parent ba099c5 commit 6393a9e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

libc/test/IntegrationTest/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ add_object_library(
1313
DEPENDS
1414
libc.hdr.stdint_proxy
1515
libc.src.__support.OSUtil.osutil
16-
libc.src.__support.CPP.atomic
1716
${arch_specific_deps}
1817
)

libc/test/IntegrationTest/test.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
89
#include "hdr/stdint_proxy.h"
9-
#include "src/__support/CPP/atomic.h"
1010
#include "src/__support/common.h"
1111
#include "src/__support/macros/config.h"
1212
#include <stddef.h>
@@ -65,19 +65,14 @@ int atexit(void (*func)(void)) { return LIBC_NAMESPACE::atexit(func); }
6565

6666
static constexpr uint64_t MEMORY_SIZE = 16384;
6767
static uint8_t memory[MEMORY_SIZE];
68-
static LIBC_NAMESPACE::cpp::Atomic<size_t> used = 0;
68+
static uint8_t *ptr = memory;
6969

7070
extern "C" {
7171

72-
// For simple test purposes.
7372
void *malloc(size_t s) {
74-
// Emulate the alignment of std::max_align_t.
75-
constexpr size_t DEFAULT_ALIGNMENT = alignof(long double);
76-
s += (-s) & (DEFAULT_ALIGNMENT - 1); // Align to default alignment.
77-
auto res = used.fetch_add(s, LIBC_NAMESPACE::cpp::MemoryOrder::RELAXED);
78-
if (res + s > MEMORY_SIZE)
79-
return nullptr; // Out of memory.
80-
return &memory[res];
73+
void *mem = ptr;
74+
ptr += s;
75+
return static_cast<uint64_t>(ptr - memory) >= MEMORY_SIZE ? nullptr : mem;
8176
}
8277

8378
void free(void *) {}

0 commit comments

Comments
 (0)