mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd: Define all IRCD_USE_ as integers for constexprs.
This commit is contained in:
parent
856745d178
commit
61d558fc9d
9 changed files with 98 additions and 77 deletions
28
configure.ac
28
configure.ac
|
@ -1403,6 +1403,8 @@ AM_COND_IF(LINUX,
|
||||||
|
|
||||||
if test "$aio" = "yes"; then
|
if test "$aio" = "yes"; then
|
||||||
IRCD_DEFINE(USE_AIO, [1], [Linux AIO is supported and will be used])
|
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
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL([AIO], [[[[ $aio = yes ]]]])
|
AM_CONDITIONAL([AIO], [[[[ $aio = yes ]]]])
|
||||||
|
@ -1426,6 +1428,8 @@ AM_CONDITIONAL([IOU], [[[[ $io_uring = yes ]]]])
|
||||||
AM_COND_IF([IOU],
|
AM_COND_IF([IOU],
|
||||||
[
|
[
|
||||||
IRCD_DEFINE(USE_IOU, [1], [Linux io_uring is supported and may be used])
|
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([ICUUC], [test "x$have_icuuc" = "xyes" ])
|
||||||
AM_CONDITIONAL([ICU], [test "x$have_icu" = "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
|
dnl
|
||||||
dnl libsodium (NaCl) crypto support
|
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],
|
AM_COND_IF([IMAGEMAGICK],
|
||||||
[
|
[
|
||||||
IRCD_DEFINE(USE_MAGICK, [1], [Magick support is available and enabled])
|
IRCD_DEFINE(USE_MAGICK, [1], [Magick support is available and enabled])
|
||||||
|
], [
|
||||||
|
IRCD_DEFINE(USE_MAGICK, [0], [Magick support is not available])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
@ -2343,6 +2356,13 @@ PKG_CHECK_MODULES(LLVM, [LLVM],
|
||||||
|
|
||||||
AM_CONDITIONAL([LLVM], [test "x$have_libllvm" = "xyes" ])
|
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
|
dnl
|
||||||
dnl LibDRM
|
dnl LibDRM
|
||||||
|
@ -2389,6 +2409,8 @@ AM_COND_IF([DRM],
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
IRCD_DEFINE(USE_DRM, [1], [DRM support is available and enabled])
|
IRCD_DEFINE(USE_DRM, [1], [DRM support is available and enabled])
|
||||||
DRM_LIBS+="-ldrm"
|
DRM_LIBS+="-ldrm"
|
||||||
|
], [
|
||||||
|
IRCD_DEFINE(USE_DRM, [0], [DRM support is not available])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
@ -2465,7 +2487,11 @@ AM_COND_IF([OPENCL],
|
||||||
[
|
[
|
||||||
IRCD_DEFINE(USE_MESA_OPENCL, [1], [MesaOpenCL support is available and enabled])
|
IRCD_DEFINE(USE_MESA_OPENCL, [1], [MesaOpenCL support is available and enabled])
|
||||||
OPENCL_LIBS+=" -lMesaOpenCL"
|
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
|
dnl
|
||||||
|
@ -2521,6 +2547,8 @@ AM_COND_IF([ARMNN],
|
||||||
[
|
[
|
||||||
IRCD_DEFINE(USE_ARMNN, [1], [Arm NN support is available and enabled])
|
IRCD_DEFINE(USE_ARMNN, [1], [Arm NN support is available and enabled])
|
||||||
ARMNN_LIBS+="-larmnn"
|
ARMNN_LIBS+="-larmnn"
|
||||||
|
], [
|
||||||
|
IRCD_DEFINE(USE_ARMNN, [0], [Arm NN support is not available])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
|
|
@ -38,7 +38,7 @@ ircd::cl::init
|
||||||
init(), ~init() noexcept;
|
init(), ~init() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef IRCD_USE_OPENCL
|
#if IRCD_USE_OPENCL == 0
|
||||||
inline ircd::cl::init::init() {}
|
inline ircd::cl::init::init() {}
|
||||||
inline ircd::cl::init::~init() noexcept {}
|
inline ircd::cl::init::~init() noexcept {}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,15 +113,7 @@ ircd::magick::init
|
||||||
};
|
};
|
||||||
|
|
||||||
// inline stubs when magick disabled/unavailable.
|
// inline stubs when magick disabled/unavailable.
|
||||||
#if !defined(IRCD_USE_MAGICK)
|
#if IRCD_USE_MAGICK == 0
|
||||||
|
inline ircd::magick::init::init() {}
|
||||||
inline
|
inline ircd::magick::init::~init() noexcept {}
|
||||||
ircd::magick::init::init()
|
#endif IRCD_USE_MAGICK == 0
|
||||||
{}
|
|
||||||
|
|
||||||
inline
|
|
||||||
ircd::magick::init::~init()
|
|
||||||
noexcept
|
|
||||||
{}
|
|
||||||
|
|
||||||
#endif IRCD_USE_MAGICK
|
|
||||||
|
|
52
ircd/fs.cc
52
ircd/fs.cc
|
@ -15,16 +15,17 @@
|
||||||
#include <RB_INC_SYS_RESOURCE_H
|
#include <RB_INC_SYS_RESOURCE_H
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#ifdef IRCD_USE_AIO
|
#if IRCD_USE_AIO > 0
|
||||||
#include "fs_aio.h"
|
#include "fs_aio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IRCD_USE_IOU
|
#if IRCD_USE_IOU > 0
|
||||||
#include "fs_iou.h"
|
#include "fs_iou.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: prevents use until io_uring support implemented
|
// TODO: prevents use until io_uring support implemented
|
||||||
#undef IRCD_USE_IOU
|
#undef IRCD_USE_IOU
|
||||||
|
#define IRCD_USE_IOU 0
|
||||||
|
|
||||||
namespace ircd::fs
|
namespace ircd::fs
|
||||||
{
|
{
|
||||||
|
@ -230,17 +231,13 @@ ircd::fs::support::rwf_write_life
|
||||||
decltype(ircd::fs::support::aio)
|
decltype(ircd::fs::support::aio)
|
||||||
ircd::fs::support::aio
|
ircd::fs::support::aio
|
||||||
{
|
{
|
||||||
#ifdef IRCD_USE_AIO
|
IRCD_USE_AIO
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::fs::support::dump_info()
|
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};
|
const bool support_async {true};
|
||||||
#else
|
#else
|
||||||
const bool support_async {false};
|
const bool support_async {false};
|
||||||
|
@ -779,12 +776,11 @@ ircd::fs::flush(const fd &fd,
|
||||||
{
|
{
|
||||||
assert(opts.op == op::SYNC);
|
assert(opts.op == op::SYNC);
|
||||||
|
|
||||||
#ifdef IRCD_USE_IOU
|
if constexpr(IRCD_USE_IOU)
|
||||||
if(iou::system && opts.aio)
|
if(iou::system && opts.aio)
|
||||||
return void(iou::fsync(fd, opts));
|
return void(iou::fsync(fd, opts));
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IRCD_USE_AIO
|
if constexpr(IRCD_USE_AIO)
|
||||||
if(aio::system && opts.aio)
|
if(aio::system && opts.aio)
|
||||||
{
|
{
|
||||||
if(support::aio_fdsync && !opts.metadata)
|
if(support::aio_fdsync && !opts.metadata)
|
||||||
|
@ -793,7 +789,6 @@ ircd::fs::flush(const fd &fd,
|
||||||
else if(support::aio_fsync && opts.metadata)
|
else if(support::aio_fsync && opts.metadata)
|
||||||
return void(aio::fsync(fd, opts));
|
return void(aio::fsync(fd, opts));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
const prof::syscall_usage_warning message
|
const prof::syscall_usage_warning message
|
||||||
{
|
{
|
||||||
|
@ -1038,15 +1033,13 @@ ircd::fs::_read(const fd &fd,
|
||||||
{
|
{
|
||||||
assert(opts.op == op::READ);
|
assert(opts.op == op::READ);
|
||||||
|
|
||||||
#ifdef IRCD_USE_IOU
|
if constexpr(IRCD_USE_IOU)
|
||||||
if(likely(iou::system && opts.aio))
|
if(likely(iou::system && opts.aio))
|
||||||
return iou::read(fd, iov, opts);
|
return iou::read(fd, iov, opts);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IRCD_USE_AIO
|
if constexpr(IRCD_USE_AIO)
|
||||||
if(likely(aio::system && opts.aio))
|
if(likely(aio::system && opts.aio))
|
||||||
return aio::read(fd, iov, opts);
|
return aio::read(fd, iov, opts);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PREADV2
|
#ifdef HAVE_PREADV2
|
||||||
return support::preadv2?
|
return support::preadv2?
|
||||||
|
@ -1425,15 +1418,13 @@ ircd::fs::_write(const fd &fd,
|
||||||
{
|
{
|
||||||
assert(opts.op == op::WRITE);
|
assert(opts.op == op::WRITE);
|
||||||
|
|
||||||
#ifdef IRCD_USE_IOU
|
if constexpr(IRCD_USE_IOU)
|
||||||
if(likely(iou::system && opts.aio))
|
if(likely(iou::system && opts.aio))
|
||||||
return iou::write(fd, iov, opts);
|
return iou::write(fd, iov, opts);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IRCD_USE_AIO
|
if constexpr(IRCD_USE_AIO)
|
||||||
if(likely(aio::system && opts.aio))
|
if(likely(aio::system && opts.aio))
|
||||||
return aio::write(fd, iov, opts);
|
return aio::write(fd, iov, opts);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PWRITEV2
|
#ifdef HAVE_PWRITEV2
|
||||||
return support::pwritev2?
|
return support::pwritev2?
|
||||||
|
@ -1671,14 +1662,14 @@ ircd::fs::aio::system;
|
||||||
// init
|
// init
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef IRCD_USE_AIO
|
#if IRCD_USE_AIO == 0
|
||||||
ircd::fs::aio::init::init()
|
ircd::fs::aio::init::init()
|
||||||
{
|
{
|
||||||
assert(!system);
|
assert(!system);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IRCD_USE_AIO
|
#if IRCD_USE_AIO == 0
|
||||||
[[using gnu: weak, cold]]
|
[[using gnu: weak, cold]]
|
||||||
ircd::fs::aio::init::~init()
|
ircd::fs::aio::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
|
@ -1895,12 +1886,9 @@ ircd::fs::aio::stats::stats()
|
||||||
decltype(ircd::fs::iou::support)
|
decltype(ircd::fs::iou::support)
|
||||||
ircd::fs::iou::support
|
ircd::fs::iou::support
|
||||||
{
|
{
|
||||||
#ifdef IRCD_USE_IOU
|
IRCD_USE_IOU &&
|
||||||
info::kernel_version[0] > 5 ||
|
(info::kernel_version[0] > 5 ||
|
||||||
(info::kernel_version[0] >= 5 && info::kernel_version[1] >= 1)
|
(info::kernel_version[0] >= 5 && info::kernel_version[1] >= 1))
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Conf item to control whether iou is enabled or bypassed.
|
/// Conf item to control whether iou is enabled or bypassed.
|
||||||
|
@ -1927,7 +1915,7 @@ ircd::fs::iou::system;
|
||||||
// init
|
// init
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef IRCD_USE_IOU
|
#if IRCD_USE_IOU == 0
|
||||||
[[gnu::weak]]
|
[[gnu::weak]]
|
||||||
ircd::fs::iou::init::init()
|
ircd::fs::iou::init::init()
|
||||||
{
|
{
|
||||||
|
@ -1935,7 +1923,7 @@ ircd::fs::iou::init::init()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IRCD_USE_IOU
|
#if IRCD_USE_IOU == 0
|
||||||
[[gnu::weak]]
|
[[gnu::weak]]
|
||||||
ircd::fs::iou::init::~init()
|
ircd::fs::iou::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
|
@ -2725,7 +2713,7 @@ ircd::fs::reflect(const op &op)
|
||||||
return "????";
|
return "????";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef IRCD_USE_AIO
|
#if IRCD_USE_AIO == 0
|
||||||
[[gnu::weak]]
|
[[gnu::weak]]
|
||||||
ircd::fs::op
|
ircd::fs::op
|
||||||
ircd::fs::aio::translate(const int &val)
|
ircd::fs::aio::translate(const int &val)
|
||||||
|
@ -2734,7 +2722,7 @@ ircd::fs::aio::translate(const int &val)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IRCD_USE_IOU
|
#if IRCD_USE_IOU == 0
|
||||||
[[gnu::weak]]
|
[[gnu::weak]]
|
||||||
ircd::fs::op
|
ircd::fs::op
|
||||||
ircd::fs::iou::translate(const int &val)
|
ircd::fs::iou::translate(const int &val)
|
||||||
|
|
|
@ -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
|
// 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
|
// 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.
|
// to construct. In all other cases AIO can serve as a fallback.
|
||||||
#if defined(IRCD_USE_IOU)
|
if constexpr(IRCD_USE_IOU)
|
||||||
if(iou::system)
|
if(iou::system)
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(!system);
|
assert(!system);
|
||||||
if(!aio::enable)
|
if(!aio::enable)
|
||||||
|
|
|
@ -32,6 +32,8 @@ ircd::gpt::pipe::handle_quit
|
||||||
void
|
void
|
||||||
ircd::gpt::pipe::init()
|
ircd::gpt::pipe::init()
|
||||||
{
|
{
|
||||||
|
if constexpr(!IRCD_USE_OPENCL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[using gnu: cold, visibility("hidden")]]
|
[[using gnu: cold, visibility("hidden")]]
|
||||||
|
@ -39,6 +41,9 @@ void
|
||||||
ircd::gpt::pipe::fini()
|
ircd::gpt::pipe::fini()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
if constexpr(!IRCD_USE_OPENCL)
|
||||||
|
return;
|
||||||
|
|
||||||
const auto pending
|
const auto pending
|
||||||
{
|
{
|
||||||
cl::work::list.size()
|
cl::work::list.size()
|
||||||
|
|
|
@ -17284,6 +17284,12 @@ console_cmd__bridge__protocol(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__icu(opt &out, const string_view &line)
|
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
|
const unique_mutable_buffer buf
|
||||||
{
|
{
|
||||||
size(line) * 4
|
size(line) * 4
|
||||||
|
@ -17553,6 +17559,12 @@ console_cmd__app__signal(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__cl__info(opt &out, const string_view &line)
|
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, " ",
|
const params param{line, " ",
|
||||||
{
|
{
|
||||||
"platform", "device",
|
"platform", "device",
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
#if !defined(IRCD_USE_LLVM) \
|
#if IRCD_USE_LLVM == 1 && \
|
||||||
&& __has_include("<llvm/Config/llvm-config.h>") \
|
(!__has_include("<llvm/Config/llvm-config.h>") || \
|
||||||
&& __has_include("<llvm/Object/Wasm.h>")
|
! __has_include("<llvm/Object/Wasm.h>"))
|
||||||
#define IRCD_USE_LLVM
|
#undef IRCD_USE_LLVM
|
||||||
|
#define IRCD_USE_LLVM 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(IRCD_USE_LLVM) // -------------------------------------------------
|
#if IRCD_USE_LLVM > 0 // ------------------------------------------------------
|
||||||
|
|
||||||
#include <llvm/Config/llvm-config.h>
|
#include <llvm/Config/llvm-config.h>
|
||||||
#include <llvm/Object/Wasm.h>
|
#include <llvm/Object/Wasm.h>
|
||||||
|
@ -88,4 +89,4 @@ ircd::llvm::fini()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // IRCD_USE_LLVM ------------------------------------------------------
|
#endif // IRCD_USE_LLVM > 0 --------------------------------------------------
|
||||||
|
|
|
@ -282,11 +282,7 @@ get__thumbnail_local(client &client,
|
||||||
const bool supported
|
const bool supported
|
||||||
{
|
{
|
||||||
// Available in build
|
// Available in build
|
||||||
#ifdef IRCD_USE_MAGICK
|
IRCD_USE_MAGICK
|
||||||
(true)
|
|
||||||
#else
|
|
||||||
(false)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enabled by configuration
|
// Enabled by configuration
|
||||||
&& enable
|
&& enable
|
||||||
|
|
Loading…
Reference in a new issue