From a0b7883fa308c4e166ef48e59a4233fcbfdb8692 Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Sun, 26 Feb 2012 22:55:18 +0000 Subject: [PATCH] SDL: support unofficial (not in the OSD class) num_processors API used by chdman. Allows chdman to use multiple cores/processors on non-Windows. [R. Belmont] --- src/osd/sdl/osdsdl.h | 2 +- src/osd/sdl/sdlmain.c | 8 ++++---- src/osd/sdl/sdlos.h | 2 +- src/osd/sdl/sdlos_macosx.c | 2 +- src/osd/sdl/sdlos_os2.c | 2 +- src/osd/sdl/sdlos_unix.c | 2 +- src/osd/sdl/sdlos_win32.c | 2 +- src/osd/sdl/sdlwork.c | 13 +++++++------ src/tools/chdman.c | 5 ----- 9 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 66a6bfb9921..8fcb50bffb1 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -269,6 +269,6 @@ void sdlaudio_init(running_machine &machine); // sdlwork.c //============================================================ -extern int sdl_num_processors; +extern int osd_num_processors; #endif diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 9ab0dd600a8..1ebad69f74a 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -609,15 +609,15 @@ void sdl_osd_interface::init(running_machine &machine) /* get number of processors */ stemp = options.numprocessors(); - sdl_num_processors = 0; + osd_num_processors = 0; if (strcmp(stemp, "auto") != 0) { - sdl_num_processors = atoi(stemp); - if (sdl_num_processors < 1) + osd_num_processors = atoi(stemp); + if (osd_num_processors < 1) { mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); - sdl_num_processors = 0; + osd_num_processors = 0; } } diff --git a/src/osd/sdl/sdlos.h b/src/osd/sdl/sdlos.h index 9b9f5d8a7e2..673935d6bab 100644 --- a/src/osd/sdl/sdlos.h +++ b/src/osd/sdl/sdlos.h @@ -23,7 +23,7 @@ Number of processors -----------------------------------------------------------------------------*/ -int osd_num_processors(void); +int osd_get_num_processors(void); /*----------------------------------------------------------------------------- diff --git a/src/osd/sdl/sdlos_macosx.c b/src/osd/sdl/sdlos_macosx.c index 857c9991d18..f06b8bcbf03 100644 --- a/src/osd/sdl/sdlos_macosx.c +++ b/src/osd/sdl/sdlos_macosx.c @@ -142,7 +142,7 @@ void osd_sleep(osd_ticks_t duration) // osd_num_processors //============================================================ -int osd_num_processors(void) +int osd_get_num_processors(void) { int processors = 1; diff --git a/src/osd/sdl/sdlos_os2.c b/src/osd/sdl/sdlos_os2.c index fd294b7ac6f..d21fe73545f 100644 --- a/src/osd/sdl/sdlos_os2.c +++ b/src/osd/sdl/sdlos_os2.c @@ -175,7 +175,7 @@ void osd_sleep(osd_ticks_t duration) // osd_num_processors //============================================================ -int osd_num_processors(void) +int osd_get_num_processors(void) { ULONG numprocs = 1; diff --git a/src/osd/sdl/sdlos_unix.c b/src/osd/sdl/sdlos_unix.c index b325302a9bb..dd5e4bee50c 100644 --- a/src/osd/sdl/sdlos_unix.c +++ b/src/osd/sdl/sdlos_unix.c @@ -67,7 +67,7 @@ void osd_sleep(osd_ticks_t duration) // osd_num_processors //============================================================ -int osd_num_processors(void) +int osd_get_num_processors(void) { int processors = 1; diff --git a/src/osd/sdl/sdlos_win32.c b/src/osd/sdl/sdlos_win32.c index 3d2c66d2d61..ea0c6c3a823 100644 --- a/src/osd/sdl/sdlos_win32.c +++ b/src/osd/sdl/sdlos_win32.c @@ -160,7 +160,7 @@ void osd_sleep(osd_ticks_t duration) // osd_num_processors //============================================================ -int osd_num_processors(void) +int osd_get_num_processors(void) { SYSTEM_INFO info; diff --git a/src/osd/sdl/sdlwork.c b/src/osd/sdl/sdlwork.c index 265ec1c6a1e..c2798b17752 100644 --- a/src/osd/sdl/sdlwork.c +++ b/src/osd/sdl/sdlwork.c @@ -16,7 +16,7 @@ * This is not really a sound solution. */ -int sdl_num_processors = 0; +int osd_num_processors = 0; #include "../osdmini/miniwork.c" @@ -131,7 +131,7 @@ typedef void *PVOID; // GLOBAL VARIABLES //============================================================ -int sdl_num_processors = 0; +int osd_num_processors = 0; //============================================================ // FUNCTION PROTOTYPES @@ -567,10 +567,11 @@ static int effective_num_processors(void) { char *procsoverride; int numprocs = 0; - int physprocs = osd_num_processors(); + int physprocs = osd_get_num_processors(); - if (sdl_num_processors > 0) - return MIN(4 * physprocs, sdl_num_processors); + // osd_num_processors == 0 for 'auto' + if (osd_num_processors > 0) + return MIN(4 * physprocs, osd_num_processors); else { // if the OSDPROCESSORS environment variable is set, use that value if valid @@ -601,7 +602,7 @@ static UINT32 effective_cpu_mask(int index) if (index<2) mask = 0x01; /* main thread and io threads on cpu #0 */ else - mask = (1 << (((index - 1) % (osd_num_processors() - 1)) + 1)); + mask = (1 << (((index - 1) % (osd_get_num_processors() - 1)) + 1)); } else { diff --git a/src/tools/chdman.c b/src/tools/chdman.c index 095d77975ce..308bd622a32 100644 --- a/src/tools/chdman.c +++ b/src/tools/chdman.c @@ -52,12 +52,7 @@ #include #include -#ifdef _WIN32 #define NUM_PROCESSORS_SUPPORTED 1 -#else -#define NUM_PROCESSORS_SUPPORTED 0 -#endif - //************************************************************************** // CONSTANTS & DEFINES