From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.insanity.kuhnchris.eu (insanity.kuhnchris.eu [37.59.36.123]) by passt.top (Postfix) with ESMTPS id 87E585A0268 for ; Fri, 3 Mar 2023 23:49:40 +0100 (CET) From: KuhnChris DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kuhnchris.eu; s=mail; t=1677883781; bh=N/zxLpZfa0vzCqVo1UwLK5wRFUcHciH2DEmWvr09zig=; h=From:To:Cc:Subject:In-Reply-To:References; b=HFlRpV4rMvUf7M4a2tM9iVEQhI8+4I9DTfGQDII4s/shGirbHJhJYFx77fUDe2k9n K67l/MxWC4lD7wW44/6QlLNXsyly0LOY+oH7mkNqdGUHFu6Gis7Wug+DKVTaxTZ8fC JU2Hpd560CG2JctLYWDqclYlbHAGUxA5w86r469SwW7obwl/CeajKjfNQsejzGogKk Jb+HCzugRZRNqzNEond9WLiSxVPIdyif4EZ1yMK/qSWIWyGDLKDG6LlGsUELzAchAl EyWk4VO7g8Cj0aof21LwobJciIVDpg/ZVX2FZMDJBAUFoZ1xFHDSzeHReYlyg2l22Y n7NgbjsSZfu0g== To: passt-dev@passt.top Subject: [PATCH 3/3] define _bswap_constant_16/32 for musl This uses the implementation from libiio (https://github.com/analogdevicesinc/libiio/commit/9c6c6a432a0cbe2832bc97a7eeddfb61f6b8b856) Also restored the old behavior from the old util.h. Date: Fri, 3 Mar 2023 22:49:31 +0000 Message-Id: <20230303224931.11791-3-kuhnchris+github@kuhnchris.eu> In-Reply-To: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> References: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: kuhnchris+github@kuhnchris.eu X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: HTJBOHBU25YMX7MCINKIPHVY6JFD2CO6 X-Message-ID-Hash: HTJBOHBU25YMX7MCINKIPHVY6JFD2CO6 X-Mailman-Approved-At: Sat, 04 Mar 2023 09:52:28 +0100 CC: KuhnChris 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: --- util.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/util.h b/util.h index 7315ce2..a6ad4ad 100644 --- a/util.h +++ b/util.h @@ -91,7 +91,16 @@ #define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 }) #define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN)) -#if defined(__GLIBC__) || defined(__UCLIBC__) +#ifndef __bswap_constant_16 +#define __bswap_constant_16(x) \ + ((unsigned short int) ((((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) @@ -101,14 +110,6 @@ #define htonl_constant(x) (__bswap_constant_32(x)) #endif -#else - -/* mainly musl fallback */ - -#define htons_constant(x) (x) -#define htonl_constant(x) (x) - -#endif #define IN4_IS_ADDR_UNSPECIFIED(a) \ ((a)->s_addr == htonl(INADDR_ANY)) -- 2.38.4