]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
nproc: Fix compilation error with Android API ≤ 20.
authorCollin Funk <collin.funk1@gmail.com>
Wed, 5 Nov 2025 03:56:18 +0000 (19:56 -0800)
committerPádraig Brady <P@draigBrady.com>
Wed, 5 Nov 2025 16:23:11 +0000 (16:23 +0000)
Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00027.html>.

* 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.

ChangeLog
lib/nproc.c
m4/nproc.m4

index 940ebffb52abf3cb008c160db01dff86c6068420..e9eef97cd5301961bd7a1d9b7578a5a905c4006d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-11-04  Collin Funk  <collin.funk1@gmail.com>
+
+       nproc: Fix compilation error with Android API ≤ 20.
+       Reported by Po Lu in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00027.html>.
+       * 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  <eggert@cs.ucla.edu>
 
        time_rz: tzfree now preserves errno
index e899ff17620cb72c92efd5ae05276e13c633eb12..9404be1d384b321192500d6265956f05c1409d78 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <errno.h>
 #include <limits.h>
-#if HAVE_MNTENT_H
+#if HAVE_SETMNTENT
 # include <mntent.h>
 #endif
 #include <stdlib.h>
@@ -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")))
index 9225779585a817033cdf36f173fc6b4232ffb62c..e9fba1533cad4dbca9f91fefa347bcc04f73af9d 100644 (file)
@@ -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 <stdio.h>
+      #include <mntent.h>
+    ]])
   dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
   AC_CHECK_HEADERS([sys/sysctl.h],,,
     [AC_INCLUDES_DEFAULT