Run time stats conditional compilation

jvalenzuela wrote on Friday, October 14, 2011:

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

rtel wrote on Saturday, October 15, 2011:

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 )
		#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.
			#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 /* portGET_RUN_TIME_COUNTER_VALUE */
#endif /* configGENERATE_RUN_TIME_STATS */


jvalenzuela wrote on Monday, October 17, 2011:

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

edwards3 wrote on Monday, October 17, 2011:

No #ifdef block is needed. In freertos.h you will find the code below that removes the macro if it is not defined