Remove some compile time warnings about duplicate definitions.
[official-gcc.git] / gcc / ada / s-pack12.adb
blob958c88140ba4e7119a6fd70fe86809c09df26ced
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- S Y S T E M . P A C K _ 1 2 --
6 -- --
7 -- B o d y --
8 -- --
9 -- $Revision: 1.4 $
10 -- --
11 -- Copyright (C) 1992-1999 Free Software Foundation, Inc. --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 with System.Storage_Elements;
37 with System.Unsigned_Types;
38 with Unchecked_Conversion;
40 package body System.Pack_12 is
42 subtype Ofs is System.Storage_Elements.Storage_Offset;
43 subtype Uns is System.Unsigned_Types.Unsigned;
44 subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
46 use type System.Storage_Elements.Storage_Offset;
47 use type System.Unsigned_Types.Unsigned;
49 type Cluster is record
50 E0, E1, E2, E3, E4, E5, E6, E7 : Bits_12;
51 end record;
53 for Cluster use record
54 E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
55 E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
56 E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
57 E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
58 E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
59 E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
60 E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
61 E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
62 end record;
64 for Cluster'Size use Bits * 8;
66 for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
67 1 +
68 1 * Boolean'Pos (Bits mod 2 = 0) +
69 2 * Boolean'Pos (Bits mod 4 = 0));
70 -- Use maximum possible alignment, given the bit field size, since this
71 -- will result in the most efficient code possible for the field.
73 type Cluster_Ref is access Cluster;
75 function To_Ref is new
76 Unchecked_Conversion (System.Address, Cluster_Ref);
78 -- The following declarations are for the case where the address
79 -- passed to GetU_12 or SetU_12 is not guaranteed to be aligned.
80 -- These routines are used when the packed array is itself a
81 -- component of a packed record, and therefore may not be aligned.
83 type ClusterU is new Cluster;
84 for ClusterU'Alignment use 1;
86 type ClusterU_Ref is access ClusterU;
88 function To_Ref is new
89 Unchecked_Conversion (System.Address, ClusterU_Ref);
91 ------------
92 -- Get_12 --
93 ------------
95 function Get_12 (Arr : System.Address; N : Natural) return Bits_12 is
96 C : constant Cluster_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
98 begin
99 case N07 (Uns (N) mod 8) is
100 when 0 => return C.E0;
101 when 1 => return C.E1;
102 when 2 => return C.E2;
103 when 3 => return C.E3;
104 when 4 => return C.E4;
105 when 5 => return C.E5;
106 when 6 => return C.E6;
107 when 7 => return C.E7;
108 end case;
109 end Get_12;
111 -------------
112 -- GetU_12 --
113 -------------
115 function GetU_12 (Arr : System.Address; N : Natural) return Bits_12 is
116 C : constant ClusterU_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
118 begin
119 case N07 (Uns (N) mod 8) is
120 when 0 => return C.E0;
121 when 1 => return C.E1;
122 when 2 => return C.E2;
123 when 3 => return C.E3;
124 when 4 => return C.E4;
125 when 5 => return C.E5;
126 when 6 => return C.E6;
127 when 7 => return C.E7;
128 end case;
129 end GetU_12;
131 ------------
132 -- Set_12 --
133 ------------
135 procedure Set_12 (Arr : System.Address; N : Natural; E : Bits_12) is
136 C : constant Cluster_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
138 begin
139 case N07 (Uns (N) mod 8) is
140 when 0 => C.E0 := E;
141 when 1 => C.E1 := E;
142 when 2 => C.E2 := E;
143 when 3 => C.E3 := E;
144 when 4 => C.E4 := E;
145 when 5 => C.E5 := E;
146 when 6 => C.E6 := E;
147 when 7 => C.E7 := E;
148 end case;
149 end Set_12;
151 -------------
152 -- SetU_12 --
153 -------------
155 procedure SetU_12 (Arr : System.Address; N : Natural; E : Bits_12) is
156 C : constant ClusterU_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
158 begin
159 case N07 (Uns (N) mod 8) is
160 when 0 => C.E0 := E;
161 when 1 => C.E1 := E;
162 when 2 => C.E2 := E;
163 when 3 => C.E3 := E;
164 when 4 => C.E4 := E;
165 when 5 => C.E5 := E;
166 when 6 => C.E6 := E;
167 when 7 => C.E7 := E;
168 end case;
169 end SetU_12;
171 end System.Pack_12;