Misc fixes, mostly for FreeBSD (#1536)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
mkdocs / deploy (push) Waiting to run

This commit is contained in:
trapexit 2025-09-29 00:17:51 -04:00 • committed by GitHub
parent 7a9c3b7eb2
commit 46f85c0f6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 146 additions and 140 deletions

View file

@ -1,9 +1,10 @@
#include "ioprio.hpp"
#include <errno.h>
#ifdef __linux__
# include <sys/syscall.h>
# include <unistd.h>
# include <errno.h>
#else
#warning "ioprio not supported on this platform"
#endif
@ -17,33 +18,33 @@ thread_local int ioprio::SetFrom::thread_prio = -1;
bool _enabled = false;
int
ioprio::get(const int which_,
const int who_)
ioprio::get(const int who_)
{
#ifdef SYS_ioprio_get
int rv;
const int which = IOPRIO_WHO_PROCESS;
rv = syscall(SYS_ioprio_get,which_,who_);
rv = syscall(SYS_ioprio_get,which,who_);
return ((rv == -1) ? -errno : rv);
#else
return -ENOSUP;
return -EOPNOTSUPP;
#endif
}
int
ioprio::set(const int which_,
const int who_,
ioprio::set(const int who_,
const int ioprio_)
{
#ifdef SYS_ioprio_set
int rv;
const int which = IOPRIO_WHO_PROCESS;
rv = syscall(SYS_ioprio_set,which_,who_,ioprio_);
rv = syscall(SYS_ioprio_set,which,who_,ioprio_);
return ((rv == -1) ? -errno : rv);
#else
return -ENOSUP;
return -EOPNOTSUPP;
#endif
}
@ -66,12 +67,12 @@ ioprio::SetFrom::SetFrom(const pid_t pid_)
if(!_enabled)
return;
client_prio = ioprio::get(IOPRIO_WHO_PROCESS,pid_);
client_prio = ioprio::get(pid_);
if(client_prio < 0)
return;
if(client_prio == thread_prio)
return;
thread_prio = client_prio;
ioprio::set(IOPRIO_WHO_PROCESS,0,client_prio);
ioprio::set(0,client_prio);
}