From a2f0ff5f73db204a9d61e65148b28f6acc5121df Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 16 Aug 2011 19:30:20 -0400 Subject: [PATCH] Make lswap{l,s} inline functions text data bss dec hex filename before: 1875668 52136 78040 2005844 1e9b54 hw/xfree86/Xorg after: 1875588 52136 78040 2005764 1e9b04 hw/xfree86/Xorg Reviewed-by: Peter Harris Signed-off-by: Matt Turner --- include/misc.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/misc.h b/include/misc.h index ac27a81f3..096a31ad0 100644 --- a/include/misc.h +++ b/include/misc.h @@ -122,13 +122,19 @@ typedef struct _xReq *xReqPtr; /* byte swap a 32-bit literal */ -#define lswapl(x) ((((x) & 0xff) << 24) |\ - (((x) & 0xff00) << 8) |\ - (((x) & 0xff0000) >> 8) |\ - (((x) >> 24) & 0xff)) +static inline uint32_t lswapl(uint32_t x) +{ + return ((x & 0xff) << 24) | + ((x & 0xff00) << 8) | + ((x & 0xff0000) >> 8) | + ((x >> 24) & 0xff); +} -/* byte swap a short literal */ -#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)) +/* byte swap a 16-bit literal */ +static inline uint16_t lswaps(uint16_t x) +{ + return ((x & 0xff) << 8) | ((x >> 8) & 0xff); +} #undef min #undef max