[WIN32-MingW Demo] TickType_t width is defined based on compiler type.(32bit/64bit) (#1199)

* [WIN32-MingW Demo] Add tick type width definition based on compiler type.(32bit/64bit)
32bit TickType_t is used if compiler is MinGW32. 64bit TickType_t is used if compiler is MinGW64.

Reason of change: Before this change, 32bit TickType_t is always used in MinGW demo. It is inefficient  for 64bit compiler. In addition, MinGW64 reported warnings for the cast operation between TickType_t and (void *) pointer because of different width. 64bit TickType_t should be used instead of 32bit if compiler is 64bit.

* [WIN32-MingW Demo] Change printf() format specifiers from %u to %llu.

Reason of change: %u specifier corrupts 64bit tick count because it supports only 32bit value. %llu can be used for both of 64bit value and 32bit value.(After casting to 64bit)

* [WIN32-MingW Demo] Change type of some variables from uint32_t to UBaseType_t.

Reason of change: These variables are cast to/from pointer type in existing codes. 64bit compiler(MinGW64) reports warnings for the cast operations between uint32_t and pointer type. UBaseType_t solves those warnings because it has same width as pointer type on both of MinGW32 and MinGW64.

* [WIN32-MingW Demo] Change type of some variables from uint32_t to UBaseType_t.

Same change as previous commit is applied to source codes which are built only on Debug configuration.

* [WIN32-MingW Demo] Add brackets to the condition in #if statement. Behavior is not changed. Reason of change is to follow coding style guide of FreeRTOS.

* Update "FreeRTOS/Source" submodule(FreeRTOS-kernel) to #1008.

* [WIN32-MingW Demo] Change type of one more variable from uint32_t to UBaseType_t.

Additional modification for solving compiler warnings for the cast operation on MinGW64.

* Update FreeRTOS-kernel submodule version in manifest.yml.

* Modify prefix of variables to follow coding style guide.

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: ActoryOu <ousc@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
pull/1181/head
wat 11 months ago committed by GitHub
parent 273fb94328
commit 076430b2ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -48,7 +48,6 @@
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 100 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 0
@ -61,6 +60,14 @@
#define configUSE_TASK_NOTIFICATIONS 1
#define configSUPPORT_STATIC_ALLOCATION 1
/* Tick type width is defined based on the compiler type (32bit or 64bit). */
#ifdef __x86_64__
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_64_BITS
#else
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
#endif
/* Software timer related configuration options. The maximum possible task
priority is configMAX_PRIORITIES - 1. The priority of the timer task is
deliberately set higher to ensure it is correctly capped back to
@ -135,7 +142,11 @@ used with multiple project configurations. If it is
#define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" )
/* Ensure the tick count overflows during the coverage test. */
#define configINITIAL_TICK_COUNT 0xffffd800UL
#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define configINITIAL_TICK_COUNT 0xffffffffffffd800ULL
#else
#define configINITIAL_TICK_COUNT 0xffffd800UL
#endif
/* Allows tests of trying to allocate more than the heap has free. */
#define configUSE_MALLOC_FAILED_HOOK 0

@ -86,50 +86,50 @@ static BaseType_t prvTimerQuery( void );
static BaseType_t prvStaticAllocationsWithNullBuffers( void )
{
uint32_t ulReturned = 0;
UBaseType_t uxReturned = 0;
BaseType_t xReturn = pdPASS;
UBaseType_t uxDummy = 10;
/* Don't expect to create any of the objects as a NULL parameter is always
passed in place of a required buffer. Hence if all passes then none of the
|= will be against 0, and ulReturned will still be zero at the end of this
|= will be against 0, and uxReturned will still be zero at the end of this
function. */
ulReturned |= ( uint32_t ) xEventGroupCreateStatic( NULL );
uxReturned |= ( UBaseType_t ) xEventGroupCreateStatic( NULL );
/* Try creating a task twice, once with puxStackBuffer NULL, and once with
pxTaskBuffer NULL. */
ulReturned |= ( uint32_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
NULL,
( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
ulReturned |= ( uint32_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
ulReturned |= ( uint32_t ) xQueueCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
uxReturned |= ( UBaseType_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
NULL,
( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
uxReturned |= ( UBaseType_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */
"Dummy", /* Task name. */
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY,
( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
uxReturned |= ( UBaseType_t ) xQueueCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
/* Try creating a stream buffer twice, once with pucStreamBufferStorageArea
set to NULL, and once with pxStaticStreamBuffer set to NULL. */
ulReturned |= ( uint32_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
NULL,
( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
uxReturned |= ( UBaseType_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
NULL,
( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */
ulReturned |= ( uint32_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
uxReturned |= ( UBaseType_t ) xStreamBufferCreateStatic( uxDummy,
uxDummy,
( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */
NULL );
/* Try to create a task with a stack that is too large to be allocated. */
if( xTaskCreate( NULL, "TooLarge", configTOTAL_HEAP_SIZE, NULL, tskIDLE_PRIORITY, NULL ) != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY )
@ -137,7 +137,7 @@ UBaseType_t uxDummy = 10;
xReturn = pdFAIL;
}
if( ulReturned != 0 )
if( uxReturned != 0 )
{
/* Something returned a non-NULL value. */
xReturn = pdFAIL;

@ -386,19 +386,21 @@ static void prvCheckTask( void * pvParameters )
#endif /* configSUPPORT_STATIC_ALLOCATION */
/* This is the only task that uses stdout so its ok to call printf()
* directly. */
* directly. %llu (long long unsigned) format specifier is used here
* to support both 32-bit values on MinGW32 and 64-bit values on
* MinGW64. */
vPortGetHeapStats( &xHeapStats );
configASSERT( xHeapStats.xAvailableHeapSpaceInBytes == xPortGetFreeHeapSize() );
configASSERT( xHeapStats.xMinimumEverFreeBytesRemaining == xPortGetMinimumEverFreeHeapSize() );
printf( "%s - tick count %u - free heap %u - min free heap %u - largest free block %u - number of free blocks %u\r\n",
printf( "%s - tick count %llu - free heap %llu - min free heap %llu - largest free block %llu - number of free blocks %llu\r\n",
pcStatusMessage,
xTaskGetTickCount(),
xHeapStats.xAvailableHeapSpaceInBytes,
xHeapStats.xMinimumEverFreeBytesRemaining,
xHeapStats.xSizeOfLargestFreeBlockInBytes,
xHeapStats.xNumberOfFreeBlocks );
( uint64_t ) xTaskGetTickCount(),
( uint64_t ) xHeapStats.xAvailableHeapSpaceInBytes,
( uint64_t ) xHeapStats.xMinimumEverFreeBytesRemaining,
( uint64_t ) xHeapStats.xSizeOfLargestFreeBlockInBytes,
( uint64_t ) xHeapStats.xNumberOfFreeBlocks );
fflush( stdout );
}
@ -554,21 +556,22 @@ void vFullDemoTickHookFunction( void )
static void prvPendedFunction( void * pvParameter1,
uint32_t ulParameter2 )
{
static uint32_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
uint32_t ulParameter1;
static UBaseType_t uxLastParameter1 = 1000UL;
static uint32_t ulLastParameter2 = 0UL;
UBaseType_t uxParameter1;
ulParameter1 = ( uint32_t ) pvParameter1;
uxParameter1 = ( UBaseType_t ) pvParameter1;
/* Ensure the parameters are as expected. */
configASSERT( ulParameter1 == ( ulLastParameter1 + 1 ) );
configASSERT( uxParameter1 == ( uxLastParameter1 + 1 ) );
configASSERT( ulParameter2 == ( ulLastParameter2 + 1 ) );
/* Remember the parameters for the next time the function is called. */
ulLastParameter1 = ulParameter1;
uxLastParameter1 = uxParameter1;
ulLastParameter2 = ulParameter2;
/* Remove compiler warnings in case configASSERT() is not defined. */
( void ) ulLastParameter1;
( void ) uxLastParameter1;
( void ) ulLastParameter2;
}
/*-----------------------------------------------------------*/
@ -622,17 +625,18 @@ static void prvDemonstrateTimerQueryFunctions( void )
static void prvDemonstratePendingFunctionCall( void )
{
static uint32_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
static UBaseType_t uxParameter1 = 1000UL;
static uint32_t ulParameter2 = 0UL;
const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
/* prvPendedFunction() just expects the parameters to be incremented by one
* each time it is called. */
ulParameter1++;
uxParameter1++;
ulParameter2++;
/* Pend the function call, sending the parameters. */
xTimerPendFunctionCall( prvPendedFunction, ( void * ) ulParameter1, ulParameter2, xDontBlock );
xTimerPendFunctionCall( prvPendedFunction, ( void * ) uxParameter1, ulParameter2, xDontBlock );
}
/*-----------------------------------------------------------*/
@ -869,12 +873,12 @@ static void prvPermanentlyBlockingNotificationTask( void * pvParameters )
static void prvReloadModeTestTimerCallback( TimerHandle_t xTimer )
{
uint32_t ulTimerID;
UBaseType_t uxTimerID;
/* Increment the timer's ID to show the callback has executed. */
ulTimerID = ( uint32_t ) pvTimerGetTimerID( xTimer );
ulTimerID++;
vTimerSetTimerID( xTimer, ( void * ) ulTimerID );
uxTimerID = ( UBaseType_t ) pvTimerGetTimerID( xTimer );
uxTimerID++;
vTimerSetTimerID( xTimer, ( void * ) uxTimerID );
}
/*-----------------------------------------------------------*/
@ -906,7 +910,7 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
vTimerSetTimerID( xTimer, ( void * ) 0 );
xTimerStart( xTimer, portMAX_DELAY );
vTaskDelay( 3UL * x50ms );
configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
configASSERT( ( ( UBaseType_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
/* Now change the timer to be an auto-reload timer and check it executes
* the expected number of times. */
@ -914,7 +918,7 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
vTimerSetTimerID( xTimer, ( void * ) 0 );
xTimerStart( xTimer, 0 );
vTaskDelay( ( 3UL * x50ms ) + ( x50ms / 2UL ) ); /* Three full periods. */
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
configASSERT( ( UBaseType_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
/* Now change the timer back to be a one-shot timer and check it only
@ -924,9 +928,10 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
xTimerStart( xTimer, 0 );
vTaskDelay( 3UL * x50ms );
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
configASSERT( ( UBaseType_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
/* Clean up at the end. */
xTimerDelete( xTimer, portMAX_DELAY );
vTaskDelete( NULL );
}
/*-----------------------------------------------------------*/

@ -1 +1 @@
Subproject commit 30f6061f48e2d54625d31e72ada6f5c474fba99f
Subproject commit 625b24a104dd901d86759668b6b272590d154308

@ -5,7 +5,7 @@ license: "MIT"
dependencies:
- name: "FreeRTOS-Kernel"
version: "30f6061f4"
version: "625b24a10"
repository:
type: "git"
url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git"

Loading…
Cancel
Save