The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame^] | 1 | #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 | |
| 12 | static inline int is_host_little(void) |
| 13 | { |
| 14 | short val = 0x10; |
| 15 | return ((char *)&val)[0] != 0; |
| 16 | } |
| 17 | |
| 18 | static 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*/ |