Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.cpp

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove findbugs issues. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.cpp
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.cpp b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5b2d2e63612416df424a70dfec78fda2e42b97cf
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.cpp
@@ -0,0 +1,46 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "crazy_linker_ashmem.h"
+
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <linux/ashmem.h>
+
+#include "crazy_linker_system.h"
+
+namespace crazy {
+
+bool AshmemRegion::Allocate(size_t region_size, const char* region_name) {
+ int fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR));
+ if (fd < 0)
+ return false;
+
+ if (ioctl(fd, ASHMEM_SET_SIZE, region_size) < 0)
+ goto ERROR;
+
+ if (region_name) {
+ char buf[256];
+ strlcpy(buf, region_name, sizeof(buf));
+ if (ioctl(fd, ASHMEM_SET_NAME, buf) < 0)
+ goto ERROR;
+ }
+
+ Reset(fd);
+ return true;
+
+ERROR:
+ ::close(fd);
+ return false;
+}
+
+bool AshmemRegion::SetProtectionFlags(int prot) {
+ return ioctl(fd_, ASHMEM_SET_PROT_MASK, prot) == 0;
+}
+} // namespace crazy

Powered by Google App Engine
This is Rietveld 408576698