summaryrefslogtreecommitdiff
path: root/src/core/endian_func.hpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-21 19:21:21 +0000
committerrubidium <rubidium@openttd.org>2007-12-21 19:21:21 +0000
commit01e20c91403ebe8c88697ec11812fb46d414c770 (patch)
treefc1669fb9cd1857bea972a4378d8ebd1e80facfa /src/core/endian_func.hpp
parentd5c4ba8246fbd9b44469037d8224a94c0a5ce5d3 (diff)
downloadopenttd-01e20c91403ebe8c88697ec11812fb46d414c770.tar.xz
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
Diffstat (limited to 'src/core/endian_func.hpp')
-rw-r--r--src/core/endian_func.hpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/endian_func.hpp b/src/core/endian_func.hpp
new file mode 100644
index 000000000..545e6b986
--- /dev/null
+++ b/src/core/endian_func.hpp
@@ -0,0 +1,22 @@
+/* $Id$ */
+
+/** @file endian_func.hpp */
+
+#ifndef ENDIAN_FUNC_H
+#define ENDIAN_FUNC_H
+
+static inline uint16 ReadLE16Aligned(const void *x)
+{
+ return FROM_LE16(*(const uint16*)x);
+}
+
+static inline uint16 ReadLE16Unaligned(const void *x)
+{
+#ifdef OTTD_ALIGNMENT
+ return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
+#else
+ return FROM_LE16(*(const uint16*)x);
+#endif
+}
+
+#endif /* ENDIAN_FUNC_H */