FSF GCC merge 02/23/03
[official-gcc.git] / gcc / ada / s-direio.ads
blob60ed827d62de40b03f3894606943c069f1903813
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- S Y S T E M . D I R E C T _ I O --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This package contains the declaration of the control block used for
36 -- Direct_IO. This must be declared at the outer library level. It also
37 -- contains code that is shared between instances of Direct_IO.
39 with Interfaces.C_Streams;
40 with Ada.Streams;
41 with System.File_Control_Block;
42 with System.Storage_Elements;
44 package System.Direct_IO is
46 package FCB renames System.File_Control_Block;
48 type Operation is (Op_Read, Op_Write, Op_Other);
49 -- Type used to record last operation (to optimize sequential operations)
51 subtype Count is Interfaces.C_Streams.long;
52 -- The Count type in each instantiation is derived from this type
54 subtype Positive_Count is Count range 1 .. Count'Last;
56 type Direct_AFCB is new FCB.AFCB with record
57 Index : Count := 1;
58 -- Current Index value
60 Bytes : Interfaces.C_Streams.size_t;
61 -- Length of item in bytes (set from inside generic template)
63 Last_Op : Operation := Op_Other;
64 -- Last operation performed on file, used to avoid unnecessary
65 -- repositioning between successive read or write operations.
66 end record;
68 function AFCB_Allocate (Control_Block : Direct_AFCB) return FCB.AFCB_Ptr;
70 procedure AFCB_Close (File : access Direct_AFCB);
71 procedure AFCB_Free (File : access Direct_AFCB);
73 procedure Read
74 (File : in out Direct_AFCB;
75 Item : out Ada.Streams.Stream_Element_Array;
76 Last : out Ada.Streams.Stream_Element_Offset);
77 -- Required overriding of Read, not actually used for Direct_IO
79 procedure Write
80 (File : in out Direct_AFCB;
81 Item : in Ada.Streams.Stream_Element_Array);
82 -- Required overriding of Write, not actually used for Direct_IO
84 type File_Type is access all Direct_AFCB;
85 -- File_Type in individual instantiations is derived from this type
87 procedure Create
88 (File : in out File_Type;
89 Mode : in FCB.File_Mode := FCB.Inout_File;
90 Name : in String := "";
91 Form : in String := "");
93 function End_Of_File (File : in File_Type) return Boolean;
95 function Index (File : in File_Type) return Positive_Count;
97 procedure Open
98 (File : in out File_Type;
99 Mode : in FCB.File_Mode;
100 Name : in String;
101 Form : in String := "");
103 procedure Read
104 (File : in File_Type;
105 Item : System.Address;
106 Size : in Interfaces.C_Streams.size_t;
107 From : in Positive_Count);
109 procedure Read
110 (File : in File_Type;
111 Item : System.Address;
112 Size : in Interfaces.C_Streams.size_t);
114 procedure Reset (File : in out File_Type; Mode : in FCB.File_Mode);
116 procedure Reset (File : in out File_Type);
118 procedure Set_Index (File : in File_Type; To : in Positive_Count);
120 function Size (File : in File_Type) return Count;
122 procedure Write
123 (File : in File_Type;
124 Item : System.Address;
125 Size : in Interfaces.C_Streams.size_t;
126 Zeroes : System.Storage_Elements.Storage_Array);
127 -- Note: Zeroes is the buffer of zeroes used to fill out partial records
129 end System.Direct_IO;