diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 63e2feb51..f28268885 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -2748,6 +2748,10 @@ #define portTASK_USES_FLOATING_POINT() #endif +#ifndef portSTRIP_ADDRESS_TAG + #define portSTRIP_ADDRESS_TAG( pxPointer ) ( pxPointer ) +#endif + #ifndef portALLOCATE_SECURE_CONTEXT #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) #endif diff --git a/include/stack_macros.h b/include/stack_macros.h index 6d0117722..3d66f6f91 100644 --- a/include/stack_macros.h +++ b/include/stack_macros.h @@ -71,7 +71,7 @@ do \ { \ /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \ + if( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \ { \ char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ @@ -88,7 +88,7 @@ do \ { \ /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \ + if( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \ { \ char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ diff --git a/tasks.c b/tasks.c index c596c475f..e08a57334 100644 --- a/tasks.c +++ b/tasks.c @@ -2011,11 +2011,11 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, #if ( portSTACK_GROWTH < 0 ) { - configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) ); + configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxTopOfStack ) - ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) ); } #else /* portSTACK_GROWTH */ { - configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) ); + configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) - ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) ); } #endif /* portSTACK_GROWTH */ }