diff options
author | Nico Weber <thakis@chromium.org> | 2023-04-14 09:29:27 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-14 16:16:42 +0200 |
commit | fc15fc36ce03fc6639f182c42607fa1661dedf2d (patch) | |
tree | a108f86cd825fe1d7efc7795e915e2a738d9e12a | |
parent | bf5a18babb25c0e9bef68ca8e78ae9ca125fd32e (diff) | |
download | serenity-fc15fc36ce03fc6639f182c42607fa1661dedf2d.zip |
AK: Make math work on arm hosts again
957f89ce4abb6ad added some tweaks for serenity-on-aarch64.
It broke anythingelse-on-aarch64 hosts though, so only do these tweaks
when targeting serenity.
(I wonder if AK/Math.h should fall back to the system math routines
when not targeting serenity in general. Would probably help ladybird
performance. On the other hand, the serenity routines would see less
use and hence exposure and love.)
-rw-r--r-- | AK/Math.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -90,8 +90,10 @@ constexpr T fmod(T x, T y) } while (fpu_status & 0x400); return x; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_fmod(x, y); #endif } @@ -111,8 +113,10 @@ constexpr T remainder(T x, T y) } while (fpu_status & 0x400); return x; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_fmod(x, y); #endif } @@ -248,9 +252,13 @@ constexpr T sin(T angle) : "0"(angle)); return ret; #else +# if defined(AK_OS_SERENITY) // FIXME: This is a very naive implementation, and is only valid for small x. // Probably a good idea to use a better algorithm in the future, such as a taylor approximation. return angle; +# else + return __builtin_sin(angle); +# endif #endif } @@ -267,9 +275,13 @@ constexpr T cos(T angle) : "0"(angle)); return ret; #else +# if defined(AK_OS_SERENITY) // FIXME: This is a very naive implementation, and is only valid for small x. // Probably a good idea to use a better algorithm in the future, such as a taylor approximation. return 1 - ((angle * angle) / 2); +# else + return __builtin_cos(angle); +# endif #endif } @@ -306,9 +318,13 @@ constexpr T tan(T angle) return ret; #else +# if defined(AK_OS_SERENITY) // FIXME: This is a very naive implementation, and is only valid for small x. // Probably a good idea to use a better algorithm in the future, such as a taylor approximation. return angle; +# else + return __builtin_tan(angle); +# endif #endif } @@ -326,8 +342,10 @@ constexpr T atan(T value) : "0"(value)); return ret; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_atan(value); #endif } @@ -383,8 +401,10 @@ constexpr T atan2(T y, T x) : "st(1)"); return ret; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_atan2(y, x); #endif } @@ -418,8 +438,10 @@ constexpr T log(T x) : "0"(x)); return ret; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_log(x); #endif } @@ -439,8 +461,10 @@ constexpr T log2(T x) : "0"(x)); return ret; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_log2(x); #endif } @@ -460,8 +484,10 @@ constexpr T log10(T x) : "0"(x)); return ret; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_log10(x); #endif } @@ -486,8 +512,10 @@ constexpr T exp(T exponent) : "0"(exponent)); return res; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_exp(exponent); #endif } @@ -510,8 +538,10 @@ constexpr T exp2(T exponent) : "0"(exponent)); return res; #else +# if defined(AK_OS_SERENITY) // TODO: Add implementation for this function. TODO(); +# endif return __builtin_exp2(exponent); #endif } |