public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: KuhnChris <kuhnchris+github@kuhnchris.eu>
Cc: passt-dev@passt.top
Subject: Re: [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: Sat, 4 Mar 2023 10:55:50 +0100	[thread overview]
Message-ID: <20230304105550.0eb99f2d@elisabeth> (raw)
In-Reply-To: <20230303224931.11791-3-kuhnchris+github@kuhnchris.eu>

On Fri,  3 Mar 2023 22:49:31 +0000
KuhnChris <kuhnchris+github@kuhnchris.eu> wrote:

> ---
>  util.h | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)

Here, what you wrote in the subject (first line of commit message)
should be in the commit message itself. Example of commit message for
this:

--
util: Provide own __bswap_constant_{16,32} if not defined by C library

musl, and possibly other C libraries, don't define __bswap_constant_16
and __bswap_constant_32. Define them if they aren't.

Signed-off-by: Name Surname <email address>
--

The first line becomes the patch subject. Here, there would be no
strict need to mention libiio because that's just one example of the
same trivial implementation copied over and over again in many
projects, which might come from pretty much anywhere.

Wwas it copied from glibc? Was it written by the author of that
commit? I don't think it qualifies as copyrightable work:

  https://en.wikipedia.org/wiki/Threshold_of_originality

...but you can also do that, as you have the link at hand, if you
actually took it from there.

> 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

And this, again, shouldn't be in the first patch.

>  
>  #define IN4_IS_ADDR_UNSPECIFIED(a) \
>  	((a)->s_addr == htonl(INADDR_ANY))

I understand this might be a lot to digest and a bit of effort, so let
me know -- you figured out most of the issues and did all the tests, I
can also fix up the patches for you.

-- 
Stefano


  reply	other threads:[~2023-03-04  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 22:49 [PATCH 1/3] musl adaptations KuhnChris
2023-03-03 22:49 ` [PATCH 2/3] sbrivio/manual buffer size due to musl being 1024 KuhnChris
2023-03-04  9:54   ` Stefano Brivio
2023-03-03 22:49 ` [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 KuhnChris
2023-03-04  9:55   ` Stefano Brivio [this message]
2023-03-04  9:54 ` [PATCH 1/3] musl adaptations Stefano Brivio

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=20230304105550.0eb99f2d@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=kuhnchris+github@kuhnchris.eu \
    --cc=passt-dev@passt.top \
    /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).