Differences From Artifact [ebf56cad93]:
- File
src/socket.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: 5411) [annotate] [blame] [check-ins using]
To Artifact [34bd39e695]:
- File src/socket.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: 5415) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
28 29 30 31 32 33 34 | # include "threading.h" static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; | | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # include "threading.h" static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; #ifdef OF_WII # ifdef OF_HAVE_THREADS static of_spinlock_t spinlock; # endif static uint8_t portRegistry[2][65536 / 8]; #endif static void init(void) { #if defined(OF_WINDOWS) WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) return; #elif defined(OF_WII) if (net_init() < 0) return; #endif #ifdef OF_HAVE_THREADS if (!of_mutex_new(&mutex)) return; # ifdef OF_WII if (!of_spinlock_new(&spinlock)) return; # endif #endif initialized = true; } |
︙ | ︙ | |||
77 78 79 80 81 82 83 | return initialized; } int of_socket_errno() { | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | return initialized; } int of_socket_errno() { #ifndef OF_WINDOWS return errno; #else switch (WSAGetLastError()) { case WSAEACCES: return EACCES; case WSAEADDRINUSE: return EADDRINUSE; |
︙ | ︙ | |||
173 174 175 176 177 178 179 | return EWOULDBLOCK; } return 0; #endif } | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | return EWOULDBLOCK; } return 0; #endif } #ifndef OF_WII int of_getsockname(of_socket_t socket, struct sockaddr *restrict address, socklen_t *restrict address_len) { int ret; # ifdef OF_HAVE_THREADS |
︙ | ︙ |