Changeset b8a84064 in rtems


Ignore:
Timestamp:
Jun 8, 2016, 6:43:20 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
80bbb4ed
Parents:
7103ad34
git-author:
Sebastian Huber <sebastian.huber@…> (06/08/16 06:43:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/08/16 13:48:03)
Message:

score: Inline _Bitfield_Find_first_bit()

Turn _Bitfield_Find_first_bit() macro into an inline function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/prioritybitmapimpl.h

    r7103ad34 rb8a84064  
    4141
    4242/**
    43  *  @brief Gets the @a _bit_number of the first bit set in the specified value.
    44  *
    45  *  This routine returns the @a _bit_number of the first bit set
    46  *  in the specified value.  The correspondence between @a _bit_number
    47  *  and actual bit position is processor dependent.  The search for
    48  *  the first bit set may run from most to least significant bit
    49  *  or vice-versa.
    50  *
    51  *  @param[in] _value is the value to bit scan.
    52  *  @param[in] _bit_number is the position of the first bit set.
    53  *
    54  *  @note This routine is used when the executing thread is removed
    55  *  from the ready state and, as a result, its performance has a
    56  *  significant impact on the performance of the executive as a whole.
    57  *
    58  *  @note This routine must be a macro because if a CPU specific version
    59  *  is used it will most likely use inline assembly.
    60  */
     43 * @brief Returns the bit number of the first bit set in the specified value.
     44 *
     45 * The correspondence between the bit number and actual bit position is CPU
     46 * architecture dependent.  The search for the first bit set may run from most
     47 * to least significant bit or vice-versa.
     48 *
     49 * @param value The value to bit scan.
     50 *
     51 * @return The bit number of the first bit set.
     52 *
     53 * @see _Priority_Bits_index() and _Priority_Mask().
     54 */
     55RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit(
     56  unsigned int value
     57)
     58{
     59  unsigned int bit_number;
     60
    6161#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
    62 #define _Bitfield_Find_first_bit( _value, _bit_number ) \
    63         _CPU_Bitfield_Find_first_bit( _value, _bit_number )
     62  _CPU_Bitfield_Find_first_bit( value, bit_number );
    6463#else
    65 #define _Bitfield_Find_first_bit( _value, _bit_number ) \
    66   { \
    67     unsigned int __value = (_value); \
    68     const unsigned char *__p = _Bitfield_Leading_zeros; \
    69     \
    70     if ( __value < 0x100 ) \
    71       (_bit_number) = (Priority_bit_map_Word)( __p[ __value ] + 8 );  \
    72     else \
    73       (_bit_number) = (Priority_bit_map_Word)( __p[ __value >> 8 ] ); \
     64  if ( value < 0x100 ) {
     65    bit_number = _Bitfield_Leading_zeros[ value ] + 8;
     66  } else { \
     67    bit_number = _Bitfield_Leading_zeros[ value >> 8 ];
    7468  }
    7569#endif
     70
     71  return bit_number;
     72}
    7673
    7774/**
     
    168165  unsigned int major;
    169166
    170   /* Avoid problems with some inline ASM statements */
    171   unsigned int tmp;
    172 
    173   tmp = bit_map->major_bit_map;
    174   _Bitfield_Find_first_bit( tmp, major );
    175 
    176   tmp = bit_map->bit_map[ major ];
    177   _Bitfield_Find_first_bit( tmp, minor );
     167  major = _Bitfield_Find_first_bit( bit_map->major_bit_map );
     168  minor = _Bitfield_Find_first_bit( bit_map->bit_map[ major ] );
    178169
    179170  return (_Priority_Bits_index( major ) << 4) +
Note: See TracChangeset for help on using the changeset viewer.