-- POSIX_Poll_Poorly - Provide a rather simple binding specifically for the dumb poll functionality. -- Copyright (C) 2023 Prince Trippy . -- This program is free software: you can redistribute it and/or modify it under the terms of the -- GNU Affero General Public License version 3 as published by the Free Software Foundation. -- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without -- even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- See the GNU Affero General Public License for more details. -- You should have received a copy of the GNU Affero General Public License along with this program. -- If not, see . -- This library is designed to adhere to the requirements of Ada 1995, due entirely to Interfaces.C. with Interfaces.C; use Interfaces.C; -- Poll is much easier to model than Select, since Select uses many asinine text replacement macros. package POSIX_Poll_Poorly is -- Unlike the other libraries, this package exposes those C language types and whatnot, directly. -- While distasteful, converting a long array on every call is no reasonable option, and oh well. type Pollfd is record Socket : Int; Events, Read_Events : Unsigned_Short; end record; pragma Convention(Convention => C, Entity => Pollfd); -- I was going to name these Read, Send, Error, Closed, and Invalid respectively, but I care not. POLLIN : constant Unsigned_Short := 1; POLLOUT : constant Unsigned_Short := 4; POLLERR : constant Unsigned_Short := 8; POLLHUP : constant Unsigned_Short := 16; POLLNVAL : constant Unsigned_Short := 32; type Fds is array (Long range <>) of Pollfd; -- This array's index type could need to be changed. -- This call should only fail in the cases of EAGAIN or EINTR, thus one error generally suffices. procedure Poll (File_Descriptors : in out Fds; Milliseconds_Timeout : in Int; Count : out Int); Poll_Error : exception; end POSIX_Poll_Poorly; .