OSDN Git Service

PR bootstrap/11932
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-direio.ads
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 --   Copyright (C) 1992,1993,1994,1995,1996 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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package contains the declaration of the control block used for
35 --  Direct_IO. This must be declared at the outer library level. It also
36 --  contains code that is shared between instances of Direct_IO.
37
38 with Interfaces.C_Streams;
39 with Ada.Streams;
40 with System.File_Control_Block;
41 with System.Storage_Elements;
42
43 package System.Direct_IO is
44
45    package FCB renames System.File_Control_Block;
46
47    type Operation is (Op_Read, Op_Write, Op_Other);
48    --  Type used to record last operation (to optimize sequential operations)
49
50    subtype Count is Interfaces.C_Streams.long;
51    --  The Count type in each instantiation is derived from this type
52
53    subtype Positive_Count is Count range 1 .. Count'Last;
54
55    type Direct_AFCB is new FCB.AFCB with record
56       Index : Count := 1;
57       --  Current Index value
58
59       Bytes : Interfaces.C_Streams.size_t;
60       --  Length of item in bytes (set from inside generic template)
61
62       Last_Op : Operation := Op_Other;
63       --  Last operation performed on file, used to avoid unnecessary
64       --  repositioning between successive read or write operations.
65    end record;
66
67    function AFCB_Allocate (Control_Block : Direct_AFCB) return FCB.AFCB_Ptr;
68
69    procedure AFCB_Close (File : access Direct_AFCB);
70    procedure AFCB_Free  (File : access Direct_AFCB);
71
72    procedure Read
73      (File : in out Direct_AFCB;
74       Item : out Ada.Streams.Stream_Element_Array;
75       Last : out Ada.Streams.Stream_Element_Offset);
76    --  Required overriding of Read, not actually used for Direct_IO
77
78    procedure Write
79      (File : in out Direct_AFCB;
80       Item : in Ada.Streams.Stream_Element_Array);
81    --  Required overriding of Write, not actually used for Direct_IO
82
83    type File_Type is access all Direct_AFCB;
84    --  File_Type in individual instantiations is derived from this type
85
86    procedure Create
87      (File : in out File_Type;
88       Mode : in FCB.File_Mode := FCB.Inout_File;
89       Name : in String := "";
90       Form : in String := "");
91
92    function End_Of_File (File : in File_Type) return Boolean;
93
94    function Index (File : in File_Type) return Positive_Count;
95
96    procedure Open
97      (File : in out File_Type;
98       Mode : in FCB.File_Mode;
99       Name : in String;
100       Form : in String := "");
101
102    procedure Read
103      (File : in File_Type;
104       Item : System.Address;
105       Size : in Interfaces.C_Streams.size_t;
106       From : in Positive_Count);
107
108    procedure Read
109      (File : in File_Type;
110       Item : System.Address;
111       Size : in Interfaces.C_Streams.size_t);
112
113    procedure Reset (File : in out File_Type; Mode : in FCB.File_Mode);
114
115    procedure Reset (File : in out File_Type);
116
117    procedure Set_Index (File : in File_Type; To : in Positive_Count);
118
119    function Size (File : in File_Type) return Count;
120
121    procedure Write
122      (File   : in File_Type;
123       Item   : System.Address;
124       Size   : in Interfaces.C_Streams.size_t;
125       Zeroes : System.Storage_Elements.Storage_Array);
126    --  Note: Zeroes is the buffer of zeroes used to fill out partial records
127
128 end System.Direct_IO;