forked from epagris/FreeRTOS-Kernel
		
	Add code to allow building for x64 in MSVC (#924)
* Add code to allow building for x64 in MSVC - Add code for x64 arch. - Add initial value for local otherwise it won't get proper value in x64. * Moving init local to portGET_HIGHEST_PRIORITY - From code review. * More changes following review * Another style fix from review * Update formatting Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> Co-authored-by: Soren Ptak <ptaksoren@gmail.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
		
							parent
							
								
									1860c9ad09
								
							
						
					
					
						commit
						722596eaae
					
				@ -121,32 +121,50 @@ void vPortExitCritical( void );
 | 
			
		||||
    #define configUSE_PORT_OPTIMISED_TASK_SELECTION    1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*-----------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
 | 
			
		||||
 | 
			
		||||
/* Check the configuration. */
 | 
			
		||||
    /* Check the configuration. */
 | 
			
		||||
    #if ( configMAX_PRIORITIES > 32 )
 | 
			
		||||
        #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
/* Store/clear 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 ) )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*-----------------------------------------------------------*/
 | 
			
		||||
    /* Store/clear the ready priorities in a bit map. */
 | 
			
		||||
    #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities )    ( uxReadyPriorities ) |= ( ( ( UBaseType_t ) 1 ) << ( uxPriority ) )
 | 
			
		||||
    #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities )     ( uxReadyPriorities ) &= ~( ( ( UBaseType_t ) 1 ) << ( uxPriority ) )
 | 
			
		||||
 | 
			
		||||
    #ifdef __GNUC__
 | 
			
		||||
        #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
 | 
			
		||||
    __asm volatile ( "bsr %1, %0\n\t"                                        \
 | 
			
		||||
                     : "=r" ( uxTopPriority ) : "rm" ( uxReadyPriorities ) : "cc" )
 | 
			
		||||
    #else
 | 
			
		||||
 | 
			
		||||
/* BitScanReverse returns the bit position of the most significant '1'
 | 
			
		||||
 * in the word. */
 | 
			
		||||
        #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
 | 
			
		||||
        #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    \
 | 
			
		||||
        __asm volatile ( "bsr %1, %0\n\t"                                       \
 | 
			
		||||
                         : "=r" ( uxTopPriority )                               \
 | 
			
		||||
                         : "rm" ( uxReadyPriorities )                           \
 | 
			
		||||
                         : "cc" )
 | 
			
		||||
 | 
			
		||||
    #else /* __GNUC__ */
 | 
			
		||||
 | 
			
		||||
        /* BitScanReverse returns the bit position of the most significant '1'
 | 
			
		||||
         * in the word. */
 | 
			
		||||
        #if defined( __x86_64__ ) || defined( _M_X64 )
 | 
			
		||||
 | 
			
		||||
            #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    \
 | 
			
		||||
            do                                                                      \
 | 
			
		||||
            {                                                                       \
 | 
			
		||||
                DWORD ulTopPriority;                                                \
 | 
			
		||||
                _BitScanReverse64( &ulTopPriority, ( uxReadyPriorities ) );         \
 | 
			
		||||
                uxTopPriority = ulTopPriority;                                      \
 | 
			
		||||
            } while( 0 )
 | 
			
		||||
 | 
			
		||||
        #else /* #if defined( __x86_64__ ) || defined( _M_X64 ) */
 | 
			
		||||
 | 
			
		||||
            #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
 | 
			
		||||
 | 
			
		||||
        #endif /* #if defined( __x86_64__ ) || defined( _M_X64 ) */
 | 
			
		||||
 | 
			
		||||
    #endif /* __GNUC__ */
 | 
			
		||||
 | 
			
		||||
#endif /* taskRECORD_READY_PRIORITY */
 | 
			
		||||
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
 | 
			
		||||
 | 
			
		||||
#ifndef __GNUC__
 | 
			
		||||
    __pragma( warning( disable:4211 ) ) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user