compat: enable building on OS X

OS X lacks some Linux (and recent POSIX) specific functionality; implement
the required OS X equivalents in compat.h and add OS X Makefile rules in
compat.mk.

Switched tests to use CLOCK_REALTIME as they don't really need monotonic
clock for anything and it makes compatibility easier.

In the Python CFFI wrapper, load the .dylib module on darwin.