--- /dev/null
+/*
+ * Copyright (C) 2015 Czech Technical University in Prague
+ *
+ * Authors:
+ * - Michal Sojka <sojkam1@fel.cvut.cz>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include "types.h"
+
+#if defined(__TI_COMPILER_VERSION__)
+#if defined(__big_endian__) && !defined(__little_endian__)
+#define RPP_BIG_ENDIAN 1
+#endif
+#if defined(__little_endian__) && !defined(__big_endian__)
+#define RPP_LITTLE_ENDIAN 1
+#endif
+#endif
+
+#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__)
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define RPP_BIG_ENDIAN 1
+#endif
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define RPP_LITTLE_ENDIAN 1
+#endif
+#endif
+
+#if defined(RPP_BIG_ENDIAN) && !defined(RPP_LITTLE_ENDIAN)
+
+static inline uint16_t cpu_to_le16(uint16_t x) { return __rev16(x); }
+static inline uint16_t cpu_to_be16(uint16_t x) { return x; }
+static inline uint32_t cpu_to_le32(uint32_t x) { return __rev(x); }
+static inline uint32_t cpu_to_be32(uint32_t x) { return x; }
+
+static inline uint16_t le16_to_cpu(uint16_t x) { return __rev16(x); }
+static inline uint16_t be16_to_cpu(uint16_t x) { return x; }
+static inline uint32_t le32_to_cpu(uint32_t x) { return __rev(x); }
+static inline uint32_t be32_to_cpu(uint32_t x) { return x; }
+
+#elif defined(RPP_LITTLE_ENDIAN) && !defined(RPP_BIG_ENDIAN)
+
+static inline uint16_t cpu_to_be16(uint16_t x) { return __rev16(x); }
+static inline uint16_t cpu_to_le16(uint16_t x) { return x; }
+static inline uint32_t cpu_to_be32(uint32_t x) { return __rev(x); }
+static inline uint32_t cpu_to_le32(uint32_t x) { return x; }
+
+static inline uint16_t be16_to_cpu(uint16_t x) { return __rev16(x); }
+static inline uint16_t le16_to_cpu(uint16_t x) { return x; }
+static inline uint32_t be32_to_cpu(uint32_t x) { return __rev(x); }
+static inline uint32_t le32_to_cpu(uint32_t x) { return x; }
+
+#else
+#error Unknown endian
+#endif /* endian */
+
+#endif