diff --git a/include/etl/experimental/crc16.h b/include/etl/experimental/crc16.h index 73c7246e..68d921b4 100644 --- a/include/etl/experimental/crc16.h +++ b/include/etl/experimental/crc16.h @@ -42,7 +42,7 @@ namespace etl { namespace crc { -#if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 template using crc16_t = etl::crc_type; #else @@ -51,8 +51,6 @@ namespace etl { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* diff --git a/include/etl/experimental/crc16_aug_ccitt.h b/include/etl/experimental/crc16_aug_ccitt.h index 13b49212..8496ad70 100644 --- a/include/etl/experimental/crc16_aug_ccitt.h +++ b/include/etl/experimental/crc16_aug_ccitt.h @@ -32,7 +32,8 @@ SOFTWARE. #define ETL_CRC16_AUG_CCITT_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 1300 @@ -45,12 +46,16 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_aug_ccitt_t = etl::crc_type; +#else template - class crc16_aug_ccitt_t : public etl::private_crc::crc_type + class crc16_aug_ccitt_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); + //************************************************************************* /// Default constructor. @@ -72,6 +77,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_aug_ccitt_t<256U> crc16_aug_ccitt_t256; typedef etl::crc::crc16_aug_ccitt_t<16U> crc16_aug_ccitt_t16; diff --git a/include/etl/experimental/crc16_ccitt.h b/include/etl/experimental/crc16_ccitt.h index e2f12d31..0039f602 100644 --- a/include/etl/experimental/crc16_ccitt.h +++ b/include/etl/experimental/crc16_ccitt.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_CCITT_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_ccitt 16 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 template - class crc16_ccitt_t : public etl::private_crc::crc_type + using crc16_ccitt_t = etl::crc_type; +#else + template + class crc16_ccitt_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_ccitt_t<256U> crc16_ccitt_t256; typedef etl::crc::crc16_ccitt_t<16U> crc16_ccitt_t16; diff --git a/include/etl/experimental/crc16_genibus.h b/include/etl/experimental/crc16_genibus.h index 72a5d1b7..d2707c55 100644 --- a/include/etl/experimental/crc16_genibus.h +++ b/include/etl/experimental/crc16_genibus.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_GENIBUS_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_genibus 16 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_genibus_t = etl::crc_type; +#else template - class crc16_genibus_t : public etl::private_crc::crc_type + class crc16_genibus_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_genibus_t<256U> crc16_genibus_t256; typedef etl::crc::crc16_genibus_t<16U> crc16_genibus_t16; diff --git a/include/etl/experimental/crc16_kermit.h b/include/etl/experimental/crc16_kermit.h index dcb026ca..bcbbd85d 100644 --- a/include/etl/experimental/crc16_kermit.h +++ b/include/etl/experimental/crc16_kermit.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_KERMIT_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_kermit 16 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_kermit_t = etl::crc_type; +#else template - class crc16_kermit_t : public etl::private_crc::crc_type + class crc16_kermit_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_kermit_t<256U> crc16_kermit_t256; typedef etl::crc::crc16_kermit_t<16U> crc16_kermit_t16; diff --git a/include/etl/experimental/crc16_modbus.h b/include/etl/experimental/crc16_modbus.h index cc62a179..94bdf574 100644 --- a/include/etl/experimental/crc16_modbus.h +++ b/include/etl/experimental/crc16_modbus.h @@ -32,26 +32,25 @@ SOFTWARE. #define ETL_CRC16_MODBUS_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif - -///\defgroup crc16_modbus 16 bit CRC calculation +//\defgroup crc16_modbus 16 bit CRC calculation ///\ingroup crc namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_modbus_t = etl::crc_type; +#else template - class crc16_modbus_t : public etl::private_crc::crc_type + class crc16_modbus_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_modbus_t<256U> crc16_modbus_t256; typedef etl::crc::crc16_modbus_t<16U> crc16_modbus_t16; diff --git a/include/etl/experimental/crc16_usb.h b/include/etl/experimental/crc16_usb.h index e1205999..914a1a49 100644 --- a/include/etl/experimental/crc16_usb.h +++ b/include/etl/experimental/crc16_usb.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_USB_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_usb 16 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_usb_t = etl::crc_type; +#else template - class crc16_usb_t : public etl::private_crc::crc_type + class crc16_usb_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_usb_t<256U> crc16_usb_t256; typedef etl::crc::crc16_usb_t<16U> crc16_usb_t16; diff --git a/include/etl/experimental/crc16_x25.h b/include/etl/experimental/crc16_x25.h index d423d342..33e34866 100644 --- a/include/etl/experimental/crc16_x25.h +++ b/include/etl/experimental/crc16_x25.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_X25_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_x25 16 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 + template + using crc16_x25_t = etl::crc_type; +#else template - class crc16_x25_t : public etl::private_crc::crc_type + class crc16_x25_t : public etl::private_crc::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc16_x25_t<256U> crc16_x25_t256; typedef etl::crc::crc16_x25_t<16U> crc16_x25_t16; diff --git a/include/etl/experimental/crc16_xmodem.h b/include/etl/experimental/crc16_xmodem.h index c0d1921b..24ef637f 100644 --- a/include/etl/experimental/crc16_xmodem.h +++ b/include/etl/experimental/crc16_xmodem.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC16_XMODEM_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc16_xmodem 16 bit CRC calculation ///\ingroup crc @@ -47,15 +44,13 @@ namespace etl { #if ETL_CPP11_SUPPORTED template - using crc16_xmodem_t = etl::private_crc::crc_type; + using crc16_xmodem_t = etl::crc_type; #else template - class crc16_xmodem_t : public etl::private_crc::crc_type + class crc16_xmodem_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* diff --git a/include/etl/experimental/crc32.h b/include/etl/experimental/crc32.h index 5fd6b37e..c3bbf70a 100644 --- a/include/etl/experimental/crc32.h +++ b/include/etl/experimental/crc32.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC32_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc32 32 bit CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED template - class crc32_t : public etl::private_crc::crc_type + using crc32_t = etl::crc_type; +#else + template + class crc32_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc32_t<256U> crc32_t256; typedef etl::crc::crc32_t<16U> crc32_t16; diff --git a/include/etl/experimental/crc32_bzip2.h b/include/etl/experimental/crc32_bzip2.h new file mode 100644 index 00000000..5b04a078 --- /dev/null +++ b/include/etl/experimental/crc32_bzip2.h @@ -0,0 +1,82 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC32_BZIP2_EX_INCLUDED +#define ETL_CRC32_BZIP2_EX_INCLUDED + +#include "../platform.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" + +///\defgroup crc32_bzip2 32 bit CRC BZIP2 calculation +///\ingroup crc + +namespace etl +{ + namespace crc + { +#if ETL_CPP11_SUPPORTED + template + using crc32_bzip2_t = etl::crc_type; +#else + template + class crc32_bzip2_t : public etl::crc_type + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_bzip2_t() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_bzip2_t(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +#endif + + typedef etl::crc::crc32_bzip2_t<256U> crc32_bzip2_t256; + typedef etl::crc::crc32_bzip2_t<16U> crc32_bzip2_t16; + typedef etl::crc::crc32_bzip2_t<4U> crc32_bzip2_t4; + typedef crc32_bzip2_t256 crc32_bzip2; + } +} +#endif diff --git a/include/etl/experimental/crc32_c.h b/include/etl/experimental/crc32_c.h new file mode 100644 index 00000000..f9df5c2a --- /dev/null +++ b/include/etl/experimental/crc32_c.h @@ -0,0 +1,82 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC32_C_EX_INCLUDED +#define ETL_CRC32_C_EX_INCLUDED + +#include "../platform.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" + +///\defgroup crc32_c 32 bit CRC_C calculation +///\ingroup crc + +namespace etl +{ + namespace crc + { +#if ETL_CPP11_SUPPORTED + template + using crc32_c_t = etl::crc_type; +#else + template + class crc32_c_t : public etl::crc_type + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_c_t() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_c_t(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +#endif + + typedef etl::crc::crc32_c_t<256U> crc32_c_t256; + typedef etl::crc::crc32_c_t<16U> crc32_c_t16; + typedef etl::crc::crc32_c_t<4U> crc32_c_t4; + typedef crc32_c_t256 crc32_c; + } +} +#endif diff --git a/include/etl/experimental/crc32_mpeg2.h b/include/etl/experimental/crc32_mpeg2.h new file mode 100644 index 00000000..5b04a078 --- /dev/null +++ b/include/etl/experimental/crc32_mpeg2.h @@ -0,0 +1,82 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC32_BZIP2_EX_INCLUDED +#define ETL_CRC32_BZIP2_EX_INCLUDED + +#include "../platform.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" + +///\defgroup crc32_bzip2 32 bit CRC BZIP2 calculation +///\ingroup crc + +namespace etl +{ + namespace crc + { +#if ETL_CPP11_SUPPORTED + template + using crc32_bzip2_t = etl::crc_type; +#else + template + class crc32_bzip2_t : public etl::crc_type + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_bzip2_t() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_bzip2_t(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +#endif + + typedef etl::crc::crc32_bzip2_t<256U> crc32_bzip2_t256; + typedef etl::crc::crc32_bzip2_t<16U> crc32_bzip2_t16; + typedef etl::crc::crc32_bzip2_t<4U> crc32_bzip2_t4; + typedef crc32_bzip2_t256 crc32_bzip2; + } +} +#endif diff --git a/include/etl/experimental/crc32_posix.h b/include/etl/experimental/crc32_posix.h new file mode 100644 index 00000000..bce4492e --- /dev/null +++ b/include/etl/experimental/crc32_posix.h @@ -0,0 +1,82 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC32_POSIX_EX_INCLUDED +#define ETL_CRC32_POSIX_EX_INCLUDED + +#include "../platform.h" +#include "crc_implementation_2.h" +#include "crc_parameters.h" + +///\defgroup crc32_posix 32 bit CRC POSIX calculation +///\ingroup crc + +namespace etl +{ + namespace crc + { +#if ETL_CPP11_SUPPORTED + template + using crc32_posix_t = etl::crc_type; +#else + template + class crc32_posix_t : public etl::crc_type + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_posix_t() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_posix_t(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +#endif + + typedef etl::crc::crc32_posix_t<256U> crc32_posix_t256; + typedef etl::crc::crc32_posix_t<16U> crc32_posix_t16; + typedef etl::crc::crc32_posix_t<4U> crc32_posix_t4; + typedef crc32_posix_t256 crc32_posix; + } +} +#endif diff --git a/include/etl/experimental/crc64_ecma.h b/include/etl/experimental/crc64_ecma.h index adb3980d..3a7aebe3 100644 --- a/include/etl/experimental/crc64_ecma.h +++ b/include/etl/experimental/crc64_ecma.h @@ -32,11 +32,8 @@ SOFTWARE. #define ETL_CRC64_ECMA_EX_INCLUDED #include "../platform.h" -#include "crc_implementation.h" - -#if defined(ETL_COMPILER_KEIL) -#pragma diag_suppress 1300 -#endif +#include "crc_implementation_2.h" +#include "crc_parameters.h" ///\defgroup crc64_ecma 64 bit ECMA CRC calculation ///\ingroup crc @@ -45,13 +42,15 @@ namespace etl { namespace crc { +#if ETL_CPP11_SUPPORTED template - class crc64_ecma_t : public etl::private_crc::crc_type + using crc64_ecma_t = etl::crc_type; +#else + template + class crc64_ecma_t : public etl::crc_type { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* @@ -72,6 +71,7 @@ namespace etl this->add(begin, end); } }; +#endif typedef etl::crc::crc64_ecma_t<256U> crc64_ecma_t256; typedef etl::crc::crc64_ecma_t<16U> crc64_ecma_t16; diff --git a/include/etl/experimental/crc8_ccitt.h b/include/etl/experimental/crc8_ccitt.h index 4734ab52..4f6d8d2d 100644 --- a/include/etl/experimental/crc8_ccitt.h +++ b/include/etl/experimental/crc8_ccitt.h @@ -39,7 +39,7 @@ namespace etl { namespace crc { -#if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 template using crc8_ccitt_t = etl::crc_type; #else @@ -48,8 +48,6 @@ namespace etl { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* diff --git a/include/etl/experimental/crc8_rohc.h b/include/etl/experimental/crc8_rohc.h index b0e08d3a..d01d7e91 100644 --- a/include/etl/experimental/crc8_rohc.h +++ b/include/etl/experimental/crc8_rohc.h @@ -42,7 +42,7 @@ namespace etl { namespace crc { -#if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 template using crc8_rohc_t = etl::crc_type; #else @@ -51,8 +51,6 @@ namespace etl { public: - ETL_STATIC_ASSERT((Table_Size == 4U) || (Table_Size == 16U) || (Table_Size == 256U), "Table size must be 4, 16 or 256"); - //************************************************************************* /// Default constructor. //************************************************************************* diff --git a/include/etl/experimental/crc_implementation_2.h b/include/etl/experimental/crc_implementation_2.h index eaf60807..b6945f0c 100644 --- a/include/etl/experimental/crc_implementation_2.h +++ b/include/etl/experimental/crc_implementation_2.h @@ -191,13 +191,13 @@ namespace etl } //***************************************************************************** - // + // CRC Policies. //***************************************************************************** template struct crc_policy; //********************************* - // Policy for 256 sized table. + // Policy for 256 entry table. template struct crc_policy { @@ -491,7 +491,7 @@ namespace etl }; //********************************* - // Policy for 16 sized table. + // Policy for 16 entry table. template struct crc_policy { @@ -560,7 +560,7 @@ namespace etl }; //********************************* - // Policy for 4 sized table. + // Policy for 4 entry table. template struct crc_policy { diff --git a/include/etl/experimental/crc_parameters.h b/include/etl/experimental/crc_parameters.h index a4551ee2..ffa4e8ca 100644 --- a/include/etl/experimental/crc_parameters.h +++ b/include/etl/experimental/crc_parameters.h @@ -31,13 +31,17 @@ namespace etl typedef crc_parameters crc16_modbus_parameters; typedef crc_parameters crc16_usb_parameters; typedef crc_parameters crc16_x25_parameters; - typedef crc_parameters crc16_xmodem_parameters; + typedef crc_parameters crc16_xmodem_parameters; // 32 bit. - typedef crc_parameters crc32_parameters; + typedef crc_parameters crc32_parameters; + typedef crc_parameters crc32_c_parameters; + typedef crc_parameters crc32_bzip2_parameters; + typedef crc_parameters crc32_mpeg2_parameters; + typedef crc_parameters crc32_posix_parameters; // 64 bit. - typedef crc_parameters crc64_ecma_parameters; + typedef crc_parameters crc64_ecma_parameters; } } diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index 7b8d4dd0..bfd54ce3 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -59,10 +59,10 @@ namespace etl template <> struct integral_limits { - static const int min = 0; - static const int max = 0; - static const int bits = 0; - static const bool is_signed = false; + static ETL_CONSTANT int min = 0; + static ETL_CONSTANT int max = 0; + static ETL_CONSTANT int bits = 0; + static ETL_CONSTANT bool is_signed = false; }; //*************************************************************************** @@ -71,10 +71,10 @@ namespace etl template <> struct integral_limits { - static const signed char min = SCHAR_MIN; - static const signed char max = SCHAR_MAX; - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT signed char min = SCHAR_MIN; + static ETL_CONSTANT signed char max = SCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -83,10 +83,10 @@ namespace etl template <> struct integral_limits { - static const unsigned char min = 0; - static const unsigned char max = UCHAR_MAX; - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned char min = 0; + static ETL_CONSTANT unsigned char max = UCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -95,10 +95,10 @@ namespace etl template <> struct integral_limits { - static const char min = (etl::is_signed::value) ? SCHAR_MIN : 0; - static const char max = (etl::is_signed::value) ? SCHAR_MAX : char(UCHAR_MAX); - static const int bits = CHAR_BIT; - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : char(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -107,10 +107,10 @@ namespace etl template <> struct integral_limits { - static const short min = SHRT_MIN; - static const short max = SHRT_MAX; - static const int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT short min = SHRT_MIN; + static ETL_CONSTANT short max = SHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -119,10 +119,10 @@ namespace etl template <> struct integral_limits { - static const unsigned short min = 0; - static const unsigned short max = USHRT_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned short min = 0; + static ETL_CONSTANT unsigned short max = USHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -131,10 +131,10 @@ namespace etl template <> struct integral_limits { - static const int min = INT_MIN; - static const int max = INT_MAX; - static const int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT int min = INT_MIN; + static ETL_CONSTANT int max = INT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -143,10 +143,10 @@ namespace etl template <> struct integral_limits { - static const unsigned int min = 0; - static const unsigned int max = UINT_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned int min = 0; + static ETL_CONSTANT unsigned int max = UINT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -155,10 +155,10 @@ namespace etl template <> struct integral_limits { - static const long min = LONG_MIN; - static const long max = LONG_MAX; - static const int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT long min = LONG_MIN; + static ETL_CONSTANT long max = LONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -167,10 +167,10 @@ namespace etl template <> struct integral_limits { - static const unsigned long min = 0; - static const unsigned long max = ULONG_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned long min = 0; + static ETL_CONSTANT unsigned long max = ULONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; #ifndef LLONG_MAX @@ -191,10 +191,10 @@ namespace etl template <> struct integral_limits { - static const long long min = LLONG_MIN; - static const long long max = LLONG_MAX; - static const int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT long long min = LLONG_MIN; + static ETL_CONSTANT long long max = LLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** @@ -203,10 +203,10 @@ namespace etl template <> struct integral_limits { - static const unsigned long long min = 0; - static const unsigned long long max = ULLONG_MAX; - static const int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); - static const bool is_signed = etl::is_signed::value; + static ETL_CONSTANT unsigned long long min = 0; + static ETL_CONSTANT unsigned long long max = ULLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; } diff --git a/include/etl/integral_limits.zip b/include/etl/integral_limits.zip new file mode 100644 index 00000000..1b22a9fe Binary files /dev/null and b/include/etl/integral_limits.zip differ diff --git a/test/test_crc_table256.cpp b/test/test_crc_table256.cpp index 86af8870..352805a4 100644 --- a/test/test_crc_table256.cpp +++ b/test/test_crc_table256.cpp @@ -36,16 +36,16 @@ SOFTWARE. #include "etl/experimental/crc8_ccitt.h" #include "etl/experimental/crc8_rohc.h" #include "etl/experimental/crc16.h" -//#include "etl/experimental/crc16_aug_ccitt.h" -//#include "etl/experimental/crc16_ccitt.h" -//#include "etl/experimental/crc16_kermit.h" -//#include "etl/experimental/crc16_modbus.h" -//#include "etl/experimental/crc16_usb.h" -//#include "etl/experimental/crc16_genibus.h" -//#include "etl/experimental/crc16_x25.h" -//#include "etl/experimental/crc16_xmodem.h" -//#include "etl/experimental/crc32.h" -//#include "etl/experimental/crc64_ecma.h" +#include "etl/experimental/crc16_aug_ccitt.h" +#include "etl/experimental/crc16_ccitt.h" +#include "etl/experimental/crc16_kermit.h" +#include "etl/experimental/crc16_modbus.h" +#include "etl/experimental/crc16_usb.h" +#include "etl/experimental/crc16_genibus.h" +#include "etl/experimental/crc16_x25.h" +#include "etl/experimental/crc16_xmodem.h" +#include "etl/experimental/crc32.h" +#include "etl/experimental/crc64_ecma.h" //#include "etl/crc32_c.h" //#include "etl/crc32_bzip2.h" diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 96f76a52..41f6646b 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1273,7 +1273,6 @@ - @@ -1282,6 +1281,10 @@ + + + + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index f27544ae..43169276 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1002,9 +1002,6 @@ ETL\Maths\Experimental - - ETL\Maths\Experimental - ETL\Maths\Experimental @@ -1035,6 +1032,18 @@ ETL\Maths\Experimental + + ETL\Maths\Experimental + + + ETL\Maths\Experimental + + + ETL\Maths\Experimental + + + ETL\Maths\Experimental +