I was looking how memory barriers are used in the kernel (Linux kernel v4.19-rc5). I don't understand the difference between asm
asm and __asm__
. For example, consider barrier function:
static inline void barrier(void)
{
asm volatile("" : : : "memory");
}
This function uses asm
and volatile
keywords and it is a software barrier. On the other hand, consider a hardware barrier like this one:
#define mb() __asm__ __volatile__("mb": : :"memory")
This time, the keywords __asm__
and __volatile__
were used. What is the difference between them? I understand from this post that the difference comes from the compiler but I don't understand why both versions (__asm__
and asm
) were used in the same source code?