-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
--- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T . --
--- O P E R A T I O N S --
+-- SYSTEM.INTERRUPT_MANAGEMENT.OPERATIONS --
-- --
-- B o d y --
-- --
-- Copyright (C) 1991-1994, Florida State University --
--- Copyright (C) 1995-2005, AdaCore --
+-- Copyright (C) 1995-2008, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- --
------------------------------------------------------------------------------
--- This is a POSIX-like version of this package.
--- Note: this file can only be used for POSIX compliant systems.
+-- This is a POSIX-like version of this package
+
+-- Note: this file can only be used for POSIX compliant systems
with Interfaces.C;
--- used for int
--- size_t
--- unsigned
with System.OS_Interface;
--- used for various type, constant, and operations
-
with System.Storage_Elements;
--- used for To_Address
--- Integer_Address
-
-with Unchecked_Conversion;
package body System.Interrupt_Management.Operations is
use Interfaces.C;
use System.OS_Interface;
- type Interrupt_Mask_Ptr is access all Interrupt_Mask;
-
- function "+" is new
- Unchecked_Conversion (Interrupt_Mask_Ptr, sigset_t_ptr);
-
---------------------
-- Local Variables --
---------------------
Initial_Action : array (Signal) of aliased struct_sigaction;
Default_Action : aliased struct_sigaction;
+ pragma Warnings (Off, Default_Action);
- Ignore_Action : aliased struct_sigaction;
+ Ignore_Action : aliased struct_sigaction;
----------------------------
-- Thread_Block_Interrupt --
pragma Assert (Result = 0);
Result := sigaddset (Mask'Access, Signal (Interrupt));
pragma Assert (Result = 0);
- Result := pthread_sigmask (SIG_BLOCK, Mask'Unchecked_Access, null);
+ Result := pthread_sigmask (SIG_BLOCK, Mask'Access, null);
pragma Assert (Result = 0);
end Thread_Block_Interrupt;
pragma Assert (Result = 0);
Result := sigaddset (Mask'Access, Signal (Interrupt));
pragma Assert (Result = 0);
- Result := pthread_sigmask (SIG_UNBLOCK, Mask'Unchecked_Access, null);
+ Result := pthread_sigmask (SIG_UNBLOCK, Mask'Access, null);
pragma Assert (Result = 0);
end Thread_Unblock_Interrupt;
------------------------
procedure Set_Interrupt_Mask (Mask : access Interrupt_Mask) is
- Result : Interfaces.C.int;
+ Result : Interfaces.C.int;
begin
- Result := pthread_sigmask
- (SIG_SETMASK, +Interrupt_Mask_Ptr (Mask), null);
+ Result := pthread_sigmask (SIG_SETMASK, Mask, null);
pragma Assert (Result = 0);
end Set_Interrupt_Mask;
is
Result : Interfaces.C.int;
begin
- Result := pthread_sigmask
- (SIG_SETMASK, +Interrupt_Mask_Ptr (Mask), +Interrupt_Mask_Ptr (OMask));
+ Result := pthread_sigmask (SIG_SETMASK, Mask, OMask);
pragma Assert (Result = 0);
end Set_Interrupt_Mask;
procedure Get_Interrupt_Mask (Mask : access Interrupt_Mask) is
Result : Interfaces.C.int;
begin
- Result := pthread_sigmask
- (SIG_SETMASK, null, +Interrupt_Mask_Ptr (Mask));
+ Result := pthread_sigmask (SIG_SETMASK, null, Mask);
pragma Assert (Result = 0);
end Get_Interrupt_Mask;
--------------------
function Interrupt_Wait
- (Mask : access Interrupt_Mask)
- return Interrupt_ID
+ (Mask : access Interrupt_Mask) return Interrupt_ID
is
Result : Interfaces.C.int;
Sig : aliased Signal;
+
begin
Result := sigwait (Mask, Sig'Access);
for Sig in 1 .. Signal'Last loop
Result := sigaction
- (Sig, null, Initial_Action (Sig)'Unchecked_Access);
+ (Sig, null, Initial_Action (Sig)'Access);
-- ??? [assert 1]
-- we can't check Result here since sigaction will fail on
end loop;
- -- Setup the masks to be exported.
+ -- Setup the masks to be exported
Result := sigemptyset (mask'Access);
pragma Assert (Result = 0);
(Storage_Elements.Integer_Address (SIG_IGN));
for J in Interrupt_ID loop
-
- -- We need to check whether J is in Keep_Unmasked because
- -- the index type of the Keep_Unmasked array is not always
- -- Interrupt_ID; it may be a subtype of Interrupt_ID.
-
- if J in Keep_Unmasked'Range and then Keep_Unmasked (J) then
+ if Keep_Unmasked (J) then
Result := sigaddset (mask'Access, Signal (J));
pragma Assert (Result = 0);
Result := sigdelset (allmask'Access, Signal (J));
-- The Keep_Unmasked signals should be unmasked for Environment task
- Result := pthread_sigmask (SIG_UNBLOCK, mask'Unchecked_Access, null);
+ Result := pthread_sigmask (SIG_UNBLOCK, mask'Access, null);
pragma Assert (Result = 0);
-- Get the signal mask of the Environment Task
- Result := pthread_sigmask (SIG_SETMASK, null, mask'Unchecked_Access);
+ Result := pthread_sigmask (SIG_SETMASK, null, mask'Access);
pragma Assert (Result = 0);
-- Setup the constants exported