+
+static double
+double_time (void)
+{
+ struct timeval now;
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ struct timezone tzp;
+ gettimeofday(&now, &tzp);
+# else
+ gettimeofday(&now);
+# endif
+
+ return (now.tv_sec + ((double) now.tv_usec * 0.000001));
+}
+
+
+/* Some of the hacks set their timing based on the real-world wall clock,
+ so to make the animations record at a sensible speed, we need to slow
+ down that clock by discounting the time taken up by snapshotting and
+ saving the frame.
+ */
+static double recanim_time_warp = 0;
+
+void
+screenhack_record_anim_gettimeofday (struct timeval *tv
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ , struct timezone *tz
+# endif
+ )
+{
+ gettimeofday (tv
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ , tz
+# endif
+ );
+ tv->tv_sec -= (time_t) recanim_time_warp;
+ tv->tv_usec -= 1000000 * (recanim_time_warp - (time_t) recanim_time_warp);
+}
+
+time_t
+screenhack_record_anim_time (time_t *o)
+{
+ struct timeval tv;
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ struct timezone tz;
+# endif
+ screenhack_record_anim_gettimeofday (&tv
+# ifdef GETTIMEOFDAY_TWO_ARGS
+ , &tz
+# endif
+ );
+ if (o) *o = tv.tv_sec;
+ return tv.tv_sec;
+}
+
+