I realized that stdout was acquiring and releasing a mutex on every write operation; fixing that improved things. The good news is that when writing to /dev/null, it's now faster than the C++ version, but writing to stdout is still ~25% slower. I suppose there's something else suboptimal about the way I'm using stdout, but I haven't figured it out yet.
Code is here: https://gist.github.com/usefulcat/56f334bc58c97edb073b457b68...
There is actually one other file but it only contains a couple of struct definitions for the libpcap file and packet headers. Thanks for having a look!