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

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

Issue 10826233: Add _android files for building DartVM on Android (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporate reviewer's feedback (asiva, Soren Gjesse) Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/process_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "bin/platform.h" 5 #include "bin/platform.h"
6 6
7 #include <crt_externs.h>
8 #include <signal.h> 7 #include <signal.h>
9 #include <string.h> 8 #include <string.h>
10 #include <unistd.h> 9 #include <unistd.h>
11 10
12 11
13 bool Platform::Initialize() { 12 bool Platform::Initialize() {
14 // Turn off the signal handler for SIGPIPE as it causes the process 13 // Turn off the signal handler for SIGPIPE as it causes the process
15 // to terminate on writing to a closed pipe. Without the signal 14 // to terminate on writing to a closed pipe. Without the signal
16 // handler error EPIPE is set instead. 15 // handler error EPIPE is set instead.
17 struct sigaction act; 16 struct sigaction act;
18 bzero(&act, sizeof(act)); 17 bzero(&act, sizeof(act));
19 act.sa_handler = SIG_IGN; 18 act.sa_handler = SIG_IGN;
20 if (sigaction(SIGPIPE, &act, 0) != 0) { 19 if (sigaction(SIGPIPE, &act, 0) != 0) {
21 perror("Setting signal handler failed"); 20 perror("Setting signal handler failed");
22 return false; 21 return false;
23 } 22 }
24 return true; 23 return true;
25 } 24 }
26 25
27 26
28 int Platform::NumberOfProcessors() { 27 int Platform::NumberOfProcessors() {
29 return sysconf(_SC_NPROCESSORS_ONLN); 28 return sysconf(_SC_NPROCESSORS_ONLN);
30 } 29 }
31 30
32 31
33 const char* Platform::OperatingSystem() { 32 const char* Platform::OperatingSystem() {
34 return "macos"; 33 return "android";
35 } 34 }
36 35
37 36
38 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { 37 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) {
39 return gethostname(buffer, buffer_length) == 0; 38 return gethostname(buffer, buffer_length) == 0;
40 } 39 }
41 40
42 41
43 char** Platform::Environment(intptr_t* count) { 42 char** Platform::Environment(intptr_t* count) {
44 // Using environ directly is only safe as long as we do not 43 // Using environ directly is only safe as long as we do not
45 // provide access to modifying environment variables. 44 // provide access to modifying environment variables.
46 // On MacOS you have to do a bit of magic to get to the
47 // environment strings.
48 char** environ = *(_NSGetEnviron());
49 intptr_t i = 0; 45 intptr_t i = 0;
50 char** tmp = environ; 46 char** tmp = environ;
51 while (*(tmp++) != NULL) i++; 47 while (*(tmp++) != NULL) i++;
52 *count = i; 48 *count = i;
53 char** result = new char*[i]; 49 char** result = new char*[i];
54 for (intptr_t current = 0; current < i; current++) { 50 for (intptr_t current = 0; current < i; current++) {
55 result[current] = environ[current]; 51 result[current] = environ[current];
56 } 52 }
57 return result; 53 return result;
58 } 54 }
59 55
60 56
61 char* Platform::StrError(int error_code) { 57 char* Platform::StrError(int error_code) {
62 static const int kBufferSize = 1024; 58 static const int kBufferSize = 1024;
63 char* error = static_cast<char*>(malloc(kBufferSize)); 59 char* error = static_cast<char*>(malloc(kBufferSize));
64 error[0] = '\0'; 60 error[0] = '\0';
65 strerror_r(error_code, error, kBufferSize); 61 strerror_r(error_code, error, kBufferSize);
66 return error; 62 return error;
67 } 63 }
OLDNEW
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/process_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698