diff options
author | Christopher Ferris <cferris@google.com> | 2015-10-23 15:42:27 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 01:42:32 -0800 |
commit | de3e5ac94a907a4baca0fb606173b11da090216b (patch) | |
tree | 37c1d0fd25e66a37d8c4d0abde75a41430b20d2c /libm | |
parent | 795a57e08bb61fb0c2ae22d9f7a3ae6312511fed (diff) | |
download | bionic-de3e5ac94a907a4baca0fb606173b11da090216b.zip bionic-de3e5ac94a907a4baca0fb606173b11da090216b.tar.gz bionic-de3e5ac94a907a4baca0fb606173b11da090216b.tar.bz2 |
Fix arm64 fenv warnings, and make warnings errors.
Even though the control registers being read/written in fenv.c only
have 32 bits that are used, the instructions take a 64 bit register.
Make sure the inline assembler in the macros use 64 bit values.
Verified that before the change and after the change, the disassembly
is exactly the same.
In addition, add -Werror to the cflags.
Change-Id: I6603779327488c23e3aab13300edf2e02b101916
Diffstat (limited to 'libm')
-rw-r--r-- | libm/Android.mk | 1 | ||||
-rw-r--r-- | libm/arm64/fenv.c | 19 |
2 files changed, 16 insertions, 4 deletions
diff --git a/libm/Android.mk b/libm/Android.mk index 7535f20..f053e25 100644 --- a/libm/Android.mk +++ b/libm/Android.mk @@ -484,6 +484,7 @@ LOCAL_CFLAGS := \ -D__BIONIC_NO_MATH_INLINES \ -DFLT_EVAL_METHOD=0 \ -include $(LOCAL_PATH)/freebsd-compat.h \ + -Werror \ -Wno-missing-braces \ -Wno-parentheses \ -Wno-sign-compare \ diff --git a/libm/arm64/fenv.c b/libm/arm64/fenv.c index ce560a7..19a2393 100644 --- a/libm/arm64/fenv.c +++ b/libm/arm64/fenv.c @@ -26,6 +26,7 @@ * $FreeBSD: libm/aarch64/fenv.c $ */ +#include <stdint.h> #include <fenv.h> #define FPCR_EXCEPT_SHIFT 8 @@ -38,10 +39,20 @@ const fenv_t __fe_dfl_env = { 0 /* control */, 0 /* status */}; typedef __uint32_t fpu_control_t; // FPCR, Floating-point Control Register. typedef __uint32_t fpu_status_t; // FPSR, Floating-point Status Register. -#define __get_fpcr(__fpcr) __asm__ __volatile__("mrs %0,fpcr" : "=r" (__fpcr)) -#define __get_fpsr(__fpsr) __asm__ __volatile__("mrs %0,fpsr" : "=r" (__fpsr)) -#define __set_fpcr(__fpcr) __asm__ __volatile__("msr fpcr,%0" : :"ri" (__fpcr)) -#define __set_fpsr(__fpsr) __asm__ __volatile__("msr fpsr,%0" : :"ri" (__fpsr)) +#define __get(REGISTER, __value) { \ + uint64_t __value64; \ + __asm__ __volatile__("mrs %0," REGISTER : "=r" (__value64)); \ + __value = (__uint32_t) __value64; \ +} +#define __get_fpcr(__fpcr) __get("fpcr", __fpcr) +#define __get_fpsr(__fpsr) __get("fpsr", __fpsr) + +#define __set(REGISTER, __value) { \ + uint64_t __value64 = __value; \ + __asm__ __volatile__("msr " REGISTER ",%0" : : "ri" (__value64)); \ +} +#define __set_fpcr(__fpcr) __set("fpcr", __fpcr) +#define __set_fpsr(__fpsr) __set("fpsr", __fpsr) int fegetenv(fenv_t* envp) { __get_fpcr(envp->__control); |