mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-08-18 00:45:04 -05:00
Add substitution code for unavailable functions gettimeofday and gmtime_r.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13560 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
2006-03-09 Christian Stimming <stimming@tuhh.de>
|
2006-03-09 Christian Stimming <stimming@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
|
* configure.in, Makefile.am: Replace "ln -sf" by "$(LN_S) -f" for
|
||||||
systems that don't have symbolic links available.
|
systems that don't have symbolic links available.
|
||||||
|
|
||||||
|
|||||||
@@ -1425,7 +1425,11 @@ qof_date_add_days(Timespec *ts, gint days)
|
|||||||
|
|
||||||
g_return_val_if_fail(ts, FALSE);
|
g_return_val_if_fail(ts, FALSE);
|
||||||
tt = timespecToTime_t(*ts);
|
tt = timespecToTime_t(*ts);
|
||||||
|
#ifdef HAVE_GMTIME_R
|
||||||
tm = *gmtime_r(&tt, &tm);
|
tm = *gmtime_r(&tt, &tm);
|
||||||
|
#else
|
||||||
|
tm = *gmtime(&tt);
|
||||||
|
#endif
|
||||||
tm.tm_mday += days;
|
tm.tm_mday += days;
|
||||||
/* let mktime normalise the months and year
|
/* let mktime normalise the months and year
|
||||||
because we aren't tracking last_day_of_month */
|
because we aren't tracking last_day_of_month */
|
||||||
@@ -1445,7 +1449,11 @@ qof_date_add_months(Timespec *ts, gint months, gboolean track_last_day)
|
|||||||
|
|
||||||
g_return_val_if_fail(ts, FALSE);
|
g_return_val_if_fail(ts, FALSE);
|
||||||
tt = timespecToTime_t(*ts);
|
tt = timespecToTime_t(*ts);
|
||||||
|
#ifdef HAVE_GMTIME_R
|
||||||
tm = *gmtime_r(&tt, &tm);
|
tm = *gmtime_r(&tt, &tm);
|
||||||
|
#else
|
||||||
|
tm = *gmtime(&tt);
|
||||||
|
#endif
|
||||||
was_last_day = date_is_last_mday(&tm);
|
was_last_day = date_is_last_mday(&tm);
|
||||||
tm.tm_mon += months;
|
tm.tm_mon += months;
|
||||||
while (tm.tm_mon > 11) {
|
while (tm.tm_mon > 11) {
|
||||||
|
|||||||
@@ -204,11 +204,18 @@ void
|
|||||||
qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
|
qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
|
||||||
const gchar *function_name, const gchar *format, ...)
|
const gchar *function_name, const gchar *format, ...)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
|
#endif
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
gettimeofday (&qof_clock[clockno], &tz);
|
gettimeofday (&qof_clock[clockno], &tz);
|
||||||
|
#else
|
||||||
|
time (&(qof_clock[clockno].tv_sec));
|
||||||
|
qof_clock[clockno].tv_usec = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!fout) qof_log_init();
|
if (!fout) qof_log_init();
|
||||||
|
|
||||||
@@ -229,12 +236,19 @@ void
|
|||||||
qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
|
qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
|
||||||
const gchar *function_name, const gchar *format, ...)
|
const gchar *function_name, const gchar *format, ...)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
|
#endif
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
gettimeofday (&now, &tz);
|
gettimeofday (&now, &tz);
|
||||||
|
#else
|
||||||
|
time (&(now.tv_sec));
|
||||||
|
now.tv_usec = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* need to borrow to make difference */
|
/* need to borrow to make difference */
|
||||||
if (now.tv_usec < qof_clock[clockno].tv_usec)
|
if (now.tv_usec < qof_clock[clockno].tv_usec)
|
||||||
|
|||||||
Reference in New Issue
Block a user