summaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index fe6720b..3acc42f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -32,6 +32,18 @@
#pragma once
+
+#include <sys/types.h>
+
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
+
/**
Returns a pointer to a data structure, given the address of a member contained in the structure
@@ -91,3 +103,14 @@ static inline size_t max_size_t(size_t a, size_t b) {
static inline size_t min_size_t(size_t a, size_t b) {
return (a < b) ? a : b;
}
+
+
+#ifndef HAVE_LINUX_ENDIAN
+
+/** converts a 32bit integer from big endian to host byte order */
+#define be32toh(x) betoh32(x)
+
+/** converts a 32bit integer from little endian to host byte order */
+#define le32toh(x) letoh32(x)
+
+#endif