Skip to content

[libc] Remove use of BlockStore for GPU atexit #82823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libc/src/stdlib/atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ struct AtExitUnit {
constexpr AtExitUnit(AtExitCallback *c, void *p) : callback(c), payload(p) {}
};

#ifdef LIBC_COPT_PUBLIC_PACKAGING
#if defined(LIBC_TARGET_ARCH_IS_GPU)
// The GPU build cannot handle the potentially recursive definitions required by
// the BlockStore class. Additionally, the liklihood that someone exceeds this
// while executing on the GPU is extremely small.
// FIXME: It is not generally safe to use 'atexit' on the GPU because the
// mutexes simply passthrough. We will need a lock free stack.
using ExitCallbackList = FixedVector<AtExitUnit, 64>;
#elif defined(LIBC_COPT_PUBLIC_PACKAGING)
using ExitCallbackList = cpp::ReverseOrderBlockStore<AtExitUnit, 32>;
#else
// BlockStore uses dynamic memory allocation. To avoid dynamic memory
Expand Down