From 1eef52ed8dbe8db5d11085d378020ed6e57175e8 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Thu, 6 Jan 2011 11:10:51 +0000 Subject: [PATCH] Introduce option that permits a smaller printf() library to be used when sizeof( int ) == sizeof( long ) in cases where formatted strings are used to present run time stats information. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1233 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/CCS4/MSP430X/portmacro.h | 4 ++++ Source/portable/IAR/MSP430X/portmacro.h | 4 ++++ Source/tasks.c | 24 ++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Source/portable/CCS4/MSP430X/portmacro.h b/Source/portable/CCS4/MSP430X/portmacro.h index d4422d9ec..cea0e4ace 100644 --- a/Source/portable/CCS4/MSP430X/portmacro.h +++ b/Source/portable/CCS4/MSP430X/portmacro.h @@ -156,5 +156,9 @@ extern void vTaskSwitchContext( void ); void vApplicationSetupTimerInterrupt( void ); +/* sizeof( int ) != sizeof( long ) so a full printf() library is required if +run time stats information is to be displayed. */ +#define portLU_PRINTF_SPECIFIER_REQUIRED + #endif /* PORTMACRO_H */ diff --git a/Source/portable/IAR/MSP430X/portmacro.h b/Source/portable/IAR/MSP430X/portmacro.h index d52f130e1..0e3b284bd 100644 --- a/Source/portable/IAR/MSP430X/portmacro.h +++ b/Source/portable/IAR/MSP430X/portmacro.h @@ -156,5 +156,9 @@ extern void vTaskSwitchContext( void ); void vApplicationSetupTimerInterrupt( void ); +/* sizeof( int ) != sizeof( long ) so a full printf() library is required if +run time stats information is to be displayed. */ +#define portLU_PRINTF_SPECIFIER_REQUIRED + #endif /* PORTMACRO_H */ diff --git a/Source/tasks.c b/Source/tasks.c index 3f8d1aad0..ab4bc9f38 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -2131,13 +2131,33 @@ tskTCB *pxNewTCB; if( ulStatsAsPercentage > 0UL ) { - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage ); + #ifdef portLU_PRINTF_SPECIFIER_REQUIRED + { + sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage ); + } + #else + { + /* sizeof( int ) == sizeof( long ) so a smaller + printf() library can be used. */ + sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); + } + #endif } else { /* If the percentage is zero here then the task has consumed less than 1% of the total run time. */ - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter ); + #ifdef portLU_PRINTF_SPECIFIER_REQUIRED + { + sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter ); + } + #else + { + /* sizeof( int ) == sizeof( long ) so a smaller + printf() library can be used. */ + sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); + } + #endif } } -- 2.39.5