Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1

Message ID 1485879287-12548-1-git-send-email-peter.maydell@linaro.org
State Accepted
Commit fa54abb8c298f892639ffc4bc2f61448ac3be4a1
Headers show

Commit Message

Peter Maydell Jan. 31, 2017, 4:14 p.m.
We already require gcc 4.1 or newer (for the atomic
support), so the fallback codepaths for older gcc
versions than that are now dead code and we can
just delete them.

NB: clang reports itself as gcc 4.2 (regardless of
clang version), so clang won't be using the fallbacks
either.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
For compatibility with clang we should probably try to avoid
using QEMU_GNUC_PREREQ() and instead have something in
compiler.h that abstracts away whether the test for "does
the compiler support feature foo" is via a GCC version
check or a clang __has_feature or whatever.


 include/qemu/compiler.h   |   8 ---
 include/qemu/host-utils.h | 121 ----------------------------------------------
 tcg/arm/tcg-target.h      |   7 ---
 3 files changed, 136 deletions(-)

-- 
2.7.4

Comments

Daniel P. Berrange Jan. 31, 2017, 4:55 p.m. | #1
On Tue, Jan 31, 2017 at 04:14:47PM +0000, Peter Maydell wrote:
> We already require gcc 4.1 or newer (for the atomic

> support), so the fallback codepaths for older gcc

> versions than that are now dead code and we can

> just delete them.


Do we have any explicit check alreadu for 4.1, or do we
just let the build fail on the atomic code ?

IOW, is there any use in having..

#if !QEMU_GNUC_PREREQ(4, 1)
# error "QEMU requires GCC >= 4.1 or CLang"
#endif

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
Peter Maydell Jan. 31, 2017, 4:58 p.m. | #2
On 31 January 2017 at 16:55, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Tue, Jan 31, 2017 at 04:14:47PM +0000, Peter Maydell wrote:

>> We already require gcc 4.1 or newer (for the atomic

>> support), so the fallback codepaths for older gcc

>> versions than that are now dead code and we can

>> just delete them.

>

> Do we have any explicit check alreadu for 4.1, or do we

> just let the build fail on the atomic code ?

>

> IOW, is there any use in having..

>

> #if !QEMU_GNUC_PREREQ(4, 1)

> # error "QEMU requires GCC >= 4.1 or CLang"

> #endif


I guess we just barf in the atomics. An explicit check might
not be a bad idea I guess, though it depends a bit on how
many releases we've been implicitly requiring 4.1 for. I
suppose it would act as documentation of our current
minimum req.

thanks
-- PMM
Markus Armbruster Jan. 31, 2017, 5:40 p.m. | #3
Peter Maydell <peter.maydell@linaro.org> writes:

> We already require gcc 4.1 or newer (for the atomic

> support), so the fallback codepaths for older gcc

> versions than that are now dead code and we can

> just delete them.

>

> NB: clang reports itself as gcc 4.2 (regardless of

> clang version), so clang won't be using the fallbacks

> either.

>

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

> For compatibility with clang we should probably try to avoid

> using QEMU_GNUC_PREREQ() and instead have something in

> compiler.h that abstracts away whether the test for "does

> the compiler support feature foo" is via a GCC version

> check or a clang __has_feature or whatever.


Yes, testing for feature is better than testing a version.

This patch reduces use of QEMU_GNUC_PREREQ roughly by half.  Good.

>

>

>  include/qemu/compiler.h   |   8 ---

>  include/qemu/host-utils.h | 121 ----------------------------------------------

>  tcg/arm/tcg-target.h      |   7 ---

>  3 files changed, 136 deletions(-)

>

> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h

> index 157698b..fc12e49 100644

> --- a/include/qemu/compiler.h

> +++ b/include/qemu/compiler.h

> @@ -24,17 +24,9 @@

>  

>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>  

> -#if QEMU_GNUC_PREREQ(3, 4)

>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

> -#else

> -#define QEMU_WARN_UNUSED_RESULT

