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

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

Issue 2405393002: Use a single file for app snapshots. (Closed)
Patch Set: okay 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::Map(MapType type, int64_t position, int64_t length) {
81 ASSERT(handle_->fd() >= 0); 81 ASSERT(handle_->fd() >= 0);
82 intptr_t length = Length(); 82 int prot = PROT_NONE;
83 void* addr = mmap(0, length, 83 switch (type) {
84 PROT_READ | PROT_EXEC, MAP_PRIVATE, 84 case kReadOnly:
85 handle_->fd(), 0); 85 prot = PROT_READ;
86 break;
87 case kReadExecute:
88 prot = PROT_READ | PROT_EXEC;
89 break;
90 }
91 void* addr = mmap(NULL, length, prot, MAP_PRIVATE,
92 handle_->fd(), position);
86 if (addr == MAP_FAILED) { 93 if (addr == MAP_FAILED) {
87 *len = -1; 94 return NULL;
88 } else {
89 *len = length;
90 } 95 }
91 return addr; 96 return addr;
92 } 97 }
93 98
94 99
95 int64_t File::Read(void* buffer, int64_t num_bytes) { 100 int64_t File::Read(void* buffer, int64_t num_bytes) {
96 ASSERT(handle_->fd() >= 0); 101 ASSERT(handle_->fd() >= 0);
97 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 102 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
98 } 103 }
99 104
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return ((file_1_info.st_ino == file_2_info.st_ino) && 524 return ((file_1_info.st_ino == file_2_info.st_ino) &&
520 (file_1_info.st_dev == file_2_info.st_dev)) ? 525 (file_1_info.st_dev == file_2_info.st_dev)) ?
521 File::kIdentical : 526 File::kIdentical :
522 File::kDifferent; 527 File::kDifferent;
523 } 528 }
524 529
525 } // namespace bin 530 } // namespace bin
526 } // namespace dart 531 } // namespace dart
527 532
528 #endif // defined(TARGET_OS_LINUX) 533 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698