network: use official bswap_32() rather than inofficial __bswap_32()

The former is a macro for the latter, but let's use the official API
(the one that has an API).
This commit is contained in:
Lennart Poettering
2021-10-11 14:10:07 +02:00
parent 899c1c0a34
commit fe92eb795b
3 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -55,9 +55,9 @@ typedef uint64_t __sd_bitwise be64_t;
#undef le64toh
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define bswap_16_on_le(x) __bswap_16(x)
#define bswap_32_on_le(x) __bswap_32(x)
#define bswap_64_on_le(x) __bswap_64(x)
#define bswap_16_on_le(x) bswap_16(x)
#define bswap_32_on_le(x) bswap_32(x)
#define bswap_64_on_le(x) bswap_64(x)
#define bswap_16_on_be(x) (x)
#define bswap_32_on_be(x) (x)
#define bswap_64_on_be(x) (x)
@@ -65,9 +65,9 @@ typedef uint64_t __sd_bitwise be64_t;
#define bswap_16_on_le(x) (x)
#define bswap_32_on_le(x) (x)
#define bswap_64_on_le(x) (x)
#define bswap_16_on_be(x) __bswap_16(x)
#define bswap_32_on_be(x) __bswap_32(x)
#define bswap_64_on_be(x) __bswap_64(x)
#define bswap_16_on_be(x) bswap_16(x)
#define bswap_32_on_be(x) bswap_32(x)
#define bswap_64_on_be(x) bswap_64(x)
#endif
static inline le16_t htole16(uint16_t value) { return (le16_t __sd_force) bswap_16_on_be(value); }
+1 -1
View File
@@ -207,7 +207,7 @@ int dhcp_identifier_set_iaid(
if (legacy_unstable_byteorder)
/* for historical reasons (a bug), the bits were swapped and thus
* the result was endianness dependent. Preserve that behavior. */
id32 = __bswap_32(id32);
id32 = bswap_32(id32);
else
/* the fixed behavior returns a stable byte order. Since LE is expected
* to be more common, swap the bytes on LE to give the same as legacy
+1 -1
View File
@@ -158,7 +158,7 @@ static void test_dhcp_identifier_set_iaid(void) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
assert_se(iaid == iaid_legacy);
#else
assert_se(iaid == __bswap_32(iaid_legacy));
assert_se(iaid == bswap_32(iaid_legacy));
#endif
}