|
@@ -238,24 +238,11 @@ rtkit_setpriority(pid_t thread, int nice_level)
|
|
|
|
|
|
#endif /* !SDL_USE_LIBDBUS */
|
|
|
|
|
|
+#if __LINUX__
|
|
|
int
|
|
|
-SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|
|
+SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
|
|
|
{
|
|
|
-#if __NACL__
|
|
|
- /* FIXME: Setting thread priority does not seem to be supported in NACL */
|
|
|
- return 0;
|
|
|
-#elif __LINUX__
|
|
|
- int value;
|
|
|
- pid_t thread = syscall(SYS_gettid);
|
|
|
-
|
|
|
- if (priority == SDL_THREAD_PRIORITY_LOW) {
|
|
|
- value = 19;
|
|
|
- } else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
|
|
- value = -20;
|
|
|
- } else {
|
|
|
- value = 0;
|
|
|
- }
|
|
|
- if (setpriority(PRIO_PROCESS, thread, value) < 0) {
|
|
|
+ if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) < 0) {
|
|
|
/* Note that this fails if you're trying to set high priority
|
|
|
and you don't have root permission. BUT DON'T RUN AS ROOT!
|
|
|
|
|
@@ -268,11 +255,32 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|
|
README and sample code at:
|
|
|
http://git.0pointer.net/rtkit.git
|
|
|
*/
|
|
|
- if (rtkit_setpriority(thread, value) == SDL_FALSE) {
|
|
|
+ if (rtkit_setpriority((pid_t)threadID, priority) == SDL_FALSE) {
|
|
|
return SDL_SetError("setpriority() failed");
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
+}
|
|
|
+#endif /* __LINUX__ */
|
|
|
+
|
|
|
+int
|
|
|
+SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|
|
+{
|
|
|
+#if __NACL__
|
|
|
+ /* FIXME: Setting thread priority does not seem to be supported in NACL */
|
|
|
+ return 0;
|
|
|
+#elif __LINUX__
|
|
|
+ int value;
|
|
|
+ pid_t thread = syscall(SYS_gettid);
|
|
|
+
|
|
|
+ if (priority == SDL_THREAD_PRIORITY_LOW) {
|
|
|
+ value = 19;
|
|
|
+ } else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
|
|
+ value = -20;
|
|
|
+ } else {
|
|
|
+ value = 0;
|
|
|
+ }
|
|
|
+ return SDL_LinuxSetThreadPriority(thread, value);
|
|
|
#else
|
|
|
struct sched_param sched;
|
|
|
int policy;
|