fix missing dlfcn.h include
[rofl0r-df-libgraphics.git] / g_src / endian.h
blobb56dee4a1c3226d13974608c6dfb0c68ae1930dc
1 #ifndef ENDIAN_H
2 #define ENDIAN_H
4 inline unsigned short byteswap(unsigned short x)
6 #if defined(__ppc__) || defined(__ppc64__)
7 return (x << 8 | x >> 8);
8 #else
9 return x;
10 #endif
13 inline unsigned long byteswap(unsigned long x)
15 #if defined(__ppc__) || defined(__ppc64__)
16 return
17 ( (x << 24) & 0xFF000000) |
18 ( (x << 8) & 0x00FF0000) |
19 ( (x >> 8) & 0x0000FF00) |
20 ( (x >> 24) & 0x000000FF) ;
21 #else
22 return x;
23 #endif
26 inline unsigned int byteswap(unsigned int x)
28 #if defined(__ppc__) || defined(__ppc64__)
29 return
30 ( (x << 24) & 0xFF000000) |
31 ( (x << 8) & 0x00FF0000) |
32 ( (x >> 8) & 0x0000FF00) |
33 ( (x >> 24) & 0x000000FF) ;
34 #else
35 return x;
36 #endif
39 inline short byteswap(short x) { return byteswap( (unsigned short) x ); }
40 inline long byteswap(long x) { return byteswap( (unsigned long) x ); }
41 inline int byteswap(int x) { return byteswap( (unsigned int) x ); }
42 #endif