You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
785 B

/************************************************************************/
/* <EFBFBD>ֽ<EFBFBD>˳<EFBFBD>򽻻<EFBFBD> */
/************************************************************************/
#ifndef __BSWAP_H__
#define __BSWAP_H__
/* 16bit<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>˳<EFBFBD>򽻻<EFBFBD> */
static inline uint16_t bswap_16(uint16_t x)
{
return (x >> 8) | (x << 8);
}
/* 32bit<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>˳<EFBFBD>򽻻<EFBFBD> */
static inline uint32_t bswap_32(uint32_t x)
{
x = ((x << 8) &0xFF00FF00) | ((x >> 8) &0x00FF00FF);
return (x >> 16) | (x << 16);
}
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#endif