summaryrefslogtreecommitdiff
path: root/lib/ktl/include/cmath
blob: 13b8e6b49bf4fff14f243c64ecbb2da8010d7dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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_