Skip to contentSkip to conversation

Avoid compiler error

PATCH In review Stefan Weil 3 participants 3 messages Apr 10, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Avoid compiler error

A 32 bit cross compilation of x86_64-linux-user raises this error:

CC x86_64-linux-user/exec.o
cc1: warnings being treated as errors
exec.c: In function ‘page_init’:
exec.c:350: error: large integer implicitly truncated to unsigned type

L1_MAP_ADDR_SPACE_BITS == 47, HOST_LONG_BITS == 32, so the shift operation indeed is problematic.

Limit endaddr to ULONG_MAX in this case.

Cc Richard Henderson <[email protected]>
Cc Aurelien Jarno <[email protected]>
Cc Juergen Lock <[email protected]>
---
 exec.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
exec.c +2 -0
index a6d3bad..c80b7f7 100644
@@ -343,6 +343,8 @@ static void page_init(void)
                     } else {
 #if TARGET_ABI_BITS <= L1_MAP_ADDR_SPACE_BITS
                         endaddr = ~0ul;
+#elif HOST_LONG_BITS <= L1_MAP_ADDR_SPACE_BITS
+                        endaddr = ULONG_MAX;
 #else
                         endaddr = ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS) - 1;
 #endif
Signature · 1 line
1.7.0
#1 lore raw
Quoted 10 lines · Stefan Weil

A 32 bit cross compilation of x86_64-linux-user raises this error:

CC x86_64-linux-user/exec.o
cc1: warnings being treated as errors
exec.c: In function ‘page_init’:
exec.c:350: error: large integer implicitly truncated to unsigned type

L1_MAP_ADDR_SPACE_BITS == 47, HOST_LONG_BITS == 32, so the shift operation indeed is problematic.

I am not sure it is the real fix. I don't think there is a point of having L1_MAP_ADDR_SPACE_BITS > HOST_LONG_BITS, most probably it should be reduced to HOST_LONG_BITS if the latter is smaller, as done in system mode.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#2 lore raw
In reply to Stefan Weil

exec.c static void page_init(void) · line 350

Quoted 9 lines · Stefan Weil

A 32 bit cross compilation of x86_64-linux-user raises this error:

                      } else {
  #if TARGET_ABI_BITS<= L1_MAP_ADDR_SPACE_BITS
                          endaddr = ~0ul;
exec.c +2 -0
+#elif HOST_LONG_BITS<= L1_MAP_ADDR_SPACE_BITS
+                        endaddr = ULONG_MAX;
  #else
                          endaddr = ((abi_ulong)1<<  L1_MAP_ADDR_SPACE_BITS) - 1;
  #endif

You ought to merge those two ifs. I.e.

#if TARGET_ABI_BITS <= L1_MAP_ADDR_SPACE_BITS \
    || HOST_LONG_BITS<= L1_MAP_ADDR_SPACE_BITS

r~