This makes the new support for extended overflow checking work on big-endian
platforms as well by fixing a thinko in the allocation routine of bignums.
No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
2012-10-29 Eric Botcazou <[email protected]>
* s-bignum.adb (Allocate_Bignum): Use the exact layout of
Bignum_Data for the overlay.
Index: s-bignum.adb
===================================================================
--- s-bignum.adb (revision 192933)
+++ s-bignum.adb (working copy)
@@ -233,14 +233,27 @@
pragma Import (Ada, BD);
-- Expose a writable view of discriminant BD.Len so that we can
- -- initialize it.
+ -- initialize it. We need to use the exact layout of the record
+ -- for the overlay to shield ourselves from endianness issues.
- BL : Length;
- for BL'Address use BD.Len'Address;
- pragma Import (Ada, BL);
+ type Bignum_Data_Header is record
+ Len : Length;
+ Neg : Boolean;
+ end record;
+ for Bignum_Data_Header use record
+ Len at 0 range 0 .. 23;
+ Neg at 3 range 0 .. 7;
+ end record;
+
+ BDH : Bignum_Data_Header;
+ for BDH'Address use BD'Address;
+ pragma Import (Ada, BDH);
+
+ pragma Assert (BDH.Len'Size = BD.Len'Size);
+
begin
- BL := Len;
+ BDH.Len := Len;
return B;
end;
end if;