Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1
PATCH 1/1 Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1
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.
---
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(-)
include/qemu/compiler.h +0 -8
@@ -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))
include/qemu/host-utils.h +0 -121
177 lines not on this page · raw message
tcg/arm/tcg-target.h +0 -7
@@ -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
Signature · 1 line
2.7.4
Quoted 4 lines · Peter Maydell
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
Signature · 3 lines
|: 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/ :|
Quoted 6 lines · Daniel P. Berrange
Quoted 4 lines · Peter Maydell
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.
Quoted 8 lines
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
Quoted 16 lines · Peter Maydell
Quoted 6 lines · Daniel P. Berrange
Quoted 4 lines · Peter Maydell
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.
Quoted 8 lines
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
Quoted 5 lines
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
Quoted 9 lines · Peter Maydell
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.
Quoted 7 lines
Signed-off-by Peter Maydell <[email protected]>---
For compatibility with clang we should probably try to avoid usingQEMU_GNUC_PREREQ()and instead have something incompiler.hthat abstracts away whether the test for "does the compiler support feature foo" is via a GCC version check or a clang__has_featureor whatever.
Yes, testing for feature is better than testing a version.
This patch reduces use of QEMU_GNUC_PREREQ roughly by half. Good.
Quoted 12 lines
include/qemu/compiler.h | 8 --- include/qemu/host-utils.h | 121 ---------------------------------------------- tcg/arm/tcg-target.h | 7 --- 3 files changed, 136 deletions(-)include/qemu/compiler.h +0
-0
include/qemu/compiler.h line 31
Quoted 8 lines
include/qemu/compiler.h +0
-4@@ -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?
include/qemu/compiler.h line 37
Quoted 6 lines
include/qemu/compiler.h +0
-4-#if QEMU_GNUC_PREREQ (4 ,0 )#define QEMU_SENTINEL __attribute__((sentinel)) -#else -#define QEMU_SENTINEL -#endif
Likewise.
include/qemu/compiler.h line 32
Quoted 3 lines
include/qemu/compiler.h +0
-0#if QEMU_GNUC_PREREQ (4 ,3 )#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
[Nothing to say on the rest...]
Regardless of my question:
Quoted 38 lines · Markus Armbruster
Quoted 9 lines · Peter Maydell
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.
Quoted 7 lines
Signed-off-by Peter Maydell <[email protected]>---
For compatibility with clang we should probably try to avoid usingQEMU_GNUC_PREREQ()and instead have something incompiler.hthat abstracts away whether the test for "does the compiler support feature foo" is via a GCC version check or a clang__has_featureor whatever.Yes, testing for feature is better than testing a version.
This patch reduces use of
QEMU_GNUC_PREREQroughly by half. Good.Quoted 15 lines
include/qemu/compiler.h | 8 --- include/qemu/host-utils.h | 121 ---------------------------------------------- tcg/arm/tcg-target.h | 7 --- 3 files changed, 136 deletions(-)include/qemu/compiler.h +0
-0@@ -24,17 +24,9 @@#define QEMU_NORETURN __attribute__ ((__noreturn__))
Quoted 7 lines
include/qemu/compiler.h line 31
Quoted 5 lines
include/qemu/compiler.h +0
-4-#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
Quoted 47 lines · Peter Maydell
Quoted 38 lines · Markus Armbruster
Quoted 9 lines · Peter Maydell
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.
Quoted 7 lines
Signed-off-by Peter Maydell <[email protected]>---
For compatibility with clang we should probably try to avoid usingQEMU_GNUC_PREREQ()and instead have something incompiler.hthat abstracts away whether the test for "does the compiler support feature foo" is via a GCC version check or a clang__has_featureor whatever.Yes, testing for feature is better than testing a version.
This patch reduces use of
QEMU_GNUC_PREREQroughly by half. Good.Quoted 15 lines
include/qemu/compiler.h | 8 --- include/qemu/host-utils.h | 121 ---------------------------------------------- tcg/arm/tcg-target.h | 7 --- 3 files changed, 136 deletions(-)include/qemu/compiler.h +0
-0@@ -24,17 +24,9 @@#define QEMU_NORETURN __attribute__ ((__noreturn__))Quoted 7 lines
include/qemu/compiler.h line 31
Quoted 5 lines
include/qemu/compiler.h +0
-4-#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?
Quoted 8 lines
We have attributes which we wrap in
QEMU_macros already even though they always expand to the same thing:QEMU_NORETURNandQEMU_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
Signature · 3 lines
|: 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/ :|
Quoted 12 lines · Daniel P. Berrange
Quoted 8 lines · Peter Maydell
We have attributes which we wrap in
QEMU_macros already even though they always expand to the same thing:QEMU_NORETURNandQEMU_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_RESULTwith
Quoted 7 lines
#define QEMU_WARN_UNUSED_RESULT G_GNUC_WARN_UNUSED_RESULTand convert code to use
G_GNUC_WARN_UNUSED_RESULTdirectly 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_RESULTwas 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
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Daniel P. Berrange
Quoted 8 lines · Peter Maydell
We have attributes which we wrap in
QEMU_macros already even though they always expand to the same thing:QEMU_NORETURNandQEMU_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_RESULTwith#define QEMU_WARN_UNUSED_RESULT G_GNUC_WARN_UNUSED_RESULT
Quoted 8 lines
Quoted 5 lines
and convert code to use
G_GNUC_WARN_UNUSED_RESULTdirectly 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_RESULTwas 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!"
Quoted 47 lines · Peter Maydell
Quoted 38 lines · Markus Armbruster
Quoted 9 lines · Peter Maydell
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.
Quoted 7 lines
Signed-off-by Peter Maydell <[email protected]>---
For compatibility with clang we should probably try to avoid usingQEMU_GNUC_PREREQ()and instead have something incompiler.hthat abstracts away whether the test for "does the compiler support feature foo" is via a GCC version check or a clang__has_featureor whatever.Yes, testing for feature is better than testing a version.
This patch reduces use of
QEMU_GNUC_PREREQroughly by half. Good.Quoted 15 lines
include/qemu/compiler.h | 8 --- include/qemu/host-utils.h | 121 ---------------------------------------------- tcg/arm/tcg-target.h | 7 --- 3 files changed, 136 deletions(-)include/qemu/compiler.h +0
-0@@ -24,17 +24,9 @@#define QEMU_NORETURN __attribute__ ((__noreturn__))Quoted 7 lines
include/qemu/compiler.h line 31
Quoted 5 lines
include/qemu/compiler.h +0
-4-#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?
Quoted 3 lines
We have attributes which we wrap in
QEMU_macros already even though they always expand to the same thing:QEMU_NORETURNandQEMU_ALIGNED.
We also use attributes that are supported by all compilers of interest without wrapping them in macros. Just grep for __attribute__.
Quoted 6 lines
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.
Quoted 11 lines · Markus Armbruster
include/qemu/compiler.h line 31
Quoted 8 lines
#define
QEMU_NORETURN__attribute__((__noreturn__))include/qemu/compiler.h +0
-4-#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?
Quoted 1 line
Quoted 6 lines
include/qemu/compiler.h line 37
Quoted 5 lines
include/qemu/compiler.h +0
-4-#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
Quoted 12 lines · Paolo Bonzini
Quoted 11 lines · Markus Armbruster
include/qemu/compiler.h line 31
Quoted 8 lines
#define
QEMU_NORETURN__attribute__((__noreturn__))include/qemu/compiler.h +0
-4-#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?
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
include/qemu/compiler.h line 37
Quoted 5 lines
include/qemu/compiler.h +0
-4-#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
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Paolo Bonzini
Quoted 17 lines · Markus Armbruster
include/qemu/compiler.h line 31
Quoted 8 lines
#define
QEMU_NORETURN__attribute__((__noreturn__))include/qemu/compiler.h +0
-4-#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?
include/qemu/compiler.h line 37
Quoted 6 lines
include/qemu/compiler.h +0
-4-#if QEMU_GNUC_PREREQ (4 ,0 )#define QEMU_SENTINEL __attribute__((sentinel)) -#else -#define QEMU_SENTINEL -#endif Likewise.
Quoted 7 lines
Quoted 1 line
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
Quoted 34 lines · Paolo Bonzini
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Paolo Bonzini
Quoted 17 lines · Markus Armbruster
include/qemu/compiler.h line 31
Quoted 8 lines
#define
QEMU_NORETURN__attribute__((__noreturn__))include/qemu/compiler.h +0
-4-#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?
include/qemu/compiler.h line 37
Quoted 6 lines
include/qemu/compiler.h +0
-4-#if QEMU_GNUC_PREREQ (4 ,0 )#define QEMU_SENTINEL __attribute__((sentinel)) -#else -#define QEMU_SENTINEL -#endif Likewise.
Quoted 7 lines
Quoted 1 line
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 -uUh 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.
Quoted 8 lines
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_inlineand constructor.always_inlinehas three users, constructors has many, aligned has many and there'sQEMU_ALIGNEDtoo. 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
AppliedQuoted 11 lines · Peter Maydell
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 <[email protected]>---
Applied to master, thanks.
-- PMM