> -#endif


Should we inline this macro?

>  

> -#if QEMU_GNUC_PREREQ(4, 0)

>  #define QEMU_SENTINEL __attribute__((sentinel))

> -#else

> -#define QEMU_SENTINEL

> -#endif


Likewise.

>  

>  #if QEMU_GNUC_PREREQ(4, 3)

>  #define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))

[Nothing to say on the rest...]

Regardless of my question:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Peter Maydell Jan. 31, 2017, 6 p.m. | #4
On 31 January 2017 at 17:40, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:

>

>> We already require gcc 4.1 or newer (for the atomic

>> support), so the fallback codepaths for older gcc

>> versions than that are now dead code and we can

>> just delete them.

>>

>> NB: clang reports itself as gcc 4.2 (regardless of

>> clang version), so clang won't be using the fallbacks

>> either.

>>

>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

>> ---

>> For compatibility with clang we should probably try to avoid

>> using QEMU_GNUC_PREREQ() and instead have something in

>> compiler.h that abstracts away whether the test for "does

>> the compiler support feature foo" is via a GCC version

>> check or a clang __has_feature or whatever.

>

> Yes, testing for feature is better than testing a version.

>

> This patch reduces use of QEMU_GNUC_PREREQ roughly by half.  Good.

>

>>

>>

>>  include/qemu/compiler.h   |   8 ---

>>  include/qemu/host-utils.h | 121 ----------------------------------------------

>>  tcg/arm/tcg-target.h      |   7 ---

>>  3 files changed, 136 deletions(-)

>>

>> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h

>> index 157698b..fc12e49 100644

>> --- a/include/qemu/compiler.h

>> +++ b/include/qemu/compiler.h

>> @@ -24,17 +24,9 @@

>>

>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>

>> -#if QEMU_GNUC_PREREQ(3, 4)

>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>> -#else

>> -#define QEMU_WARN_UNUSED_RESULT

>> -#endif

>

> Should we inline this macro?


We have attributes which we wrap in QEMU_ macros already
even though they always expand to the same thing:
QEMU_NORETURN and QEMU_ALIGNED. I'm happy to leave these
to follow that pattern. (If you wanted to send a patch
series that uninlined all of those then I wouldn't hugely
object to it, but I think it touches enough files that it's
a separate thing from removing the #if guards that this
patch does.)

thanks
-- PMM
Daniel P. Berrange Jan. 31, 2017, 6:11 p.m. | #5
On Tue, Jan 31, 2017 at 06:00:13PM +0000, Peter Maydell wrote:
> On 31 January 2017 at 17:40, Markus Armbruster <armbru@redhat.com> wrote:

> > Peter Maydell <peter.maydell@linaro.org> writes:

> >

> >> We already require gcc 4.1 or newer (for the atomic

> >> support), so the fallback codepaths for older gcc

> >> versions than that are now dead code and we can

> >> just delete them.

> >>

> >> NB: clang reports itself as gcc 4.2 (regardless of

> >> clang version), so clang won't be using the fallbacks

> >> either.

> >>

> >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> >> ---

> >> For compatibility with clang we should probably try to avoid

> >> using QEMU_GNUC_PREREQ() and instead have something in

> >> compiler.h that abstracts away whether the test for "does

> >> the compiler support feature foo" is via a GCC version

> >> check or a clang __has_feature or whatever.

> >

> > Yes, testing for feature is better than testing a version.

> >

> > This patch reduces use of QEMU_GNUC_PREREQ roughly by half.  Good.

> >

> >>

> >>

> >>  include/qemu/compiler.h   |   8 ---

> >>  include/qemu/host-utils.h | 121 ----------------------------------------------

> >>  tcg/arm/tcg-target.h      |   7 ---

> >>  3 files changed, 136 deletions(-)

> >>

> >> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h

> >> index 157698b..fc12e49 100644

> >> --- a/include/qemu/compiler.h

> >> +++ b/include/qemu/compiler.h

