From e944cdaa8bfbf5695ef1b7f8a2b02bfa2ebfba96 Mon Sep 17 00:00:00 2001 From: lidija-b <48994452+lidija-b@users.noreply.github.com> Date: Fri, 12 Apr 2019 16:32:58 +0200 Subject: [PATCH] Add endian set for default toolchain (#2808) When default toolchain is used and architecture not listed in "#if" in jerry-libm-internal.h on little endian around 90 test-suite tests, 4 unittests and 30 jerry-tests fails depending on setup tested. This change checks endians in case no toolchain is found and sets __LITTLE_ENDIAN macro if it is little endian. This way it will be set for any future arhitectures using little endian and architecture that can have both big and little endian not listed in jerry-libm-internal.h check. JerryScript-DCO-1.0-Signed-off-by: Lidija Besker lidija.besker@rt-rk.com --- jerry-libm/jerry-libm-internal.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jerry-libm/jerry-libm-internal.h b/jerry-libm/jerry-libm-internal.h index 8b75061a4..4c6e68c6f 100644 --- a/jerry-libm/jerry-libm-internal.h +++ b/jerry-libm/jerry-libm-internal.h @@ -30,14 +30,22 @@ /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly but these catch some common cases. */ + +#ifndef __LITTLE_ENDIAN +/* Check if compiler has byte order macro. Some older versions do not. + * If byte order is supported and set to little or target is among common + * cases checked define __LITTLE_ENDIAN. + */ #if (defined (i386) || defined (__i386) || defined (__i386__) || \ defined (i486) || defined (__i486) || defined (__i486__) || \ defined (intel) || defined (x86) || defined (i86pc) || \ defined (__alpha) || defined (__osf__) || \ defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \ - defined (__xtensa__)) + defined (__xtensa__) || defined (__MIPSEL)) || \ +(defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) #define __LITTLE_ENDIAN #endif +#endif /* !__LITTLE_ENDIAN */ #ifdef __LITTLE_ENDIAN #define __HI(x) *(1 + (int *) &x)