Skip to content

Commit e3a0e3e

Browse files
authored
Revert "FreeRTOS SMP: direct access to current TCB inside stack macros (#1270)" (#1272)
This reverts commit 4162ca4.
1 parent 4162ca4 commit e3a0e3e

File tree

2 files changed

+6
-101
lines changed

2 files changed

+6
-101
lines changed

include/stack_macros.h

+5-100
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@
6666
*/
6767
#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
6868

69-
#if ( configNUMBER_OF_CORES == 1 )
70-
7169
/* Only the current stack state is to be checked. */
72-
#define taskCHECK_FOR_STACK_OVERFLOW() \
70+
#define taskCHECK_FOR_STACK_OVERFLOW() \
7371
do \
7472
{ \
7573
/* Is the currently saved stack pointer within the stack limit? */ \
@@ -80,33 +78,13 @@
8078
} \
8179
} while( 0 )
8280

83-
#else /* if ( configNUMBER_OF_CORES == 1 ) */
84-
85-
/* Only the current stack state is to be checked. */
86-
#define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \
87-
do \
88-
{ \
89-
TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \
90-
\
91-
/* Is the currently saved stack pointer within the stack limit? */ \
92-
if( pxTCB->pxTopOfStack <= pxTCB->pxStack + portSTACK_LIMIT_PADDING ) \
93-
{ \
94-
char * pcOverflowTaskName = pxTCB->pcTaskName; \
95-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \
96-
} \
97-
} while( 0 )
98-
99-
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
100-
10181
#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
10282
/*-----------------------------------------------------------*/
10383

10484
#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
10585

106-
#if ( configNUMBER_OF_CORES == 1 )
107-
10886
/* Only the current stack state is to be checked. */
109-
#define taskCHECK_FOR_STACK_OVERFLOW() \
87+
#define taskCHECK_FOR_STACK_OVERFLOW() \
11088
do \
11189
{ \
11290
/* Is the currently saved stack pointer within the stack limit? */ \
@@ -117,32 +95,12 @@
11795
} \
11896
} while( 0 )
11997

120-
#else /* if ( configNUMBER_OF_CORES == 1 ) */
121-
122-
/* Only the current stack state is to be checked. */
123-
#define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \
124-
do \
125-
{ \
126-
TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \
127-
\
128-
/* Is the currently saved stack pointer within the stack limit? */ \
129-
if( pxTCB->pxTopOfStack >= pxTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
130-
{ \
131-
char * pcOverflowTaskName = pxTCB->pcTaskName; \
132-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \
133-
} \
134-
} while( 0 )
135-
136-
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
137-
13898
#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
13999
/*-----------------------------------------------------------*/
140100

141101
#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
142102

143-
#if ( configNUMBER_OF_CORES == 1 )
144-
145-
#define taskCHECK_FOR_STACK_OVERFLOW() \
103+
#define taskCHECK_FOR_STACK_OVERFLOW() \
146104
do \
147105
{ \
148106
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
@@ -159,36 +117,12 @@
159117
} \
160118
} while( 0 )
161119

162-
#else /* if ( configNUMBER_OF_CORES == 1 ) */
163-
164-
#define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \
165-
do \
166-
{ \
167-
TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \
168-
const uint32_t * const pulStack = ( uint32_t * ) pxTCB->pxStack; \
169-
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
170-
\
171-
if( ( pxTCB->pxTopOfStack <= pxTCB->pxStack + portSTACK_LIMIT_PADDING ) || \
172-
( pulStack[ 0 ] != ulCheckValue ) || \
173-
( pulStack[ 1 ] != ulCheckValue ) || \
174-
( pulStack[ 2 ] != ulCheckValue ) || \
175-
( pulStack[ 3 ] != ulCheckValue ) ) \
176-
{ \
177-
char * pcOverflowTaskName = pxTCB->pcTaskName; \
178-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \
179-
} \
180-
} while( 0 )
181-
182-
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
183-
184120
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
185121
/*-----------------------------------------------------------*/
186122

187123
#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
188124

189-
#if ( configNUMBER_OF_CORES == 1 )
190-
191-
#define taskCHECK_FOR_STACK_OVERFLOW() \
125+
#define taskCHECK_FOR_STACK_OVERFLOW() \
192126
do \
193127
{ \
194128
int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
@@ -208,41 +142,12 @@
208142
} \
209143
} while( 0 )
210144

211-
#else /* if ( configNUMBER_OF_CORES == 1 ) */
212-
213-
#define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \
214-
do \
215-
{ \
216-
TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \
217-
int8_t * pcEndOfStack = ( int8_t * ) pxTCB->pxEndOfStack; \
218-
static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
219-
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
220-
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
221-
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
222-
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
223-
\
224-
pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
225-
\
226-
if( ( pxTCB->pxTopOfStack >= pxTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \
227-
( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) ) \
228-
{ \
229-
char * pcOverflowTaskName = pxTCB->pcTaskName; \
230-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \
231-
} \
232-
} while( 0 )
233-
234-
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
235-
236145
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
237146
/*-----------------------------------------------------------*/
238147

239148
/* Remove stack overflow macro if not being used. */
240149
#ifndef taskCHECK_FOR_STACK_OVERFLOW
241-
#if ( configNUMBER_OF_CORES == 1 )
242-
#define taskCHECK_FOR_STACK_OVERFLOW()
243-
#else
244-
#define taskCHECK_FOR_STACK_OVERFLOW( xCoreID )
245-
#endif
150+
#define taskCHECK_FOR_STACK_OVERFLOW()
246151
#endif
247152

248153

tasks.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5251,7 +5251,7 @@ BaseType_t xTaskIncrementTick( void )
52515251
#endif /* configGENERATE_RUN_TIME_STATS */
52525252

52535253
/* Check for stack overflow, if configured. */
5254-
taskCHECK_FOR_STACK_OVERFLOW( xCoreID );
5254+
taskCHECK_FOR_STACK_OVERFLOW();
52555255

52565256
/* Before the currently running task is switched out, save its errno. */
52575257
#if ( configUSE_POSIX_ERRNO == 1 )

0 commit comments

Comments
 (0)