> >> @@ -24,17 +24,9 @@

> >>

> >>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

> >>

> >> -#if QEMU_GNUC_PREREQ(3, 4)

> >>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

> >> -#else

> >> -#define QEMU_WARN_UNUSED_RESULT

> >> -#endif

> >

> > Should we inline this macro?

> 

> We have attributes which we wrap in QEMU_ macros already

> even though they always expand to the same thing:

> QEMU_NORETURN and QEMU_ALIGNED. I'm happy to leave these

> to follow that pattern. (If you wanted to send a patch

> series that uninlined all of those then I wouldn't hugely

> object to it, but I think it touches enough files that it's

> a separate thing from removing the #if guards that this

> patch does.)


The other option is just to replace QEMU_WARN_UNUSED_RESULT with

  #define QEMU_WARN_UNUSED_RESULT  G_GNUC_WARN_UNUSED_RESULT

and convert code to use G_GNUC_WARN_UNUSED_RESULT directly until we
can kill the QEMU specific define. There's no benefit to QEMU having
its own defines that duplicate stuff already covered by our min
required glib - G_GNUC_WARN_UNUSED_RESULT was added in 2.10 for
example.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
Peter Maydell Jan. 31, 2017, 6:32 p.m. | #6
On 31 January 2017 at 18:11, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Tue, Jan 31, 2017 at 06:00:13PM +0000, Peter Maydell wrote:

>> We have attributes which we wrap in QEMU_ macros already

>> even though they always expand to the same thing:

>> QEMU_NORETURN and QEMU_ALIGNED. I'm happy to leave these

>> to follow that pattern. (If you wanted to send a patch

>> series that uninlined all of those then I wouldn't hugely

>> object to it, but I think it touches enough files that it's

>> a separate thing from removing the #if guards that this

>> patch does.)

>

> The other option is just to replace QEMU_WARN_UNUSED_RESULT with

>

>   #define QEMU_WARN_UNUSED_RESULT  G_GNUC_WARN_UNUSED_RESULT

>

> and convert code to use G_GNUC_WARN_UNUSED_RESULT directly until we

> can kill the QEMU specific define. There's no benefit to QEMU having

> its own defines that duplicate stuff already covered by our min

> required glib - G_GNUC_WARN_UNUSED_RESULT was added in 2.10 for

> example.


I wouldn't object to that either, but again it ought to be
a different patch or patch series to this one...

thanks
-- PMM
Markus Armbruster Jan. 31, 2017, 6:58 p.m. | #7
Peter Maydell <peter.maydell@linaro.org> writes:

> On 31 January 2017 at 17:40, Markus Armbruster <armbru@redhat.com> wrote:

>> Peter Maydell <peter.maydell@linaro.org> writes:

>>

>>> We already require gcc 4.1 or newer (for the atomic

>>> support), so the fallback codepaths for older gcc

>>> versions than that are now dead code and we can

>>> just delete them.

>>>

>>> NB: clang reports itself as gcc 4.2 (regardless of

>>> clang version), so clang won't be using the fallbacks

>>> either.

>>>

>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

>>> ---

>>> For compatibility with clang we should probably try to avoid

>>> using QEMU_GNUC_PREREQ() and instead have something in

>>> compiler.h that abstracts away whether the test for "does

>>> the compiler support feature foo" is via a GCC version

>>> check or a clang __has_feature or whatever.

>>

>> Yes, testing for feature is better than testing a version.

>>

>> This patch reduces use of QEMU_GNUC_PREREQ roughly by half.  Good.

>>

>>>

>>>

>>>  include/qemu/compiler.h   |   8 ---

>>>  include/qemu/host-utils.h | 121 ----------------------------------------------

>>>  tcg/arm/tcg-target.h      |   7 ---

>>>  3 files changed, 136 deletions(-)

>>>

>>> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h

>>> index 157698b..fc12e49 100644

>>> --- a/include/qemu/compiler.h

