annotate gcc/ada/libgnat/s-direio.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . D I R E C T _ I O --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package contains the declaration of the control block used for
kono
parents:
diff changeset
33 -- Direct_IO. This must be declared at the outer library level. It also
kono
parents:
diff changeset
34 -- contains code that is shared between instances of Direct_IO.
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 with Interfaces.C_Streams;
kono
parents:
diff changeset
37 with Ada.Streams;
kono
parents:
diff changeset
38 with System.File_Control_Block;
kono
parents:
diff changeset
39 with System.Storage_Elements;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 package System.Direct_IO is
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 package FCB renames System.File_Control_Block;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 type Operation is (Op_Read, Op_Write, Op_Other);
kono
parents:
diff changeset
46 -- Type used to record last operation (to optimize sequential operations)
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 subtype Count is Interfaces.C_Streams.int64;
kono
parents:
diff changeset
49 -- The Count type in each instantiation is derived from this type
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 subtype Positive_Count is Count range 1 .. Count'Last;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 type Direct_AFCB is new FCB.AFCB with record
kono
parents:
diff changeset
54 Index : Count := 1;
kono
parents:
diff changeset
55 -- Current Index value
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 Bytes : Interfaces.C_Streams.size_t;
kono
parents:
diff changeset
58 -- Length of item in bytes (set from inside generic template)
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Last_Op : Operation := Op_Other;
kono
parents:
diff changeset
61 -- Last operation performed on file, used to avoid unnecessary
kono
parents:
diff changeset
62 -- repositioning between successive read or write operations.
kono
parents:
diff changeset
63 end record;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 function AFCB_Allocate (Control_Block : Direct_AFCB) return FCB.AFCB_Ptr;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 procedure AFCB_Close (File : not null access Direct_AFCB);
kono
parents:
diff changeset
68 procedure AFCB_Free (File : not null access Direct_AFCB);
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Read
kono
parents:
diff changeset
71 (File : in out Direct_AFCB;
kono
parents:
diff changeset
72 Item : out Ada.Streams.Stream_Element_Array;
kono
parents:
diff changeset
73 Last : out Ada.Streams.Stream_Element_Offset);
kono
parents:
diff changeset
74 -- Required overriding of Read, not actually used for Direct_IO
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Write
kono
parents:
diff changeset
77 (File : in out Direct_AFCB;
kono
parents:
diff changeset
78 Item : Ada.Streams.Stream_Element_Array);
kono
parents:
diff changeset
79 -- Required overriding of Write, not actually used for Direct_IO
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 type File_Type is access all Direct_AFCB;
kono
parents:
diff changeset
82 -- File_Type in individual instantiations is derived from this type
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 procedure Create
kono
parents:
diff changeset
85 (File : in out File_Type;
kono
parents:
diff changeset
86 Mode : FCB.File_Mode := FCB.Inout_File;
kono
parents:
diff changeset
87 Name : String := "";
kono
parents:
diff changeset
88 Form : String := "");
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function End_Of_File (File : File_Type) return Boolean;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 function Index (File : File_Type) return Positive_Count;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 procedure Open
kono
parents:
diff changeset
95 (File : in out File_Type;
kono
parents:
diff changeset
96 Mode : FCB.File_Mode;
kono
parents:
diff changeset
97 Name : String;
kono
parents:
diff changeset
98 Form : String := "");
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 procedure Read
kono
parents:
diff changeset
101 (File : File_Type;
kono
parents:
diff changeset
102 Item : System.Address;
kono
parents:
diff changeset
103 Size : Interfaces.C_Streams.size_t;
kono
parents:
diff changeset
104 From : Positive_Count);
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Read
kono
parents:
diff changeset
107 (File : File_Type;
kono
parents:
diff changeset
108 Item : System.Address;
kono
parents:
diff changeset
109 Size : Interfaces.C_Streams.size_t);
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Reset (File : in out File_Type; Mode : FCB.File_Mode);
kono
parents:
diff changeset
112 procedure Reset (File : in out File_Type);
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 procedure Set_Index (File : File_Type; To : Positive_Count);
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 function Size (File : File_Type) return Count;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Write
kono
parents:
diff changeset
119 (File : File_Type;
kono
parents:
diff changeset
120 Item : System.Address;
kono
parents:
diff changeset
121 Size : Interfaces.C_Streams.size_t;
kono
parents:
diff changeset
122 Zeroes : System.Storage_Elements.Storage_Array);
kono
parents:
diff changeset
123 -- Note: Zeroes is the buffer of zeroes used to fill out partial records
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -- The following procedures have a File_Type formal of mode IN OUT because
kono
parents:
diff changeset
126 -- they may close the original file. The Close operation may raise an
kono
parents:
diff changeset
127 -- exception, but in that case we want any assignment to the formal to
kono
parents:
diff changeset
128 -- be effective anyway, so it must be passed by reference (or the caller
kono
parents:
diff changeset
129 -- will be left with a dangling pointer).
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 pragma Export_Procedure
kono
parents:
diff changeset
132 (Internal => Reset,
kono
parents:
diff changeset
133 External => "",
kono
parents:
diff changeset
134 Parameter_Types => (File_Type),
kono
parents:
diff changeset
135 Mechanism => Reference);
kono
parents:
diff changeset
136 pragma Export_Procedure
kono
parents:
diff changeset
137 (Internal => Reset,
kono
parents:
diff changeset
138 External => "",
kono
parents:
diff changeset
139 Parameter_Types => (File_Type, FCB.File_Mode),
kono
parents:
diff changeset
140 Mechanism => (File => Reference));
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 end System.Direct_IO;