qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] qemu/bswap: Remove <byteswap.h> dependency


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 4/4] qemu/bswap: Remove <byteswap.h> dependency
Date: Fri, 25 Sep 2020 11:22:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 9/24/20 9:33 PM, Peter Maydell wrote:
> On Thu, 24 Sep 2020 at 20:30, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> On 9/23/20 3:30 AM, Philippe Mathieu-Daudé wrote:
>>> On 9/23/20 12:16 PM, Peter Maydell wrote:
>>>> I suppose if we wanted to just use the __builtin_bswap*
>>>> implementation on all hosts (ie drop the special casing
>>>> of CONFIG_MACHINE_BSWAP_H/FreeBSD/Haiku) we'd need to
>>>> rename our macros to avoid potential conflicts with the
>>>> versions in the system headers there in case they were
>>>> pulled in via some other path ?
>>>
>>> Yes, this is why I couldn't get ride of everything
>>>
>>> After reading Paolo's suggestion to use qatomic*, I
>>> am tempted to suggest qbswap* but I am still looking
>>> for better alternatives...
>>
>> Hum, maybe.  It's pretty ugly.  We could just leave those alone and hope the
>> system version is decent enough.
> 
> Mostly what I would like is to be able to be rid of the
> configure machinery so we could just use a single
> portable implementation.

Good news. Using the Haiku image provided by Alexander,
GCC is pretty recent and supports builtin atomic:

> uname -a
Haiku shredder 1 hrev54154+115 Jun 30 2020 15:20 x86_64 x86_64 Haiku
> gcc --version
gcc (2019_05_24) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.

The <endian.h> include (/system/develop/headers/posix/endian.h)
only defines BYTE_ORDER.

Looking at FreeBSD, bswap*() are defined as macro:
https://github.com/freebsd/freebsd/blob/master/sys/sys/endian.h#L58
So we could eventually undefine them... but the manpage
describe them as functions [*]:

DESCRIPTION
    The bswap16(), bswap32(), and bswap64() functions return
    a byte order swapped integer.

So theoretically they could change the prototype still respecting
the documentation contract, and undefines wouldn't work anymore.

Would this be acceptable? Any clever idea?

[*] https://www.freebsd.org/cgi/man.cgi?query=bswap32&apropos=0&sektion=9

> 
> thanks
> -- PMM
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]