| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #if defined(FLETCH_TARGET_OS_MACOS) | 5 #if defined(DARTINO_TARGET_OS_MACOS) |
| 6 | 6 |
| 7 #include "src/vm/event_handler.h" | 7 #include "src/vm/event_handler.h" |
| 8 | 8 |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <sys/event.h> | 10 #include <sys/event.h> |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 #include <time.h> | 12 #include <time.h> |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 | 14 |
| 15 #include "src/vm/object.h" | 15 #include "src/vm/object.h" |
| 16 #include "src/vm/process.h" | 16 #include "src/vm/process.h" |
| 17 #include "src/vm/thread.h" | 17 #include "src/vm/thread.h" |
| 18 | 18 |
| 19 namespace fletch { | 19 namespace dartino { |
| 20 | 20 |
| 21 void EventHandler::Create() { | 21 void EventHandler::Create() { |
| 22 int* fds = new int[2]; | 22 int* fds = new int[2]; |
| 23 if (pipe(fds) != 0) FATAL("Failed to start the event handler pipe\n"); | 23 if (pipe(fds) != 0) FATAL("Failed to start the event handler pipe\n"); |
| 24 int status = fcntl(fds[0], F_SETFD, FD_CLOEXEC); | 24 int status = fcntl(fds[0], F_SETFD, FD_CLOEXEC); |
| 25 if (status == -1) FATAL("Failed making read pipe close on exec."); | 25 if (status == -1) FATAL("Failed making read pipe close on exec."); |
| 26 status = fcntl(fds[1], F_SETFD, FD_CLOEXEC); | 26 status = fcntl(fds[1], F_SETFD, FD_CLOEXEC); |
| 27 if (status == -1) FATAL("Failed making write pipe close on exec."); | 27 if (status == -1) FATAL("Failed making write pipe close on exec."); |
| 28 | 28 |
| 29 id_ = kqueue(); | 29 id_ = kqueue(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return Failure::illegal_state(); | 137 return Failure::illegal_state(); |
| 138 } | 138 } |
| 139 int result = kevent(id_, &event, 1, NULL, 0, NULL); | 139 int result = kevent(id_, &event, 1, NULL, 0, NULL); |
| 140 if (result == -1) return Failure::index_out_of_bounds(); | 140 if (result == -1) return Failure::index_out_of_bounds(); |
| 141 // Only if the call to kevent succeeded do we actually have a reference to the | 141 // Only if the call to kevent succeeded do we actually have a reference to the |
| 142 // port. | 142 // port. |
| 143 port->IncrementRef(); | 143 port->IncrementRef(); |
| 144 return process->program()->null_object(); | 144 return process->program()->null_object(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace fletch | 147 } // namespace dartino |
| 148 | 148 |
| 149 #endif // defined(FLETCH_TARGET_OS_MACOS) | 149 #endif // defined(DARTINO_TARGET_OS_MACOS) |
| OLD | NEW |