Skip to content

Commit 48acdd2

Browse files
committed
Remove __builtin_clz from header file
1 parent 5652423 commit 48acdd2

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

portable/GCC/ARM_CRx_No_GIC/portASM.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
.global vPortEnableInterrupts
5454
.global vPortDisableInterrupts
5555
.global ulPortSetInterruptMaskFromISR
56+
.global ulPortCountLeadingZeros
5657

5758
.weak vApplicationSVCHandler
5859
/*-----------------------------------------------------------*/
@@ -236,6 +237,21 @@ vApplicationSVCHandler:
236237

237238
/*-----------------------------------------------------------*/
238239

240+
/*
241+
* UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
242+
*
243+
* According to the Procedure Call Standard for the ARM Architecture (AAPCS):
244+
* - Parameter ulBitmap is passed in R0.
245+
* - Return value must be in R0.
246+
*/
247+
.align 4
248+
.type ulPortCountLeadingZeros, %function
249+
ulPortCountLeadingZeros:
250+
CLZ R0, R0
251+
BX LR
252+
253+
/*-----------------------------------------------------------*/
254+
239255
/*
240256
* SVC handler is used to yield.
241257
*/

portable/GCC/ARM_CRx_No_GIC/portmacro.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ extern uint32_t ulPortSetInterruptMaskFromISR( void );
132132
* handler for whichever peripheral is used to generate the RTOS tick. */
133133
void FreeRTOS_Tick_Handler( void );
134134

135+
/**
136+
* @brief Returns the number of leading zeros in a 32 bit variable.
137+
*
138+
* @param[in] ulBitmap 32-Bit number to count leading zeros in.
139+
*
140+
* @return The number of leading zeros in ulBitmap.
141+
*/
142+
UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
143+
135144
/* If configUSE_TASK_FPU_SUPPORT is set to 1 (or left undefined) then tasks are
136145
* created without an FPU context and must call vPortTaskUsesFPU() to give
137146
* themselves an FPU context before using any FPU instructions. If
@@ -159,7 +168,7 @@ void FreeRTOS_Tick_Handler( void );
159168
/* Store, clear and get the ready priorities in a bit map. */
160169
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
161170
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
162-
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) )
171+
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ulPortCountLeadingZeros( ( uxTopReadyPriority ) ) )
163172

164173
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
165174

0 commit comments

Comments
 (0)