Skip to content

Commit

Permalink
[nrf fromtree] zcbor: Copy source and header files
Browse files Browse the repository at this point in the history
from zcbor 0.8.1

Signed-off-by: Øyvind Rønningstad <[email protected]>
(cherry picked from commit c8d213a)
  • Loading branch information
oyvindronningstad committed Feb 16, 2024
1 parent df46b95 commit 9cbf90d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 17 deletions.
21 changes: 20 additions & 1 deletion boot/zcbor/include/zcbor_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand All @@ -22,6 +22,23 @@
extern "C" {
#endif

#define ZCBOR_STRINGIFY_PRE(x) #x
#define ZCBOR_STRINGIFY(s) ZCBOR_STRINGIFY_PRE(s)

#define ZCBOR_VERSION_MAJOR 0
#define ZCBOR_VERSION_MINOR 8
#define ZCBOR_VERSION_BUGFIX 1

/** The version string with dots and not prefix. */
#define ZCBOR_VERSION_STR ZCBOR_STRINGIFY(ZCBOR_VERSION_MAJOR) \
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_MINOR) \
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_BUGFIX)

/** Monotonically increasing integer representing the version. */
#define ZCBOR_VERSION ((ZCBOR_VERSION_MAJOR << 24) \
+ (ZCBOR_VERSION_MINOR << 16) \
+ (ZCBOR_VERSION_BUGFIX << 8))

/** Convenience type that allows pointing to strings directly inside the payload
* without the need to copy out.
*/
Expand Down Expand Up @@ -488,6 +505,8 @@ static inline size_t zcbor_flags_to_states(size_t num_flags)
#define ZCBOR_FLAG_STATES(n_flags) 0
#endif

size_t strnlen(const char *, size_t);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/include/zcbor_decode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/include/zcbor_encode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down
24 changes: 14 additions & 10 deletions boot/zcbor/include/zcbor_print.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down Expand Up @@ -93,23 +93,27 @@ static void zcbor_print_compare_lines(const uint8_t *str1, const uint8_t *str2,
__attribute__((used))
static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2, uint32_t size)
{
for (uint32_t i = 0; i <= size / 16; i++) {
zcbor_do_print("line %d (char %d)\r\n", i, i*16);
zcbor_print_compare_lines(&str1[i*16], &str2[i*16],
MIN(16, (size - i*16)));
const size_t col_width = 16;

for (size_t i = 0; i <= size / col_width; i++) {
zcbor_do_print("line %zu (char %zu)\r\n", i, i*col_width);
zcbor_print_compare_lines(&str1[i*col_width], &str2[i*col_width],
MIN(col_width, (size - i*col_width)));
}
zcbor_do_print("\r\n");
}

__attribute__((used))
static void zcbor_print_compare_strings_diff(const uint8_t *str1, const uint8_t *str2, uint32_t size)
{
const size_t col_width = 16;
bool printed = false;
for (uint32_t i = 0; i <= size / 16; i++) {
if (memcmp(&str1[i*16], &str2[i*16], MIN(16, (size - i*16))) != 0) {
zcbor_do_print("line %d (char %d)\r\n", i, i*16);
zcbor_print_compare_lines(&str1[i*16], &str2[i*16],
MIN(16, (size - i*16)));

for (size_t i = 0; i <= size / col_width; i++) {
if (memcmp(&str1[i*col_width], &str2[i*col_width], MIN(col_width, (size - i*col_width))) != 0) {
zcbor_do_print("line %zu (char %zu)\r\n", i, i*col_width);
zcbor_print_compare_lines(&str1[i*col_width], &str2[i*col_width],
MIN(col_width, (size - i*col_width)));
printed = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/include/zcbor_tags.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/src/zcbor_common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/src/zcbor_decode.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down
2 changes: 1 addition & 1 deletion boot/zcbor/src/zcbor_encode.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file has been copied from the zcbor library.
* Commit zcbor 0.8.0
* Commit zcbor 0.8.1
*/

/*
Expand Down

0 comments on commit 9cbf90d

Please sign in to comment.