forked from premiere/premiere-libtorrent
leverage boost's endian detection in sha1-implementation
This commit is contained in:
parent
838f8c3892
commit
0ed91e248f
|
@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
#include <boost/detail/endian.hpp>
|
||||||
#include <stdio.h> // for snprintf
|
#include <stdio.h> // for snprintf
|
||||||
#include <limits.h> // for IOV_MAX
|
#include <limits.h> // for IOV_MAX
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ namespace
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined __BIG_ENDIAN__ && !defined __LITTLE_ENDIAN__
|
#if !defined BOOST_BIG_ENDIAN && !defined BOOST_LITTLE_ENDIAN
|
||||||
bool is_big_endian()
|
bool is_big_endian()
|
||||||
{
|
{
|
||||||
u32 test = 1;
|
u32 test = 1;
|
||||||
|
@ -205,9 +205,9 @@ void SHA1_update(sha_ctx* context, u8 const* data, u32 len)
|
||||||
{
|
{
|
||||||
// GCC standard defines for endianness
|
// GCC standard defines for endianness
|
||||||
// test with: cpp -dM /dev/null
|
// test with: cpp -dM /dev/null
|
||||||
#if defined __BIG_ENDIAN__
|
#if defined BOOST_BIG_ENDIAN
|
||||||
internal_update<big_endian_blk0>(context, data, len);
|
internal_update<big_endian_blk0>(context, data, len);
|
||||||
#elif defined __LITTLE_ENDIAN__
|
#elif defined BOOST_LITTLE_ENDIAN
|
||||||
internal_update<little_endian_blk0>(context, data, len);
|
internal_update<little_endian_blk0>(context, data, len);
|
||||||
#else
|
#else
|
||||||
// select different functions depending on endianess
|
// select different functions depending on endianess
|
||||||
|
@ -309,7 +309,7 @@ By Arvid Norberg <arvidn@sourceforge.net>
|
||||||
previous SHA1HANDSOFF implicit
|
previous SHA1HANDSOFF implicit
|
||||||
2- uses C99 types with size guarantees
|
2- uses C99 types with size guarantees
|
||||||
from boost
|
from boost
|
||||||
3- if none of __BIG_ENDIAN__ or LITTLE_ENDIAN
|
3- if none of BOOST_BIG_ENDIAN or BOOST_LITTLE_ENDIAN
|
||||||
are defined, endianess is determined
|
are defined, endianess is determined
|
||||||
at runtime. templates are used to duplicate
|
at runtime. templates are used to duplicate
|
||||||
the transform function for each endianess
|
the transform function for each endianess
|
||||||
|
|
Loading…
Reference in New Issue