Elliott Hughes | f9f4a43 | 2015-08-24 22:57:08 +0000 | [diff] [blame] | 1 | /* |
| 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 Hughes | 591a2a7 | 2022-12-05 20:58:15 +0000 | [diff] [blame] | 21 | double fabs(double x) { return __builtin_fabs(x); } |
| 22 | float fabsf(float x) { return __builtin_fabsf(x); } |
Elliott Hughes | f9f4a43 | 2015-08-24 22:57:08 +0000 | [diff] [blame] | 23 | long double fabsl(long double x) { return __builtin_fabsl(x); } |
Elliott Hughes | 9a1bb70 | 2017-11-09 22:40:11 +0000 | [diff] [blame] | 24 | |
| 25 | #if defined(__aarch64__) |
Jake Weinstein | 1e108e3 | 2017-12-11 02:50:04 -0500 | [diff] [blame] | 26 | float ceilf(float x) { return __builtin_ceilf(x); } |
| 27 | double ceil(double x) { return __builtin_ceil(x); } |
| 28 | |
Elliott Hughes | 46f24a1 | 2022-10-26 21:55:34 +0000 | [diff] [blame] | 29 | double copysign(double x, double y) { return __builtin_copysign(x, y); } |
| 30 | float copysignf(float x, float y) { return __builtin_copysignf(x, y); } |
| 31 | |
Jake Weinstein | 1e108e3 | 2017-12-11 02:50:04 -0500 | [diff] [blame] | 32 | float floorf(float x) { return __builtin_floorf(x); } |
| 33 | double floor(double x) { return __builtin_floor(x); } |
| 34 | |
Elliott Hughes | 9a1bb70 | 2017-11-09 22:40:11 +0000 | [diff] [blame] | 35 | float fmaf(float x, float y, float z) { return __builtin_fmaf(x, y, z); } |
| 36 | double fma(double x, double y, double z) { return __builtin_fma(x, y, z); } |
| 37 | |
| 38 | float fmaxf(float x, float y) { return __builtin_fmaxf(x, y); } |
| 39 | double fmax(double x, double y) { return __builtin_fmax(x, y); } |
| 40 | |
| 41 | float fminf(float x, float y) { return __builtin_fminf(x, y); } |
| 42 | double fmin(double x, double y) { return __builtin_fmin(x, y); } |
| 43 | |
Elliott Hughes | 0cbb902 | 2022-10-28 00:00:00 +0000 | [diff] [blame] | 44 | long lround(double x) { return __builtin_lround(x); } |
| 45 | long lroundf(float x) { return __builtin_lroundf(x); } |
| 46 | long long llround(double x) { return __builtin_llround(x); } |
| 47 | long long llroundf(float x) { return __builtin_llroundf(x); } |
| 48 | |
Jake Weinstein | 1e108e3 | 2017-12-11 02:50:04 -0500 | [diff] [blame] | 49 | float rintf(float x) { return __builtin_rintf(x); } |
| 50 | double rint(double x) { return __builtin_rint(x); } |
| 51 | |
Elliott Hughes | 9a1bb70 | 2017-11-09 22:40:11 +0000 | [diff] [blame] | 52 | float roundf(float x) { return __builtin_roundf(x); } |
| 53 | double round(double x) { return __builtin_round(x); } |
Jake Weinstein | 1e108e3 | 2017-12-11 02:50:04 -0500 | [diff] [blame] | 54 | |
| 55 | float truncf(float x) { return __builtin_truncf(x); } |
| 56 | double trunc(double x) { return __builtin_trunc(x); } |
Elliott Hughes | 9a1bb70 | 2017-11-09 22:40:11 +0000 | [diff] [blame] | 57 | #endif |