> -----Original Message----- > From: > avr-libc-dev-bounces+eric.weddington=atmel....@nongnu.org > [mailto:avr-libc-dev-bounces+eric.weddington=atmel....@nongnu. > org] On Behalf Of Timothy Baldwin > Sent: Sunday, October 11, 2009 8:02 PM > To: Carlos Lamas; Clarence Risher; Timothy Baldwin; > avr-libc-dev@nongnu.org > Subject: [avr-libc-dev] [patch #6418] Yet another delay routines > > > Follow-up Comment #3, patch #6418 (project avr-libc): > > Rather than generating an error when an integer non-constant > is passed the > non-exact macros could form a loop around a constant delay. > > > #define _delay_ms(__ms) > > > do { > > > if (!__builtin_constant_p(F_CPU)) { > > > _DELAY_EMIT_ERROR(__STRINGIFY(F_CPU) > > > " is not a constant for > _delay_ms"); > > } else if (__builtin_constant_p(__ms)) { > > > _delay_f_ms(F_CPU, __ms); > > > } else if ((__typeof__((_ms) + 0))0.25 == 0) { > > > __typeof__((__ms) + 0) __ms2 = __ms; > > > while (__ms2--) _delay_f_ms(F_CPU, 1); > > > } else { > > > _DELAY_EMIT_ERROR(__STRINGIFY(__ms) > > > " is not a constant or integer for > _delay_ms"); > > } > > > } while (0) >
The only reason why I wouldn't like this is that the 'while' look adds overhead to the overall delay, thereby reducing the accuracy of the delay. Why should avr-libc provide this when a user can essentially create a loop in their own code that does a variable delay, and then they can control how much overhead they have in their code. Looping at a 1 millisecond resolution is arbitrary. _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-libc-dev