Zephyr API Documentation
4.1.99
A Scalable Open Source RTOS
4.1.99
Toggle main menu visibility
Main Page
Related Pages
Topics
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
Enumerations
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
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
z
Variables
$
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
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
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
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
▼
Zephyr API Documentation
►
Introduction
Deprecated List
►
Topics
►
Data Structures
▼
Files
▼
File List
►
doc
►
kernel
►
lib
►
modules
►
subsys
▼
zephyr
►
acpi
►
app_memory
▼
arch
►
arc
►
arm
►
arm64
▼
common
►
addr_types.h
exc_handle.h
►
ffs.h
►
pm_s2ram.h
►
semihost.h
►
sys_bitops.h
►
sys_io.h
►
mips
►
posix
►
riscv
►
rx
►
sparc
►
x86
►
xtensa
arch_inlines.h
►
arch_interface.h
►
cache.h
cpu.h
exception.h
structs.h
syscall.h
►
audio
►
bluetooth
►
canbus
►
console
►
crypto
►
data
►
debug
►
devicetree
►
dfu
►
display
►
drivers
►
dsp
►
dt-bindings
►
fs
►
input
►
internal
►
ipc
►
kernel
►
linker
►
llext
►
logging
►
lorawan
►
math
►
mem_mgmt
►
mgmt
►
misc
►
modbus
►
modem
►
multi_heap
►
net
►
platform
►
pm
►
pmci
►
portability
►
posix
►
psa
►
random
►
retention
►
rtio
►
sd
►
sensing
►
settings
►
shell
►
sip_svc
►
stats
►
storage
►
sys
►
task_wdt
►
timing
►
toolchain
►
tracing
►
usb
►
usb_c
►
virtio
►
xen
►
zbus
►
zvfs
►
bindesc.h
►
cache.h
►
device.h
►
devicetree.h
►
fatal.h
►
fatal_types.h
►
init.h
►
irq.h
►
irq_multilevel.h
►
irq_nextlevel.h
►
irq_offload.h
►
kernel.h
kernel_includes.h
►
kernel_structs.h
►
kernel_version.h
►
net_buf.h
►
shared_irq.h
►
smf.h
►
spinlock.h
►
sw_isr_table.h
►
sys_clock.h
►
syscall.h
►
toolchain.h
types.h
►
Globals
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
ffs.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, Wind River Systems, Inc.
3
* Copyright (c) 2017, Oticon A/S
4
*
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
8
#ifndef ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_
9
#define ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_
10
11
#ifndef _ASMLANGUAGE
12
13
#include <
zephyr/types.h
>
14
#include <
zephyr/toolchain.h
>
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
32
static
ALWAYS_INLINE
unsigned
int
find_msb_set
(
uint32_t
op)
33
{
34
if
(op == 0) {
35
return
0;
36
}
37
38
return
32 - __builtin_clz(op);
39
}
32
static
ALWAYS_INLINE
unsigned
int
find_msb_set
(
uint32_t
op) {
…
}
40
41
54
static
ALWAYS_INLINE
unsigned
int
find_lsb_set
(
uint32_t
op)
55
{
56
#ifdef CONFIG_TOOLCHAIN_HAS_BUILTIN_FFS
57
return
__builtin_ffs(op);
58
59
#else
60
/*
61
* Toolchain does not have __builtin_ffs(). Leverage find_lsb_set()
62
* by first clearing all but the lowest set bit.
63
*/
64
65
op = op ^ (op & (op - 1));
66
67
return
find_msb_set
(op);
68
#endif
/* CONFIG_TOOLCHAIN_HAS_BUILTIN_FFS */
69
}
54
static
ALWAYS_INLINE
unsigned
int
find_lsb_set
(
uint32_t
op) {
…
}
70
71
#ifdef __cplusplus
72
}
73
#endif
74
75
#endif
/* _ASMLANGUAGE */
76
77
#endif
/* ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_ */
find_msb_set
static ALWAYS_INLINE unsigned int find_msb_set(uint32_t op)
find most significant bit set in a 32-bit word
Definition
ffs.h:32
find_lsb_set
static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op)
find least significant bit set in a 32-bit word
Definition
ffs.h:54
ALWAYS_INLINE
#define ALWAYS_INLINE
Definition
common.h:160
types.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:90
toolchain.h
Macros to abstract toolchain specific capabilities.
zephyr
arch
common
ffs.h
Generated on Tue Jun 3 2025 21:07:34 for Zephyr API Documentation by
1.12.0