[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in bswap_64 macro <bits/byteswap.h>
From: |
Henk |
Subject: |
Re: Bug in bswap_64 macro <bits/byteswap.h> |
Date: |
Fri, 27 Dec 2002 06:55:55 +0100 |
Oops, looked in CVS fixed 17 months ago....
Sorry folks.
H.
Henk wrote:
> Hi,
>
> The __bswap_64 macro fails on my Alpha machine, and may possibly fail on
>
> other 64bits architectures as well...
> The macro uses a union which expands to a 16 byte structure, because
> "unsigned long int " is of size 8 on a 64-bits machine.
>
> To fix it use "unsigned int" for the __l field, better still use in
> bswap_XX fixed size types like __32 __64 .. , or so.
>
> Regards,
>
> Henk
>
> Original bits/byteswap.h macro:
>
> # define __bswap_64(x) \
> (__extension__
> ({ union { __extension__ unsigned long long int __ll;
> !!!!! -> unsigned long int <-!!!!!!! __l[2]; } __w,
> __r;
> if (__builtin_constant_p (x))
> __r.__ll = __bswap_constant_64(x);
> else
> {
> __w.__ll = (x);
> __r.__l[0] = __bswap_32(__w.__l[1]);
> __r.__l[1] = __bswap_32(__w.__l[0]);
> }
> __r.__ll; }))