mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
core: use pthread_setschedparam on OpenBSD
OpenBSD don't have support for sched_getparam(), sched_setparam(), or
sched_setscheduler() functions (yet). In this case, we need use
pthead-equivalents for real-time sched for picom. Theses changes add
this support.
(cherry picked from commit 023103c620
)
Authored-by: Jose Maldonado aka Yukiteru <josemald89@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
baf78e733f
commit
33c20c57c1
2 changed files with 19 additions and 0 deletions
|
@ -86,6 +86,10 @@ elif (host_system == 'freebsd' or host_system == 'netbsd' or
|
|||
cflags += ['-DHAS_KQUEUE']
|
||||
endif
|
||||
|
||||
if host_system == 'openbsd'
|
||||
deps += [dependency('threads', required: true)]
|
||||
endif
|
||||
|
||||
subdir('backend')
|
||||
|
||||
picom = executable('picom', srcs, c_args: cflags,
|
||||
|
|
15
src/picom.c
15
src/picom.c
|
@ -33,6 +33,9 @@
|
|||
#include <xcb/render.h>
|
||||
#include <xcb/sync.h>
|
||||
#include <xcb/xfixes.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <ev.h>
|
||||
#include <test.h>
|
||||
|
@ -2588,14 +2591,26 @@ void set_rr_scheduling(void) {
|
|||
int ret;
|
||||
struct sched_param param;
|
||||
|
||||
#ifndef __OpenBSD__
|
||||
ret = sched_getparam(0, ¶m);
|
||||
#else
|
||||
int old_policy;
|
||||
ret = pthread_getschedparam(pthread_self(), &old_policy, ¶m);
|
||||
#endif
|
||||
|
||||
if (ret != 0) {
|
||||
log_debug("Failed to get old scheduling priority");
|
||||
return;
|
||||
}
|
||||
|
||||
param.sched_priority = priority;
|
||||
|
||||
#ifndef __OpenBSD__
|
||||
ret = sched_setscheduler(0, SCHED_RR, ¶m);
|
||||
#else
|
||||
ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
|
||||
#endif
|
||||
|
||||
if (ret != 0) {
|
||||
log_info("Failed to set real-time scheduling priority to %d.", priority);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue