Skip to content

Commit

Permalink
Remove MSVC-specific intrinsic use in detail/rot.hpp; it's unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 2, 2024
1 parent 31677e4 commit 781752b
Showing 1 changed file with 4 additions and 60 deletions.
64 changes: 4 additions & 60 deletions include/boost/hash2/detail/rot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/hash2/detail/is_constant_evaluated.hpp>
#include <boost/config.hpp>
#include <cstdint>
#include <cstdlib>

namespace boost
{
Expand All @@ -17,84 +15,30 @@ namespace hash2
namespace detail
{

#if defined( _MSC_VER )

BOOST_FORCEINLINE BOOST_HASH2_CXX14_CONSTEXPR std::uint32_t rotl( std::uint32_t v, int k )
{
if( !detail::is_constant_evaluated() )
{
return _rotl( v, k );
}
else
{
return ( v << k ) | ( v >> ( 32 - k ) );
}
}

BOOST_FORCEINLINE BOOST_HASH2_CXX14_CONSTEXPR std::uint64_t rotl( std::uint64_t v, int k )
{
if( !detail::is_constant_evaluated() )
{
return _rotl64( v, k );
}
else
{
return ( v << k ) | ( v >> ( 64 - k ) );
}
}

BOOST_FORCEINLINE BOOST_HASH2_CXX14_CONSTEXPR std::uint32_t rotr( std::uint32_t v, int k )
{
if( !detail::is_constant_evaluated() )
{
return _rotr( v, k );
}
else
{
return ( v >> k ) | ( v << ( 32 - k ) );
}
}

BOOST_FORCEINLINE BOOST_HASH2_CXX14_CONSTEXPR std::uint64_t rotr( std::uint64_t v, int k )
{
if( !detail::is_constant_evaluated() )
{
return _rotr64( v, k );
}
else
{
return ( v >> k ) | ( v << ( 64 - k ) );
}
}

#else

// k must not be 0
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR std::uint32_t rotl( std::uint32_t v, int k )
BOOST_FORCEINLINE constexpr std::uint32_t rotl( std::uint32_t v, int k )
{
return ( v << k ) | ( v >> ( 32 - k ) );
}

// k must not be 0
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR std::uint64_t rotl( std::uint64_t v, int k )
BOOST_FORCEINLINE constexpr std::uint64_t rotl( std::uint64_t v, int k )
{
return ( v << k ) | ( v >> ( 64 - k ) );
}

// k must not be 0
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR std::uint32_t rotr( std::uint32_t v, int k )
BOOST_FORCEINLINE constexpr std::uint32_t rotr( std::uint32_t v, int k )
{
return ( v >> k ) | ( v << ( 32 - k ) );
}

// k must not be 0
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR std::uint64_t rotr( std::uint64_t v, int k )
BOOST_FORCEINLINE constexpr std::uint64_t rotr( std::uint64_t v, int k )
{
return ( v >> k ) | ( v << ( 64 - k ) );
}

#endif

} // namespace detail
} // namespace hash2
} // namespace boost
Expand Down

0 comments on commit 781752b

Please sign in to comment.