Eric Anholt <e...@anholt.net> writes:

>  #define swapll(x) do { \
> +             uint64_t temp; \
>               if (sizeof(*(x)) != 8) \
>                       wrong_size(); \
> -                swap_uint64((uint64_t *)(x));   \
> +             memcpy(&temp, x, 8); \
> +             temp = bswap_64(temp); \
> +             memcpy(x, &temp, 8); \
>       } while (0)

>  #define swapl(x) do { \
> +             uint32_t temp; \
>               if (sizeof(*(x)) != 4) \
>                       wrong_size(); \
> -             if (__builtin_constant_p((uintptr_t)(x) & 3) && ((uintptr_t)(x) 
> & 3) == 0) \
> -                     *(x) = lswapl(*(x)); \
> -             else \
> -                     swap_uint32((uint32_t *)(x)); \
> +             memcpy(&temp, x, 4); \
> +             temp = bswap_32(temp); \
> +             memcpy(x, &temp, 4); \
>       } while (0)

>  #define swaps(x) do { \
> +             uint16_t temp; \
>               if (sizeof(*(x)) != 2) \
>                       wrong_size(); \
> -             if (__builtin_constant_p((uintptr_t)(x) & 1) && ((uintptr_t)(x) 
> & 1) == 0) \
> -                     *(x) = lswaps(*(x)); \
> -             else \
> -                     swap_uint16((uint16_t *)(x)); \
> +             memcpy(&temp, x, 2); \
> +             temp = bswap_16(temp); \
> +             memcpy(x, &temp, 2); \
>       } while (0)

Any particular reason to think that x might be unaligned (and hence need
the memcpys? Yeah, I know they're probably 'free' when things are
aligned.

The rest of this is

Reviewed-by: Keith Packard <kei...@keithp.com>

-- 
-keith

Attachment: signature.asc
Description: PGP signature

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to