[MPlayer-dev-eng] [PATCH] bswap.h which takes care of cpu's > 386 by using different asm commands
Falk Hueffner
falk.hueffner at student.uni-tuebingen.de
Sun Aug 4 20:58:02 CEST 2002
Dirk <noisyb at gmx.net> writes:
> + unsigned char *ptr = (unsigned char *) &x, tmp;
> + tmp = ptr[0];
> + ptr[0] = ptr[7];
> + ptr[7] = tmp;
> + tmp = ptr[1];
> + ptr[1] = ptr[6];
> + ptr[6] = tmp;
> + tmp = ptr[2];
> + ptr[2] = ptr[5];
> + ptr[5] = tmp;
> + tmp = ptr[3];
> + ptr[3] = ptr[4];
> + ptr[4] = tmp;
This is going to be horrendously slow on Alpha, and probably on most
other RISC architectures. Besides, I don't see any reason to touch
this code unless you can measure an improvement for some platform.
> -#define bswap_64(x) \
> - (__extension__ \
> - ({ union { __extension__ unsigned long long int __ll; \
> - unsigned long int __l[2]; } __w, __r; \
> - __w.__ll = (x); \
> - __r.__l[0] = bswap_32 (__w.__l[1]); \
> - __r.__l[1] = bswap_32 (__w.__l[0]); \
> - __r.__ll; }))
> -#endif /* !ARCH_X86 */
By the way, this is broken, too, since long int is 64 bit on some
architectures (It was fixed in glibc some years ago). Please somebody
s/unsigned long int/unsigned int/.
Falk
More information about the MPlayer-dev-eng
mailing list