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

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

Issue 1559053002: Refs #10260 OpenBSD support #25327 Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Replace // FIXME with // TODO(mulander) Created 4 years, 11 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_OPENBSD)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 #include "bin/platform.h" 9 #include "bin/platform.h"
10 10
11 #include <signal.h> // NOLINT 11 #include <signal.h> // NOLINT
12 #include <string.h> // NOLINT 12 #include <string.h> // NOLINT
13 #include <unistd.h> // NOLINT 13 #include <unistd.h> // NOLINT
14 14
15 #include "bin/fdutils.h" 15 #include "bin/fdutils.h"
16 16
17 extern char **environ;
17 18
18 namespace dart { 19 namespace dart {
19 namespace bin { 20 namespace bin {
20 21
21 bool Platform::Initialize() { 22 bool Platform::Initialize() {
22 // Turn off the signal handler for SIGPIPE as it causes the process 23 // Turn off the signal handler for SIGPIPE as it causes the process
23 // to terminate on writing to a closed pipe. Without the signal 24 // to terminate on writing to a closed pipe. Without the signal
24 // handler error EPIPE is set instead. 25 // handler error EPIPE is set instead.
25 struct sigaction act; 26 struct sigaction act;
26 bzero(&act, sizeof(act)); 27 bzero(&act, sizeof(act));
27 act.sa_handler = SIG_IGN; 28 act.sa_handler = SIG_IGN;
28 if (sigaction(SIGPIPE, &act, 0) != 0) { 29 if (sigaction(SIGPIPE, &act, 0) != 0) {
29 perror("Setting signal handler failed"); 30 perror("Setting signal handler failed");
30 return false; 31 return false;
31 } 32 }
32 return true; 33 return true;
33 } 34 }
34 35
35 36
36 int Platform::NumberOfProcessors() { 37 int Platform::NumberOfProcessors() {
37 return sysconf(_SC_NPROCESSORS_ONLN); 38 return sysconf(_SC_NPROCESSORS_ONLN);
38 } 39 }
39 40
40 41
41 const char* Platform::OperatingSystem() { 42 const char* Platform::OperatingSystem() {
42 return "linux"; 43 return "openbsd";
43 } 44 }
44 45
45 46
46 const char* Platform::LibraryExtension() { 47 const char* Platform::LibraryExtension() {
47 return "so"; 48 return "so";
48 } 49 }
49 50
50 51
51 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { 52 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) {
52 return gethostname(buffer, buffer_length) == 0; 53 return gethostname(buffer, buffer_length) == 0;
(...skipping 14 matching lines...) Expand all
67 return result; 68 return result;
68 } 69 }
69 70
70 71
71 void Platform::FreeEnvironment(char** env, intptr_t count) { 72 void Platform::FreeEnvironment(char** env, intptr_t count) {
72 delete[] env; 73 delete[] env;
73 } 74 }
74 75
75 76
76 char* Platform::ResolveExecutablePath() { 77 char* Platform::ResolveExecutablePath() {
78 // TODO(mulander): There is no procfs on OpenBSD - find a workaround
Ivan Posva 2016/01/11 23:58:40 Would remembering arg[0] in main.cc work? It is no
mulander 2016/01/12 00:22:45 There is an example implementation in Go I want to
77 return File::LinkTarget("/proc/self/exe"); 79 return File::LinkTarget("/proc/self/exe");
78 } 80 }
79 81
80 void Platform::Exit(int exit_code) { 82 void Platform::Exit(int exit_code) {
81 exit(exit_code); 83 exit(exit_code);
82 } 84 }
83 85
84 } // namespace bin 86 } // namespace bin
85 } // namespace dart 87 } // namespace dart
86 88
87 #endif // defined(TARGET_OS_LINUX) 89 #endif // defined(TARGET_OS_OPENBSD)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698