diff --git a/CMakeLists.txt b/CMakeLists.txt index f91b164ab..f0c2149d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/lib/crc.cpp b/lib/crc.cpp deleted file mode 100644 index c4dd12b90..000000000 --- a/lib/crc.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -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); -} diff --git a/lib/crc10.cpp b/lib/crc10.cpp new file mode 100644 index 000000000..9ebf42ed7 --- /dev/null +++ b/lib/crc10.cpp @@ -0,0 +1,24 @@ +#include + +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); +} diff --git a/lib/crc12.cpp b/lib/crc12.cpp new file mode 100644 index 000000000..e7d0a80ee --- /dev/null +++ b/lib/crc12.cpp @@ -0,0 +1,24 @@ +#include + +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); +}