Skip to content

Commit

Permalink
Fix sign-compare warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomix1024 authored and christophe-lunarg committed Mar 12, 2024
1 parent c48d16b commit 08a1190
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion glm/gtc/bitfield.inl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ namespace detail
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'mask' accepts only integer values");

return Bits >= sizeof(genIUType) * 8 ? ~static_cast<genIUType>(0) : (static_cast<genIUType>(1) << Bits) - static_cast<genIUType>(1);
return Bits >= static_cast<genIUType>(sizeof(genIUType) * 8) ? ~static_cast<genIUType>(0) : (static_cast<genIUType>(1) << Bits) - static_cast<genIUType>(1);
}

#if GLM_COMPILER & GLM_COMPILER_CLANG
Expand Down
22 changes: 11 additions & 11 deletions test/core/core_func_integer_bit_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,63 +208,63 @@ int main()
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop0(test[i]) != test[i+1]) error(test[i], pop0(test[i]));}
if (pop0(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop0(test[i]));}
TimestampEnd = std::clock();

std::printf("pop0: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop1(test[i]) != test[i+1]) error(test[i], pop1(test[i]));}
if (pop1(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop1(test[i]));}
TimestampEnd = std::clock();

std::printf("pop1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop2(test[i]) != test[i+1]) error(test[i], pop2(test[i]));}
if (pop2(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop2(test[i]));}
TimestampEnd = std::clock();

std::printf("pop2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop3(test[i]) != test[i+1]) error(test[i], pop3(test[i]));}
if (pop3(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop3(test[i]));}
TimestampEnd = std::clock();

std::printf("pop3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop4(test[i]) != test[i+1]) error(test[i], pop4(test[i]));}
if (pop4(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop4(test[i]));}
TimestampEnd = std::clock();

std::printf("pop4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop5(test[i]) != test[i+1]) error(test[i], pop5(test[i]));}
if (pop5(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop5(test[i]));}
TimestampEnd = std::clock();

std::printf("pop5: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop5a(test[i]) != test[i+1]) error(test[i], pop5a(test[i]));}
if (pop5a(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop5a(test[i]));}
TimestampEnd = std::clock();

std::printf("pop5a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop6(test[i]) != test[i+1]) error(test[i], pop6(test[i]));}
if (pop6(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop6(test[i]));}
TimestampEnd = std::clock();

std::printf("pop6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand All @@ -273,7 +273,7 @@ int main()
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffffff00) == 0)
if (pop7(test[i]) != test[i+1]) error(test[i], pop7(test[i]));}
if (pop7(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop7(test[i]));}
TimestampEnd = std::clock();

std::printf("pop7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand All @@ -282,7 +282,7 @@ int main()
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffffff80) == 0)
if (pop8(test[i]) != test[i+1]) error(test[i], pop8(test[i]));}
if (pop8(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop8(test[i]));}
TimestampEnd = std::clock();

std::printf("pop8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand All @@ -291,7 +291,7 @@ int main()
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffff8000) == 0)
if (pop9(test[i]) != test[i+1]) error(test[i], pop9(test[i]));}
if (pop9(test[i]) != static_cast<int>(test[i+1])) error(test[i], pop9(test[i]));}
TimestampEnd = std::clock();

