1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H
10#define _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H
11
12#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_integral.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22namespace __math {
23
24// cos
25
26inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT { return __builtin_cosf(__x); }
27
28template <class = int>
29_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
30 return __builtin_cos(__x);
31}
32
33inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT { return __builtin_cosl(__x); }
34
35template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
36inline _LIBCPP_HIDE_FROM_ABI double cos(_A1 __x) _NOEXCEPT {
37 return __builtin_cos((double)__x);
38}
39
40// sin
41
42inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT { return __builtin_sinf(__x); }
43
44template <class = int>
45_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
46 return __builtin_sin(__x);
47}
48
49inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT { return __builtin_sinl(__x); }
50
51template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
52inline _LIBCPP_HIDE_FROM_ABI double sin(_A1 __x) _NOEXCEPT {
53 return __builtin_sin((double)__x);
54}
55
56// tan
57
58inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT { return __builtin_tanf(__x); }
59
60template <class = int>
61_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
62 return __builtin_tan(__x);
63}
64
65inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT { return __builtin_tanl(__x); }
66
67template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
68inline _LIBCPP_HIDE_FROM_ABI double tan(_A1 __x) _NOEXCEPT {
69 return __builtin_tan((double)__x);
70}
71
72} // namespace __math
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H
77