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

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

Issue 2168193002: Fuchsia: Build standalone VM. Make it run "Hello, World!". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 5 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
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/process_fuchsia.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) 2016, 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_FUCHSIA)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #include <signal.h> // NOLINT 10 #include <runtime/sysinfo.h>
11 #include <string.h> // NOLINT 11 #include <string.h> // NOLINT
12 #include <unistd.h> // NOLINT 12 #include <unistd.h> // NOLINT
13 13
14 #include "bin/fdutils.h" 14 #include "bin/fdutils.h"
15 #include "bin/file.h" 15 #include "bin/file.h"
16 16
17 namespace dart { 17 namespace dart {
18 namespace bin { 18 namespace bin {
19 19
20 const char* Platform::executable_name_ = NULL; 20 const char* Platform::executable_name_ = NULL;
21 char* Platform::resolved_executable_name_ = NULL; 21 char* Platform::resolved_executable_name_ = NULL;
22 int Platform::script_index_ = 1; 22 int Platform::script_index_ = 1;
23 char** Platform::argv_ = NULL; 23 char** Platform::argv_ = NULL;
24 24
25 bool Platform::Initialize() { 25 bool Platform::Initialize() {
26 // Turn off the signal handler for SIGPIPE as it causes the process
27 // to terminate on writing to a closed pipe. Without the signal
28 // handler error EPIPE is set instead.
29 struct sigaction act;
30 bzero(&act, sizeof(act));
31 act.sa_handler = SIG_IGN;
32 if (sigaction(SIGPIPE, &act, 0) != 0) {
33 perror("Setting signal handler failed");
34 return false;
35 }
36 return true; 26 return true;
37 } 27 }
38 28
39 29
40 int Platform::NumberOfProcessors() { 30 int Platform::NumberOfProcessors() {
41 return sysconf(_SC_NPROCESSORS_ONLN); 31 return mxr_get_nprocs();
42 } 32 }
43 33
44 34
45 const char* Platform::OperatingSystem() { 35 const char* Platform::OperatingSystem() {
46 return "android"; 36 return "fuchsia";
47 } 37 }
48 38
49 39
50 const char* Platform::LibraryPrefix() { 40 const char* Platform::LibraryPrefix() {
51 return "lib"; 41 return "lib";
52 } 42 }
53 43
54 44
55 const char* Platform::LibraryExtension() { 45 const char* Platform::LibraryExtension() {
56 return "so"; 46 return "so";
57 } 47 }
58 48
59 49
60 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { 50 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) {
61 return gethostname(buffer, buffer_length) == 0; 51 return gethostname(buffer, buffer_length) == 0;
62 } 52 }
63 53
64 54
65 char** Platform::Environment(intptr_t* count) { 55 char** Platform::Environment(intptr_t* count) {
66 // Using environ directly is only safe as long as we do not 56 char** result =
67 // provide access to modifying environment variables. 57 reinterpret_cast<char**>(Dart_ScopeAllocate(1 * sizeof(*result)));
68 intptr_t i = 0; 58 result[0] = NULL;
69 char** tmp = environ;
70 while (*(tmp++) != NULL) {
71 i++;
72 }
73 *count = i;
74 char** result;
75 result = reinterpret_cast<char**>(Dart_ScopeAllocate(i * sizeof(*result)));
76 for (intptr_t current = 0; current < i; current++) {
77 result[current] = environ[current];
78 }
79 return result; 59 return result;
80 } 60 }
81 61
82 62
83 const char* Platform::ResolveExecutablePath() { 63 const char* Platform::ResolveExecutablePath() {
84 return NULL; 64 return "dart";
85 } 65 }
86 66
87 67
88 void Platform::Exit(int exit_code) { 68 void Platform::Exit(int exit_code) {
89 exit(exit_code); 69 exit(exit_code);
90 } 70 }
91 71
92 } // namespace bin 72 } // namespace bin
93 } // namespace dart 73 } // namespace dart
94 74
95 #endif // defined(TARGET_OS_ANDROID) 75 #endif // defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/process_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698