Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/libc/newlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
zephyr_library()
zephyr_library_sources(libc-hooks.c)

zephyr_library_sources_ifdef(CONFIG_ASSERT assert.c)

# Zephyr normally uses -ffreestanding, which with current GNU toolchains
# means that the flag macros used by newlib 3.x <inttypes.h> to signal
# support for PRI.64 macros are not present. To make them available we
Expand Down Expand Up @@ -47,4 +49,3 @@ if(CONFIG_NEWLIB_LIBC_NANO)
-specs=nano.specs
)
endif()

22 changes: 22 additions & 0 deletions lib/libc/newlib/assert.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <sys/__assert.h>

/**
*
* @brief Handler of C standard library assert.
*/
void __assert_func(const char *file,
int line,
const char *func,
const char *failedexpr)
{
__ASSERT_LOC(...);
__ASSERT_MSG_INFO("Assertion fail: (%s) at %s:%d",
failedexpr, file, line);
__ASSERT_POST_ACTION();
}
Comment on lines +9 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having this function in a separate file, given that it is unlikely we will ever add more assert-related stuff here, can we move it into libc-hooks.c as with the rest of the newlib hook functions?