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

Side by Side Diff: runtime/bin/file_macos.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_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::Map(MapType type, int64_t position, int64_t length) { 83 void* File::MapExecutable(intptr_t* len) {
84 ASSERT(handle_->fd() >= 0); 84 ASSERT(handle_->fd() >= 0);
85 int prot = PROT_NONE; 85 intptr_t length = Length();
86 switch (type) { 86 void* addr = mmap(0, length,
87 case kReadOnly: 87 PROT_READ | PROT_EXEC, MAP_PRIVATE,
88 prot = PROT_READ; 88 handle_->fd(), 0);
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);
98 if (addr == MAP_FAILED) { 89 if (addr == MAP_FAILED) {
99 return NULL; 90 *len = -1;
91 } else {
92 *len = length;
100 } 93 }
101 return addr; 94 return addr;
102 } 95 }
103 96
104 97
105 int64_t File::Read(void* buffer, int64_t num_bytes) { 98 int64_t File::Read(void* buffer, int64_t num_bytes) {
106 ASSERT(handle_->fd() >= 0); 99 ASSERT(handle_->fd() >= 0);
107 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 100 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
108 } 101 }
109 102
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return ((file_1_info.st_ino == file_2_info.st_ino) && 483 return ((file_1_info.st_ino == file_2_info.st_ino) &&
491 (file_1_info.st_dev == file_2_info.st_dev)) ? 484 (file_1_info.st_dev == file_2_info.st_dev)) ?
492 File::kIdentical : 485 File::kIdentical :
493 File::kDifferent; 486 File::kDifferent;
494 } 487 }
495 488
496 } // namespace bin 489 } // namespace bin
497 } // namespace dart 490 } // namespace dart
498 491
499 #endif // defined(TARGET_OS_MACOS) 492 #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