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

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

Issue 2405393002: 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
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::MapReadOnly(int64_t position, int64_t length) {
84 ASSERT(handle_->fd() >= 0); 84 ASSERT(handle_->fd() >= 0);
85 intptr_t length = Length();
86 void* addr = mmap(0, length, 85 void* addr = mmap(0, length,
87 PROT_READ | PROT_EXEC, MAP_PRIVATE, 86 PROT_READ, MAP_PRIVATE,
88 handle_->fd(), 0); 87 handle_->fd(), position);
89 if (addr == MAP_FAILED) { 88 if (addr == MAP_FAILED) {
90 *len = -1; 89 return NULL;
91 } else {
92 *len = length;
93 } 90 }
94 return addr; 91 return addr;
95 } 92 }
93
94
95 void* File::MapReadExecute(int64_t position, int64_t length) {
96 ASSERT(handle_->fd() >= 0);
97 void* addr = mmap(0, length,
98 PROT_READ | PROT_EXEC, MAP_PRIVATE,
99 handle_->fd(), position);
100 if (addr == MAP_FAILED) {
101 return NULL;
102 }
103 return addr;
104 }
96 105
97 106
98 int64_t File::Read(void* buffer, int64_t num_bytes) { 107 int64_t File::Read(void* buffer, int64_t num_bytes) {
99 ASSERT(handle_->fd() >= 0); 108 ASSERT(handle_->fd() >= 0);
100 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 109 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
101 } 110 }
102 111
103 112
104 int64_t File::Write(const void* buffer, int64_t num_bytes) { 113 int64_t File::Write(const void* buffer, int64_t num_bytes) {
105 ASSERT(handle_->fd() >= 0); 114 ASSERT(handle_->fd() >= 0);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return ((file_1_info.st_ino == file_2_info.st_ino) && 492 return ((file_1_info.st_ino == file_2_info.st_ino) &&
484 (file_1_info.st_dev == file_2_info.st_dev)) ? 493 (file_1_info.st_dev == file_2_info.st_dev)) ?
485 File::kIdentical : 494 File::kIdentical :
486 File::kDifferent; 495 File::kDifferent;
487 } 496 }
488 497
489 } // namespace bin 498 } // namespace bin
490 } // namespace dart 499 } // namespace dart
491 500
492 #endif // defined(TARGET_OS_MACOS) 501 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698