| 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..4ac11b9843937346ca48b2e5bf4cea9f0d0e32e7
|
| --- /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
|
|
|