* [KJ] thread_info.h use kzalloc
@ 2006-07-11 16:47 tom hisch
2006-07-11 17:05 ` Nishanth Aravamudan
2006-07-11 17:09 ` Alexey Dobriyan
0 siblings, 2 replies; 3+ messages in thread
From: tom hisch @ 2006-07-11 16:47 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1.1: Type: text/plain, Size: 878 bytes --]
hello,
i have some questions about the alloc_thread_info(tsk) macro in
asm-i386/thread_info.h
/* thread information allocation */
#ifdef CONFIG_DEBUG_STACK_USAGE
#define alloc_thread_info(tsk) \
({ \
struct thread_info *ret; \
\
------> ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ // what
about the use of kzalloc ??
if (ret) \
memset(ret, 0, THREAD_SIZE); \
------> ret; \ // whats
the meaning of this instruction ??
})
#else
#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
#endif
thanks
tom hisch
[-- Attachment #1.2: Type: text/html, Size: 2728 bytes --]
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [KJ] thread_info.h use kzalloc
2006-07-11 16:47 [KJ] thread_info.h use kzalloc tom hisch
@ 2006-07-11 17:05 ` Nishanth Aravamudan
2006-07-11 17:09 ` Alexey Dobriyan
1 sibling, 0 replies; 3+ messages in thread
From: Nishanth Aravamudan @ 2006-07-11 17:05 UTC (permalink / raw)
To: kernel-janitors
On 11.07.2006 [18:47:14 +0200], tom hisch wrote:
> hello,
>
> i have some questions about the alloc_thread_info(tsk) macro in
> asm-i386/thread_info.h
>
>
> /* thread information allocation */
> #ifdef CONFIG_DEBUG_STACK_USAGE
> #define alloc_thread_info(tsk) \
> ({ \
> struct thread_info *ret; \
> \
> ------> ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ // what
> about the use of kzalloc ??
> if (ret) \
> memset(ret, 0, THREAD_SIZE); \
Probably a reasonable change.
> ------> ret; \ // whats
> the meaning of this instruction ??
> })
I think it's part of the magic of the ({ }) gcc'ism, which allows the
macro to effectively have a return value (that's how I think of it, at
least) without a return statement (in this case, the value of ret will
be stored in the corresponding lhs). I'm sure the real explanation can
be found in the gcc manual in the ({ }) section.
Thanks,
Nish
--
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [KJ] thread_info.h use kzalloc
2006-07-11 16:47 [KJ] thread_info.h use kzalloc tom hisch
2006-07-11 17:05 ` Nishanth Aravamudan
@ 2006-07-11 17:09 ` Alexey Dobriyan
1 sibling, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2006-07-11 17:09 UTC (permalink / raw)
To: kernel-janitors
On Tue, Jul 11, 2006 at 06:47:14PM +0200, tom hisch wrote:
> i have some questions about the alloc_thread_info(tsk) macro in
> asm-i386/thread_info.h
> /* thread information allocation */
> #ifdef CONFIG_DEBUG_STACK_USAGE
> #define alloc_thread_info(tsk) \
> ({ \
> struct thread_info *ret; \
> \
> ------> ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ // what
> about the use of kzalloc ??
> if (ret) \
> memset(ret, 0, THREAD_SIZE); \
Indeed it should be kzalloc.
> ------> ret; \ // whats
> the meaning of this instruction ??
> })
That's GNU extension meaning that value of this block equals to "ret" at
that point. It should be more or less equivalent to
static inline struct thread_info *alloc_thread_info(struct task_struct *task)
{
return kzalloc(THREAD_SIZE, GFP_KERNEL);
}
> #else
> #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
> #endif
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-07-11 17:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-11 16:47 [KJ] thread_info.h use kzalloc tom hisch
2006-07-11 17:05 ` Nishanth Aravamudan
2006-07-11 17:09 ` Alexey Dobriyan
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.