Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update included CRCpp #302

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions extern/CRCpp/inc/CRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
# define crcpp_constexpr const
#endif

#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
/* Disable warning C4127: conditional expression is constant. */
#pragma warning(push)
#pragma warning(disable : 4127)
#endif

#ifdef CRCPP_USE_NAMESPACE
namespace CRCPP
{
Expand Down Expand Up @@ -230,6 +236,7 @@ class CRC
static const Parameters< crcpp_uint8, 8> & CRC_8();
#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
static const Parameters< crcpp_uint8, 8> & CRC_8_EBU();
static const Parameters< crcpp_uint8, 8> & CRC_8_HDLC();
static const Parameters< crcpp_uint8, 8> & CRC_8_MAXIM();
static const Parameters< crcpp_uint8, 8> & CRC_8_WCDMA();
static const Parameters< crcpp_uint8, 8> & CRC_8_LTE();
Expand Down Expand Up @@ -888,15 +895,15 @@ inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const
{
while (size--)
{
#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
// Disable warning about data loss when doing (remainder >> CHAR_BIT) when
// remainder is one byte long. The algorithm is still correct in this case,
// though it's possible that one additional machine instruction will be executed.
# pragma warning (push)
# pragma warning (disable : 4333)
#endif
remainder = static_cast<CRCType>((remainder >> CHAR_BIT) ^ lookupTable[static_cast<unsigned char>(remainder ^ *current++)]);
#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
# pragma warning (pop)
#endif
}
Expand Down Expand Up @@ -1216,6 +1223,24 @@ inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8_EBU()
return parameters;
}

/**
@brief Returns a set of parameters for CRC-8 HDLC (ISO/IEC 13239:2002).
@note The parameters are static and are delayed-constructed to reduce memory footprint.
@note CRC-8 HDLC has the following parameters and check value:
- polynomial = 0x07
- initial value = 0xFF
- final XOR = 0xFF
- reflect input = true
- reflect output = true
- check value = 0x2F
@return CRC-8 HDLC parameters
*/
inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8_HDLC()
{
static const Parameters<crcpp_uint8, 8> parameters = { 0x07, 0xFF, 0xFF, true, true };
return parameters;
}

/**
@brief Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC).
@note The parameters are static and are delayed-constructed to reduce memory footprint.
Expand Down Expand Up @@ -2082,4 +2107,8 @@ inline const CRC::Parameters<crcpp_uint64, 64> & CRC::CRC_64()
}
#endif

#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#pragma warning(pop)
#endif

#endif // CRCPP_CRC_H_
Loading