Skip to content

Commit 654e73c

Browse files
committed
Fix issues identified during zephyr integration
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
1 parent 3b9d198 commit 654e73c

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

include/utils/utils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ extern "C" {
5151
#define STRINGIFY(x) #x
5252
#endif
5353

54+
#ifndef ROUND_UP
5455
#define ROUND_UP(x, y) ((x + y - 1) & ~ (y - 1))
56+
#endif
5557

5658
#define MATH_MOD(a, b) (((a % b) + b) % b)
5759

@@ -65,20 +67,26 @@ extern "C" {
6567

6668
#define OFFSET_OF(type, field) (size_t)(&((type *)(0))->field)
6769

70+
#ifndef CONTAINER_OF
6871
#define CONTAINER_OF(ptr, type, field) \
6972
((type *)(((char *)(ptr)) - OFFSET_OF(type, field)))
73+
#endif
7074

75+
#ifndef MAX
7176
#define MAX(a,b) ({ \
7277
__typeof__ (a) _a = (a); \
7378
__typeof__ (b) _b = (b); \
7479
_a > _b ? _a : _b; \
7580
})
81+
#endif
7682

83+
#ifndef MIN
7784
#define MIN(a,b) ({ \
7885
__typeof__ (a) _a = (a); \
7986
__typeof__ (b) _b = (b); \
8087
_a > _b ? _b : _a; \
8188
})
89+
#endif
8290

8391
#define SWAP(a,b) { \
8492
__typeof__ (a) _tmp; \
@@ -102,12 +110,14 @@ extern "C" {
102110
#define ABS(x) ((x) >= 0 ? (x) : -(x))
103111

104112
/* config_enabled() from the kernel */
113+
#ifndef IS_ENABLED
105114
#define __IS_ENABLED1(x) __IS_ENABLED2(__XXXX ## x)
106115
#define __XXXX1 __YYYY,
107116
#define __IS_ENABLED2(y) __IS_ENABLED3(y 1, 0)
108117
#define __IS_ENABLED3(_i, val, ...) val
109118

110119
#define IS_ENABLED(x) __IS_ENABLED1(x)
120+
#endif
111121

112122
/* gcc attribute shorthands */
113123
#ifndef __fallthrough

src/logger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const char *log_level_names[LOG_MAX_LEVEL] = {
5959

6060
static inline void logger_log_set_color(logger_t *ctx, const char *color)
6161
{
62-
#if !defined(__BARE_METAL__)
62+
#if !defined(__BARE_METAL__) && !defined(__ZEPHYR__)
6363
size_t ret, len;
6464

6565
if (ctx->flags & LOGGER_FLAG_NO_COLORS)

src/utils.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ int add_iso8601_utc_datetime(char* buf, size_t size) {
182182

183183
#include <sys/time.h>
184184

185+
int add_iso8601_utc_datetime(char *buf, size_t size)
186+
{
187+
ARG_UNUSED(buf);
188+
ARG_UNUSED(size);
189+
return 0;
190+
}
191+
185192
#elif defined(__BARE_METAL__)
186193

187194
#ifndef _TIMEVAL_DEFINED

0 commit comments

Comments
 (0)