From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 504445A0271; Wed, 8 Mar 2023 08:35:16 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 4/4] util: Carry own definition of __bswap_constant{16,32} Date: Wed, 8 Mar 2023 08:35:16 +0100 Message-Id: <20230308073516.2189680-5-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308073516.2189680-1-sbrivio@redhat.com> References: <20230308073516.2189680-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: KS4E2VYCX4M6D25VRVVMPJHLUGTY6QG7 X-Message-ID-Hash: KS4E2VYCX4M6D25VRVVMPJHLUGTY6QG7 X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Chris Kuhn , lemmi X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Stefano Brivio --- util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- 2.39.2