mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-28 03:17:31 +09:00
Issue #1053 - Remove android support from mfbt
This commit is contained in:
parent
dd6048d3ec
commit
bf056898b5
7 changed files with 1 additions and 181 deletions
|
|
@ -66,9 +66,6 @@ __declspec(dllimport) void* __stdcall GetCurrentProcess(void);
|
||||||
#else
|
#else
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef ANDROID
|
|
||||||
# include <android/log.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C.
|
* 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_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine)
|
||||||
MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
|
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);
|
fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine);
|
||||||
#if defined (MOZ_DUMP_ASSERTION_STACK)
|
#if defined (MOZ_DUMP_ASSERTION_STACK)
|
||||||
nsTraceRefcnt::WalkTheStack(stderr);
|
nsTraceRefcnt::WalkTheStack(stderr);
|
||||||
#endif
|
#endif
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MOZ_COLD MOZ_ALWAYS_INLINE void
|
static MOZ_COLD MOZ_ALWAYS_INLINE void
|
||||||
MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
|
MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
|
||||||
MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
|
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);
|
fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
|
||||||
#if defined(MOZ_DUMP_ASSERTION_STACK)
|
#if defined(MOZ_DUMP_ASSERTION_STACK)
|
||||||
nsTraceRefcnt::WalkTheStack(stderr);
|
nsTraceRefcnt::WalkTheStack(stderr);
|
||||||
#endif
|
#endif
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,25 +28,4 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#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_ */
|
#endif /* mozilla_IntegerPrintfMacros_h_ */
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -39,28 +39,6 @@
|
||||||
|
|
||||||
#include "mozilla/Types.h"
|
#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
|
static inline void
|
||||||
MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
|
MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag)
|
||||||
{
|
{
|
||||||
|
|
@ -79,8 +57,6 @@ MozTaggedMemoryIsSupported(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ANDROID
|
|
||||||
|
|
||||||
#endif // !XP_WIN
|
#endif // !XP_WIN
|
||||||
|
|
||||||
#endif // mozilla_TaggedAnonymousMemory_h
|
#endif // mozilla_TaggedAnonymousMemory_h
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ mfbt_src_lcppsrcs = [
|
||||||
'JSONWriter.cpp',
|
'JSONWriter.cpp',
|
||||||
'Poison.cpp',
|
'Poison.cpp',
|
||||||
'SHA1.cpp',
|
'SHA1.cpp',
|
||||||
'TaggedAnonymousMemory.cpp',
|
|
||||||
'Unused.cpp',
|
'Unused.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -636,20 +636,6 @@ static_assert(IsSame<Decay<int[1]>::Type, int*>::value,
|
||||||
static_assert(IsSame<Decay<void(int)>::Type, void(*)(int)>::value,
|
static_assert(IsSame<Decay<void(int)>::Type, void(*)(int)>::value,
|
||||||
"decaying void(int) must return void(*)(int)");
|
"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
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
// A rough feature check for is_literal_type. Not very carefully checked.
|
// A rough feature check for is_literal_type. Not very carefully checked.
|
||||||
// Feel free to amend as needed.
|
// 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
|
||||||
#if __cplusplus >= 201103L && !defined(ANDROID)
|
|
||||||
# if defined(__clang__)
|
# if defined(__clang__)
|
||||||
/*
|
/*
|
||||||
* Per Clang documentation, "Note that marketing version numbers should not
|
* Per Clang documentation, "Note that marketing version numbers should not
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue