summaryrefslogtreecommitdiff
path: root/Libraries/LibM
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-08-09 23:23:01 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-08-10 08:46:22 +0200
commitcfe8fdd5aaf1937563278ac6a30d57593df24c7c (patch)
treed7e6c34feb11d78676576c0c7a0eb58d3750568f /Libraries/LibM
parent0a061d4314e172529298a6c1c65e89dde6dec9f3 (diff)
downloadserenity-cfe8fdd5aaf1937563278ac6a30d57593df24c7c.zip
LibM: Implement sqrt()
Use the x87 fsqrt instruction for that. We cannot use __builtin_sqrt(), since GCC expands it into a sqrt() call, so we just loop endlessly.
Diffstat (limited to 'Libraries/LibM')
-rw-r--r--Libraries/LibM/math.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp
index 8d0cc11135..52170f23dc 100644
--- a/Libraries/LibM/math.cpp
+++ b/Libraries/LibM/math.cpp
@@ -58,9 +58,11 @@ double tan(double angle)
return ampsin(angle) / ampsin(M_PI_2 + angle);
}
-double sqrt(double)
+double sqrt(double x)
{
- ASSERT_NOT_REACHED();
+ double res;
+ __asm__("fsqrt" : "=t"(res) : "0"(x));
+ return res;
}
double sinh(double)