From: <ent...@ma...> - 2008-09-20 20:46:12
|
Author: entryway Date: Sat Sep 20 22:46:05 2008 New Revision: 2831 Modified: branches/prboom-plus-24/prboom2/src/SDL/i_main.c branches/prboom-plus-24/prboom2/src/e6y.c branches/prboom-plus-24/prboom2/src/e6y.h Log: I_SetAffinityMask() has moved to i_main.c from e6y.c Modified: branches/prboom-plus-24/prboom2/src/SDL/i_main.c ============================================================================== --- branches/prboom-plus-24/prboom2/src/SDL/i_main.c (original) +++ branches/prboom-plus-24/prboom2/src/SDL/i_main.c Sat Sep 20 22:46:05 2008 @@ -37,9 +37,17 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include <sched.h> +#endif + #include "doomdef.h" #include "m_argv.h" #include "d_main.h" @@ -497,6 +505,54 @@ uid_t stored_euid = -1; #endif +// +// Ability to use only the allowed CPUs +// + +static void I_SetAffinityMask(void) +{ + // Set the process affinity mask so that all threads + // run on the same processor. This is a workaround for a bug in + // SDL_mixer that causes occasional crashes. + if (process_affinity_mask) + { + char *errbuf = NULL; +#ifdef _WIN32 + if (!SetProcessAffinityMask(GetCurrentProcess(), process_affinity_mask)) + { + errbuf = WINError(); + } +#else + // POSIX version: + int i; + { + cpu_set_t set; + + CPU_ZERO(&set); + + for(i = 0; i < 16; i++) + { + CPU_SET((process_affinity_mask>>i)&1, &set); + } + + if (sched_setaffinity(getpid(), sizeof(set), &set) == -1) + { + errbuf = strerror(errno); + } + } +#endif + + if (errbuf == NULL) + { + lprintf(LO_INFO, "I_SetAffinityMask: manual affinity mask is %d\n", process_affinity_mask); + } + else + { + lprintf(LO_ERROR, "I_SetAffinityMask: failed to set process affinity mask (%s)\n", errbuf); + } + } +} + //int main(int argc, const char * const * argv) int main(int argc, char **argv) { Modified: branches/prboom-plus-24/prboom2/src/e6y.c ============================================================================== --- branches/prboom-plus-24/prboom2/src/e6y.c (original) +++ branches/prboom-plus-24/prboom2/src/e6y.c Sat Sep 20 22:46:05 2008 @@ -39,9 +39,6 @@ #include <windows.h> #include <direct.h> #include <winreg.h> -#else -#include <unistd.h> -#include <sched.h> #endif #ifdef GL_DOOM #include <SDL_opengl.h> @@ -252,54 +249,6 @@ } #endif -// -// Ability to use only the allowed CPUs -// - -void I_SetAffinityMask(void) -{ - // Set the process affinity mask so that all threads - // run on the same processor. This is a workaround for a bug in - // SDL_mixer that causes occasional crashes. - if (process_affinity_mask) - { - char *errbuf = NULL; -#ifdef _WIN32 - if (!SetProcessAffinityMask(GetCurrentProcess(), process_affinity_mask)) - { - errbuf = WINError(); - } -#else - // POSIX version: - int i; - { - cpu_set_t set; - - CPU_ZERO(&set); - - for(i = 0; i < 16; i++) - { - CPU_SET((process_affinity_mask>>i)&1, &set); - } - - if (sched_setaffinity(getpid(), sizeof(set), &set) == -1) - { - errbuf = strerror(errno); - } - } -#endif - - if (errbuf == NULL) - { - lprintf(LO_INFO, "I_SetAffinityMask: manual affinity mask is %d\n", process_affinity_mask); - } - else - { - lprintf(LO_ERROR, "I_SetAffinityMask: failed to set process affinity mask (%s)\n", errbuf); - } - } -} - //-------------------------------------------------- #ifdef _WIN32 static HWND WIN32_GetHWND(void); Modified: branches/prboom-plus-24/prboom2/src/e6y.h ============================================================================== --- branches/prboom-plus-24/prboom2/src/e6y.h (original) +++ branches/prboom-plus-24/prboom2/src/e6y.h Sat Sep 20 22:46:05 2008 @@ -330,6 +330,10 @@ int stat[TT_MAX]; } timetable_t; +#ifdef _WIN32 +char* WINError(void); +#endif + extern int stats_level; void e6y_G_DoCompleted(void); void e6y_G_CheckDemoStatus(void); |