treewide: only define feature macros when the feature is available

Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing

  if cond
    cdata.set('X', 1)
  endif

with

  cdata.set('X', cond)
This commit is contained in:
Barnabás Pőcze 2022-02-03 18:52:54 +01:00
parent 140378efd6
commit 15e7a61aa7
15 changed files with 49 additions and 83 deletions

View file

@ -24,7 +24,7 @@
#include "config.h"
#if !HAVE_SIGABBREV_NP
#ifndef HAVE_SIGABBREV_NP
#include <stddef.h>
#include <signal.h>

View file

@ -36,10 +36,10 @@
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#if HAVE_PIDFD_OPEN
#ifdef HAVE_PIDFD_OPEN
#include <sys/syscall.h>
#endif
#if HAVE_LIBCAP
#ifdef HAVE_LIBCAP
#include <sys/capability.h>
#endif
#include <sys/epoll.h>
@ -177,7 +177,7 @@ static void restore_env(struct pwtest_test *t)
static void pwtest_backtrace(pid_t p)
{
#if HAVE_GSTACK
#ifdef HAVE_GSTACK
char pid[11];
pid_t parent, child;
int status;
@ -820,7 +820,7 @@ static int monitor_test_forked(struct pwtest_test *t, pid_t pid, int read_fds[_F
size_t nevents = 0;
int r;
#if HAVE_PIDFD_OPEN
#ifdef HAVE_PIDFD_OPEN
pidfd = syscall(SYS_pidfd_open, pid, 0);
#else
errno = ENOSYS;
@ -1168,7 +1168,7 @@ static void list_tests(struct pwtest_context *ctx)
static bool is_debugger_attached(void)
{
bool rc = false;
#if HAVE_LIBCAP
#ifdef HAVE_LIBCAP
int status;
int pid = fork();

View file

@ -233,7 +233,7 @@ PWTEST(context_support)
SPA_TYPE_INTERFACE_Loop,
SPA_TYPE_INTERFACE_LoopUtils,
SPA_TYPE_INTERFACE_Log,
#if HAVE_DBUS
#ifdef HAVE_DBUS
SPA_TYPE_INTERFACE_DBus,
#endif
SPA_TYPE_INTERFACE_CPU

View file

@ -32,7 +32,7 @@
PWTEST(compat_sigabbrev_np)
{
#if !HAVE_SIGABBREV_NP
#ifndef HAVE_SIGABBREV_NP
pwtest_str_eq(sigabbrev_np(SIGABRT), "ABRT");
pwtest_str_eq(sigabbrev_np(SIGSEGV), "SEGV");
pwtest_str_eq(sigabbrev_np(SIGSTOP), "STOP");