summaryrefslogtreecommitdiff
path: root/include/endian.h
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-04-04 06:01:50 +0000
committerstefan <stefan@s00.xyz>2023-04-04 06:01:50 +0000
commit25108684fe235d4296c3cbc480298df209682586 (patch)
tree59f051e13154764da2b98dfdc1ce66e363d801da /include/endian.h
parent254ffbc869c2376e77ecc298dfd396f077e9d58a (diff)
downloadsv-25108684fe235d4296c3cbc480298df209682586.tar.gz
build system and some other stuff
Diffstat (limited to 'include/endian.h')
-rw-r--r--include/endian.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/endian.h b/include/endian.h
new file mode 100644
index 0000000..79b4c93
--- /dev/null
+++ b/include/endian.h
@@ -0,0 +1,17 @@
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <stdint.h>
+
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+#define BYTE_ORDER __BYTE_ORDER__
+
+static inline uint32_t
+__bswap32(uint32_t x)
+{
+ uint8_t *p = (uint8_t*)&x;
+ return ((p[0] << 030) | (p[1] << 020) | (p[2] << 010) | p[3]);
+}
+
+#endif /* _ENDIAN_H */