public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Chris Kuhn <kuhnchris+passt@kuhnchris.eu>,
	lemmi <lemmi@nerd2nerd.org>
Subject: Re: [PATCH 4/4] util: Carry own definition of __bswap_constant{16,32}
Date: Thu, 9 Mar 2023 09:11:43 +1100	[thread overview]
Message-ID: <ZAkIH2XkV0/6BlVm@yekko> (raw)
In-Reply-To: <20230308073516.2189680-5-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

On Wed, Mar 08, 2023 at 08:35:16AM +0100, Stefano Brivio wrote:
> 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>

> ---
>  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)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2023-03-08 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08  7:35 [PATCH 0/4] Fix build against musl C library Stefano Brivio
2023-03-08  7:35 ` [PATCH 1/4] netlink: Use 8 KiB * netlink message header size as response buffer Stefano Brivio
2023-03-08 22:06   ` David Gibson
2023-03-08  7:35 ` [PATCH 2/4] conf, passt: Rename stderr to force_stderr Stefano Brivio
2023-03-08 22:10   ` David Gibson
2023-03-08  7:35 ` [PATCH 3/4] treewide: Fix header includes to build with musl Stefano Brivio
2023-03-08 22:11   ` David Gibson
2023-03-08  7:35 ` [PATCH 4/4] util: Carry own definition of __bswap_constant{16,32} Stefano Brivio
2023-03-08 22:11   ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAkIH2XkV0/6BlVm@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=kuhnchris+passt@kuhnchris.eu \
    --cc=lemmi@nerd2nerd.org \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).