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/include/cmath | |
| parent | 48ef95c24e9ac3d11200b61af617a01b10b507d1 (diff) | |
| download | lume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.gz lume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.xz | |
lib: establish Zircon libc++ and KTL foundation
Diffstat (limited to 'lib/ktl/include/cmath')
| -rw-r--r-- | lib/ktl/include/cmath | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/ktl/include/cmath b/lib/ktl/include/cmath new file mode 100644 index 0000000..13b8e6b --- /dev/null +++ b/lib/ktl/include/cmath @@ -0,0 +1,53 @@ +// Copyright 2021 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 + +#ifndef ZIRCON_KERNEL_LIB_KTL_INCLUDE_CMATH_ +#define ZIRCON_KERNEL_LIB_KTL_INCLUDE_CMATH_ + +// The kernel doesn't want this file but some libc++ headers we need +// wind up including it. They don't actually most of the math +// declarations except under #if conditions that aren't true. + +#include <__config> +#include <type_traits> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// These are used in templates that won't ever be instantiated in kernel code. + +template <typename T> +constexpr bool isinf(T&& x) { + static_assert(!is_same_v<T, T>, "must not be instantiated in kernel code"); + return false; +} + +template <typename T> +constexpr bool isnan(T&& x) { + static_assert(!is_same_v<T, T>, "must not be instantiated in kernel code"); + return false; +} + +template <typename T> +constexpr bool signbit(T&& x) { + static_assert(!is_same_v<T, T>, "must not be instantiated in kernel code"); + return false; +} + +template <typename T> +constexpr T frexp(T&& x, int* exponent) { + static_assert(!is_same_v<T, T>, "must not be instantiated in kernel code"); + return x; +} + +template <typename T> +constexpr auto ceil(T&& x) { + static_assert(!is_same_v<T, T>, "must not be instantiated in kernel code"); + return x; +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // ZIRCON_KERNEL_LIB_KTL_INCLUDE_CMATH_ |
