annotate gcc/ada/libgnat/g-socthi__mingw.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . S O C K E T S . T H I N --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 2001-2017, AdaCore --
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 provides a target dependent thin interface to the sockets
kono
parents:
diff changeset
33 -- layer for use by the GNAT.Sockets package (g-socket.ads). This package
kono
parents:
diff changeset
34 -- should not be directly with'ed by an applications program.
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- This version is for NT
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 with Interfaces.C;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 with GNAT.Sockets.Thin_Common;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 with System;
kono
parents:
diff changeset
43 with System.CRTL;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 package GNAT.Sockets.Thin is
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 use Thin_Common;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 package C renames Interfaces.C;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 function Socket_Errno return Integer;
kono
parents:
diff changeset
52 -- Returns last socket error number
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Set_Socket_Errno (Errno : Integer);
kono
parents:
diff changeset
55 -- Set last socket error number
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 function Socket_Error_Message (Errno : Integer) return String;
kono
parents:
diff changeset
58 -- Returns the error message string for the error number Errno. If Errno is
kono
parents:
diff changeset
59 -- not known, returns "Unknown system error".
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 function Host_Errno return Integer;
kono
parents:
diff changeset
62 pragma Import (C, Host_Errno, "__gnat_get_h_errno");
kono
parents:
diff changeset
63 -- Returns last host error number
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 package Host_Error_Messages is
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 function Host_Error_Message (H_Errno : Integer) return String;
kono
parents:
diff changeset
68 -- Returns the error message string for the host error number H_Errno.
kono
parents:
diff changeset
69 -- If H_Errno is not known, returns "Unknown system error".
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 end Host_Error_Messages;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 --------------------------------
kono
parents:
diff changeset
74 -- Standard library functions --
kono
parents:
diff changeset
75 --------------------------------
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 function C_Accept
kono
parents:
diff changeset
78 (S : C.int;
kono
parents:
diff changeset
79 Addr : System.Address;
kono
parents:
diff changeset
80 Addrlen : not null access C.int) return C.int;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function C_Bind
kono
parents:
diff changeset
83 (S : C.int;
kono
parents:
diff changeset
84 Name : System.Address;
kono
parents:
diff changeset
85 Namelen : C.int) return C.int;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 function C_Close
kono
parents:
diff changeset
88 (Fd : C.int) return C.int;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function C_Connect
kono
parents:
diff changeset
91 (S : C.int;
kono
parents:
diff changeset
92 Name : System.Address;
kono
parents:
diff changeset
93 Namelen : C.int) return C.int;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 function C_Gethostname
kono
parents:
diff changeset
96 (Name : System.Address;
kono
parents:
diff changeset
97 Namelen : C.int) return C.int;
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 function C_Getpeername
kono
parents:
diff changeset
100 (S : C.int;
kono
parents:
diff changeset
101 Name : System.Address;
kono
parents:
diff changeset
102 Namelen : not null access C.int) return C.int;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 function C_Getsockname
kono
parents:
diff changeset
105 (S : C.int;
kono
parents:
diff changeset
106 Name : System.Address;
kono
parents:
diff changeset
107 Namelen : not null access C.int) return C.int;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 function C_Getsockopt
kono
parents:
diff changeset
110 (S : C.int;
kono
parents:
diff changeset
111 Level : C.int;
kono
parents:
diff changeset
112 Optname : C.int;
kono
parents:
diff changeset
113 Optval : System.Address;
kono
parents:
diff changeset
114 Optlen : not null access C.int) return C.int;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 function Socket_Ioctl
kono
parents:
diff changeset
117 (S : C.int;
kono
parents:
diff changeset
118 Req : SOSC.IOCTL_Req_T;
kono
parents:
diff changeset
119 Arg : access C.int) return C.int;
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 function C_Listen
kono
parents:
diff changeset
122 (S : C.int;
kono
parents:
diff changeset
123 Backlog : C.int) return C.int;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 function C_Recv
kono
parents:
diff changeset
126 (S : C.int;
kono
parents:
diff changeset
127 Msg : System.Address;
kono
parents:
diff changeset
128 Len : C.int;
kono
parents:
diff changeset
129 Flags : C.int) return C.int;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 function C_Recvfrom
kono
parents:
diff changeset
132 (S : C.int;
kono
parents:
diff changeset
133 Msg : System.Address;
kono
parents:
diff changeset
134 Len : C.int;
kono
parents:
diff changeset
135 Flags : C.int;
kono
parents:
diff changeset
136 From : System.Address;
kono
parents:
diff changeset
137 Fromlen : not null access C.int) return C.int;
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 function C_Recvmsg
kono
parents:
diff changeset
140 (S : C.int;
kono
parents:
diff changeset
141 Msg : System.Address;
kono
parents:
diff changeset
142 Flags : C.int) return System.CRTL.ssize_t;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 function C_Select
kono
parents:
diff changeset
145 (Nfds : C.int;
kono
parents:
diff changeset
146 Readfds : access Fd_Set;
kono
parents:
diff changeset
147 Writefds : access Fd_Set;
kono
parents:
diff changeset
148 Exceptfds : access Fd_Set;
kono
parents:
diff changeset
149 Timeout : Timeval_Access) return C.int;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 function C_Sendmsg
kono
parents:
diff changeset
152 (S : C.int;
kono
parents:
diff changeset
153 Msg : System.Address;
kono
parents:
diff changeset
154 Flags : C.int) return System.CRTL.ssize_t;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function C_Sendto
kono
parents:
diff changeset
157 (S : C.int;
kono
parents:
diff changeset
158 Msg : System.Address;
kono
parents:
diff changeset
159 Len : C.int;
kono
parents:
diff changeset
160 Flags : C.int;
kono
parents:
diff changeset
161 To : System.Address;
kono
parents:
diff changeset
162 Tolen : C.int) return C.int;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 function C_Setsockopt
kono
parents:
diff changeset
165 (S : C.int;
kono
parents:
diff changeset
166 Level : C.int;
kono
parents:
diff changeset
167 Optname : C.int;
kono
parents:
diff changeset
168 Optval : System.Address;
kono
parents:
diff changeset
169 Optlen : C.int) return C.int;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 function C_Shutdown
kono
parents:
diff changeset
172 (S : C.int;
kono
parents:
diff changeset
173 How : C.int) return C.int;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 function C_Socket
kono
parents:
diff changeset
176 (Domain : C.int;
kono
parents:
diff changeset
177 Typ : C.int;
kono
parents:
diff changeset
178 Protocol : C.int) return C.int;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 function C_System
kono
parents:
diff changeset
181 (Command : System.Address) return C.int;
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 function WSAStartup
kono
parents:
diff changeset
184 (WS_Version : Interfaces.C.unsigned_short;
kono
parents:
diff changeset
185 WSADataAddress : System.Address) return Interfaces.C.int;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 -------------------------------------------------------
kono
parents:
diff changeset
188 -- Signalling file descriptors for selector abortion --
kono
parents:
diff changeset
189 -------------------------------------------------------
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 package Signalling_Fds is
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 function Create (Fds : not null access Fd_Pair) return C.int;
kono
parents:
diff changeset
194 pragma Convention (C, Create);
kono
parents:
diff changeset
195 -- Create a pair of connected descriptors suitable for use with C_Select
kono
parents:
diff changeset
196 -- (used for signalling in Selector objects).
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 function Read (Rsig : C.int) return C.int;
kono
parents:
diff changeset
199 pragma Convention (C, Read);
kono
parents:
diff changeset
200 -- Read one byte of data from rsig, the read end of a pair of signalling
kono
parents:
diff changeset
201 -- fds created by Create_Signalling_Fds.
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 function Write (Wsig : C.int) return C.int;
kono
parents:
diff changeset
204 pragma Convention (C, Write);
kono
parents:
diff changeset
205 -- Write one byte of data to wsig, the write end of a pair of signalling
kono
parents:
diff changeset
206 -- fds created by Create_Signalling_Fds.
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 procedure Close (Sig : C.int);
kono
parents:
diff changeset
209 pragma Convention (C, Close);
kono
parents:
diff changeset
210 -- Close one end of a pair of signalling fds (ignoring any error)
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 end Signalling_Fds;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 procedure WSACleanup;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 procedure Initialize;
kono
parents:
diff changeset
217 procedure Finalize;
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 private
kono
parents:
diff changeset
220 pragma Import (Stdcall, C_Accept, "accept");
kono
parents:
diff changeset
221 pragma Import (Stdcall, C_Bind, "bind");
kono
parents:
diff changeset
222 pragma Import (Stdcall, C_Close, "closesocket");
kono
parents:
diff changeset
223 pragma Import (Stdcall, C_Gethostname, "gethostname");
kono
parents:
diff changeset
224 pragma Import (Stdcall, C_Getpeername, "getpeername");
kono
parents:
diff changeset
225 pragma Import (Stdcall, C_Getsockname, "getsockname");
kono
parents:
diff changeset
226 pragma Import (Stdcall, C_Getsockopt, "getsockopt");
kono
parents:
diff changeset
227 pragma Import (Stdcall, C_Listen, "listen");
kono
parents:
diff changeset
228 pragma Import (Stdcall, C_Recv, "recv");
kono
parents:
diff changeset
229 pragma Import (Stdcall, C_Recvfrom, "recvfrom");
kono
parents:
diff changeset
230 pragma Import (Stdcall, C_Sendto, "sendto");
kono
parents:
diff changeset
231 pragma Import (Stdcall, C_Setsockopt, "setsockopt");
kono
parents:
diff changeset
232 pragma Import (Stdcall, C_Shutdown, "shutdown");
kono
parents:
diff changeset
233 pragma Import (Stdcall, C_Socket, "socket");
kono
parents:
diff changeset
234 pragma Import (C, C_System, "_system");
kono
parents:
diff changeset
235 pragma Import (Stdcall, Socket_Errno, "WSAGetLastError");
kono
parents:
diff changeset
236 pragma Import (Stdcall, Set_Socket_Errno, "WSASetLastError");
kono
parents:
diff changeset
237 pragma Import (Stdcall, WSAStartup, "WSAStartup");
kono
parents:
diff changeset
238 pragma Import (Stdcall, WSACleanup, "WSACleanup");
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 end GNAT.Sockets.Thin;