dacb3dbfeb
Until now iterable sections APIs have been part of the toolchain (common) headers. They are not strictly related to a toolchain, they just rely on linker providing support for sections. Most files relied on indirect includes to access the API, now, it is included as needed. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
29 lines
680 B
C
29 lines
680 B
C
/*
|
|
* Copyright (c) 2022 Rodrigo Peixoto <rodrigopex@gmail.com>
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#include <zephyr/logging/log.h>
|
|
#include <zephyr/sys/iterable_sections.h>
|
|
#include <zephyr/zbus/zbus.h>
|
|
LOG_MODULE_DECLARE(zbus, CONFIG_ZBUS_LOG_LEVEL);
|
|
|
|
bool zbus_iterate_over_channels(bool (*iterator_func)(const struct zbus_channel *chan))
|
|
{
|
|
STRUCT_SECTION_FOREACH(zbus_channel, chan) {
|
|
if (!(*iterator_func)(chan)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool zbus_iterate_over_observers(bool (*iterator_func)(const struct zbus_observer *obs))
|
|
{
|
|
STRUCT_SECTION_FOREACH(zbus_observer, obs) {
|
|
if (!(*iterator_func)(obs)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|