Zephyr API Documentation 4.2.0-rc3
A Scalable Open Source RTOS
 4.2.0-rc3
service.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tomasz Bursztyka.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SERVICE_H_
8#define ZEPHYR_INCLUDE_SERVICE_H_
9
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
25
31struct service {
35 int (*init)(void);
36};
37
39
48#define Z_SERVICE_NAME_GET(name) _CONCAT(__service_, name)
49
55#define Z_SERVICE_INIT(init_fn) \
56 { \
57 .init = (init_fn) \
58 }
59
66#define Z_SERVICE_SECTION_NAME(level, prio) \
67 _CONCAT(INIT_LEVEL_ORD(level), _##prio)
68
77#define Z_SERVICE_DEFINE(name, init_fn, level, prio) \
78 static const \
79 STRUCT_SECTION_ITERABLE_NAMED_ALTERNATE( \
80 service, service, \
81 Z_SERVICE_SECTION_NAME(level, prio), \
82 Z_SERVICE_NAME_GET(name)) = Z_SERVICE_INIT(init_fn)
83
85
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif /* ZEPHYR_INCLUDE_SERVICE_H_ */
Structure to store service instance.
Definition service.h:31
int(* init)(void)
Initialization function.
Definition service.h:35