[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v4] compiler.h: remove GCC < 3 __builtin_expect fallback
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [RFC PATCH v4] compiler.h: remove GCC < 3 __builtin_expect fallback |
Date: |
Fri, 11 Dec 2020 14:35:08 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
On 12/11/20 2:28 PM, Claudio Fontana wrote:
> On 12/11/20 2:13 PM, Philippe Mathieu-Daudé wrote:
>> Since commit efc6c07 ("configure: Add a test for the minimum compiler
>> version"), QEMU explicitely depends on GCC >= 4.8.
>>
>> (clang >= 3.4 advertizes itself as GCC >= 4.2 compatible and supports
>> __builtin_expect too)
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> [PMD: #error if likely/unlikely already defined]
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> Supersedes: <20201210134752.780923-4-marcandre.lureau@redhat.com>
>> ---
>> include/qemu/compiler.h | 7 ++-----
>> 1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
>> index c76281f3540..ae1aee79c8d 100644
>> --- a/include/qemu/compiler.h
>> +++ b/include/qemu/compiler.h
>> @@ -43,14 +43,11 @@
>> #define tostring(s) #s
>> #endif
>>
>> -#ifndef likely
>> -#if __GNUC__ < 3
>> -#define __builtin_expect(x, n) (x)
>> +#if defined(likely) || defined(unlikely)
>> +#error building with likely/unlikely is not supported
>
> I'd put the argument of #error as a single string constant delimited by
> quotes ",
> doesn't matter in this case though as there are no problem characters in the
> string.
This is the style I prefer too, but I this seems the QEMU style...:
$ git grep -E \#\s*error|wc -l
82
$ git grep -E \#\s*error|fgrep \"|wc -l
11
>
>> #endif
>> -
>> #define likely(x) __builtin_expect(!!(x), 1)
>> #define unlikely(x) __builtin_expect(!!(x), 0)
>> -#endif
>>
>> #ifndef container_of
>> #define container_of(ptr, type, member) ({ \
>>
>
> Reviewed-by: Claudio Fontana <cfontana@suse.de>
>