Hi everybody!
On looking through "timer.c", I have found a few things that I want to
share with you.
1) Here's an excerpt of the manpage for "timercmp()":
Some systems (but not Linux/glibc), have a broken timercmp()
implementation, in which CMP of >=, <=, and == do not work; portable
applications can instead use
!timercmp(..., <)
!timercmp(..., >)
!timercmp(..., !=)
So I have changed the corresponding line in "timer.c" from
if (timercmp(&Timers[i].when, &now, <=)) {
to
if (!timercmp(&Timers[i].when, &now, >)) {
and committed this to SVN.
2) I find the function "timer_inc()" rather messy. Why not change it to
static void timer_inc(struct timeval *tv, const int msec)
{
struct timeval diff;
diff.tv_sec = msec / 1000;
diff.tv_usec = (msec % 1000) * 1000;
timeradd(tv, &diff, tv);
}
This is much less messy and works just as well. I have not committed
this to SVN, as according to its manpage, "timeradd()" is
Not in POSIX.1-2001. Present on most BSD derivatives.
However, you already use "timercmp()", and the same restriction applies
here. Thus, using "timeradd()" should be fine. Shall I commit, or
shan't I commit? That is the question... ;)
3) The variable "flag" in "timer_process()" is completely useless (it is
always "1" when tested). This variable should either be removed for
clarity, or the code should be changed so it actually serves a purpose.
Best regards,
Martin
--
www.mzuther.de
www.radix-musik.de
|