[PATCH 5/5] Make swapl and swaps macros readable
Matt Turner
mattst88 at gmail.com
Thu Aug 4 15:06:36 PDT 2011
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
include/misc.h | 38 +++++++++++++++++++++-----------------
1 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/include/misc.h b/include/misc.h
index d2b5e11..6eeacda 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -261,25 +261,29 @@ version_compare(uint16_t a_major, uint16_t a_minor,
void __attribute__((error("wrong sized variable passed to swap"))) wrong_size(void);
/* byte swap a 32-bit value */
-#define swapl(x) do { \
- char n;\
- if (sizeof(*(x)) != 4) wrong_size();\
- n = ((char *) (x))[0];\
- ((char *) (x))[0] = ((char *) (x))[3];\
- ((char *) (x))[3] = n;\
- n = ((char *) (x))[1];\
- ((char *) (x))[1] = ((char *) (x))[2];\
- ((char *) (x))[2] = n;\
- } while (0)
+#define swapl(x) \
+ do { \
+ char n; \
+ if (sizeof(*(x)) != 4) \
+ wrong_size(); \
+ n = ((char *) (x))[0]; \
+ ((char *) (x))[0] = ((char *) (x))[3]; \
+ ((char *) (x))[3] = n; \
+ n = ((char *) (x))[1]; \
+ ((char *) (x))[1] = ((char *) (x))[2]; \
+ ((char *) (x))[2] = n; \
+ } while (0)
/* byte swap a short */
-#define swaps(x) do { \
- char n;\
- if (sizeof(*(x)) != 2) wrong_size();\
- n = ((char *) (x))[0];\
- ((char *) (x))[0] = ((char *) (x))[1];\
- ((char *) (x))[1] = n;\
- } while (0)
+#define swaps(x) \
+ do { \
+ char n; \
+ if (sizeof(*(x)) != 2) \
+ wrong_size(); \
+ n = ((char *) (x))[0]; \
+ ((char *) (x))[0] = ((char *) (x))[1]; \
+ ((char *) (x))[1] = n; \
+ } while (0)
/* copy 32-bit value from src to dst byteswapping on the way */
#define cpswapl(src, dst) \
--
1.7.3.4
More information about the xorg-devel
mailing list