From fd2096f3dc1e13ad7b5326cd9cb2a98a9a0b5015 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 04:26:09 +0200 Subject: [PATCH] Cleanups --- libretro-common/net/net_compat.c | 24 ++++++++++ netlogger.c | 80 ++++++-------------------------- 2 files changed, 39 insertions(+), 65 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 7ef476c4f0..153b3c479c 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -240,8 +240,28 @@ bool network_init(void) return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + int timeout_count = 10; + cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); + + if (cellNetCtlInit() < 0) + goto error; + + for (;;) + { + int state; + if (cellNetCtlGetState(&state) < 0) + goto error; + + if (state == CELL_NET_CTL_STATE_IPObtained) + break; + + retro_sleep(500); + timeout_count--; + if (timeout_count < 0) + return 0; + } #elif defined(VITA) SceNetInitParam initparam; @@ -259,6 +279,10 @@ bool network_init(void) } retro_epoll_fd = sceNetEpollCreate("epoll", 0); +#elif defined(GEKKO) + char t[16]; + if (if_config(t, NULL, NULL, TRUE) < 0) + goto error; #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif diff --git a/netlogger.c b/netlogger.c index 7a1ea0088a..fdcb289fd1 100644 --- a/netlogger.c +++ b/netlogger.c @@ -40,84 +40,37 @@ static int g_sid; static struct sockaddr_in target; static char sendbuf[4096]; -#ifdef VITA -#define NET_INIT_SIZE 512*1024 -#endif -static void *net_memory = NULL; -static int network_interface_up(struct sockaddr_in *target, - const char *server, unsigned port, int *s) +void logger_init (void) { -#if defined(VITA) - if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) + const char *server = PC_DEVELOPMENT_IP_ADDRESS; + unsigned port = PC_DEVELOPMENT_UDP_PORT; + + if (!network_init()) { - SceNetInitParam initparam; - net_memory = malloc(NET_INIT_SIZE); - - initparam.memory = net_memory; - initparam.size = NET_INIT_SIZE; - initparam.flags = 0; - - sceNetInit(&initparam); + printf("Could not initialize network logger interface.\n"); + return; } -#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - int timeout_count = 10; - if (cellNetCtlInit() < 0) - goto error; - - for (;;) - { - int state; - if (cellNetCtlGetState(&state) < 0) - goto error; - - if (state == CELL_NET_CTL_STATE_IPObtained) - break; - - retro_sleep(500); - timeout_count--; - if (timeout_count < 0) - return 0; - } -#elif defined(GEKKO) - char t[16]; - if (if_config(t, NULL, NULL, TRUE) < 0) - goto error; -#endif - - *s = socket_create( + g_sid = socket_create( "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, SOCKET_PROTOCOL_NONE); #ifdef VITA - target->sin_family = PSP2_NET_AF_INET; - target->sin_port = sceNetHtons(port); - target->sin_addr = inet_aton(server); + target.sin_family = PSP2_NET_AF_INET; + target.sin_port = sceNetHtons(port); + target.sin_addr = inet_aton(server); #else - target->sin_family = AF_INET; - target->sin_port = htons(port); + target.sin_family = AF_INET; + target.sin_port = htons(port); #ifdef GEKKO - target->sin_len = 8; + target.sin_len = 8; #endif - inet_pton(AF_INET, server, &target->sin_addr); + inet_pton(AF_INET, server, &target.sin_addr); #endif - - return 0; - -error: - printf("Could not initialize network logger interface.\n"); - - return -1; -} - -void logger_init (void) -{ - network_interface_up(&target, - PC_DEVELOPMENT_IP_ADDRESS,PC_DEVELOPMENT_UDP_PORT, &g_sid); } void logger_shutdown (void) @@ -126,9 +79,6 @@ void logger_shutdown (void) network_deinit(); - if (net_memory) - free(net_memory); - if (ret < 0) printf("Could not deinitialize network logger interface.\n"); }