Skip to content

Commit

Permalink
Cast clz() calls to unsigned int where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Aug 10, 2024
1 parent 43d1925 commit 13dca0b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion udivdi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
COMPILER_RT_ABI du_int __udivdi3(du_int n, du_int d) {
const unsigned N = sizeof(du_int) * CHAR_BIT;
// d == 0 cases are unspecified.
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
unsigned sr = (d ? (unsigned)clz(d) : N) - (n ? (unsigned)clz(n) : N);
// 0 <= sr <= N - 1 or sr is very large.
if (sr > N - 1) // n < d
return 0;
Expand Down
2 changes: 1 addition & 1 deletion udivsi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d) {
const unsigned N = sizeof(su_int) * CHAR_BIT;
// d == 0 cases are unspecified.
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
unsigned sr = (d ? (unsigned)clz(d) : N) - (n ? (unsigned)clz(n) : N);
// 0 <= sr <= N - 1 or sr is very large.
if (sr > N - 1) // n < d
return 0;
Expand Down
2 changes: 1 addition & 1 deletion umoddi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
COMPILER_RT_ABI du_int __umoddi3(du_int n, du_int d) {
const unsigned N = sizeof(du_int) * CHAR_BIT;
// d == 0 cases are unspecified.
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
unsigned sr = (d ? (unsigned)clz(d) : N) - (n ? (unsigned)clz(n) : N);
// 0 <= sr <= N - 1 or sr is very large.
if (sr > N - 1) // n < d
return n;
Expand Down
2 changes: 1 addition & 1 deletion umodsi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
COMPILER_RT_ABI su_int __umodsi3(su_int n, su_int d) {
const unsigned N = sizeof(su_int) * CHAR_BIT;
// d == 0 cases are unspecified.
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
unsigned sr = (d ? (unsigned)clz(d) : N) - (n ? (unsigned)clz(n) : N);
// 0 <= sr <= N - 1 or sr is very large.
if (sr > N - 1) // n < d
return n;
Expand Down

0 comments on commit 13dca0b

Please sign in to comment.