Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifdef _WIN32
  2.  
  3. #include <time.h>
  4. #include <winsock2.h>
  5. #include <windows.h>
  6.  
  7. #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
  8. #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
  9. #else
  10. #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
  11. #endif
  12.  
  13. struct timeval;
  14.  
  15. int gettimeofday(struct timeval *tv, struct timezone *tz)
  16. {
  17.         FILETIME ft;
  18.         unsigned __int64 tmpres = 0;
  19.  
  20.         if (tv)
  21.         {
  22.                 GetSystemTimeAsFileTime(&ft);
  23.  
  24.                 tmpres |= ft.dwHighDateTime;
  25.                 tmpres <<= 32;
  26.                 tmpres |= ft.dwLowDateTime;
  27.  
  28.                 tmpres /= 10; /*convert into microseconds*/
  29.                 /*converting file time to unix epoch*/
  30.                 tmpres -= DELTA_EPOCH_IN_MICROSECS;
  31.                 tv->tv_sec = (long)(tmpres / 1000000UL);
  32.                 tv->tv_usec = (long)(tmpres % 1000000UL);
  33.         }
  34.  
  35.         return 0;
  36. }
  37.  
  38. #else
  39.  
  40. void fz_gettimeofday_dummy() { }
  41.  
  42. #endif
  43.