Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1598068) for build bustage at ShowSSECon…
Browse files Browse the repository at this point in the history
…fig on a CLOSED TREE

Backed out changeset 5fb8d24977eb (bug 1598068)
Backed out changeset eba60d849030 (bug 1598068)
  • Loading branch information
ccoroiu committed Feb 13, 2020
1 parent 51b509b commit fc53596
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 114 deletions.
2 changes: 1 addition & 1 deletion build/moz.configure/android-sdk.configure
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def android_sdk_root(value):

@depends('--help')
def android_sdk_version(_):
return namespace(build_tools_versions=['28.0.3'], target_sdk_version='29')
return namespace(build_tools_versions=['28.0.3'], target_sdk_version='28')


@depends(android_sdk_root, android_sdk_version)
Expand Down
10 changes: 7 additions & 3 deletions ipc/chromium/src/base/shared_memory_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <unistd.h>

#ifdef ANDROID
# include "mozilla/Ashmem.h"
# include <linux/ashmem.h>
#endif

#include "base/eintr_wrapper.h"
Expand Down Expand Up @@ -202,11 +202,15 @@ bool SharedMemory::CreateInternal(size_t size, bool freezeable) {

#ifdef ANDROID
// Android has its own shared memory facility:
fd.reset(mozilla::android::ashmem_create(nullptr, size));
fd.reset(open("/" ASHMEM_NAME_DEF, O_RDWR, 0600));
if (!fd) {
CHROMIUM_LOG(WARNING) << "failed to open shm: " << strerror(errno);
return false;
}
if (ioctl(fd.get(), ASHMEM_SET_SIZE, size) != 0) {
CHROMIUM_LOG(WARNING) << "failed to set shm size: " << strerror(errno);
return false;
}
needs_truncate = false;
#else
// Generic Unix: shm_open + shm_unlink
Expand Down Expand Up @@ -267,7 +271,7 @@ bool SharedMemory::Freeze() {
Unmap();

#ifdef ANDROID
if (mozilla::android::ashmem_setProt(mapped_file_, PROT_READ) != 0) {
if (ioctl(mapped_file_, ASHMEM_SET_PROT_MASK, PROT_READ) != 0) {
CHROMIUM_LOG(WARNING) << "failed to freeze shm: " << strerror(errno);
return false;
}
Expand Down
14 changes: 12 additions & 2 deletions ipc/glue/SharedMemoryBasic_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

#include "SharedMemoryBasic.h"

#include "mozilla/Ashmem.h"
//
// Temporarily go directly to the kernel interface until we can
// interact better with libcutils.
//
#include <linux/ashmem.h>

namespace mozilla {
namespace ipc {
Expand Down Expand Up @@ -47,12 +51,18 @@ bool SharedMemoryBasic::Create(size_t aNbytes) {
MOZ_ASSERT(-1 == mShmFd, "Already Create()d");

// Carve a new instance off of /dev/ashmem
int shmfd = mozilla::android::ashmem_create(nullptr, aNbytes);
int shmfd = open("/" ASHMEM_NAME_DEF, O_RDWR, 0600);
if (-1 == shmfd) {
LogError("ShmemAndroid::Create():open");
return false;
}

if (ioctl(shmfd, ASHMEM_SET_SIZE, aNbytes)) {
LogError("ShmemAndroid::Unmap():ioctl(SET_SIZE)");
close(shmfd);
return false;
}

mShmFd = shmfd;
Created(aNbytes);
return true;
Expand Down
9 changes: 6 additions & 3 deletions memory/volatile/VolatileBufferAshmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
#include "mozilla/mozalloc.h"

#include <fcntl.h>
#include <linux/ashmem.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "mozilla/Ashmem.h"

#ifdef MOZ_MEMORY
extern "C" int posix_memalign(void** memptr, size_t alignment, size_t size);
#endif
Expand All @@ -39,11 +38,15 @@ bool VolatileBuffer::Init(size_t aSize, size_t aAlignment) {
goto heap_alloc;
}

mFd = mozilla::android::ashmem_create(nullptr, mSize);
mFd = open("/" ASHMEM_NAME_DEF, O_RDWR);
if (mFd < 0) {
goto heap_alloc;
}

if (ioctl(mFd, ASHMEM_SET_SIZE, mSize) < 0) {
goto heap_alloc;
}

mBuf = mmap(nullptr, mSize, PROT_READ | PROT_WRITE, MAP_SHARED, mFd, 0);
if (mBuf != MAP_FAILED) {
return true;
Expand Down
67 changes: 0 additions & 67 deletions mozglue/android/Ashmem.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions mozglue/android/Ashmem.h

This file was deleted.

5 changes: 0 additions & 5 deletions mozglue/android/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ EXPORTS += [
'APKOpen.h',
]

EXPORTS.mozilla += ['Ashmem.h']

OS_LIBS += ['android']

SOURCES += [
'APKOpen.cpp',
'Ashmem.cpp',
'NativeCrypto.cpp',
'nsGeckoUtils.cpp',
'NSSBridge.cpp',
Expand Down
27 changes: 16 additions & 11 deletions mozglue/linker/Mappable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "mozilla/UniquePtr.h"

#ifdef ANDROID
# include "mozilla/Ashmem.h"
# include <linux/ashmem.h>
#endif
#include <sys/stat.h>
#include <errno.h>
Expand Down Expand Up @@ -243,14 +243,19 @@ class _MappableBuffer : public MappedPtr {
AutoCloseFD fd;
#ifdef ANDROID
/* On Android, initialize an ashmem region with the given length */
fd = mozilla::android::ashmem_create(name, length);

/* The Gecko crash reporter is confused by adjacent memory mappings of
* the same file and chances are we're going to map from the same file
* descriptor right away. To avoid problems with the crash reporter,
* create an empty anonymous page before or after the ashmem mapping,
* depending on how mappings grow in the address space.
*/
fd = open("/" ASHMEM_NAME_DEF, O_RDWR, 0600);
if (fd == -1) return nullptr;
char str[ASHMEM_NAME_LEN];
strlcpy(str, name, sizeof(str));
ioctl(fd, ASHMEM_SET_NAME, str);
if (ioctl(fd, ASHMEM_SET_SIZE, length)) return nullptr;

/* The Gecko crash reporter is confused by adjacent memory mappings of
* the same file and chances are we're going to map from the same file
* descriptor right away. To avoid problems with the crash reporter,
* create an empty anonymous page before or after the ashmem mapping,
* depending on how mappings grow in the address space.
*/
# if defined(__arm__)
// Address increases on ARM.
void* buf = ::mmap(nullptr, length + PAGE_SIZE, PROT_READ | PROT_WRITE,
Expand All @@ -261,7 +266,7 @@ class _MappableBuffer : public MappedPtr {
0);
DEBUG_LOG("Decompression buffer of size 0x%" PRIxPTR
" in ashmem \"%s\", mapped @%p",
length, name, buf);
length, str, buf);
return new _MappableBuffer(fd.forget(), buf, length);
}
# elif defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
Expand All @@ -284,7 +289,7 @@ class _MappableBuffer : public MappedPtr {

DEBUG_LOG("Decompression buffer of size 0x%" PRIxPTR
" in ashmem \"%s\", mapped @%p",
length, name, actual_buf);
length, str, actual_buf);
return new _MappableBuffer(fd.forget(), actual_buf, length);
}
# else
Expand Down

0 comments on commit fc53596

Please sign in to comment.