This surely has portability problems and is ugly since it works with three different representations (timeout in milliseconds, deadline as timeval, deadline as timespec).
Also, this is completely untested. But at least its a start.
Related to #38
Anyone who wants is free to pick this up and do it properly.
For the public API, I was thinking on whether this should be a timeout
(as it is now) or a deadline (
struct timeval / timespec). I only picked
the timeout so that no structs from
sys/time.h appear in the public
API. No idea if that was a good choice.