[WIN32-MSVC Demo] Define TickType_t width based on the target platform(32bit/64bit). (#1201)

* [WIN32-MSVC Demo] Add tick type width definition based on the target platform.(32bit/64bit)
32bit TickType_t is used on Win32 target. 64bit TickType_t is used on x64 target.

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

* [WIN32-MSVC 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. x64 compiler 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 Win32 platform and x64 platform.

* [WIN32-MSVC Demo]Correct prefix of variables and indent to follow coding style guide.

* [WIN32-MSVC Demo]Correct type of the argument in vApplicationGetIdleTaskMemory() prototype declaration.
It is corrected to match original declaration described in task.h.

* [WIN32-MSVC] Add cast operation to solve compiler warnings on x64 platform.
Before this change, compiler claimed that the cast operation to wider type should be applied before other arithmetic operations because of overflow risk. There is no overflow risk here but it is modified to solve compiler warnings.
pull/1202/head
wat 10 months ago committed by GitHub
parent 4592acca4c
commit 7514cd3d54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -49,7 +49,6 @@
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 490 * 1024 ) ) /* This demo tests heap_5 so places multiple blocks within this total heap size. See mainREGION_1_SIZE to mainREGION_3_SIZE definitions in main.c. */
#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
@ -66,6 +65,13 @@
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
/* Tick type width is defined based on the target platform(32bit or 64bit). */
#ifdef _M_X64
#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. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

@ -133,7 +133,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
void vApplicationTickHook( void );
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize );
configSTACK_DEPTH_TYPE * puxIdleTaskStackSize );
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
StackType_t ** ppxTimerTaskStackBuffer,
uint32_t * pulTimerTaskStackSize );
@ -417,7 +417,7 @@ static void prvInitialiseHeap( void )
* used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
configSTACK_DEPTH_TYPE * pulIdleTaskStackSize )
configSTACK_DEPTH_TYPE * puxIdleTaskStackSize )
{
/* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
@ -435,7 +435,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
*puxIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/

@ -463,7 +463,7 @@ void vFullDemoIdleFunction( void )
/* Exercise heap_5 a bit. The malloc failed hook will trap failed
* allocations so there is no need to test here. */
pvAllocated = pvPortMalloc( ( rand() % 500 ) + 1 );
pvAllocated = pvPortMalloc( ( size_t )( rand() % 500 ) + 1 );
vPortFree( pvAllocated );
}
/*-----------------------------------------------------------*/
@ -521,17 +521,18 @@ 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;
}
/*-----------------------------------------------------------*/
@ -585,17 +586,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 );
}
/*-----------------------------------------------------------*/

Loading…
Cancel
Save