1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- G N A T . S O C K E T S . T H I N . S I G N A L L I N G _ F D S --
9 -- Copyright (C) 2001-2023, AdaCore --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- Portable sockets-based implementation of GNAT.Sockets.Thin.Signalling_Fds
33 -- used for platforms that do not support UNIX pipes.
35 -- Note: this code used to be in GNAT.Sockets, but has been moved to a
36 -- platform-specific file. It is now used only for non-UNIX platforms.
38 separate (GNAT
.Sockets
.Thin
)
39 package body Signalling_Fds
is
45 procedure Close
(Sig
: C
.int
) is
47 pragma Unreferenced
(Res
);
48 -- Res is assigned but never read, because we purposefully ignore
49 -- any error returned by the C_Close system call, as per the spec
59 function Create
(Fds
: not null access Fd_Pair
) return C
.int
is
60 Res
: constant C
.int
:=
61 C_Socketpair
(SOSC
.AF_INET
, SOSC
.SOCK_STREAM
, 0, Fds
);
63 if Res
/= Failure
then
64 -- Set TCP_NODELAY on Fds (Write_End), since we always want to send
65 -- the data out immediately.
68 (Socket
=> Socket_Type
(Fds
(Write_End
)),
69 Level
=> IP_Protocol_For_TCP_Level
,
70 Option
=> (Name
=> No_Delay
, Enabled
=> True));
80 function Read
(Rsig
: C
.int
) return C
.int
is
81 Buf
: aliased Character;
83 return C_Recv
(Rsig
, Buf
'Address, 1, SOSC
.MSG_Forced_Flags
);
90 function Write
(Wsig
: C
.int
) return C
.int
is
91 Buf
: aliased Character := ASCII
.NUL
;
94 (Wsig
, Buf
'Address, 1,
95 Flags
=> SOSC
.MSG_Forced_Flags
,
96 To
=> System
.Null_Address
,