Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
3.0.0
Toggle main menu visibility
Main Page
Related Pages
Modules
Data Structures
Data Structures
Data Structure Index
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
z
Functions
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
z
Enumerator
Files
File List
Globals
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
z
Functions
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
z
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
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
ilog2.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021 Intel Corporation
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
#include <
stdint.h
>
8
9
#include <
toolchain.h
>
10
#include <
arch/common/ffs.h
>
11
#include <
sys/util.h
>
12
36
#define ilog2_compile_time_const_u32(n) \
37
( \
38
(n < 2) ? 0 : \
39
((n & BIT(31)) == BIT(31)) ? 31 : \
40
((n & BIT(30)) == BIT(30)) ? 30 : \
41
((n & BIT(29)) == BIT(29)) ? 29 : \
42
((n & BIT(28)) == BIT(28)) ? 28 : \
43
((n & BIT(27)) == BIT(27)) ? 27 : \
44
((n & BIT(26)) == BIT(26)) ? 26 : \
45
((n & BIT(25)) == BIT(25)) ? 25 : \
46
((n & BIT(24)) == BIT(24)) ? 24 : \
47
((n & BIT(23)) == BIT(23)) ? 23 : \
48
((n & BIT(22)) == BIT(22)) ? 22 : \
49
((n & BIT(21)) == BIT(21)) ? 21 : \
50
((n & BIT(20)) == BIT(20)) ? 20 : \
51
((n & BIT(19)) == BIT(19)) ? 19 : \
52
((n & BIT(18)) == BIT(18)) ? 18 : \
53
((n & BIT(17)) == BIT(17)) ? 17 : \
54
((n & BIT(16)) == BIT(16)) ? 16 : \
55
((n & BIT(15)) == BIT(15)) ? 15 : \
56
((n & BIT(14)) == BIT(14)) ? 14 : \
57
((n & BIT(13)) == BIT(13)) ? 13 : \
58
((n & BIT(12)) == BIT(12)) ? 12 : \
59
((n & BIT(11)) == BIT(11)) ? 11 : \
60
((n & BIT(10)) == BIT(10)) ? 10 : \
61
((n & BIT(9)) == BIT(9)) ? 9 : \
62
((n & BIT(8)) == BIT(8)) ? 8 : \
63
((n & BIT(7)) == BIT(7)) ? 7 : \
64
((n & BIT(6)) == BIT(6)) ? 6 : \
65
((n & BIT(5)) == BIT(5)) ? 5 : \
66
((n & BIT(4)) == BIT(4)) ? 4 : \
67
((n & BIT(3)) == BIT(3)) ? 3 : \
68
((n & BIT(2)) == BIT(2)) ? 2 : \
69
1 \
70
)
71
84
/*
85
* This is in #define form as this needs to also work on
86
* compile time constants. Doing this as a static inline
87
* function will result in compiler complaining with
88
* "initializer element is not constant".
89
*/
90
#define ilog2(n) \
91
( \
92
__builtin_constant_p(n) ? \
93
ilog2_compile_time_const_u32(n) : \
94
find_msb_set(n) - 1 \
95
)
ffs.h
stdint.h
toolchain.h
Macros to abstract toolchain specific capabilities.
util.h
Misc utilities.
include
math
ilog2.h
Generated on Mon Feb 21 2022 22:43:01 for Zephyr API Documentation by
1.9.2