blob: f5d9d2ef8b38b844a4a5652e022a7b9b303267d8 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#ifndef COMMON_H
2#define COMMON_H
3
4#include <libelf.h>
5#include <elf.h>
6
7#define unlikely(expr) __builtin_expect (expr, 0)
8#define likely(expr) __builtin_expect (expr, 1)
9
10#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
11
12static inline int is_host_little(void)
13{
14 short val = 0x10;
15 return ((char *)&val)[0] != 0;
16}
17
18static inline long switch_endianness(long val)
19{
20 long newval;
21 ((char *)&newval)[3] = ((char *)&val)[0];
22 ((char *)&newval)[2] = ((char *)&val)[1];
23 ((char *)&newval)[1] = ((char *)&val)[2];
24 ((char *)&newval)[0] = ((char *)&val)[3];
25 return newval;
26}
27
28#endif/*COMMON_H*/