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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crazy_linker_ashmem.h"
6
7 #include <fcntl.h>
8 #include <string.h>
9 #include <sys/ioctl.h>
10 #include <sys/stat.h>
11 #include <sys/types.h>
12 #include <unistd.h>
13
14 #include <linux/ashmem.h>
15
16 #include "crazy_linker_system.h"
17
18 namespace crazy {
19
20 bool AshmemRegion::Allocate(size_t region_size, const char* region_name) {
21 int fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR));
22 if (fd < 0)
23 return false;
24
25 if (ioctl(fd, ASHMEM_SET_SIZE, region_size) < 0)
26 goto ERROR;
27
28 if (region_name) {
29 char buf[256];
30 strlcpy(buf, region_name, sizeof(buf));
31 if (ioctl(fd, ASHMEM_SET_NAME, buf) < 0)
32 goto ERROR;
33 }
34
35 Reset(fd);
36 return true;
37
38 ERROR:
39 ::close(fd);
40 return false;
41 }
42
43 bool AshmemRegion::SetProtectionFlags(int prot) {
44 return ioctl(fd_, ASHMEM_SET_PROT_MASK, prot) == 0;
45 }
46 } // namespace crazy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698