1570af302Sopenharmony_ci#ifndef _BYTESWAP_H 2570af302Sopenharmony_ci#define _BYTESWAP_H 3570af302Sopenharmony_ci 4570af302Sopenharmony_ci#include <features.h> 5570af302Sopenharmony_ci#include <stdint.h> 6570af302Sopenharmony_ci 7570af302Sopenharmony_cistatic __inline uint16_t __bswap_16(uint16_t __x) 8570af302Sopenharmony_ci{ 9570af302Sopenharmony_ci return __x<<8 | __x>>8; 10570af302Sopenharmony_ci} 11570af302Sopenharmony_ci 12570af302Sopenharmony_cistatic __inline uint32_t __bswap_32(uint32_t __x) 13570af302Sopenharmony_ci{ 14570af302Sopenharmony_ci return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; 15570af302Sopenharmony_ci} 16570af302Sopenharmony_ci 17570af302Sopenharmony_cistatic __inline uint64_t __bswap_64(uint64_t __x) 18570af302Sopenharmony_ci{ 19570af302Sopenharmony_ci return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32); 20570af302Sopenharmony_ci} 21570af302Sopenharmony_ci 22570af302Sopenharmony_ci#define bswap_16(x) __bswap_16(x) 23570af302Sopenharmony_ci#define bswap_32(x) __bswap_32(x) 24570af302Sopenharmony_ci#define bswap_64(x) __bswap_64(x) 25570af302Sopenharmony_ci 26570af302Sopenharmony_ci#endif 27