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

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

Issue 2405393002: Use a single file for app snapshots. (Closed)
Patch Set: gen_snapshot 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_linux.cc ('k') | runtime/bin/file_win.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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <copyfile.h> // NOLINT 10 #include <copyfile.h> // NOLINT
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 intptr_t File::GetFD() { 73 intptr_t File::GetFD() {
74 return handle_->fd(); 74 return handle_->fd();
75 } 75 }
76 76
77 77
78 bool File::IsClosed() { 78 bool File::IsClosed() {
79 return handle_->fd() == kClosedFd; 79 return handle_->fd() == kClosedFd;
80 } 80 }
81 81
82 82
83 void* File::MapExecutable(intptr_t* len) { 83 void* File::Map(MapType type, int64_t position, int64_t length) {
84 ASSERT(handle_->fd() >= 0); 84 ASSERT(handle_->fd() >= 0);
85 intptr_t length = Length(); 85 int prot = PROT_NONE;
86 void* addr = mmap(0, length, 86 switch (type) {
87 PROT_READ | PROT_EXEC, MAP_PRIVATE, 87 case kReadOnly:
88 handle_->fd(), 0); 88 prot = PROT_READ;
89 break;
90 case kReadExecute:
91 prot = PROT_READ | PROT_EXEC;
92 break;
93 default:
94 return NULL;
95 }
96 void* addr = mmap(NULL, length, prot, MAP_PRIVATE,
97 handle_->fd(), position);
89 if (addr == MAP_FAILED) { 98 if (addr == MAP_FAILED) {
90 *len = -1; 99 return NULL;
91 } else {
92 *len = length;
93 } 100 }
94 return addr; 101 return addr;
95 } 102 }
96 103
97 104
98 int64_t File::Read(void* buffer, int64_t num_bytes) { 105 int64_t File::Read(void* buffer, int64_t num_bytes) {
99 ASSERT(handle_->fd() >= 0); 106 ASSERT(handle_->fd() >= 0);
100 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 107 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
101 } 108 }
102 109
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return ((file_1_info.st_ino == file_2_info.st_ino) && 490 return ((file_1_info.st_ino == file_2_info.st_ino) &&
484 (file_1_info.st_dev == file_2_info.st_dev)) ? 491 (file_1_info.st_dev == file_2_info.st_dev)) ?
485 File::kIdentical : 492 File::kIdentical :
486 File::kDifferent; 493 File::kDifferent;
487 } 494 }
488 495
489 } // namespace bin 496 } // namespace bin
490 } // namespace dart 497 } // namespace dart
491 498
492 #endif // defined(TARGET_OS_MACOS) 499 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698