From 48acdd2c14eea34e42c7d06782ddefe614fce769 Mon Sep 17 00:00:00 2001 From: kar-rahul-aws Date: Sun, 14 Jul 2024 22:55:11 +0530 Subject: [PATCH] Remove __builtin_clz from header file --- portable/GCC/ARM_CRx_No_GIC/portASM.S | 16 ++++++++++++++++ portable/GCC/ARM_CRx_No_GIC/portmacro.h | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CRx_No_GIC/portASM.S b/portable/GCC/ARM_CRx_No_GIC/portASM.S index faba69872..75493b357 100644 --- a/portable/GCC/ARM_CRx_No_GIC/portASM.S +++ b/portable/GCC/ARM_CRx_No_GIC/portASM.S @@ -53,6 +53,7 @@ .global vPortEnableInterrupts .global vPortDisableInterrupts .global ulPortSetInterruptMaskFromISR + .global ulPortCountLeadingZeros .weak vApplicationSVCHandler /*-----------------------------------------------------------*/ @@ -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. */ diff --git a/portable/GCC/ARM_CRx_No_GIC/portmacro.h b/portable/GCC/ARM_CRx_No_GIC/portmacro.h index 83a2c92bf..726ffcbd9 100644 --- a/portable/GCC/ARM_CRx_No_GIC/portmacro.h +++ b/portable/GCC/ARM_CRx_No_GIC/portmacro.h @@ -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 @@ -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 */