term: replace gettimeofday()

gettimeofday() is not portable, replace with os_hrtime() wherever possible.
The new code should behave equivalently to the old implementation.
cmake: remove check for gettimeofday

There are no more uses of gettimeofday, so remove the check in CMake.