Merge branch 'main' into fix/missing-extern-c

This commit is contained in:
Rahul Kar 2024-05-29 23:53:44 +05:30 committed by GitHub
commit 51f529888b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 17 deletions

View file

@ -53,6 +53,14 @@
/* A few bytes might be lost to byte aligning the heap start address. */ /* A few bytes might be lost to byte aligning the heap start address. */
#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
/* Max value that fits in a size_t type. */
#define heapSIZE_MAX ( ~( ( size_t ) 0 ) )
/* Check if adding a and b will result in overflow. */
#define heapADD_WILL_OVERFLOW( a, b ) ( ( a ) > ( heapSIZE_MAX - ( b ) ) )
/*-----------------------------------------------------------*/
/* Allocate the memory for the heap. */ /* Allocate the memory for the heap. */
#if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) #if ( configAPPLICATION_ALLOCATED_HEAP == 1 )
@ -76,12 +84,16 @@ void * pvPortMalloc( size_t xWantedSize )
/* Ensure that blocks are always aligned. */ /* Ensure that blocks are always aligned. */
#if ( portBYTE_ALIGNMENT != 1 ) #if ( portBYTE_ALIGNMENT != 1 )
{ {
if( xWantedSize & portBYTE_ALIGNMENT_MASK ) size_t xAdditionalRequiredSize;
if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
{ {
/* Byte alignment required. Check for overflow. */ /* Byte alignment required. */
if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK );
if( heapADD_WILL_OVERFLOW( xWantedSize, xAdditionalRequiredSize ) == 0 )
{ {
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); xWantedSize += xAdditionalRequiredSize;
} }
else else
{ {
@ -96,13 +108,14 @@ void * pvPortMalloc( size_t xWantedSize )
if( pucAlignedHeap == NULL ) if( pucAlignedHeap == NULL )
{ {
/* Ensure the heap starts on a correctly aligned boundary. */ /* Ensure the heap starts on a correctly aligned boundary. */
pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT - 1 ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &( ucHeap[ portBYTE_ALIGNMENT - 1 ] ) ) &
( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
} }
/* Check there is enough room left for the allocation and. */ /* Check there is enough room left for the allocation. */
if( ( xWantedSize > 0 ) && /* valid size */ if( ( xWantedSize > 0 ) &&
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && ( heapADD_WILL_OVERFLOW( xNextFreeByte, xWantedSize ) == 0 ) &&
( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */ ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) )
{ {
/* Return the next free byte then increment the index past this /* Return the next free byte then increment the index past this
* block. */ * block. */

13
tasks.c
View file

@ -662,7 +662,8 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
/* /*
* Return the amount of time, in ticks, that will pass before the kernel will * Return the amount of time, in ticks, that will pass before the kernel will
* next move a task from the Blocked state to the Running state. * next move a task from the Blocked state to the Running state or before the
* tick count overflows (whichever is earlier).
* *
* This conditional compilation should use inequality to 0, not equality to 1. * This conditional compilation should use inequality to 0, not equality to 1.
* This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user
@ -3894,9 +3895,9 @@ void vTaskSuspendAll( void )
static TickType_t prvGetExpectedIdleTime( void ) static TickType_t prvGetExpectedIdleTime( void )
{ {
TickType_t xReturn; TickType_t xReturn;
UBaseType_t uxHigherPriorityReadyTasks = pdFALSE; BaseType_t xHigherPriorityReadyTasks = pdFALSE;
/* uxHigherPriorityReadyTasks takes care of the case where /* xHigherPriorityReadyTasks takes care of the case where
* configUSE_PREEMPTION is 0, so there may be tasks above the idle priority * configUSE_PREEMPTION is 0, so there may be tasks above the idle priority
* task that are in the Ready state, even though the idle task is * task that are in the Ready state, even though the idle task is
* running. */ * running. */
@ -3904,7 +3905,7 @@ void vTaskSuspendAll( void )
{ {
if( uxTopReadyPriority > tskIDLE_PRIORITY ) if( uxTopReadyPriority > tskIDLE_PRIORITY )
{ {
uxHigherPriorityReadyTasks = pdTRUE; xHigherPriorityReadyTasks = pdTRUE;
} }
} }
#else #else
@ -3918,7 +3919,7 @@ void vTaskSuspendAll( void )
* care of the case where the co-operative scheduler is in use. */ * care of the case where the co-operative scheduler is in use. */
if( uxTopReadyPriority > uxLeastSignificantBit ) if( uxTopReadyPriority > uxLeastSignificantBit )
{ {
uxHigherPriorityReadyTasks = pdTRUE; xHigherPriorityReadyTasks = pdTRUE;
} }
} }
#endif /* if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) */ #endif /* if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) */
@ -3934,7 +3935,7 @@ void vTaskSuspendAll( void )
* processed. */ * processed. */
xReturn = 0; xReturn = 0;
} }
else if( uxHigherPriorityReadyTasks != pdFALSE ) else if( xHigherPriorityReadyTasks != pdFALSE )
{ {
/* There are tasks in the Ready state that have a priority above the /* There are tasks in the Ready state that have a priority above the
* idle priority. This path can only be reached if * idle priority. This path can only be reached if