shithub: choc

Download patch

ref: e2e1069332289a714ebebc71db225510c6d8ebff
parent: 535c64b336ce59b4e18819544cd2a1129ae97c61
author: Simon Howard <fraggle@gmail.com>
date: Sat Mar 14 11:28:41 EDT 2009

Add check to allow sched_setaffinity code to work on older versions of
libc.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1470

--- 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,10 +84,14 @@
 
 #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);
@@ -103,6 +98,10 @@
     CPU_SET(0, &set);
 
     sched_setaffinity(getpid(), sizeof(set), &set);
+#else
+    unsigned long mask = 1;
+    sched_setaffinity(getpid(), sizeof(mask), &mask);
+#endif
 }
 
 #else