OLD | NEW |
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 Loading... |
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) |
OLD | NEW |