aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
diff options
context:
space:
mode:
authorGravatar Frank Denis <github@pureftpd.org>2017-12-30 03:29:35 +0100
committerGravatar Frank Denis <github@pureftpd.org>2017-12-30 03:29:35 +0100
commitccb5ff9bb3a75d6ceac19e193eac447f7e84de79 (patch)
tree6ca666ad8a1916dfcf0a016ec06ff43fb3f5c42a /src/common.h
parentf1e3970b52886c2e784d9d6a247788924eec6941 (diff)
downloadtweetpipe-ccb5ff9bb3a75d6ceac19e193eac447f7e84de79.tar.gz
Move things to src/
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h
new file mode 100644
index 0000000..8181c42
--- /dev/null
+++ b/src/common.h
@@ -0,0 +1,28 @@
+#ifndef common_H
+#define common_H 1
+
+#define LOAD32_LE(SRC) load32_le(SRC)
+static inline uint32_t
+load32_le(const uint8_t src[4])
+{
+ uint32_t w = (uint32_t) src[0];
+ w |= (uint32_t) src[1] << 8;
+ w |= (uint32_t) src[2] << 16;
+ w |= (uint32_t) src[3] << 24;
+ return w;
+}
+
+#define STORE32_LE(DST, W) store32_le((DST), (W))
+static inline void
+store32_le(uint8_t dst[4], uint32_t w)
+{
+ dst[0] = (uint8_t) w;
+ w >>= 8;
+ dst[1] = (uint8_t) w;
+ w >>= 8;
+ dst[2] = (uint8_t) w;
+ w >>= 8;
+ dst[3] = (uint8_t) w;
+}
+
+#endif