changeset 40149:e1f68c6256cf

vma-iter: Add support for Android. * lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define on Android as well. * lib/vma-iter.c: Treat Android like Linux. * lib/get-rusage-data.c (get_rusage_data): Likewise.
author Bruno Haible <bruno@clisp.org>
date Sun, 27 Jan 2019 04:57:29 +0100
parents 5be6b690b930
children dd38f4180e3f
files ChangeLog lib/get-rusage-data.c lib/vma-iter.c lib/vma-iter.h
diffstat 4 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 27 04:57:27 2019 +0100
+++ b/ChangeLog	Sun Jan 27 04:57:29 2019 +0100
@@ -1,3 +1,10 @@
+2019-01-26  Bruno Haible  <bruno@clisp.org>
+
+	vma-iter: Add support for Android.
+	* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define on Android as well.
+	* lib/vma-iter.c: Treat Android like Linux.
+	* lib/get-rusage-data.c (get_rusage_data): Likewise.
+
 2019-01-26  Bruno Haible  <bruno@clisp.org>
 
 	fts: Optimize on Android.
--- a/lib/get-rusage-data.c	Sun Jan 27 04:57:27 2019 +0100
+++ b/lib/get-rusage-data.c	Sun Jan 27 04:57:29 2019 +0100
@@ -413,7 +413,7 @@
      Prefer get_rusage_data_via_iterator().  */
   return get_rusage_data_via_iterator ();
 #elif HAVE_SETRLIMIT && defined RLIMIT_DATA && !defined __HAIKU__
-# if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined _AIX || defined __hpux || defined __sgi || defined __osf__ || defined __sun /* Linux, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris */
+# if defined __linux__ || defined __ANDROID__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined _AIX || defined __hpux || defined __sgi || defined __osf__ || defined __sun /* Linux, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris */
   /* get_rusage_data_via_setrlimit() works.  */
   return get_rusage_data_via_setrlimit ();
 # else
--- a/lib/vma-iter.c	Sun Jan 27 04:57:27 2019 +0100
+++ b/lib/vma-iter.c	Sun Jan 27 04:57:29 2019 +0100
@@ -40,11 +40,11 @@
 #include <fcntl.h> /* open, O_RDONLY */
 #include <unistd.h> /* getpagesize, lseek, read, close, getpid */
 
-#if defined __linux__
+#if defined __linux__ || defined __ANDROID__
 # include <limits.h> /* PATH_MAX */
 #endif
 
-#if defined __linux__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
+#if defined __linux__ || defined __ANDROID__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
 # include <sys/types.h>
 # include <sys/mman.h> /* mmap, munmap */
 #endif
@@ -112,7 +112,7 @@
 
 /* Support for reading text files in the /proc file system.  */
 
-#if defined __linux__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
+#if defined __linux__ || defined __ANDROID__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
 
 /* Buffered read-only streams.
    We cannot use <stdio.h> here, because fopen() calls malloc(), and a malloc()
@@ -129,7 +129,7 @@
        VMAs with nonsensical addresses.
    So use mmap(), and ignore the resulting VMA.  */
 
-# ifdef __linux__
+# if defined __linux__ || defined __ANDROID__
   /* On Linux, if the file does not entirely fit into the buffer, the read()
      function stops before the line that would come out truncated.  The
      maximum size of such a line is 73 + PATH_MAX bytes.  To be sure that we
@@ -205,7 +205,7 @@
                 {
                   /* The buffer was sufficiently large.  */
                   rof->filled = n;
-# ifdef __linux__
+# if defined __linux__ || defined __ANDROID__
                   /* On Linux, the read() call may stop even if the buffer was
                      large enough.  We need the equivalent of full_read().  */
                   for (;;)
@@ -342,7 +342,7 @@
 
 /* Support for reading the info from a text file in the /proc file system.  */
 
-#if defined __linux__ || (defined __FreeBSD_kernel__ && !defined __FreeBSD__) /* || defined __CYGWIN__ */
+#if defined __linux__ || defined __ANDROID__ || (defined __FreeBSD_kernel__ && !defined __FreeBSD__) /* || defined __CYGWIN__ */
 /* GNU/kFreeBSD mounts /proc as linprocfs, which looks like a Linux /proc
    file system.  */
 
@@ -866,7 +866,7 @@
 int
 vma_iterate (vma_iterate_callback_fn callback, void *data)
 {
-#if defined __linux__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
+#if defined __linux__ || defined __ANDROID__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __minix /* || defined __CYGWIN__ */
 
 # if defined __FreeBSD__
   /* On FreeBSD with procfs (but not GNU/kFreeBSD, which uses linprocfs), the
--- a/lib/vma-iter.h	Sun Jan 27 04:57:27 2019 +0100
+++ b/lib/vma-iter.h	Sun Jan 27 04:57:29 2019 +0100
@@ -52,7 +52,7 @@
    this platform.
    Note that even when this macro is defined, vma_iterate() may still fail to
    find any virtual memory area, for example if /proc is not mounted.  */
-#if defined __linux__ || defined __GNU__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sgi || defined __osf__ || defined __sun || HAVE_PSTAT_GETPROCVM || (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__ || defined __minix || HAVE_MQUERY
+#if defined __linux__ || defined __ANDROID__ || defined __GNU__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sgi || defined __osf__ || defined __sun || HAVE_PSTAT_GETPROCVM || (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__ || defined __minix || HAVE_MQUERY
 # define VMA_ITERATE_SUPPORTED 1
 #endif