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

Side by Side Diff: runtime/bin/file_android.cc

Issue 2410303008: Revert "Use a single file for app snapshots." (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_fuchsia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 intptr_t File::GetFD() { 71 intptr_t File::GetFD() {
72 return handle_->fd(); 72 return handle_->fd();
73 } 73 }
74 74
75 75
76 bool File::IsClosed() { 76 bool File::IsClosed() {
77 return handle_->fd() == kClosedFd; 77 return handle_->fd() == kClosedFd;
78 } 78 }
79 79
80 80
81 void* File::Map(MapType type, int64_t position, int64_t length) { 81 void* File::MapExecutable(intptr_t* len) {
82 ASSERT(handle_->fd() >= 0); 82 ASSERT(handle_->fd() >= 0);
83 int prot = PROT_NONE; 83
84 switch (type) { 84 intptr_t length = Length();
85 case kReadOnly: 85 void* addr = mmap(0, length,
86 prot = PROT_READ; 86 PROT_READ | PROT_EXEC, MAP_PRIVATE,
87 break; 87 handle_->fd(), 0);
88 case kReadExecute:
89 prot = PROT_READ | PROT_EXEC;
90 break;
91 default:
92 return NULL;
93 }
94 void* addr = mmap(NULL, length, prot, MAP_PRIVATE,
95 handle_->fd(), position);
96 if (addr == MAP_FAILED) { 88 if (addr == MAP_FAILED) {
97 return NULL; 89 *len = -1;
90 } else {
91 *len = length;
98 } 92 }
99 return addr; 93 return addr;
100 } 94 }
101 95
102 96
103 int64_t File::Read(void* buffer, int64_t num_bytes) { 97 int64_t File::Read(void* buffer, int64_t num_bytes) {
104 ASSERT(handle_->fd() >= 0); 98 ASSERT(handle_->fd() >= 0);
105 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 99 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
106 } 100 }
107 101
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 return ((file_1_info.st_ino == file_2_info.st_ino) && 508 return ((file_1_info.st_ino == file_2_info.st_ino) &&
515 (file_1_info.st_dev == file_2_info.st_dev)) ? 509 (file_1_info.st_dev == file_2_info.st_dev)) ?
516 File::kIdentical : 510 File::kIdentical :
517 File::kDifferent; 511 File::kDifferent;
518 } 512 }
519 513
520 } // namespace bin 514 } // namespace bin
521 } // namespace dart 515 } // namespace dart
522 516
523 #endif // defined(TARGET_OS_ANDROID) 517 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698