Skip to content

Commit 830533d

Browse files
authored
Add taskYIELD_WITHIN_API macro (#782)
Add taskYIELD_WITHIN_API macro for readability improvement.
1 parent 5cdb1bc commit 830533d

File tree

5 files changed

+17
-91
lines changed

5 files changed

+17
-91
lines changed

event_groups.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
253253
{
254254
if( xAlreadyYielded == pdFALSE )
255255
{
256-
#if ( configNUMBER_OF_CORES == 1 )
257-
{
258-
portYIELD_WITHIN_API();
259-
}
260-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
261-
{
262-
vTaskYieldWithinAPI();
263-
}
264-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
256+
taskYIELD_WITHIN_API();
265257
}
266258
else
267259
{
@@ -417,15 +409,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
417409
{
418410
if( xAlreadyYielded == pdFALSE )
419411
{
420-
#if ( configNUMBER_OF_CORES == 1 )
421-
{
422-
portYIELD_WITHIN_API();
423-
}
424-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
425-
{
426-
vTaskYieldWithinAPI();
427-
}
428-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
412+
taskYIELD_WITHIN_API();
429413
}
430414
else
431415
{

include/task.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,6 +3330,12 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
33303330
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
33313331
*----------------------------------------------------------*/
33323332

3333+
#if ( configNUMBER_OF_CORES == 1 )
3334+
#define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
3335+
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
3336+
#define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
3337+
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
3338+
33333339
/*
33343340
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
33353341
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS

queue.c

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,15 +1129,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
11291129
* is also a higher priority task in the pending ready list. */
11301130
if( xTaskResumeAll() == pdFALSE )
11311131
{
1132-
#if ( configNUMBER_OF_CORES == 1 )
1133-
{
1134-
portYIELD_WITHIN_API();
1135-
}
1136-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1137-
{
1138-
vTaskYieldWithinAPI();
1139-
}
1140-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1132+
taskYIELD_WITHIN_API();
11411133
}
11421134
}
11431135
else
@@ -1616,15 +1608,7 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue,
16161608

16171609
if( xTaskResumeAll() == pdFALSE )
16181610
{
1619-
#if ( configNUMBER_OF_CORES == 1 )
1620-
{
1621-
portYIELD_WITHIN_API();
1622-
}
1623-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1624-
{
1625-
vTaskYieldWithinAPI();
1626-
}
1627-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1611+
taskYIELD_WITHIN_API();
16281612
}
16291613
else
16301614
{
@@ -1817,15 +1801,7 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
18171801

18181802
if( xTaskResumeAll() == pdFALSE )
18191803
{
1820-
#if ( configNUMBER_OF_CORES == 1 )
1821-
{
1822-
portYIELD_WITHIN_API();
1823-
}
1824-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1825-
{
1826-
vTaskYieldWithinAPI();
1827-
}
1828-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1804+
taskYIELD_WITHIN_API();
18291805
}
18301806
else
18311807
{
@@ -2013,15 +1989,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue,
20131989

20141990
if( xTaskResumeAll() == pdFALSE )
20151991
{
2016-
#if ( configNUMBER_OF_CORES == 1 )
2017-
{
2018-
portYIELD_WITHIN_API();
2019-
}
2020-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
2021-
{
2022-
vTaskYieldWithinAPI();
2023-
}
2024-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1992+
taskYIELD_WITHIN_API();
20251993
}
20261994
else
20271995
{

tasks.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,11 +2195,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
21952195
* have put ourselves to sleep. */
21962196
if( xAlreadyYielded == pdFALSE )
21972197
{
2198-
#if ( configNUMBER_OF_CORES == 1 )
2199-
portYIELD_WITHIN_API();
2200-
#else
2201-
vTaskYieldWithinAPI();
2202-
#endif
2198+
taskYIELD_WITHIN_API();
22032199
}
22042200
else
22052201
{
@@ -2251,11 +2247,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
22512247
* have put ourselves to sleep. */
22522248
if( xAlreadyYielded == pdFALSE )
22532249
{
2254-
#if ( configNUMBER_OF_CORES == 1 )
2255-
portYIELD_WITHIN_API();
2256-
#else
2257-
vTaskYieldWithinAPI();
2258-
#endif
2250+
taskYIELD_WITHIN_API();
22592251
}
22602252
else
22612253
{
@@ -7253,15 +7245,7 @@ TickType_t uxTaskResetEventItemValue( void )
72537245
* section (some will yield immediately, others wait until the
72547246
* critical section exits) - but it is not something that
72557247
* application code should ever do. */
7256-
#if ( configNUMBER_OF_CORES == 1 )
7257-
{
7258-
portYIELD_WITHIN_API();
7259-
}
7260-
#else
7261-
{
7262-
vTaskYieldWithinAPI();
7263-
}
7264-
#endif
7248+
taskYIELD_WITHIN_API();
72657249
}
72667250
else
72677251
{
@@ -7344,15 +7328,7 @@ TickType_t uxTaskResetEventItemValue( void )
73447328
* section (some will yield immediately, others wait until the
73457329
* critical section exits) - but it is not something that
73467330
* application code should ever do. */
7347-
#if ( configNUMBER_OF_CORES == 1 )
7348-
{
7349-
portYIELD_WITHIN_API();
7350-
}
7351-
#else
7352-
{
7353-
vTaskYieldWithinAPI();
7354-
}
7355-
#endif
7331+
taskYIELD_WITHIN_API();
73567332
}
73577333
else
73587334
{

timers.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,15 +771,7 @@
771771
* block time to expire. If a command arrived between the
772772
* critical section being exited and this yield then the yield
773773
* will not cause the task to block. */
774-
#if ( configNUMBER_OF_CORES == 1 )
775-
{
776-
portYIELD_WITHIN_API();
777-
}
778-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
779-
{
780-
vTaskYieldWithinAPI();
781-
}
782-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
774+
taskYIELD_WITHIN_API();
783775
}
784776
else
785777
{

0 commit comments

Comments
 (0)