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

Side by Side Diff: runtime/bin/eventhandler_linux.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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/bin/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_LINUX) 8 #if defined(HOST_OS_LINUX)
9 9
10 #include "bin/eventhandler.h" 10 #include "bin/eventhandler.h"
11 #include "bin/eventhandler_linux.h" 11 #include "bin/eventhandler_linux.h"
12 12
13 #include <errno.h> // NOLINT 13 #include <errno.h> // NOLINT
14 #include <fcntl.h> // NOLINT 14 #include <fcntl.h> // NOLINT
15 #include <pthread.h> // NOLINT 15 #include <pthread.h> // NOLINT
16 #include <stdio.h> // NOLINT 16 #include <stdio.h> // NOLINT
17 #include <string.h> // NOLINT 17 #include <string.h> // NOLINT
18 #include <sys/epoll.h> // NOLINT 18 #include <sys/epoll.h> // NOLINT
19 #include <sys/stat.h> // NOLINT 19 #include <sys/stat.h> // NOLINT
20 #include <sys/timerfd.h> // NOLINT 20 #include <sys/timerfd.h> // NOLINT
21 #include <unistd.h> // NOLINT 21 #include <unistd.h> // NOLINT
22 22
23 #include "bin/dartutils.h" 23 #include "bin/dartutils.h"
24 #include "bin/fdutils.h" 24 #include "bin/fdutils.h"
25 #include "bin/lockers.h"
25 #include "bin/log.h" 26 #include "bin/log.h"
26 #include "bin/lockers.h"
27 #include "bin/socket.h" 27 #include "bin/socket.h"
28 #include "bin/thread.h" 28 #include "bin/thread.h"
29 #include "platform/utils.h" 29 #include "platform/utils.h"
30 30
31 namespace dart { 31 namespace dart {
32 namespace bin { 32 namespace bin {
33 33
34 intptr_t DescriptorInfo::GetPollEvents() { 34 intptr_t DescriptorInfo::GetPollEvents() {
35 // Do not ask for EPOLLERR and EPOLLHUP explicitly as they are 35 // Do not ask for EPOLLERR and EPOLLHUP explicitly as they are
36 // triggered anyway. 36 // triggered anyway.
37 intptr_t events = 0; 37 intptr_t events = 0;
38 if ((Mask() & (1 << kInEvent)) != 0) { 38 if ((Mask() & (1 << kInEvent)) != 0) {
39 events |= EPOLLIN; 39 events |= EPOLLIN;
40 } 40 }
41 if ((Mask() & (1 << kOutEvent)) != 0) { 41 if ((Mask() & (1 << kOutEvent)) != 0) {
42 events |= EPOLLOUT; 42 events |= EPOLLOUT;
43 } 43 }
44 return events; 44 return events;
45 } 45 }
46 46
47
48 // Unregister the file descriptor for a DescriptorInfo structure with 47 // Unregister the file descriptor for a DescriptorInfo structure with
49 // epoll. 48 // epoll.
50 static void RemoveFromEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) { 49 static void RemoveFromEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) {
51 VOID_NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, di->fd(), NULL)); 50 VOID_NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, di->fd(), NULL));
52 } 51 }
53 52
54
55 static void AddToEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) { 53 static void AddToEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) {
56 struct epoll_event event; 54 struct epoll_event event;
57 event.events = EPOLLRDHUP | di->GetPollEvents(); 55 event.events = EPOLLRDHUP | di->GetPollEvents();
58 if (!di->IsListeningSocket()) { 56 if (!di->IsListeningSocket()) {
59 event.events |= EPOLLET; 57 event.events |= EPOLLET;
60 } 58 }
61 event.data.ptr = di; 59 event.data.ptr = di;
62 int status = 60 int status =
63 NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, di->fd(), &event)); 61 NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, di->fd(), &event));
64 if (status == -1) { 62 if (status == -1) {
65 // TODO(dart:io): Verify that the dart end is handling this correctly. 63 // TODO(dart:io): Verify that the dart end is handling this correctly.
66 64
67 // Epoll does not accept the file descriptor. It could be due to 65 // Epoll does not accept the file descriptor. It could be due to
68 // already closed file descriptor, or unuspported devices, such 66 // already closed file descriptor, or unuspported devices, such
69 // as /dev/null. In such case, mark the file descriptor as closed, 67 // as /dev/null. In such case, mark the file descriptor as closed,
70 // so dart will handle it accordingly. 68 // so dart will handle it accordingly.
71 di->NotifyAllDartPorts(1 << kCloseEvent); 69 di->NotifyAllDartPorts(1 << kCloseEvent);
72 } 70 }
73 } 71 }
74 72
75
76 EventHandlerImplementation::EventHandlerImplementation() 73 EventHandlerImplementation::EventHandlerImplementation()
77 : socket_map_(&HashMap::SamePointerValue, 16) { 74 : socket_map_(&HashMap::SamePointerValue, 16) {
78 intptr_t result; 75 intptr_t result;
79 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); 76 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_));
80 if (result != 0) { 77 if (result != 0) {
81 FATAL("Pipe creation failed"); 78 FATAL("Pipe creation failed");
82 } 79 }
83 if (!FDUtils::SetNonBlocking(interrupt_fds_[0])) { 80 if (!FDUtils::SetNonBlocking(interrupt_fds_[0])) {
84 FATAL("Failed to set pipe fd non blocking\n"); 81 FATAL("Failed to set pipe fd non blocking\n");
85 } 82 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 event.events = EPOLLIN; 114 event.events = EPOLLIN;
118 event.data.fd = timer_fd_; 115 event.data.fd = timer_fd_;
119 status = 116 status =
120 NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &event)); 117 NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &event));
121 if (status == -1) { 118 if (status == -1) {
122 FATAL2("Failed adding timerfd fd(%i) to epoll instance: %i", timer_fd_, 119 FATAL2("Failed adding timerfd fd(%i) to epoll instance: %i", timer_fd_,
123 errno); 120 errno);
124 } 121 }
125 } 122 }
126 123
127
128 static void DeleteDescriptorInfo(void* info) { 124 static void DeleteDescriptorInfo(void* info) {
129 DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(info); 125 DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(info);
130 di->Close(); 126 di->Close();
131 delete di; 127 delete di;
132 } 128 }
133 129
134
135 EventHandlerImplementation::~EventHandlerImplementation() { 130 EventHandlerImplementation::~EventHandlerImplementation() {
136 socket_map_.Clear(DeleteDescriptorInfo); 131 socket_map_.Clear(DeleteDescriptorInfo);
137 VOID_TEMP_FAILURE_RETRY(close(epoll_fd_)); 132 VOID_TEMP_FAILURE_RETRY(close(epoll_fd_));
138 VOID_TEMP_FAILURE_RETRY(close(timer_fd_)); 133 VOID_TEMP_FAILURE_RETRY(close(timer_fd_));
139 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); 134 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0]));
140 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); 135 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1]));
141 } 136 }
142 137
143
144 void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask, 138 void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask,
145 DescriptorInfo* di) { 139 DescriptorInfo* di) {
146 intptr_t new_mask = di->Mask(); 140 intptr_t new_mask = di->Mask();
147 if ((old_mask != 0) && (new_mask == 0)) { 141 if ((old_mask != 0) && (new_mask == 0)) {
148 RemoveFromEpollInstance(epoll_fd_, di); 142 RemoveFromEpollInstance(epoll_fd_, di);
149 } else if ((old_mask == 0) && (new_mask != 0)) { 143 } else if ((old_mask == 0) && (new_mask != 0)) {
150 AddToEpollInstance(epoll_fd_, di); 144 AddToEpollInstance(epoll_fd_, di);
151 } else if ((old_mask != 0) && (new_mask != 0) && (old_mask != new_mask)) { 145 } else if ((old_mask != 0) && (new_mask != 0) && (old_mask != new_mask)) {
152 ASSERT(!di->IsListeningSocket()); 146 ASSERT(!di->IsListeningSocket());
153 RemoveFromEpollInstance(epoll_fd_, di); 147 RemoveFromEpollInstance(epoll_fd_, di);
154 AddToEpollInstance(epoll_fd_, di); 148 AddToEpollInstance(epoll_fd_, di);
155 } 149 }
156 } 150 }
157 151
158
159 DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo( 152 DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
160 intptr_t fd, 153 intptr_t fd,
161 bool is_listening) { 154 bool is_listening) {
162 ASSERT(fd >= 0); 155 ASSERT(fd >= 0);
163 HashMap::Entry* entry = socket_map_.Lookup(GetHashmapKeyFromFd(fd), 156 HashMap::Entry* entry = socket_map_.Lookup(GetHashmapKeyFromFd(fd),
164 GetHashmapHashFromFd(fd), true); 157 GetHashmapHashFromFd(fd), true);
165 ASSERT(entry != NULL); 158 ASSERT(entry != NULL);
166 DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(entry->value); 159 DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(entry->value);
167 if (di == NULL) { 160 if (di == NULL) {
168 // If there is no data in the hash map for this file descriptor a 161 // If there is no data in the hash map for this file descriptor a
169 // new DescriptorInfo for the file descriptor is inserted. 162 // new DescriptorInfo for the file descriptor is inserted.
170 if (is_listening) { 163 if (is_listening) {
171 di = new DescriptorInfoMultiple(fd); 164 di = new DescriptorInfoMultiple(fd);
172 } else { 165 } else {
173 di = new DescriptorInfoSingle(fd); 166 di = new DescriptorInfoSingle(fd);
174 } 167 }
175 entry->value = di; 168 entry->value = di;
176 } 169 }
177 ASSERT(fd == di->fd()); 170 ASSERT(fd == di->fd());
178 return di; 171 return di;
179 } 172 }
180 173
181
182 void EventHandlerImplementation::WakeupHandler(intptr_t id, 174 void EventHandlerImplementation::WakeupHandler(intptr_t id,
183 Dart_Port dart_port, 175 Dart_Port dart_port,
184 int64_t data) { 176 int64_t data) {
185 InterruptMessage msg; 177 InterruptMessage msg;
186 msg.id = id; 178 msg.id = id;
187 msg.dart_port = dart_port; 179 msg.dart_port = dart_port;
188 msg.data = data; 180 msg.data = data;
189 // WriteToBlocking will write up to 512 bytes atomically, and since our msg 181 // WriteToBlocking will write up to 512 bytes atomically, and since our msg
190 // is smaller than 512, we don't need a thread lock. 182 // is smaller than 512, we don't need a thread lock.
191 // See: http://linux.die.net/man/7/pipe, section 'Pipe_buf'. 183 // See: http://linux.die.net/man/7/pipe, section 'Pipe_buf'.
192 ASSERT(kInterruptMessageSize < PIPE_BUF); 184 ASSERT(kInterruptMessageSize < PIPE_BUF);
193 intptr_t result = 185 intptr_t result =
194 FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize); 186 FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize);
195 if (result != kInterruptMessageSize) { 187 if (result != kInterruptMessageSize) {
196 if (result == -1) { 188 if (result == -1) {
197 perror("Interrupt message failure:"); 189 perror("Interrupt message failure:");
198 } 190 }
199 FATAL1("Interrupt message failure. Wrote %" Pd " bytes.", result); 191 FATAL1("Interrupt message failure. Wrote %" Pd " bytes.", result);
200 } 192 }
201 } 193 }
202 194
203
204 void EventHandlerImplementation::HandleInterruptFd() { 195 void EventHandlerImplementation::HandleInterruptFd() {
205 const intptr_t MAX_MESSAGES = kInterruptMessageSize; 196 const intptr_t MAX_MESSAGES = kInterruptMessageSize;
206 InterruptMessage msg[MAX_MESSAGES]; 197 InterruptMessage msg[MAX_MESSAGES];
207 ssize_t bytes = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 198 ssize_t bytes = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
208 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize)); 199 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize));
209 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) { 200 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) {
210 if (msg[i].id == kTimerId) { 201 if (msg[i].id == kTimerId) {
211 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data); 202 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data);
212 struct itimerspec it; 203 struct itimerspec it;
213 memset(&it, 0, sizeof(it)); 204 memset(&it, 0, sizeof(it));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 intptr_t old_mask = di->Mask(); 276 intptr_t old_mask = di->Mask();
286 di->SetPortAndMask(msg[i].dart_port, msg[i].data & EVENT_MASK); 277 di->SetPortAndMask(msg[i].dart_port, msg[i].data & EVENT_MASK);
287 UpdateEpollInstance(old_mask, di); 278 UpdateEpollInstance(old_mask, di);
288 } else { 279 } else {
289 UNREACHABLE(); 280 UNREACHABLE();
290 } 281 }
291 } 282 }
292 } 283 }
293 } 284 }
294 285
295
296 #ifdef DEBUG_POLL 286 #ifdef DEBUG_POLL
297 static void PrintEventMask(intptr_t fd, intptr_t events) { 287 static void PrintEventMask(intptr_t fd, intptr_t events) {
298 Log::Print("%d ", fd); 288 Log::Print("%d ", fd);
299 if ((events & EPOLLIN) != 0) { 289 if ((events & EPOLLIN) != 0) {
300 Log::Print("EPOLLIN "); 290 Log::Print("EPOLLIN ");
301 } 291 }
302 if ((events & EPOLLPRI) != 0) { 292 if ((events & EPOLLPRI) != 0) {
303 Log::Print("EPOLLPRI "); 293 Log::Print("EPOLLPRI ");
304 } 294 }
305 if ((events & EPOLLOUT) != 0) { 295 if ((events & EPOLLOUT) != 0) {
(...skipping 12 matching lines...) Expand all
318 EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDHUP; 308 EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
319 if ((events & ~all_events) != 0) { 309 if ((events & ~all_events) != 0) {
320 Log::Print("(and %08x) ", events & ~all_events); 310 Log::Print("(and %08x) ", events & ~all_events);
321 } 311 }
322 Log::Print("(available %d) ", FDUtils::AvailableBytes(fd)); 312 Log::Print("(available %d) ", FDUtils::AvailableBytes(fd));
323 313
324 Log::Print("\n"); 314 Log::Print("\n");
325 } 315 }
326 #endif 316 #endif
327 317
328
329 intptr_t EventHandlerImplementation::GetPollEvents(intptr_t events, 318 intptr_t EventHandlerImplementation::GetPollEvents(intptr_t events,
330 DescriptorInfo* di) { 319 DescriptorInfo* di) {
331 #ifdef DEBUG_POLL 320 #ifdef DEBUG_POLL
332 PrintEventMask(di->fd(), events); 321 PrintEventMask(di->fd(), events);
333 #endif 322 #endif
334 if ((events & EPOLLERR) != 0) { 323 if ((events & EPOLLERR) != 0) {
335 // Return error only if EPOLLIN is present. 324 // Return error only if EPOLLIN is present.
336 return ((events & EPOLLIN) != 0) ? (1 << kErrorEvent) : 0; 325 return ((events & EPOLLIN) != 0) ? (1 << kErrorEvent) : 0;
337 } 326 }
338 intptr_t event_mask = 0; 327 intptr_t event_mask = 0;
339 if ((events & EPOLLIN) != 0) { 328 if ((events & EPOLLIN) != 0) {
340 event_mask |= (1 << kInEvent); 329 event_mask |= (1 << kInEvent);
341 } 330 }
342 if ((events & EPOLLOUT) != 0) { 331 if ((events & EPOLLOUT) != 0) {
343 event_mask |= (1 << kOutEvent); 332 event_mask |= (1 << kOutEvent);
344 } 333 }
345 if ((events & (EPOLLHUP | EPOLLRDHUP)) != 0) { 334 if ((events & (EPOLLHUP | EPOLLRDHUP)) != 0) {
346 event_mask |= (1 << kCloseEvent); 335 event_mask |= (1 << kCloseEvent);
347 } 336 }
348 return event_mask; 337 return event_mask;
349 } 338 }
350 339
351
352 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, 340 void EventHandlerImplementation::HandleEvents(struct epoll_event* events,
353 int size) { 341 int size) {
354 bool interrupt_seen = false; 342 bool interrupt_seen = false;
355 for (int i = 0; i < size; i++) { 343 for (int i = 0; i < size; i++) {
356 if (events[i].data.ptr == NULL) { 344 if (events[i].data.ptr == NULL) {
357 interrupt_seen = true; 345 interrupt_seen = true;
358 } else if (events[i].data.fd == timer_fd_) { 346 } else if (events[i].data.fd == timer_fd_) {
359 int64_t val; 347 int64_t val;
360 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 348 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
361 read(timer_fd_, &val, sizeof(val))); 349 read(timer_fd_, &val, sizeof(val)));
(...skipping 17 matching lines...) Expand all
379 } 367 }
380 } 368 }
381 } 369 }
382 if (interrupt_seen) { 370 if (interrupt_seen) {
383 // Handle after socket events, so we avoid closing a socket before we handle 371 // Handle after socket events, so we avoid closing a socket before we handle
384 // the current events. 372 // the current events.
385 HandleInterruptFd(); 373 HandleInterruptFd();
386 } 374 }
387 } 375 }
388 376
389
390 void EventHandlerImplementation::Poll(uword args) { 377 void EventHandlerImplementation::Poll(uword args) {
391 ThreadSignalBlocker signal_blocker(SIGPROF); 378 ThreadSignalBlocker signal_blocker(SIGPROF);
392 static const intptr_t kMaxEvents = 16; 379 static const intptr_t kMaxEvents = 16;
393 struct epoll_event events[kMaxEvents]; 380 struct epoll_event events[kMaxEvents];
394 EventHandler* handler = reinterpret_cast<EventHandler*>(args); 381 EventHandler* handler = reinterpret_cast<EventHandler*>(args);
395 EventHandlerImplementation* handler_impl = &handler->delegate_; 382 EventHandlerImplementation* handler_impl = &handler->delegate_;
396 ASSERT(handler_impl != NULL); 383 ASSERT(handler_impl != NULL);
397 384
398 while (!handler_impl->shutdown_) { 385 while (!handler_impl->shutdown_) {
399 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 386 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
400 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, -1)); 387 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, -1));
401 ASSERT(EAGAIN == EWOULDBLOCK); 388 ASSERT(EAGAIN == EWOULDBLOCK);
402 if (result <= 0) { 389 if (result <= 0) {
403 if (errno != EWOULDBLOCK) { 390 if (errno != EWOULDBLOCK) {
404 perror("Poll failed"); 391 perror("Poll failed");
405 } 392 }
406 } else { 393 } else {
407 handler_impl->HandleEvents(events, result); 394 handler_impl->HandleEvents(events, result);
408 } 395 }
409 } 396 }
410 DEBUG_ASSERT(ReferenceCounted<Socket>::instances() == 0); 397 DEBUG_ASSERT(ReferenceCounted<Socket>::instances() == 0);
411 handler->NotifyShutdownDone(); 398 handler->NotifyShutdownDone();
412 } 399 }
413 400
414
415 void EventHandlerImplementation::Start(EventHandler* handler) { 401 void EventHandlerImplementation::Start(EventHandler* handler) {
416 int result = Thread::Start(&EventHandlerImplementation::Poll, 402 int result = Thread::Start(&EventHandlerImplementation::Poll,
417 reinterpret_cast<uword>(handler)); 403 reinterpret_cast<uword>(handler));
418 if (result != 0) { 404 if (result != 0) {
419 FATAL1("Failed to start event handler thread %d", result); 405 FATAL1("Failed to start event handler thread %d", result);
420 } 406 }
421 } 407 }
422 408
423
424 void EventHandlerImplementation::Shutdown() { 409 void EventHandlerImplementation::Shutdown() {
425 SendData(kShutdownId, 0, 0); 410 SendData(kShutdownId, 0, 0);
426 } 411 }
427 412
428
429 void EventHandlerImplementation::SendData(intptr_t id, 413 void EventHandlerImplementation::SendData(intptr_t id,
430 Dart_Port dart_port, 414 Dart_Port dart_port,
431 int64_t data) { 415 int64_t data) {
432 WakeupHandler(id, dart_port, data); 416 WakeupHandler(id, dart_port, data);
433 } 417 }
434 418
435
436 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 419 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
437 // The hashmap does not support keys with value 0. 420 // The hashmap does not support keys with value 0.
438 return reinterpret_cast<void*>(fd + 1); 421 return reinterpret_cast<void*>(fd + 1);
439 } 422 }
440 423
441
442 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 424 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
443 // The hashmap does not support keys with value 0. 425 // The hashmap does not support keys with value 0.
444 return dart::Utils::WordHash(fd + 1); 426 return dart::Utils::WordHash(fd + 1);
445 } 427 }
446 428
447 } // namespace bin 429 } // namespace bin
448 } // namespace dart 430 } // namespace dart
449 431
450 #endif // defined(HOST_OS_LINUX) 432 #endif // defined(HOST_OS_LINUX)
451 433
452 #endif // !defined(DART_IO_DISABLED) 434 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698