[Gnucash-changes] r13560 - gnucash/trunk - Add substitution code
for unavailable functions gettimeofday and gmtime_r.
Christian Stimming
cstim at cvs.gnucash.org
Thu Mar 9 11:26:03 EST 2006
Author: cstim
Date: 2006-03-09 11:26:02 -0500 (Thu, 09 Mar 2006)
New Revision: 13560
Trac: http://svn.gnucash.org/trac/changeset/13560
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/lib/libqof/qof/gnc-date.c
gnucash/trunk/lib/libqof/qof/qoflog.c
Log:
Add substitution code for unavailable functions gettimeofday and gmtime_r.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-03-09 16:06:49 UTC (rev 13559)
+++ gnucash/trunk/ChangeLog 2006-03-09 16:26:02 UTC (rev 13560)
@@ -1,5 +1,8 @@
2006-03-09 Christian Stimming <stimming at tuhh.de>
+ * lib/libqof/qof/qoflog.c, gnc-date.c: Add substitution code for
+ unavailable functions gettimeofday and gmtime_r.
+
* configure.in, Makefile.am: Replace "ln -sf" by "$(LN_S) -f" for
systems that don't have symbolic links available.
Modified: gnucash/trunk/lib/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/gnc-date.c 2006-03-09 16:06:49 UTC (rev 13559)
+++ gnucash/trunk/lib/libqof/qof/gnc-date.c 2006-03-09 16:26:02 UTC (rev 13560)
@@ -1425,7 +1425,11 @@
g_return_val_if_fail(ts, FALSE);
tt = timespecToTime_t(*ts);
+#ifdef HAVE_GMTIME_R
tm = *gmtime_r(&tt, &tm);
+#else
+ tm = *gmtime(&tt);
+#endif
tm.tm_mday += days;
/* let mktime normalise the months and year
because we aren't tracking last_day_of_month */
@@ -1445,7 +1449,11 @@
g_return_val_if_fail(ts, FALSE);
tt = timespecToTime_t(*ts);
+#ifdef HAVE_GMTIME_R
tm = *gmtime_r(&tt, &tm);
+#else
+ tm = *gmtime(&tt);
+#endif
was_last_day = date_is_last_mday(&tm);
tm.tm_mon += months;
while (tm.tm_mon > 11) {
Modified: gnucash/trunk/lib/libqof/qof/qoflog.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.c 2006-03-09 16:06:49 UTC (rev 13559)
+++ gnucash/trunk/lib/libqof/qof/qoflog.c 2006-03-09 16:26:02 UTC (rev 13560)
@@ -204,11 +204,18 @@
qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
const gchar *function_name, const gchar *format, ...)
{
+#ifdef HAVE_GETTIMEOFDAY
struct timezone tz;
+#endif
va_list ap;
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
+#ifdef HAVE_GETTIMEOFDAY
gettimeofday (&qof_clock[clockno], &tz);
+#else
+ time (&(qof_clock[clockno].tv_sec));
+ qof_clock[clockno].tv_usec = 0;
+#endif
if (!fout) qof_log_init();
@@ -229,12 +236,19 @@
qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
const gchar *function_name, const gchar *format, ...)
{
+#ifdef HAVE_GETTIMEOFDAY
struct timezone tz;
+#endif
struct timeval now;
va_list ap;
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
+#ifdef HAVE_GETTIMEOFDAY
gettimeofday (&now, &tz);
+#else
+ time (&(now.tv_sec));
+ now.tv_usec = 0;
+#endif
/* need to borrow to make difference */
if (now.tv_usec < qof_clock[clockno].tv_usec)
More information about the gnucash-changes
mailing list