summaryrefslogtreecommitdiff
path: root/src/apk_defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/apk_defines.h')
-rw-r--r--src/apk_defines.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 5373725..00e9ea8 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -149,6 +149,16 @@ static inline size_t mulmod(size_t a, size_t b, size_t c)
return (size_t) tmp;
}
+static inline uint32_t get_unaligned32(const void *ptr)
+{
+#if defined(__x86_64__) || defined(__i386__)
+ return *(const uint32_t *)ptr;
+#else
+ const uint8_t *p = ptr;
+ return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
+#endif
+}
+
typedef void (*apk_progress_cb)(void *cb_ctx, size_t);
void *apk_array_resize(void *array, size_t new_size, size_t elem_size);