Welcome! Log In Create A New Profile


kthread_run macro

Posted by RichardMc 
kthread_run macro
October 03, 2013 10:02PM
In the kthread_run() macro, the last line just has "__k" on it...

#define kthread_run(threadfn, data, namefmt, ...)
struct task_struct *__k
= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__);
if (!IS_ERR(__k))

It took me a while to work out what this might be achieving, but my thoughts are that the outer ({ and }) make the contents of the macro a compound statement expression and the sub-expression on the last line (__k) serves as the final value of the whole construct (in some ways like a return value in a function).

In other words, this would allow (in the "calling" code) something like :

struct task_struct *xyz = kthread_run(insert, parameters, here ...)

That is, having the "__k" on the last line of the macro allows whatever kthread_create() has returned (and stored in the variable __k) to be assigned to a variable in the code which "calls" the kthread_run() macro.

Could someone confirm this ?

Your Email:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 5 plus 23?