Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
prove global state of timer client
Browse files Browse the repository at this point in the history
ref #164
  • Loading branch information
jklmnn committed Apr 24, 2020
1 parent f748543 commit 0c92318
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
17 changes: 11 additions & 6 deletions src/timer/client/gneiss-timer-client.ads
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-- This file is part of Gneiss, which is distributed under the terms of the
-- GNU Affero General Public License version 3.
--
with Gneiss_Internal;

generic
-- Timer event
Expand All @@ -23,7 +24,8 @@ is
procedure Initialize (C : in out Client_Session;
Cap : Capability;
Label : String;
Idx : Session_Index := 1);
Idx : Session_Index := 1) with
Global => (In_Out => Gneiss_Internal.Platform_State);

-- Returns a monotonic clock value
--
Expand All @@ -34,7 +36,8 @@ is
-- @return Current clock value
function Clock (C : Client_Session) return Time with
Volatile_Function,
Pre => Initialized (C);
Pre => Initialized (C),
Global => (Input => Gneiss_Internal.Platform_State);

-- Sets the timeout after which the Event procedure will be called
--
Expand All @@ -48,14 +51,16 @@ is
-- @param D Timeout event duration
procedure Set_Timeout (C : in out Client_Session;
D : Duration) with
Pre => Initialized (C)
and then D > 0.0,
Post => Initialized (C);
Pre => Initialized (C)
and then D > 0.0,
Post => Initialized (C),
Global => (In_Out => Gneiss_Internal.Platform_State);

-- Finalizes timer session
--
-- @param C Timer client session object
procedure Finalize (C : in out Client_Session) with
Post => not Initialized (C);
Post => not Initialized (C),
Global => (In_Out => Gneiss_Internal.Platform_State);

end Gneiss.Timer.Client;
12 changes: 8 additions & 4 deletions src/timer/client/linux/gneiss-timer-client.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

with System;
with Gneiss_Internal;
with Gneiss_Internal.Epoll;
with Gneiss_Internal.Syscall;
with Gneiss_Internal.Client;
Expand All @@ -24,18 +23,21 @@ is
D : Duration) with
Import,
Convention => C,
External_Name => "gneiss_timer_set";
External_Name => "gneiss_timer_set",
Global => (In_Out => Gneiss_Internal.Platform_State);

function Timer_Get (Fd : Gneiss_Internal.File_Descriptor) return Time with
Import,
Convention => C,
External_Name => "gneiss_timer_get",
Global => (Input => Gneiss_Internal.Platform_State),
Volatile_Function;

procedure Timer_Read (Fd : Gneiss_Internal.File_Descriptor) with
Import,
Convention => C,
External_Name => "gneiss_timer_read";
External_Name => "gneiss_timer_read",
Global => (In_Out => Gneiss_Internal.Platform_State);

function Event_Address (Session : Client_Session) return System.Address with
SPARK_Mode => Off
Expand Down Expand Up @@ -81,7 +83,9 @@ is
C.Index := Session_Index_Option'(Valid => True, Value => Idx);
end Initialize;

function Clock (C : Client_Session) return Time
function Clock (C : Client_Session) return Time with
SPARK_Mode => Off
-- Clock is not recognized as volatile even though Timer_Get is
is
begin
return Timer_Get (C.Fd);
Expand Down
10 changes: 8 additions & 2 deletions test/timer/component.adb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ with Gneiss.Timer.Client;
with Basalt.Strings;

package body Component with
SPARK_Mode
SPARK_Mode,
Refined_State => (Component_State => Capability,
Platform_State => (Log, Timer))
is
procedure Event;
procedure Event with
Global => (In_Out => (Log,
Gneiss_Internal.Platform_State,
Main.Platform),
Input => (Capability, Timer));

package Gneiss_Log is new Gneiss.Log;
package Gneiss_Timer is new Gneiss.Timer;
Expand Down
16 changes: 13 additions & 3 deletions test/timer/component.ads
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@

with Gneiss;
with Gneiss.Component;
with Gneiss_Internal;

package Component with
SPARK_Mode
SPARK_Mode,
Abstract_State => (Component_State, Platform_State),
Initializes => (Main.Platform, Platform_State)
is

procedure Construct (Cap : Gneiss.Capability);
procedure Destruct;
procedure Construct (Cap : Gneiss.Capability) with
Global => (Output => Component_State,
In_Out => (Platform_State,
Main.Platform,
Gneiss_Internal.Platform_State));

procedure Destruct with
Global => (In_Out => (Platform_State,
Gneiss_Internal.Platform_State));

package Main is new Gneiss.Component (Construct, Destruct);

Expand Down

0 comments on commit 0c92318

Please sign in to comment.