Changed 'wait' to 'wait_until' to avoid 'error: conflicting types for wait'
Added an implementation of clock_gettime for Mac