From 9df799f16bb001179abf265b93ab524b14d0ba61 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 1 Jun 2019 09:06:01 +0900 Subject: [PATCH] Bug 1526653 - Include struct definitions for user_vfp and user_vfp_exc. Gbp-Pq: Topic porting-armhf Gbp-Pq: Name Bug-1526653-Include-struct-definitions-for-user_vfp-and-u.patch --- js/src/wasm/WasmSignalHandlers.cpp | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp index 67d18a9ebb..8420b878a3 100644 --- a/js/src/wasm/WasmSignalHandlers.cpp +++ b/js/src/wasm/WasmSignalHandlers.cpp @@ -243,7 +243,38 @@ using mozilla::DebugOnly; "Don't know how to read/write to the thread state via the mcontext_t." # endif -# if defined(ANDROID) +// On ARM Linux, including Android, unaligned FP accesses that were not flagged +// as unaligned will tend to trap (with SIGBUS) and will need to be emulated. +// +// We can only perform this emulation if the system header files provide access +// to the FP registers. In particular, must have definitions of +// `struct user_vfp` and `struct user_vfp_exc`, as it does on Android. +// +// Those definitions are however not present in the headers of every Linux +// distro - Raspbian is known to be a problem, for example. However those +// distros are tier-3 platforms. +// +// If you run into compile problems on a tier-3 platform, you can disable the +// emulation here. + +#if defined(__linux__) && defined(__arm__) +# define WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS +#endif + +#ifdef WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS +struct user_vfp { + unsigned long long fpregs[32]; + unsigned long fpscr; +}; + +struct user_vfp_exc { + unsigned long fpexc; + unsigned long fpinst; + unsigned long fpinst2; +}; +#endif + +#if defined(ANDROID) // Not all versions of the Android NDK define ucontext_t or mcontext_t. // Detect this and provide custom but compatible definitions. Note that these // follow the GLibc naming convention to access register values from -- 2.30.2