Fix OpenFEC compile error on Windows platform

This commit is contained in:
dijunkun
2023-11-10 10:00:09 +08:00
parent 6d89a2aa35
commit 2040db4eec
11 changed files with 85 additions and 79 deletions

View File

@@ -1,29 +1,26 @@
cmake_minimum_required(VERSION 2.6)
##project
# #project
project(openfec C)
ENABLE_TESTING()
if (PROFILING STREQUAL "ON")
if(PROFILING STREQUAL "ON")
else(PROFILING STREQUAL "ON")
endif(PROFILING STREQUAL "ON")
if (DEBUG STREQUAL "ON")
# Debug mode
ADD_DEFINITIONS(-DOF_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "Debug mode ON" )
if(DEBUG STREQUAL "ON")
# Debug mode
ADD_DEFINITIONS(-DOF_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "Debug mode ON")
else(DEBUG STREQUAL "ON")
# Release mode
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_C_FLAGS "-O4")
message(STATUS "Debug mode OFF")
endif (DEBUG STREQUAL "ON")
# Release mode
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_C_FLAGS "-O2")
message(STATUS "Debug mode OFF")
endif(DEBUG STREQUAL "ON")
# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
@@ -32,7 +29,6 @@ endif (DEBUG STREQUAL "ON")
# include_directories(${PROJECT_SOURCE_DIR}/src/lib_common)
# set(CMAKE_INSTALL_LIBDIR ${PROJECT_SOURCE_DIR}/src/lib_common)
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
MARK_AS_ADVANCED(
LIBRARY_OUTPUT_PATH
EXECUTABLE_OUTPUT_PATH

View File

@@ -1,16 +1,16 @@
file (GLOB_RECURSE openfec_sources *)
file(GLOB_RECURSE openfec_sources *)
add_library(openfec STATIC ${openfec_sources})
add_library(openfec STATIC ${openfec_sources})
# From: $cmake --help-property SOVERSION
# For shared libraries VERSION and SOVERSION can be used to specify
# the build version and api version respectively.
# For shared libraries VERSION and SOVERSION can be used to specify
# the build version and api version respectively.
#
# Edit it as appropriate to be in line with the src/lib_common/of_openfec_api.c::more_about() version
#
set_target_properties(openfec PROPERTIES
VERSION 1.4.2
SOVERSION 1)
VERSION 1.4.2
SOVERSION 1)
# Feel free to edit as appropriate the "target_link_libraries".
#
@@ -21,9 +21,9 @@ set_target_properties(openfec PROPERTIES
# Please install it on your machine before compiling the OpenFEC
# library if needed.
# Otherwise remove the IL library.
target_link_libraries(openfec m)
#target_link_libraries(openfec m IL)
#target_link_libraries(openfec pthread IL)
#target_link_libraries(openfec pthread)
# target_link_libraries(openfec m IL)
# target_link_libraries(openfec pthread IL)
# target_link_libraries(openfec pthread)

View File

@@ -37,7 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/time.h> /* for timersub */
// #include <sys/time.h> /* for timersub */
#include "../../lib_common/of_openfec_api.h"

View File

@@ -6,27 +6,27 @@
*
* You are free:
*
* to Share to copy, distribute and transmit the work
* to Remix to adapt the work
* to Share <EFBFBD><EFBFBD> to copy, distribute and transmit the work
* to Remix <EFBFBD><EFBFBD> to adapt the work
*
* Under the following conditions:
*
* Attribution You must attribute the work in the manner specified by the author or licensor
* Attribution <EFBFBD><EFBFBD> You must attribute the work in the manner specified by the author or licensor
* (but not in any way that suggests that they endorse you or your use of the work).
* Share Alike If you alter, transform, or build upon this work, you may distribute the
* Share Alike <EFBFBD><EFBFBD> If you alter, transform, or build upon this work, you may distribute the
* resulting work only under the same, similar or a compatible license.
*
* With the understanding that:
*
* Waiver Any of the above conditions can be waived if you get permission from the copyright holder.
* Public Domain Where the work or any of its elements is in the public domain under applicable law,
* Waiver <EFBFBD><EFBFBD> Any of the above conditions can be waived if you get permission from the copyright holder.
* Public Domain <EFBFBD><EFBFBD> Where the work or any of its elements is in the public domain under applicable law,
* that status is in no way affected by the license.
* Other Rights In no way are any of the following rights affected by the license:
* Other Rights <EFBFBD><EFBFBD> In no way are any of the following rights affected by the license:
* Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
* The author's moral rights;
* Rights other persons may have either in the work itself or in how the work is used, such as publicity
* or privacy rights.
* Notice For any reuse or distribution, you must make clear to others the license terms of this work.
* Notice <EFBFBD><EFBFBD> For any reuse or distribution, you must make clear to others the license terms of this work.
*
* The best way to do this is with a link to this web page: http://creativecommons.org/licenses/by-sa/3.0/
*/

View File

@@ -6,27 +6,27 @@
*
* You are free:
*
* to Share to copy, distribute and transmit the work
* to Remix to adapt the work
* to Share <EFBFBD><EFBFBD> to copy, distribute and transmit the work
* to Remix <EFBFBD><EFBFBD> to adapt the work
*
* Under the following conditions:
*
* Attribution You must attribute the work in the manner specified by the author or licensor
* Attribution <EFBFBD><EFBFBD> You must attribute the work in the manner specified by the author or licensor
* (but not in any way that suggests that they endorse you or your use of the work).
* Share Alike If you alter, transform, or build upon this work, you may distribute the
* Share Alike <EFBFBD><EFBFBD> If you alter, transform, or build upon this work, you may distribute the
* resulting work only under the same, similar or a compatible license.
*
* With the understanding that:
*
* Waiver Any of the above conditions can be waived if you get permission from the copyright holder.
* Public Domain Where the work or any of its elements is in the public domain under applicable law,
* Waiver <EFBFBD><EFBFBD> Any of the above conditions can be waived if you get permission from the copyright holder.
* Public Domain <EFBFBD><EFBFBD> Where the work or any of its elements is in the public domain under applicable law,
* that status is in no way affected by the license.
* Other Rights In no way are any of the following rights affected by the license:
* Other Rights <EFBFBD><EFBFBD> In no way are any of the following rights affected by the license:
* Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
* The author's moral rights;
* Rights other persons may have either in the work itself or in how the work is used, such as publicity
* or privacy rights.
* Notice For any reuse or distribution, you must make clear to others the license terms of this work.
* Notice <EFBFBD><EFBFBD> For any reuse or distribution, you must make clear to others the license terms of this work.
*
* The best way to do this is with a link to this web page: http://creativecommons.org/licenses/by-sa/3.0/
*/

View File

@@ -1724,11 +1724,11 @@ void of_mod2dense_print_memory_info (of_mod2dense *m)
#else
printf ("m->row=%p\n", m->row);
printf (" m->row size = %lu\n", m->n_rows*sizeof *m->row);
printf (" m->row size = %zu\n", m->n_rows*sizeof *m->row);
#endif
printf ("m->bits=%p\n", m->bits);
printf (" m->bits size = %lu\n", m->n_words*m->n_rows*sizeof *m->bits);
printf ("sizeof(mod2word)=%lu\n", sizeof (of_mod2word));
printf (" m->bits size = %zu\n", m->n_words*m->n_rows*sizeof *m->bits);
printf ("sizeof(mod2word)=%zu\n", sizeof (of_mod2word));
OF_EXIT_FUNCTION
}

