Run time stats conditional compilation

Just getting FreeRTOS running for the first time and I came across what appears to be a simple problem. If configGENERATE_RUN_TIME_STATS is defined as zero should the call to portCONFIGURE_TIMER_FOR_RUN_TIME_STATS in vTaskStartScheduler be excluded from the build? Jason Valenzuela

Run time stats conditional compilation

If configGENERATE_RUN_TIME_STATS is set to one then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS and ( portGET_RUN_TIME_COUNTER_VALUE or portGET_ALT_RUN_TIME_COUNTER_VALUE ) must also be defined.  If configGENERATE_RUN_TIME_STATS is set to 0, then the other two macros should not also be defined, although defining them is probably harmless. The code contains the following sanity check:
#if ( configGENERATE_RUN_TIME_STATS == 1 )
    #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
        #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined.  portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.
    #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
    #ifndef portGET_RUN_TIME_COUNTER_VALUE
        #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
            #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined.  See the examples provided and the FreeRTOS web site for more information.
        #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
    #endif /* portGET_RUN_TIME_COUNTER_VALUE */
#endif /* configGENERATE_RUN_TIME_STATS */
Regards.

Run time stats conditional compilation

Understood. My question stemmed from line 1133 in task.c, which calls portCONFIGURE_TIMER_FOR_RUN_TIME_STATS regardless of the configGENERATE_RUN_TIME_STATS value. This of course fails when configGENERATE_RUN_TIME_STATS is defined to 0 and portCONFIGURE_TIMER_FOR_RUN_TIME_STATS is not defined. I was wondering if the call should be enclosed in an appropriate #ifdef block. Jason Valenzuela

Run time stats conditional compilation

No #ifdef block is needed. In freertos.h you will find the code below that removes the macro if it is not defined
#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
    #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#endif