Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.2 KiB

  1. // timemath.h---written by Bill Griffin (Billgr)
  2. #if !defined(_TIMEMATH_H_)
  3. #define _TIMEMATH_H_
  4. const __int64 hnsPerMillisecond = 10000i64;
  5. const __int64 hnsPerSecond = 10000000i64;
  6. const __int64 hnsPerMinute = 600000000i64;
  7. const __int64 hnsPerHour = 36000000000i64;
  8. const __int64 hnsPerDay = 864000000000i64;
  9. inline __int64 MsFromHns(__int64 hns)
  10. { return hns / hnsPerMillisecond; }
  11. inline __int64 SecFromHns(__int64 hns)
  12. { return hns / hnsPerSecond; }
  13. inline __int64 MinFromHns(__int64 hns)
  14. { return hns / hnsPerMinute; }
  15. inline __int64 HrFromHns(__int64 hns)
  16. { return hns / hnsPerHour; }
  17. inline __int64 DayFromHns(__int64 hns)
  18. { return hns / hnsPerDay; }
  19. inline __int64 HnsFromMs(__int64 ms)
  20. { return ms * hnsPerMillisecond; }
  21. inline __int64 HnsFromSec(__int64 sec)
  22. { return sec * hnsPerSecond; }
  23. inline __int64 HnsFromMin(__int64 min)
  24. { return min * hnsPerMinute; }
  25. inline __int64 HnsFromHr(__int64 hr)
  26. { return hr * hnsPerHour; }
  27. inline __int64 HnsFromDay(__int64 day)
  28. { return day * hnsPerDay; }
  29. inline __int64 HnsFromFt(FILETIME ft)
  30. { return *((__int64*)&ft); }
  31. inline __int64 HnsFromFtSpan(FILETIME ftStart, FILETIME ftEnd)
  32. { return HnsFromFt(ftEnd) - HnsFromFt(ftStart); }
  33. inline __int64 SecFromFtSpan(FILETIME ftStart, FILETIME ftEnd)
  34. { return SecFromHns(HnsFromFtSpan(ftStart, ftEnd)); }
  35. inline __int64 MinFromFtSpan(FILETIME ftStart, FILETIME ftEnd)
  36. { return MinFromHns(HnsFromFtSpan(ftStart, ftEnd)); }
  37. inline __int64 HrFromFtSpan(FILETIME ftStart, FILETIME ftEnd)
  38. { return HrFromHns(HnsFromFtSpan(ftStart, ftEnd)); }
  39. inline __int64 DayFromFtSpan(FILETIME ftStart, FILETIME ftEnd)
  40. { return DayFromHns(HnsFromFtSpan(ftStart, ftEnd)); }
  41. //NimishK - some more good stuff related to the time math issues
  42. #define I64_LI(cli) (*((__int64*)&cli))
  43. #define LI_I64(i) (*((LARGE_INTEGER*)&i))
  44. #define INT64_FROM_LARGE_INTEGER(cli) I64_LI(cli)
  45. #define LARGE_INTEGER_FROM_INT64(i) LI_I64(i)
  46. #define I64_FT(ft) (*((__int64*)&ft))
  47. #define FT_I64(i) (*((FILETIME*)&i))
  48. #define INT64_FROM_FILETIME(ft) I64_FT(ft)
  49. #define FILETIME_FROM_INT64(i) FT_I64(i)
  50. #endif // !defined(_TIMEMATH_H_)