aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-03-08 15:12:27 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-05-25 09:44:18 +0200
commit5b8bdb676dae45d51af82c7e56968d1e1af1a494 (patch)
tree193c97d51640931f656bec751be7dc21af483cda /gcc
parent70ff3a2e4c85d2d48717067708631b56aa929a6e (diff)
downloadgcc-5b8bdb676dae45d51af82c7e56968d1e1af1a494.zip
gcc-5b8bdb676dae45d51af82c7e56968d1e1af1a494.tar.gz
gcc-5b8bdb676dae45d51af82c7e56968d1e1af1a494.tar.bz2
ada: Decouple size of addresses and pointers from size of memory space
This decouples the size of the types representing addresses and pointers, which is Standard'Address_Size, from the size of the memory space, which is System.Memory_Size (more precisely log2 of it). They are tied through the definition of System.Address: type Address is mod Memory_Size; so Standard'Address_Size >= log2 (System.Memory_Size) necessarily, but the equality does not hold on platforms where addresses and pointers contain additional bits of metadata. gcc/ada/ * libgnat/a-ststio.adb (Set_Mode): Test System.Memory_Size. * libgnat/g-debuti.ads (Address_64): Likewise. * libgnat/i-c.ads: Add with clause for System. (ptrdiff_t): Define based on the size of memory space. (size_t): Likewise. * libgnat/s-crtl.ads (size_t): Likewise. (ssize_t): Likewise. * libgnat/s-memory.ads (size_t): Likewise. * libgnat/s-parame.ads (Size_Type): Likewise. * libgnat/s-parame__hpux.ads (Size_Type): Likewise. * libgnat/s-parame__posix2008.ads (Size_Type): Likewise. * libgnat/s-parame__vxworks.ads (Size_Type): Likewise. * libgnat/s-putima.adb (Signed_Address): Likewise. (Unsigned_Address): Likewise. * libgnat/s-stoele.ads (Storage_Offset): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/libgnat/a-ststio.adb4
-rw-r--r--gcc/ada/libgnat/g-debuti.ads4
-rw-r--r--gcc/ada/libgnat/i-c.ads6
-rw-r--r--gcc/ada/libgnat/s-crtl.ads5
-rw-r--r--gcc/ada/libgnat/s-memory.ads2
-rw-r--r--gcc/ada/libgnat/s-parame.ads4
-rw-r--r--gcc/ada/libgnat/s-parame__hpux.ads4
-rw-r--r--gcc/ada/libgnat/s-parame__posix2008.ads4
-rw-r--r--gcc/ada/libgnat/s-parame__vxworks.ads4
-rw-r--r--gcc/ada/libgnat/s-putima.adb5
-rw-r--r--gcc/ada/libgnat/s-stoele.ads7
11 files changed, 18 insertions, 31 deletions
diff --git a/gcc/ada/libgnat/a-ststio.adb b/gcc/ada/libgnat/a-ststio.adb
index 2cb9d97..ab46f48 100644
--- a/gcc/ada/libgnat/a-ststio.adb
+++ b/gcc/ada/libgnat/a-ststio.adb
@@ -367,11 +367,13 @@ package body Ada.Streams.Stream_IO is
FIO.Append_Set (AP (File));
if File.Mode = FCB.Append_File then
- if Standard'Address_Size = 64 then
+ pragma Warnings (Off, "condition is always *");
+ if Memory_Size = 2**64 then
File.Index := Count (ftell64 (File.Stream)) + 1;
else
File.Index := Count (ftell (File.Stream)) + 1;
end if;
+ pragma Warnings (On);
end if;
File.Last_Op := Op_Other;
diff --git a/gcc/ada/libgnat/g-debuti.ads b/gcc/ada/libgnat/g-debuti.ads
index b989cd4..51a1b77 100644
--- a/gcc/ada/libgnat/g-debuti.ads
+++ b/gcc/ada/libgnat/g-debuti.ads
@@ -39,8 +39,8 @@ with System;
package GNAT.Debug_Utilities is
pragma Pure;
- Address_64 : constant Boolean := Standard'Address_Size = 64;
- -- Set true if 64 bit addresses (assumes only 32 and 64 are possible)
+ Address_64 : constant Boolean := System.Memory_Size = 2**64;
+ -- Set true if 64-bit addresses (assumes only 32 and 64 are possible)
Address_Image_Length : constant := 13 + 10 * Boolean'Pos (Address_64);
-- Length of string returned by Image function for an address
diff --git a/gcc/ada/libgnat/i-c.ads b/gcc/ada/libgnat/i-c.ads
index 7013902..70af56a 100644
--- a/gcc/ada/libgnat/i-c.ads
+++ b/gcc/ada/libgnat/i-c.ads
@@ -24,6 +24,7 @@ pragma Assertion_Policy (Pre => Ignore,
Contract_Cases => Ignore,
Ghost => Ignore);
+with System;
with System.Parameters;
package Interfaces.C
@@ -82,10 +83,9 @@ is
-- a non-private system.address type.
type ptrdiff_t is
- range -(2 ** (System.Parameters.ptr_bits - Integer'(1))) ..
- +(2 ** (System.Parameters.ptr_bits - Integer'(1)) - 1);
+ range -System.Memory_Size / 2 .. System.Memory_Size / 2 - 1;
- type size_t is mod 2 ** System.Parameters.ptr_bits;
+ type size_t is mod System.Memory_Size;
-- Boolean type
diff --git a/gcc/ada/libgnat/s-crtl.ads b/gcc/ada/libgnat/s-crtl.ads
index 4b6fc76..c3a3b64 100644
--- a/gcc/ada/libgnat/s-crtl.ads
+++ b/gcc/ada/libgnat/s-crtl.ads
@@ -55,10 +55,9 @@ package System.CRTL is
subtype off_t is Long_Integer;
- type size_t is mod 2 ** Standard'Address_Size;
+ type size_t is mod System.Memory_Size;
- type ssize_t is range -(2 ** (Standard'Address_Size - 1))
- .. +(2 ** (Standard'Address_Size - 1)) - 1;
+ type ssize_t is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
type int64 is new Long_Long_Integer;
-- Note: we use Long_Long_Integer'First instead of -2 ** 63 to allow this
diff --git a/gcc/ada/libgnat/s-memory.ads b/gcc/ada/libgnat/s-memory.ads
index dc431b7..4f6dd3d2 100644
--- a/gcc/ada/libgnat/s-memory.ads
+++ b/gcc/ada/libgnat/s-memory.ads
@@ -43,7 +43,7 @@
package System.Memory is
pragma Elaborate_Body;
- type size_t is mod 2 ** Standard'Address_Size;
+ type size_t is mod Memory_Size;
-- Note: the reason we redefine this here instead of using the
-- definition in Interfaces.C is that we do not want to drag in
-- all of Interfaces.C just because System.Memory is used.
diff --git a/gcc/ada/libgnat/s-parame.ads b/gcc/ada/libgnat/s-parame.ads
index 3d6e345..72e7238 100644
--- a/gcc/ada/libgnat/s-parame.ads
+++ b/gcc/ada/libgnat/s-parame.ads
@@ -53,9 +53,7 @@ package System.Parameters is
-- Task And Stack Allocation Control --
---------------------------------------
- type Size_Type is range
- -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
- +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1;
+ type Size_Type is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
-- Type used to provide task stack sizes to the runtime. Sized to permit
-- stack sizes of up to half the total addressable memory space. This may
-- seem excessively large (even for 32-bit systems), however there are many
diff --git a/gcc/ada/libgnat/s-parame__hpux.ads b/gcc/ada/libgnat/s-parame__hpux.ads
index 542131f..243f8c3 100644
--- a/gcc/ada/libgnat/s-parame__hpux.ads
+++ b/gcc/ada/libgnat/s-parame__hpux.ads
@@ -53,9 +53,7 @@ package System.Parameters is
-- Task And Stack Allocation Control --
---------------------------------------
- type Size_Type is range
- -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
- +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1;
+ type Size_Type is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
-- Type used to provide task stack sizes to the runtime. Sized to permit
-- stack sizes of up to half the total addressable memory space. This may
-- seem excessively large (even for 32-bit systems), however there are many
diff --git a/gcc/ada/libgnat/s-parame__posix2008.ads b/gcc/ada/libgnat/s-parame__posix2008.ads
index 4f5d47a..16555e1 100644
--- a/gcc/ada/libgnat/s-parame__posix2008.ads
+++ b/gcc/ada/libgnat/s-parame__posix2008.ads
@@ -53,9 +53,7 @@ package System.Parameters is
-- Task And Stack Allocation Control --
---------------------------------------
- type Size_Type is range
- -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
- +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1;
+ type Size_Type is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
-- Type used to provide task stack sizes to the runtime. Sized to permit
-- stack sizes of up to half the total addressable memory space. This may
-- seem excessively large (even for 32-bit systems), however there are many
diff --git a/gcc/ada/libgnat/s-parame__vxworks.ads b/gcc/ada/libgnat/s-parame__vxworks.ads
index adae27d..6cf32ca 100644
--- a/gcc/ada/libgnat/s-parame__vxworks.ads
+++ b/gcc/ada/libgnat/s-parame__vxworks.ads
@@ -53,9 +53,7 @@ package System.Parameters is
-- Task And Stack Allocation Control --
---------------------------------------
- type Size_Type is range
- -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
- +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1;
+ type Size_Type is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
-- Type used to provide task stack sizes to the runtime. Sized to permit
-- stack sizes of up to half the total addressable memory space. This may
-- seem excessively large (even for 32-bit systems), however there are many
diff --git a/gcc/ada/libgnat/s-putima.adb b/gcc/ada/libgnat/s-putima.adb
index 34d5a03..1d6e608 100644
--- a/gcc/ada/libgnat/s-putima.adb
+++ b/gcc/ada/libgnat/s-putima.adb
@@ -118,9 +118,8 @@ package body System.Put_Images is
(S : in out Sink'Class; X : Long_Long_Long_Unsigned)
renames LLL_Integer_Images.Put_Image;
- type Signed_Address is range
- -2**(Standard'Address_Size - 1) .. 2**(Standard'Address_Size - 1) - 1;
- type Unsigned_Address is mod 2**Standard'Address_Size;
+ type Signed_Address is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
+ type Unsigned_Address is mod Memory_Size;
package Hex is new Generic_Integer_Images
(Signed_Address, Unsigned_Address, Base => 16);
diff --git a/gcc/ada/libgnat/s-stoele.ads b/gcc/ada/libgnat/s-stoele.ads
index 99a195a..3262d03 100644
--- a/gcc/ada/libgnat/s-stoele.ads
+++ b/gcc/ada/libgnat/s-stoele.ads
@@ -45,12 +45,7 @@ package System.Storage_Elements is
pragma Annotate (GNATprove, Always_Return, Storage_Elements);
- type Storage_Offset is range
- -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
- +(2 ** (Integer'(Standard'Address_Size) - 1)) - Long_Long_Integer'(1);
- -- Note: the reason for the Long_Long_Integer qualification here is to
- -- avoid a bogus ambiguity when this unit is analyzed in an rtsfind
- -- context.
+ type Storage_Offset is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last;