diff options
author | Matt Turner <mattst88@gmail.com> | 2011-08-04 18:02:31 -0400 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2011-08-04 18:08:04 -0400 |
commit | 4e565ad47b57f832ae85977e1e9737d1bbd3cd19 (patch) | |
tree | 1b3e573c0a9d5158346df8c5ebc7051b58c9fec3 | |
parent | 07c114e0f196d420afb568c80f100dc56624edd5 (diff) |
Make swapl and swaps macros readablebswap-cleanup
Signed-off-by: Matt Turner <mattst88@gmail.com>
-rw-r--r-- | include/misc.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/include/misc.h b/include/misc.h index d2b5e115d..6eeacdadb 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) \ |