diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-08-16 22:50:22 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-08-16 22:50:22 +0000 |
commit | b1187223a37f7e79c386c6ec86b3cd082bf9021f (patch) | |
tree | 084ec952478e36b67d3de3ad1a335227e47289bb /libmpdvdkit2/bswap.h | |
parent | a695955bd29a2691bf5e918d2e4716d58299b0cb (diff) | |
download | mpv-b1187223a37f7e79c386c6ec86b3cd082bf9021f.tar.bz2 mpv-b1187223a37f7e79c386c6ec86b3cd082bf9021f.tar.xz |
apply mplayer-specific patches
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7034 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdvdkit2/bswap.h')
-rw-r--r-- | libmpdvdkit2/bswap.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/libmpdvdkit2/bswap.h b/libmpdvdkit2/bswap.h index dd7417059a..5967c7fee9 100644 --- a/libmpdvdkit2/bswap.h +++ b/libmpdvdkit2/bswap.h @@ -20,8 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <config.h> - #if defined(WORDS_BIGENDIAN) /* All bigendian systems are fine, just ignore the swaps. */ #define B2N_16(x) (void)(x) @@ -48,13 +46,51 @@ #define B2N_32(x) x = swap32(x) #define B2N_64(x) x = swap64(x) +#elif defined(ARCH_X86) +inline static unsigned short bswap_16(unsigned short x) +{ + __asm("xchgb %b0,%h0" : + "=q" (x) : + "0" (x)); + return x; +} +#define B2N_16(x) x = bswap_16(x) + +inline static unsigned int bswap_32(unsigned int x) +{ + __asm( +#if __CPU__ > 386 + "bswap %0": + "=r" (x) : +#else + "xchgb %b0,%h0\n" + " rorl $16,%0\n" + " xchgb %b0,%h0": + "=q" (x) : +#endif + "0" (x)); + return x; +} +#define B2N_32(x) x = bswap_32(x) + +inline static unsigned long long int bswap_64(unsigned long long int x) +{ + register union { __extension__ uint64_t __ll; + uint32_t __l[2]; } __x; + asm("xchgl %0,%1": + "=r"(__x.__l[0]),"=r"(__x.__l[1]): + "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); + return __x.__ll; +} +#define B2N_64(x) x = bswap_64(x) + /* This is a slow but portable implementation, it has multiple evaluation * problems so beware. * FreeBSD and Solaris don't have <byteswap.h> or any other such * functionality! */ -#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) +#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(__CYGWIN__) #define B2N_16(x) \ x = ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8)) |