Overview
Comment: | Use a single global socket base on MorphOS
MorphOS allows sharing a single socket base between tasks, so having a |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b45a563f2b5fdf8cba8137727c54c4f0 |
User & Date: | js on 2020-12-06 17:49:25 |
Other Links: | manifest | tags |
Context
2020-12-06
| ||
17:52 | PLATFORMS.md: Change MorphOS version to 3.14 check-in: e55c278266 user: js tags: trunk | |
17:49 | Use a single global socket base on MorphOS check-in: b45a563f2b user: js tags: trunk | |
01:54 | Use OS-native TLS keys on MorphOS check-in: c75596237e user: js tags: trunk | |
Changes
Modified src/OFApplication.m from [b8581aaf02] to [9bf3f4dbf0].
︙ | ︙ | |||
92 93 94 95 96 97 98 | id <OFApplicationDelegate> delegate = app.delegate; if ([delegate respondsToSelector: @selector(applicationWillTerminate)]) [delegate applicationWillTerminate]; [delegate release]; | | > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | id <OFApplicationDelegate> delegate = app.delegate; if ([delegate respondsToSelector: @selector(applicationWillTerminate)]) [delegate applicationWillTerminate]; [delegate release]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \ defined(OF_AMIGAOS) && !defined(OF_MORPHOS) of_socket_deinit(); #endif } int of_application_main(int *argc, char **argv[], id <OFApplicationDelegate> delegate) |
︙ | ︙ |
Modified src/OFThread.m from [690c42ccaa] to [fe4bfba4ee].
︙ | ︙ | |||
142 143 144 145 146 147 148 | #ifdef OF_OBJFW_RUNTIME objc_autoreleasePoolPop((void *)(uintptr_t)-1); #else objc_autoreleasePoolPop(thread->_pool); #endif | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #ifdef OF_OBJFW_RUNTIME objc_autoreleasePoolPop((void *)(uintptr_t)-1); #else objc_autoreleasePoolPop(thread->_pool); #endif #if defined(OF_AMIGAOS) && !defined(OF_MORPHOS) && defined(OF_HAVE_SOCKETS) if (thread.supportsSockets) of_socket_deinit(); #endif thread->_running = OF_THREAD_WAITING_FOR_JOIN; [thread release]; |
︙ | ︙ |
Modified src/socket.h from [750c66c5d1] to [fc5416a7db].
︙ | ︙ | |||
288 289 290 291 292 293 294 | * @param node A byte array to store the IPX node of the address */ extern void of_socket_address_get_ipx_node( const of_socket_address_t *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN]); extern bool of_socket_init(void); | | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | * @param node A byte array to store the IPX node of the address */ extern void of_socket_address_get_ipx_node( const of_socket_address_t *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN]); extern bool of_socket_init(void); #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) extern void of_socket_deinit(void); #endif extern int of_socket_errno(void); #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) extern int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr, socklen_t *restrict addrLen); #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) extern of_tlskey_t of_socket_base_key; # ifdef OF_AMIGAOS4 extern of_tlskey_t of_socket_interface_key; # endif #endif #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/socket.m from [3d8eb3c453] to [d03343d8fd].
︙ | ︙ | |||
34 35 36 37 38 39 40 | #import "OFInvalidFormatException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #import "socket.h" #import "socket_helpers.h" #ifdef OF_HAVE_THREADS | | | | | | | | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #import "OFInvalidFormatException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #import "socket.h" #import "socket_helpers.h" #ifdef OF_HAVE_THREADS # if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) # import "mutex.h" # else # import "tlskey.h" # endif #endif #import "once.h" #ifdef OF_AMIGAOS # include <proto/exec.h> #endif #ifdef OF_NINTENDO_3DS # include <3ds/types.h> # include <3ds/services/soc.h> #endif #if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) static of_mutex_t mutex; #endif #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) static bool initSuccessful = false; #endif #ifdef OF_AMIGAOS # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) of_tlskey_t of_socket_base_key; # ifdef OF_AMIGAOS4 of_tlskey_t of_socket_interface_key; # endif # else struct Library *SocketBase; # ifdef OF_AMIGAOS4 struct SocketIFace *ISocket = NULL; # endif # endif #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) OF_CONSTRUCTOR() { if (!of_tlskey_new(&of_socket_base_key)) @throw [OFInitializationFailedException exception]; # ifdef OF_AMIGAOS4 if (!of_tlskey_new(&of_socket_interface_key)) @throw [OFInitializationFailedException exception]; # endif } #endif #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) static void init(void) { # if defined(OF_WINDOWS) WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) |
︙ | ︙ | |||
120 121 122 123 124 125 126 | if (socInit(ctx, 0x100000) != 0) return; atexit((void (*)(void))socExit); # endif | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | if (socInit(ctx, 0x100000) != 0) return; atexit((void (*)(void))socExit); # endif # if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) if (!of_mutex_new(&mutex)) return; # ifdef OF_WII if (!of_spinlock_new(&spinlock)) return; # endif |
︙ | ︙ | |||
150 151 152 153 154 155 156 | } # endif #endif bool of_socket_init(void) { | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | } # endif #endif bool of_socket_init(void) { #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) static of_once_t onceControl = OF_ONCE_INIT; of_once(&onceControl, init); return initSuccessful; #else struct Library *socketBase; # ifdef OF_AMIGAOS4 |
︙ | ︙ | |||
199 200 201 202 203 204 205 | } # endif return true; #endif } | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | } # endif return true; #endif } #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) void of_socket_deinit(void) { struct Library *socketBase = of_tlskey_get(of_socket_base_key); # ifdef OF_AMIGAOS4 struct SocketIFace *socketInterface = of_tlskey_get(of_socket_interface_key); |
︙ | ︙ | |||
324 325 326 327 328 329 330 | #ifndef OF_WII int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr, socklen_t *restrict addrLen) { int ret; | | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | #ifndef OF_WII int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr, socklen_t *restrict addrLen) { int ret; # if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; # endif ret = getsockname(sock, addr, addrLen); # if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; # endif return ret; } #endif |
︙ | ︙ |
Modified src/socket_helpers.h from [76048c8293] to [c2b374f2db].
︙ | ︙ | |||
55 56 57 58 59 60 61 | # include <proto/bsdsocket.h> # endif # include <sys/filio.h> # define closesocket(sock) CloseSocket(sock) # define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg) # define hstrerror(err) "unknown (no hstrerror)" # define SOCKET_ERROR -1 | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # include <proto/bsdsocket.h> # endif # include <sys/filio.h> # define closesocket(sock) CloseSocket(sock) # define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg) # define hstrerror(err) "unknown (no hstrerror)" # define SOCKET_ERROR -1 # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) # define SocketBase ((struct Library *)of_tlskey_get(of_socket_base_key)) # ifdef OF_AMIGAOS4 # define ISocket \ ((struct SocketIFace *)of_tlskey_get(of_socket_interface_key)) # endif # endif # ifdef OF_MORPHOS |
︙ | ︙ |