use of asm volatile in Linux kernel

Viewed 36

I am reading the Linux kernel code, and I have a hard time understanding a macro involving asm volatile.

There is a macro current which returns a pointer to the currently running process. I want to understand how the code works. I am stuck at the line

ENTRY(pcurrent)

Here ENTRY is defined as

#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))

DEFINE is defined as

#define DEFINE(sym, val) \
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))

As far as I know, the '\n' in the definition of DEFINE may be used to separate assembly instructions, but I do not know why there is a '->'. If possible, could anyone also explain the logic behind the implementation?

0 Answers
Related