summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRob Landley2006-05-29 05:51:12 +0000
committerRob Landley2006-05-29 05:51:12 +0000
commitbba7f08d2788bc9bc30a7a60fdfd873a73fead9a (patch)
treed2f6adda7dc120be2aa64c7a984f12c8ecf608f2 /include
parent97551974485a8680299560af8863023dfb9634af (diff)
downloadbusybox-bba7f08d2788bc9bc30a7a60fdfd873a73fead9a.zip
busybox-bba7f08d2788bc9bc30a7a60fdfd873a73fead9a.tar.gz
Add SWAP_LE?? and SWAP_BE?? macros, and make things use them. Converts values
to/from little endian or big endian, which is a NOP if that's what the current platform already is.
Diffstat (limited to 'include')
-rw-r--r--include/platform.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/include/platform.h b/include/platform.h
index d684c2d..10c1d7d 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -48,11 +48,6 @@
# define __const const
#endif
-#ifndef __THROW
-# define __THROW
-#endif
-
-
#ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */
@@ -118,6 +113,22 @@
# define BB_LITTLE_ENDIAN 1
#endif
+#if BB_BIG_ENDIAN
+#define SWAP_BE16(x) x
+#define SWAP_BE32(x) x
+#define SWAP_BE64(x) x
+#define SWAP_LE16(x) bswap_16(x)
+#define SWAP_LE32(x) bswap_32(x)
+#define SWAP_LE64(x) bswap_64(x)
+#else
+#define SWAP_BE16(x) bswap_16(x)
+#define SWAP_BE32(x) bswap_32(x)
+#define SWAP_BE64(x) bswap_64(x)
+#define SWAP_LE16(x) x
+#define SWAP_LE32(x) x
+#define SWAP_LE64(x) x
+#endif
+
/* ---- Networking ------------------------------------------ */
#ifndef __APPLE__
# include <arpa/inet.h>