Differences From Artifact [23a24b058b]:
- File
src/OFKernelEventObserver.m
— part of check-in
[ed4549ddd3]
at
2015-10-17 10:59:15
on branch trunk
— Add a port registry for the Wii
This is necessary as the Wii does not allow picking a random free port,
and thus we need to track which ports are used. (user: js, size: 8179) [annotate] [blame] [check-ins using]
To Artifact [6ae3a0050f]:
- File src/OFKernelEventObserver.m — part of check-in [1ba08eebc5] at 2015-10-19 22:15:13 on branch trunk — Add platform.h & make platform defines consistent (user: js, size: 8180) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #ifdef HAVE_KQUEUE # import "OFKernelEventObserver_kqueue.h" #endif #ifdef HAVE_EPOLL # import "OFKernelEventObserver_epoll.h" #endif #if defined(HAVE_POLL_H) || defined(OF_WII) # import "OFKernelEventObserver_poll.h" #endif #if defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) # import "OFKernelEventObserver_select.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" |
︙ | ︙ | |||
82 83 84 85 86 87 88 | + alloc { if (self == [OFKernelEventObserver class]) #if defined(HAVE_KQUEUE) return [OFKernelEventObserver_kqueue alloc]; #elif defined(HAVE_EPOLL) return [OFKernelEventObserver_epoll alloc]; | | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | + alloc { if (self == [OFKernelEventObserver class]) #if defined(HAVE_KQUEUE) return [OFKernelEventObserver_kqueue alloc]; #elif defined(HAVE_EPOLL) return [OFKernelEventObserver_epoll alloc]; #elif defined(HAVE_POLL_H) || defined(OF_WII) return [OFKernelEventObserver_poll alloc]; #elif defined(HAVE_SYS_SELECT_H) || defined(OF_WINDOWS) return [OFKernelEventObserver_select alloc]; #else # error No kqueue / epoll / poll / select found! #endif return [super alloc]; } - init { self = [super init]; @try { #if !defined(OF_HAVE_PIPE) && !defined(OF_WII) socklen_t cancelAddrLen; #endif _readObjects = [[OFMutableArray alloc] init]; _writeObjects = [[OFMutableArray alloc] init]; _queue = [[OFMutableArray alloc] init]; _queueActions = [[OFDataArray alloc] |
︙ | ︙ | |||
123 124 125 126 127 128 129 | @throw [OFInitializationFailedException exceptionWithClass: [self class]]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); | | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | @throw [OFInitializationFailedException exceptionWithClass: [self class]]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); # ifdef OF_WII _cancelAddr.sin_len = 8; /* The Wii does not accept port 0 as "choose any free port" */ _cancelAddr.sin_port = of_socket_port_find(SOCK_DGRAM); # endif if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; # ifndef OF_WII cancelAddrLen = sizeof(_cancelAddr); if (of_getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; # endif #endif |
︙ | ︙ | |||
160 161 162 163 164 165 166 | - (void)dealloc { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | - (void)dealloc { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); #ifdef OF_WII of_socket_port_free(_cancelAddr.sin_port, SOCK_DGRAM); #endif [_readObjects release]; [_writeObjects release]; [_queue release]; [_queueActions release]; |
︙ | ︙ | |||
356 357 358 359 360 361 362 | } - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | } - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else # ifndef OF_WII OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) > 0); # else OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, 8) > 0); # endif #endif |
︙ | ︙ |