mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
ARM: Use own lj_bswap(). Reduce min. req. version of GCC to 4.2.
This commit is contained in:
parent
5d096dcfde
commit
0b606061db
@ -123,8 +123,8 @@ operating system, CPU and compilers:
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td class="compatcpu">ARM</td>
|
||||
<td class="compatos">GCC 4.3+</td>
|
||||
<td class="compatos">GCC 4.3+</td>
|
||||
<td class="compatos">GCC 4.2+</td>
|
||||
<td class="compatos">GCC 4.2+</td>
|
||||
<td class="compatos compatno"> </td>
|
||||
<td class="compatos compatno"> </td>
|
||||
</tr>
|
||||
|
@ -173,7 +173,11 @@
|
||||
#if __GNUC__ < 4
|
||||
#error "Need at least GCC 4.0 or newer"
|
||||
#endif
|
||||
#elif LJ_TARGET_ARM || LJ_TARGET_PPC
|
||||
#elif LJ_TARGET_ARM
|
||||
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
|
||||
#error "Need at least GCC 4.2 or newer"
|
||||
#endif
|
||||
#elif LJ_TARGET_PPC
|
||||
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
|
||||
#error "Need at least GCC 4.3 or newer"
|
||||
#endif
|
||||
|
24
src/lj_def.h
24
src/lj_def.h
@ -131,7 +131,29 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
|
||||
#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31))
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
#if defined(__arm__)
|
||||
static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
|
||||
{
|
||||
uint32_t r;
|
||||
#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\
|
||||
__ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
|
||||
__asm__("rev %0, %1" : "=r" (r) : "r" (x));
|
||||
return r;
|
||||
#else
|
||||
#ifdef __thumb__
|
||||
r = x ^ lj_ror(x, 16);
|
||||
#else
|
||||
__asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x));
|
||||
#endif
|
||||
return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
|
||||
{
|
||||
return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32));
|
||||
}
|
||||
#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
|
||||
{
|
||||
return (uint32_t)__builtin_bswap32((int32_t)x);
|
||||
|
Loading…
Reference in New Issue
Block a user