From patchwork Thu Jul 12 10:30:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 170631 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 467CF2C0084 for ; Thu, 12 Jul 2012 20:31:01 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1342693862; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=Oko7R16BsMYDb+Yzoq2p 6IjEEIA=; b=TW8ZNR3+Qmw7FFGE2rPS0sfBxod9F/KeuTYKQctKC394LgYQ8XQi NppA9RV0pr8XxjunBOlw0eICDvPD/50GxYE1hTVcnU+0AKsr52LEIKu/cytH0OYd cluZrFPglhxIbkArs10yKZR/9t+nn5j5dI74CKHoCQtizThPai/OF3c= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=YhKTAA317/u4zc7qkheJ7eru+k4dpLkh7vUDXfNUHQjWLpwGUQy5CPd0ztWb2g MjCLkrkf/yq9hTF8H7Hx7Rk/TC0KNKh7rBqPTJzh+VaM3hnJeNG3I/XoaMQD/FDb oDIqsfoDdKJFDxaMYnD9upxu/e+3H1yfhrt1bdxZ5A4iA=; Received: (qmail 24770 invoked by alias); 12 Jul 2012 10:30:57 -0000 Received: (qmail 24758 invoked by uid 22791); 12 Jul 2012 10:30:54 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jul 2012 10:30:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8ADD21C740E; Thu, 12 Jul 2012 06:30:38 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id P-gnm5JmtK6H; Thu, 12 Jul 2012 06:30:38 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 603831C736F; Thu, 12 Jul 2012 06:30:38 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 53AEE92BF6; Thu, 12 Jul 2012 06:30:38 -0400 (EDT) Date: Thu, 12 Jul 2012 06:30:38 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Move GNAT.Byte_Swapping to System Message-ID: <20120712103038.GA4797@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 change moves the GNAT runtime package GNAT.Byte_Swapping under System (with a renaming under GNAT for compatibility) so that the unit can be used from expanded code at a later point. No visible behaviour change (simple code reorganization), no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-12 Thomas Quinot * g-bytswa.adb, g-bytswa.ads, s-bytswa.adb, s-bytswa.ads, Makefile.rtl: Move GNAT.Byte_Swapping to System (with a renaming under GNAT) so that it is usable in expanded code. Index: g-bytswa.adb =================================================================== --- g-bytswa.adb (revision 189431) +++ g-bytswa.adb (working copy) @@ -2,11 +2,11 @@ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- --- G N A T . B Y T E _ S W A P P I N G -- +-- G N A T . B Y T E _ S W A P P I N G -- -- -- -- B o d y -- -- -- --- Copyright (C) 2006-2012, AdaCore -- +-- Copyright (C) 1995-2012, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -29,98 +29,8 @@ -- -- ------------------------------------------------------------------------------ --- This is a general implementation that uses GCC intrinsics to take --- advantage of any machine-specific instructions. +-- This package does not require a body, since it is a package renaming. We +-- provide a dummy file containing a No_Body pragma so that previous versions +-- of the body (which did exist) will not interfere. -with Ada.Unchecked_Conversion; use Ada; - -package body GNAT.Byte_Swapping is - - type U16 is mod 2**16; - type U32 is mod 2**32; - type U64 is mod 2**64; - - function Bswap_16 (X : U16) return U16 is (X / 256 or X * 256); - -- The above is an idiom recognized by GCC - - function Bswap_32 (X : U32) return U32; - pragma Import (Intrinsic, Bswap_32, "__builtin_bswap32"); - - function Bswap_64 (X : U64) return U64; - pragma Import (Intrinsic, Bswap_64, "__builtin_bswap64"); - - -------------- - -- Swapped2 -- - -------------- - - function Swapped2 (Input : Item) return Item is - function As_U16 is new Unchecked_Conversion (Item, U16); - function As_Item is new Unchecked_Conversion (U16, Item); - - function Bswap_16 (X : U16) return U16 is (X / 256 or X * 256); - -- ??? Need to have function local here to allow inlining - pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 2, - "storage size must be 2 bytes"); - begin - return As_Item (Bswap_16 (As_U16 (Input))); - end Swapped2; - - -------------- - -- Swapped4 -- - -------------- - - function Swapped4 (Input : Item) return Item is - function As_U32 is new Unchecked_Conversion (Item, U32); - function As_Item is new Unchecked_Conversion (U32, Item); - pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 4, - "storage size must be 4 bytes"); - begin - return As_Item (Bswap_32 (As_U32 (Input))); - end Swapped4; - - -------------- - -- Swapped8 -- - -------------- - - function Swapped8 (Input : Item) return Item is - function As_U64 is new Unchecked_Conversion (Item, U64); - function As_Item is new Unchecked_Conversion (U64, Item); - pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 8, - "storage size must be 8 bytes"); - begin - return As_Item (Bswap_64 (As_U64 (Input))); - end Swapped8; - - ----------- - -- Swap2 -- - ----------- - - procedure Swap2 (Location : System.Address) is - X : U16; - for X'Address use Location; - begin - X := Bswap_16 (X); - end Swap2; - - ----------- - -- Swap4 -- - ----------- - - procedure Swap4 (Location : System.Address) is - X : U32; - for X'Address use Location; - begin - X := Bswap_32 (X); - end Swap4; - - ----------- - -- Swap8 -- - ----------- - - procedure Swap8 (Location : System.Address) is - X : U64; - for X'Address use Location; - begin - X := Bswap_64 (X); - end Swap8; -end GNAT.Byte_Swapping; +pragma No_Body; Index: g-bytswa.ads =================================================================== --- g-bytswa.ads (revision 189431) +++ g-bytswa.ads (working copy) @@ -2,11 +2,11 @@ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- --- G N A T . B Y T E _ S W A P P I N G -- +-- G N A T . B Y T E _ S W A P P I N G -- -- -- -- S p e c -- -- -- --- Copyright (C) 2006-2011, AdaCore -- +-- Copyright (C) 2006-2012, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -31,176 +31,8 @@ -- Simple routines for swapping the bytes of 16-, 32-, and 64-bit objects --- The generic functions should be instantiated with types that are of a size --- in bytes corresponding to the name of the generic. For example, a 2-byte --- integer type would be compatible with Swapped2, 4-byte integer with --- Swapped4, and so on. Failure to do so will result in a warning when --- compiling the instantiation; this warning should be heeded. Ignoring this --- warning can result in unexpected results. +-- See file s-bytswa.ads for full documentation of the interface --- An example of proper usage follows: +with System.Byte_Swapping; --- declare --- type Short_Integer is range -32768 .. 32767; --- for Short_Integer'Size use 16; -- for confirmation - --- X : Short_Integer := 16#7FFF#; - --- function Swapped is new Byte_Swapping.Swapped2 (Short_Integer); - --- begin --- Put_Line (X'Img); --- X := Swapped (X); --- Put_Line (X'Img); --- end; - --- Note that the generic actual types need not be scalars, but must be --- 'definite' types. They can, for example, be constrained subtypes of --- unconstrained array types as long as the size is correct. For instance, --- a subtype of String with length of 4 would be compatible with the --- Swapped4 generic: - --- declare --- subtype String4 is String (1 .. 4); --- function Swapped is new Byte_Swapping.Swapped4 (String4); --- S : String4 := "ABCD"; --- for S'Alignment use 4; --- begin --- Put_Line (S); --- S := Swapped (S); --- Put_Line (S); --- end; - --- Similarly, a constrained array type is also acceptable: - --- declare --- type Mask is array (0 .. 15) of Boolean; --- for Mask'Alignment use 2; --- for Mask'Component_Size use Boolean'Size; --- X : Mask := (0 .. 7 => True, others => False); --- function Swapped is new Byte_Swapping.Swapped2 (Mask); --- begin --- ... --- X := Swapped (X); --- ... --- end; - --- A properly-sized record type will also be acceptable, and so forth - --- However, as described, a size mismatch must be avoided. In the following we --- instantiate one of the generics with a type that is too large. The result --- of the function call is undefined, such that assignment to an object can --- result in garbage values. - --- Wrong: declare --- subtype String16 is String (1 .. 16); - --- function Swapped is new Byte_Swapping.Swapped8 (String16); --- -- Instantiation generates a compiler warning about --- -- mismatched sizes - --- S : String16; - --- begin --- S := "ABCDEFGHDEADBEEF"; --- --- Put_Line (S); --- --- -- the following assignment results in garbage in S after the --- -- first 8 bytes --- --- S := Swapped (S); --- --- Put_Line (S); --- end Wrong; - --- When the size of the type is larger than 8 bytes, the use of the non- --- generic procedures is an alternative because no function result is --- involved; manipulation of the object is direct. - --- The procedures are passed the address of an object to manipulate. They will --- swap the first N bytes of that object corresponding to the name of the --- procedure. For example: - --- declare --- S2 : String := "AB"; --- for S2'Alignment use 2; --- S4 : String := "ABCD"; --- for S4'Alignment use 4; --- S8 : String := "ABCDEFGH"; --- for S8'Alignment use 8; - --- begin --- Swap2 (S2'Address); --- Put_Line (S2); - --- Swap4 (S4'Address); --- Put_Line (S4); - --- Swap8 (S8'Address); --- Put_Line (S8); --- end; - --- If an object of a type larger than N is passed, the remaining bytes of the --- object are undisturbed. For example: - --- declare --- subtype String16 is String (1 .. 16); - --- S : String16; --- for S'Alignment use 8; - --- begin --- S := "ABCDEFGHDEADBEEF"; --- Put_Line (S); --- Swap8 (S'Address); --- Put_Line (S); --- end; - -with System; - -package GNAT.Byte_Swapping is - pragma Pure; - - -- NB: all the routines in this package treat the application objects as - -- unsigned (modular) types of a size in bytes corresponding to the routine - -- name. For example, the generic function Swapped2 manipulates the object - -- passed to the formal parameter Input as a value of an unsigned type that - -- is 2 bytes long. Therefore clients are responsible for the compatibility - -- of application types manipulated by these routines and these modular - -- types, in terms of both size and alignment. This requirement applies to - -- the generic actual type passed to the generic formal type Item in the - -- generic functions, as well as to the type of the object implicitly - -- designated by the address passed to the non-generic procedures. Use of - -- incompatible types can result in implementation- defined effects. - - generic - type Item is limited private; - function Swapped2 (Input : Item) return Item; - -- Return the 2-byte value of Input with the bytes swapped - - generic - type Item is limited private; - function Swapped4 (Input : Item) return Item; - -- Return the 4-byte value of Input with the bytes swapped - - generic - type Item is limited private; - function Swapped8 (Input : Item) return Item; - -- Return the 8-byte value of Input with the bytes swapped - - procedure Swap2 (Location : System.Address); - -- Swap the first 2 bytes of the object starting at the address specified - -- by Location. - - procedure Swap4 (Location : System.Address); - -- Swap the first 4 bytes of the object starting at the address specified - -- by Location. - - procedure Swap8 (Location : System.Address); - -- Swap the first 8 bytes of the object starting at the address specified - -- by Location. - - pragma Inline (Swap2, Swap4, Swap8, Swapped2, Swapped4, Swapped8); - -end GNAT.Byte_Swapping; +package GNAT.Byte_Swapping renames System.Byte_Swapping; Index: s-bytswa.adb =================================================================== --- s-bytswa.adb (revision 0) +++ s-bytswa.adb (revision 0) @@ -0,0 +1,127 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . B Y T E _ S W A P P I N G -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2006-2012, AdaCore -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This is a general implementation that uses GCC intrinsics to take +-- advantage of any machine-specific instructions. + +with Ada.Unchecked_Conversion; use Ada; + +package body System.Byte_Swapping is + + type U16 is mod 2**16; + type U32 is mod 2**32; + type U64 is mod 2**64; + + function Bswap_16 (X : U16) return U16; + pragma Import (Intrinsic, Bswap_16, "__builtin_bswap16"); + + function Bswap_32 (X : U32) return U32; + pragma Import (Intrinsic, Bswap_32, "__builtin_bswap32"); + + function Bswap_64 (X : U64) return U64; + pragma Import (Intrinsic, Bswap_64, "__builtin_bswap64"); + + -------------- + -- Swapped2 -- + -------------- + + function Swapped2 (Input : Item) return Item is + function As_U16 is new Unchecked_Conversion (Item, U16); + function As_Item is new Unchecked_Conversion (U16, Item); + + function Bswap_16 (X : U16) return U16 is (X / 256 or X * 256); + -- ??? Need to have function local here to allow inlining + pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 2, + "storage size must be 2 bytes"); + begin + return As_Item (Bswap_16 (As_U16 (Input))); + end Swapped2; + + -------------- + -- Swapped4 -- + -------------- + + function Swapped4 (Input : Item) return Item is + function As_U32 is new Unchecked_Conversion (Item, U32); + function As_Item is new Unchecked_Conversion (U32, Item); + pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 4, + "storage size must be 4 bytes"); + begin + return As_Item (Bswap_32 (As_U32 (Input))); + end Swapped4; + + -------------- + -- Swapped8 -- + -------------- + + function Swapped8 (Input : Item) return Item is + function As_U64 is new Unchecked_Conversion (Item, U64); + function As_Item is new Unchecked_Conversion (U64, Item); + pragma Compile_Time_Error (Item'Max_Size_In_Storage_Elements /= 8, + "storage size must be 8 bytes"); + begin + return As_Item (Bswap_64 (As_U64 (Input))); + end Swapped8; + + ----------- + -- Swap2 -- + ----------- + + procedure Swap2 (Location : System.Address) is + X : U16; + for X'Address use Location; + begin + X := Bswap_16 (X); + end Swap2; + + ----------- + -- Swap4 -- + ----------- + + procedure Swap4 (Location : System.Address) is + X : U32; + for X'Address use Location; + begin + X := Bswap_32 (X); + end Swap4; + + ----------- + -- Swap8 -- + ----------- + + procedure Swap8 (Location : System.Address) is + X : U64; + for X'Address use Location; + begin + X := Bswap_64 (X); + end Swap8; + +end System.Byte_Swapping; Index: s-bytswa.ads =================================================================== --- s-bytswa.ads (revision 0) +++ s-bytswa.ads (revision 0) @@ -0,0 +1,206 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . B Y T E _ S W A P P I N G -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2006-2012, AdaCore -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- Simple routines for swapping the bytes of 16-, 32-, and 64-bit objects + +-- The generic functions should be instantiated with types that are of a size +-- in bytes corresponding to the name of the generic. For example, a 2-byte +-- integer type would be compatible with Swapped2, 4-byte integer with +-- Swapped4, and so on. Failure to do so will result in a warning when +-- compiling the instantiation; this warning should be heeded. Ignoring this +-- warning can result in unexpected results. + +-- An example of proper usage follows: + +-- declare +-- type Short_Integer is range -32768 .. 32767; +-- for Short_Integer'Size use 16; -- for confirmation + +-- X : Short_Integer := 16#7FFF#; + +-- function Swapped is new Byte_Swapping.Swapped2 (Short_Integer); + +-- begin +-- Put_Line (X'Img); +-- X := Swapped (X); +-- Put_Line (X'Img); +-- end; + +-- Note that the generic actual types need not be scalars, but must be +-- 'definite' types. They can, for example, be constrained subtypes of +-- unconstrained array types as long as the size is correct. For instance, +-- a subtype of String with length of 4 would be compatible with the +-- Swapped4 generic: + +-- declare +-- subtype String4 is String (1 .. 4); +-- function Swapped is new Byte_Swapping.Swapped4 (String4); +-- S : String4 := "ABCD"; +-- for S'Alignment use 4; +-- begin +-- Put_Line (S); +-- S := Swapped (S); +-- Put_Line (S); +-- end; + +-- Similarly, a constrained array type is also acceptable: + +-- declare +-- type Mask is array (0 .. 15) of Boolean; +-- for Mask'Alignment use 2; +-- for Mask'Component_Size use Boolean'Size; +-- X : Mask := (0 .. 7 => True, others => False); +-- function Swapped is new Byte_Swapping.Swapped2 (Mask); +-- begin +-- ... +-- X := Swapped (X); +-- ... +-- end; + +-- A properly-sized record type will also be acceptable, and so forth + +-- However, as described, a size mismatch must be avoided. In the following we +-- instantiate one of the generics with a type that is too large. The result +-- of the function call is undefined, such that assignment to an object can +-- result in garbage values. + +-- Wrong: declare +-- subtype String16 is String (1 .. 16); + +-- function Swapped is new Byte_Swapping.Swapped8 (String16); +-- -- Instantiation generates a compiler warning about +-- -- mismatched sizes + +-- S : String16; + +-- begin +-- S := "ABCDEFGHDEADBEEF"; +-- +-- Put_Line (S); +-- +-- -- the following assignment results in garbage in S after the +-- -- first 8 bytes +-- +-- S := Swapped (S); +-- +-- Put_Line (S); +-- end Wrong; + +-- When the size of the type is larger than 8 bytes, the use of the non- +-- generic procedures is an alternative because no function result is +-- involved; manipulation of the object is direct. + +-- The procedures are passed the address of an object to manipulate. They will +-- swap the first N bytes of that object corresponding to the name of the +-- procedure. For example: + +-- declare +-- S2 : String := "AB"; +-- for S2'Alignment use 2; +-- S4 : String := "ABCD"; +-- for S4'Alignment use 4; +-- S8 : String := "ABCDEFGH"; +-- for S8'Alignment use 8; + +-- begin +-- Swap2 (S2'Address); +-- Put_Line (S2); + +-- Swap4 (S4'Address); +-- Put_Line (S4); + +-- Swap8 (S8'Address); +-- Put_Line (S8); +-- end; + +-- If an object of a type larger than N is passed, the remaining bytes of the +-- object are undisturbed. For example: + +-- declare +-- subtype String16 is String (1 .. 16); + +-- S : String16; +-- for S'Alignment use 8; + +-- begin +-- S := "ABCDEFGHDEADBEEF"; +-- Put_Line (S); +-- Swap8 (S'Address); +-- Put_Line (S); +-- end; + +with System; + +package System.Byte_Swapping is + pragma Pure; + + -- NB: all the routines in this package treat the application objects as + -- unsigned (modular) types of a size in bytes corresponding to the routine + -- name. For example, the generic function Swapped2 manipulates the object + -- passed to the formal parameter Input as a value of an unsigned type that + -- is 2 bytes long. Therefore clients are responsible for the compatibility + -- of application types manipulated by these routines and these modular + -- types, in terms of both size and alignment. This requirement applies to + -- the generic actual type passed to the generic formal type Item in the + -- generic functions, as well as to the type of the object implicitly + -- designated by the address passed to the non-generic procedures. Use of + -- incompatible types can result in implementation- defined effects. + + generic + type Item is limited private; + function Swapped2 (Input : Item) return Item; + -- Return the 2-byte value of Input with the bytes swapped + + generic + type Item is limited private; + function Swapped4 (Input : Item) return Item; + -- Return the 4-byte value of Input with the bytes swapped + + generic + type Item is limited private; + function Swapped8 (Input : Item) return Item; + -- Return the 8-byte value of Input with the bytes swapped + + procedure Swap2 (Location : System.Address); + -- Swap the first 2 bytes of the object starting at the address specified + -- by Location. + + procedure Swap4 (Location : System.Address); + -- Swap the first 4 bytes of the object starting at the address specified + -- by Location. + + procedure Swap8 (Location : System.Address); + -- Swap the first 8 bytes of the object starting at the address specified + -- by Location. + + pragma Inline (Swap2, Swap4, Swap8, Swapped2, Swapped4, Swapped8); + +end System.Byte_Swapping; Index: Makefile.rtl =================================================================== --- Makefile.rtl (revision 189431) +++ Makefile.rtl (working copy) @@ -483,6 +483,7 @@ s-auxdec$(objext) \ s-bitops$(objext) \ s-boarop$(objext) \ + s-bytswa$(objext) \ s-carsi8$(objext) \ s-carun8$(objext) \ s-casi16$(objext) \