|
20 | 20 | #define htobe16(x) __builtin_bswap16((x)) |
21 | 21 | #define htobe32(x) __builtin_bswap32((x)) |
22 | 22 | #define htobe64(x) __builtin_bswap64((x)) |
23 | | -#define htole16(x) ((uint16_t)(x)) |
24 | | -#define htole32(x) ((uint32_t)(x)) |
25 | | -#define htole64(x) ((uint64_t)(x)) |
| 23 | +#define htole16(x) __LLVM_LIBC_CAST(static_cast, uint16_t, x) |
| 24 | +#define htole32(x) __LLVM_LIBC_CAST(static_cast, uint32_t, x) |
| 25 | +#define htole64(x) __LLVM_LIBC_CAST(static_cast, uint64_t, x) |
26 | 26 | #define be16toh(x) __builtin_bswap16((x)) |
27 | 27 | #define be32toh(x) __builtin_bswap32((x)) |
28 | 28 | #define be64toh(x) __builtin_bswap64((x)) |
29 | | -#define le16toh(x) ((uint16_t)(x)) |
30 | | -#define le32toh(x) ((uint32_t)(x)) |
31 | | -#define le64toh(x) ((uint64_t)(x)) |
| 29 | +#define le16toh(x) __LLVM_LIBC_CAST(static_cast, uint16_t, x) |
| 30 | +#define le32toh(x) __LLVM_LIBC_CAST(static_cast, uint32_t, x) |
| 31 | +#define le64toh(x) __LLVM_LIBC_CAST(static_cast, uint64_t, x) |
32 | 32 |
|
33 | 33 | #else |
34 | 34 |
|
35 | | -#define htobe16(x) ((uint16_t)(x)) |
36 | | -#define htobe32(x) ((uint32_t)(x)) |
37 | | -#define htobe64(x) ((uint64_t)(x)) |
| 35 | +#define htobe16(x) __LLVM_LIBC_CAST(static_cast, uint16_t, x) |
| 36 | +#define htobe32(x) __LLVM_LIBC_CAST(static_cast, uint32_t, x) |
| 37 | +#define htobe64(x) __LLVM_LIBC_CAST(static_cast, uint64_t, x) |
38 | 38 | #define htole16(x) __builtin_bswap16((x)) |
39 | 39 | #define htole32(x) __builtin_bswap32((x)) |
40 | 40 | #define htole64(x) __builtin_bswap64((x)) |
41 | | -#define be16toh(x) ((uint16_t)(x)) |
42 | | -#define be32toh(x) ((uint32_t)(x)) |
43 | | -#define be64toh(x) ((uint64_t)(x)) |
| 41 | +#define be16toh(x) __LLVM_LIBC_CAST(static_cast, uint16_t, x) |
| 42 | +#define be32toh(x) __LLVM_LIBC_CAST(static_cast, uint32_t, x) |
| 43 | +#define be64toh(x) __LLVM_LIBC_CAST(static_cast, uint64_t, x) |
44 | 44 | #define le16toh(x) __builtin_bswap16((x)) |
45 | 45 | #define le32toh(x) __builtin_bswap32((x)) |
46 | 46 | #define le64toh(x) __builtin_bswap64((x)) |
|
0 commit comments