Skip to content

Commit ef3d622

Browse files
committed
AK: Use correct built-in overload for several math functions
sqrt, sin, cos, tan, atan, atan2, log, log10 used to always call the double built-in. Now the float overload calls the float built-in, the double overload the double built-in, and the long double overload the long double built-in. Ideally, we'd stop calling built-ins for these (see #26662), but as long as we do, we should call the right ones. Similar to the last two commits in #18998.
1 parent 0041ff7 commit ef3d622

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

AK/Math.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ constexpr T sqrt(T x)
598598
// TODO: Add implementation for this function.
599599
TODO();
600600
# endif
601-
return __builtin_sqrt(x);
601+
CALL_BUILTIN(sqrt, x);
602602
#endif
603603
}
604604

@@ -706,7 +706,7 @@ constexpr T sin(T angle)
706706
T angle_squared = angle * angle;
707707
return sign * (angle + angle * angle_squared * f(angle_squared));
708708
# else
709-
return __builtin_sin(angle);
709+
CALL_BUILTIN(sin, angle);
710710
# endif
711711
#endif
712712
}
@@ -769,7 +769,7 @@ constexpr T cos(T angle)
769769
T angle_squared = angle * angle;
770770
return sign * (1 + angle_squared * f(angle_squared));
771771
# else
772-
return __builtin_cos(angle);
772+
CALL_BUILTIN(cos, angle);
773773
# endif
774774
#endif
775775
}
@@ -810,7 +810,7 @@ constexpr T tan(T angle)
810810
# if defined(AK_OS_SERENITY)
811811
return sin(angle) / cos(angle);
812812
# else
813-
return __builtin_tan(angle);
813+
CALL_BUILTIN(tan, angle);
814814
# endif
815815
#endif
816816
}
@@ -923,7 +923,7 @@ constexpr T atan(T value)
923923
T squared = value * value;
924924
return value + value * squared * f(squared);
925925
# endif
926-
return __builtin_atan(value);
926+
CALL_BUILTIN(atan, value);
927927
#endif
928928
}
929929

@@ -1001,7 +1001,7 @@ constexpr T atan2(T y, T x)
10011001
// y < 0 && x > 0
10021002
return atan(y / x);
10031003
# else
1004-
return __builtin_atan2(y, x);
1004+
CALL_BUILTIN(atan2, y, x);
10051005
# endif
10061006
#endif
10071007
}
@@ -1120,7 +1120,7 @@ constexpr T log(T x)
11201120
// FIXME: Adjust the polynomial and formula in log2 to fit this
11211121
return log2<T>(x) / L2_E<T>;
11221122
#else
1123-
return __builtin_log(x);
1123+
CALL_BUILTIN(log, x);
11241124
#endif
11251125
}
11261126

@@ -1142,7 +1142,7 @@ constexpr T log10(T x)
11421142
// FIXME: Adjust the polynomial and formula in log2 to fit this
11431143
return log2<T>(x) / L2_10<T>;
11441144
#else
1145-
return __builtin_log10(x);
1145+
CALL_BUILTIN(log10, x);
11461146
#endif
11471147
}
11481148

0 commit comments

Comments
 (0)