gettimeofday.c.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. gettimeofday.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='GetProperty.c.html' title=' GetProperty.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='gpioinfo.c.html' title=' gpioinfo.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * gettimeofday.c - get time of day for Windows;
  24. *
  25. * A gettimeofday implementation for Microsoft Windows;
  26. *
  27. * Public domain code, author &quot;ponnada&quot;;
  28. *
  29. *--------------------------------------------------------------------*/
  30. #ifndef GETTIMEOFDAY_SOURCE
  31. #define GETTIMEOFDAY_SOURCE
  32. #include &lt;time.h&gt;
  33. #include &lt;windows.h&gt;
  34. #include &lt;sys/time.h&gt;
  35. int gettimeofday (struct timeval *tv, struct timezone *tz)
  36. {
  37. FILETIME ft;
  38. unsigned __int64 tmpres = 0;
  39. static int tzflag = 0;
  40. if (NULL != tv)
  41. {
  42. GetSystemTimeAsFileTime (&amp;ft);
  43. tmpres |= ft.dwHighDateTime;
  44. tmpres &lt;&lt;= 32;
  45. tmpres |= ft.dwLowDateTime;
  46. tmpres /= 10;
  47. tmpres -= DELTA_EPOCH_IN_MICROSECS;
  48. tv-&gt;tv_sec = (long)(tmpres / 1000000UL);
  49. tv-&gt;tv_usec = (long)(tmpres % 1000000UL);
  50. }
  51. if (NULL != tz)
  52. {
  53. if (!tzflag)
  54. {
  55. _tzset ();
  56. tzflag++;
  57. }
  58. tz-&gt;tz_minuteswest = _timezone / 60;
  59. tz-&gt;tz_dsttime = _daylight;
  60. }
  61. return 0;
  62. }
  63. #endif
  64. </pre>
  65. <div class='footerlink'>
  66. [<a href='GetProperty.c.html' title=' GetProperty.c '>PREV</a>]
  67. [<a href='toolkit.html' title=' Index '>HOME</a>]
  68. [<a href='gpioinfo.c.html' title=' gpioinfo.c '>NEXT</a>]
  69. </div>
  70. </body>
  71. </html>