summaryrefslogtreecommitdiff
path: root/navit/endianess.h
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
commit0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76 (patch)
treebe7bb1cb1020f4022e41c004e2fa9d561ea3580d /navit/endianess.h
parentf46eb419c46011d6d103b7f06cb2c842a2cbe6c9 (diff)
downloadnavit-0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76.tar.gz
Fix:Core:Renamed src to navit for cleanup of includes
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1059 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/endianess.h')
-rw-r--r--navit/endianess.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/navit/endianess.h b/navit/endianess.h
new file mode 100644
index 000000000..5cd58b8d1
--- /dev/null
+++ b/navit/endianess.h
@@ -0,0 +1,34 @@
+#ifndef __ENDIANESS_HANDLER__
+
+#include <endian.h>
+
+/* Get machine dependent optimized versions of byte swapping functions. */
+#include <byteswap.h>
+
+#ifdef __OPTIMIZE__
+/* We can optimize calls to the conversion functions. Either nothing has
+ to be done or we are using directly the byte-swapping functions which
+ often can be inlined. */
+
+ #if __BYTE_ORDER == __BIG_ENDIAN
+ #define le16_to_cpu(x) __bswap_16 (x)
+ #define le32_to_cpu(x) __bswap_32 (x)
+ #define le64_to_cpu(x) __bswap_64 (x)
+ #define cpu_to_le16(x) __bswap_16 (x)
+ #define cpu_to_le32(x) __bswap_32 (x)
+ #define cpu_to_le64(x) __bswap_64 (x)
+ #else
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define le16_to_cpu(x) (x)
+ #define le32_to_cpu(x) (x)
+ #define cpu_to_le16(x) (x)
+ #define cpu_to_le16(x) (x)
+ #else
+ #error "Unknown endianess"
+ #endif
+ #endif
+#endif
+
+#define __ENDIANESS_HANDLER__
+#endif
+