gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog gui/gui.cpp libbase/Makefile.am...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog gui/gui.cpp libbase/Makefile.am...
Date: Mon, 07 Apr 2008 10:59:28 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/04/07 10:59:27

Modified files:
        .              : ChangeLog 
        gui            : gui.cpp 
        libbase        : Makefile.am WallClockTimer.cpp 
        server         : SystemClock.cpp 
        server/asobj   : Date.cpp NetStreamFfmpeg.cpp 
        utilities      : processor.cpp 
Added files:
        libbase        : ClockTime.cpp ClockTime.h 
Removed files:
        libbase        : Time.cpp Time.h 

Log message:
        Another go at fixing w32 build. Renamed Time files to ClockTime. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6197&r2=1.6198
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.146&r2=1.147
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/WallClockTimer.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ClockTime.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ClockTime.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Time.cpp?cvsroot=gnash&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Time.h?cvsroot=gnash&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/server/SystemClock.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.cpp?cvsroot=gnash&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.110&r2=1.111
http://cvs.savannah.gnu.org/viewcvs/gnash/utilities/processor.cpp?cvsroot=gnash&r1=1.93&r2=1.94

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6197
retrieving revision 1.6198
diff -u -b -r1.6197 -r1.6198
--- ChangeLog   7 Apr 2008 09:22:09 -0000       1.6197
+++ ChangeLog   7 Apr 2008 10:59:25 -0000       1.6198
@@ -1,5 +1,15 @@
 2008-04-07 Benjamin Wolsey <address@hidden>
 
+       * libbase/Time.{cpp,h}: renamed.
+       * libbase/ClockTime.{cpp,h}: renamed from Time.{cpp,h}.
+       * libbase/Makefile.am: reflect name change.
+       * libbase/WallClockTimer.cpp, server/SystemClock.cpp,
+         utilities/processor.cpp, gui/gui.cpp,
+         server/asobj/NetStreamFfmpeg.cpp, server/asobj/Date.cpp: update
+         includes.
+
+2008-04-07 Benjamin Wolsey <address@hidden>
+
        * server/asobj/Date.cpp: add getUTCYear(), fix setMilliseconds,
          fix setFullYear.
        * testsuite/actionscript.all/Date.as: drop tests that vary according

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -b -r1.146 -r1.147
--- gui/gui.cpp 7 Apr 2008 07:42:38 -0000       1.146
+++ gui/gui.cpp 7 Apr 2008 10:59:26 -0000       1.147
@@ -31,7 +31,7 @@
 #include "VM.h"
 
 #ifdef GNASH_FPS_DEBUG
-#include "Time.h"
+#include "ClockTime.h"
 #endif
 
 #include <cstdio>

Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- libbase/Makefile.am 6 Apr 2008 17:48:30 -0000       1.106
+++ libbase/Makefile.am 7 Apr 2008 10:59:26 -0000       1.107
@@ -89,7 +89,7 @@
        string_table.cpp \
        tu_file.cpp \
        $(SDL_FILE) \
-       Time.cpp \
+       ClockTime.cpp \
        WallClockTimer.cpp \
        utf8.cpp \
        utility.cpp \
@@ -128,7 +128,7 @@
        tu_file.h \
        tu_math.h \
        tu_opengl_includes.h \
-       Time.h \
+       ClockTime.h \
        WallClockTimer.h \
        utf8.h \
        utility.h \

Index: libbase/WallClockTimer.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/WallClockTimer.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libbase/WallClockTimer.cpp  6 Apr 2008 17:48:31 -0000       1.5
+++ libbase/WallClockTimer.cpp  7 Apr 2008 10:59:27 -0000       1.6
@@ -23,7 +23,7 @@
 #endif
 
 #include "WallClockTimer.h"
