Skip to content

Commit

Permalink
Remove __builtin_clz from header file
Browse files Browse the repository at this point in the history
  • Loading branch information
kar-rahul-aws committed Jul 14, 2024
1 parent 5652423 commit 48acdd2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions portable/GCC/ARM_CRx_No_GIC/portASM.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
.global vPortEnableInterrupts
.global vPortDisableInterrupts
.global ulPortSetInterruptMaskFromISR
.global ulPortCountLeadingZeros

.weak vApplicationSVCHandler
/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -236,6 +237,21 @@ vApplicationSVCHandler:

/*-----------------------------------------------------------*/

/*
* UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
*
* According to the Procedure Call Standard for the ARM Architecture (AAPCS):
* - Parameter ulBitmap is passed in R0.
* - Return value must be in R0.
*/
.align 4
.type ulPortCountLeadingZeros, %function
ulPortCountLeadingZeros:
CLZ R0, R0
BX LR

/*-----------------------------------------------------------*/

/*
* SVC handler is used to yield.
*/
Expand Down
11 changes: 10 additions & 1 deletion portable/GCC/ARM_CRx_No_GIC/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ extern uint32_t ulPortSetInterruptMaskFromISR( void );
* handler for whichever peripheral is used to generate the RTOS tick. */
void FreeRTOS_Tick_Handler( void );

/**
* @brief Returns the number of leading zeros in a 32 bit variable.
*
* @param[in] ulBitmap 32-Bit number to count leading zeros in.
*
* @return The number of leading zeros in ulBitmap.
*/
UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );

/* If configUSE_TASK_FPU_SUPPORT is set to 1 (or left undefined) then tasks are
* created without an FPU context and must call vPortTaskUsesFPU() to give
* themselves an FPU context before using any FPU instructions. If
Expand Down Expand Up @@ -159,7 +168,7 @@ void FreeRTOS_Tick_Handler( void );
/* Store, clear and get the ready priorities in a bit map. */
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) )
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ulPortCountLeadingZeros( ( uxTopReadyPriority ) ) )

#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */

Expand Down

0 comments on commit 48acdd2

Please sign in to comment.