* DEFINE Macro
@ 2012-01-06 3:32 Fredrick
2012-01-06 6:12 ` mypopy at gmail.com
2012-01-06 14:09 ` Josh Cartwright
0 siblings, 2 replies; 4+ messages in thread
From: Fredrick @ 2012-01-06 3:32 UTC (permalink / raw)
To: kernelnewbies
Hi,
I am not able to understand the DEFINE macro used in
arch/powerpc/kernel/asm-offsets.c
I suppose the DEFINE is present in
include/linux/kbuild.h
where it says
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
What does the above mean?
-Fredrick
^ permalink raw reply [flat|nested] 4+ messages in thread
* DEFINE Macro
2012-01-06 3:32 DEFINE Macro Fredrick
@ 2012-01-06 6:12 ` mypopy at gmail.com
2012-01-06 14:09 ` Josh Cartwright
1 sibling, 0 replies; 4+ messages in thread
From: mypopy at gmail.com @ 2012-01-06 6:12 UTC (permalink / raw)
To: kernelnewbies
? 2012?1?6? ??11:32?Fredrick <fjohnber@zoho.com>???
> Hi,
>
> I am not able to understand the DEFINE macro used in
> arch/powerpc/kernel/asm-offsets.c
>
> I suppose the DEFINE is present in
> include/linux/kbuild.h
> where it says
> #define DEFINE(sym, val) \
> asm volatile("\n->" #sym " %0 " #val : : "i" (val))
>
> What does the above mean?
>
>
> -Fredrick
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
Oh, This is the inline ASM in gcc, pls refer to
http://ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
--
=======================================
Pixelworks
Room 301-303 No. 88,Lane 887 Zuchongzhi Road, Zhangjiang Hi-tech Park,
Shanghai 201203, China
Best Regards,
Jun zhao/??
+++++++++++++++++++++++++++++++++++++++
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120106/41389c9d/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* DEFINE Macro
2012-01-06 3:32 DEFINE Macro Fredrick
2012-01-06 6:12 ` mypopy at gmail.com
@ 2012-01-06 14:09 ` Josh Cartwright
2012-01-06 16:09 ` Fredrick
1 sibling, 1 reply; 4+ messages in thread
From: Josh Cartwright @ 2012-01-06 14:09 UTC (permalink / raw)
To: kernelnewbies
On Thu, Jan 05, 2012 at 07:32:48PM -0800, Fredrick wrote:
> Hi,
>
> I am not able to understand the DEFINE macro used in
> arch/powerpc/kernel/asm-offsets.c
>
> I suppose the DEFINE is present in
> include/linux/kbuild.h
> where it says
> #define DEFINE(sym, val) \
> asm volatile("\n->" #sym " %0 " #val : : "i" (val))
>
> What does the above mean?
This is just a trick to get the offsets of members into a generated header file
asm-offsets.h. The inline assembly does NOT contain valid instructions,
and in fact, asm-offsets.c is never actually assembled into a program.
Instead, the build process generates the assembly language output
asm-offsets.s, and processes it with a sed script to generate
asm-offsets.h.
For example (assume offsetof(struct thread_struct, regs) is 30):
DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
will generate within the assembly language output:
->PT_REGS $30 offsetof(struct thread_struct, regs)
A sed script, executed on the assembly language output will generate a
line in include/generated/asm-offsets.h:
#define PT_REGS 30 /* offsetof(struct thread_struct, regs) */
Thats about it. You can find the exact sed script used, and the make
magic involved in Kbuild (see cmd_offsets).
--
joshc
^ permalink raw reply [flat|nested] 4+ messages in thread
* DEFINE Macro
2012-01-06 14:09 ` Josh Cartwright
@ 2012-01-06 16:09 ` Fredrick
0 siblings, 0 replies; 4+ messages in thread
From: Fredrick @ 2012-01-06 16:09 UTC (permalink / raw)
To: kernelnewbies
Nice! Thanks for the explanation Josh.
-Fredrick
On 01/06/2012 06:09 AM, Josh Cartwright wrote:
> On Thu, Jan 05, 2012 at 07:32:48PM -0800, Fredrick wrote:
>> Hi,
>>
>> I am not able to understand the DEFINE macro used in
>> arch/powerpc/kernel/asm-offsets.c
>>
>> I suppose the DEFINE is present in
>> include/linux/kbuild.h
>> where it says
>> #define DEFINE(sym, val) \
>> asm volatile("\n->" #sym " %0 " #val : : "i" (val))
>>
>> What does the above mean?
>
> This is just a trick to get the offsets of members into a generated header file
> asm-offsets.h. The inline assembly does NOT contain valid instructions,
> and in fact, asm-offsets.c is never actually assembled into a program.
> Instead, the build process generates the assembly language output
> asm-offsets.s, and processes it with a sed script to generate
> asm-offsets.h.
>
> For example (assume offsetof(struct thread_struct, regs) is 30):
>
> DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
>
> will generate within the assembly language output:
>
> ->PT_REGS $30 offsetof(struct thread_struct, regs)
>
> A sed script, executed on the assembly language output will generate a
> line in include/generated/asm-offsets.h:
>
> #define PT_REGS 30 /* offsetof(struct thread_struct, regs) */
>
> Thats about it. You can find the exact sed script used, and the make
> magic involved in Kbuild (see cmd_offsets).
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-06 16:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-06 3:32 DEFINE Macro Fredrick
2012-01-06 6:12 ` mypopy at gmail.com
2012-01-06 14:09 ` Josh Cartwright
2012-01-06 16:09 ` Fredrick
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).