X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Fcrc.hpp;h=e70c8340337ba4d7fa67b3229c3553d514989284;hb=7a69f2cff423cc14093ebe166a7872d2e5b53387;hp=d7bff778f8cd1a719583a84c066d25a465c1937f;hpb=9359baacf89c4586751e60e45d711eaa3a2c9335;p=lyx.git diff --git a/boost/boost/crc.hpp b/boost/boost/crc.hpp index d7bff778f8..e70c834033 100644 --- a/boost/boost/crc.hpp +++ b/boost/boost/crc.hpp @@ -1,11 +1,10 @@ // Boost CRC library crc.hpp header file -----------------------------------// -// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or -// implied warranty, and with no claim as to its suitability for any purpose. +// Copyright 2001, 2004 Daryle Walker. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or a copy at .) -// See http://www.boost.org for updates, documentation, and revision history. +// See for the library's home page. #ifndef BOOST_CRC_HPP #define BOOST_CRC_HPP @@ -23,7 +22,7 @@ // on the CRC's bit count. This macro expresses that type in a compact // form, but also allows an alternate type for compilers that don't support // dependent types (in template value-parameters). -#ifndef BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +#if !(defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) || (defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))) #define BOOST_CRC_PARM_TYPE typename ::boost::uint_t::fast #else #define BOOST_CRC_PARM_TYPE unsigned long @@ -38,7 +37,7 @@ // arguments explicitly specified. At least one compiler that needs this // workaround also needs the default value for the dummy argument to be // specified in the definition. -#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#if defined(__GNUC__) || !defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) #define BOOST_CRC_DUMMY_PARM_TYPE #define BOOST_CRC_DUMMY_INIT #define BOOST_ACRC_DUMMY_PARM_TYPE @@ -280,9 +279,9 @@ namespace detail typedef typename base_type::least least; typedef typename base_type::fast fast; -#ifdef __DECCXX - static const least high_bit = 1ul << (Bits - 1u); - static const fast high_bit_fast = 1ul << (Bits - 1u); +#if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243 + static const least high_bit = 1ul << ( Bits - 1u ); + static const fast high_bit_fast = 1ul << ( Bits - 1u ); #else BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << ( Bits - 1u )) ); @@ -345,13 +344,17 @@ namespace detail BOOST_STATIC_CONSTANT( fast, high_bit_fast = base_type::high_bit_fast ); #endif -#ifdef __DECCXX - static const least sig_bits = (~( ~(0ul) << Bits)); +#if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243 + static const least sig_bits = (~( ~( 0ul ) << Bits )) ; #else BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) ); #endif +#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 + // Work around a weird bug that ICEs the compiler in build_c_cast + BOOST_STATIC_CONSTANT( fast, sig_bits_fast = static_cast(sig_bits) ); +#else BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); - +#endif }; // boost::detail::mask_uint_t template < > @@ -457,7 +460,13 @@ namespace detail typedef mask_uint_t masking_type; typedef typename masking_type::fast value_type; +#if defined(__BORLANDC__) && defined(_M_IX86) && (__BORLANDC__ == 0x560) + // for some reason Borland's command line compiler (version 0x560) + // chokes over this unless we do the calculation for it: + typedef value_type table_type[ 0x100 ]; +#else typedef value_type table_type[ byte_combos ]; +#endif static void init_table(); @@ -522,6 +531,30 @@ namespace detail did_init = true; } + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // Align the msb of the remainder to a byte + template < std::size_t Bits, bool RightShift > + class remainder + { + public: + typedef typename uint_t::fast value_type; + + static unsigned char align_msb( value_type rem ) + { return rem >> (Bits - CHAR_BIT); } + }; + + // Specialization for the case that the remainder has less + // bits than a byte: align the remainder msb to the byte msb + template < std::size_t Bits > + class remainder< Bits, false > + { + public: + typedef typename uint_t::fast value_type; + + static unsigned char align_msb( value_type rem ) + { return rem << (CHAR_BIT - Bits); } + }; + #endif // CRC helper routines template < std::size_t Bits, bool DoReflect > @@ -550,7 +583,9 @@ namespace detail // Compare a byte to the remainder's highest byte static unsigned char index( value_type rem, unsigned char x ) - { return x ^ ( rem >> (DoReflect ? 0u : Bits - CHAR_BIT) ); } + { return x ^ ( DoReflect ? rem : + ((Bits>CHAR_BIT)?( rem >> (Bits - CHAR_BIT) ) : + ( rem << (CHAR_BIT - Bits) ))); } // Shift out the remainder's highest byte static value_type shift( value_type rem ) @@ -573,7 +608,7 @@ namespace detail // Compare a byte to the remainder's highest byte static unsigned char index( value_type rem, unsigned char x ) - { return x ^ ( rem >> (Bits - CHAR_BIT) ); } + { return x ^ remainderCHAR_BIT)>::align_msb( rem ); } // Shift out the remainder's highest byte static value_type shift( value_type rem ) @@ -701,7 +736,7 @@ crc_basic::process_bit // a full polynominal division step is done when the highest bit is one bool const do_poly_div = static_cast( rem_ & high_bit_mask ); - // shift out the highest bit + // shift out the highest bit rem_ <<= 1; // carry out the division, if needed @@ -1068,3 +1103,4 @@ augmented_crc #endif // BOOST_CRC_HPP +