linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Query about cplusplus in linkage.h
@ 2010-11-20  4:17 rocky
  2010-11-22  8:30 ` Baruch Siach
  0 siblings, 1 reply; 5+ messages in thread
From: rocky @ 2010-11-20  4:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, all

I am a little confused about the following definition :

--------------include/linux/linkage.h-----------
#ifdef __cplusplus
#define CPP_ASMLINKAGE extern "C"
#else
#define CPP_ASMLINKAGE
#endif

#ifndef asmlinkage
#define asmlinkage CPP_ASMLINKAGE
#endif

all system call functions are marked with asmlinkage, as well as other kernel function like printk/schedule/do_softirq


so every asmlinkage function has extern "C"  attribute if cplusplus is defined, which definitely happens  when compiling C++ code.

I dont get it when cplusplus is needed when compiling kernel?

Can anyone help me out of this little misunderstanding?

Thansk




		

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Query about cplusplus in linkage.h
  2010-11-20  4:17 Query about cplusplus in linkage.h rocky
@ 2010-11-22  8:30 ` Baruch Siach
  2010-11-22 15:07   ` rocky
  0 siblings, 1 reply; 5+ messages in thread
From: Baruch Siach @ 2010-11-22  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hi rocky,

On Sat, Nov 20, 2010 at 12:17:02PM +0800, rocky wrote:
> I am a little confused about the following definition :
> 
> --------------include/linux/linkage.h-----------
> #ifdef __cplusplus
> #define CPP_ASMLINKAGE extern "C"
> #else
> #define CPP_ASMLINKAGE
> #endif
> 
> #ifndef asmlinkage
> #define asmlinkage CPP_ASMLINKAGE
> #endif
> 
> all system call functions are marked with asmlinkage, as well as other kernel function like printk/schedule/do_softirq
> 
> 
> so every asmlinkage function has extern "C"  attribute if cplusplus is defined, which definitely happens  when compiling C++ code.
> 
> I dont get it when cplusplus is needed when compiling kernel?

It isn't.

> Can anyone help me out of this little misunderstanding?

Userspace C++ code may include kernel header files. Making the exported 
function calls extern "C" makes it easier to build such applications.

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Query about cplusplus in linkage.h
  2010-11-22  8:30 ` Baruch Siach
@ 2010-11-22 15:07   ` rocky
  2010-11-23  5:46     ` Baruch Siach
  0 siblings, 1 reply; 5+ messages in thread
From: rocky @ 2010-11-22 15:07 UTC (permalink / raw)
  To: linux-arm-kernel

hi,Baruch

thanks for you kindly replay;
I am still lost in this maze, so does extern "C" help user space C++ program to call schedule/printk?
sys_xxx functions are called through SWI ,not directly called from user space C++ program;

BR

rocky

At 2010-11-22 16:30:10?"Baruch Siach" <baruch@tkos.co.il> wrote:

