Skip to content

Commit 28a62d7

Browse files
committed
Merge branch 'Explorer09-strchrnul-darwin'
2 parents da7bb15 + 0a57ba0 commit 28a62d7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

configure.ac

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,28 @@ AC_CHECK_FUNCS([ \
371371
readlinkat \
372372
sched_getscheduler \
373373
sched_setscheduler \
374-
strchrnul \
375374
])
376375

376+
# strchrnul is available in macOS since 15.4, but the user may specify an older
377+
# macOS version ('-mmacos-version-min') to build for. We need to ensure it is
378+
# actually exposed in the header.
379+
htop_save_CFLAGS=$CFLAGS
380+
CFLAGS="$CFLAGS -Werror"
381+
382+
AC_MSG_CHECKING([for strchrnul])
383+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
384+
#include <string.h>
385+
]], [[
386+
static char ch;
387+
char* ptr = strchrnul(&ch, 0);
388+
return ptr != &ch; /* Should be 0 (exit success) */
389+
]])],
390+
[AC_MSG_RESULT(yes)
391+
AC_DEFINE([HAVE_STRCHRNUL], [1], [Define to 1 if you have the 'strchrnul' function.])],
392+
[AC_MSG_RESULT(no)])
393+
394+
CFLAGS=$htop_save_CFLAGS
395+
377396
if test "$my_htop_platform" = darwin; then
378397
AC_CHECK_FUNCS([host_statistics64], [
379398
AC_CHECK_TYPES([struct vm_statistics64], [], [], [[#include <mach/vm_statistics.h>]])

0 commit comments

Comments
 (0)