11 #define swap16(x) ntohs(x) 12 #define swap32(x) ntohl(x) 14 #define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \ 15 ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \ 16 ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \ 17 ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \ 18 ((x) >> 8) & 0x00000000ff000000ULL | \ 19 ((x) >> 24) & 0x0000000000ff0000ULL | \ 20 ((x) >> 40) & 0x000000000000ff00ULL | \ 21 ((x) >> 56) & 0x00000000000000ffULL)) 40 # define htobe16(x) htons(x) 43 # define htobe32(x) htonl(x) 46 # define be16toh(x) ntohs(x) 49 # define be32toh(x) ntohl(x) 52 #define HTOBE16(x) (x) = htobe16(x) 53 #define HTOBE32(x) (x) = htobe32(x) 54 #define BE32TOH(x) (x) = be32toh(x) 55 #define BE16TOH(x) (x) = be16toh(x) 59 # define htole16(x) (x) 62 # define htole32(x) (x) 65 # define htole64(x) (x) 68 # define le16toh(x) (x) 71 # define le32toh(x) (x) 74 # define le64toh(x) (x) 77 #define HTOLE16(x) (void) (x) 78 #define HTOLE32(x) (void) (x) 79 #define HTOLE64(x) (void) (x) 80 #define LE16TOH(x) (void) (x) 81 #define LE32TOH(x) (void) (x) 82 #define LE64TOH(x) (void) (x) 86 # define htobe64(x) swap64(x) 89 # define be64toh(x) swap64(x) 92 #define HTOBE64(x) (x) = htobe64(x) 93 #define BE64TOH(x) (x) = be64toh(x) 105 #define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1])) 106 #define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])) 107 #define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift) 108 #define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \ 109 be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7]))) 110 #define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) 111 #define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0])) 112 #define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift) 113 #define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \ 114 le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0]))) 116 #define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x) 117 #define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \ 118 (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x) 119 #define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \ 120 (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \ 121 (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \ 122 (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x) 123 #define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) 124 #define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \ 125 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) 126 #define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \ 127 (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \ 128 (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \ 129 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)