Skip to content

Commit 1a89099

Browse files
committed
utils: Add platform support for zephyr RTOS
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
1 parent 6a78915 commit 1a89099

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/utils/utils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ extern "C" {
4646

4747
#define STR(x) #x
4848
#define XSTR(x) STR(x)
49+
50+
#ifndef __ZEPHYR__
4951
#define STRINGIFY(x) #x
52+
#endif
5053

5154
#define ROUND_UP(x, y) ((x + y - 1) & ~ (y - 1))
5255

@@ -132,6 +135,7 @@ extern "C" {
132135
#endif
133136

134137
#if (defined(_WIN32) || defined(_WIN64))
138+
135139
#include <io.h>
136140
#define isatty _isatty /* from io.h */
137141
#define fileno _fileno
@@ -142,7 +146,17 @@ extern "C" {
142146
#define likely(p) (p)
143147
#define unlikely(p) (p)
144148
#define PATH_SEPARATOR '\\'
149+
150+
#elif defined(__ZEPHYR__)
151+
152+
#include <zephyr/toolchain.h> // __weak, __builtin_xxx() etc.,
153+
154+
#define PATH_SEPARATOR '/'
155+
#define __unreachable() __builtin_unreachable()
156+
#define __format_printf(x, y) __attribute__((format(printf, x, y)))
157+
145158
#else
159+
146160
#define __format_printf(x, y) __attribute__((format(printf, x, y)))
147161
#define __noreturn __attribute__((noreturn))
148162
#define __weak __attribute__((weak))

0 commit comments

Comments
 (0)