[PATCH 6/8] Make lswap{l,s} inline functions

Matt Turner mattst88 at gmail.com
Tue Aug 16 19:58:25 PDT 2011


           text   data    bss      dec     hex  filename
before: 1875668  52136  78040  2005844  1e9b54  hw/xfree86/Xorg
after:  1875588  52136  78040  2005764  1e9b04  hw/xfree86/Xorg

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 include/misc.h |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/misc.h b/include/misc.h
index 660d265..46b83ef 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
-- 
1.7.3.4



More information about the xorg-devel mailing list