summaryrefslogtreecommitdiffstats
path: root/tools/isprelinked/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/isprelinked/common.h')
-rw-r--r--tools/isprelinked/common.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/isprelinked/common.h b/tools/isprelinked/common.h
new file mode 100644
index 0000000..f5d9d2e
--- /dev/null
+++ b/tools/isprelinked/common.h
@@ -0,0 +1,28 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <libelf.h>
+#include <elf.h>
+
+#define unlikely(expr) __builtin_expect (expr, 0)
+#define likely(expr) __builtin_expect (expr, 1)
+
+#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
+
+static inline int is_host_little(void)
+{
+ short val = 0x10;
+ return ((char *)&val)[0] != 0;
+}
+
+static inline long switch_endianness(long val)
+{
+ long newval;
+ ((char *)&newval)[3] = ((char *)&val)[0];
+ ((char *)&newval)[2] = ((char *)&val)[1];
+ ((char *)&newval)[1] = ((char *)&val)[2];
+ ((char *)&newval)[0] = ((char *)&val)[3];
+ return newval;
+}
+
+#endif/*COMMON_H*/