12 for (uint64_t i
= 0; i
< (~UINT64_C (0)) >> 2; i
= (i
<< 1) + 3)
14 if (i
< UINT64_C (65536))
16 if (htobe16 (be16toh (i
)) != i
)
18 printf ("htobe16 (be16toh (%" PRIx64
")) == %" PRIx16
"\n",
19 i
, (uint16_t) htobe16 (be16toh (i
)));
22 if (htole16 (le16toh (i
)) != i
)
24 printf ("htole16 (le16toh (%" PRIx64
")) == %" PRIx16
"\n",
25 i
, (uint16_t) htole16 (le16toh (i
)));
30 n
[__BYTE_ORDER
== __LITTLE_ENDIAN
] = bswap_16 (i
);
31 n
[__BYTE_ORDER
== __BIG_ENDIAN
] = i
;
32 if (htole16 (i
) != n
[0])
34 printf ("htole16 (%" PRIx64
") == %" PRIx16
" != %" PRIx16
"\n",
35 i
, (uint16_t) htole16 (i
), n
[0]);
38 if (htobe16 (i
) != n
[1])
40 printf ("htobe16 (%" PRIx64
") == %" PRIx16
" != %" PRIx16
"\n",
41 i
, (uint16_t) htobe16 (i
), n
[1]);
46 if (i
< UINT64_C (4294967296))
48 if (htobe32 (be32toh (i
)) != i
)
50 printf ("htobe32 (be32toh (%" PRIx64
")) == %" PRIx32
"\n",
51 i
, (uint32_t) htobe32 (be32toh (i
)));
54 if (htole32 (le32toh (i
)) != i
)
56 printf ("htole32 (le32toh (%" PRIx64
")) == %" PRIx32
"\n",
57 i
, (uint32_t) htole32 (le32toh (i
)));
62 n
[__BYTE_ORDER
== __LITTLE_ENDIAN
] = bswap_32 (i
);
63 n
[__BYTE_ORDER
== __BIG_ENDIAN
] = i
;
64 if (htole32 (i
) != n
[0])
66 printf ("htole32 (%" PRIx64
") == %" PRIx32
" != %" PRIx32
"\n",
67 i
, (uint32_t) htole32 (i
), n
[0]);
70 if (htobe32 (i
) != n
[1])
72 printf ("htobe32 (%" PRIx64
") == %" PRIx32
" != %" PRIx32
"\n",
73 i
, (uint32_t) htobe32 (i
), n
[1]);
78 if (htobe64 (be64toh (i
)) != i
)
80 printf ("htobe64 (be64toh (%" PRIx64
")) == %" PRIx64
"\n",
81 i
, htobe64 (be64toh (i
)));
84 if (htole64 (le64toh (i
)) != i
)
86 printf ("htole64 (le64toh (%" PRIx64
")) == %" PRIx64
"\n",
87 i
, htole64 (le64toh (i
)));
92 n
[__BYTE_ORDER
== __LITTLE_ENDIAN
] = bswap_64 (i
);
93 n
[__BYTE_ORDER
== __BIG_ENDIAN
] = i
;
94 if (htole64 (i
) != n
[0])
96 printf ("htole64 (%" PRIx64
") == %" PRIx64
" != %" PRIx64
"\n",
97 i
, htole64 (i
), n
[0]);
100 if (htobe64 (i
) != n
[1])
102 printf ("htobe64 (%" PRIx64
") == %" PRIx64
" != %" PRIx64
"\n",
103 i
, htobe64 (i
), n
[1]);
111 #define TEST_FUNCTION do_test ()
112 #include "../test-skeleton.c"