> > +static inline int64_t is_between(int64_t x, int64_t a, int64_t b) > > +{ > > + if (a < b) { > > + return x > a && x <= b; > > + } > > + return x < a && x >= b; > > +} > > This looks slightly odd -- should the boundary condition for whether > a value equal to the max/min really change depending on :whether a > or b is greater?
This is a ugly hack. Instead of figuring out whether we have a count-up or count-down timer the code checks for both, and have the "in_between" function magically DTRT. I haven't followed the paths through in enough detail to figure out whether it gets all the corner cases right. Paul