kthread_run -- 最后一条语句的目的 (__k;)

wor*_*nga 3 c linux-kernel

我正在阅读 linux 内核,特别是我正在查看进程创建并偶然发现了以下宏 [1]

/**
 * kthread_run - create and wake a thread.
 * @threadfn: the function to run until signal_pending(current).
 * @data: data ptr for @threadfn.
 * @namefmt: printf-style name for the thread.
 *
 * Description: Convenient wrapper for kthread_create() followed by
 * wake_up_process().  Returns the kthread or ERR_PTR(-ENOMEM).
 */
#define kthread_run(threadfn, data, namefmt, ...)              \
({                                     \
    struct task_struct *__k                        \
        = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
    if (!IS_ERR(__k))                          \
        wake_up_process(__k);                      \
    __k;                                   \
})
Run Code Online (Sandbox Code Playgroud)

我的问题很简单:最后一行 : 的目的是什么__k;

[1] http://lxr.free-electrons.com/source/include/linux/kthread.h#L31

Ric*_*ton 5

该宏是一个语句表达式。__k 是返回值(线程指针)。语句表达式是一个 GCC 扩展,clang 也支持它。