RTEMS CPU Kit with SuperCore
4.11.3
Main Page
Related Pages
Modules
+
Data Structures
Data Structures
+
Data Fields
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Functions
_
a
b
c
d
e
f
g
i
j
l
m
n
o
p
q
r
s
t
u
v
w
+
Variables
_
b
c
d
i
r
+
Typedefs
a
b
c
d
f
h
i
m
o
p
q
r
s
t
u
w
x
+
Enumerations
b
c
d
e
h
i
m
o
p
r
s
t
w
+
Enumerator
c
i
m
p
r
s
t
w
+
Macros
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
w
mnt
data0
chrisj
rtems
releases
rtems-release.git
4.11.3
ws-rtems
rtems-4.11.3
cpukit
score
cpu
nios2
rtems
score
nios2-count-zeros.h
Go to the documentation of this file.
1
/*
2
* Author: Jeffrey O. Hill
3
*
4
* Copyright 2012. Los Alamos National Security, LLC.
5
* This material was produced under U.S. Government contract
6
* DE-AC52-06NA25396 for Los Alamos National Laboratory (LANL),
7
* which is operated by Los Alamos National Security, LLC for
8
* the U.S. Department of Energy. The U.S. Government has rights
9
* to use, reproduce, and distribute this software. NEITHER THE
10
* GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY
11
* WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR
12
* THE USE OF THIS SOFTWARE.
13
*
14
* The license and distribution terms for this file may be
15
* found in the file LICENSE in this distribution or at
16
* http://www.rtems.org/license/LICENSE.
17
*/
18
19
#ifndef _NIOS2_COUNT_ZEROS_H
20
#define _NIOS2_COUNT_ZEROS_H
21
22
#include <stdint.h>
23
24
#include <rtems/score/bitfield.h>
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
/* __cplusplus */
29
30
/*
31
* This implementation is currently much more efficient than
32
* the GCC provided __builtin_clz
33
*/
34
static
inline
unsigned
_Nios2_Count_leading_zeros( uint32_t p )
35
{
36
unsigned
bitIdx;
37
38
if
( p <= 0xffffu ) {
39
if
( p < 0x100u ) {
40
bitIdx =
__log2table
[ p ] + 24u;
41
}
else
{
42
bitIdx =
__log2table
[ p >> 8u ] + 16u;
43
}
44
}
else
{
45
p >>= 16u;
46
47
if
( p < 0x100u ) {
48
bitIdx =
__log2table
[ p ] + 8u;
49
}
else
{
50
bitIdx =
__log2table
[ p >> 8u ];
51
}
52
}
53
54
return
bitIdx;
55
}
56
57
/*
58
* This implementation is currently much more efficient than
59
* the GCC provided __builtin_ctz
60
*/
61
static
inline
unsigned
_Nios2_Count_trailing_zeros( uint32_t p )
62
{
63
return
31u - _Nios2_Count_leading_zeros( p & ( -p ) );
64
}
65
66
#ifdef __cplusplus
67
}
68
#endif
/* __cplusplus */
69
70
#endif
/* _NIOS2_COUNT_ZEROS_H */
__log2table
const unsigned char __log2table[256]
This table is used by the generic bitfield routines to perform a highly optimized bit scan without th...
Definition:
log2table.c:25
Generated by
1.8.13