[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

byteswap.h: Un 64bit ism



Hi,
  In /usr/include/bits/byteswap.h  is the following macro:

# define __bswap_64(x) \
     (__extension__                   \
      ({ union { unsigned long long int __ll;             \
     unsigned long int __l[2]; } __v, __r;            \
   __v.__ll = (x);                  \
   __r.__l[0] = __bswap_32 (__v.__l[1]);              \
   __r.__l[1] = __bswap_32 (__v.__l[0]);              \
   __r.__ll; }))

It is supposed to do a byte swap on a 64 bit value by swapping the two 32
bit quantities and then byteswapping each of those.

Unfortunatly you'll notice that the union uses a union of an unsigned long
long  and unsigned long int; both 64 bit on Alpha. I've changed this in my
installation to :


# define __bswap_64(x) \
     (__extension__                   \
      ({ union { uint64_t __ll;             \
     uint32_t __l[2]; } __v, __r;           \
   __v.__ll = (x);                  \
   __r.__l[0] = __bswap_32 (__v.__l[1]);              \
   __r.__l[1] = __bswap_32 (__v.__l[0]);              \
   __r.__ll; }))


I found this while debugging the Xine DVD/MPEG/VCD player; which now does
a passable attempt at playing a DVD on Linux/Alpha - although its dropping
frames all over.  I haven't got the 'Xv' video extension working so its
doing everything in software.

(That construct is in libac3/bswap.h in the xine distribution).


Share & Enjoy,

Dave


-- 
 ---------------- Have a happy GNU millennium! ----------------------   
/ Dr. David Alan Gilbert      | Running GNU/Linux on       |  Happy  \ 
\   gro.gilbert @ treblig.org |  Alpha, x86, ARM and SPARC |  In Hex /
 \ ___________________________|___ http://www.treblig.org  |________/



Reply to: