8 #include <machine/endian.h> 22 #define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1])) 23 #define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])) 24 #define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift) 25 #define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \ 26 be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7]))) 27 #define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) 28 #define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0])) 29 #define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift) 30 #define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \ 31 le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0]))) 33 #define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x) 34 #define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \ 35 (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x) 36 #define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \ 37 (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \ 38 (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \ 39 (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x) 40 #define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) 41 #define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \ 42 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) 43 #define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \ 44 (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \ 45 (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \ 46 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)