Skip to content

Commit 20acf7f

Browse files
Finn Thainmpe
authored andcommitted
powerpc/lib: Fix "integer constant is too large" build failure
My powerpc-linux-gnu-gcc v4.4.5 compiler can't build a 32-bit kernel any more: arch/powerpc/lib/sstep.c: In function 'do_popcnt': arch/powerpc/lib/sstep.c:1068: error: integer constant is too large for 'long' type arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type arch/powerpc/lib/sstep.c:1069: error: integer constant is too large for 'long' type arch/powerpc/lib/sstep.c:1070: error: integer constant is too large for 'long' type arch/powerpc/lib/sstep.c:1079: error: integer constant is too large for 'long' type arch/powerpc/lib/sstep.c: In function 'do_prty': arch/powerpc/lib/sstep.c:1117: error: integer constant is too large for 'long' type This file gets compiled with -std=gnu89 which means a constant can be given the type 'long' even if it won't fit. Fix the errors with a 'ULL' suffix on the relevant constants. Fixes: 2c979c4 ("powerpc/lib/sstep: Add prty instruction emulation") Fixes: dcbd19b ("powerpc/lib/sstep: Add popcnt instruction emulation") Signed-off-by: Finn Thain <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent c0beffc commit 20acf7f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/powerpc/lib/sstep.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,10 @@ static nokprobe_inline void do_popcnt(const struct pt_regs *regs,
10651065
{
10661066
unsigned long long out = v1;
10671067

1068-
out -= (out >> 1) & 0x5555555555555555;
1069-
out = (0x3333333333333333 & out) + (0x3333333333333333 & (out >> 2));
1070-
out = (out + (out >> 4)) & 0x0f0f0f0f0f0f0f0f;
1068+
out -= (out >> 1) & 0x5555555555555555ULL;
1069+
out = (0x3333333333333333ULL & out) +
1070+
(0x3333333333333333ULL & (out >> 2));
1071+
out = (out + (out >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
10711072

10721073
if (size == 8) { /* popcntb */
10731074
op->val = out;
@@ -1076,7 +1077,7 @@ static nokprobe_inline void do_popcnt(const struct pt_regs *regs,
10761077
out += out >> 8;
10771078
out += out >> 16;
10781079
if (size == 32) { /* popcntw */
1079-
op->val = out & 0x0000003f0000003f;
1080+
op->val = out & 0x0000003f0000003fULL;
10801081
return;
10811082
}
10821083

@@ -1114,7 +1115,7 @@ static nokprobe_inline void do_prty(const struct pt_regs *regs,
11141115

11151116
res ^= res >> 16;
11161117
if (size == 32) { /* prtyw */
1117-
op->val = res & 0x0000000100000001;
1118+
op->val = res & 0x0000000100000001ULL;
11181119
return;
11191120
}
11201121

0 commit comments

Comments
 (0)