[ac7d5ef0] | 1 | /* bitfield.h |
---|
| 2 | * |
---|
| 3 | * This include file contains all bit field manipulation routines. |
---|
| 4 | * |
---|
| 5 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * All rights assigned to U.S. Government, 1994. |
---|
| 8 | * |
---|
| 9 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 10 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 11 | * notice must appear in all copies of this file and its derivatives. |
---|
| 12 | * |
---|
| 13 | * $Id$ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #ifndef __RTEMS_BITFIELD_h |
---|
| 17 | #define __RTEMS_BITFIELD_h |
---|
| 18 | |
---|
| 19 | #ifdef __cplusplus |
---|
| 20 | extern "C" { |
---|
| 21 | #endif |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | * _Bitfield_Find_first_bit |
---|
| 25 | * |
---|
| 26 | * DESCRIPTION: |
---|
| 27 | * |
---|
| 28 | * This routine returns the bit_number of the first bit set |
---|
| 29 | * in the specified value. The correspondence between bit_number |
---|
| 30 | * and actual bit position is processor dependent. The search for |
---|
| 31 | * the first bit set may run from most to least significant bit |
---|
| 32 | * or vice-versa. |
---|
| 33 | * |
---|
| 34 | * NOTE: |
---|
| 35 | * |
---|
| 36 | * This routine is used when the executing thread is removed |
---|
| 37 | * from the ready state and, as a result, its performance has a |
---|
| 38 | * significant impact on the performance of the executive as a whole. |
---|
| 39 | */ |
---|
| 40 | |
---|
[9700578] | 41 | #if ( CPU_USE_GENERIC_BITFIELD_DATA == TRUE ) |
---|
| 42 | |
---|
[c627b2a3] | 43 | #ifndef SCORE_INIT |
---|
| 44 | extern const unsigned char __log2table[256]; |
---|
[9700578] | 45 | #else |
---|
| 46 | const unsigned char __log2table[256] = { |
---|
| 47 | 7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, |
---|
| 48 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
---|
| 49 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 50 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
| 51 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
| 52 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
| 53 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
| 54 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
| 55 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 56 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 58 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 59 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 60 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 61 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
| 62 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
---|
| 63 | }; |
---|
| 64 | #endif |
---|
| 65 | |
---|
| 66 | #endif |
---|
| 67 | |
---|
| 68 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) |
---|
| 69 | |
---|
[ac7d5ef0] | 70 | #define _Bitfield_Find_first_bit( _value, _bit_number ) \ |
---|
| 71 | _CPU_Bitfield_Find_first_bit( _value, _bit_number ) |
---|
| 72 | |
---|
[9700578] | 73 | #else |
---|
| 74 | |
---|
| 75 | /* |
---|
| 76 | * The following must be a macro because if a CPU specific version |
---|
| 77 | * is used it will most likely use inline assembly. |
---|
| 78 | */ |
---|
| 79 | |
---|
| 80 | #define _Bitfield_Find_first_bit( _value, _bit_number ) \ |
---|
| 81 | { \ |
---|
| 82 | register __value = (_value); \ |
---|
| 83 | register const unsigned char *__p = __log2table; \ |
---|
| 84 | \ |
---|
| 85 | if ( __value < 0x100 ) \ |
---|
| 86 | (_bit_number) = __p[ __value ] + 8; \ |
---|
| 87 | else \ |
---|
| 88 | (_bit_number) = __p[ __value >> 8 ]; \ |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | #endif |
---|
| 92 | |
---|
[ac7d5ef0] | 93 | #ifdef __cplusplus |
---|
| 94 | } |
---|
| 95 | #endif |
---|
| 96 | |
---|
| 97 | #endif |
---|
| 98 | /* end of include file */ |
---|