>>> +++ b/include/qemu/compiler.h

>>> @@ -24,17 +24,9 @@

>>>

>>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>>

>>> -#if QEMU_GNUC_PREREQ(3, 4)

>>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>>> -#else

>>> -#define QEMU_WARN_UNUSED_RESULT

>>> -#endif

>>

>> Should we inline this macro?

>

> We have attributes which we wrap in QEMU_ macros already

> even though they always expand to the same thing:

> QEMU_NORETURN and QEMU_ALIGNED.


We also use attributes that are supported by all compilers of interest
without wrapping them in macros.  Just grep for __attribute__.

>                                 I'm happy to leave these

> to follow that pattern. (If you wanted to send a patch

> series that uninlined all of those then I wouldn't hugely

> object to it, but I think it touches enough files that it's

> a separate thing from removing the #if guards that this

> patch does.)


Makes sense.
Markus Armbruster Jan. 31, 2017, 7:02 p.m. | #8
Peter Maydell <peter.maydell@linaro.org> writes:

> On 31 January 2017 at 18:11, Daniel P. Berrange <berrange@redhat.com> wrote:

>> On Tue, Jan 31, 2017 at 06:00:13PM +0000, Peter Maydell wrote:

>>> We have attributes which we wrap in QEMU_ macros already

>>> even though they always expand to the same thing:

>>> QEMU_NORETURN and QEMU_ALIGNED. I'm happy to leave these

>>> to follow that pattern. (If you wanted to send a patch

>>> series that uninlined all of those then I wouldn't hugely

>>> object to it, but I think it touches enough files that it's

>>> a separate thing from removing the #if guards that this

>>> patch does.)

>>

>> The other option is just to replace QEMU_WARN_UNUSED_RESULT with

>>

>>   #define QEMU_WARN_UNUSED_RESULT  G_GNUC_WARN_UNUSED_RESULT

>>

>> and convert code to use G_GNUC_WARN_UNUSED_RESULT directly until we

>> can kill the QEMU specific define. There's no benefit to QEMU having

>> its own defines that duplicate stuff already covered by our min

>> required glib - G_GNUC_WARN_UNUSED_RESULT was added in 2.10 for

>> example.

>

> I wouldn't object to that either, but again it ought to be

> a different patch or patch series to this one...


I wouldn't exactly object, just say that to me, wrapping an attribute in
a GLib-provided macro even though we're not aware of a compiler that
profits from it feels a bit like "look ma, I've read all of the GLib
manual!"
Paolo Bonzini Jan. 31, 2017, 11:27 p.m. | #9
On 31/01/2017 11:58, Peter Maydell wrote:
> On 31 January 2017 at 16:55, Daniel P. Berrange <berrange@redhat.com> wrote:

>> On Tue, Jan 31, 2017 at 04:14:47PM +0000, Peter Maydell wrote:

>>> We already require gcc 4.1 or newer (for the atomic

>>> support), so the fallback codepaths for older gcc

>>> versions than that are now dead code and we can

>>> just delete them.

>>

>> Do we have any explicit check alreadu for 4.1, or do we

>> just let the build fail on the atomic code ?

>>

>> IOW, is there any use in having..

>>

>> #if !QEMU_GNUC_PREREQ(4, 1)

>> # error "QEMU requires GCC >= 4.1 or CLang"

>> #endif

> 

> I guess we just barf in the atomics. An explicit check might

> not be a bad idea I guess, though it depends a bit on how

> many releases we've been implicitly requiring 4.1 for. I

> suppose it would act as documentation of our current

> minimum req.


We have:

- first occurrence on Linux hosts: 0.13.0 (for vhost)

- first occurrence on non-Linux hosts: 0.15.0 (simpletrace backend),
then backed out in 1.0

- next occurrence on all hosts, but only in tests: 1.4.0

- finally, first occurrence on all hosts with simple ./configure &&
make: 2.0.0

