Store Descriptors as `Natural` data types, since Interface.C.int will raise a Constraint_Error
I believe it's a valid assumption to say all file descriptors should be positive, non-zero integers
This commit is contained in:
parent
354a63c937
commit
d4a9b19359
|
@ -11,6 +11,10 @@ package body Epoll is
|
|||
begin
|
||||
Validate_Hub (This);
|
||||
|
||||
if Descriptor <= 0 then
|
||||
raise Invalid_Descriptor;
|
||||
end if;
|
||||
|
||||
Event.Events := EPOLLIN;
|
||||
Event.Data.Fd := Descriptor;
|
||||
|
||||
|
@ -24,7 +28,7 @@ package body Epoll is
|
|||
end if;
|
||||
end;
|
||||
|
||||
Callback_Registry.Insert (This.Callbacks, Descriptor, Cb);
|
||||
Callback_Registry.Insert (This.Callbacks, Natural(Descriptor), Cb);
|
||||
end Register;
|
||||
|
||||
procedure Run (This : in Hub) is
|
||||
|
|
|
@ -12,7 +12,7 @@ use Interfaces;
|
|||
package Epoll is
|
||||
type Callback is access procedure (Descriptor : C.int);
|
||||
-- My_Callback.all (Fd);
|
||||
package Callback_Registry is new Vectors (C.int, Callback);
|
||||
package Callback_Registry is new Vectors (Natural, Callback);
|
||||
|
||||
|
||||
type Hub is tagged private;
|
||||
|
@ -27,6 +27,7 @@ package Epoll is
|
|||
Hub_Create_Failed : exception;
|
||||
Hub_Invalid : exception;
|
||||
Descriptor_Registration_Falied : exception;
|
||||
Invalid_Descriptor : exception;
|
||||
|
||||
private
|
||||
use Interfaces.C;
|
||||
|
|
Loading…
Reference in New Issue