Looking for source code of __builtin_avr_delay_cycles called by _delay_ms in avr-gcc

Viewed 1878

I was investigating the delay_ms function of avr-gcc. In delay.h I found its definition:

void _delay_ms(double __ms)
{
    double __tmp ;
#if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \
    !defined(__DELAY_BACKWARD_COMPATIBLE__) &&       \
    __STDC_HOSTED__

    uint32_t __ticks_dc;
    extern void __builtin_avr_delay_cycles(unsigned long);
    __tmp = ((F_CPU) / 1e3) * __ms;

    #if defined(__DELAY_ROUND_DOWN__)
        __ticks_dc = (uint32_t)fabs(__tmp);

    #elif defined(__DELAY_ROUND_CLOSEST__)
        __ticks_dc = (uint32_t)(fabs(__tmp)+0.5);

    #else
          //round up by default
          __ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
    #endif

    __builtin_avr_delay_cycles(__ticks_dc);

#else
    ...
}

I am interested in how the __builtin_avr_delay_cycles function looks like internally and where it is defined? Where can I find the source?

1 Answers
Related