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

Side by Side Diff: runtime/bin/file_linux.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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 intptr_t File::GetFD() { 70 intptr_t File::GetFD() {
71 return handle_->fd(); 71 return handle_->fd();
72 } 72 }
73 73
74 74
75 bool File::IsClosed() { 75 bool File::IsClosed() {
76 return handle_->fd() == kClosedFd; 76 return handle_->fd() == kClosedFd;
77 } 77 }
78 78
79 79
80 void* File::MapExecutable(intptr_t* len) { 80 void* File::MapReadOnly(int64_t position, int64_t length) {
81 ASSERT(handle_->fd() >= 0); 81 ASSERT(handle_->fd() >= 0);
82 intptr_t length = Length();
83 void* addr = mmap(0, length, 82 void* addr = mmap(0, length,
84 PROT_READ | PROT_EXEC, MAP_PRIVATE, 83 PROT_READ, MAP_PRIVATE,
85 handle_->fd(), 0); 84 handle_->fd(), position);
86 if (addr == MAP_FAILED) { 85 if (addr == MAP_FAILED) {
87 *len = -1; 86 return NULL;
88 } else {
89 *len = length;
90 } 87 }
91 return addr; 88 return addr;
92 } 89 }
90
91
92 void* File::MapReadExecute(int64_t position, int64_t length) {
93 ASSERT(handle_->fd() >= 0);
94 void* addr = mmap(0, length,
95 PROT_READ | PROT_EXEC, MAP_PRIVATE,
96 handle_->fd(), position);
97 if (addr == MAP_FAILED) {
98 return NULL;
99 }
100 return addr;
101 }
93 102
94 103
95 int64_t File::Read(void* buffer, int64_t num_bytes) { 104 int64_t File::Read(void* buffer, int64_t num_bytes) {
96 ASSERT(handle_->fd() >= 0); 105 ASSERT(handle_->fd() >= 0);
97 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 106 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
98 } 107 }
99 108
100 109
101 int64_t File::Write(const void* buffer, int64_t num_bytes) { 110 int64_t File::Write(const void* buffer, int64_t num_bytes) {
102 ASSERT(handle_->fd() >= 0); 111 ASSERT(handle_->fd() >= 0);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return ((file_1_info.st_ino == file_2_info.st_ino) && 528 return ((file_1_info.st_ino == file_2_info.st_ino) &&
520 (file_1_info.st_dev == file_2_info.st_dev)) ? 529 (file_1_info.st_dev == file_2_info.st_dev)) ?
521 File::kIdentical : 530 File::kIdentical :
522 File::kDifferent; 531 File::kDifferent;
523 } 532 }
524 533
525 } // namespace bin 534 } // namespace bin
526 } // namespace dart 535 } // namespace dart
527 536
528 #endif // defined(TARGET_OS_LINUX) 537 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698