-#include "Time.h" // for "portable" get_ticks (contains implementation for 
win32)
+#include "ClockTime.h" // for "portable" get_ticks (contains implementation 
for win32)
 
 namespace gnash {
 

Index: server/SystemClock.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/SystemClock.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/SystemClock.cpp      6 Apr 2008 17:48:31 -0000       1.4
+++ server/SystemClock.cpp      7 Apr 2008 10:59:27 -0000       1.5
@@ -23,7 +23,7 @@
 
 #include "SystemClock.h"
 
-#include "Time.h" // for fetchSystemTime
+#include "ClockTime.h" // for getting system time
 
 #include <boost/cstdint.hpp> // for boost::uint64_t typedef
 

Index: server/asobj/Date.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Date.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- server/asobj/Date.cpp       7 Apr 2008 09:22:10 -0000       1.62
+++ server/asobj/Date.cpp       7 Apr 2008 10:59:27 -0000       1.63
@@ -76,7 +76,7 @@
 #include "GnashException.h"
 #include "builtin_function.h"
 #include "Object.h" // for getObjectInterface
-#include "Time.h"
+#include "ClockTime.h"
 
 #include <ctime>
 #include <cmath>

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -b -r1.110 -r1.111
--- server/asobj/NetStreamFfmpeg.cpp    6 Apr 2008 17:48:32 -0000       1.110
+++ server/asobj/NetStreamFfmpeg.cpp    7 Apr 2008 10:59:27 -0000       1.111
@@ -32,7 +32,7 @@
 #include "movie_root.h"
 #include "sound_handler.h"
 #include "VideoDecoderFfmpeg.h"
-#include "Time.h" // TODO: use the VirtualClock instead ?
+#include "ClockTime.h" // TODO: use the VirtualClock instead ?
 
 #include <boost/scoped_array.hpp>
 

Index: utilities/processor.cpp
===================================================================
RCS file: /sources/gnash/gnash/utilities/processor.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- utilities/processor.cpp     6 Apr 2008 17:48:32 -0000       1.93
+++ utilities/processor.cpp     7 Apr 2008 10:59:27 -0000       1.94
@@ -24,14 +24,14 @@
 #include <iostream>
 #include <cstdio>
 #include <sys/time.h>
-#include <time.h>
+#include <ctime>
 
 #ifdef ENABLE_NLS
 #include <locale>
 #endif
 
 #include "gettext.h"
-#include "Time.h"
+#include "ClockTime.h"
 #include "gnash.h"
 #include "movie_definition.h"
 #include "sprite_instance.h"

Index: libbase/ClockTime.cpp
===================================================================
RCS file: libbase/ClockTime.cpp
diff -N libbase/ClockTime.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libbase/ClockTime.cpp       7 Apr 2008 10:59:26 -0000       1.1
@@ -0,0 +1,279 @@
+// Time.cpp: clock and local time functions for Gnash
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+/// \page
+/// Gnash has three time implementations: one using boost::date_time,
+/// which handles portability itself, one for POSIX systems and one for 
+/// Win32.
+///
+/// Namespace clocktime contains a unified source for wall clock time: this
+/// is used mainly for the timing of movie advances and in the ActionScript
+/// Date class. FPS profiling also uses clocktime:: for a relatively high 
resolution,
+/// robust timer.
+///
+/// The boost::date_time has the great advantage of handling portability 
itself,
+/// as well as being able to handle a much larger range of true dates. Its
+/// disadvantage is that date_time requires not only header files, but also
+/// a run-time library, and thus increases the requirements.
+
+#include "ClockTime.h"
+#include "log.h"
+
+// Define USE_BOOST_DATE_TIME to use boost as the basis for all
+// clock time functions. The function getTimeZoneOffset() is not
+// yet implemented for boost, but will only affect the Date class.
+#undef USE_BOOST_DATE_TIME
+
+#ifdef USE_BOOST_DATE_TIME
+
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/microsec_time_clock.hpp>
+
+using namespace boost::posix_time;
+
+boost::uint64_t
+clocktime::getTicks()
+{
+
+    // Midnight, 1st January 1970: the Epoch.
+    static const posix_time::ptime epoch (from_time_t(0));
+    
+    // Time between now and the Epoch.
+    posix_time::time_duration elapsed = (microsec_clock::local_time() - epoch);
+    
+    // Divisor to convert ticks to milliseconds
+    const int denominator = time_duration::ticks_per_second() / 1000.0;
+    
+       return elapsed.ticks() / denominator;
+}
+
+boost::int32_t
+clocktime::getTimeZoneOffset()
+{
+    // Obviously this doesn't work yet. Using this method
+    // may come up against the problem that boost won't handle
+    // dates outside its limits. However, ActionScript seems
+    // not to regard dates later than 2037 as having dst (this
+    // may depend on a machine-specific tz database) and there
+    // could also be a lower limit.
+
+    return 0;
+}
+
+#else // not using boost::date_time
+
+#include <ctime> // for time_t, localtime
+
+#if !defined(HAVE_GETTIMEOFDAY) || (!defined(HAVE_TM_GMTOFF) && 
!defined(HAVE_TZSET))
+#ifdef HAVE_FTIME
+extern "C" {
+#  include <sys/types.h>    // for ftime()
+#  include <sys/timeb.h>    // for ftime()
+}
+#endif
+#endif
+
+#if !defined(HAVE_TM_GMTOFF)
+# ifdef HAVE_LONG_TIMEZONE
+extern long timezone;   // for tzset()/long timezone;
+# endif
+#endif
+
+/// Win32 implementation for getTicks
+# if defined(_WIN32) || defined(WIN32)
+#  include <windows.h>
+#  include <mmsystem.h>
+
+
+boost::uint64_t
+clocktime::getTicks()
+{
+       return timeGetTime();
+}
+
+boost::int32_t
+clocktime::getTimeZoneOffset()
+{
+    return 0;
+}
+
+
+# else // not _WIN32
+#  include <sys/time.h>
+
+boost::uint64_t
+clocktime::getTicks()
+{
+
+       struct timeval tv;
+       
+       gettimeofday(&tv, 0);
+
+       boost::uint64_t result = static_cast<boost::uint64_t>(tv.tv_sec) * 
1000000L;
+
+       // Time Unit: microsecond
+       result += tv.tv_usec;
+
+       return static_cast<boost::uint64_t>(result / 1000.0);
+}
+
+# endif // not WIN32
+
+/// Common non-boost function to return the present time offset.
+/// This all seems like a terrible hack. It was moved from Date.cpp,
+/// whence the following explanation also comes.
+///
+/// If the real mktime() sees isdst == 0 with a DST date, it sets
+/// t_isdst and modifies the hour fields, but we need to set the
+/// specified hour in the localtime in force at that time.
+///
+/// To do this we set tm_isdst to the correct value for that moment in time
+/// by doing an initial conversion of the time to find out is_dst for that
+/// moment without DST, then do the real conversion.
+/// This may still get things wrong around the hour when the clocks go back
+///
+/// It also gets things wrong for very high or low time values, when the
+/// localtime implementation fills the gmtoff element with 53 minutes (on
+/// at least one machine, anyway).
+boost::int32_t
+clocktime::getTimeZoneOffset(double time)
+{
+    
+    time_t tt = static_cast<time_t>(time / 1000.0);
+
+    struct tm tm;
+
+#ifdef HAVE_LOCALTIME_R
+    localtime_r(&tt, &tm);
+#else
+    struct tm *tmp;
+    tmp = localtime(t);
+    memcpy(tm, tmp, sizeof(struct tm));
+#endif
+
+    struct tm tm2 = tm;
+    tm2.tm_isdst = 0;
+
+    time_t ttmp = 0;
+    
+    ttmp = mktime(&tm2);
+
+    localtime_r(&ttmp, &tm2);  // find out whether DST is in force
+
+    // If mktime or localtime fail, tm2.tm_isdst should be unchanged,
+    // so 0. That's why we don't make any checks on their success.
+
+    tm.tm_isdst = tm2.tm_isdst;
+
+#ifdef HAVE_TM_GMTOFF
+
+    int offset;
+
+    // tm_gmtoff is in seconds east of GMT; convert to minutes.
+    offset = tm.tm_gmtoff / 60;
+    //gnash::log_debug("Using tm.tm_gmtoff. Offset is %d", offset);
+    return offset;
+
+#else
+
+  // Find the geographical system timezone offset and add an hour if
+  // DST applies to the date.
+  // To get it really right I guess we should call both gmtime()
+  // and localtime() and look at the difference.
+  //
+  // The range of standard time is GMT-11 to GMT+14.
+  // The most extreme with DST is Chatham Island GMT+12:45 +1DST
+
+  int offset;
+
+# if defined(HAVE_TZSET) && defined(HAVE_LONG_TIMEZONE)
+
+    tzset();
+    // timezone is seconds west of GMT
+    offset = -timezone / 60;
+    //gnash::log_debug("Using tzset. Offset is %d", offset);
+
+# elif defined(HAVE_GETTIMEOFDAY)
+
+    // gettimeofday(3):
+    // "The use of the timezone structure is obsolete; the tz argument
+    // should normally be specified as NULL. The tz_dsttime field has
+    // never been used under Linux; it has not been and will not be
+    // supported by libc or glibc."
+    // Still, mancansa d'asu, t'acuma i buoi (Mangels Esel, Ochsen 
einspannen...)
+    //
+    // In practice this appears to return the present time offset including 
dst,
+    // so adding the dst of the time specified (we do this a couple of lines 
down)
+    // gives the correct result when it's not presently dst, the wrong one when
+    // it is.
+    struct timeval tv;
+    struct timezone tz;
+    gettimeofday(&tv, &tz);
+    offset = -tz.tz_minuteswest;
+    //gnash::log_debug("Using gettimeofday. Offset is %d", offset);
+
+# elif defined(HAVE_FTIME)
+    // ftime(3): "These days the contents of the timezone and dstflag
+    // fields are undefined."
+    // In practice, timezone is -120 in Italy when it should be -60.
+    // The problem here as for gettimeofday: the offset also includes dst.
+    struct timeb tb;
+    
+    ftime (&tb);
+    // tb.timezone is number of minutes west of GMT
+    offset = -tb.timezone;
+    //gnash::log_debug("Using ftime. Offset is %d", offset);
+
+# else
+
+    offset = 0; // No idea.
+    //gnash::log_debug("Cannot find offset. Offset is %d", offset);
+
+# endif
+
+  // Adjust by one hour if DST was in force at that time.
+  //
+  // According to http://www.timeanddate.com/time/, the only place that
+  // uses DST != +1 hour is Lord Howe Island with half an hour. Tough.
+
+    if (tm.tm_isdst == 0) {
+        // DST exists and is not in effect
+    }
+    else if (tm.tm_isdst > 0) {
+        // DST exists and was in effect
+        offset += 60;
+    }
+    else {
+        // tm_isdst is negative: cannot get TZ info.
+        // Convert and print in UTC instead.
+        static bool warned = false;
+        if (!warned) {
+            gnash::log_error(_("Cannot get requested timezone information"));
+            warned = true;
+        }
+        offset = 0;
+    }
+
+    return offset;
+
+#endif // No gmoff
+}
+
+
+
+#endif // Not using boost::date_time

