mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Removed bitRevert, duplicated of bitfieldReverse
This commit is contained in:
parent
45c4fbeb65
commit
8dd3ec02ea
@ -76,11 +76,6 @@ namespace glm
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType powerOfTwoNearest(genType const & value);
|
||||
|
||||
//! Revert all bits of any integer based type.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
GLM_DEPRECATED GLM_FUNC_DECL genType bitRevert(genType const & value);
|
||||
|
||||
//! Set to 1 a range of bits.
|
||||
/// @see gtx_bit
|
||||
template <typename genIUType>
|
||||
|
@ -153,21 +153,6 @@ namespace glm
|
||||
|
||||
VECTORIZE_VEC(powerOfTwoNearest)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
|
||||
|
||||
genType Out = 0;
|
||||
std::size_t BitSize = sizeof(genType) * 8;
|
||||
for(std::size_t i = 0; i < BitSize; ++i)
|
||||
if(In & (genType(1) << i))
|
||||
Out |= genType(1) << (BitSize - 1 - i);
|
||||
return Out;
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(bitRevert)
|
||||
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithOne
|
||||
(
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include <glm/integer.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
enum result
|
||||
{
|
||||
@ -148,7 +148,25 @@ namespace bitfieldReverse
|
||||
{0xf0000000, 0x0000000f, SUCCESS},
|
||||
};
|
||||
|
||||
int test()
|
||||
typedef type<glm::uint64> typeU64;
|
||||
|
||||
#if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44))
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffffLLU, 0xffffffffffffffffLLU, SUCCESS},
|
||||
{0x0000000000000000LLU, 0x0000000000000000LLU, SUCCESS},
|
||||
{0xf000000000000000LLU, 0x000000000000000fLLU, SUCCESS},
|
||||
};
|
||||
#else
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffff, 0xffffffffffffffff, SUCCESS},
|
||||
{0x0000000000000000, 0x0000000000000000, SUCCESS},
|
||||
{0xf000000000000000, 0x000000000000000f, SUCCESS},
|
||||
};
|
||||
#endif
|
||||
|
||||
int test32()
|
||||
{
|
||||
glm::uint count = sizeof(Data32) / sizeof(typeU32);
|
||||
|
||||
@ -164,13 +182,46 @@ namespace bitfieldReverse
|
||||
else if(Data32[i].Result == FAIL && !Compare)
|
||||
continue;
|
||||
|
||||
std::cout << "glm::bitfieldReverse test fail on test " << i << std::endl;
|
||||
printf("glm::bitfieldReverse test fail on test %d\n", i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}//bitRevert
|
||||
|
||||
int test64()
|
||||
{
|
||||
glm::uint32 count = sizeof(Data64) / sizeof(typeU64);
|
||||
|
||||
for(glm::uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
glm::uint64 Return = glm::bitfieldReverse(
|
||||
Data64[i].Value);
|
||||
|
||||
bool Compare = Data64[i].Return == Return;
|
||||
|
||||
if(Data64[i].Result == SUCCESS && Compare)
|
||||
continue;
|
||||
else if(Data64[i].Result == FAIL && !Compare)
|
||||
continue;
|
||||
|
||||
printf("glm::extractfield test fail on test %d\n", i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test32();
|
||||
Error += test64();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//bitfieldReverse
|
||||
|
||||
namespace findMSB
|
||||
{
|
||||
@ -639,8 +690,6 @@ int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::cout << "sizeof(glm::uint64): " << sizeof(glm::detail::uint64) << std::endl;
|
||||
|
||||
Error += ::umulExtended::test();
|
||||
Error += ::imulExtended::test();
|
||||
Error += ::uaddCarry::test();
|
||||
|
@ -10,79 +10,11 @@
|
||||
#include <glm/gtx/bit.hpp>
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
|
||||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
# include <glm/detail/intrinsic_integer.hpp>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
enum result
|
||||
{
|
||||
SUCCESS,
|
||||
FAIL,
|
||||
ASSERT,
|
||||
STATIC_ASSERT
|
||||
};
|
||||
|
||||
namespace bitRevert
|
||||
{
|
||||
template <typename genType>
|
||||
struct type
|
||||
{
|
||||
genType Value;
|
||||
genType Return;
|
||||
result Result;
|
||||
};
|
||||
|
||||
typedef type<glm::uint64> typeU64;
|
||||
|
||||
#if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44))
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffffLLU, 0xffffffffffffffffLLU, SUCCESS},
|
||||
{0x0000000000000000LLU, 0x0000000000000000LLU, SUCCESS},
|
||||
{0xf000000000000000LLU, 0x000000000000000fLLU, SUCCESS},
|
||||
};
|
||||
#else
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffff, 0xffffffffffffffff, SUCCESS},
|
||||
{0x0000000000000000, 0x0000000000000000, SUCCESS},
|
||||
{0xf000000000000000, 0x000000000000000f, SUCCESS},
|
||||
};
|
||||
#endif
|
||||
|
||||
int test()
|
||||
{
|
||||
glm::uint32 count = sizeof(Data64) / sizeof(typeU64);
|
||||
|
||||
for(glm::uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
glm::uint64 Return = glm::bitRevert(
|
||||
Data64[i].Value);
|
||||
|
||||
bool Compare = Data64[i].Return == Return;
|
||||
|
||||
if(Data64[i].Result == SUCCESS && Compare)
|
||||
continue;
|
||||
else if(Data64[i].Result == FAIL && !Compare)
|
||||
continue;
|
||||
|
||||
printf("glm::extractfield test fail on test %d\n", i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}//bitRevert
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += ::bitRevert::test();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user