summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-22 23:30:31 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:53:13 +0200
commit44c169c9be3cec6957d5b04272a3564cf9137109 (patch)
tree67e67139a70d6907f81e0fd3c74236acd0d84776
parent57383be95da385b336d988ff713b8e3bf097ce0f (diff)
downloadUXP-44c169c9be3cec6957d5b04272a3564cf9137109.tar
UXP-44c169c9be3cec6957d5b04272a3564cf9137109.tar.gz
UXP-44c169c9be3cec6957d5b04272a3564cf9137109.tar.lz
UXP-44c169c9be3cec6957d5b04272a3564cf9137109.tar.xz
UXP-44c169c9be3cec6957d5b04272a3564cf9137109.zip
Issue #1053 - Remove android support from mfbt
-rw-r--r--mfbt/Assertions.h14
-rw-r--r--mfbt/IntegerPrintfMacros.h21
-rw-r--r--mfbt/TaggedAnonymousMemory.cpp105
-rw-r--r--mfbt/TaggedAnonymousMemory.h24
-rw-r--r--mfbt/objs.mozbuild1
-rw-r--r--mfbt/tests/TestTypeTraits.cpp14
-rw-r--r--mfbt/tests/TestTypedEnum.cpp3
7 files changed, 1 insertions, 181 deletions
diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h
index e7b010b7f..94dcfb8a5 100644
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -66,9 +66,6 @@ __declspec(dllimport) void* __stdcall GetCurrentProcess(void);
#else
# include <signal.h>
#endif
-#ifdef ANDROID
-# include <android/log.h>
-#endif
/*
* MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C.
@@ -158,33 +155,22 @@ static MOZ_COLD MOZ_ALWAYS_INLINE void
MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine)
MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
{
-#ifdef ANDROID
- __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
- "Assertion failure: %s, at %s:%d\n",
- aStr, aFilename, aLine);
-#else
fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine);
#if defined (MOZ_DUMP_ASSERTION_STACK)
nsTraceRefcnt::WalkTheStack(stderr);
#endif
fflush(stderr);
-#endif
}
static MOZ_COLD MOZ_ALWAYS_INLINE void
MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
{
-#ifdef ANDROID
- __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
- "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
-#else
fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
#if defined(MOZ_DUMP_ASSERTION_STACK)
nsTraceRefcnt::WalkTheStack(stderr);
#endif
fflush(stderr);
-#endif
}
/**
diff --git a/mfbt/IntegerPrintfMacros.h b/mfbt/IntegerPrintfMacros.h
index c534a0ba2..14872a242 100644
--- a/mfbt/IntegerPrintfMacros.h
+++ b/mfbt/IntegerPrintfMacros.h
@@ -28,25 +28,4 @@
#include <inttypes.h>
-/*
- * Fix up Android's broken [u]intptr_t inttype macros. Android's PRI*PTR
- * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
- * is 4 on 32-bit Android. TestTypeTraits.cpp asserts that these new macro
- * definitions match the actual type sizes seen at compile time.
- */
-#if defined(ANDROID) && !defined(__LP64__)
-# undef PRIdPTR /* intptr_t */
-# define PRIdPTR "d" /* intptr_t */
-# undef PRIiPTR /* intptr_t */
-# define PRIiPTR "i" /* intptr_t */
-# undef PRIoPTR /* uintptr_t */
-# define PRIoPTR "o" /* uintptr_t */
-# undef PRIuPTR /* uintptr_t */
-# define PRIuPTR "u" /* uintptr_t */
-# undef PRIxPTR /* uintptr_t */
-# define PRIxPTR "x" /* uintptr_t */
-# undef PRIXPTR /* uintptr_t */
-# define PRIXPTR "X" /* uintptr_t */
-#endif
-
#endif /* mozilla_IntegerPrintfMacros_h_ */
diff --git a/mfbt/TaggedAnonymousMemory.cpp b/mfbt/TaggedAnonymousMemory.cpp
deleted file mode 100644
index a2ba9ee4b..000000000
--- a/mfbt/TaggedAnonymousMemory.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifdef ANDROID
-
-#include "mozilla/TaggedAnonymousMemory.h"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-#include "mozilla/Assertions.h"
-
-// These constants are copied from <sys/prctl.h>, because the headers
-// used for building may not have them even though the running kernel
-// supports them.
-#ifndef PR_SET_VMA
-#define PR_SET_VMA 0x53564d41
-#endif
-#ifndef PR_SET_VMA_ANON_NAME
-#define PR_SET_VMA_ANON_NAME 0
-#endif
-
-namespace mozilla {
-
-// Returns 0 for success and -1 (with errno) for error.
-static int
-TagAnonymousMemoryAligned(const void* aPtr, size_t aLength, const char* aTag)
-{
- return prctl(PR_SET_VMA,
- PR_SET_VMA_ANON_NAME,
- reinterpret_cast<unsigned long>(aPtr),
- aLength,
- reinterpret_cast<unsigned long>(aTag));
-}
-
-// On some architectures, it's possible for the page size to be larger
-// than the PAGE_SIZE we were compiled with. This computes the
-// equivalent of PAGE_MASK.
-static uintptr_t
-GetPageMask()
-{
- static uintptr_t mask = 0;
-
- if (mask == 0) {
- uintptr_t pageSize = sysconf(_SC_PAGESIZE);
- mask = ~(pageSize - 1);
- MOZ_ASSERT((pageSize & (pageSize - 1)) == 0,
- "Page size must be a power of 2!");
- }
- return mask;
-}
-
-} // namespace mozilla
-
-int
-MozTaggedMemoryIsSupported(void)
-{
- static int supported = -1;
-
- if (supported == -1) {
- // Tagging an empty range always "succeeds" if the feature is supported,
- // regardless of the start pointer.
- supported = mozilla::TagAnonymousMemoryAligned(nullptr, 0, nullptr) == 0;
- }
- return supported;
-}
-
-void
-MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
-{
- if (MozTaggedMemoryIsSupported()) {
- // The kernel will round up the end of the range to the next page
- // boundary if it's not aligned (comments indicate this behavior
- // is based on that of madvise), but it will reject the request if
- // the start is not aligned. We therefore round down the start
- // address and adjust the length accordingly.
- uintptr_t addr = reinterpret_cast<uintptr_t>(aPtr);
- uintptr_t end = addr + aLength;
- uintptr_t addrRounded = addr & mozilla::GetPageMask();
- const void* ptrRounded = reinterpret_cast<const void*>(addrRounded);
-
- mozilla::TagAnonymousMemoryAligned(ptrRounded, end - addrRounded, aTag);
- }
-}
-
-void*
-MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags,
- int aFd, off_t aOffset, const char* aTag)
-{
- void* mapped = mmap(aAddr, aLength, aProt, aFlags, aFd, aOffset);
- if (MozTaggedMemoryIsSupported() &&
- (aFlags & MAP_ANONYMOUS) == MAP_ANONYMOUS &&
- mapped != MAP_FAILED) {
- mozilla::TagAnonymousMemoryAligned(mapped, aLength, aTag);
- }
- return mapped;
-}
-
-#endif // ANDROID
diff --git a/mfbt/TaggedAnonymousMemory.h b/mfbt/TaggedAnonymousMemory.h
index d26b06dfb..545928471 100644
--- a/mfbt/TaggedAnonymousMemory.h
+++ b/mfbt/TaggedAnonymousMemory.h
@@ -39,28 +39,6 @@
#include "mozilla/Types.h"
-#ifdef ANDROID
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-MFBT_API void
-MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag);
-
-MFBT_API void*
-MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags,
- int aFd, off_t aOffset, const char* aTag);
-
-MFBT_API int
-MozTaggedMemoryIsSupported(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#else // ANDROID
-
static inline void
MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
{
@@ -79,8 +57,6 @@ MozTaggedMemoryIsSupported(void)
return 0;
}
-#endif // ANDROID
-
#endif // !XP_WIN
#endif // mozilla_TaggedAnonymousMemory_h
diff --git a/mfbt/objs.mozbuild b/mfbt/objs.mozbuild
index 37b2240c4..06bdca677 100644
--- a/mfbt/objs.mozbuild
+++ b/mfbt/objs.mozbuild
@@ -20,7 +20,6 @@ mfbt_src_lcppsrcs = [
'JSONWriter.cpp',
'Poison.cpp',
'SHA1.cpp',
- 'TaggedAnonymousMemory.cpp',
'Unused.cpp',
]
diff --git a/mfbt/tests/TestTypeTraits.cpp b/mfbt/tests/TestTypeTraits.cpp
index eb412bc54..cd42f1e44 100644
--- a/mfbt/tests/TestTypeTraits.cpp
+++ b/mfbt/tests/TestTypeTraits.cpp
@@ -636,20 +636,6 @@ static_assert(IsSame<Decay<int[1]>::Type, int*>::value,
static_assert(IsSame<Decay<void(int)>::Type, void(*)(int)>::value,
"decaying void(int) must return void(*)(int)");
-/*
- * Android's broken [u]intptr_t inttype macros are broken because its PRI*PTR
- * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
- * is 4 on 32-bit Android. We redefine Android's PRI*PTR macros in
- * IntegerPrintfMacros.h and assert here that our new definitions match the
- * actual type sizes seen at compile time.
- */
-#if defined(ANDROID) && !defined(__LP64__)
-static_assert(mozilla::IsSame<int, intptr_t>::value,
- "emulated PRI[di]PTR definitions will be wrong");
-static_assert(mozilla::IsSame<unsigned int, uintptr_t>::value,
- "emulated PRI[ouxX]PTR definitions will be wrong");
-#endif
-
int
main()
{
diff --git a/mfbt/tests/TestTypedEnum.cpp b/mfbt/tests/TestTypedEnum.cpp
index 43c36f2b8..1c8db754b 100644
--- a/mfbt/tests/TestTypedEnum.cpp
+++ b/mfbt/tests/TestTypedEnum.cpp
@@ -12,8 +12,7 @@
// A rough feature check for is_literal_type. Not very carefully checked.
// Feel free to amend as needed.
-// We leave ANDROID out because it's using stlport which doesn't have std::is_literal_type.
-#if __cplusplus >= 201103L && !defined(ANDROID)
+#if __cplusplus >= 201103L
# if defined(__clang__)
/*
* Per Clang documentation, "Note that marketing version numbers should not