* [PATCH 1/2] Correct function definition for C++
@ 2017-02-21 15:24 Joakim Tjernlund
2017-02-21 15:24 ` [PATCH 2/2] compiler.h: fix C++ uninitialized const issue Joakim Tjernlund
2017-02-22 7:10 ` [PATCH 1/2] Correct function definition for C++ Greg KH
0 siblings, 2 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2017-02-21 15:24 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Joakim Tjernlund
C++ does does not like the extra extern before asmlinkage, remove it.
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
---
include/linux/printk.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 3472cc6..be823f5 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -139,7 +139,7 @@ struct va_format {
})
#ifdef CONFIG_EARLY_PRINTK
-extern asmlinkage __printf(1, 2)
+asmlinkage __printf(1, 2)
void early_printk(const char *fmt, ...);
#else
static inline __printf(1, 2) __cold
@@ -270,7 +270,7 @@ static inline void show_regs_print_info(const char *log_lvl)
}
#endif
-extern asmlinkage void dump_stack(void) __cold;
+asmlinkage void dump_stack(void) __cold;
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
--
2.10.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] compiler.h: fix C++ uninitialized const issue
2017-02-21 15:24 [PATCH 1/2] Correct function definition for C++ Joakim Tjernlund
@ 2017-02-21 15:24 ` Joakim Tjernlund
2017-02-22 7:10 ` [PATCH 1/2] Correct function definition for C++ Greg KH
1 sibling, 0 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2017-02-21 15:24 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Joakim Tjernlund
C++ does not like the union { typeof(x) __val; char __c[1]; } __u
construct for const types:
error: uninitialized const member in
'union atomic_read(const atomic_t*)::<anonymous>'
Address this by creating a C++ version of READ_ONCE where this union is
initialized: union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0}
To please gcc 6.3.0 also add in a _u(){} as default ctor.
This makes C++ happy enough to build.
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
---
include/linux/compiler.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index cf0fa5d..0a047fd 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -300,6 +300,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
* required ordering.
*/
+#ifndef __cplusplus
#define __READ_ONCE(x, check) \
({ \
union { typeof(x) __val; char __c[1]; } __u; \
@@ -309,6 +310,17 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
__read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
__u.__val; \
})
+#else
+#define __READ_ONCE(x, check) \
+({ \
+ union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0}; \
+ if (check) \
+ __read_once_size(&(x), __u.__c, sizeof(x)); \
+ else \
+ __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
+ __u.__val; \
+})
+#endif
#define READ_ONCE(x) __READ_ONCE(x, 1)
/*
--
2.10.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-21 15:24 [PATCH 1/2] Correct function definition for C++ Joakim Tjernlund
2017-02-21 15:24 ` [PATCH 2/2] compiler.h: fix C++ uninitialized const issue Joakim Tjernlund
@ 2017-02-22 7:10 ` Greg KH
2017-02-22 7:50 ` Joakim Tjernlund
1 sibling, 1 reply; 10+ messages in thread
From: Greg KH @ 2017-02-22 7:10 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linux-kernel, stable
On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> C++ does does not like the extra extern before asmlinkage, remove it.
>
> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> ---
> include/linux/printk.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 3472cc6..be823f5 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
Why are you building this file with a C++ compiler?
Also, this is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 7:10 ` [PATCH 1/2] Correct function definition for C++ Greg KH
@ 2017-02-22 7:50 ` Joakim Tjernlund
2017-02-22 13:03 ` greg
2017-02-28 23:15 ` Thomas Backlund
0 siblings, 2 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2017-02-22 7:50 UTC (permalink / raw)
To: greg; +Cc: linux-kernel, stable
On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > C++ does does not like the extra extern before asmlinkage, remove it.
> >
> > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > ---
> > include/linux/printk.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > index 3472cc6..be823f5 100644
> > --- a/include/linux/printk.h
> > +++ b/include/linux/printk.h
>
>
> Why are you building this file with a C++ compiler?
virtualbox uses C++ and includes various kernel headers and the build
fails, virtualbox guest additions has not build for quite some time now and
this is one of the problems.
>
> Also, this is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read Documentation/stable_kernel_rules.txt
> for how to do this properly.
Sorry, I was in a hurry(lazy:) so I just included stable directly as
I know it needs to be fixed in 4.9 as well.
Jocke
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 7:50 ` Joakim Tjernlund
@ 2017-02-22 13:03 ` greg
2017-02-22 14:00 ` Joakim Tjernlund
2017-02-28 23:15 ` Thomas Backlund
1 sibling, 1 reply; 10+ messages in thread
From: greg @ 2017-02-22 13:03 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linux-kernel, stable
On Wed, Feb 22, 2017 at 07:50:46AM +0000, Joakim Tjernlund wrote:
> On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> > On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > > C++ does does not like the extra extern before asmlinkage, remove it.
> > >
> > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > > ---
> > > include/linux/printk.h | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > > index 3472cc6..be823f5 100644
> > > --- a/include/linux/printk.h
> > > +++ b/include/linux/printk.h
> >
> >
> > Why are you building this file with a C++ compiler?
>
> virtualbox uses C++ and includes various kernel headers and the build
> fails, virtualbox guest additions has not build for quite some time now and
> this is one of the problems.
Virtualbox is a horrid pile of crap. You can quote me on that. We
don't care about out-of-tree drivers, the authors should work to get
them merged properly if they do care.
Kernel code should be C, not C++, and if you do want to use C++, then
you are on your own, sorry.
> > Also, this is not the correct way to submit patches for inclusion in the
> > stable kernel tree. Please read Documentation/stable_kernel_rules.txt
> > for how to do this properly.
>
> Sorry, I was in a hurry(lazy:) so I just included stable directly as
> I know it needs to be fixed in 4.9 as well.
But that's not how to get a patch into the stable tree :(
sorry,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 13:03 ` greg
@ 2017-02-22 14:00 ` Joakim Tjernlund
2017-02-22 14:22 ` greg
0 siblings, 1 reply; 10+ messages in thread
From: Joakim Tjernlund @ 2017-02-22 14:00 UTC (permalink / raw)
To: greg; +Cc: linux-kernel, stable
On Wed, 2017-02-22 at 14:03 +0100, greg@kroah.com wrote:
> On Wed, Feb 22, 2017 at 07:50:46AM +0000, Joakim Tjernlund wrote:
> > On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> > > On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > > > C++ does does not like the extra extern before asmlinkage, remove it.
> > > >
> > > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > > > ---
> > > > include/linux/printk.h | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > > > index 3472cc6..be823f5 100644
> > > > --- a/include/linux/printk.h
> > > > +++ b/include/linux/printk.h
> > >
> > >
> > > Why are you building this file with a C++ compiler?
> >
> > virtualbox uses C++ and includes various kernel headers and the build
> > fails, virtualbox guest additions has not build for quite some time now and
> > this is one of the problems.
>
> Virtualbox is a horrid pile of crap. You can quote me on that. We
> don't care about out-of-tree drivers, the authors should work to get
> them merged properly if they do care.
Sure, I believe you :)
But in this case it is not the kernel modules that fails, it is their
guest additions/xf86 video driver. Seem like that these need to include some
kernel herders there too.
>
> Kernel code should be C, not C++, and if you do want to use C++, then
> you are on your own, sorry.
But there are already a lot of C++ adjustments!? Just grepping for __cplusplus shows
plenty of hits and what is the point of asmlinkage then:
#ifdef __cplusplus
#define CPP_ASMLINKAGE extern "C"
#else
#define CPP_ASMLINKAGE
#endif
#ifndef asmlinkage
#define asmlinkage CPP_ASMLINKAGE
#endif
I read all of this that C++ code should be able to at least include kernel headers
without fatal errors.
You don't agree? In that case all __cplusplus/asmlinkage should be removed?
>
> > > Also, this is not the correct way to submit patches for inclusion in the
> > > stable kernel tree. Please read Documentation/stable_kernel_rules.txt
> > > for how to do this properly.
> >
> > Sorry, I was in a hurry(lazy:) so I just included stable directly as
> > I know it needs to be fixed in 4.9 as well.
>
> But that's not how to get a patch into the stable tree :(
>
> sorry,
Right, my mistake. No need to be sorry, I got what I deserved :)
Jocke
>
> greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 14:00 ` Joakim Tjernlund
@ 2017-02-22 14:22 ` greg
0 siblings, 0 replies; 10+ messages in thread
From: greg @ 2017-02-22 14:22 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linux-kernel, stable
On Wed, Feb 22, 2017 at 02:00:53PM +0000, Joakim Tjernlund wrote:
> On Wed, 2017-02-22 at 14:03 +0100, greg@kroah.com wrote:
> > On Wed, Feb 22, 2017 at 07:50:46AM +0000, Joakim Tjernlund wrote:
> > > On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> > > > On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > > > > C++ does does not like the extra extern before asmlinkage, remove it.
> > > > >
> > > > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > > > > ---
> > > > > include/linux/printk.h | 4 ++--
> > > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > > > > index 3472cc6..be823f5 100644
> > > > > --- a/include/linux/printk.h
> > > > > +++ b/include/linux/printk.h
> > > >
> > > >
> > > > Why are you building this file with a C++ compiler?
> > >
> > > virtualbox uses C++ and includes various kernel headers and the build
> > > fails, virtualbox guest additions has not build for quite some time now and
> > > this is one of the problems.
> >
> > Virtualbox is a horrid pile of crap. You can quote me on that. We
> > don't care about out-of-tree drivers, the authors should work to get
> > them merged properly if they do care.
>
> Sure, I believe you :)
>
> But in this case it is not the kernel modules that fails, it is their
> guest additions/xf86 video driver. Seem like that these need to include some
> kernel herders there too.
Seems like their build system is broken, it should not be including non
uapi header files at all.
> > Kernel code should be C, not C++, and if you do want to use C++, then
> > you are on your own, sorry.
>
> But there are already a lot of C++ adjustments!? Just grepping for __cplusplus shows
> plenty of hits and what is the point of asmlinkage then:
> #ifdef __cplusplus
> #define CPP_ASMLINKAGE extern "C"
> #else
> #define CPP_ASMLINKAGE
> #endif
>
> #ifndef asmlinkage
> #define asmlinkage CPP_ASMLINKAGE
> #endif
The usages in include/uapi/ make a bit of sense, but not much.
Everything outside of there makes no sense at all (really just some drm
and one scsi file.) They should be removed.
> I read all of this that C++ code should be able to at least include kernel headers
> without fatal errors.
For uapi stuff, yes. But that's not what you are doing here. You are
trying to build kernel code with a c++ compiler. That's not going to
work.
How is a C++ compiler supposed to parse the following line in device.h
struct class;
(one of my most proud moments...)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
@ 2017-02-22 14:22 ` greg
0 siblings, 0 replies; 10+ messages in thread
From: greg @ 2017-02-22 14:22 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linux-kernel, stable
On Wed, Feb 22, 2017 at 02:00:53PM +0000, Joakim Tjernlund wrote:
> On Wed, 2017-02-22 at 14:03 +0100, greg@kroah.com wrote:
> > On Wed, Feb 22, 2017 at 07:50:46AM +0000, Joakim Tjernlund wrote:
> > > On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> > > > On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > > > > C++ does does not like the extra extern before asmlinkage, remove it.
> > > > >
> > > > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > > > > ---
> > > > > include/linux/printk.h | 4 ++--
> > > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > > > > index 3472cc6..be823f5 100644
> > > > > --- a/include/linux/printk.h
> > > > > +++ b/include/linux/printk.h
> > > >
> > > >
> > > > Why are you building this file with a C++ compiler?
> > >
> > > virtualbox uses C++ and includes various kernel headers and the build
> > > fails, virtualbox guest additions has not build for quite some time now and
> > > this is one of the problems.
> >
> > Virtualbox is a horrid pile of crap. You can quote me on that. We
> > don't care about out-of-tree drivers, the authors should work to get
> > them merged properly if they do care.
>
> Sure, I believe you :)
>
> But in this case it is not the kernel modules that fails, it is their
> guest additions/xf86 video driver. Seem like that these need to include some
> kernel herders there too.
Seems like their build system is broken, it should not be including non
uapi header files at all.
> > Kernel code should be C, not C++, and if you do want to use C++, then
> > you are on your own, sorry.
>
> But there are already a lot of C++ adjustments!? Just grepping for __cplusplus shows
> plenty of hits and what is the point of asmlinkage then:
> #ifdef __cplusplus
> #define CPP_ASMLINKAGE extern "C"
> #else
> #define CPP_ASMLINKAGE
> #endif
>
> #ifndef asmlinkage
> #define asmlinkage CPP_ASMLINKAGE
> #endif
The usages in include/uapi/ make a bit of sense, but not much.
Everything outside of there makes no sense at all (really just some drm
and one scsi file.) They should be removed.
> I read all of this that C++ code should be able to at least include kernel headers
> without fatal errors.�
For uapi stuff, yes. But that's not what you are doing here. You are
trying to build kernel code with a c++ compiler. That's not going to
work.
How is a C++ compiler supposed to parse the following line in device.h
struct class;
(one of my most proud moments...)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 14:22 ` greg
(?)
@ 2017-02-22 16:25 ` Joakim Tjernlund
-1 siblings, 0 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2017-02-22 16:25 UTC (permalink / raw)
To: greg; +Cc: linux-kernel, stable
On Wed, 2017-02-22 at 15:22 +0100, greg@kroah.com wrote:
> On Wed, Feb 22, 2017 at 02:00:53PM +0000, Joakim Tjernlund wrote:
> > On Wed, 2017-02-22 at 14:03 +0100, greg@kroah.com wrote:
> > > On Wed, Feb 22, 2017 at 07:50:46AM +0000, Joakim Tjernlund wrote:
> > > > On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
> > > > > On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
> > > > > > C++ does does not like the extra extern before asmlinkage, remove it.
> > > > > >
> > > > > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > > > > > ---
> > > > > > include/linux/printk.h | 4 ++--
> > > > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > > > > > index 3472cc6..be823f5 100644
> > > > > > --- a/include/linux/printk.h
> > > > > > +++ b/include/linux/printk.h
> > > > >
> > > > >
> > > > > Why are you building this file with a C++ compiler?
> > > >
> > > > virtualbox uses C++ and includes various kernel headers and the build
> > > > fails, virtualbox guest additions has not build for quite some time now and
> > > > this is one of the problems.
> > >
> > > Virtualbox is a horrid pile of crap. You can quote me on that. We
> > > don't care about out-of-tree drivers, the authors should work to get
> > > them merged properly if they do care.
> >
> > Sure, I believe you :)
> >
> > But in this case it is not the kernel modules that fails, it is their
> > guest additions/xf86 video driver. Seem like that these need to include some
> > kernel herders there too.
>
> Seems like their build system is broken, it should not be including non
> uapi header files at all.
>
> > > Kernel code should be C, not C++, and if you do want to use C++, then
> > > you are on your own, sorry.
> >
> > But there are already a lot of C++ adjustments!? Just grepping for __cplusplus shows
> > plenty of hits and what is the point of asmlinkage then:
> > #ifdef __cplusplus
> > #define CPP_ASMLINKAGE extern "C"
> > #else
> > #define CPP_ASMLINKAGE
> > #endif
> >
> > #ifndef asmlinkage
> > #define asmlinkage CPP_ASMLINKAGE
> > #endif
>
> The usages in include/uapi/ make a bit of sense, but not much.
> Everything outside of there makes no sense at all (really just some drm
> and one scsi file.) They should be removed.
>
> > I read all of this that C++ code should be able to at least include kernel headers
> > without fatal errors.
>
> For uapi stuff, yes. But that's not what you are doing here. You are
> trying to build kernel code with a c++ compiler. That's not going to
> work.
Right, I looked into guest-addition and it builds a few kernel modules too
and include linux/string.h and that pulls in the offending code.
Anyhow, the code in printk.h is "wrong" to add an extra extern so that
change should not be a big deal as is, C++ or not.
>
> How is a C++ compiler supposed to parse the following line in device.h
> struct class;
> (one of my most proud moments...)
:)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Correct function definition for C++
2017-02-22 7:50 ` Joakim Tjernlund
2017-02-22 13:03 ` greg
@ 2017-02-28 23:15 ` Thomas Backlund
1 sibling, 0 replies; 10+ messages in thread
From: Thomas Backlund @ 2017-02-28 23:15 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linux-kernel, stable
Den 22.02.2017 kl. 09:50, skrev Joakim Tjernlund:
> On Wed, 2017-02-22 at 08:10 +0100, Greg KH wrote:
>> On Tue, Feb 21, 2017 at 04:24:04PM +0100, Joakim Tjernlund wrote:
>>> C++ does does not like the extra extern before asmlinkage, remove it.
>>>
>>> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
>>> ---
>>> include/linux/printk.h | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/linux/printk.h b/include/linux/printk.h
>>> index 3472cc6..be823f5 100644
>>> --- a/include/linux/printk.h
>>> +++ b/include/linux/printk.h
>>
>>
>> Why are you building this file with a C++ compiler?
>
> virtualbox uses C++ and includes various kernel headers and the build
> fails, virtualbox guest additions has not build for quite some time now and
> this is one of the problems.
You need this fix for virtualbox:
https://www.virtualbox.org/changeset/65874/vbox/trunk/configure
--
Thomas
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-03-01 0:53 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 15:24 [PATCH 1/2] Correct function definition for C++ Joakim Tjernlund
2017-02-21 15:24 ` [PATCH 2/2] compiler.h: fix C++ uninitialized const issue Joakim Tjernlund
2017-02-22 7:10 ` [PATCH 1/2] Correct function definition for C++ Greg KH
2017-02-22 7:50 ` Joakim Tjernlund
2017-02-22 13:03 ` greg
2017-02-22 14:00 ` Joakim Tjernlund
2017-02-22 14:22 ` greg
2017-02-22 14:22 ` greg
2017-02-22 16:25 ` Joakim Tjernlund
2017-02-28 23:15 ` Thomas Backlund
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.