summaryrefslogtreecommitdiff
path: root/core/riscv-rv32i/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/riscv-rv32i/math.c')
-rw-r--r--core/riscv-rv32i/math.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/riscv-rv32i/math.c b/core/riscv-rv32i/math.c
new file mode 100644
index 0000000000..591a67eb8f
--- /dev/null
+++ b/core/riscv-rv32i/math.c
@@ -0,0 +1,19 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+#ifdef CONFIG_FPU
+/* Single precision floating point square root. */
+float sqrtf(float x)
+{
+ asm volatile (
+ "fsqrt.s %0, %1"
+ : "=f" (x)
+ : "f" (x));
+
+ return x;
+}
+#endif