From: Owen Taylor Date: Fri, 18 Dec 1998 17:52:18 +0000 (+0000) Subject: Dec 18 12:51:39 1998 Owen Taylor X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=2623d2831ab006459da71d8a869a7a9a55869df2;p=dana%2Fcg-glib.git Dec 18 12:51:39 1998 Owen Taylor * gmain.c: Fix errors in computation of timeout expiration times > 1sec. --- diff --git a/ChangeLog b/ChangeLog index 4f3324df..89e13cb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4f3324df..89e13cb7 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Fri Dec 18 12:51:39 1998 Owen Taylor + + * gmain.c: Fix errors in computation of timeout + expiration times > 1sec. + 1998-12-18 Sebastian Wilhelmi * configure.in (have_threads): Changed the last pthread_cond_init diff --git a/glib/gmain.c b/glib/gmain.c index 5fa9691a..274c8352 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -832,8 +832,11 @@ g_timeout_dispatch (gpointer source_data, if (data->callback(user_data)) { - data->expiration.tv_sec = current_time->tv_sec; - data->expiration.tv_usec = current_time->tv_usec + data->interval * 1000; + guint seconds = data->interval / 1000; + guint msecs = data->interval - seconds * 1000; + + data->expiration.tv_sec = current_time->tv_sec + seconds; + data->expiration.tv_usec = current_time->tv_usec + msecs * 1000; if (data->expiration.tv_usec >= 1000000) { data->expiration.tv_usec -= 1000000; @@ -852,13 +855,19 @@ g_timeout_add_full (gint priority, gpointer data, GDestroyNotify notify) { + guint seconds; + guint msecs; GTimeoutData *timeout_data = g_new (GTimeoutData, 1); timeout_data->interval = interval; timeout_data->callback = function; g_get_current_time (&timeout_data->expiration); - timeout_data->expiration.tv_usec += timeout_data->interval * 1000; + seconds = timeout_data->interval / 1000; + msecs = timeout_data->interval - seconds * 1000; + + timeout_data->expiration.tv_sec += seconds; + timeout_data->expiration.tv_usec += msecs * 1000; if (timeout_data->expiration.tv_usec >= 1000000) { timeout_data->expiration.tv_usec -= 1000000; diff --git a/gmain.c b/gmain.c index 5fa9691a..274c8352 100644 --- a/gmain.c +++ b/gmain.c @@ -832,8 +832,11 @@ g_timeout_dispatch (gpointer source_data, if (data->callback(user_data)) { - data->expiration.tv_sec = current_time->tv_sec; - data->expiration.tv_usec = current_time->tv_usec + data->interval * 1000; + guint seconds = data->interval / 1000; + guint msecs = data->interval - seconds * 1000; + + data->expiration.tv_sec = current_time->tv_sec + seconds; + data->expiration.tv_usec = current_time->tv_usec + msecs * 1000; if (data->expiration.tv_usec >= 1000000) { data->expiration.tv_usec -= 1000000; @@ -852,13 +855,19 @@ g_timeout_add_full (gint priority, gpointer data, GDestroyNotify notify) { + guint seconds; + guint msecs; GTimeoutData *timeout_data = g_new (GTimeoutData, 1); timeout_data->interval = interval; timeout_data->callback = function; g_get_current_time (&timeout_data->expiration); - timeout_data->expiration.tv_usec += timeout_data->interval * 1000; + seconds = timeout_data->interval / 1000; + msecs = timeout_data->interval - seconds * 1000; + + timeout_data->expiration.tv_sec += seconds; + timeout_data->expiration.tv_usec += msecs * 1000; if (timeout_data->expiration.tv_usec >= 1000000) { timeout_data->expiration.tv_usec -= 1000000;