Paolo
Paolo Bonzini Jan. 31, 2017, 11:27 p.m. | #10
On 31/01/2017 12:40, Markus Armbruster wrote:
>>  

>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>  

>> -#if QEMU_GNUC_PREREQ(3, 4)

>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>> -#else

>> -#define QEMU_WARN_UNUSED_RESULT

>> -#endif

> Should we inline this macro?

> 

>>  

>> -#if QEMU_GNUC_PREREQ(4, 0)

>>  #define QEMU_SENTINEL __attribute__((sentinel))

>> -#else

>> -#define QEMU_SENTINEL

>> -#endif

> Likewise.


Why, since we don't do that for QEMU_NORETURN, QEMU_PACKED, etc.?

Paolo
Markus Armbruster Feb. 1, 2017, 6:49 a.m. | #11
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 31/01/2017 12:40, Markus Armbruster wrote:

>>>  

>>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>>  

>>> -#if QEMU_GNUC_PREREQ(3, 4)

>>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>>> -#else

>>> -#define QEMU_WARN_UNUSED_RESULT

>>> -#endif

>> Should we inline this macro?

>> 

>>>  

>>> -#if QEMU_GNUC_PREREQ(4, 0)

>>>  #define QEMU_SENTINEL __attribute__((sentinel))

>>> -#else

>>> -#define QEMU_SENTINEL

>>> -#endif

>> Likewise.

>

> Why, since we don't do that for QEMU_NORETURN, QEMU_PACKED, etc.?


Because we do it for aligned, always_inline, constructor, format, mode,
noinline, and in places even noreturn and packed:

    $ git-grep __attribute__ | sed '/define/d;s/.*__attribute__ *((\([A-Za-z0-9_]*\).*/\1/' | sort -u
Paolo Bonzini Feb. 2, 2017, 1:09 a.m. | #12
On 31/01/2017 22:49, Markus Armbruster wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:

> 

>> On 31/01/2017 12:40, Markus Armbruster wrote:

>>>>  

>>>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>>>  

>>>> -#if QEMU_GNUC_PREREQ(3, 4)

>>>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>>>> -#else

>>>> -#define QEMU_WARN_UNUSED_RESULT

>>>> -#endif

>>> Should we inline this macro?

>>>

>>>>  

>>>> -#if QEMU_GNUC_PREREQ(4, 0)

>>>>  #define QEMU_SENTINEL __attribute__((sentinel))

>>>> -#else

>>>> -#define QEMU_SENTINEL

>>>> -#endif

>>> Likewise.

>>

>> Why, since we don't do that for QEMU_NORETURN, QEMU_PACKED, etc.?

> 

> Because we do it for aligned, always_inline, constructor, format, mode,

> noinline, and in places even noreturn and packed:

> 

>     $ git-grep __attribute__ | sed '/define/d;s/.*__attribute__ *((\([A-Za-z0-9_]*\).*/\1/' | sort -u

> 


Uh oh. :)  You have to remove uses in firmware and in imported code
(which covers mode, format and noreturn), but there's certainly room for
some BiteSizedTasks.

For sure noinline should be wrapped by a macro so that you also include
noclone (usually you want to thwart some compiler optimization so both
are needed).

That leaves aligned, always_inline and constructor.  always_inline has
three users, constructors has many, aligned has many and there's
QEMU_ALIGNED too.  The smallest work would be to convert these three to
QEMU_* rather than convert QEMU_* to __attribute__.

Thanks,

Paolo
Markus Armbruster Feb. 2, 2017, 10:17 a.m. | #13
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 31/01/2017 22:49, Markus Armbruster wrote:

>> Paolo Bonzini <pbonzini@redhat.com> writes:

>> 

>>> On 31/01/2017 12:40, Markus Armbruster wrote:

>>>>>  

>>>>>  #define QEMU_NORETURN __attribute__ ((__noreturn__))

>>>>>  

>>>>> -#if QEMU_GNUC_PREREQ(3, 4)

>>>>>  #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

>>>>> -#else

