0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd: Define all IRCD_USE_ as integers for constexprs.

This commit is contained in:
Jason Volk 2022-06-22 18:59:33 -07:00
parent 856745d178
commit 61d558fc9d
9 changed files with 98 additions and 77 deletions

View file

@ -1403,6 +1403,8 @@ AM_COND_IF(LINUX,
if test "$aio" = "yes"; then
IRCD_DEFINE(USE_AIO, [1], [Linux AIO is supported and will be used])
else
IRCD_DEFINE(USE_AIO, [0], [Linux AIO is not supported and won't be used])
fi
AM_CONDITIONAL([AIO], [[[[ $aio = yes ]]]])
@ -1426,6 +1428,8 @@ AM_CONDITIONAL([IOU], [[[[ $io_uring = yes ]]]])
AM_COND_IF([IOU],
[
IRCD_DEFINE(USE_IOU, [1], [Linux io_uring is supported and may be used])
], [
IRCD_DEFINE(USE_IOU, [0], [Linux io_uring is not available])
])
@ -1659,6 +1663,13 @@ PKG_CHECK_MODULES(icuuc, [icuuc],
AM_CONDITIONAL([ICUUC], [test "x$have_icuuc" = "xyes" ])
AM_CONDITIONAL([ICU], [test "x$have_icu" = "xyes" ])
AM_COND_IF(ICU,
[
IRCD_DEFINE(USE_ICU, [1], [International Components for Unicode is available])
], [
IRCD_DEFINE(USE_ICU, [0], [International Components for Unicode is not available])
])
dnl
dnl
dnl libsodium (NaCl) crypto support
@ -2237,6 +2248,8 @@ dnl IRCD_ENABLE_MAGICK is always defined for use in a constexpr if
AM_COND_IF([IMAGEMAGICK],
[
IRCD_DEFINE(USE_MAGICK, [1], [Magick support is available and enabled])
], [
IRCD_DEFINE(USE_MAGICK, [0], [Magick support is not available])
])
dnl
@ -2343,6 +2356,13 @@ PKG_CHECK_MODULES(LLVM, [LLVM],
AM_CONDITIONAL([LLVM], [test "x$have_libllvm" = "xyes" ])
AM_COND_IF(LLVM,
[
IRCD_DEFINE(USE_LLVM, [1], [libllvm is available and enabled])
], [
IRCD_DEFINE(USE_LLVM, [0], [libllvm is not available])
])
dnl
dnl
dnl LibDRM
@ -2389,6 +2409,8 @@ AM_COND_IF([DRM],
AC_MSG_RESULT([yes])
IRCD_DEFINE(USE_DRM, [1], [DRM support is available and enabled])
DRM_LIBS+="-ldrm"
], [
IRCD_DEFINE(USE_DRM, [0], [DRM support is not available])
])
dnl
@ -2465,7 +2487,11 @@ AM_COND_IF([OPENCL],
[
IRCD_DEFINE(USE_MESA_OPENCL, [1], [MesaOpenCL support is available and enabled])
OPENCL_LIBS+=" -lMesaOpenCL"
], [
IRCD_DEFINE(USE_MESA_OPENCL, [0], [MesaOpenCL support is not available and disabled])
])
], [
IRCD_DEFINE(USE_OPENCL, [0], [OpenCL support is not available])
])
dnl
@ -2521,6 +2547,8 @@ AM_COND_IF([ARMNN],
[
IRCD_DEFINE(USE_ARMNN, [1], [Arm NN support is available and enabled])
ARMNN_LIBS+="-larmnn"
], [
IRCD_DEFINE(USE_ARMNN, [0], [Arm NN support is not available])
])
dnl

View file

@ -38,7 +38,7 @@ ircd::cl::init
init(), ~init() noexcept;
};
#ifndef IRCD_USE_OPENCL
#if IRCD_USE_OPENCL == 0
inline ircd::cl::init::init() {}
inline ircd::cl::init::~init() noexcept {}
#endif

View file

@ -113,15 +113,7 @@ ircd::magick::init
};
// inline stubs when magick disabled/unavailable.
#if !defined(IRCD_USE_MAGICK)
inline
ircd::magick::init::init()
{}
inline
ircd::magick::init::~init()
noexcept
{}
#endif IRCD_USE_MAGICK
#if IRCD_USE_MAGICK == 0
inline ircd::magick::init::init() {}
inline ircd::magick::init::~init() noexcept {}
#endif IRCD_USE_MAGICK == 0

