===================================================================
@@ -112,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := Standard'Address_Size;
+ subtype C_Address is System.Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -46,6 +46,8 @@
-- Note: do not introduce any pragma Inline statements into this unit, since
-- otherwise the relinking and rebinding capability would be deactivated.
+with System.Aux_DEC;
+
package System.Parameters is
pragma Pure;
@@ -110,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := 32;
+ subtype C_Address is System.Short_Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc32";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -110,6 +110,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := Standard'Address_Size;
+ subtype C_Address is System.Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -36,7 +36,7 @@
package body Interfaces.C.Pointers is
- type Addr is mod Memory_Size;
+ type Addr is mod 2 ** System.Parameters.ptr_bits;
function To_Pointer is new Ada.Unchecked_Conversion (Addr, Pointer);
function To_Addr is new Ada.Unchecked_Conversion (Pointer, Addr);
@@ -195,6 +195,7 @@
subtype A is Element_Array (L .. H);
type PA is access A;
+ for PA'Size use System.Parameters.ptr_bits;
function To_PA is new Ada.Unchecked_Conversion (Pointer, PA);
begin
@@ -238,6 +239,7 @@
subtype A is Element_Array (L .. H);
type PA is access A;
+ for PA'Size use System.Parameters.ptr_bits;
function To_PA is new Ada.Unchecked_Conversion (Pointer, PA);
begin
===================================================================
@@ -42,10 +42,10 @@
-- this type will in fact be used for aliasing values of other types.
function To_chars_ptr is
- new Ada.Unchecked_Conversion (Address, chars_ptr);
+ new Ada.Unchecked_Conversion (System.Parameters.C_Address, chars_ptr);
function To_Address is
- new Ada.Unchecked_Conversion (chars_ptr, Address);
+ new Ada.Unchecked_Conversion (chars_ptr, System.Parameters.C_Address);
-----------------------
-- Local Subprograms --
@@ -70,7 +70,7 @@
-- compatible, so we directly import here the malloc and free routines.
function Memory_Alloc (Size : size_t) return chars_ptr;
- pragma Import (C, Memory_Alloc, "__gnat_malloc");
+ pragma Import (C, Memory_Alloc, System.Parameters.C_Malloc_Linkname);
procedure Memory_Free (Address : chars_ptr);
pragma Import (C, Memory_Free, "__gnat_free");
===================================================================
@@ -33,6 +33,8 @@
-- --
------------------------------------------------------------------------------
+with System.Parameters;
+
generic
type Index is (<>);
type Element is private;
@@ -43,6 +45,7 @@
pragma Preelaborate;
type Pointer is access all Element;
+ for Pointer'Size use System.Parameters.ptr_bits;
pragma No_Strict_Aliasing (Pointer);
-- We turn off any strict aliasing assumptions for the pointer type,
===================================================================
@@ -37,6 +37,7 @@
pragma Preelaborate;
type char_array_access is access all char_array;
+ for char_array_access'Size use System.Parameters.ptr_bits;
pragma No_Strict_Aliasing (char_array_access);
-- Since this type is used for external interfacing, with the pointer
@@ -91,7 +92,7 @@
private
type chars_ptr is access all Character;
- pragma Convention (C, chars_ptr);
+ for chars_ptr'Size use System.Parameters.ptr_bits;
pragma No_Strict_Aliasing (chars_ptr);
-- Since this type is used for external interfacing, with the pointer
===================================================================
@@ -46,6 +46,8 @@
-- Note: do not introduce any pragma Inline statements into this unit, since
-- otherwise the relinking and rebinding capability would be deactivated.
+with System.Aux_DEC;
+
package System.Parameters is
pragma Pure;
@@ -110,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := 32;
+ subtype C_Address is System.Short_Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc32";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -112,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := Standard'Address_Size;
+ subtype C_Address is System.Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -54,10 +54,10 @@
-- a non-private system.address type.
type ptrdiff_t is
- range -(2 ** (Standard'Address_Size - Integer'(1))) ..
- +(2 ** (Standard'Address_Size - Integer'(1)) - 1);
+ range -(2 ** (System.Parameters.ptr_bits - Integer'(1))) ..
+ +(2 ** (System.Parameters.ptr_bits - Integer'(1)) - 1);
- type size_t is mod 2 ** Standard'Address_Size;
+ type size_t is mod 2 ** System.Parameters.ptr_bits;
-- Floating-Point
===================================================================
@@ -112,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := Standard'Address_Size;
+ subtype C_Address is System.Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------
===================================================================
@@ -46,6 +46,8 @@
-- Note: do not introduce any pragma Inline statements into this unit, since
-- otherwise the relinking and rebinding capability would be deactivated.
+with System.Aux_DEC;
+
package System.Parameters is
pragma Pure;
@@ -110,6 +112,15 @@
-- is that this is the same as type Long_Integer, but this is not true
-- of all targets. For example, in OpenVMS long /= Long_Integer.
+ ptr_bits : constant := 32;
+ subtype C_Address is System.Short_Address;
+ -- Number of bits in Interaces.C pointers, normally a standard address,
+ -- except on 64-bit VMS where they are 32-bit addresses, for compatibility
+ -- with legacy code.
+
+ C_Malloc_Linkname : constant String := "__gnat_malloc32";
+ -- Name of runtime function used to allocate such a pointer
+
----------------------------------------------
-- Behavior of Pragma Finalize_Storage_Only --
----------------------------------------------