Split CRC10 & 12 implementations into separate translation units

Separate translation units avoids  compiler generated CRC tables being
linked when not needed.

Also only compile once and add to wsjt_cxx library for later link
editing.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7631 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-04-05 00:29:46 +00:00
parent c47e0cd228
commit 3a1b40d524
4 changed files with 56 additions and 36 deletions

View File

@ -266,10 +266,14 @@ set (wsjtx_CXXSRCS
)
set (wsjt_CXXSRCS
lib/crc.cpp
lib/crc10.cpp
lib/crc12.cpp
)
# deal with a GCC v6 UB error message
set_source_files_properties (lib/crc.cpp PROPERTIES COMPILE_FLAGS -fpermissive)
set_source_files_properties (
lib/crc10.cpp
lib/crc12.cpp
PROPERTIES COMPILE_FLAGS -fpermissive)
if (WIN32)
set (wsjt_CXXSRCS
@ -1087,13 +1091,13 @@ target_link_libraries (jt65 wsjt_fort wsjt_cxx)
add_executable (ldpcsim40 lib/ldpcsim40.f90 wsjtx.rc)
target_link_libraries (ldpcsim40 wsjt_fort wsjt_cxx)
add_executable (ldpcsim120 lib/fsk4hf/ldpcsim120.f90 lib/crc.cpp wsjtx.rc)
add_executable (ldpcsim120 lib/fsk4hf/ldpcsim120.f90 wsjtx.rc)
target_link_libraries (ldpcsim120 wsjt_fort wsjt_cxx)
add_executable (ldpcsim144 lib/ldpcsim144.f90 wsjtx.rc)
target_link_libraries (ldpcsim144 wsjt_fort wsjt_cxx)
add_executable (ldpcsim168 lib/fsk4hf/ldpcsim168.f90 lib/crc.cpp wsjtx.rc)
add_executable (ldpcsim168 lib/fsk4hf/ldpcsim168.f90 wsjtx.rc)
target_link_libraries (ldpcsim168 wsjt_fort wsjt_cxx)
add_executable (msk144sim lib/msk144sim.f90 wsjtx.rc)

View File

@ -1,32 +0,0 @@
#include <boost/crc.hpp>
#include <boost/cstdint.hpp>
extern "C"
{
short crc12 (unsigned char const * data, int length);
bool crc12_check (unsigned char const * data, int length);
short crc10 (unsigned char const * data, int length);
bool crc10_check (unsigned char const * data, int length);
}
// assumes CRC is last 16 bits of the data and is set to zero
// caller should assign the returned CRC into the message in big endian byte order
short crc12 (unsigned char const * data, int length)
{
return boost::augmented_crc<12, 0xc06> (data, length);
}
bool crc12_check (unsigned char const * data, int length)
{
return !boost::augmented_crc<12, 0xc06> (data, length);
}
short crc10 (unsigned char const * data, int length)
{
return boost::augmented_crc<10, 0x08f> (data, length);
}
bool crc10_check (unsigned char const * data, int length)
{
return !boost::augmented_crc<10, 0x08f> (data, length);
}

24
lib/crc10.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <boost/crc.hpp>
extern "C"
{
short crc10 (unsigned char const * data, int length);
bool crc10_check (unsigned char const * data, int length);
}
namespace
{
unsigned long constexpr truncated_polynomial = 0x08f;
}
// assumes CRC is last 16 bits of the data and is set to zero
// caller should assign the returned CRC into the message in big endian byte order
short crc10 (unsigned char const * data, int length)
{
return boost::augmented_crc<10, truncated_polynomial> (data, length);
}
bool crc10_check (unsigned char const * data, int length)
{
return !boost::augmented_crc<10, truncated_polynomial> (data, length);
}

24
lib/crc12.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <boost/crc.hpp>
extern "C"
{
short crc12 (unsigned char const * data, int length);
bool crc12_check (unsigned char const * data, int length);
}
namespace
{
unsigned long constexpr truncated_polynomial = 0xc06;
}
// assumes CRC is last 16 bits of the data and is set to zero
// caller should assign the returned CRC into the message in big endian byte order
short crc12 (unsigned char const * data, int length)
{
return boost::augmented_crc<12, truncated_polynomial> (data, length);
}
bool crc12_check (unsigned char const * data, int length)
{
return !boost::augmented_crc<12, truncated_polynomial> (data, length);
}