From 2af4ace25935df7fd2e280b88be438395d97e163 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 5 Oct 2023 16:35:29 +0200 Subject: [PATCH] Reed-Solomon (zfec): fixed fec_new fail With current zfec code, fec_init() needs to be called prior to fec_new(), otherwise the later one returns NULL. \+ updated submodule to the current zfec version (requiring fec_init(); but UG will compile with the older zfec version as well) --- configure.ac | 13 +++++++++++++ ext-deps/zfec | 2 +- src/host.cpp | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d0f3dab9e..847534d78 100644 --- a/configure.ac +++ b/configure.ac @@ -2554,6 +2554,19 @@ if test $cross_compile = no && test "$zfec_req" != no; then fi AC_CHECK_FILES([$ZFEC_PREFIX/fec.c $ZFEC_PREFIX/fec.h], [found_zfec=yes]) fi + if test "$found_zfec" = yes; then + AC_MSG_CHECKING([fec_init declaration in $ZFEC_PREFIX/fec.h]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include "$ZFEC_PREFIX/fec.h" + ]], + [[ + #pragma GCC diagnostic error "-Wimplicit-function-declaration" + fec_init();]])], fec_init=yes, fec_init=no) + if test "$fec_init" = yes; then + AC_DEFINE([HAVE_FEC_INIT], [1], [fec_init must be called before fec_new]) + fi + AC_MSG_RESULT($fec_init) + fi fi if test "$found_zfec" = yes; then diff --git a/ext-deps/zfec b/ext-deps/zfec index 4eb5c7c99..049599ac0 160000 --- a/ext-deps/zfec +++ b/ext-deps/zfec @@ -1 +1 @@ -Subproject commit 4eb5c7c99a6a7c5568e3567d3e135ce840e81acb +Subproject commit 049599ac0eee0a7e0d3e8a44dc4404b3c7a78bd7 diff --git a/src/host.cpp b/src/host.cpp index 9ce91fa02..fd1c54ae3 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -99,6 +99,13 @@ #define X11_LIB_NAME "libX11.so.6" #endif +#ifdef HAVE_FEC_INIT +#define restrict __restrict // not a C++ keyword +extern "C" { +#include +} +#endif + #ifdef __linux__ #include #endif @@ -431,6 +438,10 @@ struct init_data *common_preinit(int argc, char *argv[]) incompatible_features = true; } +#ifdef HAVE_FEC_INIT + fec_init(); +#endif + return new init_data{init}; }