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 "vm/os.h" | 5 #include "vm/os.h" |
6 | 6 |
| 7 #include <android/log.h> |
7 #include <errno.h> | 8 #include <errno.h> |
8 #include <limits.h> | 9 #include <limits.h> |
9 #include <malloc.h> | 10 #include <malloc.h> |
10 #include <time.h> | 11 #include <time.h> |
11 #include <sys/resource.h> | 12 #include <sys/resource.h> |
12 #include <sys/time.h> | 13 #include <sys/time.h> |
13 #include <sys/types.h> | 14 #include <sys/types.h> |
14 #include <unistd.h> | 15 #include <unistd.h> |
15 | 16 |
16 #include "platform/utils.h" | 17 #include "platform/utils.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void OS::Sleep(int64_t millis) { | 146 void OS::Sleep(int64_t millis) { |
146 // TODO(5411554): For now just use usleep we may have to revisit this. | 147 // TODO(5411554): For now just use usleep we may have to revisit this. |
147 usleep(millis * 1000); | 148 usleep(millis * 1000); |
148 } | 149 } |
149 | 150 |
150 | 151 |
151 void OS::Print(const char* format, ...) { | 152 void OS::Print(const char* format, ...) { |
152 va_list args; | 153 va_list args; |
153 va_start(args, format); | 154 va_start(args, format); |
154 VFPrint(stdout, format, args); | 155 VFPrint(stdout, format, args); |
| 156 // Forward to the Android log for remote access. |
| 157 __android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args); |
155 va_end(args); | 158 va_end(args); |
156 } | 159 } |
157 | 160 |
158 | 161 |
159 void OS::VFPrint(FILE* stream, const char* format, va_list args) { | 162 void OS::VFPrint(FILE* stream, const char* format, va_list args) { |
160 vfprintf(stream, format, args); | 163 vfprintf(stream, format, args); |
161 fflush(stream); | 164 fflush(stream); |
162 } | 165 } |
163 | 166 |
164 | 167 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 errno = 0; | 199 errno = 0; |
197 *value = strtoll(str, &endptr, base); | 200 *value = strtoll(str, &endptr, base); |
198 return ((errno == 0) && (endptr != str) && (*endptr == 0)); | 201 return ((errno == 0) && (endptr != str) && (*endptr == 0)); |
199 } | 202 } |
200 | 203 |
201 | 204 |
202 void OS::PrintErr(const char* format, ...) { | 205 void OS::PrintErr(const char* format, ...) { |
203 va_list args; | 206 va_list args; |
204 va_start(args, format); | 207 va_start(args, format); |
205 VFPrint(stderr, format, args); | 208 VFPrint(stderr, format, args); |
| 209 // Forward to the Android log for remote access. |
| 210 __android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args); |
206 va_end(args); | 211 va_end(args); |
207 } | 212 } |
208 | 213 |
209 | 214 |
210 void OS::InitOnce() { | 215 void OS::InitOnce() { |
211 // TODO(5411554): For now we check that initonce is called only once, | 216 // TODO(5411554): For now we check that initonce is called only once, |
212 // Once there is more formal mechanism to call InitOnce we can move | 217 // Once there is more formal mechanism to call InitOnce we can move |
213 // this check there. | 218 // this check there. |
214 static bool init_once_called = false; | 219 static bool init_once_called = false; |
215 ASSERT(init_once_called == false); | 220 ASSERT(init_once_called == false); |
216 init_once_called = true; | 221 init_once_called = true; |
217 } | 222 } |
218 | 223 |
219 | 224 |
220 void OS::Shutdown() { | 225 void OS::Shutdown() { |
221 } | 226 } |
222 | 227 |
223 | 228 |
224 void OS::Abort() { | 229 void OS::Abort() { |
225 abort(); | 230 abort(); |
226 } | 231 } |
227 | 232 |
228 | 233 |
229 void OS::Exit(int code) { | 234 void OS::Exit(int code) { |
230 exit(code); | 235 exit(code); |
231 } | 236 } |
232 | 237 |
233 } // namespace dart | 238 } // namespace dart |
OLD | NEW |