Disable tests for strdup/strndup on __hpux__
[official-gcc.git] / gcc / ada / libgnat / g-sopowa__mingw.adb
blobbe8f639a998741ca85828e75819fe448e009e916
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T . S O C K E T S . P O L L . W A I T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2020-2023, AdaCore --
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 ------------------------------------------------------------------------------
32 -- Wait implementation on top of Windows select call
34 -- Microsoft Windows from Vista version has WSAPoll function in API which is
35 -- similar to POSIX poll call, but experiments show that the WSAPoll is much
36 -- slower than select at least in Windows version 10.0.18363.1016.
38 with GNAT.Sockets.Poll.G_Wait;
40 separate (GNAT.Sockets.Poll)
42 procedure Wait
43 (Fds : in out Set; Timeout : Interfaces.C.int; Result : out Integer)
45 use Interfaces;
47 type FD_Array is array (1 .. Fds.Length) of FD_Type
48 with Convention => C;
50 type FD_Set_Type is record
51 Count : C.int;
52 Set : FD_Array;
53 end record with Convention => C;
55 procedure Reset_Socket_Set (Set : in out FD_Set_Type) with Inline;
57 procedure Insert_Socket_In_Set (Set : in out FD_Set_Type; FD : FD_Type)
58 with Inline;
60 function Is_Socket_In_Set (Set : FD_Set_Type; FD : FD_Type) return C.int
61 with Import, Convention => C,
62 External_Name => "__gnat_is_socket_in_set";
64 --------------------------
65 -- Insert_Socket_In_Set --
66 --------------------------
68 procedure Insert_Socket_In_Set (Set : in out FD_Set_Type; FD : FD_Type) is
69 begin
70 Set.Count := Set.Count + 1;
71 Set.Set (Integer (Set.Count)) := FD;
72 end Insert_Socket_In_Set;
74 ----------------------
75 -- Reset_Socket_Set --
76 ----------------------
78 procedure Reset_Socket_Set (Set : in out FD_Set_Type) is
79 begin
80 Set.Count := 0;
81 end Reset_Socket_Set;
83 ----------
84 -- Poll --
85 ----------
87 procedure Poll is new G_Wait
88 (FD_Set_Type, Reset_Socket_Set, Insert_Socket_In_Set, Is_Socket_In_Set);
90 begin
91 Poll (Fds, Timeout, Result);
92 end Wait;