This snippet is neither MASM, nor GAS, nor NASM, etc. This is an inline assembly , and the syntax is documented in the C compiler documentation.
The syntax is complex, even if you are already familiar with a clean assembly, because it should indicate how to connect part C to the part of the assembly and vice versa.
asm volatile("" :: "m" (buf)); operator asm volatile("" :: "m" (buf)); it is usually an empty assembly bit (not noop, but the actual lack of instructions), with binding instructions such as "m" that make the sum of the operator a memory barrier from the point of view of the C compiler.
EDIT: StackOverflow Jester's comment under the now deleted answer says that the purpose of the statement is to prevent buf , and therefore the alloca call, which will be optimized by the compiler, pretending to read assembly code from it "" .
I believe that the C11 standard offers cleaner ways to express memory barriers, but I have not yet had the opportunity to investigate. In any case, as a way to specify a memory barrier, the above could be a way of targeting "GCC and compilers that aim for GCC compatibility, even if they are a bit old," as a wider set of compilers than C compilers that correctly implement all C11 standard ". Actually, the C11 Wikipedia page cites asm volatile ("" : : : "memory"); as an example when discussing memory barriers.
source share