diff options
author | Matt Turner <mattst88@gmail.com> | 2011-08-16 19:12:21 -0400 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2011-09-21 17:14:44 -0400 |
commit | 889b700e7760ced38bcf5f3aff2d31d3d9a058d7 (patch) | |
tree | 1536d5c1bf0809e07fc1bc4653f5f4167f53ac08 /include | |
parent | a2f0ff5f73db204a9d61e65148b28f6acc5121df (diff) |
Use lswap{l,s} in cpswap{l,s}
Should be safe since cpswap isn't used on pointers.
text data bss dec hex filename
before: 1875588 52136 78040 2005764 1e9b04 hw/xfree86/Xorg
after: 1872820 52136 78040 2002996 1e9034 hw/xfree86/Xorg
bswap instructions: 5 -> 131 (used in lswapl)
rol instructions: 811 -> 943 (used in lswaps)
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/misc.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/include/misc.h b/include/misc.h index 096a31ad0..fb235edeb 100644 --- a/include/misc.h +++ b/include/misc.h @@ -301,20 +301,18 @@ static inline void swap_uint16(uint16_t *x) } while (0) /* copy 32-bit value from src to dst byteswapping on the way */ -#define cpswapl(src, dst) { \ +#define cpswapl(src, dst) do { \ if (sizeof((src)) != 4 || sizeof((dst)) != 4) \ wrong_size(); \ - ((char *)&(dst))[0] = ((char *) &(src))[3];\ - ((char *)&(dst))[1] = ((char *) &(src))[2];\ - ((char *)&(dst))[2] = ((char *) &(src))[1];\ - ((char *)&(dst))[3] = ((char *) &(src))[0]; } + (dst) = lswapl((src)); \ + } while (0) /* copy short from src to dst byteswapping on the way */ -#define cpswaps(src, dst) { \ +#define cpswaps(src, dst) do { \ if (sizeof((src)) != 2 || sizeof((dst)) != 2) \ wrong_size(); \ - ((char *) &(dst))[0] = ((char *) &(src))[1];\ - ((char *) &(dst))[1] = ((char *) &(src))[0]; } + (dst) = lswaps((src)); \ + } while (0) extern _X_EXPORT void SwapLongs( CARD32 *list, |