comp.lang.ada
 help / color / mirror / Atom feed
From: roderick.chapman@googlemail.com
Subject: Re: Representing errno in SPARK
Date: Tue, 9 Jun 2009 07:32:16 -0700 (PDT)
Date: 2009-06-09T07:32:16-07:00	[thread overview]
Message-ID: <8a00d4ad-0ca3-4908-abf0-4fa980decb19@o36g2000vbi.googlegroups.com> (raw)
In-Reply-To: 95bb6d31-f4fe-47c9-9274-72382ffad7ba@j32g2000yqh.googlegroups.com

On Jun 9, 3:06 pm, xorquew...@googlemail.com wrote:
> What is the correct way to model a pair of subprograms
> that affect state completely outside of the SPARK program?

Create an abstraction of that state as a SPARK abstract own
variable, thus:

package POSIX
--# own Errno;

  procedure Errno_Set (Code : Integer);
  --# global out Errno;
  --# derives Errno from Code;
  pragma Import (C, Errno_Set, "posix_errno_set");

  function Errno_Get return Integer;
  --# global in Errno;
  pragma Import (C, Errno_Get, "posix_errno_get");

end POSIX;

Notes

1) POSIX.Errno is _never_ actually declared in SPARK - it's
just an abstraction for something that is outside the
SPARK boundary.

2) do NOT use an external own variable for this - these
are for _volatile_ states, which Errno is not...

3) You should read the "Informed Design Method" manual
(Informed.pdf) that comes with the SPARK distibution.

 - Rod



  reply	other threads:[~2009-06-09 14:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09 14:06 Representing errno in SPARK xorquewasp
2009-06-09 14:32 ` roderick.chapman [this message]
2009-06-09 15:02   ` xorquewasp
2009-06-09 16:03     ` Phil Thornley
2009-06-09 16:11       ` xorquewasp
2009-06-09 17:26         ` Phil Thornley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox