ada: Update copyright notice
[official-gcc.git] / gcc / ada / libgnat / s-stratt.ads
blobe0ddc2346e16f3da04359a472227ac98cef984d3
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . S T R E A M _ A T T R I B U T E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- This package contains the implementations of the stream attributes for
33 -- elementary types. These are the subprograms that are directly accessed
34 -- by occurrences of the stream attributes where the type is elementary.
36 -- We only provide the subprograms for the standard base types. For user
37 -- defined types, the subprogram for the corresponding root type is called
38 -- with an appropriate conversion.
40 with System.Unsigned_Types;
41 with Ada.Streams;
43 package System.Stream_Attributes is
44 pragma Preelaborate;
46 pragma Suppress (Accessibility_Check, Stream_Attributes);
47 -- No need to check accessibility on arguments of subprograms
49 package UST renames System.Unsigned_Types;
51 subtype RST is Ada.Streams.Root_Stream_Type'Class;
53 subtype SEC is Ada.Streams.Stream_Element_Count;
55 type Integer_24 is range -2 ** 23 .. 2 ** 23 - 1;
56 for Integer_24'Size use 24;
58 type Unsigned_24 is mod 2 ** 24;
59 for Unsigned_24'Size use 24;
61 -- Enumeration types are usually transferred using the routine for the
62 -- corresponding integer. The exception is that special routines are
63 -- provided for Boolean and the character types, in case the protocol
64 -- in use provides specially for these types.
66 -- Access types use either a thin pointer (single address) or fat pointer
67 -- (double address) form. The following types are used to hold access
68 -- values using unchecked conversions.
70 type Thin_Pointer is record
71 P1 : System.Address;
72 end record;
74 type Fat_Pointer is record
75 P1 : System.Address;
76 P2 : System.Address;
77 end record;
79 ------------------------------------
80 -- Treatment of enumeration types --
81 ------------------------------------
83 -- In this interface, there are no specific routines for general input
84 -- or output of enumeration types. Generally, enumeration types whose
85 -- representation is unsigned (no negative representation values) are
86 -- treated as unsigned integers, and enumeration types that do have
87 -- negative representation values are treated as signed integers.
89 -- An exception is that there are specialized routines for Boolean,
90 -- Character, and Wide_Character types, but these specialized routines
91 -- are used only if the type in question has a standard representation.
92 -- For the case of a non-standard representation (one where the size of
93 -- the first subtype is specified, or where an enumeration representation
94 -- clause is given), these three types are treated like any other cases
95 -- of enumeration types, as described above.
97 ---------------------
98 -- Input Functions --
99 ---------------------
101 -- Functions for S'Input attribute. These functions are also used for
102 -- S'Read, with the obvious transformation, since the input operation
103 -- is the same for all elementary types (no bounds or discriminants
104 -- are involved).
106 function I_AD (Stream : not null access RST) return Fat_Pointer;
107 function I_AS (Stream : not null access RST) return Thin_Pointer;
108 function I_B (Stream : not null access RST) return Boolean;
109 function I_C (Stream : not null access RST) return Character;
110 function I_F (Stream : not null access RST) return Float;
111 function I_I (Stream : not null access RST) return Integer;
112 function I_I24 (Stream : not null access RST) return Integer_24;
113 function I_LF (Stream : not null access RST) return Long_Float;
114 function I_LI (Stream : not null access RST) return Long_Integer;
115 function I_LLF (Stream : not null access RST) return Long_Long_Float;
116 function I_LLI (Stream : not null access RST) return Long_Long_Integer;
117 function I_LLLI (Stream : not null access RST) return
118 Long_Long_Long_Integer;
119 function I_LLLU (Stream : not null access RST) return
120 UST.Long_Long_Long_Unsigned;
121 function I_LLU (Stream : not null access RST) return
122 UST.Long_Long_Unsigned;
123 function I_LU (Stream : not null access RST) return UST.Long_Unsigned;
124 function I_SF (Stream : not null access RST) return Short_Float;
125 function I_SI (Stream : not null access RST) return Short_Integer;
126 function I_SSI (Stream : not null access RST) return Short_Short_Integer;
127 function I_SSU (Stream : not null access RST) return
128 UST.Short_Short_Unsigned;
129 function I_SU (Stream : not null access RST) return UST.Short_Unsigned;
130 function I_U (Stream : not null access RST) return UST.Unsigned;
131 function I_U24 (Stream : not null access RST) return Unsigned_24;
132 function I_WC (Stream : not null access RST) return Wide_Character;
133 function I_WWC (Stream : not null access RST) return Wide_Wide_Character;
135 -----------------------
136 -- Output Procedures --
137 -----------------------
139 -- Procedures for S'Write attribute. These procedures are also used for
140 -- 'Output, since for elementary types there is no difference between
141 -- 'Write and 'Output because there are no discriminants or bounds to
142 -- be written.
144 procedure W_AD (Stream : not null access RST; Item : Fat_Pointer);
145 procedure W_AS (Stream : not null access RST; Item : Thin_Pointer);
146 procedure W_B (Stream : not null access RST; Item : Boolean);
147 procedure W_C (Stream : not null access RST; Item : Character);
148 procedure W_F (Stream : not null access RST; Item : Float);
149 procedure W_I (Stream : not null access RST; Item : Integer);
150 procedure W_I24 (Stream : not null access RST; Item : Integer_24);
151 procedure W_LF (Stream : not null access RST; Item : Long_Float);
152 procedure W_LI (Stream : not null access RST; Item : Long_Integer);
153 procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float);
154 procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer);
155 procedure W_LLLI (Stream : not null access RST; Item :
156 Long_Long_Long_Integer);
157 procedure W_LLLU (Stream : not null access RST; Item :
158 UST.Long_Long_Long_Unsigned);
159 procedure W_LLU (Stream : not null access RST; Item :
160 UST.Long_Long_Unsigned);
161 procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned);
162 procedure W_SF (Stream : not null access RST; Item : Short_Float);
163 procedure W_SI (Stream : not null access RST; Item : Short_Integer);
164 procedure W_SSI (Stream : not null access RST; Item : Short_Short_Integer);
165 procedure W_SSU (Stream : not null access RST; Item :
166 UST.Short_Short_Unsigned);
167 procedure W_SU (Stream : not null access RST; Item : UST.Short_Unsigned);
168 procedure W_U (Stream : not null access RST; Item : UST.Unsigned);
169 procedure W_U24 (Stream : not null access RST; Item : Unsigned_24);
170 procedure W_WC (Stream : not null access RST; Item : Wide_Character);
171 procedure W_WWC (Stream : not null access RST; Item : Wide_Wide_Character);
173 function Block_IO_OK return Boolean;
174 -- Indicate whether the current setting supports block IO. See
175 -- System.Strings.Stream_Ops (s-ststop) for details on block IO.
177 private
178 pragma Inline (I_AD);
179 pragma Inline (I_AS);
180 pragma Inline (I_B);
181 pragma Inline (I_C);
182 pragma Inline (I_F);
183 pragma Inline (I_I);
184 pragma Inline (I_LF);
185 pragma Inline (I_LI);
186 pragma Inline (I_LLF);
187 pragma Inline (I_LLI);
188 pragma Inline (I_LLLI);
189 pragma Inline (I_LLLU);
190 pragma Inline (I_LLU);
191 pragma Inline (I_LU);
192 pragma Inline (I_SF);
193 pragma Inline (I_SI);
194 pragma Inline (I_SSI);
195 pragma Inline (I_SSU);
196 pragma Inline (I_SU);
197 pragma Inline (I_U);
198 pragma Inline (I_WC);
199 pragma Inline (I_WWC);
201 pragma Inline (W_AD);
202 pragma Inline (W_AS);
203 pragma Inline (W_B);
204 pragma Inline (W_C);
205 pragma Inline (W_F);
206 pragma Inline (W_I);
207 pragma Inline (W_LF);
208 pragma Inline (W_LI);
209 pragma Inline (W_LLF);
210 pragma Inline (W_LLI);
211 pragma Inline (W_LLLI);
212 pragma Inline (W_LLLU);
213 pragma Inline (W_LLU);
214 pragma Inline (W_LU);
215 pragma Inline (W_SF);
216 pragma Inline (W_SI);
217 pragma Inline (W_SSI);
218 pragma Inline (W_SSU);
219 pragma Inline (W_SU);
220 pragma Inline (W_U);
221 pragma Inline (W_WC);
222 pragma Inline (W_WWC);
224 pragma Inline (Block_IO_OK);
226 end System.Stream_Attributes;