summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2008-09-20 18:18:06 +0000
committerSimon Howard2008-09-20 18:18:06 +0000
commit0d4e0453946cbdde4995b108c2cc0b8431be2168 (patch)
tree921ea160518d5777fee19ee8f595029bf1770e6a
parent303f94ed4972476cb08d75ace12f25fb0fca3196 (diff)
downloadchocolate-doom-0d4e0453946cbdde4995b108c2cc0b8431be2168.tar.gz
chocolate-doom-0d4e0453946cbdde4995b108c2cc0b8431be2168.tar.bz2
chocolate-doom-0d4e0453946cbdde4995b108c2cc0b8431be2168.zip
Set processor affinity under non-Windows platforms using the POSIX API.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1243
-rw-r--r--src/i_main.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/i_main.c b/src/i_main.c
index 748a72be..74b164b1 100644
--- a/src/i_main.c
+++ b/src/i_main.c
@@ -32,6 +32,9 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#else
+#include <unistd.h>
+#include <sched.h>
#endif
#include "doomdef.h"
@@ -46,16 +49,27 @@ int main(int argc, char **argv)
myargc = argc;
myargv = argv;
-#ifdef _WIN32
- // Set the process affinity mask to 1 on Windows, so that all threads
+ // 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.
+#ifdef _WIN32
if (!SetProcessAffinityMask(GetCurrentProcess(), 1))
{
fprintf(stderr, "Failed to set process affinity mask (%d)\n",
(int) GetLastError());
}
+#else
+ // POSIX version:
+
+ {
+ cpu_set_t set;
+
+ CPU_ZERO(&set);
+ CPU_SET(0, &set);
+
+ sched_setaffinity(getpid(), sizeof(set), &set);
+ }
#endif
// start doom