From: openocd-gerrit <ope...@us...> - 2025-01-25 10:37:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fceccde0b394cff9127dca13708ef689094c9975 (commit) from 8038e2f7548792a090bdd255ec6bfbf4128fead7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fceccde0b394cff9127dca13708ef689094c9975 Author: Antonio Borneo <bor...@gm...> Date: Mon Feb 19 20:11:07 2024 -0600 helper/log: Fix build using _DEBUG_FREE_SPACE_ The glibc API 'mallinfo' is deprecated and the new 'mallinfo2' should be used from glibc 2.33 (2021-02-01). Throw an error when '--enable-malloc-logging' is used on systems that compile without glibc. Detect the glibc version and, for backward compatibility, define 'mallinfo2' as the old 'mallinfo'. Define a macro for the format of 'fordblks'. Change-Id: I68bff7b1b58f0ec2669db0b911f19c1c5a26ed30 Reported-by: Steven J. Hill <ste...@ko...> Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8589 Tested-by: jenkins diff --git a/src/helper/log.c b/src/helper/log.c index e02556b6d..8f7ab0039 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -30,6 +30,18 @@ #else #error "malloc.h is required to use --enable-malloc-logging" #endif + +#ifdef __GLIBC__ +#if __GLIBC_PREREQ(2, 33) +#define FORDBLKS_FORMAT " %zu" +#else +/* glibc older than 2.33 (2021-02-01) use mallinfo(). Overwrite it */ +#define mallinfo2 mallinfo +#define FORDBLKS_FORMAT " %d" +#endif +#else +#error "GNU glibc is required to use --enable-malloc-logging" +#endif #endif int debug_level = LOG_LVL_INFO; @@ -105,12 +117,11 @@ static void log_puts(enum log_levels level, /* print with count and time information */ int64_t t = timeval_ms() - start; #ifdef _DEBUG_FREE_SPACE_ - struct mallinfo info; - info = mallinfo(); + struct mallinfo2 info = mallinfo2(); #endif fprintf(log_output, "%s%d %" PRId64 " %s:%d %s()" #ifdef _DEBUG_FREE_SPACE_ - " %d" + FORDBLKS_FORMAT #endif ": %s", log_strings[level + 1], count, t, file, line, function, #ifdef _DEBUG_FREE_SPACE_ ----------------------------------------------------------------------- Summary of changes: src/helper/log.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |