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

Side by Side Diff: runtime/vm/os_openbsd.cc

Issue 1559053002: Refs #10260 OpenBSD support #25327 Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review issues 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
« no previous file with comments | « runtime/vm/native_symbol_openbsd.cc ('k') | runtime/vm/os_thread.h » ('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 "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_OPENBSD)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <limits.h> // NOLINT 11 #include <limits.h> // NOLINT
12 #include <malloc.h> // NOLINT 12 #include <stdlib.h> // NOLINT
13 #include <time.h> // NOLINT 13 #include <time.h> // NOLINT
14 #include <sys/resource.h> // NOLINT 14 #include <sys/resource.h> // NOLINT
15 #include <sys/time.h> // NOLINT 15 #include <sys/time.h> // NOLINT
16 #include <sys/types.h> // NOLINT 16 #include <sys/types.h> // NOLINT
17 #include <sys/syscall.h> // NOLINT
18 #include <sys/stat.h> // NOLINT 17 #include <sys/stat.h> // NOLINT
19 #include <fcntl.h> // NOLINT 18 #include <fcntl.h> // NOLINT
20 #include <unistd.h> // NOLINT 19 #include <unistd.h> // NOLINT
21 20
22 #include "platform/utils.h" 21 #include "platform/utils.h"
23 #include "vm/code_observers.h" 22 #include "vm/code_observers.h"
24 #include "vm/dart.h" 23 #include "vm/dart.h"
25 #include "vm/debuginfo.h" 24 #include "vm/debuginfo.h"
26 #include "vm/isolate.h" 25 #include "vm/isolate.h"
27 #include "vm/lockers.h" 26 #include "vm/lockers.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 #elif defined(TARGET_ARCH_ARM64) 251 #elif defined(TARGET_ARCH_ARM64)
253 return kElfMachARM64; 252 return kElfMachARM64;
254 #elif defined(TARGET_ARCH_MIPS) 253 #elif defined(TARGET_ARCH_MIPS)
255 return kElfMachMIPS; 254 return kElfMachMIPS;
256 #else 255 #else
257 #error Unknown architecture. 256 #error Unknown architecture.
258 #endif 257 #endif
259 } 258 }
260 259
261 pid_t gettid() { 260 pid_t gettid() {
262 // libc doesn't wrap the Linux-specific gettid system call.
263 // Note that this thread id is not the same as the posix thread id. 261 // Note that this thread id is not the same as the posix thread id.
264 return syscall(SYS_gettid); 262 return getthrid();
265 } 263 }
266 264
267 uint64_t GetKernelTimeNanos() { 265 uint64_t GetKernelTimeNanos() {
268 if (clock_id_ != kInvalidClockId) { 266 if (clock_id_ != kInvalidClockId) {
269 struct timespec ts; 267 struct timespec ts;
270 int r = clock_gettime(clock_id_, &ts); 268 int r = clock_gettime(clock_id_, &ts);
271 ASSERT(r == 0); 269 ASSERT(r == 0);
272 uint64_t nanos = static_cast<uint64_t>(ts.tv_sec) * 270 uint64_t nanos = static_cast<uint64_t>(ts.tv_sec) *
273 static_cast<uint64_t>(kNanosecondsPerSecond); 271 static_cast<uint64_t>(kNanosecondsPerSecond);
274 nanos += static_cast<uint64_t>(ts.tv_nsec); 272 nanos += static_cast<uint64_t>(ts.tv_nsec);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 328
331 void* out_file_; 329 void* out_file_;
332 int clock_fd_; 330 int clock_fd_;
333 int clock_id_; 331 int clock_id_;
334 uint64_t code_sequence_; 332 uint64_t code_sequence_;
335 DISALLOW_COPY_AND_ASSIGN(JitdumpCodeObserver); 333 DISALLOW_COPY_AND_ASSIGN(JitdumpCodeObserver);
336 }; 334 };
337 335
338 336
339 const char* OS::Name() { 337 const char* OS::Name() {
340 return "linux"; 338 return "openbsd";
341 } 339 }
342 340
343 341
344 intptr_t OS::ProcessId() { 342 intptr_t OS::ProcessId() {
345 return static_cast<intptr_t>(getpid()); 343 return static_cast<intptr_t>(getpid());
346 } 344 }
347 345
348 346
349 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { 347 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) {
350 time_t seconds = static_cast<time_t>(seconds_since_epoch); 348 time_t seconds = static_cast<time_t>(seconds_since_epoch);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 result *= kMicrosecondsPerSecond; 405 result *= kMicrosecondsPerSecond;
408 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); 406 result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
409 return result; 407 return result;
410 } 408 }
411 409
412 410
413 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { 411 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
414 const int kMinimumAlignment = 16; 412 const int kMinimumAlignment = 16;
415 ASSERT(Utils::IsPowerOfTwo(alignment)); 413 ASSERT(Utils::IsPowerOfTwo(alignment));
416 ASSERT(alignment >= kMinimumAlignment); 414 ASSERT(alignment >= kMinimumAlignment);
417 void* p = memalign(alignment, size); 415 void* p = NULL;
418 if (p == NULL) { 416 if (posix_memalign(&p, alignment, size)) {
419 UNREACHABLE(); 417 UNREACHABLE();
420 } 418 }
421 return p; 419 return p;
422 } 420 }
423 421
424 422
425 void OS::AlignedFree(void* ptr) { 423 void OS::AlignedFree(void* ptr) {
426 free(ptr); 424 free(ptr);
427 } 425 }
428 426
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 abort(); 644 abort();
647 } 645 }
648 646
649 647
650 void OS::Exit(int code) { 648 void OS::Exit(int code) {
651 exit(code); 649 exit(code);
652 } 650 }
653 651
654 } // namespace dart 652 } // namespace dart
655 653
656 #endif // defined(TARGET_OS_LINUX) 654 #endif // defined(TARGET_OS_OPENBSD)
OLDNEW
« no previous file with comments | « runtime/vm/native_symbol_openbsd.cc ('k') | runtime/vm/os_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698