ioprio: Standardise Linux & macOS HAVE_* macros as defined with either 0 or 1

This commit is contained in:
Luke Dashjr 2025-02-23 02:44:15 +00:00
parent d1238b077e
commit 71c74035dd
3 changed files with 16 additions and 16 deletions

View File

@ -943,7 +943,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[ AC_MSG_RESULT([no])] [ AC_MSG_RESULT([no])]
) )
AC_MSG_CHECKING(for iopolicy functions) AC_MSG_CHECKING(for macOS iopolicy functions)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[ AC_LANG_PROGRAM([[
#include <sys/resource.h> #include <sys/resource.h>
@ -952,16 +952,16 @@ AC_COMPILE_IFELSE([
setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD, x); setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD, x);
]]) ]])
],[ ],[
have_iopolicy=yes AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_IOPOLICY,1,[Define this symbol if you have iopolicy functions]) HAVE_IOPOLICY=1
],[ ],[
have_iopolicy=no AC_MSG_RESULT([no])
HAVE_IOPOLICY=0
]) ])
AC_MSG_RESULT($have_iopolicy) AC_DEFINE_UNQUOTED([HAVE_IOPOLICY], [$HAVE_IOPOLICY], [Define to 1 if macOS iopolicy functions are usable.])
AM_CONDITIONAL([HAVE_IOPOLICY], [test "$have_iopolicy" = "yes"])
if test x$have_iopolicy = xno; then if test x$HAVE_IOPOLICY = x0; then
AC_MSG_CHECKING(for ioprio syscalls) AC_MSG_CHECKING(for Linux ioprio syscalls)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[ AC_LANG_PROGRAM([[
#define _GNU_SOURCE #define _GNU_SOURCE
@ -972,16 +972,16 @@ if test x$have_iopolicy = xno; then
syscall(SYS_ioprio_set, 1, 0, x); syscall(SYS_ioprio_set, 1, 0, x);
]]) ]])
],[ ],[
have_ioprio_syscall=yes AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_IOPRIO_SYSCALL,1,[Define this symbol if you have ioprio syscalls]) HAVE_IOPRIO_SYSCALL=1
],[ ],[
have_ioprio_syscall=no AC_MSG_RESULT([no])
HAVE_IOPRIO_SYSCALL=0
]) ])
AC_MSG_RESULT($have_ioprio_syscall)
else else
have_ioprio_syscall=no HAVE_IOPRIO_SYSCALL=0
fi fi
AM_CONDITIONAL([HAVE_IOPRIO_SYSCALL], [test "$have_ioprio_syscall" = "yes"]) AC_DEFINE_UNQUOTED([HAVE_IOPRIO_SYSCALL], [$HAVE_IOPRIO_SYSCALL], [Define to 1 if Linux ioprio syscalls are usable.])
dnl Check for different ways of gathering OS randomness dnl Check for different ways of gathering OS randomness
AC_MSG_CHECKING([for Linux getrandom function]) AC_MSG_CHECKING([for Linux getrandom function])

View File

@ -8,7 +8,7 @@
#include <util/ioprio.h> #include <util/ioprio.h>
#ifdef HAVE_IOPRIO_SYSCALL #if HAVE_IOPRIO_SYSCALL
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE

View File

@ -11,7 +11,7 @@
#include <logging.h> #include <logging.h>
#if defined(HAVE_IOPRIO_SYSCALL) || defined(HAVE_IOPOLICY) #if HAVE_IOPRIO_SYSCALL || HAVE_IOPOLICY
int ioprio_get(); int ioprio_get();
int ioprio_set(int ioprio); int ioprio_set(int ioprio);
int ioprio_set_idle(); int ioprio_set_idle();