linux: Move SDL_LinuxSetThreadPriority() elsewhere to fix build.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 05 Dec 2018 16:51:22 -0500
changeset 12456f8041c025fd3
parent 12455 bc838d7a29dc
child 12457 7cf0d21b7d99
linux: Move SDL_LinuxSetThreadPriority() elsewhere to fix build.

Fixes Bugzilla #4393.
configure
configure.in
src/core/linux/SDL_dbus.c
src/thread/pthread/SDL_systhread.c
     1.1 --- a/configure	Wed Dec 05 16:49:38 2018 -0500
     1.2 +++ b/configure	Wed Dec 05 16:51:22 2018 -0500
     1.3 @@ -24182,6 +24182,7 @@
     1.4              SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
     1.5          fi
     1.6          # Set up other core UNIX files
     1.7 +        SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
     1.8          SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
     1.9          ;;
    1.10      *-*-cygwin* | *-*-mingw32*)
     2.1 --- a/configure.in	Wed Dec 05 16:49:38 2018 -0500
     2.2 +++ b/configure.in	Wed Dec 05 16:51:22 2018 -0500
     2.3 @@ -3553,6 +3553,7 @@
     2.4              SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
     2.5          fi       
     2.6          # Set up other core UNIX files
     2.7 +        SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
     2.8          SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
     2.9          ;;
    2.10      *-*-cygwin* | *-*-mingw32*)
     3.1 --- a/src/core/linux/SDL_dbus.c	Wed Dec 05 16:49:38 2018 -0500
     3.2 +++ b/src/core/linux/SDL_dbus.c	Wed Dec 05 16:51:22 2018 -0500
     3.3 @@ -21,13 +21,6 @@
     3.4  #include "../../SDL_internal.h"
     3.5  #include "SDL_dbus.h"
     3.6  
     3.7 -#if !SDL_THREADS_DISABLED
     3.8 -#include <sys/time.h>
     3.9 -#include <sys/resource.h>
    3.10 -#include <pthread.h>
    3.11 -#include "SDL_system.h"
    3.12 -#endif
    3.13 -
    3.14  #if SDL_USE_LIBDBUS
    3.15  /* we never link directly to libdbus. */
    3.16  #include "SDL_loadso.h"
    3.17 @@ -349,82 +342,6 @@
    3.18  
    3.19      return SDL_TRUE;
    3.20  }
    3.21 -
    3.22 -#if !SDL_THREADS_DISABLED
    3.23 -/* d-bus queries to org.freedesktop.RealtimeKit1. */
    3.24 -#define RTKIT_DBUS_NODE "org.freedesktop.RealtimeKit1"
    3.25 -#define RTKIT_DBUS_PATH "/org/freedesktop/RealtimeKit1"
    3.26 -#define RTKIT_DBUS_INTERFACE "org.freedesktop.RealtimeKit1"
    3.27 -
    3.28 -static pthread_once_t rtkit_initialize_once = PTHREAD_ONCE_INIT;
    3.29 -static Sint32 rtkit_min_nice_level = -20;
    3.30 -
    3.31 -static void
    3.32 -rtkit_initialize()
    3.33 -{
    3.34 -    SDL_DBusContext *dbus = SDL_DBus_GetContext();
    3.35 -
    3.36 -    /* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
    3.37 -    if (!dbus || !SDL_DBus_QueryPropertyOnConnection(dbus->system_conn, RTKIT_DBUS_NODE, RTKIT_DBUS_PATH, RTKIT_DBUS_INTERFACE, "MinNiceLevel",
    3.38 -                                            DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
    3.39 -        rtkit_min_nice_level = -20;
    3.40 -    }
    3.41 -}
    3.42 -
    3.43 -static SDL_bool
    3.44 -rtkit_setpriority(pid_t thread, int nice_level)
    3.45 -{
    3.46 -    Uint64 ui64 = (Uint64)thread;
    3.47 -    Sint32 si32 = (Sint32)nice_level;
    3.48 -    SDL_DBusContext *dbus = SDL_DBus_GetContext();
    3.49 -
    3.50 -    pthread_once(&rtkit_initialize_once, rtkit_initialize);
    3.51 -
    3.52 -    if (si32 < rtkit_min_nice_level)
    3.53 -        si32 = rtkit_min_nice_level;
    3.54 -
    3.55 -    if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn,
    3.56 -            RTKIT_DBUS_NODE, RTKIT_DBUS_PATH, RTKIT_DBUS_INTERFACE, "MakeThreadHighPriority",
    3.57 -            DBUS_TYPE_UINT64, &ui64, DBUS_TYPE_INT32, &si32, DBUS_TYPE_INVALID,
    3.58 -            DBUS_TYPE_INVALID)) {
    3.59 -        return SDL_FALSE;
    3.60 -    }
    3.61 -    return SDL_TRUE;
    3.62 -}
    3.63  #endif
    3.64  
    3.65 -#endif
    3.66 -
    3.67 -/* this is a public symbol, so it has to exist even if threads are disabled. */
    3.68 -int
    3.69 -SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
    3.70 -{
    3.71 -#if SDL_THREADS_DISABLED
    3.72 -    return SDL_Unsupported();
    3.73 -#else
    3.74 -    if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
    3.75 -        return 0;
    3.76 -    }
    3.77 -
    3.78 -#if SDL_USE_LIBDBUS
    3.79 -    /* Note that this fails if you're trying to set high priority
    3.80 -       and you don't have root permission. BUT DON'T RUN AS ROOT!
    3.81 -
    3.82 -       You can grant the ability to increase thread priority by
    3.83 -       running the following command on your application binary:
    3.84 -          sudo setcap 'cap_sys_nice=eip' <application>
    3.85 -
    3.86 -       Let's try setting priority with RealtimeKit...
    3.87 -
    3.88 -       README and sample code at: http://git.0pointer.net/rtkit.git
    3.89 -    */
    3.90 -    if (rtkit_setpriority((pid_t)threadID, priority)) {
    3.91 -        return 0;
    3.92 -    }
    3.93 -#endif
    3.94 -
    3.95 -    return SDL_SetError("setpriority() failed");
    3.96 -#endif
    3.97 -}
    3.98 -
    3.99  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/thread/pthread/SDL_systhread.c	Wed Dec 05 16:49:38 2018 -0500
     4.2 +++ b/src/thread/pthread/SDL_systhread.c	Wed Dec 05 16:51:22 2018 -0500
     4.3 @@ -20,6 +20,7 @@
     4.4  */
     4.5  
     4.6  #include "../../SDL_internal.h"
     4.7 +#include "SDL_system.h"
     4.8  
     4.9  #include <pthread.h>
    4.10