View file

@ -15,16 +15,17 @@
#include <RB_INC_SYS_RESOURCE_H
#include <boost/filesystem.hpp>
#ifdef IRCD_USE_AIO
#if IRCD_USE_AIO > 0
#include "fs_aio.h"
#endif
#ifdef IRCD_USE_IOU
#if IRCD_USE_IOU > 0
#include "fs_iou.h"
#endif
// TODO: prevents use until io_uring support implemented
#undef IRCD_USE_IOU
#define IRCD_USE_IOU 0
namespace ircd::fs
{
@ -230,17 +231,13 @@ ircd::fs::support::rwf_write_life
decltype(ircd::fs::support::aio)
ircd::fs::support::aio
{
#ifdef IRCD_USE_AIO
true
#else
false
#endif
IRCD_USE_AIO
};
void
ircd::fs::support::dump_info()
{
#if defined(IRCD_USE_AIO) || defined(IRCD_USE_IOU)
#if IRCD_USE_AIO || IRCD_USE_IOU
const bool support_async {true};
#else
const bool support_async {false};
@ -779,21 +776,19 @@ ircd::fs::flush(const fd &fd,
{
assert(opts.op == op::SYNC);
#ifdef IRCD_USE_IOU
if(iou::system && opts.aio)
return void(iou::fsync(fd, opts));
#endif
if constexpr(IRCD_USE_IOU)
if(iou::system && opts.aio)
return void(iou::fsync(fd, opts));
#ifdef IRCD_USE_AIO
if(aio::system && opts.aio)
{
if(support::aio_fdsync && !opts.metadata)
return void(aio::fsync(fd, opts));
if constexpr(IRCD_USE_AIO)
if(aio::system && opts.aio)
{
if(support::aio_fdsync && !opts.metadata)
return void(aio::fsync(fd, opts));
else if(support::aio_fsync && opts.metadata)
return void(aio::fsync(fd, opts));
}
#endif
else if(support::aio_fsync && opts.metadata)
return void(aio::fsync(fd, opts));
}
const prof::syscall_usage_warning message
{
@ -1038,15 +1033,13 @@ ircd::fs::_read(const fd &fd,
{
assert(opts.op == op::READ);
#ifdef IRCD_USE_IOU
if(likely(iou::system && opts.aio))
return iou::read(fd, iov, opts);
#endif
if constexpr(IRCD_USE_IOU)
if(likely(iou::system && opts.aio))
return iou::read(fd, iov, opts);
#ifdef IRCD_USE_AIO
if(likely(aio::system && opts.aio))
return aio::read(fd, iov, opts);
#endif
if constexpr(IRCD_USE_AIO)
if(likely(aio::system && opts.aio))
return aio::read(fd, iov, opts);
#ifdef HAVE_PREADV2
return support::preadv2?
@ -1425,15 +1418,13 @@ ircd::fs::_write(const fd &fd,
{
assert(opts.op == op::WRITE);
#ifdef IRCD_USE_IOU
if(likely(iou::system && opts.aio))
return iou::write(fd, iov, opts);
#endif
if constexpr(IRCD_USE_IOU)
if(likely(iou::system && opts.aio))
return iou::write(fd, iov, opts);
#ifdef IRCD_USE_AIO
if(likely(aio::system && opts.aio))
return aio::write(fd, iov, opts);
#endif
if constexpr(IRCD_USE_AIO)
if(likely(aio::system && opts.aio))
return aio::write(fd, iov, opts);
#ifdef HAVE_PWRITEV2
return support::pwritev2?
@ -1671,14 +1662,14 @@ ircd::fs::aio::system;
// init
//
#ifndef IRCD_USE_AIO
#if IRCD_USE_AIO == 0
ircd::fs::aio::init::init()
{
assert(!system);
}
#endif
#ifndef IRCD_USE_AIO
#if IRCD_USE_AIO == 0
[[using gnu: weak, cold]]
ircd::fs::aio::init::~init()
noexcept
@ -1895,12 +1886,9 @@ ircd::fs::aio::stats::stats()
decltype(ircd::fs::iou::support)
ircd::fs::iou::support
{
#ifdef IRCD_USE_IOU
info::kernel_version[0] > 5 ||
(info::kernel_version[0] >= 5 && info::kernel_version[1] >= 1)
#else
false
#endif
IRCD_USE_IOU &&
(info::kernel_version[0] > 5 ||
(info::kernel_version[0] >= 5 && info::kernel_version[1] >= 1))
};
/// Conf item to control whether iou is enabled or bypassed.
@ -1927,7 +1915,7 @@ ircd::fs::iou::system;
// init
//
#ifndef IRCD_USE_IOU
#if IRCD_USE_IOU == 0
[[gnu::weak]]
ircd::fs::iou::init::init()
{
@ -1935,7 +1923,7 @@ ircd::fs::iou::init::init()
}
#endif
#ifndef IRCD_USE_IOU
#if IRCD_USE_IOU == 0
[[gnu::weak]]
ircd::fs::iou::init::~init()
noexcept
@ -2725,7 +2713,7 @@ ircd::fs::reflect(const op &op)
return "????";
}
#ifndef IRCD_USE_AIO
#if IRCD_USE_AIO == 0
[[gnu::weak]]
ircd::fs::op
ircd::fs::aio::translate(const int &val)
@ -2734,7 +2722,7 @@ ircd::fs::aio::translate(const int &val)
}
#endif
#ifndef IRCD_USE_IOU
#if IRCD_USE_IOU == 0
[[gnu::weak]]
ircd::fs::op
ircd::fs::iou::translate(const int &val)

View file

@ -85,10 +85,9 @@ ircd::fs::aio::init::init()
// Don't init AIO if the io_uring is established. If it is, that means it
// was supported by the build, this kernel, and didn't encounter an error
// to construct. In all other cases AIO can serve as a fallback.
#if defined(IRCD_USE_IOU)
if(iou::system)
return;
#endif
if constexpr(IRCD_USE_IOU)
if(iou::system)
return;
assert(!system);
if(!aio::enable)

View file

@ -32,6 +32,8 @@ ircd::gpt::pipe::handle_quit
void
ircd::gpt::pipe::init()
{
if constexpr(!IRCD_USE_OPENCL)
return;
}
[[using gnu: cold, visibility("hidden")]]
@ -39,6 +41,9 @@ void
ircd::gpt::pipe::fini()
noexcept
{
if constexpr(!IRCD_USE_OPENCL)
return;
const auto pending
{
cl::work::list.size()

View file

@ -17284,6 +17284,12 @@ console_cmd__bridge__protocol(opt &out, const string_view &line)
bool
console_cmd__icu(opt &out, const string_view &line)
{
if constexpr(!IRCD_USE_ICU)
throw error
{
"ICU is not available."
};
const unique_mutable_buffer buf
{
size(line) * 4
@ -17553,6 +17559,12 @@ console_cmd__app__signal(opt &out, const string_view &line)
bool
console_cmd__cl__info(opt &out, const string_view &line)
{
if constexpr(!IRCD_USE_OPENCL)
throw error
{
"OpenCL is not available."
};
const params param{line, " ",
{
"platform", "device",

View file

@ -8,13 +8,14 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#if !defined(IRCD_USE_LLVM) \
&& __has_include("<llvm/Config/llvm-config.h>") \
&& __has_include("<llvm/Object/Wasm.h>")
#define IRCD_USE_LLVM
#if IRCD_USE_LLVM == 1 && \
(!__has_include("<llvm/Config/llvm-config.h>") || \
! __has_include("<llvm/Object/Wasm.h>"))
#undef IRCD_USE_LLVM
#define IRCD_USE_LLVM 0
#endif
#if defined(IRCD_USE_LLVM) // -------------------------------------------------
#if IRCD_USE_LLVM > 0 // ------------------------------------------------------
#include <llvm/Config/llvm-config.h>
#include <llvm/Object/Wasm.h>
@ -88,4 +89,4 @@ ircd::llvm::fini()
}
#endif // IRCD_USE_LLVM ------------------------------------------------------
#endif // IRCD_USE_LLVM > 0 --------------------------------------------------

View file

@ -282,11 +282,7 @@ get__thumbnail_local(client &client,
const bool supported
{
// Available in build
#ifdef IRCD_USE_MAGICK
(true)
#else
(false)
#endif
IRCD_USE_MAGICK
// Enabled by configuration
&& enable