diff options
author | Simon Howard | 2008-12-09 20:35:17 +0000 |
---|---|---|
committer | Simon Howard | 2008-12-09 20:35:17 +0000 |
commit | ca3844dc5b138b19259e8dc9daaa397867834a5f (patch) | |
tree | 41b20406d45c74c5edbdd57b3a5e28e9e89fa441 | |
parent | a0062502d183d5d526c1f801b1206234b664898b (diff) | |
download | chocolate-doom-ca3844dc5b138b19259e8dc9daaa397867834a5f.tar.gz chocolate-doom-ca3844dc5b138b19259e8dc9daaa397867834a5f.tar.bz2 chocolate-doom-ca3844dc5b138b19259e8dc9daaa397867834a5f.zip |
Add check for sched_setaffinity to configure and only use it if it is
found. Display a message if we don't have any way to set processor
affinity.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1413
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/i_main.c | 39 |
2 files changed, 28 insertions, 13 deletions
diff --git a/configure.in b/configure.in index 43e3438f..83c4739a 100644 --- a/configure.in +++ b/configure.in @@ -54,7 +54,7 @@ AC_CHECK_LIB(SDL_net,SDLNet_UDP_Send,[ ]) AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h]) -AC_CHECK_FUNCS(mmap) +AC_CHECK_FUNCS(mmap sched_setaffinity) # DWF 2008-02-10: FIXME AC_CHECK_LIB(samplerate, src_new) diff --git a/src/i_main.c b/src/i_main.c index 74b164b1..c103296b 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -25,6 +25,8 @@ //----------------------------------------------------------------------------- +#include "config.h" + #include "SDL.h" #include <signal.h> @@ -32,7 +34,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> -#else +#endif + +#ifdef HAVE_SCHED_SETAFFINITY #include <unistd.h> #include <sched.h> #endif @@ -42,25 +46,35 @@ #include "m_argv.h" #include "d_main.h" -int main(int argc, char **argv) -{ +#if !defined(_WIN32) && !defined(HAVE_SCHED_SETAFFINITY) +#warning No known way to set processor affinity on this platform. +#warning You may experience crashes due to SDL_mixer. +#endif + +int main(int argc, char **argv) +{ // save arguments - myargc = argc; - myargv = argv; + myargc = argc; + myargv = argv; + +#ifdef _WIN32 // Set the process affinity mask so that all threads - // run on the same processor. This is a workaround for a bug in + // run on the same processor. This is a workaround for a bug in // SDL_mixer that causes occasional crashes. -#ifdef _WIN32 if (!SetProcessAffinityMask(GetCurrentProcess(), 1)) { fprintf(stderr, "Failed to set process affinity mask (%d)\n", (int) GetLastError()); } -#else - // POSIX version: + +#endif + +#ifdef HAVE_SCHED_SETAFFINITY + + // Linux version: { cpu_set_t set; @@ -70,12 +84,13 @@ int main(int argc, char **argv) sched_setaffinity(getpid(), sizeof(set), &set); } + #endif // start doom - - D_DoomMain (); + + D_DoomMain (); return 0; -} +} |