Commit a133b479 authored by mru's avatar mru

32/64-bit agnostic x86 bswap


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@12496 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 936b5df9
...@@ -34,16 +34,10 @@ ...@@ -34,16 +34,10 @@
#include <byteswap.h> #include <byteswap.h>
#else #else
#ifdef ARCH_X86_64
# define LEGACY_REGS "=Q"
#else
# define LEGACY_REGS "=q"
#endif
static av_always_inline uint16_t bswap_16(uint16_t x) static av_always_inline uint16_t bswap_16(uint16_t x)
{ {
#if defined(ARCH_X86) #if defined(ARCH_X86)
asm("rorw $8, %0" : LEGACY_REGS (x) : "0" (x)); asm("rorw $8, %0" : "+r"(x));
#elif defined(ARCH_SH4) #elif defined(ARCH_SH4)
asm("swap.b %0,%0" : "=r"(x) : "0"(x)); asm("swap.b %0,%0" : "=r"(x) : "0"(x));
#else #else
...@@ -56,15 +50,13 @@ static av_always_inline uint32_t bswap_32(uint32_t x) ...@@ -56,15 +50,13 @@ static av_always_inline uint32_t bswap_32(uint32_t x)
{ {
#if defined(ARCH_X86) #if defined(ARCH_X86)
#ifdef HAVE_BSWAP #ifdef HAVE_BSWAP
asm("bswap %0": asm("bswap %0" : "+r" (x));
"=r" (x) :
#else #else
asm("xchgb %b0,%h0\n" asm("rorw $8, %w0 \n\t"
"rorl $16,%0 \n" "rorl $16, %0 \n\t"
"xchgb %b0,%h0": "rorw $8, %w0"
LEGACY_REGS (x) : : "+r"(x));
#endif #endif
"0" (x));
#elif defined(ARCH_SH4) #elif defined(ARCH_SH4)
asm("swap.b %0,%0\n" asm("swap.b %0,%0\n"
"swap.w %0,%0\n" "swap.w %0,%0\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment