ref: 305ad9c2c8c62668bd3df2133494801b99b99a67
parent: 3d4b32c3af3e12ce408536464a1afa67748f9eac
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Apr 13 12:53:30 EDT 2023
use manual byte swapping on SPARC to avoid unaligned access
--- a/flisp.c
+++ b/flisp.c
@@ -1816,8 +1816,22 @@
#if BYTE_ORDER == BIG_ENDIAN
#undef SWAP_INT32
#undef SWAP_INT16
+#if defined(__sparc__)
+#define SWAP_INT32(a) \
+ do{ \
+ uint8_t *x = (void*)a, y; \
+ y = x[0]; x[0] = x[3]; x[3] = y; \
+ y = x[1]; x[1] = x[2]; x[2] = y; \
+ }while(0)
+#define SWAP_INT16(a) \
+ do{ \
+ uint8_t *x = (void*)a, y; \
+ y = x[0]; x[0] = x[1]; x[1] = y; \
+ }while(0)
+#else
#define SWAP_INT32(a) (*(int32_t*)(a) = bswap_32(*(int32_t*)(a)))
#define SWAP_INT16(a) (*(int16_t*)(a) = bswap_16(*(int16_t*)(a)))
+#endif
#define compute_maxstack compute_maxstack_swap
#include "maxstack.inc"
#undef compute_maxstack