blob: 256436e475407e2a1f3403735cef52a0737ac6c1 [file] [log] [blame]
Elliott Hughesf9f4a432015-08-24 22:57:08 +00001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <math.h>
18
19#include "fpmath.h"
20
Elliott Hughes591a2a72022-12-05 20:58:15 +000021double fabs(double x) { return __builtin_fabs(x); }
22float fabsf(float x) { return __builtin_fabsf(x); }
Elliott Hughesf9f4a432015-08-24 22:57:08 +000023long double fabsl(long double x) { return __builtin_fabsl(x); }
Elliott Hughes9a1bb702017-11-09 22:40:11 +000024
25#if defined(__aarch64__)
Jake Weinstein1e108e32017-12-11 02:50:04 -050026float ceilf(float x) { return __builtin_ceilf(x); }
27double ceil(double x) { return __builtin_ceil(x); }
Elliott Hughesedf386b2022-12-09 20:54:38 +000028#endif
Jake Weinstein1e108e32017-12-11 02:50:04 -050029
Elliott Hughesedf386b2022-12-09 20:54:38 +000030#if defined(__aarch64__) || defined(__riscv)
Elliott Hughes46f24a12022-10-26 21:55:34 +000031double copysign(double x, double y) { return __builtin_copysign(x, y); }
32float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
Elliott Hughesedf386b2022-12-09 20:54:38 +000033#endif
Elliott Hughes46f24a12022-10-26 21:55:34 +000034
Elliott Hughesedf386b2022-12-09 20:54:38 +000035#if defined(__aarch64__)
Jake Weinstein1e108e32017-12-11 02:50:04 -050036float floorf(float x) { return __builtin_floorf(x); }
37double floor(double x) { return __builtin_floor(x); }
Elliott Hughesedf386b2022-12-09 20:54:38 +000038#endif
Jake Weinstein1e108e32017-12-11 02:50:04 -050039
Elliott Hughesedf386b2022-12-09 20:54:38 +000040#if defined(__aarch64__) || defined(__riscv)
Elliott Hughes9a1bb702017-11-09 22:40:11 +000041float fmaf(float x, float y, float z) { return __builtin_fmaf(x, y, z); }
42double fma(double x, double y, double z) { return __builtin_fma(x, y, z); }
43
44float fmaxf(float x, float y) { return __builtin_fmaxf(x, y); }
45double fmax(double x, double y) { return __builtin_fmax(x, y); }
46
47float fminf(float x, float y) { return __builtin_fminf(x, y); }
48double fmin(double x, double y) { return __builtin_fmin(x, y); }
49
Elliott Hughes2dcc5ce2023-02-01 02:05:24 +000050long lrint(double x) { return __builtin_lrint(x); }
51long lrintf(float x) { return __builtin_lrintf(x); }
52long long llrint(double x) { return __builtin_llrint(x); }
53long long llrintf(float x) { return __builtin_llrintf(x); }
54
Elliott Hughes0cbb9022022-10-28 00:00:00 +000055long lround(double x) { return __builtin_lround(x); }
56long lroundf(float x) { return __builtin_lroundf(x); }
57long long llround(double x) { return __builtin_llround(x); }
58long long llroundf(float x) { return __builtin_llroundf(x); }
Elliott Hughesedf386b2022-12-09 20:54:38 +000059#endif
Elliott Hughes0cbb9022022-10-28 00:00:00 +000060
Elliott Hughesedf386b2022-12-09 20:54:38 +000061#if defined(__aarch64__)
Jake Weinstein1e108e32017-12-11 02:50:04 -050062float rintf(float x) { return __builtin_rintf(x); }
63double rint(double x) { return __builtin_rint(x); }
64
Elliott Hughes9a1bb702017-11-09 22:40:11 +000065float roundf(float x) { return __builtin_roundf(x); }
66double round(double x) { return __builtin_round(x); }
Elliott Hughes2dcc5ce2023-02-01 02:05:24 +000067#endif
Jake Weinstein1e108e32017-12-11 02:50:04 -050068
Elliott Hughes2dcc5ce2023-02-01 02:05:24 +000069#if defined(__aarch64__) || defined(__riscv)
70float sqrtf(float x) { return __builtin_sqrtf(x); }
71double sqrt(double x) { return __builtin_sqrt(x); }
72#endif
73
74#if defined(__aarch64__)
Jake Weinstein1e108e32017-12-11 02:50:04 -050075float truncf(float x) { return __builtin_truncf(x); }
76double trunc(double x) { return __builtin_trunc(x); }
Elliott Hughes9a1bb702017-11-09 22:40:11 +000077#endif