[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Improve bswap portability
From: |
Schanzenbach, Martin |
Subject: |
Re: [PATCH] Improve bswap portability |
Date: |
Sun, 19 Sep 2021 16:07:45 +0000 |
Hi,
thanks for noticing.
bswap_* and the builtin __bswap_* are not the same.
The former is a function sometimes provided by the libc, see gnulib [1].
The builtin is provided by compilers (maybe only gcc actually).
I cannot find documentation, but it seems this is sometimes also called
__builtin_bswap*.
So the patch below does not really address the issue properly and my recent
patch should not be a relevant regression [2].
I do not know where __bswap_* comes from, but the commit did not really
introduce that.
I invite you to open a bug report for detailed discussions on android/bionic.
My assumption is that a suitable function needs to be detected in configure.
BR
[1] https://www.gnu.org/software/gnulib/manual/html_node/bswap_005f32.html
[2]
https://git.gnunet.org/gnunet.git/commit/?id=3ae831780b5681764a7d0505fa94f3fdaa43e1d8
> On 19. Sep 2021, at 10:34, Malte Voos <malte@malvo.org> wrote:
>
> The official function names are bswap_*, not __bswap_*. The latter won't
> compile with Android's bionic libc.
> ---
> src/include/gnunet_common.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
> index ca3ddceaa..b09fef93f 100644
> --- a/src/include/gnunet_common.h
> +++ b/src/include/gnunet_common.h
> @@ -152,9 +152,9 @@ enum GNUNET_GenericReturnValue
>
> #if __BYTE_ORDER == __LITTLE_ENDIAN
> #if defined(__linux__)
> -#define BYTE_SWAP_16(x) __bswap_16 (x)
> -#define BYTE_SWAP_32(x) __bswap_32 (x)
> -#define BYTE_SWAP_64(x) __bswap_64 (x)
> +#define BYTE_SWAP_16(x) bswap_16 (x)
> +#define BYTE_SWAP_32(x) bswap_32 (x)
> +#define BYTE_SWAP_64(x) bswap_64 (x)
> #else
> #define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8))
>
> --
> 2.32.0
>
>