1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 10:35:10 +00:00

fix your math dummy

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@955 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2007-09-02 03:29:38 +00:00
parent 16ea4f6587
commit 39a3bfe8f8

View File

@ -25,7 +25,6 @@
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
@ -110,10 +109,11 @@ timed_thread_create (void *(*start_routine)(void*), void *arg, unsigned int inte
/* remaining microseconds convert to nanoseconds */
p_timed_thread->interval_time.tv_nsec = (long)((interval_usecs % 1000000) * 1000);
/*printf ("interval_time.tv_sec = %li, .tv_nsec = %li\n",
/*
printf ("interval_time.tv_sec = %li, .tv_nsec = %li\n",
p_timed_thread->interval_time.tv_sec,
p_timed_thread->interval_time.tv_nsec);*/
p_timed_thread->interval_time.tv_nsec);
*/
return p_timed_thread;
}
@ -186,17 +186,18 @@ timed_thread_test (timed_thread* p_timed_thread)
if (now (&wait_time)) return (-1);
/*printf ("PRE:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/
/* now add in the wait interval */
if (1000000000-wait_time.tv_nsec < p_timed_thread->interval_time.tv_nsec)
/* add in the wait interval */
if (1000000000-wait_time.tv_nsec <= p_timed_thread->interval_time.tv_nsec)
{
/* adjust for impending overflow of wait_time.tv_nsec */
wait_time.tv_sec += p_timed_thread->interval_time.tv_sec;
wait_time.tv_sec += (p_timed_thread->interval_time.tv_nsec / 1000000000) + 1;
wait_time.tv_nsec = labs (wait_time.tv_nsec - p_timed_thread->interval_time.tv_nsec);
wait_time.tv_sec += p_timed_thread->interval_time.tv_sec + 1;
wait_time.tv_nsec = wait_time.tv_nsec - (1000000000 - p_timed_thread->interval_time.tv_nsec);
/*printf ("001:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/
}
else
{
/* no overflow will occur, just add respective components */
wait_time.tv_sec += p_timed_thread->interval_time.tv_sec;
wait_time.tv_nsec += p_timed_thread->interval_time.tv_nsec;
/*printf ("002:wait_time.tv_secs = %li, .tv_nsecs = %li\n", wait_time.tv_sec, wait_time.tv_nsec);*/