* [Qemu-devel] [PATCH] build: Don't redefine 'inline'
@ 2016-02-09 18:49 Eric Blake
2016-02-12 13:24 ` Peter Maydell
2016-02-16 13:24 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Eric Blake @ 2016-02-09 18:49 UTC (permalink / raw)
To: qemu-devel
Actively redefining 'inline' is wrong for C++, where gcc has an
extension 'inline namespace' which fails to compile if the
keyword 'inline' is replaced by a macro expansion. This will
matter once we start to include "qemu/osdep.h" first from C++
files, depending also on whether the system headers are new
enough to be using the gcc extension.
But rather than just guard things by __cplusplus, let's look at
the overall picture. Commit df2542c737ea2 in 2007 defined 'inline'
to the gcc attribute __always_inline__, with the rationale "To
avoid discarded inlining bug". But compilers have improved since
then, and we are probably better off trusting the compiler rather
than trying to force its hand.
So just nuke our craziness.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
include/qemu/compiler.h | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index d22eb01..c5fbe28 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -77,18 +77,6 @@
#define typeof_field(type, field) typeof(((type *)0)->field)
#define type_check(t1,t2) ((t1*)0 - (t2*)0)
-#ifndef always_inline
-#if !((__GNUC__ < 3) || defined(__APPLE__))
-#ifdef __OPTIMIZE__
-#undef inline
-#define inline __attribute__ (( always_inline )) __inline__
-#endif
-#endif
-#else
-#undef inline
-#define inline always_inline
-#endif
-
#define QEMU_BUILD_BUG_ON(x) \
typedef char glue(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused));
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] build: Don't redefine 'inline'
2016-02-09 18:49 [Qemu-devel] [PATCH] build: Don't redefine 'inline' Eric Blake
@ 2016-02-12 13:24 ` Peter Maydell
2016-02-12 15:49 ` Eric Blake
2016-02-16 13:24 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-02-12 13:24 UTC (permalink / raw)
To: Eric Blake; +Cc: QEMU Developers
On 9 February 2016 at 18:49, Eric Blake <eblake@redhat.com> wrote:
> Actively redefining 'inline' is wrong for C++, where gcc has an
> extension 'inline namespace' which fails to compile if the
> keyword 'inline' is replaced by a macro expansion. This will
> matter once we start to include "qemu/osdep.h" first from C++
> files, depending also on whether the system headers are new
> enough to be using the gcc extension.
>
> But rather than just guard things by __cplusplus, let's look at
> the overall picture. Commit df2542c737ea2 in 2007 defined 'inline'
> to the gcc attribute __always_inline__, with the rationale "To
> avoid discarded inlining bug". But compilers have improved since
> then, and we are probably better off trusting the compiler rather
> than trying to force its hand.
>
> So just nuke our craziness.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
(and tested that it passes my usual merge build tests).
Does this patch suffice to get your system to build all
my clean-includes patches?
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] build: Don't redefine 'inline'
2016-02-12 13:24 ` Peter Maydell
@ 2016-02-12 15:49 ` Eric Blake
0 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2016-02-12 15:49 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]
On 02/12/2016 06:24 AM, Peter Maydell wrote:
> On 9 February 2016 at 18:49, Eric Blake <eblake@redhat.com> wrote:
>> Actively redefining 'inline' is wrong for C++, where gcc has an
>> extension 'inline namespace' which fails to compile if the
>> keyword 'inline' is replaced by a macro expansion. This will
>> matter once we start to include "qemu/osdep.h" first from C++
>> files, depending also on whether the system headers are new
>> enough to be using the gcc extension.
>>
>> But rather than just guard things by __cplusplus, let's look at
>> the overall picture. Commit df2542c737ea2 in 2007 defined 'inline'
>> to the gcc attribute __always_inline__, with the rationale "To
>> avoid discarded inlining bug". But compilers have improved since
>> then, and we are probably better off trusting the compiler rather
>> than trying to force its hand.
>>
>> So just nuke our craziness.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> (and tested that it passes my usual merge build tests).
>
> Does this patch suffice to get your system to build all
> my clean-includes patches?
Yes.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] build: Don't redefine 'inline'
2016-02-09 18:49 [Qemu-devel] [PATCH] build: Don't redefine 'inline' Eric Blake
2016-02-12 13:24 ` Peter Maydell
@ 2016-02-16 13:24 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-02-16 13:24 UTC (permalink / raw)
To: Eric Blake; +Cc: QEMU Developers
On 9 February 2016 at 18:49, Eric Blake <eblake@redhat.com> wrote:
> Actively redefining 'inline' is wrong for C++, where gcc has an
> extension 'inline namespace' which fails to compile if the
> keyword 'inline' is replaced by a macro expansion. This will
> matter once we start to include "qemu/osdep.h" first from C++
> files, depending also on whether the system headers are new
> enough to be using the gcc extension.
>
> But rather than just guard things by __cplusplus, let's look at
> the overall picture. Commit df2542c737ea2 in 2007 defined 'inline'
> to the gcc attribute __always_inline__, with the rationale "To
> avoid discarded inlining bug". But compilers have improved since
> then, and we are probably better off trusting the compiler rather
> than trying to force its hand.
>
> So just nuke our craziness.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> include/qemu/compiler.h | 12 ------------
> 1 file changed, 12 deletions(-)
Applied to master, thanks. I am all in favour of reducing
the craziness quotient of our codebase.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-16 13:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-09 18:49 [Qemu-devel] [PATCH] build: Don't redefine 'inline' Eric Blake
2016-02-12 13:24 ` Peter Maydell
2016-02-12 15:49 ` Eric Blake
2016-02-16 13:24 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).