Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Dave Gilbert <gilbertd@treblig.org>
To: axp-list@redhat.com
Cc: debian-alpha@lists.debian.org
Subject: byteswap.h: Un 64bit ism
Date: Tue, 26 Dec 2000 14:31:58 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.10.10012261417490.2753-100000@tardis.home.dave> (raw)

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	other threads:[~2000-12-26 14:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox