+ // If possible, use a function which avoids conversions from
+ // broken-up time structures to milliseconds
+#if defined(__WINDOWS__)
+ FILETIME ft;
+ ::GetSystemTimeAsFileTime(&ft);
+
+ // FILETIME is expressed in 100ns (or 0.1us) units since 1601-01-01,
+ // transform them to ms since 1970-01-01.
+ wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime);
+ t /= 10000;
+ t -= wxLL(11644473600000); // Unix - Windows epochs difference in ms.
+ return t;
+#else // !__WINDOWS__
+ wxLongLong val = MILLISECONDS_PER_SECOND;
+
+#if defined(HAVE_GETTIMEOFDAY)
+ struct timeval tp;
+ if ( wxGetTimeOfDay(&tp) != -1 )
+ {
+ val *= tp.tv_sec;
+ return (val + (tp.tv_usec / MICROSECONDS_PER_MILLISECOND));
+ }
+ else
+ {
+ wxLogError(_("wxGetTimeOfDay failed."));
+ return 0;
+ }
+#elif defined(HAVE_FTIME)
+ struct timeb tp;
+
+ // ftime() is void and not int in some mingw32 headers, so don't
+ // test the return code (well, it shouldn't fail anyhow...)
+ (void)::ftime(&tp);
+ val *= tp.time;
+ return (val + tp.millitm);
+#else // no gettimeofday() nor ftime()
+ // If your platform/compiler does not support ms resolution please
+ // do NOT just shut off these warnings, drop me a line instead at
+ // <guille@iies.es>
+
+ #if defined(__VISUALC__) || defined (__WATCOMC__)
+ #pragma message("wxStopWatch will be up to second resolution!")
+ #elif defined(__BORLANDC__)
+ #pragma message "wxStopWatch will be up to second resolution!"
+ #else
+ #warning "wxStopWatch will be up to second resolution!"
+ #endif // compiler