OSDN Git Service

Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-win32.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                        GNAT RUN-TIME COMPONENTS                          --
4 --                                                                          --
5 --                         S Y S T E M . W I N 3 2                          --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --            Copyright (C) 2009, 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 3,  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.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- GNAT was originally developed  by the GNAT team at  New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
29 --                                                                          --
30 ------------------------------------------------------------------------------
31
32 --  This package plus its child provide the low level interface to the Win32
33 --  API. The core part of the Win32 API (common to RTX and Win32) is in this
34 --  package, and an additional part of the Win32 API which is not supported by
35 --  RTX is in package System.Win33.Ext.
36
37 with Interfaces.C;
38
39 package System.Win32 is
40    pragma Pure;
41
42    -------------------
43    -- General Types --
44    -------------------
45
46    --  The LARGE_INTEGER type is actually a fixed point type
47    --  that only can represent integers. The reason for this is
48    --  easier conversion to Duration or other fixed point types.
49    --  (See Operations.Clock)
50
51    type LARGE_INTEGER is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
52
53    subtype PVOID is Address;
54
55    type HANDLE is new Interfaces.C.long;
56
57    INVALID_HANDLE_VALUE : constant HANDLE := -1;
58
59    type DWORD  is new Interfaces.C.unsigned_long;
60    type WORD   is new Interfaces.C.unsigned_short;
61    type BYTE   is new Interfaces.C.unsigned_char;
62    type LONG   is new Interfaces.C.long;
63    type CHAR   is new Interfaces.C.char;
64
65    type BOOL   is new Interfaces.C.int;
66    for BOOL'Size use Interfaces.C.int'Size;
67
68    type Bits1  is range 0 .. 2 ** 1 - 1;
69    type Bits2  is range 0 .. 2 ** 2 - 1;
70    type Bits17 is range 0 .. 2 ** 17 - 1;
71    for Bits1'Size  use 1;
72    for Bits2'Size  use 2;
73    for Bits17'Size use 17;
74
75    FALSE : constant := 0;
76    TRUE  : constant := 1;
77
78    function GetLastError return DWORD;
79    pragma Import (Stdcall, GetLastError, "GetLastError");
80
81    -----------
82    -- Files --
83    -----------
84
85    GENERIC_READ  : constant := 16#80000000#;
86    GENERIC_WRITE : constant := 16#40000000#;
87
88    CREATE_NEW        : constant := 1;
89    CREATE_ALWAYS     : constant := 2;
90    OPEN_EXISTING     : constant := 3;
91    OPEN_ALWAYS       : constant := 4;
92    TRUNCATE_EXISTING : constant := 5;
93
94    FILE_SHARE_DELETE : constant := 16#00000004#;
95    FILE_SHARE_READ   : constant := 16#00000001#;
96    FILE_SHARE_WRITE  : constant := 16#00000002#;
97
98    FILE_BEGIN        : constant := 0;
99    FILE_CURRENT      : constant := 1;
100    FILE_END          : constant := 2;
101
102    PAGE_NOACCESS       : constant := 16#0001#;
103    PAGE_READONLY       : constant := 16#0002#;
104    PAGE_READWRITE      : constant := 16#0004#;
105    PAGE_WRITECOPY      : constant := 16#0008#;
106    PAGE_EXECUTE        : constant := 16#0010#;
107
108    FILE_MAP_ALL_ACCESS : constant := 16#F001f#;
109    FILE_MAP_READ       : constant := 4;
110    FILE_MAP_WRITE      : constant := 2;
111    FILE_MAP_COPY       : constant := 1;
112
113    FILE_ADD_FILE             : constant := 16#0002#;
114    FILE_ADD_SUBDIRECTORY     : constant := 16#0004#;
115    FILE_APPEND_DATA          : constant := 16#0004#;
116    FILE_CREATE_PIPE_INSTANCE : constant := 16#0004#;
117    FILE_DELETE_CHILD         : constant := 16#0040#;
118    FILE_EXECUTE              : constant := 16#0020#;
119    FILE_LIST_DIRECTORY       : constant := 16#0001#;
120    FILE_READ_ATTRIBUTES      : constant := 16#0080#;
121    FILE_READ_DATA            : constant := 16#0001#;
122    FILE_READ_EA              : constant := 16#0008#;
123    FILE_TRAVERSE             : constant := 16#0020#;
124    FILE_WRITE_ATTRIBUTES     : constant := 16#0100#;
125    FILE_WRITE_DATA           : constant := 16#0002#;
126    FILE_WRITE_EA             : constant := 16#0010#;
127    STANDARD_RIGHTS_READ      : constant := 16#20000#;
128    STANDARD_RIGHTS_WRITE     : constant := 16#20000#;
129    SYNCHRONIZE               : constant := 16#100000#;
130
131    FILE_ATTRIBUTE_READONLY            : constant := 16#00000001#;
132    FILE_ATTRIBUTE_HIDDEN              : constant := 16#00000002#;
133    FILE_ATTRIBUTE_SYSTEM              : constant := 16#00000004#;
134    FILE_ATTRIBUTE_DIRECTORY           : constant := 16#00000010#;
135    FILE_ATTRIBUTE_ARCHIVE             : constant := 16#00000020#;
136    FILE_ATTRIBUTE_DEVICE              : constant := 16#00000040#;
137    FILE_ATTRIBUTE_NORMAL              : constant := 16#00000080#;
138    FILE_ATTRIBUTE_TEMPORARY           : constant := 16#00000100#;
139    FILE_ATTRIBUTE_SPARSE_FILE         : constant := 16#00000200#;
140    FILE_ATTRIBUTE_REPARSE_POINT       : constant := 16#00000400#;
141    FILE_ATTRIBUTE_COMPRESSED          : constant := 16#00000800#;
142    FILE_ATTRIBUTE_OFFLINE             : constant := 16#00001000#;
143    FILE_ATTRIBUTE_NOT_CONTENT_INDEXED : constant := 16#00002000#;
144    FILE_ATTRIBUTE_ENCRYPTED           : constant := 16#00004000#;
145    FILE_ATTRIBUTE_VALID_FLAGS         : constant := 16#00007fb7#;
146    FILE_ATTRIBUTE_VALID_SET_FLAGS     : constant := 16#000031a7#;
147
148    type OVERLAPPED is record
149       Internal     : DWORD;
150       InternalHigh : DWORD;
151       Offset       : DWORD;
152       OffsetHigh   : DWORD;
153       hEvent       : HANDLE;
154    end record;
155
156    type SECURITY_ATTRIBUTES is record
157       nLength             : DWORD;
158       pSecurityDescriptor : PVOID;
159       bInheritHandle      : BOOL;
160    end record;
161
162    function CreateFile
163      (lpFileName            : Address;
164       dwDesiredAccess       : DWORD;
165       dwShareMode           : DWORD;
166       lpSecurityAttributes  : access SECURITY_ATTRIBUTES;
167       dwCreationDisposition : DWORD;
168       dwFlagsAndAttributes  : DWORD;
169       hTemplateFile         : HANDLE) return HANDLE;
170    pragma Import (Stdcall, CreateFile, "CreateFileA");
171
172    function GetFileSize
173      (hFile          : HANDLE;
174       lpFileSizeHigh : access DWORD) return BOOL;
175    pragma Import (Stdcall, GetFileSize, "GetFileSize");
176
177    function SetFilePointer
178      (hFile                : HANDLE;
179       lDistanceToMove      : LONG;
180       lpDistanceToMoveHigh : access LONG;
181       dwMoveMethod         : DWORD) return DWORD;
182    pragma Import (Stdcall, SetFilePointer, "SetFilePointer");
183
184    function WriteFile
185      (hFile                  : HANDLE;
186       lpBuffer               : Address;
187       nNumberOfBytesToWrite  : DWORD;
188       lpNumberOfBytesWritten : access DWORD;
189       lpOverlapped           : access OVERLAPPED) return BOOL;
190    pragma Import (Stdcall, WriteFile, "WriteFile");
191
192    function ReadFile
193      (hFile                : HANDLE;
194       lpBuffer             : Address;
195       nNumberOfBytesToRead : DWORD;
196       lpNumberOfBytesRead  : access DWORD;
197       lpOverlapped         : access OVERLAPPED) return BOOL;
198    pragma Import (Stdcall, ReadFile, "ReadFile");
199
200    function CloseHandle (hObject : HANDLE) return BOOL;
201    pragma Import (Stdcall, CloseHandle, "CloseHandle");
202
203    function CreateFileMapping
204      (hFile                : HANDLE;
205       lpSecurityAttributes : access SECURITY_ATTRIBUTES;
206       flProtect            : DWORD;
207       dwMaximumSizeHigh    : DWORD;
208       dwMaximumSizeLow     : DWORD;
209       lpName               : Address) return HANDLE;
210    pragma Import (Stdcall, CreateFileMapping, "CreateFileMappingA");
211
212    function MapViewOfFile
213      (hFileMappingObject   : HANDLE;
214       dwDesiredAccess      : DWORD;
215       dwFileOffsetHigh     : DWORD;
216       dwFileOffsetLow      : DWORD;
217       dwNumberOfBytesToMap : DWORD) return System.Address;
218    pragma Import (Stdcall, MapViewOfFile, "MapViewOfFile");
219
220    function UnmapViewOfFile (lpBaseAddress : System.Address) return BOOL;
221    pragma Import (Stdcall, UnmapViewOfFile, "UnmapViewOfFile");
222
223    ------------------------
224    -- System Information --
225    ------------------------
226
227    subtype ProcessorId is DWORD;
228
229    type SYSTEM_INFO is record
230       dwOemId                     : DWORD;
231       dwPageSize                  : DWORD;
232       lpMinimumApplicationAddress : PVOID;
233       lpMaximumApplicationAddress : PVOID;
234       dwActiveProcessorMask       : DWORD;
235       dwNumberOfProcessors        : DWORD;
236       dwProcessorType             : DWORD;
237       dwAllocationGranularity     : DWORD;
238       dwReserved                  : DWORD;
239    end record;
240
241    procedure GetSystemInfo (SI : access SYSTEM_INFO);
242    pragma Import (Stdcall, GetSystemInfo, "GetSystemInfo");
243
244    ---------------------
245    -- Time Management --
246    ---------------------
247
248    type SYSTEMTIME is record
249       wYear         : WORD;
250       wMonth        : WORD;
251       wDayOfWeek    : WORD;
252       wDay          : WORD;
253       wHour         : WORD;
254       wMinute       : WORD;
255       wSecond       : WORD;
256       wMilliseconds : WORD;
257    end record;
258
259    procedure GetSystemTime (pSystemTime : access SYSTEMTIME);
260    pragma Import (Stdcall, GetSystemTime, "GetSystemTime");
261
262    procedure GetSystemTimeAsFileTime (lpFileTime : access Long_Long_Integer);
263    pragma Import (Stdcall, GetSystemTimeAsFileTime, "GetSystemTimeAsFileTime");
264
265    function FileTimeToSystemTime
266      (lpFileTime   : access Long_Long_Integer;
267       lpSystemTime : access SYSTEMTIME) return BOOL;
268    pragma Import (Stdcall, FileTimeToSystemTime, "FileTimeToSystemTime");
269
270    function SystemTimeToFileTime
271      (lpSystemTime : access SYSTEMTIME;
272       lpFileTime   : access Long_Long_Integer) return BOOL;
273    pragma Import (Stdcall, SystemTimeToFileTime, "SystemTimeToFileTime");
274
275    function FileTimeToLocalFileTime
276      (lpFileTime      : access Long_Long_Integer;
277       lpLocalFileTime : access Long_Long_Integer) return BOOL;
278    pragma Import (Stdcall, FileTimeToLocalFileTime, "FileTimeToLocalFileTime");
279
280    function LocalFileTimeToFileTime
281      (lpFileTime      : access Long_Long_Integer;
282       lpLocalFileTime : access Long_Long_Integer) return BOOL;
283    pragma Import (Stdcall, LocalFileTimeToFileTime, "LocalFileTimeToFileTime");
284
285    procedure Sleep (dwMilliseconds : DWORD);
286    pragma Import (Stdcall, Sleep, External_Name => "Sleep");
287
288    function QueryPerformanceCounter
289      (lpPerformanceCount : access LARGE_INTEGER) return BOOL;
290    pragma Import
291      (Stdcall, QueryPerformanceCounter, "QueryPerformanceCounter");
292
293 end System.Win32;