Article View: src.ada
Article #2Re: sequential io with multiple types
From: David Emery
Date: Tue, 27 Oct 1992 17:02
Date: Tue, 27 Oct 1992 17:02
40 lines
2440 bytes
2440 bytes
One of the "extensions" provided by the IEEE P1003.5 POSIX Ada Binding
is the ability to associate an Ada file object with a given file
descriptor, through use of the FORM parameter on Create or Open. This
is important to achieve the "sharing" effects that John mentioned. In
POSIX, a file descriptor maps to the operating system's record of file
access (e.g. the current read/write position in the file.) POSIX/Ada
does not guarantee that you can get the "desired effect" by opening
two file objects mapped to the same file descriptor. This is due to
the possibility of internal file buffering by the Ada IO system. But,
if the Ada IO implementation does not do any additional buffering,
then this should work: (User must supply the appropriate names/types/etc
in <angle brackets>.)
with POSIX, POSIX_IO, Sequential_IO;
procedure demo is
fd : POSIX_IO.file_descriptor;
package SIO_one is new Sequential_IO (<type_one>);
package SIO_two is new Sequential_IO (<type_two>);
SIO_one_file : SIO_one.file_type;
SIO_two_file : SIO_two.file_type;
begin
fd := POSIX_IO.Open (name => <filename goes here>,
mode => POSIX_IO.write_only);
SIO_one.open (SIO_one_file,
form => "File_Descriptor => "
& POSIX_IO.file_descriptor'image(fd));
SIO_two.open (SIO_two_file,
form => "File_Descriptor => "
& POSIX_IO.file_descriptor'image(fd));
-- note that no NAME parameter is provided for the
-- Sequential_IO instantiation Open operations
-- now both Ada sequential file objects are associated with
-- the same underlying POSIX file descriptor.
SIO_one.put (SIO_one_file, <type one value>);
SIO_two.put (SIO_one_file, <type two value>);
end demo;
Yet another feature of POSIX/Ada...
dave
Technical Details
Message-ID:
<EMERY.92Oct27120202@Dr_No.mitre.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!linus!linus.mitre.org!linus!mbunix!emeryReferences:
<9210160237.AA26805@akela.src.honeywell.com> <1992Oct27.152146.17600@sei.cmu.edu>Show Full Headers
Complete Article Headers
Newsgroups: src.ada,comp.lang.ada Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!linus!linus.mitre.org!linus!mbunix!emery From: emery@Dr_No.mitre.org (David Emery) Subject: Re: sequential io with multiple types In-Reply-To: jbg@sei.cmu.edu's message of Tue, 27 Oct 1992 15:21:46 GMT Message-ID: <EMERY.92Oct27120202@Dr_No.mitre.org> Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: dr_no.mitre.org Organization: The Mitre Corp., Bedford, MA. References: <9210160237.AA26805@akela.src.honeywell.com> <1992Oct27.152146.17600@sei.cmu.edu> Date: Tue, 27 Oct 1992 17:02:02 GMT Lines: 40