Skip to content

Commit ff23755

Browse files
oyvindronningstadjfischer-no
authored andcommitted
[nrf fromtree] zcbor: Copy source and header files
from zcbor 0.8.1 Signed-off-by: Øyvind Rønningstad <[email protected]> (cherry picked from commit c8d213a)
1 parent b16b1a9 commit ff23755

File tree

8 files changed

+40
-17
lines changed

8 files changed

+40
-17
lines changed

boot/zcbor/include/zcbor_common.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*
@@ -22,6 +22,23 @@
2222
extern "C" {
2323
#endif
2424

25+
#define ZCBOR_STRINGIFY_PRE(x) #x
26+
#define ZCBOR_STRINGIFY(s) ZCBOR_STRINGIFY_PRE(s)
27+
28+
#define ZCBOR_VERSION_MAJOR 0
29+
#define ZCBOR_VERSION_MINOR 8
30+
#define ZCBOR_VERSION_BUGFIX 1
31+
32+
/** The version string with dots and not prefix. */
33+
#define ZCBOR_VERSION_STR ZCBOR_STRINGIFY(ZCBOR_VERSION_MAJOR) \
34+
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_MINOR) \
35+
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_BUGFIX)
36+
37+
/** Monotonically increasing integer representing the version. */
38+
#define ZCBOR_VERSION ((ZCBOR_VERSION_MAJOR << 24) \
39+
+ (ZCBOR_VERSION_MINOR << 16) \
40+
+ (ZCBOR_VERSION_BUGFIX << 8))
41+
2542
/** Convenience type that allows pointing to strings directly inside the payload
2643
* without the need to copy out.
2744
*/
@@ -488,6 +505,8 @@ static inline size_t zcbor_flags_to_states(size_t num_flags)
488505
#define ZCBOR_FLAG_STATES(n_flags) 0
489506
#endif
490507

508+
size_t strnlen(const char *, size_t);
509+
491510
#ifdef __cplusplus
492511
}
493512
#endif

boot/zcbor/include/zcbor_decode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

boot/zcbor/include/zcbor_encode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

boot/zcbor/include/zcbor_print.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*
@@ -93,23 +93,27 @@ static void zcbor_print_compare_lines(const uint8_t *str1, const uint8_t *str2,
9393
__attribute__((used))
9494
static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2, uint32_t size)
9595
{
96-
for (uint32_t i = 0; i <= size / 16; i++) {
97-
zcbor_do_print("line %d (char %d)\r\n", i, i*16);
98-
zcbor_print_compare_lines(&str1[i*16], &str2[i*16],
99-
MIN(16, (size - i*16)));
96+
const size_t col_width = 16;
97+
98+
for (size_t i = 0; i <= size / col_width; i++) {
99+
zcbor_do_print("line %zu (char %zu)\r\n", i, i*col_width);
100+
zcbor_print_compare_lines(&str1[i*col_width], &str2[i*col_width],
101+
MIN(col_width, (size - i*col_width)));
100102
}
101103
zcbor_do_print("\r\n");
102104
}
103105

104106
__attribute__((used))
105107
static void zcbor_print_compare_strings_diff(const uint8_t *str1, const uint8_t *str2, uint32_t size)
106108
{
109+
const size_t col_width = 16;
107110
bool printed = false;
108-
for (uint32_t i = 0; i <= size / 16; i++) {
109-
if (memcmp(&str1[i*16], &str2[i*16], MIN(16, (size - i*16))) != 0) {
110-
zcbor_do_print("line %d (char %d)\r\n", i, i*16);
111-
zcbor_print_compare_lines(&str1[i*16], &str2[i*16],
112-
MIN(16, (size - i*16)));
111+
112+
for (size_t i = 0; i <= size / col_width; i++) {
113+
if (memcmp(&str1[i*col_width], &str2[i*col_width], MIN(col_width, (size - i*col_width))) != 0) {
114+
zcbor_do_print("line %zu (char %zu)\r\n", i, i*col_width);
115+
zcbor_print_compare_lines(&str1[i*col_width], &str2[i*col_width],
116+
MIN(col_width, (size - i*col_width)));
113117
printed = true;
114118
}
115119
}

boot/zcbor/include/zcbor_tags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

boot/zcbor/src/zcbor_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

boot/zcbor/src/zcbor_decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

boot/zcbor/src/zcbor_encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file has been copied from the zcbor library.
3-
* Commit zcbor 0.8.0
3+
* Commit zcbor 0.8.1
44
*/
55

66
/*

0 commit comments

Comments
 (0)