]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/generic/defines/byteswap.h
Merge branch 'master' into can-usb1
[lincan.git] / embedded / arch / generic / defines / byteswap.h
1 #ifndef _BYTESWAP_H
2 #define _BYTESWAP_H     1
3
4 #if defined(__KEIL__)
5 #define __bswap_16(x) ( (((x) << 8) & 0xFF00) | (((x) >> 8) & 0x00FF) )
6 #else
7 #define __bswap_16(x) ({unsigned short __x=(x); \
8                         (((__x>>8)&0xff)|((__x&0xff)<<8)); })
9 #endif
10
11 #if defined(__KEIL__)
12     //todo
13 #else
14 #define __bswap_32(x) ({unsigned long __y=(x); \
15                         (__bswap_16(__y>>16)|__bswap_16(__y)<<16); })
16 #endif
17
18 #define bswap_16(x) __bswap_16 (x)
19
20 #define bswap_32(x) __bswap_32 (x)
21
22 #endif /* byteswap.h */