std::printf("pop9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand Down
28 changes: 14 additions & 14 deletions test/core/core_func_integer_find_lsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,39 +312,39 @@ int main()
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz1(test[i]) != test[i+1]) error(test[i], ntz1(test[i]));}
if (ntz1(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz1(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz2(test[i]) != test[i+1]) error(test[i], ntz2(test[i]));}
if (ntz2(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz2(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz3(test[i]) != test[i+1]) error(test[i], ntz3(test[i]));}
if (ntz3(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz3(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz4(test[i]) != test[i+1]) error(test[i], ntz4(test[i]));}
if (ntz4(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz4(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz4a(test[i]) != test[i+1]) error(test[i], ntz4a(test[i]));}
if (ntz4a(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz4a(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz4a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand All @@ -366,71 +366,71 @@ int main()
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz6(test[i]) != test[i+1]) error(test[i], ntz6(test[i]));}
if (ntz6(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz6(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz6a(test[i]) != test[i+1]) error(test[i], ntz6a(test[i]));}
if (ntz6a(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz6a(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz6a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz7(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
if (ntz7(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz7(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
/*
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz7_christophe(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
if (ntz7_christophe(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz7(test[i]));}
TimestampEnd = std::clock();
std::printf("ntz7_christophe: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
*/
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz8(test[i]) != test[i+1]) error(test[i], ntz8(test[i]));}
if (ntz8(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz8(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz8a(test[i]) != test[i+1]) error(test[i], ntz8a(test[i]));}
if (ntz8a(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz8a(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz8a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz9(test[i]) != test[i+1]) error(test[i], ntz9(test[i]));}
if (ntz9(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz9(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz10(test[i]) != test[i+1]) error(test[i], ntz10(test[i]));}
if (ntz10(test[i]) != static_cast<int>(test[i+1])) error(test[i], ntz10(test[i]));}
TimestampEnd = std::clock();

std::printf("ntz10: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz11(test[i]) != test[i + 1]) error(test[i], ntz11(test[i]));
if (ntz11(test[i]) != static_cast<int>(test[i + 1])) error(test[i], ntz11(test[i]));
}
TimestampEnd = std::clock();

Expand Down
28 changes: 14 additions & 14 deletions test/core/core_func_integer_find_msb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,111 +338,111 @@ int main()
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz1(test[i]) != test[i+1]) error(test[i], nlz1(test[i]));}
if (nlz1(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz1(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz1a(test[i]) != test[i+1]) error(test[i], nlz1a(test[i]));}
if (nlz1a(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz1a(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz1a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz2(test[i]) != test[i+1]) error(test[i], nlz2(test[i]));}
if (nlz2(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz2(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz2a(test[i]) != test[i+1]) error(test[i], nlz2a(test[i]));}
if (nlz2a(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz2a(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz2a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz3(test[i]) != test[i+1]) error(test[i], nlz3(test[i]));}
if (nlz3(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz3(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz4(test[i]) != test[i+1]) error(test[i], nlz4(test[i]));}
if (nlz4(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz4(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz5(test[i]) != test[i+1]) error(test[i], nlz5(test[i]));}
if (nlz5(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz5(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz5: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz6(test[i]) != test[i+1]) error(test[i], nlz6(test[i]));}
if (nlz6(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz6(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz7(test[i]) != test[i+1]) error(test[i], nlz7(test[i]));}
if (nlz7(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz7(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz8(test[i]) != test[i+1]) error(test[i], nlz8(test[i]));}
if (nlz8(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz8(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz9(test[i]) != test[i+1]) error(test[i], nlz9(test[i]));}
if (nlz9(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz9(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10(test[i]) != test[i+1]) error(test[i], nlz10(test[i]));}
if (nlz10(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz10(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz10: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10a(test[i]) != test[i+1]) error(test[i], nlz10a(test[i]));}
if (nlz10a(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz10a(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz10a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10b(test[i]) != test[i+1]) error(test[i], nlz10b(test[i]));}
if (nlz10b(test[i]) != static_cast<int>(test[i + 1])) error(test[i], nlz10b(test[i]));}
TimestampEnd = std::clock();

std::printf("nlz10b: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
Expand Down
2 changes: 1 addition & 1 deletion test/gtc/gtc_bitfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace mask

static inline int mask_mix(int Bits)
{
return Bits >= sizeof(int) * 8 ? 0xffffffff : (static_cast<int>(1) << Bits) - static_cast<int>(1);
return Bits >= static_cast<int>(sizeof(int) * 8) ? 0xffffffff : (static_cast<int>(1) << Bits) - static_cast<int>(1);
}

#if GLM_COMPILER & GLM_COMPILER_CLANG
Expand Down

0 comments on commit 08a1190

Please sign in to comment.