OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [a-ststio.ads] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                A D A . S T R E A M S . S T R E A M _ I O                 --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- This specification is derived from the Ada Reference Manual for use with --
12
-- GNAT. The copyright notice above, and the license provisions that follow --
13
-- apply solely to the  contents of the part following the private keyword. --
14
--                                                                          --
15
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
16
-- terms of the  GNU General Public License as published  by the Free Soft- --
17
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
18
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
21
--                                                                          --
22
-- As a special exception under Section 7 of GPL version 3, you are granted --
23
-- additional permissions described in the GCC Runtime Library Exception,   --
24
-- version 3.1, as published by the Free Software Foundation.               --
25
--                                                                          --
26
-- You should have received a copy of the GNU General Public License and    --
27
-- a copy of the GCC Runtime Library Exception along with this program;     --
28
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
29
-- <http://www.gnu.org/licenses/>.                                          --
30
--                                                                          --
31
-- GNAT was originally developed  by the GNAT team at  New York University. --
32
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
33
--                                                                          --
34
------------------------------------------------------------------------------
35
 
36
with Ada.IO_Exceptions;
37
with System.File_Control_Block;
38
 
39
package Ada.Streams.Stream_IO is
40
 
41
   type Stream_Access is access all Root_Stream_Type'Class;
42
 
43
   type File_Type is limited private;
44
 
45
   type File_Mode is (In_File, Out_File, Append_File);
46
 
47
   --  The following representation clause allows the use of unchecked
48
   --  conversion for rapid translation between the File_Mode type
49
   --  used in this package and System.File_IO.
50
 
51
   for File_Mode use
52
     (In_File     => 0,  -- System.File_IO.File_Mode'Pos (In_File)
53
      Out_File    => 2,  -- System.File_IO.File_Mode'Pos (Out_File)
54
      Append_File => 3); -- System.File_IO.File_Mode'Pos (Append_File)
55
 
56
   type Count is new Stream_Element_Offset
57
     range 0 .. Stream_Element_Offset'Last;
58
 
59
   subtype Positive_Count is Count range 1 .. Count'Last;
60
   --  Index into file, in stream elements
61
 
62
   ---------------------
63
   -- File Management --
64
   ---------------------
65
 
66
   procedure Create
67
     (File : in out File_Type;
68
      Mode : File_Mode := Out_File;
69
      Name : String := "";
70
      Form : String := "");
71
 
72
   procedure Open
73
     (File : in out File_Type;
74
      Mode : File_Mode;
75
      Name : String;
76
      Form : String := "");
77
 
78
   procedure Close  (File : in out File_Type);
79
   procedure Delete (File : in out File_Type);
80
   procedure Reset  (File : in out File_Type; Mode : File_Mode);
81
   procedure Reset  (File : in out File_Type);
82
 
83
   function Mode (File : File_Type) return File_Mode;
84
   function Name (File : File_Type) return String;
85
   function Form (File : File_Type) return String;
86
 
87
   function Is_Open     (File : File_Type) return Boolean;
88
   function End_Of_File (File : File_Type) return Boolean;
89
 
90
   function Stream (File : File_Type) return Stream_Access;
91
 
92
   -----------------------------
93
   -- Input-Output Operations --
94
   -----------------------------
95
 
96
   procedure Read
97
     (File : File_Type;
98
      Item : out Stream_Element_Array;
99
      Last : out Stream_Element_Offset;
100
      From : Positive_Count);
101
 
102
   procedure Read
103
     (File : File_Type;
104
      Item : out Stream_Element_Array;
105
      Last : out Stream_Element_Offset);
106
 
107
   procedure Write
108
     (File : File_Type;
109
      Item : Stream_Element_Array;
110
      To   : Positive_Count);
111
 
112
   procedure Write
113
     (File : File_Type;
114
      Item : Stream_Element_Array);
115
 
116
   ----------------------------------------
117
   -- Operations on Position within File --
118
   ----------------------------------------
119
 
120
   procedure Set_Index (File : File_Type; To : Positive_Count);
121
 
122
   function Index (File : File_Type) return Positive_Count;