Index: libbase/ClockTime.h
===================================================================
RCS file: libbase/ClockTime.h
diff -N libbase/ClockTime.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libbase/ClockTime.h 7 Apr 2008 10:59:26 -0000       1.1
@@ -0,0 +1,38 @@
+// Time.h: clock and local time functions for Gnash
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef GNASH_TIME_H
+#define GNASH_TIME_H
+
+#include <boost/cstdint.hpp>
+#include "dsodefs.h"
+
+namespace clocktime
+{
+    /// Wall clock timer, returns current POSIX time in milliseconds.
+       DSOEXPORT boost::uint64_t getTicks();
+
+       /// Returns the offset between actual clock time and UTC.
+       /// It relies on the system's time zone settings, so
+       /// cannot be regarded as reliable.
+       DSOEXPORT boost::int32_t getTimeZoneOffset(double time);
+
+}
+
+#endif

Index: libbase/Time.cpp
===================================================================
RCS file: libbase/Time.cpp
diff -N libbase/Time.cpp
--- libbase/Time.cpp    7 Apr 2008 05:11:25 -0000       1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,292 +0,0 @@
-// Time.cpp: clock and local time functions for Gnash
-// 
-//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-// 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-/// \page
-/// Gnash has three time implementations: one using boost::date_time,
-/// which handles portability itself, one for POSIX systems and one for 
-/// Win32.
-///
-/// Namespace clocktime contains a unified source for wall clock time: this
-/// is used mainly for the timing of movie advances and in the ActionScript
-/// Date class. FPS profiling also uses clocktime:: for a relatively high 
resolution,
-/// robust timer.
-///
-/// The boost::date_time has the great advantage of handling portability 
itself,
-/// as well as being able to handle a much larger range of true dates. Its
-/// disadvantage is that date_time requires not only header files, but also
-/// a run-time library, and thus increases the requirements.
-
-#include "Time.h"
-#include "log.h"
-
-// Define USE_BOOST_DATE_TIME to use boost as the basis for all
-// clock time functions. The function getTimeZoneOffset() is not
-// yet implemented for boost, but will only affect the Date class.
-#undef USE_BOOST_DATE_TIME
-
-#ifdef USE_BOOST_DATE_TIME
-
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/date_time/microsec_time_clock.hpp>
-
-using namespace boost::posix_time;
-
-boost::uint64_t
-clocktime::getTicks()
-{
-
-    // Midnight, 1st January 1970: the Epoch.
-    static const posix_time::ptime epoch (from_time_t(0));
-    
-    // Time between now and the Epoch.
-    posix_time::time_duration elapsed = (microsec_clock::local_time() - epoch);
-    
-    // Divisor to convert ticks to milliseconds
-    const int denominator = time_duration::ticks_per_second() / 1000.0;
-    
-       return elapsed.ticks() / denominator;
-}
-
-double
-clocktime::ticksToSeconds(boost::uint64_t ticks)
-{
-       return ticks / 1000.0;
-}
-
-boost::int32_t
-clocktime::getTimeZoneOffset()
-{
-    // Obviously this doesn't work yet. Using this method
-    // may come up against the problem that boost won't handle
-    // dates outside its limits. However, ActionScript seems
-    // not to regard dates later than 2037 as having dst (this
-    // may depend on a machine-specific tz database) and there
-    // could also be a lower limit.
-
-    return 0;
-}
-
-#else // not using boost::date_time
-
-#include <ctime> // for time_t, localtime
-
-#if !defined(HAVE_GETTIMEOFDAY) || (!defined(HAVE_TM_GMTOFF) && 
!defined(HAVE_TZSET))
-#ifdef HAVE_FTIME
-extern "C" {
-#  include <sys/types.h>    // for ftime()
-#  include <sys/timeb.h>    // for ftime()
-}
-#endif
-#endif
-
-#if !defined(HAVE_TM_GMTOFF)
-# ifdef HAVE_LONG_TIMEZONE
-extern long timezone;   // for tzset()/long timezone;
-# endif
-#endif
-
-/// Win32 implementation for getTicks
-# if defined(_WIN32) || defined(WIN32)
-#  include <windows.h>
-#  include <mmsystem.h>
-
-
-boost::uint64_t
-clocktime::getTicks()
-{
-       return timeGetTime();
-}
-
-boost::int32_t
-clocktime::getTimeZoneOffset()
-{
-    return 0;
-}
-
-
-# else // not _WIN32
-#  include <sys/time.h>
-
-boost::uint64_t
-clocktime::getTicks()
-{
-
-       struct timeval tv;
-       
-       gettimeofday(&tv, 0);
-
-       boost::uint64_t result = static_cast<boost::uint64_t>(tv.tv_sec) * 
1000000L;
-
-       // Time Unit: microsecond
-       result += tv.tv_usec;
-
-       return static_cast<boost::uint64_t>(result / 1000.0);
-}
-
-# endif // not WIN32
-
-// Common non-boost conversion of ticks to seconds
-double
-clocktime::ticksToSeconds(boost::uint64_t ticks)
-{
-       return ticks * (1.0f / 1000.f);
-}
-
-/// Common non-boost function to return the present time offset.
-/// This all seems like a terrible hack. It was moved from Date.cpp,
-/// whence the following explanation also comes.
-///
-/// If the real mktime() sees isdst == 0 with a DST date, it sets
-/// t_isdst and modifies the hour fields, but we need to set the
-/// specified hour in the localtime in force at that time.
-///
-/// To do this we set tm_isdst to the correct value for that moment in time
-/// by doing an initial conversion of the time to find out is_dst for that
-/// moment without DST, then do the real conversion.
-/// This may still get things wrong around the hour when the clocks go back
-///
-/// It also gets things wrong for very high or low time values, when the
-/// localtime implementation fills the gmtoff element with 53 minutes (on
-/// at least one machine, anyway).
-boost::int32_t
-clocktime::getTimeZoneOffset(double time)
-{
-    
-    time_t tt = static_cast<time_t>(time / 1000.0);
-
-    struct tm tm;
-
-#ifdef HAVE_LOCALTIME_R
-    localtime_r(&tt, &tm);
-#else
-    struct tm *tmp;
-    tmp = localtime(t);
-    memcpy(tm, tmp, sizeof(struct tm));
-#endif
-
-    struct tm tm2 = tm;
-    tm2.tm_isdst = 0;
-
-    time_t ttmp = 0;
-    
-    ttmp = mktime(&tm2);
-
-    localtime_r(&ttmp, &tm2);  // find out whether DST is in force
-
-    // If mktime or localtime fail, tm2.tm_isdst should be unchanged,
-    // so 0. That's why we don't make any checks on their success.
-
-    tm.tm_isdst = tm2.tm_isdst;
-
-#ifdef HAVE_TM_GMTOFF
-
-    int offset;
-
-    // tm_gmtoff is in seconds east of GMT; convert to minutes.
-    offset = tm.tm_gmtoff / 60;
-    //gnash::log_debug("Using tm.tm_gmtoff. Offset is %d", offset);
-    return offset;
-
-#else
-
-  // Find the geographical system timezone offset and add an hour if
-  // DST applies to the date.
-  // To get it really right I guess we should call both gmtime()
-  // and localtime() and look at the difference.
-  //
-  // The range of standard time is GMT-11 to GMT+14.
-  // The most extreme with DST is Chatham Island GMT+12:45 +1DST
-
-  int offset;
-
-# if defined(HAVE_TZSET) && defined(HAVE_LONG_TIMEZONE)
-
-    tzset();
-    // timezone is seconds west of GMT
-    offset = -timezone / 60;
-    //gnash::log_debug("Using tzset. Offset is %d", offset);
-
-# elif defined(HAVE_GETTIMEOFDAY)
-
-    // gettimeofday(3):
-    // "The use of the timezone structure is obsolete; the tz argument
-    // should normally be specified as NULL. The tz_dsttime field has
-    // never been used under Linux; it has not been and will not be
-    // supported by libc or glibc."
-    // Still, mancansa d'asu, t'acuma i buoi (Mangels Esel, Ochsen 
einspannen...)
-    //
-    // In practice this appears to return the present time offset including 
dst,
-    // so adding the dst of the time specified (we do this a couple of lines 
down)
-    // gives the correct result when it's not presently dst, the wrong one when
-    // it is.
-    struct timeval tv;
-    struct timezone tz;
-    gettimeofday(&tv, &tz);
-    offset = -tz.tz_minuteswest;
-    //gnash::log_debug("Using gettimeofday. Offset is %d", offset);
-
-# elif defined(HAVE_FTIME)
-    // ftime(3): "These days the contents of the timezone and dstflag
-    // fields are undefined."
-    // In practice, timezone is -120 in Italy when it should be -60.
-    // The problem here as for gettimeofday: the offset also includes dst.
-    struct timeb tb;
-    
-    ftime (&tb);
-    // tb.timezone is number of minutes west of GMT
-    offset = -tb.timezone;
-    //gnash::log_debug("Using ftime. Offset is %d", offset);
-
-# else
-
-    offset = 0; // No idea.
-    //gnash::log_debug("Cannot find offset. Offset is %d", offset);
-
-# endif
-
-  // Adjust by one hour if DST was in force at that time.
-  //
-  // According to http://www.timeanddate.com/time/, the only place that
-  // uses DST != +1 hour is Lord Howe Island with half an hour. Tough.
-
-    if (tm.tm_isdst == 0) {
-        // DST exists and is not in effect
-    }
-    else if (tm.tm_isdst > 0) {
-        // DST exists and was in effect
-        offset += 60;
-    }
-    else {
-        // tm_isdst is negative: cannot get TZ info.
-        // Convert and print in UTC instead.
-        static bool warned = false;
-        if (!warned) {
-            gnash::log_error(_("Cannot get requested timezone information"));
-            warned = true;
-        }
-        offset = 0;
-    }
-
-    return offset;
-
-#endif // No gmoff
-}
-
-
-
-#endif // Not using boost::date_time

Index: libbase/Time.h
===================================================================
RCS file: libbase/Time.h
diff -N libbase/Time.h
--- libbase/Time.h      6 Apr 2008 17:48:31 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-// Time.h: clock and local time functions for Gnash
-// 
-//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-// 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-
-#ifndef GNASH_TIME_H
-#define GNASH_TIME_H
-
-#include <boost/cstdint.hpp>
-#include "dsodefs.h"
-
-namespace clocktime
-{
-    /// Wall clock timer, uses highest available resolution.
-    /// Generally microseconds on Linux / Unix, microseconds with
-    /// millisecond resolution on Windows. Nanosecond resolution is
-    /// theoretically available.
-       DSOEXPORT boost::uint64_t getTicks();
-
-       /// Converts ticks to seconds.
-       DSOEXPORT double ticksToSeconds(boost::uint64_t ticks);
-
-       /// Returns the offset between actual clock time and UTC.
-       /// It relies on the system's time zone settings, so
-       /// cannot be regarded as reliable.
-       DSOEXPORT boost::int32_t getTimeZoneOffset(double time);
-
-}
-
-#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]