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

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

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error (previous patch was a mistake). 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.h
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.h b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ce5685c7aa899c97e6b0bba283d4d4a5c521af2
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef CRAZY_LINKER_ASHMEM_H
+#define CRAZY_LINKER_ASHMEM_H
+
+#include <unistd.h>
+
+namespace crazy {
+
+// Helper class to hold a scoped ashmem region file descriptor.
+class AshmemRegion {
+ public:
+ AshmemRegion() : fd_(-1) {}
+
+ ~AshmemRegion() {
+ Reset(-1);
+ }
+
+ int Get() const { return fd_; }
+
+ int Release() {
+ int ret = fd_;
+ fd_ = -1;
+ return ret;
+ }
+
+ void Reset(int fd) {
+ if (fd_ != -1) {
+ ::close(fd_);
+ }
+ fd_ = fd;
+ }
+
+ // Try to allocate a new ashmem region of |region_size|
+ // (page-aligned) bytes. |region_name| is optional, if not NULL
+ // it will be the name of the region (only used for debugging).
+ // Returns true on success, false otherwise.
+ bool Allocate(size_t region_size, const char* region_name);
+
+ // Change the protection flags of the region. Returns true on success.
+ bool SetProtectionFlags(int prot_flags);
+
+ private:
+ AshmemRegion(const AshmemRegion& other);
+ AshmemRegion& operator=(const AshmemRegion& other);
+
+ int fd_;
+};
+
+} // namespace crazy
+
+#endif // CRAZY_LINKER_ASHMEM_H

Powered by Google App Engine
This is Rietveld 408576698