123
   function Size  (File : File_Type) return Count;
124
 
125
   procedure Set_Mode (File : in out File_Type; Mode : File_Mode);
126
 
127
   --  Note: The parameter file is IN OUT in the RM, but this is clearly
128
   --  an oversight, and was intended to be IN, see AI95-00057.
129
 
130
   procedure Flush (File : File_Type);
131
 
132
   ----------------
133
   -- Exceptions --
134
   ----------------
135
 
136
   Status_Error : exception renames IO_Exceptions.Status_Error;
137
   Mode_Error   : exception renames IO_Exceptions.Mode_Error;
138
   Name_Error   : exception renames IO_Exceptions.Name_Error;
139
   Use_Error    : exception renames IO_Exceptions.Use_Error;
140
   Device_Error : exception renames IO_Exceptions.Device_Error;
141
   End_Error    : exception renames IO_Exceptions.End_Error;
142
   Data_Error   : exception renames IO_Exceptions.Data_Error;
143
 
144
private
145
 
146
   --  The following procedures have a File_Type formal of mode IN OUT because
147
   --  they may close the original file. The Close operation may raise an
148
   --  exception, but in that case we want any assignment to the formal to
149
   --  be effective anyway, so it must be passed by reference (or the caller
150
   --  will be left with a dangling pointer).
151
 
152
   pragma Export_Procedure
153
     (Internal  => Close,
154
      External  => "",
155
      Mechanism => Reference);
156
   pragma Export_Procedure
157
     (Internal  => Delete,
158
      External  => "",
159
      Mechanism => Reference);
160
   pragma Export_Procedure
161
     (Internal        => Reset,
162
      External        => "",
163
      Parameter_Types => (File_Type),
164
      Mechanism       => Reference);
165
   pragma Export_Procedure
166
     (Internal        => Reset,
167
      External        => "",
168
      Parameter_Types => (File_Type, File_Mode),
169
      Mechanism       => (File => Reference));
170
   pragma Export_Procedure
171
     (Internal  => Set_Mode,
172
      External  => "",
173
      Mechanism => (File => Reference));
174
 
175
   package FCB renames System.File_Control_Block;
176
 
177
   -----------------------------
178
   -- Stream_IO Control Block --
179
   -----------------------------
180
 
181
   type Operation is (Op_Read, Op_Write, Op_Other);
182
   --  Type used to record last operation (to optimize sequential operations)
183
 
184
   type Stream_AFCB is new FCB.AFCB with record
185
      Index : Count := 1;
186
      --  Current Index value
187
 
188
      File_Size : Stream_Element_Offset := -1;
189
      --  Cached value of File_Size, so that we do not keep recomputing it
190
      --  when not necessary (otherwise End_Of_File becomes gruesomely slow).
191
      --  A value of minus one means that there is no cached value.
192
 
193
      Last_Op : Operation := Op_Other;
194
      --  Last operation performed on file, used to avoid unnecessary
195
      --  repositioning between successive read or write operations.
196
 
197
      Update_Mode : Boolean := False;
198
      --  Set if the mode is changed from write to read or vice versa.
199
      --  Indicates that the file has been reopened in update mode.
200
 
201
   end record;
202
 
203
   type File_Type is access all Stream_AFCB;
204
 
205
   function AFCB_Allocate (Control_Block : Stream_AFCB) return FCB.AFCB_Ptr;
206
 
207
   procedure AFCB_Close (File : not null access Stream_AFCB);
208
   procedure AFCB_Free  (File : not null access Stream_AFCB);
209
 
210
   procedure Read
211
     (File : in out Stream_AFCB;
212
      Item : out Ada.Streams.Stream_Element_Array;
213
      Last : out Ada.Streams.Stream_Element_Offset);
214
   --  Read operation used when Stream_IO file is treated directly as Stream
215
 
216
   procedure Write
217
     (File : in out Stream_AFCB;
218
      Item : Ada.Streams.Stream_Element_Array);
219
   --  Write operation used when Stream_IO file is treated directly as Stream
220
 
221
end Ada.Streams.Stream_IO;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.