comp.lang.ada
 help / color / mirror / Atom feed
From: xorquewasp@googlemail.com
Subject: Representing errno in SPARK
Date: Tue, 9 Jun 2009 07:06:37 -0700 (PDT)
Date: 2009-06-09T07:06:37-07:00	[thread overview]
Message-ID: <95bb6d31-f4fe-47c9-9274-72382ffad7ba@j32g2000yqh.googlegroups.com> (raw)

What is the correct way to model a pair of subprograms
that affect state completely outside of the SPARK program?

Specifically, in this case, I have a procedure:

  procedure Errno_Set (Code : Integer);
  pragma Import (C, Errno_Set, "posix_errno_set");

And a function:

  function Errno_Get return Integer;
  pragma Import (C, Errno_Get, "posix_errno_get");

The problem in this case is that the C variable 'errno' that these
subprograms refer to is completely external to the program but
the value of the Errno_Get function depends on it and therefore
the execution path the program takes depends on it. Those
closest I can find in the SPARK95 manual is "external own variables"
but even then, the variables are actually objects within the program:

package body Device
--# own State is        OldX,       -- state variable constituent
--#              in     StatusPort, -- external variable constituent
--#                 out Register;   -- external variable constituent
is
  OldX : Integer := 0; -- only component that needs or permits
initialization

  StatusPort : Integer;
  for StatusPort’Address use .........;
  Register : Integer;
  for Register’Address use ..........;



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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09 14:06 xorquewasp [this message]
2009-06-09 14:32 ` Representing errno in SPARK roderick.chapman
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