mirror of
https://github.com/siemens-mobile-hacks/siemens-process-library.git
synced 2026-11-25 23:57:42 +00:00
18 lines
469 B
C
Executable file
18 lines
469 B
C
Executable file
#ifndef _BYTESWAP_H
|
|
#define _BYTESWAP_H
|
|
|
|
//#warning "byteswap.h is an unportable GNU extension! Don't use!"
|
|
|
|
static inline unsigned short bswap_16(unsigned short x) {
|
|
return (x>>8) | (x<<8);
|
|
}
|
|
|
|
static inline unsigned int bswap_32(unsigned int x) {
|
|
return (bswap_16(x&0xffff)<<16) | (bswap_16(x>>16));
|
|
}
|
|
|
|
static inline unsigned long long bswap_64(unsigned long long x) {
|
|
return (((unsigned long long)bswap_32(x&0xffffffffull))<<32) | (bswap_32(x>>32));
|
|
}
|
|
|
|
#endif
|