[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Avoid compilation error due to 'mmap' on Android
From: |
Bruno Haible |
Subject: |
Avoid compilation error due to 'mmap' on Android |
Date: |
Sun, 13 May 2018 21:34:17 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; ) |
Compiling for Android 4.3, I see a couple of compilation errors, such as
zerosize-ptr.h:59:13: error: call to 'mmap' declared with attribute error: mmap
is not available with _FILE_OFFSET_BITS=64 when using GCC until android-21.
Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or switch to
Clang.
This patch avoids the errors.
2018-05-13 Bruno Haible <address@hidden>
Avoid compilation error due to 'mmap' on Android.
* lib/vma-iter.c (_FILE_OFFSET_BITS): Undefine on Android.
* lib/get-rusage-as.c (_FILE_OFFSET_BITS): Likewise.
* tests/zerosize-ptr.h (_FILE_OFFSET_BITS, __USE_FILE_OFFSET64):
Undefine on Android.
diff --git a/lib/get-rusage-as.c b/lib/get-rusage-as.c
index 096d3d1..e3c3dfd 100644
--- a/lib/get-rusage-as.c
+++ b/lib/get-rusage-as.c
@@ -17,6 +17,18 @@
#include <config.h>
+/* On Android, when targeting Android 4.4 or older with a GCC toolchain,
+ prevent a compilation error
+ "error: call to 'mmap' declared with attribute error: mmap is not
+ available with _FILE_OFFSET_BITS=64 when using GCC until android-21.
+ Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or
+ switch to Clang."
+ The files that we access in this compilation unit are less than 2 GB
+ large. */
+#if defined __ANDROID__
+# undef _FILE_OFFSET_BITS
+#endif
+
/* Specification. */
#include "resource-ext.h"
diff --git a/lib/vma-iter.c b/lib/vma-iter.c
index b98b041..30d19a5 100644
--- a/lib/vma-iter.c
+++ b/lib/vma-iter.c
@@ -20,9 +20,15 @@
/* On Solaris in 32-bit mode, when gnulib module 'largefile' is in use,
prevent a compilation error
"Cannot use procfs in the large file compilation environment"
+ On Android, when targeting Android 4.4 or older with a GCC toolchain,
+ prevent a compilation error
+ "error: call to 'mmap' declared with attribute error: mmap is not
+ available with _FILE_OFFSET_BITS=64 when using GCC until android-21.
+ Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or
+ switch to Clang."
The files that we access in this compilation unit are less than 2 GB
large. */
-#if defined __sun
+#if defined __sun || defined __ANDROID__
# undef _FILE_OFFSET_BITS
#endif
diff --git a/tests/zerosize-ptr.h b/tests/zerosize-ptr.h
index e4867e9..d5592c5 100644
--- a/tests/zerosize-ptr.h
+++ b/tests/zerosize-ptr.h
@@ -18,6 +18,19 @@
argument. Therefore this file produces a non-NULL pointer which cannot
be dereferenced, if possible. */
+/* On Android, when targeting Android 4.4 or older with a GCC toolchain,
+ prevent a compilation error
+ "error: call to 'mmap' declared with attribute error: mmap is not
+ available with _FILE_OFFSET_BITS=64 when using GCC until android-21.
+ Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or
+ switch to Clang."
+ The files that we access in this compilation unit are less than 2 GB
+ large. */
+#if defined __ANDROID__
+# undef _FILE_OFFSET_BITS
+# undef __USE_FILE_OFFSET64
+#endif
+
#include <stdlib.h>
/* Test whether mmap() and mprotect() are available.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Avoid compilation error due to 'mmap' on Android,
Bruno Haible <=