From: Karel Zak Date: Thu, 9 Apr 2026 08:16:30 +0000 (+0200) Subject: irqtop: add vw_printw() fallback for slang builds X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;h=e67a2ea47738b76e5cb9ccfe8ce28e18e028d755;p=thirdparty%2Futil-linux.git irqtop: add vw_printw() fallback for slang builds The vw_printw() function and OK macro are ncurses-specific and not available in slang's curses compatibility layer. This causes build failures when configuring with --with-slang. Add configure/meson checks for vw_printw() availability and provide a portable fallback implementation using vsnprintf() and waddstr() when the function is not available. Addresses: https://github.com/util-linux/util-linux/issues/4177 Signed-off-by: Karel Zak --- diff --git a/configure.ac b/configure.ac index 4c824eb12..93f4f8afe 100644 --- a/configure.ac +++ b/configure.ac @@ -1223,6 +1223,10 @@ AS_IF([test "x$have_slang" = xyes || test "x$have_ncursesw" = xyes || test "x$ha AC_DEFINE(HAVE_RESIZETERM, 1, [Define if curses library has the resizeterm().]) ]) + AC_CHECK_LIB([$CURSES_LIB_NAME], vw_printw, [ + AC_DEFINE(HAVE_VW_PRINTW, 1, + [Define if curses library has the vw_printw().]) + ]) ]) diff --git a/meson.build b/meson.build index 88c6bdf5f..19f7f02b0 100644 --- a/meson.build +++ b/meson.build @@ -320,6 +320,8 @@ foreach curses_libs : [lib_slang, lib_ncursesw, lib_ncurses] conf.set('HAVE_USE_DEFAULT_COLORS', have ? 1 : false) have = cc.has_function('resizeterm', dependencies : curses_libs) conf.set('HAVE_RESIZETERM', have ? 1 : false) + have = cc.has_function('vw_printw', dependencies : curses_libs) + conf.set('HAVE_VW_PRINTW', have ? 1 : false) break endif endforeach diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index d0b331119..c017053e7 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -86,6 +86,21 @@ struct irqtop_ctl { softirq; }; +#ifndef OK +# define OK 0 +#endif + +#ifndef HAVE_VW_PRINTW +static inline int vw_printw(WINDOW *win, const char *fmt, va_list args) +{ + char buf[BUFSIZ]; + + if (vsnprintf(buf, sizeof(buf), fmt, args) < 0) + return ERR; + return waddstr(win, buf); +} +#endif + static inline int irqtop_printf(struct irqtop_ctl *ctl, const char *fmt, ...) { int ret = 0;