aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-03-08 04:13:50 +0100
committerStefano Brivio <sbrivio@redhat.com>2023-03-09 03:44:21 +0100
commit50687616e4a99eabb2f22de8651817746c0abda1 (patch)
tree170ed3f9ada1cac96d9de6ebdbde2e91f8323a66
parent89e38f55405d00ca00ec64936531d8db18954a95 (diff)
downloadpasst-50687616e4a99eabb2f22de8651817746c0abda1.tar
passt-50687616e4a99eabb2f22de8651817746c0abda1.tar.gz
passt-50687616e4a99eabb2f22de8651817746c0abda1.tar.bz2
passt-50687616e4a99eabb2f22de8651817746c0abda1.tar.lz
passt-50687616e4a99eabb2f22de8651817746c0abda1.tar.xz
passt-50687616e4a99eabb2f22de8651817746c0abda1.tar.zst
passt-50687616e4a99eabb2f22de8651817746c0abda1.zip
util: Carry own definition of __bswap_constant{16,32}
musl doesn't define those, use our own definition there. This is a trivial implementation, similar to what's shipped by e.g. uClibc, glibc, libiio. Reported-by: Chris Kuhn <kuhnchris+github@kuhnchris.eu> Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/util.h b/util.h
index 570094c..8367f51 100644
--- a/util.h
+++ b/util.h
@@ -88,6 +88,17 @@
#define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 })
#define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN))
+#ifndef __bswap_constant_16
+#define __bswap_constant_16(x) \
+ ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
+#endif
+
+#ifndef __bswap_constant_32
+#define __bswap_constant_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+#endif
+
#if __BYTE_ORDER == __BIG_ENDIAN
#define htons_constant(x) (x)
#define htonl_constant(x) (x)