>>>>> -#define QEMU_WARN_UNUSED_RESULT

>>>>> -#endif

>>>> Should we inline this macro?

>>>>

>>>>>  

>>>>> -#if QEMU_GNUC_PREREQ(4, 0)

>>>>>  #define QEMU_SENTINEL __attribute__((sentinel))

>>>>> -#else

>>>>> -#define QEMU_SENTINEL

>>>>> -#endif

>>>> Likewise.

>>>

>>> Why, since we don't do that for QEMU_NORETURN, QEMU_PACKED, etc.?

>> 

>> Because we do it for aligned, always_inline, constructor, format, mode,

>> noinline, and in places even noreturn and packed:

>> 

>>     $ git-grep __attribute__ | sed '/define/d;s/.*__attribute__ *((\([A-Za-z0-9_]*\).*/\1/' | sort -u

>> 

>

> Uh oh. :)  You have to remove uses in firmware and in imported code

> (which covers mode, format and noreturn), but there's certainly room for

> some BiteSizedTasks.

>

> For sure noinline should be wrapped by a macro so that you also include

> noclone (usually you want to thwart some compiler optimization so both

> are needed).

>

> That leaves aligned, always_inline and constructor.  always_inline has

> three users, constructors has many, aligned has many and there's

> QEMU_ALIGNED too.  The smallest work would be to convert these three to

> QEMU_* rather than convert QEMU_* to __attribute__.


I prefer "direct" expression to hiding behind macros, unless there's a
reason for macros.  A common reason is portability.  Occasionally
abstraction, say when the direct expression doesn't really convey what
you're trying to do, or it's is overly verbose.

Anyway, I'm not particular on how we use attributes.  Since you seem to
have more specific ideas, could you file suitable BiteSizedTasks?
Peter Maydell April 21, 2017, 9:08 a.m. | #14
On 31 January 2017 at 16:14, Peter Maydell <peter.maydell@linaro.org> wrote:
> We already require gcc 4.1 or newer (for the atomic

> support), so the fallback codepaths for older gcc

> versions than that are now dead code and we can

> just delete them.

>

> NB: clang reports itself as gcc 4.2 (regardless of

> clang version), so clang won't be using the fallbacks

> either.

>

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---


Applied to master, thanks.

-- PMM

Patch hide | download patch | download mbox

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 157698b..fc12e49 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -24,17 +24,9 @@ 
 
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
-#if QEMU_GNUC_PREREQ(3, 4)
 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-#else
-#define QEMU_WARN_UNUSED_RESULT
-#endif
 
-#if QEMU_GNUC_PREREQ(4, 0)
 #define QEMU_SENTINEL __attribute__((sentinel))
