OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [include/] [rtems/] [score/] [bitfield.h] - Blame information for rev 587

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  bitfield.h
2
 *
3
 *  This include file contains all bit field manipulation routines.
4
 *
5
 *  COPYRIGHT (c) 1989-1999.
6
 *  On-Line Applications Research Corporation (OAR).
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: bitfield.h,v 1.2 2001-09-27 11:59:32 chris Exp $
13
 */
14
 
15
#ifndef __RTEMS_BITFIELD_h
16
#define __RTEMS_BITFIELD_h
17
 
18
#ifdef __cplusplus
19
extern "C" {
20
#endif
21
 
22
/*
23
 *  _Bitfield_Find_first_bit
24
 *
25
 *  DESCRIPTION:
26
 *
27
 *  This routine returns the bit_number of the first bit set
28
 *  in the specified value.  The correspondence between bit_number
29
 *  and actual bit position is processor dependent.  The search for
30
 *  the first bit set may run from most to least significant bit
31
 *  or vice-versa.
32
 *
33
 *  NOTE:
34
 *
35
 *  This routine is used when the executing thread is removed
36
 *  from the ready state and, as a result, its performance has a
37
 *  significant impact on the performance of the executive as a whole.
38
 */
39
 
40
#if ( CPU_USE_GENERIC_BITFIELD_DATA == TRUE )
41
 
42
#ifndef SCORE_INIT
43
extern const unsigned char __log2table[256];
44
#else
45
const unsigned char __log2table[256] = {
46
    7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
47
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
48
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
49
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
50
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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
};
63
#endif
64
 
65
#endif
66
 
67
#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
68
 
69
#define _Bitfield_Find_first_bit( _value, _bit_number ) \
70
        _CPU_Bitfield_Find_first_bit( _value, _bit_number )
71
 
72
#else
73
 
74
/*
75
 *  The following must be a macro because if a CPU specific version
76
 *  is used it will most likely use inline assembly.
77
 */
78
 
79
#define _Bitfield_Find_first_bit( _value, _bit_number ) \
80
  { \
81
    register unsigned32 __value = (unsigned32) (_value); \
82
    register const unsigned char *__p = __log2table; \
83
    \
84
    if ( __value < 0x100 ) \
85
      (_bit_number) = __p[ __value ] + 8; \
86
    else \
87
      (_bit_number) = __p[ __value >> 8 ]; \
88
  }
89
 
90
#endif
91
 
92
#ifdef __cplusplus
93
}
94
#endif
95
 
96
#endif
97
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.