Esempio n. 1
0
inline nanospan nanotime()
{

#if defined(HAVE_CLOCK_GETTIME_FUNC)
  timespec ts;
  if ( -1 == clock_gettime(CLOCK_MONOTONIC, &ts) )
    return nanospan();
  return nanospan(ts.tv_sec, ts.tv_nsec);
#elif defined(HAVE_GETTIMEOFDAY_FUNC)
  timeval tv;
  ::gettimeofday(&tv, 0);
  return nanospan(tv.tv_sec, tv.tv_usec*1000L);
#elif defined(HAVE__FTIME_S_FUNC)
  struct _timeb timebuffer;
  _ftime_s( &timebuffer );
  return millispan(static_cast<xsec_t>(timebuffer.time), static_cast<xsec_t>(timebuffer.millitm) );
#elif defined(HAVE__FTIME_FUNC)
  struct _timeb timebuffer;
  _ftime( &timebuffer );
  return millispan(static_cast<xsec_t>(timebuffer.time), static_cast<xsec_t>(timebuffer.millitm) );
#elif defined(HAVE_FTIME_FUNC)
	struct timeb timebuffer;
	ftime( &timebuffer );
	return millispan(static_cast<xsec_t>(timebuffer.time), static_cast<xsec_t>(timebuffer.millitm) );
#else
#error FAIL
#endif //HAVE_CLOCK_GETTIME_FUNC
  return nanospan(0, 0);
}
Esempio n. 2
0
inline nanospan operator * (const nanospan& s, const nanospan& f)
{
  if ( f.xsec == 0)
  {
    xsec_t xsec = s.to_nanosec()*f.sec;
    return nanospan(
          static_cast<xsec_t> ( xsec / FAS_NANOSEC ),
          static_cast<xsec_t> ( xsec % FAS_NANOSEC )
    );
  }
  else
    return nanospan( s.to_double() * f.to_double() );
}
Esempio n. 3
0
inline nanospan operator + (const nanospan& f,  const nanospan& s)
{
  bool flag = (f.xsec + s.xsec >= FAS_NANOSEC);
  return nanospan(
    f.sec + s.sec + flag,
    f.xsec + s.xsec - flag * FAS_NANOSEC
  );
}
Esempio n. 4
0
inline nanospan operator - (const nanospan& f,  const nanospan& s)
{
  bool flag = f.xsec < s.xsec;
  return nanospan(
    f.sec - s.sec - flag,
    f.xsec - s.xsec + flag * FAS_NANOSEC
  );
}
Esempio n. 5
0
inline nanospan operator + (const nanospan& f,  const nanospan& s)
{
  return f.xsec + s.xsec >= FAS_NANOSEC
        ? nanospan( f.sec + s.sec + 1, f.xsec + s.xsec - FAS_NANOSEC )
        : nanospan( f.sec + s.sec, f.xsec + s.xsec );
}
Esempio n. 6
0
inline nanospan operator - (const nanospan& f,  const nanospan& s)
{
  return f.xsec < s.xsec
         ? nanospan( f.sec - s.sec - 1, f.xsec - s.xsec + FAS_NANOSEC )
         : nanospan( f.sec - s.sec, f.xsec - s.xsec);
}