aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-04-28 12:33:31 +0200
committerMike Pall <mike>2011-04-28 12:33:31 +0200
commit0b606061dbe38bec18a4fdf37bfd248398ad015c (patch)
tree73ec4b6a9fe50e30e030abe547e2c3c761912562 /src
parent5d096dcfdef5ddb0e6dd67e155adf893df7d7809 (diff)
downloadluajit-0b606061dbe38bec18a4fdf37bfd248398ad015c.tar.gz
luajit-0b606061dbe38bec18a4fdf37bfd248398ad015c.tar.bz2
luajit-0b606061dbe38bec18a4fdf37bfd248398ad015c.zip
ARM: Use own lj_bswap(). Reduce min. req. version of GCC to 4.2.
Diffstat (limited to 'src')
-rw-r--r--src/lj_arch.h6
-rw-r--r--src/lj_def.h24
2 files changed, 28 insertions, 2 deletions
diff --git a/src/lj_arch.h b/src/lj_arch.h
index 3ddc3e46..f179cf80 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -173,7 +173,11 @@
173#if __GNUC__ < 4 173#if __GNUC__ < 4
174#error "Need at least GCC 4.0 or newer" 174#error "Need at least GCC 4.0 or newer"
175#endif 175#endif
176#elif LJ_TARGET_ARM || LJ_TARGET_PPC 176#elif LJ_TARGET_ARM
177#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
178#error "Need at least GCC 4.2 or newer"
179#endif
180#elif LJ_TARGET_PPC
177#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) 181#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
178#error "Need at least GCC 4.3 or newer" 182#error "Need at least GCC 4.3 or newer"
179#endif 183#endif
diff --git a/src/lj_def.h b/src/lj_def.h
index b7df8606..c60bc118 100644
--- a/src/lj_def.h
+++ b/src/lj_def.h
@@ -131,7 +131,29 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
131#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31)) 131#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31))
132#endif 132#endif
133 133
134#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 134#if defined(__arm__)
135static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
136{
137 uint32_t r;
138#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\
139 __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
140 __asm__("rev %0, %1" : "=r" (r) : "r" (x));
141 return r;
142#else
143#ifdef __thumb__
144 r = x ^ lj_ror(x, 16);
145#else
146 __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x));
147#endif
148 return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8);
149#endif
150}
151
152static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
153{
154 return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32));
155}
156#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
135static LJ_AINLINE uint32_t lj_bswap(uint32_t x) 157static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
136{ 158{
137 return (uint32_t)__builtin_bswap32((int32_t)x); 159 return (uint32_t)__builtin_bswap32((int32_t)x);