Add necessary critical sections to microtime() and nanotime().