/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Google Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile, Inc.
*
#if OS(WINDOWS)
-// Windows is first since we want to use hires timers, despite PLATFORM(CF)
+// Windows is first since we want to use hires timers, despite USE(CF)
// being defined.
// If defined, WIN32_LEAN_AND_MEAN disables timeBeginPeriod/timeEndPeriod.
#undef WIN32_LEAN_AND_MEAN
#endif
#endif
-#elif PLATFORM(CF)
-#include <CoreFoundation/CFDate.h>
#elif PLATFORM(GTK)
#include <glib.h>
#elif PLATFORM(WX)
#include <wx/datetime.h>
-#else // Posix systems relying on the gettimeofday()
+#elif PLATFORM(BREWMP)
+#include <AEEStdLib.h>
+#else
#include <sys/time.h>
#endif
// QueryPerformanceCounter has high resolution, but is only usable to measure time intervals.
// To combine them, we call ftime and QueryPerformanceCounter initially. Later calls will use QueryPerformanceCounter
// by itself, adding the delta to the saved ftime. We periodically re-sync to correct for drift.
- static bool started;
static double syncLowResUTCTime;
static double syncHighResUpTime;
static double lastUTCTime;
#endif // USE(QUERY_PERFORMANCE_COUNTER)
-#elif PLATFORM(CF)
-
-double currentTime()
-{
- return CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970;
-}
-
#elif PLATFORM(GTK)
// Note: GTK on Windows will pick up the PLATFORM(WIN) implementation above which provides
return (double)now.GetTicks() + (double)(now.GetMillisecond() / 1000.0);
}
-#else // Other Posix systems rely on the gettimeofday().
+#elif PLATFORM(BREWMP)
+// GETUTCSECONDS returns the number of seconds since 1980/01/06 00:00:00 UTC,
+// and GETTIMEMS returns the number of milliseconds that have elapsed since the last
+// occurrence of 00:00:00 local time.
+// We can combine GETUTCSECONDS and GETTIMEMS to calculate the number of milliseconds
+// since 1970/01/01 00:00:00 UTC.
double currentTime()
{
- struct timeval now;
- struct timezone zone;
+ // diffSeconds is the number of seconds from 1970/01/01 to 1980/01/06
+ const unsigned diffSeconds = 315964800;
+ return static_cast<double>(diffSeconds + GETUTCSECONDS() + ((GETTIMEMS() % 1000) / msPerSecond));
+}
+
+#else
- gettimeofday(&now, &zone);
- return static_cast<double>(now.tv_sec) + (double)(now.tv_usec / 1000000.0);
+double currentTime()
+{
+ struct timeval now;
+ gettimeofday(&now, 0);
+ return now.tv_sec + now.tv_usec / 1000000.0;
}
#endif