| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_OPENBSD) |
| 7 | 7 |
| 8 #include "bin/eventhandler.h" | 8 #include "bin/eventhandler.h" |
| 9 #include "bin/eventhandler_macos.h" | 9 #include "bin/eventhandler_openbsd.h" |
| 10 | 10 |
| 11 #include <errno.h> // NOLINT | 11 #include <errno.h> // NOLINT |
| 12 #include <pthread.h> // NOLINT | 12 #include <pthread.h> // NOLINT |
| 13 #include <stdio.h> // NOLINT | 13 #include <stdio.h> // NOLINT |
| 14 #include <string.h> // NOLINT | 14 #include <string.h> // NOLINT |
| 15 #include <sys/event.h> // NOLINT | 15 #include <sys/event.h> // NOLINT |
| 16 #include <unistd.h> // NOLINT | 16 #include <unistd.h> // NOLINT |
| 17 #include <fcntl.h> // NOLINT | 17 #include <fcntl.h> // NOLINT |
| 18 | 18 |
| 19 #include "bin/dartutils.h" | 19 #include "bin/dartutils.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 ASSERT(kInfinityTimeout < 0); | 426 ASSERT(kInfinityTimeout < 0); |
| 427 struct timespec* timeout = NULL; | 427 struct timespec* timeout = NULL; |
| 428 struct timespec ts; | 428 struct timespec ts; |
| 429 if (millis >= 0) { | 429 if (millis >= 0) { |
| 430 int32_t millis32 = static_cast<int32_t>(millis); | 430 int32_t millis32 = static_cast<int32_t>(millis); |
| 431 int32_t secs = millis32 / 1000; | 431 int32_t secs = millis32 / 1000; |
| 432 ts.tv_sec = secs; | 432 ts.tv_sec = secs; |
| 433 ts.tv_nsec = (millis32 - (secs * 1000)) * 1000000; | 433 ts.tv_nsec = (millis32 - (secs * 1000)) * 1000000; |
| 434 timeout = &ts; | 434 timeout = &ts; |
| 435 } | 435 } |
| 436 // We have to use TEMP_FAILURE_RETRY for mac, as kevent can modify the | 436 // We have to use TEMP_FAILURE_RETRY for openbsd, as kevent can modify the |
| 437 // current sigmask. | 437 // current sigmask. |
| 438 intptr_t result = TEMP_FAILURE_RETRY( | 438 intptr_t result = TEMP_FAILURE_RETRY( |
| 439 kevent(handler_impl->kqueue_fd_, NULL, 0, events, kMaxEvents, timeout)); | 439 kevent(handler_impl->kqueue_fd_, NULL, 0, events, kMaxEvents, timeout)); |
| 440 if (result == -1) { | 440 if (result == -1) { |
| 441 const int kBufferSize = 1024; | 441 const int kBufferSize = 1024; |
| 442 char error_message[kBufferSize]; | 442 char error_message[kBufferSize]; |
| 443 Utils::StrError(errno, error_message, kBufferSize); | 443 Utils::StrError(errno, error_message, kBufferSize); |
| 444 FATAL1("kevent failed %s\n", error_message); | 444 FATAL1("kevent failed %s\n", error_message); |
| 445 } else { | 445 } else { |
| 446 handler_impl->HandleTimeout(); | 446 handler_impl->HandleTimeout(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 | 481 |
| 482 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 482 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 483 // The hashmap does not support keys with value 0. | 483 // The hashmap does not support keys with value 0. |
| 484 return dart::Utils::WordHash(fd + 1); | 484 return dart::Utils::WordHash(fd + 1); |
| 485 } | 485 } |
| 486 | 486 |
| 487 } // namespace bin | 487 } // namespace bin |
| 488 } // namespace dart | 488 } // namespace dart |
| 489 | 489 |
| 490 #endif // defined(TARGET_OS_MACOS) | 490 #endif // defined(TARGET_OS_OPENBSD) |
| OLD | NEW |