Skip to content

Commit

Permalink
Reed-Solomon (zfec): fixed fec_new fail
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
MartinPulec committed Oct 6, 2023
1 parent 1cbb716 commit 2af4ace
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fec.h>
}
#endif

#ifdef __linux__
#include <mcheck.h>
#endif
Expand Down Expand Up @@ -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};
}

Expand Down

0 comments on commit 2af4ace

Please sign in to comment.