>Hi rocky,
>
>On Sat, Nov 20, 2010 at 12:17:02PM +0800, rocky wrote:
>> I am a little confused about the following definition :
>> 
>> --------------include/linux/linkage.h-----------
>> #ifdef __cplusplus
>> #define CPP_ASMLINKAGE extern "C"
>> #else
>> #define CPP_ASMLINKAGE
>> #endif
>> 
>> #ifndef asmlinkage
>> #define asmlinkage CPP_ASMLINKAGE
>> #endif
>> 
>> all system call functions are marked with asmlinkage, as well as other kernel function like printk/schedule/do_softirq
>> 
>> 
>> so every asmlinkage function has extern "C"  attribute if cplusplus is defined, which definitely happens  when compiling C++ code.
>> 
>> I dont get it when cplusplus is needed when compiling kernel?
>
>It isn't.
>
>> Can anyone help me out of this little misunderstanding?
>
>Userspace C++ code may include kernel header files. Making the exported 
>function calls extern "C" makes it easier to build such applications.
>
>baruch
>
>-- 
>                                                     ~. .~   Tk Open Systems
>=}------------------------------------------------ooO--U--Ooo------------{=
>   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
>
>_______________________________________________
>linux-arm-kernel mailing list
>linux-arm-kernel at lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101122/a99e6519/attachment-0001.html>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Query about cplusplus in linkage.h
  2010-11-22 15:07   ` rocky
@ 2010-11-23  5:46     ` Baruch Siach
  2010-11-23  6:06       ` rocky
  0 siblings, 1 reply; 5+ messages in thread
From: Baruch Siach @ 2010-11-23  5:46 UTC (permalink / raw)
  To: linux-arm-kernel

Hi rocky,

On Mon, Nov 22, 2010 at 10:35:12PM +0800, rocky wrote:
> thanks for you kindly replay;
> I am still lost in this maze, so does extern "C" help user space C++ program to call schedule/printk?
> sys_xxx functions are called through SWI ,not directly called from user space C++ program;

It seems I was wrong. Userspace programs never call these functions directly.  
See http://kernelnewbies.org/FAQ/asmlinkage for a better answer.

baruch

> At 2010-11-22 16:30:10?"Baruch Siach" <baruch@tkos.co.il> wrote:
> 
> >Hi rocky,
> >
> >On Sat, Nov 20, 2010 at 12:17:02PM +0800, rocky wrote:
> >> I am a little confused about the following definition :
> >> 
> >> --------------include/linux/linkage.h-----------
> >> #ifdef __cplusplus
> >> #define CPP_ASMLINKAGE extern "C"
> >> #else
> >> #define CPP_ASMLINKAGE
> >> #endif
> >> 
> >> #ifndef asmlinkage
> >> #define asmlinkage CPP_ASMLINKAGE
> >> #endif
> >> 
> >> all system call functions are marked with asmlinkage, as well as other kernel function like printk/schedule/do_softirq
> >> 
> >> 
> >> so every asmlinkage function has extern "C"  attribute if cplusplus is defined, which definitely happens  when compiling C++ code.
> >> 
> >> I dont get it when cplusplus is needed when compiling kernel?
> >
> >It isn't.
> >
> >> Can anyone help me out of this little misunderstanding?
> >
> >Userspace C++ code may include kernel header files. Making the exported 
> >function calls extern "C" makes it easier to build such applications.
> >
> >baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Query about cplusplus in linkage.h
  2010-11-23  5:46     ` Baruch Siach
@ 2010-11-23  6:06       ` rocky
  0 siblings, 0 replies; 5+ messages in thread
From: rocky @ 2010-11-23  6:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, Baruch

Thanks for URL: http://kernelnewbies.org/FAQ/asmlinkage


Only two arch overide asmlinkage definitions in include/linux/linkage.h
1:arch/x86/include/asm/linkage.h
2:arch/ia64/include/asm/linkage.h
that's what the above URL say about parameter passing using STACK or REGISTER;

while I must admit  _cplusplus is  a total different story;


BR
rocky


At 2010-11-23 13:46:43?"Baruch Siach" <baruch@tkos.co.il> wrote:

>Hi rocky,
>
>On Mon, Nov 22, 2010 at 10:35:12PM +0800, rocky wrote:
>> thanks for you kindly replay;
>> I am still lost in this maze, so does extern "C" help user space C++ program to call schedule/printk?
>> sys_xxx functions are called through SWI ,not directly called from user space C++ program;
>
>It seems I was wrong. Userspace programs never call these functions directly.  
>See http://kernelnewbies.org/FAQ/asmlinkage for a better answer.
>
>baruch
>
>> At 2010-11-22 16:30:10?"Baruch Siach" <baruch@tkos.co.il> wrote:
>> 
>> >Hi rocky,
>> >
>> >On Sat, Nov 20, 2010 at 12:17:02PM +0800, rocky wrote:
>> >> I am a little confused about the following definition :
>> >> 
>> >> --------------include/linux/linkage.h-----------
>> >> #ifdef __cplusplus
>> >> #define CPP_ASMLINKAGE extern "C"
>> >> #else
>> >> #define CPP_ASMLINKAGE
>> >> #endif
>> >> 
>> >> #ifndef asmlinkage
>> >> #define asmlinkage CPP_ASMLINKAGE
>> >> #endif
>> >> 
>> >> all system call functions are marked with asmlinkage, as well as other kernel function like printk/schedule/do_softirq
>> >> 
>> >> 
>> >> so every asmlinkage function has extern "C"  attribute if cplusplus is defined, which definitely happens  when compiling C++ code.
>> >> 
>> >> I dont get it when cplusplus is needed when compiling kernel?
>> >
>> >It isn't.
>> >
>> >> Can anyone help me out of this little misunderstanding?
>> >
>> >Userspace C++ code may include kernel header files. Making the exported 
>> >function calls extern "C" makes it easier to build such applications.
>> >
>> >baruch
>
>-- 
>                                                     ~. .~   Tk Open Systems
>=}------------------------------------------------ooO--U--Ooo------------{=
>   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
>
>_______________________________________________
>linux-arm-kernel mailing list
>linux-arm-kernel at lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20101123/250d9eba/attachment-0001.html>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-23  6:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-20  4:17 Query about cplusplus in linkage.h rocky
2010-11-22  8:30 ` Baruch Siach
2010-11-22 15:07   ` rocky
2010-11-23  5:46     ` Baruch Siach
2010-11-23  6:06       ` rocky

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).