From: Collin Funk Date: Wed, 5 Nov 2025 03:56:18 +0000 (-0800) Subject: nproc: Fix compilation error with Android API ≤ 20. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4db1328fb2f01b83400cfb1f6d6c2bed953177c;p=thirdparty%2Fgnulib.git nproc: Fix compilation error with Android API ≤ 20. Reported by Po Lu in . * lib/nproc.c (cgroup2_mount): Don't assume we have setmntent if we have mntent.h. * m4/nproc.m4 (gl_PREREQ_NPROC): Check if setmntent is supported by the current Android API. --- diff --git a/ChangeLog b/ChangeLog index 940ebffb52..e9eef97cd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2025-11-04 Collin Funk + + nproc: Fix compilation error with Android API ≤ 20. + Reported by Po Lu in + . + * lib/nproc.c (cgroup2_mount): Don't assume we have setmntent if we have + mntent.h. + * m4/nproc.m4 (gl_PREREQ_NPROC): Check if setmntent is supported by the + current Android API. + 2025-11-04 Paul Eggert time_rz: tzfree now preserves errno diff --git a/lib/nproc.c b/lib/nproc.c index e899ff1762..9404be1d38 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -22,7 +22,7 @@ #include #include -#if HAVE_MNTENT_H +#if HAVE_SETMNTENT # include #endif #include @@ -385,7 +385,7 @@ cgroup2_mount (void) if (access ("/sys/fs/cgroup/cgroup.controllers", F_OK) == 0) return strdup ("/sys/fs/cgroup"); -#if HAVE_MNTENT_H +#if HAVE_SETMNTENT /* Otherwise look for the mount point. */ struct mntent *mnt; if (! (fp = setmntent ("/proc/mounts", "r"))) diff --git a/m4/nproc.m4 b/m4/nproc.m4 index 9225779585..e9fba1533c 100644 --- a/m4/nproc.m4 +++ b/m4/nproc.m4 @@ -1,5 +1,5 @@ # nproc.m4 -# serial 7 +# serial 8 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,6 +19,10 @@ AC_DEFUN([gl_PREREQ_NPROC], AC_CHECK_HEADERS([mntent.h sys/pstat.h sys/param.h],,, [AC_INCLUDES_DEFAULT]) + gl_CHECK_FUNCS_ANDROID([setmntent], + [[#include + #include + ]]) dnl requires on OpenBSD 4.0. AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT