summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2009-03-14 15:28:41 +0000
committerSimon Howard2009-03-14 15:28:41 +0000
commite2e1069332289a714ebebc71db225510c6d8ebff (patch)
treed0110709bd930f9a5c79bdf84b8d3877c37f030d /src
parent535c64b336ce59b4e18819544cd2a1129ae97c61 (diff)
downloadchocolate-doom-e2e1069332289a714ebebc71db225510c6d8ebff.tar.gz
chocolate-doom-e2e1069332289a714ebebc71db225510c6d8ebff.tar.bz2
chocolate-doom-e2e1069332289a714ebebc71db225510c6d8ebff.zip
Add check to allow sched_setaffinity code to work on older versions of
libc. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1470
Diffstat (limited to 'src')
-rw-r--r--src/i_main.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/i_main.c b/src/i_main.c
index 7c5b16e7..3a9ec696 100644
--- a/src/i_main.c
+++ b/src/i_main.c
@@ -29,18 +29,6 @@
#include "SDL.h"
-#include <signal.h>
-
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#ifdef HAVE_SCHED_SETAFFINITY
-#include <unistd.h>
-#include <sched.h>
-#endif
-
#include "doomdef.h"
#include "i_system.h"
#include "m_argv.h"
@@ -48,6 +36,9 @@
#if defined(_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
typedef BOOL WINAPI (*SetAffinityFunc)(HANDLE hProcess, DWORD_PTR mask);
// This is a bit more complicated than it really needs to be. We really
@@ -93,16 +84,24 @@ static void LockCPUAffinity(void)
#elif defined(HAVE_SCHED_SETAFFINITY)
+#include <unistd.h>
+#include <sched.h>
+
// Unix (Linux) version:
static void LockCPUAffinity(void)
{
+#ifdef CPU_SET
cpu_set_t set;
CPU_ZERO(&set);
CPU_SET(0, &set);
sched_setaffinity(getpid(), sizeof(set), &set);
+#else
+ unsigned long mask = 1;
+ sched_setaffinity(getpid(), sizeof(mask), &mask);
+#endif
}
#else