"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, <sys/user.h> 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