diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-07-11 22:48:30 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-07-11 22:48:30 +0800 |
| commit | 3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee (patch) | |
| tree | 4bd5a49ef60ad1e371c0984cd46838368c5ef83a /lib/ktl/stub-new.cc | |
| parent | 48ef95c24e9ac3d11200b61af617a01b10b507d1 (diff) | |
| download | lume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.gz lume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.xz | |
lib: establish Zircon libc++ and KTL foundation
Diffstat (limited to 'lib/ktl/stub-new.cc')
| -rw-r--r-- | lib/ktl/stub-new.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ktl/stub-new.cc b/lib/ktl/stub-new.cc new file mode 100644 index 0000000..919d941 --- /dev/null +++ b/lib/ktl/stub-new.cc @@ -0,0 +1,25 @@ +// Copyright 2020 The Fuchsia Authors +// +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT + +#include <new> + +// std::stable_sort (used as ktl::stable_sort) uses std::get_temporary_buffer, +// which uses operator new to request a temporary buffer but then works fine +// if it can't get one. There is no "default" memory allocation in the +// kernel, so just provide a stub operator new that always fails so +// std::stable_sort falls back to its no-allocation algorithm. + +namespace std { + +const nothrow_t nothrow; + +} // namespace std + +void* operator new(std::size_t, const std::nothrow_t&) noexcept { return nullptr; } + +void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) noexcept { + return nullptr; +} |