-#else
-#define QEMU_SENTINEL
-#endif
 
 #if QEMU_GNUC_PREREQ(4, 3)
 #define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 96288d0..e0d5b0e 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -115,37 +115,7 @@  static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
  */
 static inline int clz32(uint32_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return val ? __builtin_clz(val) : 32;
-#else
-    /* Binary search for the leading one bit.  */
-    int cnt = 0;
-
-    if (!(val & 0xFFFF0000U)) {
-        cnt += 16;
-        val <<= 16;
-    }
-    if (!(val & 0xFF000000U)) {
-        cnt += 8;
-        val <<= 8;
-    }
-    if (!(val & 0xF0000000U)) {
-        cnt += 4;
-        val <<= 4;
-    }
-    if (!(val & 0xC0000000U)) {
-        cnt += 2;
-        val <<= 2;
-    }
-    if (!(val & 0x80000000U)) {
-        cnt++;
-        val <<= 1;
-    }
-    if (!(val & 0x80000000U)) {
-        cnt++;
-    }
-    return cnt;
-#endif
 }
 
 /**
@@ -168,19 +138,7 @@  static inline int clo32(uint32_t val)
  */
 static inline int clz64(uint64_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return val ? __builtin_clzll(val) : 64;
-#else
-    int cnt = 0;
-
-    if (!(val >> 32)) {
-        cnt += 32;
-    } else {
-        val >>= 32;
-    }
-
-    return cnt + clz32(val);
-#endif
 }
 
 /**
@@ -203,39 +161,7 @@  static inline int clo64(uint64_t val)
  */
 static inline int ctz32(uint32_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return val ? __builtin_ctz(val) : 32;
-#else
-    /* Binary search for the trailing one bit.  */
-    int cnt;
-
-    cnt = 0;
-    if (!(val & 0x0000FFFFUL)) {
-        cnt += 16;
-        val >>= 16;
-    }
-    if (!(val & 0x000000FFUL)) {
-        cnt += 8;
-        val >>= 8;
-    }
-    if (!(val & 0x0000000FUL)) {
-        cnt += 4;
-        val >>= 4;
-    }
-    if (!(val & 0x00000003UL)) {
-        cnt += 2;
-        val >>= 2;
-    }
-    if (!(val & 0x00000001UL)) {
-        cnt++;
-        val >>= 1;
-    }
-    if (!(val & 0x00000001UL)) {
-        cnt++;
-    }
-
-    return cnt;
-#endif
 }
 
 /**
@@ -258,19 +184,7 @@  static inline int cto32(uint32_t val)
  */
 static inline int ctz64(uint64_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return val ? __builtin_ctzll(val) : 64;
-#else
-    int cnt;
-
-    cnt = 0;
-    if (!((uint32_t)val)) {
-        cnt += 32;
-        val >>= 32;
-    }
-
-    return cnt + ctz32(val);
-#endif
 }
 
 /**
@@ -322,15 +236,7 @@  static inline int clrsb64(uint64_t val)
  */
 static inline int ctpop8(uint8_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return __builtin_popcount(val);
-#else
-    val = (val & 0x55) + ((val >> 1) & 0x55);
-    val = (val & 0x33) + ((val >> 2) & 0x33);
-    val = (val + (val >> 4)) & 0x0f;
-
-    return val;
-#endif
 }
 
 /**
@@ -339,16 +245,7 @@  static inline int ctpop8(uint8_t val)
  */
 static inline int ctpop16(uint16_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return __builtin_popcount(val);
-#else
-    val = (val & 0x5555) + ((val >> 1) & 0x5555);
-    val = (val & 0x3333) + ((val >> 2) & 0x3333);
-    val = (val + (val >> 4)) & 0x0f0f;
-    val = (val + (val >> 8)) & 0x00ff;
-
-    return val;
-#endif
 }
 
 /**
@@ -357,16 +254,7 @@  static inline int ctpop16(uint16_t val)
  */
 static inline int ctpop32(uint32_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return __builtin_popcount(val);
-#else
-    val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
-    val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
-    val = (val + (val >> 4)) & 0x0f0f0f0f;
-    val = (val * 0x01010101) >> 24;
-
-    return val;
-#endif
 }
 
 /**
@@ -375,16 +263,7 @@  static inline int ctpop32(uint32_t val)
  */
 static inline int ctpop64(uint64_t val)
 {
-#if QEMU_GNUC_PREREQ(3, 4)
     return __builtin_popcountll(val);
-#else
-    val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
-    val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
-    val = (val + (val >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
-    val = (val * 0x0101010101010101ULL) >> 56;
-
-    return val;
-#endif
 }
 
 /**
diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h
index 09a19c6..75ea247 100644
--- a/tcg/arm/tcg-target.h
+++ b/tcg/arm/tcg-target.h
@@ -130,14 +130,7 @@  enum {
 
 static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
 {
-#if QEMU_GNUC_PREREQ(4, 1)
     __builtin___clear_cache((char *) start, (char *) stop);
-#else
-    register uintptr_t _beg __asm("a1") = start;
-    register uintptr_t _end __asm("a2") = stop;
-    register uintptr_t _flg __asm("a3") = 0;
-    __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg));
-#endif
 }
 
 #endif