View File

@@ -202,7 +202,7 @@ extern UINT32 of_verbosity;
* @fn of_status_t of_create_codec_instance (of_session_t** ses,
*of_codec_id_t codec_id, of_codec_type_t codec_type, UINT32 verbosity)
* @brief create a codec instance
*<EFBFBD>0<EFBFBD>2@param ses (IN/OUT) address of the pointer to a session. This
*0„2@param ses (IN/OUT) address of the pointer to a session. This
*pointer is updated by this function. In case of success, it points to a
*session structure allocated by the library. In case of failure it points to
*NULL.
@@ -225,7 +225,7 @@ of_status_t of_create_codec_instance(of_session_t** ses, of_codec_id_t codec_id,
*
* @fn of_status_t of_release_codec_instance (of_session_t* ses)
* @brief release all resources used by the codec
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @return Error status.
*/
of_status_t of_release_codec_instance(of_session_t* ses);
@@ -248,7 +248,7 @@ of_status_t of_release_codec_instance(of_session_t* ses);
* @fn of_status_t of_set_fec_parameters (of_session_t* ses,
*of_parameters_t* params)
* @brief set all the FEC codec parameters (e.g. k, n, or symbol
*size) <EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*size) 0„2@param ses (IN) Pointer to the session.
* @param params (IN) pointer to a structure containing the FEC
*parameters associated to a specific FEC codec.
* @return Error status.
@@ -284,7 +284,7 @@ of_status_t of_set_fec_parameters(of_session_t* ses, of_parameters_t* params);
*esi), void* (*decoded_repair_symbol_callback) (void *context,UINT32
*size,UINT32 esi),void* context_4_callback)
* @brief set various callbock functions (see header
*of_open_fec_api.h) <EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*of_open_fec_api.h) 0„2@param ses (IN) Pointer to the session.
*
* @param decoded_source_symbol_callback
* (IN) Pointer to the function, within the
@@ -334,7 +334,7 @@ of_status_t of_set_callback_functions(
* @fn of_status_t of_build_repair_symbol (of_session_t* ses, void*
*encoding_symbols_tab[], UINT32 esi_of_symbol_to_build)
* @brief build a repair symbol (encoder only)
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @param encoding_symbols_tab (IN/OUT) table of source and repair symbols.
* The entry for the repair symbol to build can
*either point to a buffer allocated by the application, or let to NULL meaning
@@ -375,7 +375,7 @@ of_status_t of_build_repair_symbol(of_session_t* ses,
* @fn of_status_t of_decode_with_new_symbol (of_session_t* ses,
*void* const new_symbol_buf, UINT32 new_symbol_esi)
* @brief (try to) decode with a newly received symbol
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @param new_symbol_buf (IN) Pointer to the encoding symbol now
*available (i.e. a new symbol received by the application, or a decoded symbol
*in case of a recursive call).
@@ -407,7 +407,7 @@ of_status_t of_decode_with_new_symbol(of_session_t* ses,
* @fn of_status_t of_set_available_symbols
*(of_session_t* ses, void* const encoding_symbols_tab[]);
* @brief inform the decoder of all the available
*(received) symbols <EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the
*(received) symbols 0„2@param ses (IN) Pointer to the
*session.
* @param encoding_symbols_tab (IN) Pointer to the available encoding symbols
*table. To each available symbol the corresponding entry in the table must
@@ -439,7 +439,7 @@ of_status_t of_set_available_symbol_list (of_session_t* ses,
* @fn of_status_t of_finish_decoding (of_session_t*
*ses)
* @brief finish decoding with available symbols
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @return Error status. Returns OF_STATUS_FAILURE if decoding
*failed, or OF_STATUS_OK if decoding succeeded, or OF_STATUS_*_ERROR in case of
*(fatal) error.
@@ -453,7 +453,7 @@ of_status_t of_finish_decoding(of_session_t* ses);
* @fn bool of_is_decoding_complete (of_session_t*
*ses)
* @brief check if decoding is finished
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @return Boolean. Warning, this is one of the very functions of
*the library that does not return an error status.
*/
@@ -468,7 +468,7 @@ bool of_is_decoding_complete(of_session_t* ses);
* @fn of_status_t of_get_source_symbols_tab (of_session_t*
*ses, void* source_symbols_tab[])
* @brief get the table of available source symbols (after
*decoding) <EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*decoding) 0„2@param ses (IN) Pointer to the session.
* @param source_symbols_tab (IN/OUT) table, that will be filled by the
*library and returned to the application.
* @return Error status.
@@ -490,10 +490,10 @@ of_status_t of_get_source_symbols_tab(of_session_t* ses,
*string is totally managed by the library and must not be released by the
*application.
*
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session or NULL.
*<EFBFBD>0<EFBFBD>2@param version_str (IN/OUT) address of a pointer to a string. This pointer
*0„2@param ses (IN) Pointer to the session or NULL.
*0„2@param version_str (IN/OUT) address of a pointer to a string. This pointer
*is updated by this function to point ot a static string (that must not be
*released by the caller). <EFBFBD>0<EFBFBD>2@param copyrights_str (IN/OUT) address of a pointer
*released by the caller). 0„2@param copyrights_str (IN/OUT) address of a pointer
*to a string. This pointer is updated by this function to point ot a static
*string (that must not be released by the caller).
* @return Error status.
@@ -505,7 +505,7 @@ of_status_t of_more_about(of_session_t* ses, char** version_str,
* This function sets a FEC scheme/FEC codec specific control parameter, in
*addition to the FEC OTI, using a type/value method.
*
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @param type (IN) Type of parameter. This type is FEC codec ID
*specific.
* @param value (IN) Pointer to the value of the parameter. The type of
@@ -520,7 +520,7 @@ of_status_t of_set_control_parameter(of_session_t* ses, UINT32 type,
* This function gets a FEC scheme/FEC codec specific control parameter, in
*addition to the FEC OTI, using a type/value method.
*
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @param type (IN) Type of parameter. This type is FEC codec ID
*specific.
* @param value (IN/OUT) Pointer to the value of the parameter. The type
@@ -577,7 +577,7 @@ of_status_t of_get_control_parameter(of_session_t* ses, UINT32 type,
* of available source and repair symbols. The way this probability is calculated depends
* on many parameters, and above all the code nature.
*
*<EFBFBD>0<EFBFBD>2@param ses (IN) Pointer to the session.
*0„2@param ses (IN) Pointer to the session.
* @return Error status.
*/
bool of_get_decoding_success_proba (of_session_t* ses,

View File

@@ -431,7 +431,7 @@ of_status_t of_2d_parity_get_control_parameter (of_2d_parity_cb_t* ofcb,
switch (type) {
case OF_CTRL_GET_MAX_K:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}
@@ -441,7 +441,7 @@ of_status_t of_2d_parity_get_control_parameter (of_2d_parity_cb_t* ofcb,
case OF_CTRL_GET_MAX_N:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}

View File

@@ -519,7 +519,7 @@ of_status_t of_ldpc_staircase_get_control_parameter (of_ldpc_staircase_cb_t* ofc
switch (type) {
case OF_CTRL_GET_MAX_K:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}
@@ -529,7 +529,7 @@ of_status_t of_ldpc_staircase_get_control_parameter (of_ldpc_staircase_cb_t* ofc
case OF_CTRL_GET_MAX_N:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}

View File

@@ -497,7 +497,7 @@ of_status_t of_rs_get_control_parameter (of_rs_cb_t* ofcb,
switch (type) {
case OF_CTRL_GET_MAX_K:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}
@@ -507,7 +507,7 @@ of_status_t of_rs_get_control_parameter (of_rs_cb_t* ofcb,
case OF_CTRL_GET_MAX_N:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %ld)\n",
OF_PRINT_ERROR(("%s: OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %zu)\n",
__FUNCTION__, length, sizeof(UINT32)))
goto error;
}

View File

@@ -374,11 +374,11 @@ of_status_t of_rs_2_m_finish_decoding (of_rs_2_m_cb_t* ofcb)
{
UINT32 k;
UINT32 n;
char *tmp_buf[ofcb->nb_source_symbols];/* keep available source/repair symbol buffers here... */
int tmp_esi[ofcb->nb_source_symbols]; /* ...and their esi here. In fact we only need k entries
* in these tables, but in order to avoid using malloc (time
* consumming), we use an automatic table of maximum size for
* both tmp_buf[] and tmp_esi[]. */
// char *tmp_buf[ofcb->nb_source_symbols];/* keep available source/repair symbol buffers here... */
// int tmp_esi[ofcb->nb_source_symbols]; /* ...and their esi here. In fact we only need k entries
// * in these tables, but in order to avoid using malloc (time
// * consumming), we use an automatic table of maximum size for
// * both tmp_buf[] and tmp_esi[]. */
INT32 tmp_idx; /* index in tmp_buf[] and tmp_esi[] tabs */
char *large_buf = NULL; /* single large buffer where to copy all source/repair symbols */
UINT32 off; /* offset, in unit of characters, in large_buf */
@@ -394,8 +394,11 @@ of_status_t of_rs_2_m_finish_decoding (of_rs_2_m_cb_t* ofcb)
}
k = ofcb->nb_source_symbols;
n = ofcb->nb_encoding_symbols;
//int *tmp_esi = (int*)malloc(ofcb->field_size*sizeof(int));
//char ** tmp_buf = (char**)malloc(n*sizeof(char*)); // ???? WRT RS(255)
int *tmp_esi = (int*)malloc(ofcb->field_size*sizeof(int));
char ** tmp_buf = (char**)malloc(n*sizeof(char*)); // ???? WRT RS(255)
for(int i=0; i<n; i++){
tmp_buf[i] = NULL;
}
if (ofcb->nb_available_symbols < k)
{
OF_PRINT_ERROR(("ERROR: nb received symbols < nb source symbols\n"))
@@ -528,12 +531,19 @@ of_status_t of_rs_2_m_finish_decoding (of_rs_2_m_cb_t* ofcb)
tmp_idx, tmp_idx))
}
of_free(large_buf);
free(tmp_esi);
for(int i=0;i<n;i++){
free(tmp_buf[i]);
}
OF_EXIT_FUNCTION
return OF_STATUS_OK;
no_mem:
OF_PRINT_ERROR(("ERROR: out of memory.\n"))
free(tmp_esi);
for(int i=0;i<n;i++){
free(tmp_buf[i]);
}
error:
OF_EXIT_FUNCTION
return OF_STATUS_ERROR;
@@ -589,7 +599,7 @@ of_status_t of_rs_2_m_set_control_parameter (of_rs_2_m_cb_t* ofcb,
switch (type) {
case OF_RS_CTRL_SET_FIELD_SIZE:
if (value == NULL || length != sizeof(UINT16)) {
OF_PRINT_ERROR(("OF_CTRL_SET_FIELD_SIZE ERROR: null value or bad length (got %d, expected %ld)\n", length, sizeof(UINT16)))
OF_PRINT_ERROR(("OF_CTRL_SET_FIELD_SIZE ERROR: null value or bad length (got %d, expected %zu)\n", length, sizeof(UINT16)))
goto error;
}
m = *(UINT16*)value;
@@ -624,7 +634,7 @@ of_status_t of_rs_2_m_get_control_parameter (of_rs_2_m_cb_t* ofcb,
switch (type) {
case OF_CTRL_GET_MAX_K:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %ld)\n", length, sizeof(UINT32)))
OF_PRINT_ERROR(("OF_CTRL_GET_MAX_K ERROR: null value or bad length (got %d, expected %zu)\n", length, sizeof(UINT32)))
goto error;
}
if (ofcb->max_nb_source_symbols == 0) {
@@ -637,7 +647,7 @@ of_status_t of_rs_2_m_get_control_parameter (of_rs_2_m_cb_t* ofcb,
case OF_CTRL_GET_MAX_N:
if (value == NULL || length != sizeof(UINT32)) {
OF_PRINT_ERROR(("OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %ld)\n", length, sizeof(UINT32)))
OF_PRINT_ERROR(("OF_CTRL_GET_MAX_N ERROR: null value or bad length (got %d, expected %zu)\n", length, sizeof(UINT32)))
goto error;
}
if (ofcb->max_nb_encoding_symbols == 0) {