OLD | NEW |
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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 intptr_t File::GetFD() { | 71 intptr_t File::GetFD() { |
72 return handle_->fd(); | 72 return handle_->fd(); |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 bool File::IsClosed() { | 76 bool File::IsClosed() { |
77 return handle_->fd() == kClosedFd; | 77 return handle_->fd() == kClosedFd; |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 void* File::MapExecutable(intptr_t* len) { | 81 void* File::MapReadOnly(int64_t position, int64_t length) { |
82 ASSERT(handle_->fd() >= 0); | 82 ASSERT(handle_->fd() >= 0); |
83 | |
84 intptr_t length = Length(); | |
85 void* addr = mmap(0, length, | 83 void* addr = mmap(0, length, |
86 PROT_READ | PROT_EXEC, MAP_PRIVATE, | 84 PROT_READ, MAP_PRIVATE, |
87 handle_->fd(), 0); | 85 handle_->fd(), position); |
88 if (addr == MAP_FAILED) { | 86 if (addr == MAP_FAILED) { |
89 *len = -1; | 87 return NULL; |
90 } else { | |
91 *len = length; | |
92 } | 88 } |
93 return addr; | 89 return addr; |
94 } | 90 } |
| 91 |
| 92 |
| 93 void* File::MapReadExecute(int64_t position, int64_t length) { |
| 94 ASSERT(handle_->fd() >= 0); |
| 95 void* addr = mmap(0, length, |
| 96 PROT_READ | PROT_EXEC, MAP_PRIVATE, |
| 97 handle_->fd(), position); |
| 98 if (addr == MAP_FAILED) { |
| 99 return NULL; |
| 100 } |
| 101 return addr; |
| 102 } |
95 | 103 |
96 | 104 |
97 int64_t File::Read(void* buffer, int64_t num_bytes) { | 105 int64_t File::Read(void* buffer, int64_t num_bytes) { |
98 ASSERT(handle_->fd() >= 0); | 106 ASSERT(handle_->fd() >= 0); |
99 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); | 107 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); |
100 } | 108 } |
101 | 109 |
102 | 110 |
103 int64_t File::Write(const void* buffer, int64_t num_bytes) { | 111 int64_t File::Write(const void* buffer, int64_t num_bytes) { |
104 ASSERT(handle_->fd() >= 0); | 112 ASSERT(handle_->fd() >= 0); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return ((file_1_info.st_ino == file_2_info.st_ino) && | 516 return ((file_1_info.st_ino == file_2_info.st_ino) && |
509 (file_1_info.st_dev == file_2_info.st_dev)) ? | 517 (file_1_info.st_dev == file_2_info.st_dev)) ? |
510 File::kIdentical : | 518 File::kIdentical : |
511 File::kDifferent; | 519 File::kDifferent; |
512 } | 520 } |
513 | 521 |
514 } // namespace bin | 522 } // namespace bin |
515 } // namespace dart | 523 } // namespace dart |
516 | 524 |
517 #endif // defined(TARGET_OS_ANDROID) | 525 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |