move timeval to common code