src/emulation/emulation.cc
/*
 * Subtracts the first time from the second time, storing the result in res.
 *
 * Assumes the first time is greater than the second time.
 */
Subtracts the first time from the second time, storing the result in res.
Assumes the first time is greater than the second time.
Subtracts the first time from the second time storing the result in res . Assumes the first time is greater than the second time .
void Emulation::TimeDiff(EmuTime *time1, EmuTime *time2, EmuTime *res) {
  CONTRACT(TimeGt(time1, time2));
  if (time1->tv_nsec < time2->tv_nsec) {
    time1->tv_nsec += NSECS_PER_SEC;
    time1->tv_sec--;
  }
  res->tv_sec = time1->tv_sec - time2->tv_sec;
  res->tv_nsec = time1->tv_nsec - time2->tv_nsec;
  return;
}
void Emulation :: TimeDiff ( EmuTime * time1 , EmuTime * time2 , EmuTime * res ) { CONTRACT ( TimeGt ( time1 , time2 ) ) ; if ( time1 -> tv_nsec < time2 -> tv_nsec ) { time1 -> tv_nsec += NSECS_PER_SEC ; time1 -> tv_sec -- ; } res -> tv_sec = time1 -> tv_sec - time2 -> tv_sec ; res -> tv_nsec = time1 -> tv_nsec - time2 -> tv_nsec ; return ; }
Subtracts the first time from the second time, storing the result in res.
Subtracts the first time from the second time storing the result in res .
// Borrow from the seconds in nanoseconds, if needed. // Calculate the difference.