From patchwork Mon Aug 1 14:37:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 107762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7088FB7090 for ; Tue, 2 Aug 2011 00:38:22 +1000 (EST) Received: (qmail 10072 invoked by alias); 1 Aug 2011 14:38:18 -0000 Received: (qmail 9681 invoked by uid 22791); 1 Aug 2011 14:38:15 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Aug 2011 14:38:00 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 00B4ACB0262; Mon, 1 Aug 2011 16:37:59 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cTnwvAL7cFqh; Mon, 1 Aug 2011 16:37:48 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id BA040CB025A; Mon, 1 Aug 2011 16:37:48 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id A785C85978; Mon, 1 Aug 2011 16:37:51 +0200 (CEST) Date: Mon, 1 Aug 2011 16:37:51 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Remove duplicated units Message-ID: <20110801143751.GA24343@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This code reorganization reduces the amount of code duplication in the GNAT runtime library. No behaviour change, no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Thomas Quinot * s-parame-ae653.ads, s-parame-vms-alpha.ads, s-parame-hpux.ads, i-cpoint.adb, i-cstrin.adb, i-cpoint.ads, i-cstrin.ads, s-parame-vms-ia64.ads, s-parame.ads, i-c.ads, s-parame-vxworks.ads, s-parame-vms-restrict.ads: Remove duplicated Interfaces.C.* packages for VMS, instead parametrize the common implementation with System.Parameters declarations. Index: s-parame-ae653.ads =================================================================== --- s-parame-ae653.ads (revision 176998) +++ s-parame-ae653.ads (working copy) @@ -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 -- ---------------------------------------------- Index: s-parame-vms-alpha.ads =================================================================== --- s-parame-vms-alpha.ads (revision 176998) +++ s-parame-vms-alpha.ads (working copy) @@ -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 -- ---------------------------------------------- Index: s-parame-hpux.ads =================================================================== --- s-parame-hpux.ads (revision 176998) +++ s-parame-hpux.ads (working copy) @@ -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 -- ---------------------------------------------- Index: i-cpoint.adb =================================================================== --- i-cpoint.adb (revision 176998) +++ i-cpoint.adb (working copy) @@ -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 Index: i-cstrin.adb =================================================================== --- i-cstrin.adb (revision 177030) +++ i-cstrin.adb (working copy) @@ -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"); Index: i-cpoint.ads =================================================================== --- i-cpoint.ads (revision 176998) +++ i-cpoint.ads (working copy) @@ -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, Index: i-cstrin.ads =================================================================== --- i-cstrin.ads (revision 176998) +++ i-cstrin.ads (working copy) @@ -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 Index: s-parame-vms-ia64.ads =================================================================== --- s-parame-vms-ia64.ads (revision 176998) +++ s-parame-vms-ia64.ads (working copy) @@ -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 -- ---------------------------------------------- Index: s-parame.ads =================================================================== --- s-parame.ads (revision 176998) +++ s-parame.ads (working copy) @@ -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 -- ---------------------------------------------- Index: i-c.ads =================================================================== --- i-c.ads (revision 176998) +++ i-c.ads (working copy) @@ -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 Index: s-parame-vxworks.ads =================================================================== --- s-parame-vxworks.ads (revision 176998) +++ s-parame-vxworks.ads (working copy) @@ -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 -- ---------------------------------------------- Index: s-parame-vms-restrict.ads =================================================================== --- s-parame-vms-restrict.ads (revision 176998) +++ s-parame-vms-restrict.ads (working copy) @@ -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 -- ----------------------------------------------