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

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

Issue 2854303005: Fixes issue 29539 with the workaround of initializing libnotify early by calling localtime_r in OS:… (Closed)
Patch Set: assss Created 3 years, 7 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 | « no previous file | no next file » | 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(HOST_OS_MACOS) 6 #if defined(HOST_OS_MACOS)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 416 }
417 417
418 418
419 void OS::InitOnce() { 419 void OS::InitOnce() {
420 // TODO(5411554): For now we check that initonce is called only once, 420 // TODO(5411554): For now we check that initonce is called only once,
421 // Once there is more formal mechanism to call InitOnce we can move 421 // Once there is more formal mechanism to call InitOnce we can move
422 // this check there. 422 // this check there.
423 static bool init_once_called = false; 423 static bool init_once_called = false;
424 ASSERT(init_once_called == false); 424 ASSERT(init_once_called == false);
425 init_once_called = true; 425 init_once_called = true;
426
427 // See https://github.com/dart-lang/sdk/issues/29539
428 // This is a workaround for a macos bug, we eagerly call localtime_r so that
429 // libnotify is initialized early before any fork happens.
430 struct timeval tv;
431 if (gettimeofday(&tv, NULL) < 0) {
432 FATAL1("gettimeofday returned an error (%s)\n", strerror(errno));
433 return;
434 }
435 tm decomposed;
436 struct tm* error_code = localtime_r(&(tv.tv_sec), &decomposed);
437 if (error_code == NULL) {
438 FATAL1("localtime_r returned an error (%s)\n", strerror(errno));
439 return;
440 }
426 } 441 }
427 442
428 443
429 void OS::Shutdown() {} 444 void OS::Shutdown() {}
430 445
431 446
432 void OS::Abort() { 447 void OS::Abort() {
433 abort(); 448 abort();
434 } 449 }
435 450
436 451
437 void OS::Exit(int code) { 452 void OS::Exit(int code) {
438 exit(code); 453 exit(code);
439 } 454 }
440 455
441 } // namespace dart 456 } // namespace dart
442 457
443 #endif // defined(HOST_OS_MACOS) 458 #endif // defined(HOST_OS_MACOS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698