Merge "Simplify the libm build now we don't support non-neon."
diff --git a/libc/arch-riscv64/bionic/setjmp.S b/libc/arch-riscv64/bionic/setjmp.S
index 2811bbe..eea2978 100644
--- a/libc/arch-riscv64/bionic/setjmp.S
+++ b/libc/arch-riscv64/bionic/setjmp.S
@@ -107,13 +107,13 @@
ENTRY(setjmp)
__BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(setjmp)
li a1, 1
- tail PIC_PLT(sigsetjmp)
+ tail sigsetjmp
END(setjmp)
ENTRY(_setjmp)
__BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(_setjmp)
li a1, 0
- tail PIC_PLT(sigsetjmp)
+ tail sigsetjmp
END(_setjmp)
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
@@ -126,7 +126,7 @@
// Get the cookie and store it along with the signal flag.
mv a0, a1
- call PIC_PLT(__bionic_setjmp_cookie_get)
+ call __bionic_setjmp_cookie_get
mv a1, a0
ld a0, 0(sp)
sd a1, _JB_SIGFLAG(a0)
@@ -139,7 +139,7 @@
// The 'how'/a0 argument is ignored if set is NULL.
li a1, 0 // NULL
addi a2, a0, _JB_SIGMASK // old_mask.
- call PIC_PLT(sigprocmask)
+ call sigprocmask
1:
// Restore original a0/ra.
@@ -216,7 +216,7 @@
li a0, 2 // SIG_SETMASK
addi a1, a2, _JB_SIGMASK // new_mask
li a2, 0 // NULL
- call PIC_PLT(sigprocmask)
+ call sigprocmask
mv a1, t0 // Restore 'value'.
// Restore original a0 and ra.
@@ -250,7 +250,7 @@
sd a0, 8(sp)
sd a1, 16(sp)
ld a0, _JB_SIGFLAG(a0)
- call PIC_PLT(__bionic_setjmp_cookie_check)
+ call __bionic_setjmp_cookie_check
ld ra, 0(sp)
ld a0, 8(sp)
ld a1, 16(sp)
@@ -278,7 +278,7 @@
ret
3:
- call PIC_PLT(__bionic_setjmp_checksum_mismatch)
+ call __bionic_setjmp_checksum_mismatch
END(siglongjmp)
ALIAS_SYMBOL(longjmp, siglongjmp)
diff --git a/libc/private/bionic_asm_riscv64.h b/libc/private/bionic_asm_riscv64.h
index e0fb9a3..463ca31 100644
--- a/libc/private/bionic_asm_riscv64.h
+++ b/libc/private/bionic_asm_riscv64.h
@@ -37,8 +37,6 @@
#pragma once
-#define PIC_PLT(x) x@plt
-
#define __bionic_asm_align 16
#undef __bionic_asm_function_type
diff --git a/libm/Android.bp b/libm/Android.bp
index 9b9b5e5..e829f74 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -316,6 +316,8 @@
"upstream-freebsd/lib/msun/src/e_sqrtf.c",
"upstream-freebsd/lib/msun/src/s_ceil.c",
"upstream-freebsd/lib/msun/src/s_ceilf.c",
+ "upstream-freebsd/lib/msun/src/s_copysign.c",
+ "upstream-freebsd/lib/msun/src/s_copysignf.c",
"upstream-freebsd/lib/msun/src/s_floor.c",
"upstream-freebsd/lib/msun/src/s_floorf.c",
"upstream-freebsd/lib/msun/src/s_fma.c",
@@ -326,8 +328,12 @@
"upstream-freebsd/lib/msun/src/s_fminf.c",
"upstream-freebsd/lib/msun/src/s_llrint.c",
"upstream-freebsd/lib/msun/src/s_llrintf.c",
+ "upstream-freebsd/lib/msun/src/s_llround.c",
+ "upstream-freebsd/lib/msun/src/s_llroundf.c",
"upstream-freebsd/lib/msun/src/s_lrint.c",
"upstream-freebsd/lib/msun/src/s_lrintf.c",
+ "upstream-freebsd/lib/msun/src/s_lround.c",
+ "upstream-freebsd/lib/msun/src/s_lroundf.c",
"upstream-freebsd/lib/msun/src/s_rint.c",
"upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
@@ -341,6 +347,17 @@
riscv64: {
srcs: [
"riscv64/fenv.c",
+ "riscv64/lrint.S",
+ "riscv64/sqrt.S",
+ ],
+
+ exclude_srcs: [
+ "upstream-freebsd/lib/msun/src/e_sqrt.c",
+ "upstream-freebsd/lib/msun/src/e_sqrtf.c",
+ "upstream-freebsd/lib/msun/src/s_llrint.c",
+ "upstream-freebsd/lib/msun/src/s_llrintf.c",
+ "upstream-freebsd/lib/msun/src/s_lrint.c",
+ "upstream-freebsd/lib/msun/src/s_lrintf.c",
],
version_script: ":libm.riscv64.map",
},
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 3b9228c..7487323 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -49,6 +49,9 @@
float ceilf(float x) { return __builtin_ceilf(x); }
double ceil(double x) { return __builtin_ceil(x); }
+double copysign(double x, double y) { return __builtin_copysign(x, y); }
+float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
+
float floorf(float x) { return __builtin_floorf(x); }
double floor(double x) { return __builtin_floor(x); }
@@ -61,6 +64,11 @@
float fminf(float x, float y) { return __builtin_fminf(x, y); }
double fmin(double x, double y) { return __builtin_fmin(x, y); }
+long lround(double x) { return __builtin_lround(x); }
+long lroundf(float x) { return __builtin_lroundf(x); }
+long long llround(double x) { return __builtin_llround(x); }
+long long llroundf(float x) { return __builtin_llroundf(x); }
+
float rintf(float x) { return __builtin_rintf(x); }
double rint(double x) { return __builtin_rint(x); }
diff --git a/libm/riscv64/lrint.S b/libm/riscv64/lrint.S
new file mode 100644
index 0000000..eb13833
--- /dev/null
+++ b/libm/riscv64/lrint.S
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <private/bionic_asm.h>
+
+ENTRY(lrint)
+ fcvt.l.d a0, fa0, dyn
+ ret
+END(lrint)
+
+ENTRY(lrintf)
+ fcvt.l.s a0, fa0, dyn
+ ret
+END(lrintf)
+
+// sizeof(long) and sizeof(long long) are the same for riscv64
+ALIAS_SYMBOL(llrint, lrint);
+
+ALIAS_SYMBOL(llrintf, lrintf);
diff --git a/libm/riscv64/sqrt.S b/libm/riscv64/sqrt.S
new file mode 100644
index 0000000..0db1335
--- /dev/null
+++ b/libm/riscv64/sqrt.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <private/bionic_asm.h>
+
+ENTRY(sqrt)
+ fsqrt.d fa0, fa0
+ ret
+END(sqrt)
+
+ENTRY(sqrtf)
+ fsqrt.s fa0, fa0
+ ret
+END(sqrtf)
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index 76b5078..60872f3 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -1053,22 +1053,22 @@
auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
- ASSERT_EQ(1235, lrint(1234.01));
- ASSERT_EQ(1235, lrintf(1234.01f));
- ASSERT_EQ(1235, lrintl(1234.01L));
+ EXPECT_EQ(1235, lrint(1234.01));
+ EXPECT_EQ(1235, lrintf(1234.01f));
+ EXPECT_EQ(1235, lrintl(1234.01L));
fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
- ASSERT_EQ(1234, lrint(1234.01));
- ASSERT_EQ(1234, lrintf(1234.01f));
- ASSERT_EQ(1234, lrintl(1234.01L));
+ EXPECT_EQ(1234, lrint(1234.01));
+ EXPECT_EQ(1234, lrintf(1234.01f));
+ EXPECT_EQ(1234, lrintl(1234.01L));
fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
- ASSERT_EQ(1235L, llrint(1234.01));
- ASSERT_EQ(1235L, llrintf(1234.01f));
- ASSERT_EQ(1235L, llrintl(1234.01L));
+ EXPECT_EQ(1235L, llrint(1234.01));
+ EXPECT_EQ(1235L, llrintf(1234.01f));
+ EXPECT_EQ(1235L, llrintl(1234.01L));
fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
- ASSERT_EQ(1234L, llrint(1234.01));
- ASSERT_EQ(1234L, llrintf(1234.01f));
- ASSERT_EQ(1234L, llrintl(1234.01L));
+ EXPECT_EQ(1234L, llrint(1234.01));
+ EXPECT_EQ(1234L, llrintf(1234.01f));
+ EXPECT_EQ(1234L, llrintl(1234.01L));
}
TEST(MATH_TEST, rint) {
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 21b3f6c..acc7ccd 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -490,22 +490,22 @@
// NaN.
- snprintf_fn(buf, sizeof(buf), fmt, nanf(""));
+ snprintf_fn(buf, sizeof(buf), fmt, nan(""));
EXPECT_STREQ(nan_, buf) << fmt;
EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
EXPECT_TRUE(isnan(f));
- snprintf_fn(buf, sizeof(buf), fmt, -nanf(""));
+ snprintf_fn(buf, sizeof(buf), fmt, -nan(""));
EXPECT_STREQ(minus_nan, buf) << fmt;
EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
EXPECT_TRUE(isnan(f));
- snprintf_fn(buf, sizeof(buf), fmt_plus, nanf(""));
+ snprintf_fn(buf, sizeof(buf), fmt_plus, nan(""));
EXPECT_STREQ(plus_nan, buf) << fmt_plus;
EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
EXPECT_TRUE(isnan(f));
- snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf(""));
+ snprintf_fn(buf, sizeof(buf), fmt_plus, -nan(""));
EXPECT_STREQ(minus_nan, buf) << fmt_plus;
EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
EXPECT_TRUE(isnan(f));