annotate gcc/ada/libgnat/s-mmosin__unix.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 . M M A P . O S _ I N T E R F A C E --
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) 2007-2018, AdaCore --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- This library is free software; you can redistribute it and/or modify it --
kono
parents:
diff changeset
12 -- under terms of the GNU General Public License as published by the Free --
kono
parents:
diff changeset
13 -- Software Foundation; either version 3, or (at your option) any later --
kono
parents:
diff changeset
14 -- version. This library is distributed in the hope that it will be useful, --
kono
parents:
diff changeset
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
kono
parents:
diff changeset
16 -- TABILITY 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 with System.OS_Lib;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 -- OS pecularities abstraction package for Unix systems.
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package System.Mmap.OS_Interface is
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 type System_File is record
kono
parents:
diff changeset
39 Fd : System.OS_Lib.File_Descriptor;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 Mapped : Boolean;
kono
parents:
diff changeset
42 -- Whether mapping is requested by the user and available on the system
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 Write : Boolean;
kono
parents:
diff changeset
45 -- Whether this file can be written to
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 Length : File_Size;
kono
parents:
diff changeset
48 -- Length of the file. Used to know what can be mapped in the file
kono
parents:
diff changeset
49 end record;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 type System_Mapping is record
kono
parents:
diff changeset
52 Address : Standard.System.Address;
kono
parents:
diff changeset
53 Length : File_Size;
kono
parents:
diff changeset
54 end record;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 Invalid_System_File : constant System_File :=
kono
parents:
diff changeset
57 (System.OS_Lib.Invalid_FD, False, False, 0);
kono
parents:
diff changeset
58 Invalid_System_Mapping : constant System_Mapping :=
kono
parents:
diff changeset
59 (Standard.System.Null_Address, 0);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 function Open_Read
kono
parents:
diff changeset
62 (Filename : String;
kono
parents:
diff changeset
63 Use_Mmap_If_Available : Boolean := True) return System_File;
kono
parents:
diff changeset
64 -- Open a file for reading and return the corresponding System_File. Return
kono
parents:
diff changeset
65 -- Invalid_System_File if unsuccessful.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 function Open_Write
kono
parents:
diff changeset
68 (Filename : String;
kono
parents:
diff changeset
69 Use_Mmap_If_Available : Boolean := True) return System_File;
kono
parents:
diff changeset
70 -- Likewise for writing to a file
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 procedure Close (File : in out System_File);
kono
parents:
diff changeset
73 -- Close a system file
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Read_From_Disk
kono
parents:
diff changeset
76 (File : System_File;
kono
parents:
diff changeset
77 Offset, Length : File_Size) return System.Strings.String_Access;
kono
parents:
diff changeset
78 -- Read a fragment of a file. It is up to the caller to free the result
kono
parents:
diff changeset
79 -- when done with it.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure Write_To_Disk
kono
parents:
diff changeset
82 (File : System_File;
kono
parents:
diff changeset
83 Offset, Length : File_Size;
kono
parents:
diff changeset
84 Buffer : System.Strings.String_Access);
kono
parents:
diff changeset
85 -- Write some content to a fragment of a file
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Create_Mapping
kono
parents:
diff changeset
88 (File : System_File;
kono
parents:
diff changeset
89 Offset, Length : in out File_Size;
kono
parents:
diff changeset
90 Mutable : Boolean;
kono
parents:
diff changeset
91 Mapping : out System_Mapping);
kono
parents:
diff changeset
92 -- Create a memory mapping for the given File, for the area starting at
kono
parents:
diff changeset
93 -- Offset and containing Length bytes. Store it to Mapping.
kono
parents:
diff changeset
94 -- Note that Offset and Length may be modified according to the system
kono
parents:
diff changeset
95 -- needs (for boudaries, for instance). The caller must cope with actually
kono
parents:
diff changeset
96 -- wider mapped areas.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Dispose_Mapping
kono
parents:
diff changeset
99 (Mapping : in out System_Mapping);
kono
parents:
diff changeset
100 -- Unmap a previously-created mapping
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Get_Page_Size return File_Size;
kono
parents:
diff changeset
103 -- Return the number of bytes in a system page.
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 end System.Mmap.OS_Interface;