Bug 1612025 - Avoid conflict with pread64/pwrite64 defined by libc r=gsvelto
authorMichael Forney <mforney@mforney.org>
Wed, 29 Jan 2020 07:05:44 +0000
changeset 512049 660da1ec99c0b7407bd6683a1504681e3e959f45
parent 512048 fc73a1225106205f070f1a6759e440d9769a058b
child 512050 8d0d054e5d99d943c3036182215d65ff971dab50
push id37068
push usernerli@mozilla.com
push dateWed, 29 Jan 2020 15:51:04 +0000
treeherdermozilla-central@019ae805259f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1612025
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1612025 - Avoid conflict with pread64/pwrite64 defined by libc r=gsvelto musl libc defines these to pread and pwrite respectively, since its off_t is always 64-bit. This causes unintended macro replacement when defining the pread64/pwrite64 wrappers. To prevent this, save the macro definitions at the start of the header and restore them at the end. This is what is already done to work around the same issue on Android NDK. This is a cherry-pick of the following upstream change: https://chromium.googlesource.com/linux-syscall-support/+/f70e2f1641e280e777edfdad7f73a2cfa38139c7%5E%21/ This change was also applied to google-breakpad here: https://chromium.googlesource.com/breakpad/breakpad/+/647158232ba153d33c984f201b0ee35384e684cc%5E%21/ Differential Revision: https://phabricator.services.mozilla.com/D61205
toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h
--- a/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h
+++ b/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h
@@ -125,28 +125,33 @@ extern "C" {
  */
 #include <asm/sgidefs.h>
 #else
 #include <sgidefs.h>
 #endif
 #endif
 #endif
 
-/* The Android NDK's <sys/stat.h> #defines these macros as aliases
- * to their non-64 counterparts. To avoid naming conflict, remove them. */
-#ifdef __ANDROID__
-  /* These are restored by the corresponding #pragma pop_macro near
-   * the end of this file. */
-# pragma push_macro("stat64")
-# pragma push_macro("fstat64")
-# pragma push_macro("lstat64")
-# undef stat64
-# undef fstat64
-# undef lstat64
-#endif
+/* Some libcs, for example Android NDK and musl, #define these
+ * macros as aliases to their non-64 counterparts. To avoid naming
+ * conflict, remove them.
+ *
+ * These are restored by the corresponding #pragma pop_macro near
+ * the end of this file.
+ */
+#pragma push_macro("stat64")
+#pragma push_macro("fstat64")
+#pragma push_macro("lstat64")
+#pragma push_macro("pread64")
+#pragma push_macro("pwrite64")
+#undef stat64
+#undef fstat64
+#undef lstat64
+#undef pread64
+#undef pwrite64
 
 #if defined(__ANDROID__) && defined(__x86_64__)
 // A number of x86_64 syscalls are blocked by seccomp on recent Android;
 // undefine them so that modern alternatives will be used instead where
 // possible.
 // The alternative syscalls have been sanity checked against linux-3.4+;
 // older versions might not work.
 # undef __NR_getdents
@@ -4514,22 +4519,22 @@ struct kernel_statfs {
              LSS_SYSCALL_ARG(child_stack), LSS_SYSCALL_ARG(parent_tidptr),
              LSS_SYSCALL_ARG(newtls), LSS_SYSCALL_ARG(child_tidptr));
   }
 # else
 #  error missing fork polyfill for this architecture
 # endif
 #endif
 
-#ifdef __ANDROID__
-  /* These restore the original values of these macros saved by the
-   * corresponding #pragma push_macro near the top of this file. */
-# pragma pop_macro("stat64")
-# pragma pop_macro("fstat64")
-# pragma pop_macro("lstat64")
-#endif
+/* These restore the original values of these macros saved by the
+ * corresponding #pragma push_macro near the top of this file. */
+#pragma pop_macro("stat64")
+#pragma pop_macro("fstat64")
+#pragma pop_macro("lstat64")
+#pragma pop_macro("pread64")
+#pragma pop_macro("pwrite64")
 
 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
 }
 #endif
 
 #endif
 #endif