From 92ef192b2ab1a0c3b19af6ca5a51883c60ef1029 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 8 Jan 2013 08:30:54 +0100 Subject: [PATCH] (RARCH_CONSOLE) Move logger function invocations into platform files --- frontend/frontend_console.c | 8 ++----- frontend/platform/platform_gx.c | 11 +++++---- frontend/platform/platform_inl.h | 41 ++++++++++++++++++++++++++++++++ frontend/platform/platform_ps3.c | 10 ++++---- frontend/platform/platform_xdk.c | 9 +++++++ 5 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 frontend/platform/platform_inl.h diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index ba57975186..b04e3fdac2 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -150,12 +150,8 @@ begin_shutdown: menu_free(); uninit_drivers_console(); -#ifdef HAVE_LOGGER - logger_shutdown(); -#elif defined(HAVE_FILE_LOGGER) - if (g_extern.log_file) - fclose(g_extern.log_file); - g_extern.log_file = NULL; +#ifdef PERF_TEST + rarch_perf_log(); #endif system_deinit(); diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index c209a17e56..9db775925b 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -20,6 +20,8 @@ #include "../../general.h" #include "../../libretro.h" +#include "platform_inl.h" + #include "../../console/rgui/rgui.h" #include "../../gfx/fonts/bitmap.h" @@ -467,14 +469,12 @@ static void system_init(void) fatInitDefault(); #ifdef HAVE_LOGGER - g_extern.verbose = true; - logger_init(); + inl_logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) - g_extern.verbose = true; - g_extern.log_file = fopen("/retroarch-log.txt", "w"); + inl_logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; @@ -533,6 +533,9 @@ static void system_deinit_save(void) static void system_deinit(void) { +#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + inl_logger_deinit() +#endif } static void system_exitspawn(void) diff --git a/frontend/platform/platform_inl.h b/frontend/platform/platform_inl.h new file mode 100644 index 0000000000..d234dc3ab9 --- /dev/null +++ b/frontend/platform/platform_inl.h @@ -0,0 +1,41 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + +static inline void inl_logger_init(void) +{ +#if defined(HAVE_LOGGER) + g_extern.verbose = true; + logger_init(); +#elif defined(HAVE_FILE_LOGGER) + g_extern.verbose = true; + g_extern.log_file = fopen("/retroarch-log.txt", "w"); +#endif +} + +static inline void inl_logger_deinit(void) +{ +#if defined(HAVE_LOGGER) + logger_shutdown(); +#elif defined(HAVE_FILE_LOGGER) + if (g_extern.log_file) + fclose(g_extern.log_file); + g_extern.log_file = NULL; +#endif +} + +#endif diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 0e7b4638df..d7f72903cb 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -16,6 +16,8 @@ #include +#include "platform_inl.h" + #include "../../ps3/sdk_defines.h" #include "../../ps3/ps3_input.h" @@ -243,8 +245,8 @@ static void system_init(void) sys_net_initialize_network(); #endif -#ifdef HAVE_LOGGER - logger_init(); +#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + inl_logger_init(); #endif #ifndef __PSL1GHT__ @@ -309,8 +311,8 @@ static void system_deinit(void) oskutil_unload(osk); #endif -#ifdef HAVE_LOGGER - logger_shutdown(); +#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + inl_logger_deinit(); #endif #if defined(HAVE_SYSMODULES) diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index dd9fff4832..77b88daf35 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -20,6 +20,8 @@ #include #include +#include "platform_inl.h" + #if defined(_XBOX360) #include #include "../../360/frontend-xdk/menu.h" @@ -128,6 +130,10 @@ static void system_post_init(void) static void system_init(void) { +#if defined (HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + inl_logger_init(); +#endif + #ifdef _XBOX1 // Mount drives xbox_io_mount("A:", "cdrom0"); @@ -147,6 +153,9 @@ static void system_process_args(int argc, char *argv[]) static void system_deinit(void) { +#if defined (HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) + logger_deinit(); +#endif } static void system_deinit_save(void)