For my Linux networking application, I am referring to lincap.c to understand how to use the PACKET_MMAP method of receiving Ethernet packets via a ring buffer.
lincap.c uses the memory barrier macro mb() defined in asm/system.h. However, the code in that header file is embraced by #ifdef __KERNEL__. I guess that means it is a kernel header file. How can I use mb() from a user space application (which I believe lincap.c is)?
BR
David
Perhaps you can use the
__sync_synchronizebuiltin gcc provides. I’m not sure whether it generates exactly the same code, but it should be similar enough in effect. So simply definingmbas an alias to that should work.