basic: Move assertion specific functions to assert-util.h

Various functions in log.h are only used by asserts, and there's
enough assertion related stuff in macro.h to justify a separate header
which also makes it easier to avoid circular dependencies.

Let's introduce assert-util.h and an accompanying fundamental header
and move all the assertion related stuff over there. PROJECT_FILE is
moved over to macro.h.
This commit is contained in:
Daan De Meyer
2025-04-18 13:59:06 +02:00
parent edfd847d47
commit 03e17cbe6e
27 changed files with 218 additions and 196 deletions
-24
View File
@@ -79,9 +79,6 @@ int log_show_tid_from_string(const char *e);
* environment should not be called from library code — this is always a job
* for the application itself. */
assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1);
#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1])
bool stderr_is_journal(void);
int log_open(void);
void log_close(void);
@@ -185,24 +182,6 @@ int log_dump_internal(
const char *func,
char *buffer);
/* Logging for various assertions */
_noreturn_ void log_assert_failed(
const char *text,
const char *file,
int line,
const char *func);
_noreturn_ void log_assert_failed_unreachable(
const char *file,
int line,
const char *func);
void log_assert_failed_return(
const char *text,
const char *file,
int line,
const char *func);
#define log_dispatch(level, error, buffer) \
log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer)
@@ -336,9 +315,6 @@ void log_set_open_when_needed(bool b);
* stderr, the console or kmsg */
void log_set_prohibit_ipc(bool b);
void log_set_assert_return_is_critical(bool b);
bool log_get_assert_return_is_critical(void) _pure_;
int log_dup_console(void);
int log_syntax_internal(