win_func.h 506 B

12345678910111213141516171819202122232425262728
  1. #include <time.h>
  2. #ifdef WIN32
  3. #include <windows.h>
  4. #else
  5. #include <sys/time.h>
  6. #endif
  7. #ifdef WIN32
  8. int gettimeofday(struct timeval* tp, void* tzp)
  9. {
  10. time_t clock;
  11. struct tm tm;
  12. SYSTEMTIME wtm;
  13. GetLocalTime(&wtm);
  14. tm.tm_year = wtm.wYear - 1900;
  15. tm.tm_mon = wtm.wMonth - 1;
  16. tm.tm_mday = wtm.wDay;
  17. tm.tm_hour = wtm.wHour;
  18. tm.tm_min = wtm.wMinute;
  19. tm.tm_sec = wtm.wSecond;
  20. tm.tm_isdst = -1;
  21. clock = mktime(&tm);
  22. tp->tv_sec = clock;
  23. tp->tv_usec = wtm.wMilliseconds * 1000;
  24. return (0);
  25. }
  26. #endif