Demo/Posix_GCC cleanup (#1212)

Demo/Posix_GCC cleanup

- Guard prvSaveTraceFile() function definition.
- Remove "cid" as it is unused.
- handle_sigint(): quiet compiler warning about unused param.
- main_full.c: prvCheckTask(): Remove unused var "xHeapStats".

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
This commit is contained in:
Florian La Roche 2024-04-18 15:37:34 +02:00 committed by GitHub
parent 2023ac6404
commit 17eeb79698
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 16 deletions

View file

@ -91,6 +91,7 @@
/* This demo uses heap_3.c (the libc provided malloc() and free()). */ /* This demo uses heap_3.c (the libc provided malloc() and free()). */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
extern void main_blinky( void ); extern void main_blinky( void );
extern void main_full( void ); extern void main_full( void );
static void traceOnEnter( void ); static void traceOnEnter( void );
@ -118,12 +119,16 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
StackType_t ** ppxTimerTaskStackBuffer, StackType_t ** ppxTimerTaskStackBuffer,
uint32_t * pulTimerTaskStackSize ); uint32_t * pulTimerTaskStackSize );
#if ( projENABLE_TRACING == 1 )
/* /*
* Writes trace data to a disk file when the trace recording is stopped. * Writes trace data to a disk file when the trace recording is stopped.
* This function will simply overwrite any trace files that already exist. * This function will simply overwrite any trace files that already exist.
*/ */
static void prvSaveTraceFile( void ); static void prvSaveTraceFile( void );
#endif /* if ( projENABLE_TRACING == 1 ) */
/* /*
* Signal handler for Ctrl_C to cause the program to exit, and generate the * Signal handler for Ctrl_C to cause the program to exit, and generate the
* profiling info. * profiling info.
@ -139,8 +144,6 @@ static void handle_sigint( int signal );
* in a different file. */ * in a different file. */
StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
static clockid_t cid = CLOCK_THREAD_CPUTIME_ID;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
int main( void ) int main( void )
@ -183,6 +186,7 @@ int main( void )
return 0; return 0;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationMallocFailedHook( void ) void vApplicationMallocFailedHook( void )
@ -201,6 +205,7 @@ void vApplicationMallocFailedHook( void )
* information. */ * information. */
vAssertCalled( __FILE__, __LINE__ ); vAssertCalled( __FILE__, __LINE__ );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationIdleHook( void ) void vApplicationIdleHook( void )
@ -227,6 +232,7 @@ void vApplicationIdleHook( void )
} }
#endif #endif
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( TaskHandle_t pxTask, void vApplicationStackOverflowHook( TaskHandle_t pxTask,
@ -242,6 +248,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
* when running the FreeRTOS POSIX port. */ * when running the FreeRTOS POSIX port. */
vAssertCalled( __FILE__, __LINE__ ); vAssertCalled( __FILE__, __LINE__ );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationTickHook( void ) void vApplicationTickHook( void )
@ -259,6 +266,8 @@ void vApplicationTickHook( void )
#endif /* mainSELECTED_APPLICATION */ #endif /* mainSELECTED_APPLICATION */
} }
/*-----------------------------------------------------------*/
void traceOnEnter() void traceOnEnter()
{ {
#if ( TRACE_ON_ENTER == 1 ) #if ( TRACE_ON_ENTER == 1 )
@ -286,6 +295,8 @@ void traceOnEnter()
#endif /* if ( TRACE_ON_ENTER == 1 ) */ #endif /* if ( TRACE_ON_ENTER == 1 ) */
} }
/*-----------------------------------------------------------*/
void vLoggingPrintf( const char * pcFormat, void vLoggingPrintf( const char * pcFormat,
... ) ... )
{ {
@ -295,6 +306,7 @@ void vLoggingPrintf( const char * pcFormat,
vprintf( pcFormat, arg ); vprintf( pcFormat, arg );
va_end( arg ); va_end( arg );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationDaemonTaskStartupHook( void ) void vApplicationDaemonTaskStartupHook( void )
@ -304,6 +316,7 @@ void vApplicationDaemonTaskStartupHook( void )
* application includes initialisation code that would benefit from executing * application includes initialisation code that would benefit from executing
* after the scheduler has been started. */ * after the scheduler has been started. */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vAssertCalled( const char * const pcFileName, void vAssertCalled( const char * const pcFileName,
@ -345,9 +358,11 @@ void vAssertCalled( const char * const pcFileName,
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( projENABLE_TRACING == 1 ) #if ( projENABLE_TRACING == 1 )
static void prvSaveTraceFile( void ) static void prvSaveTraceFile( void )
{ {
FILE * pxOutputFile; FILE * pxOutputFile;
@ -367,7 +382,9 @@ void vAssertCalled( const char * const pcFileName,
printf( "\r\nFailed to create trace dump file\r\n" ); printf( "\r\nFailed to create trace dump file\r\n" );
} }
} }
#endif /* if ( projENABLE_TRACING == 1 ) */ #endif /* if ( projENABLE_TRACING == 1 ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
@ -395,6 +412,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
@ -422,11 +440,15 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
} }
/*-----------------------------------------------------------*/
void handle_sigint( int signal ) void handle_sigint( int signal )
{ {
int xReturn; int xReturn;
xReturn = chdir( BUILD ); /* changing dir to place gmon.out inside build */ ( void ) signal;
xReturn = chdir( BUILD ); /* Changing dir to place gmon.out inside build. */
if( xReturn == -1 ) if( xReturn == -1 )
{ {
@ -436,6 +458,8 @@ void handle_sigint( int signal )
exit( 2 ); exit( 2 );
} }
/*-----------------------------------------------------------*/
static uint32_t ulEntryTime = 0; static uint32_t ulEntryTime = 0;
void vTraceTimerReset( void ) void vTraceTimerReset( void )
@ -443,12 +467,18 @@ void vTraceTimerReset( void )
ulEntryTime = xTaskGetTickCount(); ulEntryTime = xTaskGetTickCount();
} }
/*-----------------------------------------------------------*/
uint32_t uiTraceTimerGetFrequency( void ) uint32_t uiTraceTimerGetFrequency( void )
{ {
return configTICK_RATE_HZ; return configTICK_RATE_HZ;
} }
/*-----------------------------------------------------------*/
uint32_t uiTraceTimerGetValue( void ) uint32_t uiTraceTimerGetValue( void )
{ {
return( xTaskGetTickCount() - ulEntryTime ); return( xTaskGetTickCount() - ulEntryTime );
} }
/*-----------------------------------------------------------*/

View file

@ -269,7 +269,6 @@ static void prvCheckTask( void * pvParameters )
{ {
TickType_t xNextWakeTime; TickType_t xNextWakeTime;
const TickType_t xCycleFrequency = pdMS_TO_TICKS( 10000UL ); const TickType_t xCycleFrequency = pdMS_TO_TICKS( 10000UL );
HeapStats_t xHeapStats;
/* Just to remove compiler warning. */ /* Just to remove compiler warning. */
( void ) pvParameters; ( void ) pvParameters;