[Cmake-commits] CMake branch, master, updated. v2.8.5-137-g74e1156

KWSys Robot kwrobot at kitware.com
Wed Aug 3 14:50:06 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  74e1156bc292f45dd376d6324fbf13aa2de539b7 (commit)
      from  14e54c4c449e2704799ab5283c6c6764472d5a0a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=74e1156bc292f45dd376d6324fbf13aa2de539b7
commit 74e1156bc292f45dd376d6324fbf13aa2de539b7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Aug 3 14:48:48 2011 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Aug 3 14:50:04 2011 -0400

    KWSys: Simplify SystemTools::GetTime implementation (#12261)
    
    We already use GetSystemTimeAsFileTime() and gettimeofday()
    unconditionally on supported Windows and non-Windows platforms,
    respectively.  Remove outdated portability complexity.

diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index eefa7f5..d1f1591 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -56,6 +56,7 @@
 
 // support for realpath call
 #ifndef _WIN32
+#include <sys/time.h>
 #include <utime.h>
 #include <limits.h>
 #include <sys/wait.h>
@@ -281,71 +282,29 @@ extern int putenv (char *__string) __THROW;
 }
 #endif
 
-/* Implement floattime() for various platforms */
-// Taken from Python 2.1.3
-
-#if defined( _WIN32 ) && !defined( __CYGWIN__ )
-#  include <sys/timeb.h>
-#  define HAVE_FTIME
-#  if defined( __BORLANDC__)
-#    define FTIME ftime
-#    define TIMEB timeb
-#  else // Visual studio?
-#    define FTIME _ftime
-#    define TIMEB _timeb
-#  endif
-#elif defined( __CYGWIN__ ) || defined( __linux__ ) || defined(__APPLE__)
-#  include <sys/time.h>
-#  include <time.h>
-#  define HAVE_GETTIMEOFDAY
-#endif
-
 namespace KWSYS_NAMESPACE
 {
 
+double SystemTools::GetTime(void)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  FILETIME ft;
+  GetSystemTimeAsFileTime(&ft);
+  return (429.4967296*ft.dwHighDateTime
+          + 0.0000001*ft.dwLowDateTime
+          - 11644473600.0);
+#else
+  struct timeval t;
+  gettimeofday(&t, 0);
+  return 1.0*t.tv_sec + 0.000001*t.tv_usec;
+#endif
+}
+
 class SystemToolsTranslationMap : 
     public kwsys_stl::map<kwsys_stl::string,kwsys_stl::string>
 {
 };
 
-
-double
-SystemTools::GetTime(void)
-{
-  /* There are three ways to get the time:
-     (1) gettimeofday() -- resolution in microseconds
-     (2) ftime() -- resolution in milliseconds
-     (3) time() -- resolution in seconds
-     In all cases the return value is a float in seconds.
-     Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
-     fail, so we fall back on ftime() or time().
-     Note: clock resolution does not imply clock accuracy! */
-#ifdef HAVE_GETTIMEOFDAY
-  {
-  struct timeval t;
-#ifdef GETTIMEOFDAY_NO_TZ
-  if (gettimeofday(&t) == 0)
-#else /* !GETTIMEOFDAY_NO_TZ */
-  if (gettimeofday(&t, static_cast<struct timezone *>(NULL)) == 0)
-#endif /* !GETTIMEOFDAY_NO_TZ */
-    return static_cast<double>(t.tv_sec) +
-      static_cast<double>(t.tv_usec)*0.000001;
-  }
-#endif /* !HAVE_GETTIMEOFDAY */
-  {
-#if defined(HAVE_FTIME)
-  struct TIMEB t;
-  ::FTIME(&t);
-  return static_cast<double>(t.time) +
-    static_cast<double>(t.millitm) * static_cast<double>(0.001);
-#else /* !HAVE_FTIME */
-  time_t secs;
-  time(&secs);
-  return static_cast<double>(secs);
-#endif /* !HAVE_FTIME */
-  }
-}
-
 // adds the elements of the env variable path to the arg passed in
 void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env)
 {
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index cf47923..fd2ed19 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -690,13 +690,7 @@ public:
    *  -----------------------------------------------------------------
    */
 
-  /**
-   * Get current time as a double. On certain platforms this will
-   * return higher resolution than seconds:
-   * (1) gettimeofday() -- resolution in microseconds
-   * (2) ftime() -- resolution in milliseconds
-   * (3) time() -- resolution in seconds
-   */
+  /** Get current time in seconds since Posix Epoch (Jan 1, 1970).  */
   static double GetTime();
 
   /**

-----------------------------------------------------------------------

Summary of changes:
 Source/kwsys/SystemTools.cxx    |   73 ++++++++------------------------------
 Source/kwsys/SystemTools.hxx.in |    8 +----
 2 files changed, 17 insertions(+), 64 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list