aboutsummaryrefslogtreecommitdiff
path: root/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'include/std')
-rw-r--r--include/std/misc.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/std/misc.h b/include/std/misc.h
index a9bd5b6..03d7972 100644
--- a/include/std/misc.h
+++ b/include/std/misc.h
@@ -1,6 +1,31 @@
#ifndef AMALGAM_MISC_H
#define AMALGAM_MISC_H
+#include "types.h"
+#include <sys/types.h>
+
+#if defined(__BYTE_ORDER)
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define AMAL_LITTLE_ENDIAN
+ #elif __BYTE_ORDER == __BIG_ENDIAN
+ #define AMAL_BIG_ENDIAN
+ #endif
+#elif defined(__BYTE_ORDER__)
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ #define AMAL_LITTLE_ENDIAN
+ #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #define AMAL_BIG_ENDIAN
+ #endif
+#endif
+
+#if !defined(AMAL_LITTLE_ENDIAN) && !defined(AMAL_BIG_ENDIAN)
+#error Unsupported endian, neither little or big endian
+#endif
+
+u16 byteswap16(u16 value);
+u32 byteswap32(u32 value);
+u64 byteswap64(u64 value);
+
#ifndef AMAL_PEDANTIC
#include "log.h"
#endif