]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/gnat_rm.texi
Merge from pch-branch up to tag pch-commit-20020603.
[thirdparty/gcc.git] / gcc / ada / gnat_rm.texi
CommitLineData
41af791f 1\input texinfo @c -*-texinfo-*-
41af791f
GB
2
3@c %**start of header
4
5@c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6@c o
7@c GNAT DOCUMENTATION o
8@c o
9@c G N A T _ RM o
10@c o
e2500fed 11@c $Revision: 1.3.8.1 $
41af791f 12@c o
ad42149c 13@c Copyright (C) 1995-2002 Free Software Foundation o
41af791f 14@c o
41af791f
GB
15@c o
16@c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
17@c o
18@c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
19
20@setfilename gnat_rm.info
21@settitle GNAT Reference Manual
22@setchapternewpage odd
23@syncodeindex fn cp
24
ad42149c
FW
25@dircategory GNU Ada tools
26@direntry
27* GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
28@end direntry
41af791f
GB
29@titlepage
30
31
32@title GNAT Reference Manual
33@subtitle GNAT, The GNU Ada 95 Compiler
ad42149c
FW
34@ifset vxworks
35@title Version 3.16w
36@end ifset
37@ifclear vxworks
38@subtitle Version 3.16w
39@end ifclear
41af791f
GB
40@author Ada Core Technologies, Inc.
41
42@page
43@vskip 0pt plus 1filll
44
45
ad42149c 46Copyright @copyright{} 1995-2001, Free Software Foundation
41af791f
GB
47
48Permission is granted to copy, distribute and/or modify this document
49under the terms of the GNU Free Documentation License, Version 1.1
50or any later version published by the Free Software Foundation;
51with the Invariant Sections being ``GNU Free Documentation License'', with the
52Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts.
53A copy of the license is included in the section entitled ``GNU
54Free Documentation License''.
55
41af791f
GB
56
57@end titlepage
ace133aa 58@ifnottex
41af791f
GB
59@node Top, About This Guide, (dir), (dir)
60@top GNAT Reference Manual
61
62
63GNAT Reference Manual
64
65GNAT, The GNU Ada 95 Compiler
66
ad42149c
FW
67@ifset vxworks
68Version 3.16w
69@end ifset
70@ifclear vxworks
71Version 3.16w
72@end ifclear
41af791f
GB
73
74Ada Core Technologies, Inc.
75
76
ad42149c 77Copyright @copyright{} 1995-2001, Free Software Foundation
41af791f
GB
78
79Permission is granted to copy, distribute and/or modify this document
80under the terms of the GNU Free Documentation License, Version 1.1
81or any later version published by the Free Software Foundation;
ad42149c
FW
82with the Invariant Sections being ``GNU Free Documentation License'', with the
83Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts.
84A copy of the license is included in the section entitled ``GNU
85Free Documentation License''.
41af791f 86
41af791f
GB
87
88@menu
89* About This Guide::
90* Implementation Defined Pragmas::
91* Implementation Defined Attributes::
92* Implementation Advice::
93* Implementation Defined Characteristics::
94* Intrinsic Subprograms::
95* Representation Clauses and Pragmas::
96* Standard Library Routines::
97* The Implementation of Standard I/O::
98* The GNAT Library::
99* Interfacing to Other Languages::
100* Machine Code Insertions::
101* GNAT Implementation of Tasking::
102* Code generation for array aggregates::
103* Specialized Needs Annexes::
104* Compatibility Guide::
105* GNU Free Documentation License::
106* Index::
107
108 --- The Detailed Node Listing ---
109
110About This Guide
111
112* What This Reference Manual Contains::
113* Related Information::
114
115The Implementation of Standard I/O
116
117* Standard I/O Packages::
118* FORM Strings::
119* Direct_IO::
120* Sequential_IO::
121* Text_IO::
122* Wide_Text_IO::
123* Stream_IO::
124* Shared Files::
125* Open Modes::
126* Operations on C Streams::
127* Interfacing to C Streams::
128
129The GNAT Library
130
ad42149c 131* Ada.Characters.Latin_9 (a-chlat9.ads)::
41af791f 132* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
ad42149c 133* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
41af791f
GB
134* Ada.Command_Line.Remove (a-colire.ads)::
135* Ada.Direct_IO.C_Streams (a-diocst.ads)::
136* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
137* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
138* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
139* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
140* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
141* Ada.Text_IO.C_Streams (a-tiocst.ads)::
142* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
143* GNAT.AWK (g-awk.ads)::
144* GNAT.Bubble_Sort_A (g-busora.ads)::
145* GNAT.Bubble_Sort_G (g-busorg.ads)::
146* GNAT.Calendar (g-calend.ads)::
147* GNAT.Calendar.Time_IO (g-catiio.ads)::
148* GNAT.Case_Util (g-casuti.ads)::
149* GNAT.CGI (g-cgi.ads)::
150* GNAT.CGI.Cookie (g-cgicoo.ads)::
151* GNAT.CGI.Debug (g-cgideb.ads)::
152* GNAT.Command_Line (g-comlin.ads)::
153* GNAT.CRC32 (g-crc32.ads)::
154* GNAT.Current_Exception (g-curexc.ads)::
155* GNAT.Debug_Pools (g-debpoo.ads)::
156* GNAT.Debug_Utilities (g-debuti.ads)::
157* GNAT.Directory_Operations (g-dirope.ads)::
158* GNAT.Dynamic_Tables (g-dyntab.ads)::
159* GNAT.Exception_Traces (g-exctra.ads)::
160* GNAT.Expect (g-expect.ads)::
161* GNAT.Float_Control (g-flocon.ads)::
162* GNAT.Heap_Sort_A (g-hesora.ads)::
163* GNAT.Heap_Sort_G (g-hesorg.ads)::
164* GNAT.HTable (g-htable.ads)::
165* GNAT.IO (g-io.ads)::
166* GNAT.IO_Aux (g-io_aux.ads)::
167* GNAT.Lock_Files (g-locfil.ads)::
ad42149c 168* GNAT.MD5 (g-md5.ads)::
41af791f
GB
169* GNAT.Most_Recent_Exception (g-moreex.ads)::
170* GNAT.OS_Lib (g-os_lib.ads)::
171* GNAT.Regexp (g-regexp.ads)::
172* GNAT.Registry (g-regist.ads)::
173* GNAT.Regpat (g-regpat.ads)::
174* GNAT.Sockets (g-socket.ads)::
175* GNAT.Source_Info (g-souinf.ads)::
176* GNAT.Spell_Checker (g-speche.ads)::
177* GNAT.Spitbol.Patterns (g-spipat.ads)::
178* GNAT.Spitbol (g-spitbo.ads)::
179* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
180* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
181* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
182* GNAT.Table (g-table.ads)::
183* GNAT.Task_Lock (g-tasloc.ads)::
184* GNAT.Threads (g-thread.ads)::
185* GNAT.Traceback (g-traceb.ads)::
186* GNAT.Traceback.Symbolic (g-trasym.ads)::
187* Interfaces.C.Extensions (i-cexten.ads)::
188* Interfaces.C.Streams (i-cstrea.ads)::
189* Interfaces.CPP (i-cpp.ads)::
190* Interfaces.Os2lib (i-os2lib.ads)::
191* Interfaces.Os2lib.Errors (i-os2err.ads)::
192* Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
193* Interfaces.Os2lib.Threads (i-os2thr.ads)::
194* Interfaces.Packed_Decimal (i-pacdec.ads)::
195* Interfaces.VxWorks (i-vxwork.ads)::
ad42149c 196* Interfaces.VxWorks.IO (i-vxwoio.ads)::
41af791f
GB
197* System.Address_Image (s-addima.ads)::
198* System.Assertions (s-assert.ads)::
199* System.Partition_Interface (s-parint.ads)::
200* System.Task_Info (s-tasinf.ads)::
201* System.Wch_Cnv (s-wchcnv.ads)::
202* System.Wch_Con (s-wchcon.ads)::
203
204Text_IO
205
206* Text_IO Stream Pointer Positioning::
207* Text_IO Reading and Writing Non-Regular Files::
208* Get_Immediate::
209* Treating Text_IO Files as Streams::
210* Text_IO Extensions::
211* Text_IO Facilities for Unbounded Strings::
212
213Wide_Text_IO
214
215* Wide_Text_IO Stream Pointer Positioning::
216* Wide_Text_IO Reading and Writing Non-Regular Files::
217
218Interfacing to Other Languages
219
220* Interfacing to C::
221* Interfacing to C++::
222* Interfacing to COBOL::
223* Interfacing to Fortran::
224* Interfacing to non-GNAT Ada code::
225
226GNAT Implementation of Tasking
227
228* Mapping Ada Tasks onto the Underlying Kernel Threads::
229* Ensuring Compliance with the Real-Time Annex::
230@end menu
231
ace133aa 232@end ifnottex
41af791f
GB
233
234@node About This Guide
235@unnumbered About This Guide
236
237@noindent
238This manual contains useful information in writing programs using the
ad42149c 239GNAT compiler. It includes information on implementation dependent
41af791f
GB
240characteristics of GNAT, including all the information required by Annex
241M of the standard.
242
243Ada 95 is designed to be highly portable,and guarantees that, for most
244programs, Ada 95 compilers behave in exactly the same manner on
ad42149c 245different machines. However, since Ada 95 is designed to be used in a
41af791f 246wide variety of applications, it also contains a number of system
ad42149c 247dependent features to Functbe used in interfacing to the external world.
41af791f
GB
248
249@c Maybe put the following in platform-specific section
250@ignore
251@cindex ProDev Ada
252This reference manual discusses how these features are implemented for
253use in ProDev Ada running on the IRIX 5.3 or greater operating systems.
254@end ignore
255
256@cindex Implementation-dependent features
257@cindex Portability
258Note: Any program that makes use of implementation-dependent features
259may be non-portable. You should follow good programming practice and
260isolate and clearly document any sections of your program that make use
261of these features in a non-portable manner.
262
263@menu
264* What This Reference Manual Contains::
265* Conventions::
266* Related Information::
267@end menu
268
269@node What This Reference Manual Contains
270@unnumberedsec What This Reference Manual Contains
271
272This reference manual contains the following chapters:
273
274@itemize @bullet
275@item
276@ref{Implementation Defined Pragmas} lists GNAT implementation-dependent
277pragmas, which can be used to extend and enhance the functionality of the
278compiler.
279
280@item
281@ref{Implementation Defined Attributes} lists GNAT
282implementation-dependent attributes which can be used to extend and
283enhance the functionality of the compiler.
284
285@item
286@ref{Implementation Advice} provides information on generally
287desirable behavior which are not requirements that all compilers must
288follow since it cannot be provided on all systems, or which may be
289undesirable on some systems.
290
291@item
292@ref{Implementation Defined Characteristics} provides a guide to
293minimizing implementation dependent features.
294
295@item
296@ref{Intrinsic Subprograms} describes the intrinsic subprograms
297implemented by GNAT, and how they can be imported into user
298application programs.
299
300@item
301@ref{Representation Clauses and Pragmas} describes in detail the
302way that GNAT represents data, and in particular the exact set
303of representation clauses and pragmas that is accepted.
304
305@item
306@ref{Standard Library Routines} provides a listing of packages and a
307brief description of the functionality that is provided by Ada's
46b58b8c 308extensive set of standard library routines as implemented by GNAT@.
41af791f
GB
309
310@item
311@ref{The Implementation of Standard I/O} details how the GNAT
312implementation of the input-output facilities.
313
314@item
315@ref{Interfacing to Other Languages} describes how programs
316written in Ada using GNAT can be interfaced to other programming
317languages.
318
319@item
320@ref{Specialized Needs Annexes} describes the GNAT implementation of all
321of the special needs annexes.
322
323@item
324@ref{Compatibility Guide} includes sections on compatibility of GNAT with
325other Ada 83 and Ada 95 compilation systems, to assist in porting code
326from other environments.
327@end itemize
328
329@cindex Ada 95 ISO/ANSI Standard
330This reference manual assumes that you are familiar with Ada 95
331language, as described in the International Standard
332ANSI/ISO/IEC-8652:1995, Jan 1995.
333
334@node Conventions
335@unnumberedsec Conventions
336@cindex Conventions, typographical
337@cindex Typographical conventions
338
339@noindent
340Following are examples of the typographical and graphic conventions used
341in this guide:
342
343@itemize @bullet
344@item
345@code{Functions}, @code{utility program names}, @code{standard names},
346and @code{classes}.
347
348@item
ad42149c 349@code{Option flags}
41af791f
GB
350
351@item
ad42149c 352@file{File Names}, @samp{button names}, and @samp{field names}.
41af791f
GB
353
354@item
ad42149c 355@code{Variables}.
41af791f
GB
356
357@item
358@emph{Emphasis}.
359
360@item
361[optional information or parameters]
362
363@item
364Examples are described by text
365@smallexample
366and then shown this way.
367@end smallexample
368@end itemize
369
370@noindent
371Commands that are entered by the user are preceded in this manual by the
ad42149c 372characters @samp{$ } (dollar sign followed by space). If your system uses this
41af791f 373sequence as a prompt, then the commands will appear exactly as you see them
ad42149c
FW
374in the manual. If your system uses some other prompt, then the command will
375appear with the @samp{$} replaced by whatever prompt character you are using.
41af791f
GB
376
377@node Related Information
378@unnumberedsec Related Information
ad42149c 379See the following documents for further information on GNAT:
41af791f
GB
380
381@itemize @bullet
382@item
383@cite{GNAT User's Guide}, which provides information on how to use
384the GNAT compiler system.
385
386@item
387@cite{Ada 95 Reference Manual}, which contains all reference
388material for the Ada 95 programming language.
389
390@item
391@cite{Ada 95 Annotated Reference Manual}, which is an annotated version
ad42149c 392of the standard reference manual cited above. The annotations describe
41af791f
GB
393detailed aspects of the design decision, and in particular contain useful
394sections on Ada 83 compatibility.
395
396@item
397@cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
398which contains specific information on compatibility between GNAT and
399DEC Ada 83 systems.
400
401@item
402@cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
403describes in detail the pragmas and attributes provided by the DEC Ada 83
404compiler system.
405
406@end itemize
407
408@node Implementation Defined Pragmas
409@chapter Implementation Defined Pragmas
410
411@noindent
412Ada 95 defines a set of pragmas that can be used to supply additional
ad42149c 413information to the compiler. These language defined pragmas are
41af791f
GB
414implemented in GNAT and work as described in the Ada 95 Reference
415Manual.
416
417In addition, Ada 95 allows implementations to define additional pragmas
ad42149c 418whose meaning is defined by the implementation. GNAT provides a number
41af791f 419of these implementation-dependent pragmas which can be used to extend
ad42149c 420and enhance the functionality of the compiler. This section of the GNAT
41af791f
GB
421Reference Manual describes these additional pragmas.
422
423Note that any program using these pragmas may not be portable to other
424compilers (although GNAT implements this set of pragmas on all
ad42149c 425platforms). Therefore if portability to other compilers is an important
41af791f
GB
426consideration, the use of these pragmas should be minimized.
427
428@table @code
429
430@findex Abort_Defer
431@cindex Deferring aborts
432@item pragma Abort_Defer
433@noindent
434Syntax:
435
436@smallexample
437pragma Abort_Defer;
438@end smallexample
439
440@noindent
441This pragma must appear at the start of the statement sequence of a
ad42149c 442handled sequence of statements (right after the @code{begin}). It has
41af791f
GB
443the effect of deferring aborts for the sequence of statements (but not
444for the declarations or handlers, if any, associated with this statement
445sequence).
446
447@item pragma Ada_83
448@findex Ada_83
449@noindent
450Syntax:
451
452@smallexample
453pragma Ada_83;
454@end smallexample
455
456@noindent
457A configuration pragma that establishes Ada 83 mode for the unit to
458which it applies, regardless of the mode set by the command line
ad42149c 459switches. In Ada 83 mode, GNAT attempts to be as compatible with
41af791f 460the syntax and semantics of Ada 83, as defined in the original Ada
ad42149c 46183 Reference Manual as possible. In particular, the new Ada 95
41af791f
GB
462keywords are not recognized, optional package bodies are allowed,
463and generics may name types with unknown discriminants without using
ad42149c 464the @code{(<>)} notation. In addition, some but not all of the additional
41af791f
GB
465restrictions of Ada 83 are enforced.
466
ad42149c 467Ada 83 mode is intended for two purposes. Firstly, it allows existing
41af791f
GB
468legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
469Secondly, it aids in keeping code backwards compatible with Ada 83.
470However, there is no guarantee that code that is processed correctly
471by GNAT in Ada 83 mode will in fact compile and execute with an Ada
47283 compiler, since GNAT does not enforce all the additional checks
473required by Ada 83.
474
475@findex Ada_95
476@item pragma Ada_95
477@noindent
478Syntax:
479
480@smallexample
481pragma Ada_95;
482@end smallexample
483
484@noindent
485A configuration pragma that establishes Ada 95 mode for the unit to which
486it applies, regardless of the mode set by the command line switches.
487This mode is set automatically for the @code{Ada} and @code{System}
488packages and their children, so you need not specify it in these
ad42149c 489contexts. This pragma is useful when writing a reusable component that
41af791f
GB
490itself uses Ada 95 features, but which is intended to be usable from
491either Ada 83 or Ada 95 programs.
492
493@findex Annotate
494@item pragma Annotate
495@noindent
496Syntax:
497
498@smallexample
499pragma Annotate (IDENTIFIER @{, ARG@});
500
501ARG ::= NAME | EXPRESSION
502@end smallexample
503
504@noindent
ad42149c
FW
505This pragma is used to annotate programs. @var{identifier} identifies
506the type of annotation. GNAT verifies this is an identifier, but does
507not otherwise analyze it. The @var{arg} argument
41af791f 508can be either a string literal or an
ad42149c
FW
509expression. String literals are assumed to be of type
510@code{Standard.String}. Names of entities are simply analyzed as entity
511names. All other expressions are analyzed as expressions, and must be
41af791f
GB
512unambiguous.
513
514The analyzed pragma is retained in the tree, but not otherwise processed
ad42149c 515by any part of the GNAT compiler. This pragma is intended for use by
46b58b8c 516external tools, including ASIS@.
41af791f
GB
517
518@findex Assert
519@item pragma Assert
520@noindent
521Syntax:
522
523@smallexample
524pragma Assert (
525 boolean_EXPRESSION
526 [, static_string_EXPRESSION])
527@end smallexample
528
529@noindent
530The effect of this pragma depends on whether the corresponding command
ad42149c 531line switch is set to activate assertions. The pragma expands into code
41af791f
GB
532equivalent to the following:
533
534@smallexample
535if assertions-enabled then
536 if not boolean_EXPRESSION then
537 System.Assertions.Raise_Assert_Failure
538 (string_EXPRESSION);
539 end if;
540end if;
541@end smallexample
542
543@noindent
544The string argument, if given, is the message that will be associated
ad42149c 545with the exception occurrence if the exception is raised. If no second
41af791f
GB
546argument is given, the default message is @samp{@var{file}:@var{nnn}},
547where @var{file} is the name of the source file containing the assert,
ad42149c 548and @var{nnn} is the line number of the assert. A pragma is not a
41af791f
GB
549statement, so if a statement sequence contains nothing but a pragma
550assert, then a null statement is required in addition, as in:
551
552@smallexample
ad42149c 553@dots{}
41af791f
GB
554if J > 3 then
555 pragma Assert (K > 3, "Bad value for K");
556 null;
557end if;
558@end smallexample
559
560@noindent
ad42149c
FW
561Note that, as with the @code{if} statement to which it is equivalent, the
562type of the expression is either @code{Standard.Boolean}, or any type derived
41af791f
GB
563from this standard type.
564
565If assertions are disabled (switch @code{-gnata} not used), then there
566is no effect (and in particular, any side effects from the expression
ad42149c 567are suppressed). More precisely it is not quite true that the pragma
41af791f
GB
568has no effect, since the expression is analyzed, and may cause types
569to be frozen if they are mentioned here for the first time.
570
571If assertions are enabled, then the given expression is tested, and if
ad42149c
FW
572it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
573which results in the raising of @code{Assert_Failure} with the given message.
41af791f
GB
574
575If the boolean expression has side effects, these side effects will turn
576on and off with the setting of the assertions mode, resulting in
ad42149c
FW
577assertions that have an effect on the program. You should generally
578avoid side effects in the expression arguments of this pragma. However,
41af791f
GB
579the expressions are analyzed for semantic correctness whether or not
580assertions are enabled, so turning assertions on and off cannot affect
581the legality of a program.
582
583@cindex OpenVMS
584@findex Ast_Entry
585@item pragma Ast_Entry
586@noindent
587Syntax:
588
589@smallexample
590pragma AST_Entry (entry_IDENTIFIER);
591@end smallexample
592
593@noindent
ad42149c 594This pragma is implemented only in the OpenVMS implementation of GNAT@. The
41af791f 595argument is the simple name of a single entry; at most one @code{AST_Entry}
ad42149c 596pragma is allowed for any given entry. This pragma must be used in
41af791f
GB
597conjunction with the @code{AST_Entry} attribute, and is only allowed after
598the entry declaration and in the same task type specification or single task
ad42149c 599as the entry to which it applies. This pragma specifies that the given entry
41af791f 600may be used to handle an OpenVMS asynchronous system trap (@code{AST})
ad42149c
FW
601resulting from an OpenVMS system service call. The pragma does not affect
602normal use of the entry. For further details on this pragma, see the
41af791f
GB
603DEC Ada Language Reference Manual, section 9.12a.
604
605@cindex Passing by copy
606@findex C_Pass_By_Copy
607@item pragma C_Pass_By_Copy
608@noindent
609Syntax:
610
611@smallexample
612pragma C_Pass_By_Copy
613 ([Max_Size =>] static_integer_EXPRESSION);
614@end smallexample
615
616@noindent
617Normally the default mechanism for passing C convention records to C
618convention subprograms is to pass them by reference, as suggested by RM
ad42149c 619B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
41af791f
GB
620this default, by requiring that record formal parameters be passed by
621copy if all of the following conditions are met:
622
623@itemize @bullet
624@item
625The size of the record type does not exceed@*@var{static_integer_expression}.
626@item
627The record type has @code{Convention C}.
628@item
629The formal parameter has this record type, and the subprogram has a
630foreign (non-Ada) convention.
631@end itemize
632
633@noindent
46b58b8c 634If these conditions are met the argument is passed by copy, i.e.@: in a
41af791f
GB
635manner consistent with what C expects if the corresponding formal in the
636C prototype is a struct (rather than a pointer to a struct).
637
638You can also pass records by copy by specifying the convention
639@code{C_Pass_By_Copy} for the record type, or by using the extended
640@code{Import} and @code{Export} pragmas, which allow specification of
641passing mechanisms on a parameter by parameter basis.
642
643@findex Comment
644@item pragma Comment
645@noindent
646Syntax:
647
648@smallexample
649pragma Comment (static_string_EXPRESSION);
650@end smallexample
651
652@noindent
ad42149c 653This is almost identical in effect to pragma @code{Ident}. It allows the
41af791f 654placement of a comment into the object file and hence into the
ad42149c
FW
655executable file if the operating system permits such usage. The
656difference is that @code{Comment}, unlike @code{Ident}, has no limit on the
41af791f
GB
657length of the string argument, and no limitations on placement
658of the pragma (it can be placed anywhere in the main source unit).
659
660@findex Common_Object
661@item pragma Common_Object
662@noindent
663Syntax:
664
665@smallexample
666pragma Common_Object (
667 [Internal =>] LOCAL_NAME,
668 [, [External =>] EXTERNAL_SYMBOL]
669 [, [Size =>] EXTERNAL_SYMBOL] )
670
671EXTERNAL_SYMBOL ::=
672 IDENTIFIER
673| static_string_EXPRESSION
674@end smallexample
675
676@noindent
677This pragma enables the shared use of variables stored in overlaid
678linker areas corresponding to the use of @code{COMMON}
679in Fortran. The single
680object @var{local_name} is assigned to the area designated by
681the @var{External} argument.
682You may define a record to correspond to a series
ad42149c 683of fields. The @var{size} argument
41af791f
GB
684is syntax checked in GNAT, but otherwise ignored.
685
ad42149c 686@code{Common_Object} is not supported on all platforms. If no
41af791f
GB
687support is available, then the code generator will issue a message
688indicating that the necessary attribute for implementation of this
689pragma is not available.
690
691@findex Complex_Representation
692@item pragma Complex_Representation
693@noindent
694Syntax:
695
696@smallexample
697pragma Complex_Representation
698 ([Entity =>] LOCAL_NAME);
699@end smallexample
700
701@noindent
702The @var{Entity} argument must be the name of a record type which has
ad42149c 703two fields of the same floating-point type. The effect of this pragma is
41af791f 704to force gcc to use the special internal complex representation form for
ad42149c 705this record, which may be more efficient. Note that this may result in
41af791f 706the code for this type not conforming to standard ABI (application
ad42149c 707binary interface) requirements for the handling of record types. For
41af791f
GB
708example, in some environments, there is a requirement for passing
709records by pointer, and the use of this pragma may result in passing
710this type in floating-point registers.
711
712@cindex Alignments of components
713@findex Component_Alignment
714@item pragma Component_Alignment
715@noindent
716Syntax:
717
718@smallexample
719pragma Component_Alignment (
720 [Form =>] ALIGNMENT_CHOICE
721 [, [Name =>] type_LOCAL_NAME]);
722
723ALIGNMENT_CHOICE ::=
724 Component_Size
725| Component_Size_4
726| Storage_Unit
727| Default
728@end smallexample
729
730@noindent
731Specifies the alignment of components in array or record types.
732The meaning of the @var{Form} argument is as follows:
733
734@table @code
735@findex Component_Size
736@item Component_Size
737Aligns scalar components and subcomponents of the array or record type
738on boundaries appropriate to their inherent size (naturally
ad42149c 739aligned). For example, 1-byte components are aligned on byte boundaries,
41af791f 7402-byte integer components are aligned on 2-byte boundaries, 4-byte
ad42149c 741integer components are aligned on 4-byte boundaries and so on. These
41af791f 742alignment rules correspond to the normal rules for C compilers on all
46b58b8c 743machines except the VAX@.
41af791f
GB
744
745@findex Component_Size_4
746@item Component_Size_4
747Naturally aligns components with a size of four or fewer
ad42149c 748bytes. Components that are larger than 4 bytes are placed on the next
41af791f
GB
7494-byte boundary.
750
751@findex Storage_Unit
752@item Storage_Unit
46b58b8c 753Specifies that array or record components are byte aligned, i.e.@:
41af791f
GB
754aligned on boundaries determined by the value of the constant
755@code{System.Storage_Unit}.
756
757@cindex OpenVMS
758@item Default
759Specifies that array or record components are aligned on default
760boundaries, appropriate to the underlying hardware or operating system or
ad42149c
FW
761both. For OpenVMS VAX systems, the @code{Default} choice is the same as
762the @code{Storage_Unit} choice (byte alignment). For all other systems,
41af791f
GB
763the @code{Default} choice is the same as @code{Component_Size} (natural
764alignment).
765@end table
766
767If the @code{Name} parameter is present, @var{type_local_name} must
768refer to a local record or array type, and the specified alignment
ad42149c 769choice applies to the specified type. The use of
41af791f 770@code{Component_Alignment} together with a pragma @code{Pack} causes the
ad42149c 771@code{Component_Alignment} pragma to be ignored. The use of
41af791f
GB
772@code{Component_Alignment} together with a record representation clause
773is only effective for fields not specified by the representation clause.
774
775If the @code{Name} parameter is absent, the pragma can be used as either
776a configuration pragma, in which case it applies to one or more units in
777accordance with the normal rules for configuration pragmas, or it can be
778used within a declarative part, in which case it applies to types that
779are declared within this declarative part, or within any nested scope
ad42149c 780within this declarative part. In either case it specifies the alignment
41af791f
GB
781to be applied to any record or array type which has otherwise standard
782representation.
783
784If the alignment for a record or array type is not specified (using
785pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
786clause), the GNAT uses the default alignment as described previously.
ad42149c
FW
787
788@findex Convention_Identifier
789@cindex Conventions, synonyms
790@item pragma Convention_Identifier
791@noindent
792Syntax:
793
794@smallexample
795pragma Convention_Identifier (
796 [Name =>] IDENTIFIER,
797 [Convention =>] convention_IDENTIFIER);
798@end smallexample
799
800@noindent
801This pragma provides a mechanism for supplying synonyms for existing
802convention identifiers. The @code{Name} identifier can subsequently
803be used as a synonym for the given convention in other pragmas (including
804for example pragma @code{Import} or another @code{Convention_Identifier}
805pragma). As an example of the use of this, suppose you had legacy code
806which used Fortran77 as the identifier for Fortran. Then the pragma:
807
808@smallexample
809pragma Convention_Indentifier (Fortran77, Fortran);
810@end smallexample
811
812@noindent
813would allow the use of the convention identifier @code{Fortran77} in
814subsequent code, avoiding the need to modify the sources. As another
815example, you could use this to parametrize convention requirements
816according to systems. Suppose you needed to use @code{Stdcall} on
817windows systems, and @code{C} on some other system, then you could
818define a convention identifier @code{Library} and use a single
819@code{Convention_Identifier} pragma to specify which convention
820would be used system-wide.
41af791f
GB
821
822@findex CPP_Class
823@cindex Interfacing with C++
824@item pragma CPP_Class
825@noindent
826Syntax:
827
828@smallexample
829pragma CPP_Class ([Entity =>] LOCAL_NAME);
830@end smallexample
831
832@noindent
833The argument denotes an entity in the current declarative region
ad42149c 834that is declared as a tagged or untagged record type. It indicates that
41af791f
GB
835the type corresponds to an externally declared C++ class type, and is to
836be laid out the same way that C++ would lay out the type.
837
838If (and only if) the type is tagged, at least one component in the
839record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
840to the C++ Vtable (or Vtables in the case of multiple inheritance) used
841for dispatching.
842
843Types for which @code{CPP_Class} is specified do not have assignment or
844equality operators defined (such operations can be imported or declared
ad42149c 845as subprograms as required). Initialization is allowed only by
41af791f
GB
846constructor functions (see pragma @code{CPP_Constructor}).
847
848Pragma @code{CPP_Class} is intended primarily for automatic generation
ad42149c
FW
849using an automatic binding generator tool.
850See @ref{Interfacing to C++} for related information.
41af791f
GB
851
852@cindex Interfacing with C++
853@findex CPP_Constructor
854@item pragma CPP_Constructor
855@noindent
856Syntax:
857
858@smallexample
859pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
860@end smallexample
861
862@noindent
863This pragma identifies an imported function (imported in the usual way
ad42149c
FW
864with pragma @code{Import}) as corresponding to a C++
865constructor. The argument is a name that must have been
866previously mentioned in a pragma @code{Import}
867with @code{Convention} = @code{CPP}, and must be of one of the following
41af791f
GB
868forms:
869
870@itemize @bullet
871@item
872@code{function @var{Fname} return @var{T}'Class}
873
874@item
875@code{function @var{Fname} (@dots{}) return @var{T}'Class}
876@end itemize
877
878@noindent
879where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
880
881The first form is the default constructor, used when an object of type
ad42149c 882@var{T} is created on the Ada side with no explicit constructor. Other
41af791f
GB
883constructors (including the copy constructor, which is simply a special
884case of the second form in which the one and only argument is of type
885@var{T}), can only appear in two contexts:
886
887@itemize @bullet
888@item
889On the right side of an initialization of an object of type @var{T}.
890@item
891In an extension aggregate for an object of a type derived from @var{T}.
892@end itemize
893
894Although the constructor is described as a function that returns a value
895on the Ada side, it is typically a procedure with an extra implicit
896argument (the object being initialized) at the implementation
ad42149c 897level. GNAT issues the appropriate call, whatever it is, to get the
41af791f
GB
898object properly initialized.
899
900In the case of derived objects, you may use one of two possible forms
901for declaring and creating an object:
902
903@itemize @bullet
904@item @code{New_Object : Derived_T}
905@item @code{New_Object : Derived_T := (@var{constructor-function-call with} @dots{})}
906@end itemize
907
908In the first case the default constructor is called and extension fields
909if any are initialized according to the default initialization
ad42149c 910expressions in the Ada declaration. In the second case, the given
41af791f
GB
911constructor is called and the extension aggregate indicates the explicit
912values of the extension fields.
913
914If no constructors are imported, it is impossible to create any objects
ad42149c 915on the Ada side. If no default constructor is imported, only the
41af791f
GB
916initialization forms using an explicit call to a constructor are
917permitted.
918
919Pragma @code{CPP_Constructor} is intended primarily for automatic generation
ad42149c
FW
920using an automatic binding generator tool.
921See @ref{Interfacing to C++} for more related information.
41af791f
GB
922
923@cindex Interfacing to C++
924@findex CPP_Virtual
925@item pragma CPP_Virtual
926@noindent
927Syntax:
928
929@smallexample
930pragma CPP_Virtual
931 [Entity =>] ENTITY,
932 [, [Vtable_Ptr =>] vtable_ENTITY,]
933 [, [Position =>] static_integer_EXPRESSION])
934@end smallexample
935
936This pragma serves the same function as pragma @code{Import} in that
ad42149c 937case of a virtual function imported from C++. The @var{Entity} argument
41af791f
GB
938must be a
939primitive subprogram of a tagged type to which pragma @code{CPP_Class}
ad42149c 940applies. The @var{Vtable_Ptr} argument specifies
41af791f 941the Vtable_Ptr component which contains the
ad42149c 942entry for this virtual function. The @var{Position} argument
41af791f
GB
943is the sequential number
944counting virtual functions for this Vtable starting at 1.
945
946The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
947there is one Vtable_Ptr present (single inheritance case) and all
948virtual functions are imported. In that case the compiler can deduce both
949these values.
950
951No @code{External_Name} or @code{Link_Name} arguments are required for a
952virtual function, since it is always accessed indirectly via the
953appropriate Vtable entry.
954
955Pragma @code{CPP_Virtual} is intended primarily for automatic generation
ad42149c
FW
956using an automatic binding generator tool.
957See @ref{Interfacing to C++} for related information.
41af791f
GB
958
959@cindex Interfacing with C++
960@findex CPP_Vtable
961@item pragma CPP_Vtable
962@noindent
963Syntax:
964
965@smallexample
966pragma CPP_Vtable (
967 [Entity =>] ENTITY,
968 [Vtable_Ptr =>] vtable_ENTITY,
969 [Entry_Count =>] static_integer_EXPRESSION);
970@end smallexample
971
972@noindent
973Given a record to which the pragma @code{CPP_Class} applies,
974this pragma can be specified for each component of type
975@code{CPP.Interfaces.Vtable_Ptr}.
976@var{Entity} is the tagged type, @var{Vtable_Ptr}
977is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
ad42149c 978the number of virtual functions on the C++ side. Not all of these
41af791f
GB
979functions need to be imported on the Ada side.
980
981You may omit the @code{CPP_Vtable} pragma if there is only one
982@code{Vtable_Ptr} component in the record and all virtual functions are
983imported on the Ada side (the default value for the entry count in this
984case is simply the total number of virtual functions).
985
986Pragma @code{CPP_Vtable} is intended primarily for automatic generation
ad42149c
FW
987using an automatic binding generator tool.
988See @ref{Interfacing to C++} for related information.
41af791f
GB
989
990@findex Debug
991@item pragma Debug
992@noindent
993Syntax:
994
995@smallexample
ad42149c
FW
996pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
997
998PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
999 PROCEDURE_NAME
1000| PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
41af791f
GB
1001@end smallexample
1002
1003@noindent
ad42149c
FW
1004The argument has the syntactic form of an expression, meeting the
1005syntactic requirements for pragmas.
1006
41af791f 1007If assertions are not enabled on the command line, this pragma has no
ad42149c
FW
1008effect. If asserts are enabled, the semantics of the pragma is exactly
1009equivalent to the procedure call statement corresponding to the argument
1010with a terminating semicolon. Pragmas are permitted in sequences of
41af791f
GB
1011declarations, so you can use pragma @code{Debug} to intersperse calls to
1012debug procedures in the middle of declarations.
1013
1014@cindex Elaboration control
1015@findex Elaboration_Checks
1016@item pragma Elaboration_Checks
1017@noindent
1018Syntax:
1019
1020@smallexample
1021pragma Elaboration_Checks (RM | Static);
1022@end smallexample
1023
1024@noindent
1025This is a configuration pragma that provides control over the
1026elaboration model used by the compilation affected by the
ad42149c 1027pragma. If the parameter is RM, then the dynamic elaboration
41af791f
GB
1028model described in the Ada Reference Manual is used, as though
1029the @code{-gnatE} switch had been specified on the command
ad42149c
FW
1030line. If the parameter is Static, then the default GNAT static
1031model is used. This configuration pragma overrides the setting
1032of the command line. For full details on the elaboration models
1033used by the GNAT compiler, see section ``Elaboration Order
1034Handling in GNAT'' in the @cite{GNAT User's Guide}.
41af791f
GB
1035
1036@cindex Elimination of unused subprograms
1037@findex Eliminate
1038@item pragma Eliminate
1039@noindent
1040Syntax:
1041
1042@smallexample
1043pragma Eliminate (
1044 [Unit_Name =>] IDENTIFIER |
1045 SELECTED_COMPONENT);
1046
1047pragma Eliminate (
1048 [Unit_Name =>] IDENTIFIER |
ad42149c 1049 SELECTED_COMPONENT,
41af791f
GB
1050 [Entity =>] IDENTIFIER |
1051 SELECTED_COMPONENT |
ad42149c
FW
1052 STRING_LITERAL
1053 [,[Parameter_Types =>] PARAMETER_TYPES]
1054 [,[Result_Type =>] result_SUBTYPE_NAME]
1055 [,[Homonym_Number =>] INTEGER_LITERAL]);
41af791f
GB
1056
1057PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1058SUBTYPE_NAME ::= STRING_LITERAL
1059@end smallexample
1060
1061@noindent
1062This pragma indicates that the given entity is not used outside the
ad42149c 1063compilation unit it is defined in. The entity may be either a subprogram
41af791f
GB
1064or a variable.
1065
1066If the entity to be eliminated is a library level subprogram, then
1067the first form of pragma @code{Eliminate} is used with only a single argument.
1068In this form, the @code{Unit_Name} argument specifies the name of the
1069library level unit to be eliminated.
1070
1071In all other cases, both @code{Unit_Name} and @code{Entity} arguments
ad42149c 1072are required. item is an entity of a library package, then the first
41af791f 1073argument specifies the unit name, and the second argument specifies
ad42149c 1074the particular entity. If the second argument is in string form, it must
41af791f
GB
1075correspond to the internal manner in which GNAT stores entity names (see
1076compilation unit Namet in the compiler sources for details).
ad42149c
FW
1077
1078The remaining parameters are optionally used to distinguish
1079between overloaded subprograms. There are two ways of doing this.
1080
1081Use @code{Parameter_Types} and @code{Result_Type} to specify the
1082profile of the subprogram to be eliminated in a manner similar to that
1083used for
41af791f
GB
1084the extended @code{Import} and @code{Export} pragmas, except that the
1085subtype names are always given as string literals, again corresponding
1086to the internal manner in which GNAT stores entity names.
1087
ad42149c
FW
1088Alternatively, the @code{Homonym_Number} parameter is used to specify
1089which overloaded alternative is to be eliminated. A value of 1 indicates
1090the first subprogram (in lexical order), 2 indicates the second etc.
1091
41af791f
GB
1092The effect of the pragma is to allow the compiler to eliminate
1093the code or data associated with the named entity. Any reference to
1094an eliminated entity outside the compilation unit it is defined in,
1095causes a compile time or link time error.
1096
ad42149c
FW
1097The parameters of this pragma may be given in any order, as long as
1098the usual rules for use of named parameters and position parameters
1099are used.
1100
1101The intention of pragma @code{Eliminate} is to allow a program to be compiled
41af791f 1102in a system independent manner, with unused entities eliminated, without
ad42149c
FW
1103the requirement of modifying the source text. Normally the required set
1104of @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
41af791f 1105Elimination of unused entities local to a compilation unit is automatic,
ad42149c 1106without requiring the use of pragma @code{Eliminate}.
41af791f
GB
1107
1108Note that the reason this pragma takes string literals where names might
ad42149c 1109be expected is that a pragma @code{Eliminate} can appear in a context where the
41af791f
GB
1110relevant names are not visible.
1111
1112@cindex OpenVMS
1113@findex Export_Exception
1114@item pragma Export_Exception
1115@noindent
1116Syntax:
1117
1118@smallexample
1119pragma Export_Exception (
1120 [Internal =>] LOCAL_NAME,
1121 [, [External =>] EXTERNAL_SYMBOL,]
1122 [, [Form =>] Ada | VMS]
1123 [, [Code =>] static_integer_EXPRESSION]);
1124
1125EXTERNAL_SYMBOL ::=
1126 IDENTIFIER
1127| static_string_EXPRESSION
1128@end smallexample
1129
1130@noindent
ad42149c 1131This pragma is implemented only in the OpenVMS implementation of GNAT@. It
41af791f
GB
1132causes the specified exception to be propagated outside of the Ada program,
1133so that it can be handled by programs written in other OpenVMS languages.
1134This pragma establishes an external name for an Ada exception and makes the
ad42149c 1135name available to the OpenVMS Linker as a global symbol. For further details
41af791f
GB
1136on this pragma, see the
1137DEC Ada Language Reference Manual, section 13.9a3.2.
1138
1139@cindex Argument passing mechanisms
1140@findex Export_Function
1141@item pragma Export_Function @dots{}
1142
1143@noindent
1144Syntax:
1145
1146@smallexample
1147pragma Export_Function (
1148 [Internal =>] LOCAL_NAME,
1149 [, [External =>] EXTERNAL_SYMBOL]
1150 [, [Parameter_Types =>] PARAMETER_TYPES]
1151 [, [Result_Type =>] result_SUBTYPE_MARK]
1152 [, [Mechanism =>] MECHANISM]
1153 [, [Result_Mechanism =>] MECHANISM_NAME]);
1154
1155EXTERNAL_SYMBOL ::=
1156 IDENTIFIER
1157| static_string_EXPRESSION
1158
1159PARAMETER_TYPES ::=
1160 null
1161| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1162
1163MECHANISM ::=
1164 MECHANISM_NAME
1165| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1166
1167MECHANISM_ASSOCIATION ::=
1168 [formal_parameter_NAME =>] MECHANISM_NAME
1169
1170MECHANISM_NAME ::=
1171 Value
1172| Reference
1173| Descriptor [([Class =>] CLASS_NAME)]
1174
1175CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1176@end smallexample
1177
1178Use this pragma to make a function externally callable and optionally
1179provide information on mechanisms to be used for passing parameter and
ad42149c 1180result values. We recommend, for the purposes of improving portability,
41af791f
GB
1181this pragma always be used in conjunction with a separate pragma
1182@code{Export}, which must precede the pragma @code{Export_Function}.
1183GNAT does not require a separate pragma @code{Export}, but if none is
1184present, @code{Convention Ada} is assumed, which is usually
1185not what is wanted, so it is usually appropriate to use this
1186pragma in conjunction with a @code{Export} or @code{Convention}
1187pragma that specifies the desired foreign convention.
1188Pragma @code{Export_Function}
1189(and @code{Export}, if present) must appear in the same declarative
1190region as the function to which they apply.
1191
1192@var{internal_name} must uniquely designate the function to which the
ad42149c 1193pragma applies. If more than one function name exists of this name in
41af791f
GB
1194the declarative part you must use the @code{Parameter_Types} and
1195@code{Result_Type} parameters is mandatory to achieve the required
ad42149c 1196unique designation. @var{subtype_ mark}s in these parameters must
41af791f
GB
1197exactly match the subtypes in the corresponding function specification,
1198using positional notation to match parameters with subtype marks.
1199@cindex OpenVMS
1200@cindex Passing by descriptor
46b58b8c 1201Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
41af791f
GB
1202
1203@findex Export_Object
1204@item pragma Export_Object @dots{}
1205@noindent
1206Syntax:
1207
1208@smallexample
1209pragma Export_Object
1210 [Internal =>] LOCAL_NAME,
1211 [, [External =>] EXTERNAL_SYMBOL]
1212 [, [Size =>] EXTERNAL_SYMBOL]
1213
1214EXTERNAL_SYMBOL ::=
1215 IDENTIFIER
1216| static_string_EXPRESSION
1217@end smallexample
1218
1219This pragma designates an object as exported, and apart from the
1220extended rules for external symbols, is identical in effect to the use of
ad42149c 1221the normal @code{Export} pragma applied to an object. You may use a
41af791f
GB
1222separate Export pragma (and you probably should from the point of view
1223of portability), but it is not required. @var{Size} is syntax checked,
46b58b8c 1224but otherwise ignored by GNAT@.
41af791f
GB
1225
1226@findex Export_Procedure
1227@item pragma Export_Procedure @dots{}
1228@noindent
1229Syntax:
1230
1231@smallexample
1232pragma Export_Procedure (
1233 [Internal =>] LOCAL_NAME
1234 [, [External =>] EXTERNAL_SYMBOL]
1235 [, [Parameter_Types =>] PARAMETER_TYPES]
1236 [, [Mechanism =>] MECHANISM]);
1237
1238EXTERNAL_SYMBOL ::=
1239 IDENTIFIER
1240| static_string_EXPRESSION
1241
1242PARAMETER_TYPES ::=
1243 null
1244| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1245
1246MECHANISM ::=
1247 MECHANISM_NAME
1248| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1249
1250MECHANISM_ASSOCIATION ::=
1251 [formal_parameter_NAME =>] MECHANISM_NAME
1252
1253MECHANISM_NAME ::=
1254 Value
1255| Reference
1256| Descriptor [([Class =>] CLASS_NAME)]
1257
1258CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1259@end smallexample
1260
1261@noindent
1262This pragma is identical to @code{Export_Function} except that it
1263applies to a procedure rather than a function and the parameters
1264@code{Result_Type} and @code{Result_Mechanism} are not permitted.
1265GNAT does not require a separate pragma @code{Export}, but if none is
1266present, @code{Convention Ada} is assumed, which is usually
1267not what is wanted, so it is usually appropriate to use this
1268pragma in conjunction with a @code{Export} or @code{Convention}
1269pragma that specifies the desired foreign convention.
1270
1271@findex Export_Valued_Procedure
1272@item pragma Export_Valued_Procedure
1273@noindent
1274Syntax:
1275
1276@smallexample
1277pragma Export_Valued_Procedure (
1278 [Internal =>] LOCAL_NAME
1279 [, [External =>] EXTERNAL_SYMBOL]
1280 [, [Parameter_Types =>] PARAMETER_TYPES]
1281 [, [Mechanism =>] MECHANISM]);
1282
1283EXTERNAL_SYMBOL ::=
1284 IDENTIFIER
1285| static_string_EXPRESSION
1286
1287PARAMETER_TYPES ::=
1288 null
1289| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1290
1291MECHANISM ::=
1292 MECHANISM_NAME
1293| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1294
1295MECHANISM_ASSOCIATION ::=
1296 [formal_parameter_NAME =>] MECHANISM_NAME
1297
1298MECHANISM_NAME ::=
1299 Value
1300| Reference
1301| Descriptor [([Class =>] CLASS_NAME)]
1302
1303CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1304@end smallexample
1305
1306This pragma is identical to @code{Export_Procedure} except that the
1307first parameter of @var{local_name}, which must be present, must be of
1308mode @code{OUT}, and externally the subprogram is treated as a function
ad42149c 1309with this parameter as the result of the function. GNAT provides for
41af791f
GB
1310this capability to allow the use of @code{OUT} and @code{IN OUT}
1311parameters in interfacing to external functions (which are not permitted
1312in Ada functions).
1313GNAT does not require a separate pragma @code{Export}, but if none is
1314present, @code{Convention Ada} is assumed, which is almost certainly
1315not what is wanted since the whole point of this pragma is to interface
1316with foreign language functions, so it is usually appropriate to use this
1317pragma in conjunction with a @code{Export} or @code{Convention}
1318pragma that specifies the desired foreign convention.
1319
1320@cindex @code{system}, extending
1321@cindex Dec Ada 83
1322@findex Extend_System
1323@item pragma Extend_System
1324@noindent
1325Syntax:
1326
1327@smallexample
1328pragma Extend_System ([Name =>] IDENTIFIER);
1329@end smallexample
1330
1331@noindent
1332This pragma is used to provide backwards compatibility with other
ad42149c 1333implementations that extend the facilities of package @code{System}. In
41af791f 1334GNAT, @code{System} contains only the definitions that are present in
ad42149c 1335the Ada 95 RM@. However, other implementations, notably the DEC Ada 83
41af791f
GB
1336implementation, provide many extensions to package @code{System}.
1337
1338For each such implementation accommodated by this pragma, GNAT provides a
46b58b8c 1339package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
ad42149c 1340implementation, which provides the required additional definitions. You
41af791f
GB
1341can use this package in two ways. You can @code{with} it in the normal
1342way and access entities either by selection or using a @code{use}
ad42149c 1343clause. In this case no special processing is required.
41af791f
GB
1344
1345However, if existing code contains references such as
1346@code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1347definitions provided in package @code{System}, you may use this pragma
1348to extend visibility in @code{System} in a non-standard way that
ad42149c 1349provides greater compatibility with the existing code. Pragma
41af791f
GB
1350@code{Extend_System} is a configuration pragma whose single argument is
1351the name of the package containing the extended definition
ad42149c 1352(e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
41af791f
GB
1353control of this pragma will be processed using special visibility
1354processing that looks in package @code{System.Aux_@var{xxx}} where
1355@code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1356package @code{System}, but not found in package @code{System}.
1357
1358You can use this pragma either to access a predefined @code{System}
1359extension supplied with the compiler, for example @code{Aux_DEC} or
1360you can construct your own extension unit following the above
ad42149c
FW
1361definition. Note that such a package is a child of @code{System}
1362and thus is considered part of the implementation. To compile
41af791f 1363it you will have to use the appropriate switch for compiling
ad42149c 1364system units. See the GNAT User's Guide for details.
41af791f
GB
1365
1366@findex External
1367@item pragma External
1368@noindent
1369Syntax:
1370
1371@smallexample
1372pragma External (
1373 [ Convention =>] convention_IDENTIFIER,
1374 [ Entity =>] local_NAME
1375 [, [External_Name =>] static_string_EXPRESSION ]
1376 [, [Link_Name =>] static_string_EXPRESSION ]);
1377@end smallexample
1378
1379@noindent
1380This pragma is identical in syntax and semantics to pragma
ad42149c 1381@code{Export} as defined in the Ada Reference Manual. It is
41af791f
GB
1382provided for compatibility with some Ada 83 compilers that
1383used this pragma for exactly the same purposes as pragma
1384@code{Export} before the latter was standardized.
1385
1386@cindex Dec Ada 83 casing compatibility
1387@cindex External Names, casing
1388@cindex Casing of External names
1389@findex External_Name_Casing
1390@item pragma External_Name_Casing
1391@noindent
1392Syntax:
1393
1394@smallexample
1395pragma External_Name_Casing (
1396 Uppercase | Lowercase
1397 [, Uppercase | Lowercase | As_Is]);
1398@end smallexample
1399
1400@noindent
1401This pragma provides control over the casing of external names associated
ad42149c 1402with Import and Export pragmas. There are two cases to consider:
41af791f
GB
1403
1404@table @asis
1405@item Implicit external names
ad42149c 1406Implicit external names are derived from identifiers. The most common case
41af791f
GB
1407arises when a standard Ada 95 Import or Export pragma is used with only two
1408arguments, as in:
1409
1410@smallexample
1411 pragma Import (C, C_Routine);
1412@end smallexample
1413
1414@noindent
1415Since Ada is a case insensitive language, the spelling of the identifier in
1416the Ada source program does not provide any information on the desired
ad42149c 1417casing of the external name, and so a convention is needed. In GNAT the
41af791f 1418default treatment is that such names are converted to all lower case
ad42149c 1419letters. This corresponds to the normal C style in many environments.
41af791f 1420The first argument of pragma @code{External_Name_Casing} can be used to
ad42149c
FW
1421control this treatment. If @code{Uppercase} is specified, then the name
1422will be forced to all uppercase letters. If @code{Lowercase} is specified,
41af791f
GB
1423then the normal default of all lower case letters will be used.
1424
1425This same implicit treatment is also used in the case of extended DEC Ada 83
1426compatible Import and Export pragmas where an external name is explicitly
1427specified using an identifier rather than a string.
1428
1429@item Explicit external names
ad42149c 1430Explicit external names are given as string literals. The most common case
41af791f
GB
1431arises when a standard Ada 95 Import or Export pragma is used with three
1432arguments, as in:
1433
1434@smallexample
1435pragma Import (C, C_Routine, "C_routine");
1436@end smallexample
1437
1438@noindent
1439In this case, the string literal normally provides the exact casing required
ad42149c 1440for the external name. The second argument of pragma
41af791f
GB
1441@code{External_Name_Casing} may be used to modify this behavior.
1442If @code{Uppercase} is specified, then the name
ad42149c
FW
1443will be forced to all uppercase letters. If @code{Lowercase} is specified,
1444then the name will be forced to all lowercase letters. A specification of
41af791f
GB
1445@code{As_Is} provides the normal default behavior in which the casing is
1446taken from the string provided.
1447@end table
1448
1449@noindent
ad42149c
FW
1450This pragma may appear anywhere that a pragma is valid. In particular, it
1451can be used as a configuration pragma in the @file{gnat.adc} file, in which
41af791f
GB
1452case it applies to all subsequent compilations, or it can be used as a program
1453unit pragma, in which case it only applies to the current unit, or it can
1454be used more locally to control individual Import/Export pragmas.
1455
ad42149c
FW
1456It is primarily intended for use with OpenVMS systems, where many
1457compilers convert all symbols to upper case by default. For interfacing to
46b58b8c 1458such compilers (e.g.@: the DEC C compiler), it may be convenient to use
41af791f
GB
1459the pragma:
1460
1461@smallexample
1462pragma External_Name_Casing (Uppercase, Uppercase);
1463@end smallexample
1464
1465@noindent
1466to enforce the upper casing of all external symbols.
1467
1468@findex Finalize_Storage_Only
1469@item pragma Finalize_Storage_Only
1470@noindent
1471Syntax:
1472
1473@smallexample
1474pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1475@end smallexample
1476
1477@noindent
1478This pragma allows the compiler not to emit a Finalize call for objects
ad42149c 1479defined at the library level. This is mostly useful for types where
41af791f
GB
1480finalization is only used to deal with storage reclamation since in most
1481environments it is not necessary to reclaim memory just before terminating
1482execution, hence the name.
1483
1484@cindex OpenVMS
1485@findex Float_Representation
1486@item pragma Float_Representation
1487@noindent
1488Syntax:
1489
1490@smallexample
1491pragma Float_Representation (FLOAT_REP);
1492
1493FLOAT_REP ::= VAX_Float | IEEE_Float
1494@end smallexample
1495
1496@noindent
46b58b8c 1497This pragma is implemented only in the OpenVMS implementation of GNAT@.
41af791f
GB
1498It allows control over the internal representation chosen for the predefined
1499floating point types declared in the packages @code{Standard} and
ad42149c
FW
1500@code{System}. For further details on this pragma, see the
1501DEC Ada Language Reference Manual, section 3.5.7a. Note that to use this
1502pragma, the standard runtime libraries must be recompiled. See the
41af791f
GB
1503description of the @code{GNAT LIBRARY} command in the OpenVMS version
1504of the GNAT Users Guide for details on the use of this command.
1505
1506@findex Ident
1507@item pragma Ident
1508@noindent
1509Syntax:
1510
1511@smallexample
1512pragma Ident (static_string_EXPRESSION);
1513@end smallexample
1514
1515@noindent
1516This pragma provides a string identification in the generated object file,
1517if the system supports the concept of this kind of identification string.
1518The maximum permitted length of the string literal is 31 characters.
1519This pragma is allowed only in the outermost declarative part or
1520declarative items of a compilation unit.
1521@cindex OpenVMS
1522On OpenVMS systems, the effect of the pragma is identical to the effect of
1523the DEC Ada 83 pragma of the same name.
1524
1525@cindex OpenVMS
1526@findex Import_Exception
1527@item pragma Import_Exception
1528@noindent
1529Syntax:
1530
1531@smallexample
1532pragma Import_Exception (
1533 [Internal =>] LOCAL_NAME,
1534 [, [External =>] EXTERNAL_SYMBOL,]
1535 [, [Form =>] Ada | VMS]
1536 [, [Code =>] static_integer_EXPRESSION]);
1537
1538EXTERNAL_SYMBOL ::=
1539 IDENTIFIER
1540| static_string_EXPRESSION
1541@end smallexample
1542
1543@noindent
46b58b8c 1544This pragma is implemented only in the OpenVMS implementation of GNAT@.
41af791f
GB
1545It allows OpenVMS conditions (for example, from OpenVMS system services or
1546other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1547The pragma specifies that the exception associated with an exception
1548declaration in an Ada program be defined externally (in non-Ada code).
1549For further details on this pragma, see the
1550DEC Ada Language Reference Manual, section 13.9a.3.1.
1551
1552@findex Import_Function
1553@item pragma Import_Function @dots{}
1554@noindent
1555Syntax:
1556
1557@smallexample
1558pragma Import_Function (
1559 [Internal =>] LOCAL_NAME,
1560 [, [External =>] EXTERNAL_SYMBOL]
1561 [, [Parameter_Types =>] PARAMETER_TYPES]
1562 [, [Result_Type =>] SUBTYPE_MARK]
1563 [, [Mechanism =>] MECHANISM]
1564 [, [Result_Mechanism =>] MECHANISM_NAME]
1565 [, [First_Optional_Parameter =>] IDENTIFIER]);
1566
1567EXTERNAL_SYMBOL ::=
1568 IDENTIFIER
1569| static_string_EXPRESSION
1570
1571PARAMETER_TYPES ::=
1572 null
1573| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1574
1575MECHANISM ::=
1576 MECHANISM_NAME
1577| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1578
1579MECHANISM_ASSOCIATION ::=
1580 [formal_parameter_NAME =>] MECHANISM_NAME
1581
1582MECHANISM_NAME ::=
1583 Value
1584| Reference
1585| Descriptor [([Class =>] CLASS_NAME)]
1586
1587CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1588@end smallexample
1589
1590This pragma is used in conjunction with a pragma @code{Import} to
ad42149c 1591specify additional information for an imported function. The pragma
41af791f
GB
1592@code{Import} (or equivalent pragma @code{Interface}) must precede the
1593@code{Import_Function} pragma and both must appear in the same
1594declarative part as the function specification.
1595
1596The @var{Internal_Name} argument must uniquely designate
1597the function to which the
ad42149c 1598pragma applies. If more than one function name exists of this name in
41af791f
GB
1599the declarative part you must use the @code{Parameter_Types} and
1600@var{Result_Type} parameters to achieve the required unique
ad42149c 1601designation. Subtype marks in these parameters must exactly match the
41af791f
GB
1602subtypes in the corresponding function specification, using positional
1603notation to match parameters with subtype marks.
1604
1605You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
1606parameters to specify passing mechanisms for the
ad42149c 1607parameters and result. If you specify a single mechanism name, it
41af791f
GB
1608applies to all parameters. Otherwise you may specify a mechanism on a
1609parameter by parameter basis using either positional or named
ad42149c 1610notation. If the mechanism is not specified, the default mechanism
41af791f
GB
1611is used.
1612
1613@cindex OpenVMS
1614@cindex Passing by descriptor
46b58b8c 1615Passing by descriptor is supported only on the to OpenVMS ports of GNAT@.
41af791f 1616
46b58b8c 1617@code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
41af791f
GB
1618It specifies that the designated parameter and all following parameters
1619are optional, meaning that they are not passed at the generated code
1620level (this is distinct from the notion of optional parameters in Ada
1621where the parameters are passed anyway with the designated optional
ad42149c 1622parameters). All optional parameters must be of mode @code{IN} and have
41af791f
GB
1623default parameter values that are either known at compile time
1624expressions, or uses of the @code{'Null_Parameter} attribute.
1625
1626@findex Import_Object
1627@item pragma Import_Object
1628@noindent
1629Syntax:
1630
1631@smallexample
1632pragma Import_Object
1633 [Internal =>] LOCAL_NAME,
1634 [, [External =>] EXTERNAL_SYMBOL],
1635 [, [Size =>] EXTERNAL_SYMBOL])
1636
1637EXTERNAL_SYMBOL ::=
1638 IDENTIFIER
1639| static_string_EXPRESSION
1640@end smallexample
1641
1642@noindent
1643This pragma designates an object as imported, and apart from the
1644extended rules for external symbols, is identical in effect to the use of
1645the normal @code{Import} pragma applied to an object. Unlike the
1646subprogram case, you need not use a separate @code{Import} pragma,
1647although you may do so (and probably should do so from a portability
ad42149c 1648point of view). @var{size} is syntax checked, but otherwise ignored by
46b58b8c 1649GNAT@.
41af791f
GB
1650
1651@findex Import_Procedure
1652@item pragma Import_Procedure
1653@noindent
1654Syntax:
1655
1656@smallexample
1657pragma Import_Procedure (
1658 [Internal =>] LOCAL_NAME,
1659 [, [External =>] EXTERNAL_SYMBOL]
1660 [, [Parameter_Types =>] PARAMETER_TYPES]
1661 [, [Mechanism =>] MECHANISM]
1662 [, [First_Optional_Parameter =>] IDENTIFIER]);
1663
1664EXTERNAL_SYMBOL ::=
1665 IDENTIFIER
1666| static_string_EXPRESSION
1667
1668PARAMETER_TYPES ::=
1669 null
1670| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1671
1672MECHANISM ::=
1673 MECHANISM_NAME
1674| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1675
1676MECHANISM_ASSOCIATION ::=
1677 [formal_parameter_NAME =>] MECHANISM_NAME
1678
1679MECHANISM_NAME ::=
1680 Value
1681| Reference
1682| Descriptor [([Class =>] CLASS_NAME)]
1683
1684CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1685@end smallexample
1686
1687@noindent
1688This pragma is identical to @code{Import_Function} except that it
1689applies to a procedure rather than a function and the parameters
1690@code{Result_Type} and @code{Result_Mechanism} are not permitted.
1691
1692@findex Import_Valued_Procedure
1693@item pragma Import_Valued_Procedure @dots{}
1694@noindent
1695Syntax:
1696
1697@smallexample
1698pragma Import_Valued_Procedure (
1699 [Internal =>] LOCAL_NAME,
1700 [, [External =>] EXTERNAL_SYMBOL]
1701 [, [Parameter_Types =>] PARAMETER_TYPES]
1702 [, [Mechanism =>] MECHANISM]
1703 [, [First_Optional_Parameter =>] IDENTIFIER]);
1704
1705EXTERNAL_SYMBOL ::=
1706 IDENTIFIER
1707| static_string_EXPRESSION
1708
1709PARAMETER_TYPES ::=
1710 null
1711| SUBTYPE_MARK @{, SUBTYPE_MARK@}
1712
1713MECHANISM ::=
1714 MECHANISM_NAME
1715| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1716
1717MECHANISM_ASSOCIATION ::=
1718 [formal_parameter_NAME =>] MECHANISM_NAME
1719
1720MECHANISM_NAME ::=
1721 Value
1722| Reference
1723| Descriptor [([Class =>] CLASS_NAME)]
1724
1725CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1726@end smallexample
1727
1728@noindent
1729This pragma is identical to @code{Import_Procedure} except that the
1730first parameter of @var{local_name}, which must be present, must be of
1731mode @code{OUT}, and externally the subprogram is treated as a function
ad42149c 1732with this parameter as the result of the function. The purpose of this
41af791f
GB
1733capability is to allow the use of @code{OUT} and @code{IN OUT}
1734parameters in interfacing to external functions (which are not permitted
1735in Ada functions). You may optionally use the @code{Mechanism}
1736parameters to specify passing mechanisms for the parameters.
1737If you specify a single mechanism name, it applies to all parameters.
1738Otherwise you may specify a mechanism on a parameter by parameter
ad42149c 1739basis using either positional or named notation. If the mechanism is not
41af791f
GB
1740specified, the default mechanism is used.
1741
1742Note that it is important to use this pragma in conjunction with a separate
1743pragma Import that specifies the desired convention, since otherwise the
1744default convention is Ada, which is almost certainly not what is required.
1745
1746@findex Initialize_Scalars
1747@cindex debugging with Initialize_Scalars
1748@item pragma Initialize_Scalars
1749@noindent
1750Syntax:
1751
1752@smallexample
1753pragma Initialize_Scalars;
1754@end smallexample
1755
1756@noindent
1757This pragma is similar to @code{Normalize_Scalars} conceptually but has
ad42149c 1758two important differences. First, there is no requirement for the pragma
41af791f
GB
1759to be used uniformly in all units of a partition, in particular, it is fine
1760to use this just for some or all of the application units of a partition,
1761without needing to recompile the run-time library.
1762
1763In the case where some units are compiled with the pragma, and some without,
1764then a declaration of a variable where the type is defined in package
1765Standard or is locally declared will always be subject to initialization,
ad42149c 1766as will any declaration of a scalar variable. For composite variables,
41af791f
GB
1767whether the variable is initialized may also depend on whether the package
1768in which the type of the variable is declared is compiled with the pragma.
1769
1770The other important difference is that there is control over the value used
ad42149c 1771for initializing scalar objects. At bind time, you can select whether to
41af791f 1772initialize with invalid values (like Normalize_Scalars), or with high or
ad42149c 1773low values, or with a specified bit pattern. See the users guide for binder
41af791f
GB
1774options for specifying these cases.
1775
1776This means that you can compile a program, and then without having to
1777recompile the program, you can run it with different values being used
1778for initializing otherwise uninitialized values, to test if your program
ad42149c 1779behavior depends on the choice. Of course the behavior should not change,
41af791f
GB
1780and if it does, then most likely you have an erroneous reference to an
1781uninitialized value.
1782
1783Note that pragma @code{Initialize_Scalars} is particularly useful in
1784conjunction with the enhanced validity checking that is now provided
ad42149c 1785in GNAT, which checks for invalid values under more conditions.
41af791f
GB
1786Using this feature (see description of the @code{-gnatv} flag in the
1787users guide) in conjunction with pragma @code{Initialize_Scalars}
1788provides a powerful new tool to assist in the detection of problems
1789caused by uninitialized variables.
1790
1791@findex Inline_Always
1792@item pragma Inline_Always
1793@noindent
1794Syntax:
1795
1796@smallexample
1797pragma Inline_Always (NAME [, NAME]);
1798@end smallexample
1799
1800@noindent
ad42149c 1801Similar to pragma @code{Inline} except that inlining is not subject to
41af791f
GB
1802the use of option @code{-gnatn} for inter-unit inlining.
1803
1804@findex Inline_Generic
1805@item pragma Inline_Generic
1806@noindent
1807Syntax:
1808
1809@smallexample
1810pragma Inline_Generic (generic_package_NAME)
1811@end smallexample
1812
1813@noindent
1814This is implemented for compatibility with DEC Ada 83 and is recognized,
ad42149c 1815but otherwise ignored, by GNAT@. All generic instantiations are inlined
46b58b8c 1816by default when using GNAT@.
41af791f
GB
1817
1818@findex Interface
1819@item pragma Interface
1820@noindent
1821Syntax:
1822
1823@smallexample
1824pragma Interface (
1825 [Convention =>] convention_identifier,
1826 [Entity =>] local_name
1827 [, [External_Name =>] static_string_expression],
1828 [, [Link_Name =>] static_string_expression]);
1829@end smallexample
1830
1831@noindent
1832This pragma is identical in syntax and semantics to
ad42149c
FW
1833the standard Ada 95 pragma @code{Import}. It is provided for compatibility
1834with Ada 83. The definition is upwards compatible both with pragma
41af791f
GB
1835@code{Interface} as defined in the Ada 83 Reference Manual, and also
1836with some extended implementations of this pragma in certain Ada 83
1837implementations.
1838
1839@findex Interface_Name
1840@item pragma Interface_Name
1841@noindent
1842Syntax:
1843
1844@smallexample
1845pragma Interface_Name (
1846 [Entity =>] LOCAL_NAME
1847 [, [External_Name =>] static_string_EXPRESSION]
1848 [, [Link_Name =>] static_string_EXPRESSION]);
1849@end smallexample
1850
1851@noindent
1852This pragma provides an alternative way of specifying the interface name
1853for an interfaced subprogram, and is provided for compatibility with Ada
ad42149c 185483 compilers that use the pragma for this purpose. You must provide at
41af791f
GB
1855least one of @var{External_Name} or @var{Link_Name}.
1856
1857@findex License
1858@item pragma License
1859@cindex License checking
1860@noindent
1861Syntax:
1862
1863@smallexample
1864pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
1865@end smallexample
1866
1867@noindent
1868This pragma is provided to allow automated checking for appropriate license
ad42149c 1869conditions with respect to the standard and modified GPL@. A pragma @code{License},
41af791f
GB
1870which is a configuration pragma that typically appears at the start of a
1871source file or in a separate @file{gnat.adc} file, specifies the licensing
1872conditions of a unit as follows:
1873
1874@itemize @bullet
1875@item Unrestricted
1876This is used for a unit that can be freely used with no license restrictions.
1877Examples of such units are public domain units, and units from the Ada
1878Reference Manual.
1879
1880@item GPL
1881This is used for a unit that is licensed under the unmodified GPL, and which
1882therefore cannot be @code{with}'ed by a restricted unit.
1883
1884@item Modified_GPL
1885This is used for a unit licensed under the GNAT modified GPL that includes
1886a special exception paragraph that specifically permits the inclusion of
1887the unit in programs without requiring the entire program to be released
ad42149c 1888under the GPL@. This is the license used for the GNAT run-time which ensures
41af791f
GB
1889that the run-time can be used freely in any program without GPL concerns.
1890
1891@item Restricted
1892This is used for a unit that is restricted in that it is not permitted to
ad42149c 1893depend on units that are licensed under the GPL@. Typical examples are
41af791f 1894proprietary code that is to be released under more restrictive license
ad42149c 1895conditions. Note that restricted units are permitted to @code{with} units
41af791f
GB
1896which are licensed under the modified GPL (this is the whole point of the
1897modified GPL).
1898
1899@end itemize
1900
1901@noindent
1902Normally a unit with no @code{License} pragma is considered to have an
ad42149c 1903unknown license, and no checking is done. However, standard GNAT headers
41af791f
GB
1904are recognized, and license information is derived from them as follows.
1905
1906@itemize @bullet
1907
ad42149c 1908A GNAT license header starts with a line containing 78 hyphens. The following
41af791f
GB
1909comment text is searched for the appearence of any of the following strings.
1910
ad42149c
FW
1911If the string ``GNU General Public License'' is found, then the unit is assumed
1912to have GPL license, unless the string ``As a special exception'' follows, in
46b58b8c 1913which case the license is assumed to be modified GPL@.
41af791f
GB
1914
1915If one of the strings
ad42149c
FW
1916``This specification is adapated from the Ada Semantic Interface'' or
1917``This specification is derived from the Ada Reference Manual'' is found
41af791f
GB
1918then the unit is assumed to be unrestricted.
1919@end itemize
1920
1921@noindent
1922These default actions means that a program with a restricted license pragma
1923will automatically get warnings if a GPL unit is inappropriately
ad42149c 1924@code{with}'ed. For example, the program:
41af791f
GB
1925
1926@smallexample
1927with Sem_Ch3;
1928with GNAT.Sockets;
1929procedure Secret_Stuff is
ad42149c 1930@dots{}
41af791f
GB
1931end Secret_Stuff
1932@end smallexample
1933
1934@noindent
1935if compiled with pragma @code{License} (@code{Restricted}) in a
1936@file{gnat.adc} file will generate the warning:
1937
1938@smallexample
ad42149c 19391. with Sem_Ch3;
41af791f
GB
1940 |
1941 >>> license of withed unit "Sem_Ch3" is incompatible
1942
ad42149c
FW
19432. with GNAT.Sockets;
19443. procedure Secret_Stuff is
41af791f
GB
1945@end smallexample
1946@noindent
1947Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
1948compiler and is licensed under the
1949GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
46b58b8c 1950run time, and is therefore licensed under the modified GPL@.
41af791f
GB
1951
1952@findex Link_With
1953@item pragma Link_With
1954@noindent
1955Syntax:
1956
1957@smallexample
1958pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
1959@end smallexample
1960
1961@noindent
1962This pragma is provided for compatibility with certain Ada 83 compilers.
1963It has exactly the same effect as pragma @code{Linker_Options} except
1964that spaces occurring within one of the string expressions are treated
1965as separators. For example, in the following case:
1966
1967@smallexample
1968pragma Link_With ("-labc -ldef");
1969@end smallexample
1970
1971@noindent
1972results in passing the strings @code{-labc} and @code{-ldef} as two
ad42149c
FW
1973separate arguments to the linker. In addition pragma Link_With allows
1974multiple arguments, with the same effect as successive pragmas.
41af791f
GB
1975
1976@findex Linker_Alias
1977@item pragma Linker_Alias
1978@noindent
1979Syntax:
1980
1981@smallexample
1982pragma Linker_Alias (
1983 [Entity =>] LOCAL_NAME
1984 [Alias =>] static_string_EXPRESSION);
1985@end smallexample
1986
1987@noindent
ad42149c 1988This pragma establishes a linker alias for the given named entity. For
41af791f
GB
1989further details on the exact effect, consult the GCC manual.
1990
1991@findex Linker_Section
1992@item pragma Linker_Section
1993@noindent
1994Syntax:
1995
1996@smallexample
1997pragma Linker_Section (
1998 [Entity =>] LOCAL_NAME
1999 [Section =>] static_string_EXPRESSION);
2000@end smallexample
2001
2002@noindent
2003This pragma specifies the name of the linker section for the given entity.
2004For further details on the exact effect, consult the GCC manual.
2005
2006@findex No_Run_Time
2007@item pragma No_Run_Time
2008@noindent
2009Syntax:
2010
2011@smallexample
2012pragma No_Run_Time;
2013@end smallexample
2014
2015@noindent
2016This is a configuration pragma that makes sure the user code does not
ad42149c
FW
2017use nor need anything from the GNAT run time. This is mostly useful in
2018context where code certification is required. Please consult the
2019@cite{GNAT Pro High-Integrity Edition User's Guide} for additional information.
41af791f
GB
2020
2021@findex Normalize_Scalars
2022@item pragma Normalize_Scalars
2023@noindent
2024Syntax:
2025
2026@smallexample
2027pragma Normalize_Scalars;
2028@end smallexample
2029
2030@noindent
ad42149c 2031This is a language defined pragma which is fully implemented in GNAT@. The
41af791f 2032effect is to cause all scalar objects that are not otherwise initialized
ad42149c 2033to be initialized. The initial values are implementation dependent and
41af791f
GB
2034are as follows:
2035
2036@table @code
2037@item Standard.Character
2038@noindent
2039Objects whose root type is Standard.Character are initialized to
ad42149c 2040Character'Last. This will be out of range of the subtype only if
41af791f
GB
2041the subtype range excludes this value.
2042
2043@item Standard.Wide_Character
2044@noindent
2045Objects whose root type is Standard.Wide_Character are initialized to
ad42149c 2046Wide_Character'Last. This will be out of range of the subtype only if
41af791f
GB
2047the subtype range excludes this value.
2048
2049@item Integer types
2050@noindent
2051Objects of an integer type are initialized to base_type'First, where
ad42149c
FW
2052base_type is the base type of the object type. This will be out of range
2053of the subtype only if the subtype range excludes this value. For example,
41af791f
GB
2054if you declare the subtype:
2055
2056@smallexample
2057subtype Ityp is integer range 1 .. 10;
2058@end smallexample
2059
2060@noindent
2061then objects of type x will be initialized to Integer'First, a negative
2062number that is certainly outside the range of subtype @code{Ityp}.
2063
2064@item Real types
2065Objects of all real types (fixed and floating) are initialized to
2066base_type'First, where base_Type is the base type of the object type.
2067This will be out of range of the subtype only if the subtype range
2068excludes this value.
2069
2070@item Modular types
ad42149c 2071Objects of a modular type are initialized to typ'Last. This will be out
41af791f
GB
2072of range of the subtype only if the subtype excludes this value.
2073
2074@item Enumeration types
46b58b8c 2075Objects of an enumeration type are initialized to all one-bits, i.e.@: to
ad42149c 2076the value @code{2 ** typ'Size - 1}. This will be out of range of the enumeration
41af791f 2077subtype in all cases except where the subtype contains exactly
ad42149c 20782**8, 2**16, or 2**32 elements.
41af791f
GB
2079
2080@end table
2081
2082@cindex OpenVMS
2083@findex Long_Float
2084@item pragma Long_Float
2085@noindent
2086Syntax:
2087
2088@smallexample
2089pragma Long_Float (FLOAT_FORMAT);
2090
2091FLOAT_FORMAT ::= D_Float | G_Float
2092@end smallexample
2093
2094@noindent
46b58b8c 2095This pragma is implemented only in the OpenVMS implementation of GNAT@.
41af791f
GB
2096It allows control over the internal representation chosen for the predefined
2097type @code{Long_Float} and for floating point type representations with
ad42149c 2098@code{digits} specified in the range 7 through 15.
41af791f 2099For further details on this pragma, see the
ad42149c
FW
2100@cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use this
2101pragma, the standard runtime libraries must be recompiled. See the
41af791f 2102description of the @code{GNAT LIBRARY} command in the OpenVMS version
ad42149c 2103of the GNAT User's Guide for details on the use of this command.
41af791f
GB
2104
2105@findex Machine_Attribute
2106@item pragma Machine_Attribute @dots{}
2107@noindent
2108Syntax:
2109
2110@smallexample
2111pragma Machine_Attribute (
2112 [Attribute_Name =>] string_EXPRESSION,
2113 [Entity =>] LOCAL_NAME);
2114@end smallexample
2115
2116Machine dependent attributes can be specified for types and/or
ad42149c
FW
2117declarations. Currently only subprogram entities are supported. This
2118pragma is semantically equivalent to
2119@code{__attribute__((@var{string_expression}))} in GNU C,
2120where @code{@var{string_expression}} is
41af791f
GB
2121recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2122@code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2123configuration header file @file{tm.h} for each machine. See the GCC
2124manual for further information.
2125
2126@cindex OpenVMS
2127@findex Main_Storage
2128@item pragma Main_Storage
2129@noindent
2130Syntax:
2131
2132@smallexample
2133pragma Main_Storage
2134 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2135
2136MAIN_STORAGE_OPTION ::=
2137 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2138| [TOP_GUARD =>] static_SIMPLE_EXPRESSION
2139
2140@end smallexample
2141
2142@noindent
ad42149c
FW
2143This pragma is provided for compatibility with OpenVMS Vax Systems. It has
2144no effect in GNAT, other than being syntax checked. Note that the pragma
41af791f
GB
2145also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2146
2147@findex No_Return
2148@item pragma No_Return
2149@noindent
2150Syntax:
2151
2152@smallexample
2153pragma No_Return (procedure_LOCAL_NAME);
2154@end smallexample
2155
2156@noindent
2157@var{procedure_local_NAME} must refer to one or more procedure
ad42149c 2158declarations in the current declarative part. A procedure to which this
41af791f
GB
2159pragma is applied may not contain any explicit @code{return} statements,
2160and also may not contain any implicit return statements from falling off
ad42149c 2161the end of a statement sequence. One use of this pragma is to identify
41af791f
GB
2162procedures whose only purpose is to raise an exception.
2163
2164Another use of this pragma is to suppress incorrect warnings about
2165missing returns in functions, where the last statement of a function
2166statement sequence is a call to such a procedure.
2167
2168@findex Passive
2169@item pragma Passive
2170@noindent
2171Syntax:
2172
2173@smallexample
2174pragma Passive ([Semaphore | No]);
2175@end smallexample
2176
2177@noindent
ad42149c 2178Syntax checked, but otherwise ignored by GNAT@. This is recognized for
41af791f
GB
2179compatibility with DEC Ada 83 implementations, where it is used within a
2180task definition to request that a task be made passive. If the argument
2181@code{Semaphore} is present, or no argument is omitted, then DEC Ada 83
2182treats the pragma as an assertion that the containing task is passive
2183and that optimization of context switch with this task is permitted and
2184desired. If the argument @code{No} is present, the task must not be
ad42149c 2185optimized. GNAT does not attempt to optimize any tasks in this manner
41af791f
GB
2186(since protected objects are available in place of passive tasks).
2187
2188@findex Polling
2189@item pragma Polling
2190@noindent
2191Syntax:
2192
2193@smallexample
2194pragma Polling (ON | OFF);
2195@end smallexample
2196
2197@noindent
ad42149c 2198This pragma controls the generation of polling code. This is normally off.
41af791f 2199If @code{pragma Polling (ON)} is used then periodic calls are generated to
ad42149c
FW
2200the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
2201runtime library, and can be found in file @file{a-excpol.adb}.
41af791f 2202
ad42149c
FW
2203Pragma @code{Polling} can appear as a configuration pragma (for example it can be
2204placed in the @file{gnat.adc} file) to enable polling globally, or it can be used
41af791f
GB
2205in the statement or declaration sequence to control polling more locally.
2206
2207A call to the polling routine is generated at the start of every loop and
ad42149c 2208at the start of every subprogram call. This guarantees that the @code{Poll}
41af791f 2209routine is called frequently, and places an upper bound (determined by
ad42149c 2210the complexity of the code) on the period between two @code{Poll} calls.
41af791f
GB
2211
2212The primary purpose of the polling interface is to enable asynchronous
2213aborts on targets that cannot otherwise support it (for example Windows
2214NT), but it may be used for any other purpose requiring periodic polling.
ad42149c
FW
2215The standard version is null, and can be replaced by a user program. This
2216will require re-compilation of the @code{Ada.Exceptions} package that can be found
2217in files @file{a-except.ads} and @file{a-except.adb}.
41af791f 2218
ad42149c 2219A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
41af791f 2220distribution) is used to enable the asynchronous abort capability on
ad42149c 2221targets that do not normally support the capability. The version of @code{Poll}
41af791f
GB
2222in this file makes a call to the appropriate runtime routine to test for
2223an abort condition.
2224
ad42149c
FW
2225Note that polling can also be enabled by use of the @code{-gnatP} switch. See
2226the @cite{GNAT User's Guide} for details.
41af791f
GB
2227
2228@findex Propagate_Exceptions
2229@cindex Zero Cost Exceptions
2230@item pragma Propagate_Exceptions
2231@noindent
2232Syntax:
2233
2234@smallexample
2235pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2236@end smallexample
2237
2238@noindent
2239This pragma indicates that the given entity, which is the name of an
2240imported foreign-language subprogram may receive an Ada exception,
ad42149c 2241and that the exception should be propagated. It is relevant only if
41af791f 2242zero cost exception handling is in use, and is thus never needed if
ad42149c 2243the alternative @code{longjmp} / @code{setjmp} implementation of exceptions is used
41af791f
GB
2244(although it is harmless to use it in such cases).
2245
2246The implementation of fast exceptions always properly propagates
2247exceptions through Ada code, as described in the Ada Reference Manual.
2248However, this manual is silent about the propagation of exceptions
ad42149c 2249through foreign code. For example, consider the
41af791f
GB
2250situation where @code{P1} calls
2251@code{P2}, and @code{P2} calls @code{P3}, where
46b58b8c 2252@code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
ad42149c 2253@code{P3} raises an Ada exception. The question is whether or not
41af791f
GB
2254it will be propagated through @code{P2} and can be handled in
2255@code{P1}.
2256
ad42149c
FW
2257For the @code{longjmp} / @code{setjmp} implementation of exceptions, the answer is
2258always yes. For some targets on which zero cost exception handling
2259is implemented, the answer is also always yes. However, there are
41af791f
GB
2260some targets, notably in the current version all x86 architecture
2261targets, in which the answer is that such propagation does not
ad42149c 2262happen automatically. If such propagation is required on these
41af791f
GB
2263targets, it is mandatory to use @code{Propagate_Exceptions} to
2264name all foreign language routines through which Ada exceptions
2265may be propagated.
2266
2267@findex Psect_Object
2268@item pragma Psect_Object
2269@noindent
2270Syntax:
2271
2272@smallexample
2273pragma Psect_Object
2274 [Internal =>] LOCAL_NAME,
2275 [, [External =>] EXTERNAL_SYMBOL]
2276 [, [Size =>] EXTERNAL_SYMBOL]
2277
2278EXTERNAL_SYMBOL ::=
2279 IDENTIFIER
2280| static_string_EXPRESSION
2281@end smallexample
2282
2283@noindent
2284This pragma is identical in effect to pragma @code{Common_Object}.
2285
2286@findex Pure_Function
2287@item pragma Pure_Function
2288@noindent
2289Syntax:
2290
2291@smallexample
2292pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2293@end smallexample
2294
2295This pragma appears in the same declarative part as a function
2296declaration (or a set of function declarations if more than one
2297overloaded declaration exists, in which case the pragma applies
ad42149c
FW
2298to all entities). If specifies that the function @code{Entity} is
2299to be considered pure for the purposes of code generation. This means
41af791f
GB
2300that the compiler can assume that there are no side effects, and
2301in particular that two calls with identical arguments produce the
ad42149c 2302same result. It also means that the function can be used in an
41af791f
GB
2303address clause.
2304
2305Note that, quite deliberately, there are no static checks to try
ad42149c 2306to ensure that this promise is met, so @code{Pure_Function} can be used
41af791f 2307with functions that are conceptually pure, even if they do modify
ad42149c 2308global variables. For example, a square root function that is
41af791f
GB
2309instrumented to count the number of times it is called is still
2310conceptually pure, and can still be optimized, even though it
ad42149c 2311modifies a global variable (the count). Memo functions are another
41af791f
GB
2312example (where a table of previous calls is kept and consulted to
2313avoid re-computation).
2314
2315@findex Pure
2316Note: Most functions in a @code{Pure} package are automatically pure, and
ad42149c 2317there is no need to use pragma @code{Pure_Function} for such functions. An
41af791f 2318exception is any function that has at least one formal of type
ad42149c 2319@code{System.Address} or a type derived from it. Such functions are not
41af791f
GB
2320considered pure by default, since the compiler assumes that the
2321@code{Address} parameter may be functioning as a pointer and that the
ad42149c
FW
2322referenced data may change even if the address value does not. The use
2323of pragma @code{Pure_Function} for such a function will override this default
41af791f
GB
2324assumption, and cause the compiler to treat such a function as pure.
2325
2326Note: If pragma @code{Pure_Function} is applied to a renamed function, it
ad42149c 2327applies to the underlying renamed function. This can be used to
41af791f
GB
2328disambiguate cases of overloading where some but not all functions
2329in a set of overloaded functions are to be designated as pure.
2330
2331@findex Ravenscar
2332@item pragma Ravenscar
2333@noindent
2334Syntax:
2335
2336@smallexample
2337pragma Ravenscar
2338@end smallexample
2339
2340@noindent
2341A configuration pragma that establishes the following set of restrictions:
2342
2343@table @code
2344@item No_Abort_Statements
2345[RM D.7] There are no abort_statements, and there are
2346no calls to Task_Identification.Abort_Task.
2347
2348@item No_Select_Statements
2349There are no select_statements.
2350
2351@item No_Task_Hierarchy
2352[RM D.7] All (non-environment) tasks depend
2353directly on the environment task of the partition.
2354
2355@item No_Task_Allocators
2356[RM D.7] There are no allocators for task types
2357or types containing task subcomponents.
2358
2359@item No_Dynamic_Priorities
2360[RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2361
2362@item No_Terminate_Alternatives
2363[RM D.7] There are no selective_accepts with terminate_alternatives
2364
2365@item No_Dynamic_Interrupts
2366There are no semantic dependencies on Ada.Interrupts.
2367
2368@item No_Protected_Type_Allocators
2369There are no allocators for protected types or
2370types containing protected subcomponents.
2371
2372@item No_Local_Protected_Objects
2373Protected objects and access types that designate
2374such objects shall be declared only at library level.
2375
2376@item No_Requeue
2377Requeue statements are not allowed.
2378
2379@item No_Calendar
2380There are no semantic dependencies on the package Ada.Calendar.
2381
2382@item No_Relative_Delay
2383There are no delay_relative_statements.
2384
2385@item No_Task_Attributes
2386There are no semantic dependencies on the Ada.Task_Attributes package and
2387there are no references to the attributes Callable and Terminated [RM 9.9].
2388
2389@item Static_Storage_Size
2390The expression for pragma Storage_Size is static.
2391
2392@item Boolean_Entry_Barriers
2393Entry barrier condition expressions shall be boolean
2394objects which are declared in the protected type
2395which contains the entry.
2396
2397@item Max_Asynchronous_Select_Nesting = 0
2398[RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2399A value of zero prevents the use of any asynchronous_select.
2400
2401@item Max_Task_Entries = 0
2402[RM D.7] Specifies the maximum number of entries
2403per task. The bounds of every entry family
2404of a task unit shall be static, or shall be
2405defined by a discriminant of a subtype whose
2406corresponding bound is static. A value of zero
2407indicates that no rendezvous are possible. For
2408the Ravenscar pragma, the value of Max_Task_Entries is always
24090 (zero).
2410
2411@item Max_Protected_Entries = 1
2412[RM D.7] Specifies the maximum number of entries per
2413protected type. The bounds of every entry family of
2414a protected unit shall be static, or shall be defined
2415by a discriminant of a subtype whose corresponding
2416bound is static. For the Ravenscar pragma the value of
2417Max_Protected_Entries is always 1.
2418
2419@item Max_Select_Alternatives = 0
2420[RM D.7] Specifies the maximum number of alternatives in a selective_accept.
2421For the Ravenscar pragma the value if always 0.
2422
2423@item No_Task_Termination
2424Tasks which terminate are erroneous.
2425
2426@item No_Entry_Queue
ad42149c
FW
2427No task can be queued on a protected entry. Note that this restrictions is
2428checked at run time. The violation of this restriction generates a
41af791f
GB
2429Program_Error exception.
2430@end table
2431
2432@noindent
ad42149c
FW
2433This set of restrictions corresponds to the definition of the ``Ravenscar
2434Profile'' for limited tasking, devised and published by the @cite{International
2435Real-Time Ada Workshop}, 1997.
41af791f
GB
2436
2437The above set is a superset of the restrictions provided by pragma
2438@code{Restricted_Run_Time}, it includes six additional restrictions
2439(@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
2440@code{No_Calendar}, @code{Static_Storage_Size},
ad42149c
FW
2441@code{No_Relative_Delay} and @code{No_Task_Termination}). This means
2442that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time}, automatically
41af791f
GB
2443causes the use of a simplified, more efficient version of the tasking
2444run-time system.
2445
2446@findex Restricted_Run_Time
2447@item pragma Restricted_Run_Time
2448@noindent
2449Syntax:
2450
2451@smallexample
2452pragma Restricted_Run_Time
2453@end smallexample
2454
2455@noindent
2456A configuration pragma that establishes the following set of restrictions:
2457
2458@itemize @bullet
2459@item No_Abort_Statements
2460@item No_Asynchronous_Control
2461@item No_Entry_Queue
2462@item No_Task_Hierarchy
2463@item No_Task_Allocators
2464@item No_Dynamic_Priorities
2465@item No_Terminate_Alternatives
2466@item No_Dynamic_Interrupts
2467@item No_Protected_Type_Allocators
2468@item No_Local_Protected_Objects
2469@item No_Requeue
2470@item No_Task_Attributes
2471@item Max_Asynchronous_Select_Nesting = 0
2472@item Max_Task_Entries = 0
2473@item Max_Protected_Entries = 1
2474@item Max_Select_Alternatives = 0
2475@end itemize
2476
2477@noindent
2478This set of restrictions causes the automatic selection of a simplified
2479version of the run time that provides improved performance for the
2480limited set of tasking functionality permitted by this set of restrictions.
2481
2482@findex Share_Generic
2483@item pragma Share_Generic
2484@noindent
2485Syntax:
2486
2487@smallexample
2488pragma Share_Generic (NAME @{, NAME@});
2489@end smallexample
2490
2491@noindent
2492This pragma is recognized for compatibility with other Ada compilers
ad42149c
FW
2493but is ignored by GNAT@. GNAT does not provide the capability for
2494sharing of generic code. All generic instantiations result in making
41af791f
GB
2495an inlined copy of the template with appropriate substitutions.
2496
2497@findex Source_File_Name
2498@item pragma Source_File_Name
2499@noindent
2500Syntax:
2501
2502@smallexample
2503pragma Source_File_Name (
2504 [Unit_Name =>] unit_NAME,
2505 Spec_File_Name => STRING_LITERAL);
2506
2507pragma Source_File_Name (
2508 [Unit_Name =>] unit_NAME,
2509 Body_File_Name => STRING_LITERAL);
2510@end smallexample
2511
2512@noindent
ad42149c 2513Use this to override the normal naming convention. It is a configuration
41af791f 2514pragma, and so has the usual applicability of configuration pragmas
46b58b8c 2515(i.e.@: it applies to either an entire partition, or to all units in a
41af791f 2516compilation, or to a single unit, depending on how it is used.
ad42149c 2517@var{unit_name} is mapped to @var{file_name_literal}. The identifier for
41af791f
GB
2518the second argument is required, and indicates whether this is the file
2519name for the spec or for the body.
2520
2521Another form of the @code{Source_File_Name} pragma allows
2522the specification of patterns defining alternative file naming schemes
2523to apply to all files.
2524
2525@smallexample
2526pragma Source_File_Name
2527 (Spec_File_Name => STRING_LITERAL
2528 [,Casing => CASING_SPEC]
2529 [,Dot_Replacement => STRING_LITERAL]);
2530
2531pragma Source_File_Name
2532 (Body_File_Name => STRING_LITERAL
2533 [,Casing => CASING_SPEC]
2534 [,Dot_Replacement => STRING_LITERAL]);
2535
2536pragma Source_File_Name
2537 (Subunit_File_Name => STRING_LITERAL
2538 [,Casing => CASING_SPEC]
2539 [,Dot_Replacement => STRING_LITERAL]);
2540
2541CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
2542@end smallexample
2543
2544@noindent
2545The first argument is a pattern that contains a single asterisk indicating
2546the point at which the unit name is to be inserted in the pattern string
ad42149c 2547to form the file name. The second argument is optional. If present it
41af791f 2548specifies the casing of the unit name in the resulting file name string.
ad42149c 2549The default is lower case. Finally the third argument allows for systematic
41af791f
GB
2550replacement of any dots in the unit name by the specified string literal.
2551
2552For more details on the use of the @code{Source_File_Name} pragma,
ad42149c
FW
2553see the sections ``Using Other File Names'' and
2554``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
41af791f
GB
2555
2556@findex Source_Reference
2557@item pragma Source_Reference
2558@noindent
2559Syntax:
2560
2561@smallexample
2562pragma Source_Reference (INTEGER_LITERAL,
2563 STRING_LITERAL);
2564@end smallexample
2565
2566@noindent
2567This pragma must appear as the first line of a source file.
2568@var{integer_literal} is the logical line number of the line following
2569the pragma line (for use in error messages and debugging
ad42149c 2570information). @var{string_literal} is a static string constant that
41af791f 2571specifies the file name to be used in error messages and debugging
ad42149c
FW
2572information. This is most notably used for the output of @code{gnatchop}
2573with the @code{-r} switch, to make sure that the original unchopped
41af791f
GB
2574source file is the one referred to.
2575
2576The second argument must be a string literal, it cannot be a static
ad42149c 2577string expression other than a string literal. This is because its value
41af791f
GB
2578is needed for error messages issued by all phases of the compiler.
2579
2580@findex Stream_Convert
2581@item pragma Stream_Convert
2582@noindent
2583Syntax:
2584
2585@smallexample
2586pragma Stream_Convert (
2587 [Entity =>] type_LOCAL_NAME,
2588 [Read =>] function_NAME,
2589 [Write =>] function NAME);
2590@end smallexample
2591
2592@noindent
2593This pragma provides an efficient way of providing stream functions for
ad42149c 2594types defined in packages. Not only is it simpler to use than declaring
41af791f
GB
2595the necessary functions with attribute representation clauses, but more
2596significantly, it allows the declaration to made in such a way that the
ad42149c 2597stream packages are not loaded unless they are needed. The use of
41af791f
GB
2598the Stream_Convert pragma adds no overhead at all, unless the stream
2599attributes are actually used on the designated type.
2600
2601The first argument specifies the type for which stream functions are
ad42149c
FW
2602provided. The second parameter provides a function used to read values
2603of this type. It must name a function whose argument type may be any
41af791f
GB
2604subtype, and whose returned type must be the type given as the first
2605argument to the pragma.
2606
2607The meaning of the @var{Read}
2608parameter is that if a stream attribute directly
2609or indirectly specifies reading of the type given as the first parameter,
2610then a value of the type given as the argument to the Read function is
2611read from the stream, and then the Read function is used to convert this
2612to the required target type.
2613
2614Similarly the @var{Write} parameter specifies how to treat write attributes
2615that directly or indirectly apply to the type given as the first parameter.
2616It must have an input parameter of the type specified by the first parameter,
2617and the return type must be the same as the input type of the Read function.
2618The effect is to first call the Write function to convert to the given stream
2619type, and then write the result type to the stream.
2620
ad42149c 2621The Read and Write functions must not be overloaded subprograms. If necessary
41af791f
GB
2622renamings can be supplied to meet this requirement.
2623The usage of this attribute is best illustrated by a simple example, taken
2624from the GNAT implementation of package Ada.Strings.Unbounded:
2625
2626@smallexample
2627function To_Unbounded (S : String)
2628 return Unbounded_String
2629 renames To_Unbounded_String;
2630
2631pragma Stream_Convert
2632 (Unbounded_String, To_Unbounded, To_String);
2633@end smallexample
2634
2635@noindent
2636The specifications of the referenced functions, as given in the Ada 95
2637Reference Manual are:
2638
2639@smallexample
2640function To_Unbounded_String (Source : String)
2641 return Unbounded_String;
2642
2643function To_String (Source : Unbounded_String)
2644 return String;
2645@end smallexample
2646
2647@noindent
2648The effect is that if the value of an unbounded string is written to a
2649stream, then the representation of the item in the stream is in the same
2650format used for @code{Standard.String}, and this same representation is
2651expected when a value of this type is read from the stream.
2652
2653@findex Style_Checks
2654@item pragma Style_Checks
2655@noindent
2656Syntax:
2657
2658@smallexample
2659pragma Style_Checks (string_LITERAL | ALL_CHECKS |
2660 On | Off [, LOCAL_NAME]);
2661@end smallexample
2662
2663@noindent
2664This pragma is used in conjunction with compiler switches to control the
ad42149c 2665built in style checking provided by GNAT@. The compiler switches, if set
41af791f
GB
2666provide an initial setting for the switches, and this pragma may be used
2667to modify these settings, or the settings may be provided entirely by
ad42149c 2668the use of the pragma. This pragma can be used anywhere that a pragma
41af791f
GB
2669is legal, including use as a configuration pragma (including use in
2670the @file{gnat.adc} file).
2671
2672The form with a string literal specifies which style options are to be
ad42149c
FW
2673activated. These are additive, so they apply in addition to any previously
2674set style check options. The codes for the options are the same as those
2675used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
2676For example the following two methods can be used to enable
41af791f
GB
2677layout checking:
2678
2679@smallexample
2680pragma Style_Checks ("l");
ad42149c 2681gcc -c -gnatyl @dots{}
41af791f
GB
2682@end smallexample
2683
2684@noindent
2685The form ALL_CHECKS activates all standard checks (its use is equivalent
ad42149c 2686to the use of the @code{gnaty} switch with no options. See GNAT User's
41af791f
GB
2687Guide for details.
2688
2689The forms with @code{Off} and @code{On}
2690can be used to temporarily disable style checks
2691as shown in the following example:
2692
2693@smallexample
2694@iftex
2695@leftskip=0cm
2696@end iftex
2697pragma Style_Checks ("k"); -- requires keywords in lower case
2698pragma Style_Checks (Off); -- turn off style checks
2699NULL; -- this will not generate an error message
2700pragma Style_Checks (On); -- turn style checks back on
2701NULL; -- this will generate an error message
2702@end smallexample
2703
2704@noindent
2705Finally the two argument form is allowed only if the first argument is
ad42149c 2706@code{On} or @code{Off}. The effect is to turn of semantic style checks
41af791f
GB
2707for the specified entity, as shown in the following example:
2708
2709@smallexample
2710@iftex
2711@leftskip=0cm
2712@end iftex
2713pragma Style_Checks ("r"); -- require consistency of identifier casing
2714Arg : Integer;
2715Rf1 : Integer := ARG; -- incorrect, wrong case
2716pragma Style_Checks (Off, Arg);
2717Rf2 : Integer := ARG; -- OK, no error
2718@end smallexample
2719
2720@findex Subtitle
2721@item pragma Subtitle
2722@noindent
2723Syntax:
2724
2725@smallexample
2726pragma Subtitle ([Subtitle =>] STRING_LITERAL);
2727@end smallexample
2728
2729@noindent
2730This pragma is recognized for compatibility with other Ada compilers
46b58b8c 2731but is ignored by GNAT@.
41af791f
GB
2732
2733@findex Suppress_All
2734@item pragma Suppress_All
2735@noindent
2736Syntax:
2737
2738@smallexample
2739pragma Suppress_All;
2740@end smallexample
2741
2742@noindent
2743This pragma can only appear immediately following a compilation
ad42149c
FW
2744unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
2745which it follows. This pragma is implemented for compatibility with DEC
2746Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
46b58b8c 2747configuration pragma is the preferred usage in GNAT@.
41af791f
GB
2748
2749@findex Suppress_Initialization
2750@cindex Suppressing initialization
2751@cindex Initialization, suppression of
2752@item pragma Suppress_Initialization
2753@noindent
2754Syntax:
2755
2756@smallexample
2757pragma Suppress_Initialization ([Entity =>] type_Name);
2758@end smallexample
2759
2760@noindent
2761This pragma suppresses any implicit or explicit initialization
2762associated with the given type name for all variables of this type.
2763
2764@findex Task_Info
2765@item pragma Task_Info
2766@noindent
2767Syntax
2768
2769@smallexample
2770pragma Task_Info (EXPRESSION);
2771@end smallexample
2772
2773@noindent
2774This pragma appears within a task definition (like pragma
ad42149c 2775@code{Priority}) and applies to the task in which it appears. The
41af791f
GB
2776argument must be of type @code{System.Task_Info.Task_Info_Type}.
2777The @code{Task_Info} pragma provides system dependent control over
2778aspect of tasking implementation, for example, the ability to map
ad42149c 2779tasks to specific processors. For details on the facilities available
41af791f
GB
2780for the version of GNAT that you are using, see the documentation
2781in the specification of package System.Task_Info in the runtime
2782library.
2783
2784@findex Task_Name
2785@item pragma Task_Name
2786@noindent
2787Syntax
2788
2789@smallexample
2790pragma Task_Name (string_EXPRESSION);
2791@end smallexample
2792
2793@noindent
2794This pragma appears within a task definition (like pragma
ad42149c 2795@code{Priority}) and applies to the task in which it appears. The
41af791f 2796argument must be of type String, and provides a name to be used for
ad42149c 2797the task instance when the task is created. Note that this expression
41af791f 2798is not required to be static, and in particular, it can contain
ad42149c 2799references to task discriminants. This facility can be used to
41af791f
GB
2800provide different names for different tasks as they are created,
2801as illustrated in the example below.
2802
2803The task name is recorded internally in the run-time structures
ad42149c 2804and is accessible to tools like the debugger. In addition the
41af791f
GB
2805routine @code{Ada.Task_Identification.Image} will return this
2806string, with a unique task address appended.
2807
2808@smallexample
2809-- Example of the use of pragma Task_Name
2810
2811with Ada.Task_Identification;
2812use Ada.Task_Identification;
2813with Text_IO; use Text_IO;
2814procedure t3 is
2815
2816 type Astring is access String;
2817
2818 task type Task_Typ (Name : access String) is
2819 pragma Task_Name (Name.all);
2820 end Task_Typ;
2821
2822 task body Task_Typ is
2823 Nam : constant String := Image (Current_Task);
2824 begin
2825 Put_Line ("-->" & Nam (1 .. 14) & "<--");
2826 end Task_Typ;
2827
2828 type Ptr_Task is access Task_Typ;
2829 Task_Var : Ptr_Task;
2830
2831begin
2832 Task_Var :=
2833 new Task_Typ (new String'("This is task 1"));
2834 Task_Var :=
2835 new Task_Typ (new String'("This is task 2"));
2836end;
2837@end smallexample
2838
2839@findex Task_Storage
2840@item pragma Task_Storage
2841Syntax:
2842
2843@smallexample
2844pragma Task_Storage
2845 [Task_Type =>] LOCAL_NAME,
2846 [Top_Guard =>] static_integer_EXPRESSION);
2847@end smallexample
2848
2849This pragma specifies the length of the guard area for tasks. The guard
2850area is an additional storage area allocated to a task. A value of zero
2851means that either no guard area is created or a minimal guard area is
ad42149c 2852created, depending on the target. This pragma can appear anywhere a
41af791f
GB
2853@code{Storage_Size} attribute definition clause is allowed for a task
2854type.
2855
2856@findex Time_Slice
2857@item pragma Time_Slice
2858@noindent
2859Syntax:
2860
2861@smallexample
2862pragma Time_Slice (static_duration_EXPRESSION);
2863@end smallexample
2864
2865@noindent
2866For implementations of GNAT on operating systems where it is possible
2867to supply a time slice value, this pragma may be used for this purpose.
2868It is ignored if it is used in a system that does not allow this control,
2869or if it appears in other than the main program unit.
2870@cindex OpenVMS
2871Note that the effect of this pragma is identical to the effect of the
2872DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
2873
2874@findex Title
2875@item pragma Title
2876@noindent
2877Syntax:
2878
2879@smallexample
2880pragma Title (TITLING_OPTION [, TITLING OPTION]);
2881
2882TITLING_OPTION ::=
2883 [Title =>] STRING_LITERAL,
2884| [Subtitle =>] STRING_LITERAL
2885@end smallexample
2886
2887@noindent
ad42149c 2888Syntax checked but otherwise ignored by GNAT@. This is a listing control
41af791f 2889pragma used in DEC Ada 83 implementations to provide a title and/or
ad42149c 2890subtitle for the program listing. The program listing generated by GNAT
41af791f
GB
2891does not have titles or subtitles.
2892
2893Unlike other pragmas, the full flexibility of named notation is allowed
46b58b8c 2894for this pragma, i.e.@: the parameters may be given in any order if named
41af791f
GB
2895notation is used, and named and positional notation can be mixed
2896following the normal rules for procedure calls in Ada.
2897
2898@cindex Unions in C
2899@findex Unchecked_Union
2900@item pragma Unchecked_Union
2901@noindent
2902Syntax:
2903
2904@smallexample
2905pragma Unchecked_Union (first_subtype_LOCAL_NAME)
2906@end smallexample
2907
2908@noindent
2909This pragma is used to declare that the specified type should be represented
2910in a manner
2911equivalent to a C union type, and is intended only for use in
ad42149c 2912interfacing with C code that uses union types. In Ada terms, the named
41af791f
GB
2913type must obey the following rules:
2914
2915@itemize @bullet
2916@item
2917It is a non-tagged non-limited record type.
2918@item
2919It has a single discrete discriminant with a default value.
2920@item
2921The component list consists of a single variant part.
2922@item
2923Each variant has a component list with a single component.
2924@item
2925No nested variants are allowed.
2926@item
2927No component has an explicit default value.
2928@item
2929No component has a non-static constraint.
2930@end itemize
2931
2932In addition, given a type that meets the above requirements, the
2933following restrictions apply to its use throughout the program:
2934
2935@itemize @bullet
2936@item
2937The discriminant name can be mentioned only in an aggregate.
2938@item
2939No subtypes may be created of this type.
2940@item
2941The type may not be constrained by giving a discriminant value.
2942@item
2943The type cannot be passed as the actual for a generic formal with a
2944discriminant.
2945@end itemize
2946
2947Equality and inequality operations on @code{unchecked_unions} are not
2948available, since there is no discriminant to compare and the compiler
ad42149c 2949does not even know how many bits to compare. It is implementation
41af791f 2950dependent whether this is detected at compile time as an illegality or
ad42149c 2951whether it is undetected and considered to be an erroneous construct. In
41af791f
GB
2952GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
2953the composite case (where two composites are compared that contain an
2954unchecked union component), so such comparisons are simply considered
2955erroneous.
2956
2957The layout of the resulting type corresponds exactly to a C union, where
2958each branch of the union corresponds to a single variant in the Ada
ad42149c 2959record. The semantics of the Ada program is not changed in any way by
46b58b8c 2960the pragma, i.e.@: provided the above restrictions are followed, and no
41af791f
GB
2961erroneous incorrect references to fields or erroneous comparisons occur,
2962the semantics is exactly as described by the Ada reference manual.
2963Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
2964type and the default convention is C
2965
2966@findex Unimplemented_Unit
2967@item pragma Unimplemented_Unit
2968@noindent
2969Syntax:
2970
2971@smallexample
2972pragma Unimplemented_Unit;
2973@end smallexample
2974
2975@noindent
2976If this pragma occurs in a unit that is processed by the compiler, GNAT
2977aborts with the message @samp{@var{xxx} not implemented}, where
2978@var{xxx} is the name of the current compilation unit. This pragma is
2979intended to allow the compiler to handle unimplemented library units in
2980a clean manner.
2981
2982The abort only happens if code is being generated. Thus you can use
2983specs of unimplemented packages in syntax or semantic checking mode.
2984
ad42149c
FW
2985@findex Unreferenced
2986@item pragma Unreferenced
2987@cindex Warnings, unreferenced
2988@noindent
2989Syntax:
2990
2991@smallexample
2992pragma Unreferenced (local_Name @{, local_Name@});
2993@end smallexample
2994
2995@noindent
2996This pragma signals that the entities whose names are listed are
2997deliberately not referenced. This suppresses warnings about the
2998entities being unreferenced, and in addition a warning will be
2999generated if one of these entities is in fact referenced.
3000
3001This is particularly useful for clearly signalling that a particular
3002parameter is not referenced in some particular subprogram implementation
3003and that this is deliberate. It can also be useful in the case of
3004objects declared only for their initialization or finalization side
3005effects.
3006
3007If @code{local_Name} identifies more than one matching homonym in the
3008current scope, then the entity most recently declared is the one to which
3009the pragma applies.
3010
41af791f
GB
3011@findex Unreserve_All_Interrupts
3012@item pragma Unreserve_All_Interrupts
3013@noindent
3014Syntax:
3015
3016@smallexample
3017pragma Unreserve_All_Interrupts;
3018@end smallexample
3019
3020@noindent
ad42149c 3021Normally certain interrupts are reserved to the implementation. Any attempt
41af791f 3022to attach an interrupt causes Program_Error to be raised, as described in
ad42149c
FW
3023RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3024many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3025reserved to the implementation, so that @kbd{Ctrl-C} can be used to
41af791f
GB
3026interrupt execution.
3027
ad42149c
FW
3028If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3029a program, then all such interrupts are unreserved. This allows the
41af791f 3030program to handle these interrupts, but disables their standard
ad42149c
FW
3031functions. For example, if this pragma is used, then pressing
3032@kbd{Ctrl-C} will not automatically interrupt execution. However,
41af791f
GB
3033a program can then handle the @code{SIGINT} interrupt as it chooses.
3034
3035For a full list of the interrupts handled in a specific implementation,
ad42149c
FW
3036see the source code for the specification of @code{Ada.Interrupts.Names} in
3037file @file{a-intnam.ads}. This is a target dependent file that contains the
3038list of interrupts recognized for a given target. The documentation in
41af791f 3039this file also specifies what interrupts are affected by the use of
ad42149c 3040the @code{Unreserve_All_Interrupts} pragma.
41af791f
GB
3041
3042@findex Unsuppress
3043@item pragma Unsuppress
3044@noindent
3045Syntax:
3046
3047@smallexample
3048pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3049@end smallexample
3050
3051@noindent
ad42149c 3052This pragma undoes the effect of a previous pragma @code{Suppress}. If
41af791f 3053there is no corresponding pragma @code{Suppress} in effect, it has no
ad42149c
FW
3054effect. The range of the effect is the same as for pragma
3055@code{Suppress}. The meaning of the arguments is identical to that used
41af791f
GB
3056in pragma @code{Suppress}.
3057
3058One important application is to ensure that checks are on in cases where
3059code depends on the checks for its correct functioning, so that the code
3060will compile correctly even if the compiler switches are set to suppress
3061checks.
3062
3063@cindex @code{Size}, VADS compatibility
3064@findex Use_VADS_Size
3065@item pragma Use_VADS_Size
3066@noindent
3067Syntax:
3068
3069@smallexample
3070pragma Use_VADS_Size;
3071@end smallexample
3072
3073@noindent
ad42149c 3074This is a configuration pragma. In a unit to which it applies, any use
41af791f 3075of the 'Size attribute is automatically interpreted as a use of the
ad42149c
FW
3076'VADS_Size attribute. Note that this may result in incorrect semantic
3077processing of valid Ada 95 programs. This is intended to aid in the
41af791f 3078handling of legacy code which depends on the interpretation of Size
ad42149c 3079as implemented in the VADS compiler. See description of the VADS_Size
41af791f
GB
3080attribute for further details.
3081
3082@findex Validity_Checks
3083@item pragma Validity_Checks
3084@noindent
3085Syntax:
3086
3087@smallexample
3088pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3089@end smallexample
3090
3091@noindent
3092This pragma is used in conjunction with compiler switches to control the
ad42149c 3093built in validity checking provided by GNAT@. The compiler switches, if set
41af791f
GB
3094provide an initial setting for the switches, and this pragma may be used
3095to modify these settings, or the settings may be provided entirely by
ad42149c 3096the use of the pragma. This pragma can be used anywhere that a pragma
41af791f
GB
3097is legal, including use as a configuration pragma (including use in
3098the @file{gnat.adc} file).
3099
3100The form with a string literal specifies which validity options are to be
ad42149c 3101activated. The validity checks are first set to include only the default
41af791f 3102reference manual settings, and then a string of letters in the string
ad42149c 3103specifies the exact set of options required. The form of this string
41af791f 3104is exactly as described for the @code{-gnatVx} compiler switch (see the
ad42149c 3105GNAT users guide for details). For example the following two methods
41af791f
GB
3106can be used to enable validity checking for mode @code{in} and
3107@code{in out} subprogram parameters:
3108
3109@smallexample
3110pragma Validity_Checks ("im");
ad42149c 3111gcc -c -gnatVim @dots{}
41af791f
GB
3112@end smallexample
3113
3114@noindent
3115The form ALL_CHECKS activates all standard checks (its use is equivalent
3116to the use of the @code{gnatva} switch.
3117
3118The forms with @code{Off} and @code{On}
3119can be used to temporarily disable validity checks
3120as shown in the following example:
3121
3122@smallexample
3123@iftex
3124@leftskip=0cm
3125@end iftex
3126pragma Validity_Checks ("c"); -- validity checks for copies
3127pragma Validity_Checks (Off); -- turn off validity checks
3128A := B; -- B will not be validity checked
3129pragma Validity_Checks (On); -- turn validity checks back on
3130A := C; -- C will be validity checked
3131@end smallexample
3132
3133@findex Volatile
3134@item pragma Volatile
3135@noindent
3136Syntax:
3137
3138@smallexample
3139pragma Volatile (local_NAME)
3140@end smallexample
3141
3142@noindent
3143This pragma is defined by the Ada 95 Reference Manual, and the GNAT
ad42149c 3144implementation is fully conformant with this definition. The reason it
41af791f 3145is mentioned in this section is that a pragma of the same name was supplied
ad42149c 3146in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation
41af791f
GB
3147of pragma Volatile is upwards compatible with the implementation in
3148Dec Ada 83.
3149
3150@findex Warnings
3151@item pragma Warnings
3152@noindent
3153Syntax:
3154
3155@smallexample
3156pragma Warnings (On | Off [, LOCAL_NAME]);
3157@end smallexample
3158
3159@noindent
3160Normally warnings are enabled, with the output being controlled by
ad42149c 3161the command line switch. Warnings (@code{Off}) turns off generation of
41af791f 3162warnings until a Warnings (@code{On}) is encountered or the end of the
ad42149c 3163current unit. If generation of warnings is turned off using this
41af791f
GB
3164pragma, then no warning messages are output, regardless of the
3165setting of the command line switches.
3166
3167The form with a single argument is a configuration pragma.
3168
3169If the @var{local_name} parameter is present, warnings are suppressed for
ad42149c 3170the specified entity. This suppression is effective from the point where
41af791f
GB
3171it occurs till the end of the extended scope of the variable (similar to
3172the scope of @code{Suppress}).
3173
3174@findex Weak_External
3175@item pragma Weak_External
3176@noindent
3177Syntax:
3178
3179@smallexample
3180pragma Weak_External ([Entity =>] LOCAL_NAME);
3181@end smallexample
3182
3183@noindent
3184This pragma specifies that the given entity should be marked as a weak
ad42149c 3185external (one that does not have to be resolved) for the linker. For
41af791f
GB
3186further details, consult the GCC manual.
3187@end table
3188
3189@node Implementation Defined Attributes
3190@chapter Implementation Defined Attributes
3191Ada 95 defines (throughout the Ada 95 reference manual,
3192summarized in annex K),
3193a set of attributes that provide useful additional functionality in all
ad42149c 3194areas of the language. These language defined attributes are implemented
41af791f
GB
3195in GNAT and work as described in the Ada 95 Reference Manual.
3196
3197In addition, Ada 95 allows implementations to define additional
ad42149c 3198attributes whose meaning is defined by the implementation. GNAT provides
41af791f 3199a number of these implementation-dependent attributes which can be used
ad42149c 3200to extend and enhance the functionality of the compiler. This section of
41af791f
GB
3201the GNAT reference manual describes these additional attributes.
3202
3203Note that any program using these attributes may not be portable to
3204other compilers (although GNAT implements this set of attributes on all
ad42149c 3205platforms). Therefore if portability to other compilers is an important
41af791f
GB
3206consideration, you should minimize the use of these attributes.
3207
3208@table @code
3209@findex Abort_Signal
3210@item Abort_Signal
3211@noindent
3212@code{Standard'Abort_Signal} (@code{Standard} is the only allowed
3213prefix) provides the entity for the special exception used to signal
ad42149c 3214task abort or asynchronous transfer of control. Normally this attribute
41af791f
GB
3215should only be used in the tasking runtime (it is highly peculiar, and
3216completely outside the normal semantics of Ada, for a user program to
3217intercept the abort exception).
3218
3219@cindex Size of @code{Address}
3220@findex Address_Size
3221@item Address_Size
3222@noindent
3223@code{Standard'Address_Size} (@code{Standard} is the only allowed
3224prefix) is a static constant giving the number of bits in an
ad42149c 3225@code{Address}. It is used primarily for constructing the definition of
41af791f
GB
3226@code{Memory_Size} in package @code{Standard}, but may be freely used in user
3227programs and has the advantage of being static, while a direct
3228reference to System.Address'Size is non-static because Address
3229is a private type.
3230
3231@findex Asm_Input
3232@item Asm_Input
3233@noindent
3234The @code{Asm_Input} attribute denotes a function that takes two
3235parameters. The first is a string, the second is an expression of the
ad42149c 3236type designated by the prefix. The first (string) argument is required
41af791f 3237to be a static expression, and is the constraint for the parameter,
ad42149c
FW
3238(e.g.@: what kind of register is required). The second argument is the
3239value to be used as the input argument. The possible values for the
41af791f
GB
3240constant are the same as those used in the RTL, and are dependent on
3241the configuration file used to built the GCC back end.
3242@ref{Machine Code Insertions}
3243
3244@findex Asm_Output
3245@item Asm_Output
3246@noindent
3247The @code{Asm_Output} attribute denotes a function that takes two
3248parameters. The first is a string, the second is the name of a variable
ad42149c 3249of the type designated by the attribute prefix. The first (string)
41af791f 3250argument is required to be a static expression and designates the
46b58b8c 3251constraint for the parameter (e.g.@: what kind of register is
ad42149c
FW
3252required). The second argument is the variable to be updated with the
3253result. The possible values for constraint are the same as those used in
41af791f
GB
3254the RTL, and are dependent on the configuration file used to build the
3255GCC back end. If there are no output operands, then this argument may
3256either be omitted, or explicitly given as @code{No_Output_Operands}.
3257@ref{Machine Code Insertions}
3258
3259@cindex OpenVMS
3260@findex AST_Entry
3261@item AST_Entry
3262@noindent
ad42149c 3263This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
41af791f
GB
3264the name of an entry, it yields a value of the predefined type AST_Handler
3265(declared in the predefined package System, as extended by the use of
ad42149c
FW
3266pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
3267be called when an AST occurs. For further details, refer to the @cite{DEC Ada
3268Language Reference Manual}, section 9.12a.
41af791f
GB
3269
3270@findex Bit
3271@item Bit
3272@code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
3273offset within the storage unit (byte) that contains the first bit of
ad42149c 3274storage allocated for the object. The value of this attribute is of the
41af791f
GB
3275type @code{Universal_Integer}, and is always a non-negative number not
3276exceeding the value of @code{System.Storage_Unit}.
3277
3278For an object that is a variable or a constant allocated in a register,
ad42149c 3279the value is zero. (The use of this attribute does not force the
41af791f
GB
3280allocation of a variable to memory).
3281
3282For an object that is a formal parameter, this attribute applies
3283to either the matching actual parameter or to a copy of the
3284matching actual parameter.
3285
ad42149c 3286For an access object the value is zero. Note that
41af791f 3287@code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
ad42149c 3288designated object. Similarly for a record component
41af791f
GB
3289@code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
3290@code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
3291are subject to index checks.
3292
3293This attribute is designed to be compatible with the DEC Ada 83 definition
3294and implementation of the @code{Bit} attribute.
3295
3296@findex Bit_Position
3297@item Bit_Position
3298@noindent
3299@code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
3300of the fields of the record type, yields the bit
3301offset within the record contains the first bit of
ad42149c
FW
3302storage allocated for the object. The value of this attribute is of the
3303type @code{Universal_Integer}. The value depends only on the field
41af791f
GB
3304@var{C} and is independent of the alignment of
3305the containing record @var{R}.
3306
3307@findex Code_Address
3308@cindex Subprogram address
3309@cindex Address of subprogram code
3310@item Code_Address
3311@noindent
3312The @code{'Address}
3313attribute may be applied to subprograms in Ada 95, but the
3314intended effect from the Ada 95 reference manual seems to be to provide
3315an address value which can be used to call the subprogram by means of
3316an address clause as in the following example:
3317
3318@smallexample
ad42149c 3319procedure K is @dots{}
41af791f
GB
3320
3321procedure L;
3322for L'Address use K'Address;
3323pragma Import (Ada, L);
3324@end smallexample
3325
3326@noindent
ad42149c 3327A call to @code{L} is then expected to result in a call to @code{K}@. In Ada 83, where
41af791f
GB
3328there were no access-to-subprogram values, this was a common work around
3329for getting the effect of an indirect call.
ad42149c 3330GNAT implements the above use of @code{Address} and the technique illustrated
41af791f
GB
3331by the example code works correctly.
3332
3333However, for some purposes, it is useful to have the address of the start
ad42149c
FW
3334of the generated code for the subprogram. On some architectures, this is
3335not necessarily the same as the @code{Address} value described above. For example,
3336the @code{Address} value may reference a subprogram descriptor rather than the
41af791f
GB
3337subprogram itself.
3338
3339The @code{'Code_Address} attribute, which can only be applied to
3340subprogram entities, always returns the address of the start of the
3341generated code of the specified subprogram, which may or may not be
3342the same value as is returned by the corresponding @code{'Address}
3343attribute.
3344
3345@cindex Big endian
3346@cindex Little endian
3347@findex Default_Bit_Order
3348@item Default_Bit_Order
3349@noindent
3350@code{Standard'Default_Bit_Order} (@code{Standard} is the only
3351permissible prefix), provides the value @code{System.Default_Bit_Order}
3352as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
ad42149c 3353@code{Low_Order_First}). This is used to construct the definition of
41af791f
GB
3354@code{Default_Bit_Order} in package @code{System}.
3355
3356@findex Elaborated
3357@item Elaborated
3358@noindent
ad42149c 3359The prefix of the @code{'Elaborated} attribute must be a unit name. The
41af791f 3360value is a Boolean which indicates whether or not the given unit has been
ad42149c 3361elaborated. This attribute is primarily intended for internal use by the
41af791f 3362generated code for dynamic elaboration checking, but it can also be used
ad42149c 3363in user programs. The value will always be True once elaboration of all
41af791f
GB
3364units has been completed.
3365
3366@findex Elab_Body
3367@item Elab_Body
3368@noindent
ad42149c 3369This attribute can only be applied to a program unit name. It returns
41af791f 3370the entity for the corresponding elaboration procedure for elaborating
ad42149c 3371the body of the referenced unit. This is used in the main generated
41af791f
GB
3372elaboration procedure by the binder and is not normally used in any
3373other context. However, there may be specialized situations in which it
3374is useful to be able to call this elaboration procedure from Ada code,
46b58b8c 3375e.g.@: if it is necessary to do selective re-elaboration to fix some
41af791f
GB
3376error.
3377
3378@findex Elab_Spec
3379@item Elab_Spec
3380@noindent
ad42149c 3381This attribute can only be applied to a program unit name. It returns
41af791f 3382the entity for the corresponding elaboration procedure for elaborating
ad42149c 3383the specification of the referenced unit. This is used in the main
41af791f
GB
3384generated elaboration procedure by the binder and is not normally used
3385in any other context. However, there may be specialized situations in
3386which it is useful to be able to call this elaboration procedure from
46b58b8c 3387Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
41af791f
GB
3388some error.
3389
3390@cindex Ada 83 attributes
3391@findex Emax
3392@item Emax
3393@noindent
ad42149c 3394The @code{Emax} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3395the Ada 83 reference manual for an exact description of the semantics of
3396this attribute.
3397
3398@cindex Representation of enums
3399@findex Enum_Rep
3400@item Enum_Rep
3401@noindent
3402For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
3403function with the following specification:
3404
3405@smallexample
3406function @var{S}'Enum_Rep (Arg : @var{S}'Base)
3407 return Universal_Integer;
3408@end smallexample
3409
3410@noindent
ad42149c 3411It is also allowable to apply @code{Enum_Rep} directly to an object of an
41af791f 3412enumeration type or to a non-overloaded enumeration
ad42149c 3413literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
41af791f
GB
3414@code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
3415enumeration literal or object.
3416
3417The function returns the representation value for the given enumeration
ad42149c
FW
3418value. This will be equal to value of the @code{Pos} attribute in the
3419absence of an enumeration representation clause. This is a static
46b58b8c 3420attribute (i.e.@: the result is static if the argument is static).
41af791f 3421
ad42149c
FW
3422@code{@var{S}'Enum_Rep} can also be used with integer types and objects, in which
3423case it simply returns the integer value. The reason for this is to allow
3424it to be used for @code{(<>)} discrete formal arguments in a generic unit that
3425can be instantiated with either enumeration types or integer types. Note
3426that if @code{Enum_Rep} is used on a modular type whose upper bound exceeds the
41af791f
GB
3427upper bound of the largest signed integer type, and the argument is a
3428variable, so that the universal integer calculation is done at run-time,
3429then the call to @code{Enum_Rep} may raise @code{Constraint_Error}.
3430
3431@cindex Ada 83 attributes
3432@findex Epsilon
3433@item Epsilon
3434@noindent
ad42149c 3435The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3436the Ada 83 reference manual for an exact description of the semantics of
3437this attribute.
3438
3439@findex Fixed_Value
3440@item Fixed_Value
3441@noindent
3442For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
3443function with the following specification:
3444
3445@smallexample
3446function @var{S}'Fixed_Value (Arg : Universal_Integer)
3447 return @var{S};
3448@end smallexample
3449
3450@noindent
3451The value returned is the fixed-point value @var{V} such that
3452
3453@smallexample
3454@var{V} = Arg * @var{S}'Small
3455@end smallexample
3456
3457@noindent
3458The effect is thus equivalent to first converting the argument to the
3459integer type used to represent @var{S}, and then doing an unchecked
ad42149c 3460conversion to the fixed-point type. This attribute is primarily intended
41af791f
GB
3461for use in implementation of the input-output functions for fixed-point
3462values.
3463
3464@cindex Discriminants, testing for
3465@findex Has_Discriminants
3466@item Has_Discriminants
3467@noindent
ad42149c 3468The prefix of the @code{Has_Discriminants} attribute is a type. The result
41af791f 3469is a Boolean value which is True if the type has discriminants, and False
ad42149c
FW
3470otherwise. The intended use of this attribute is in conjunction with generic
3471definitions. If the attribute is applied to a generic private type, it
41af791f
GB
3472indicates whether or not the corresponding actual type has discriminants.
3473
3474@findex Img
3475@item Img
3476@noindent
3477The @code{Img} attribute differs from @code{Image} in that it may be
3478applied to objects as well as types, in which case it gives the
ad42149c 3479@code{Image} for the subtype of the object. This is convenient for
41af791f
GB
3480debugging:
3481
3482@smallexample
3483Put_Line ("X = " & X'Img);
3484@end smallexample
3485
3486@noindent
3487has the same meaning as the more verbose:
3488
3489@smallexample
3490Put_Line ("X = " & @var{type}'Image (X));
3491@end smallexample
3492
46b58b8c 3493where @var{type} is the subtype of the object X@.
41af791f
GB
3494
3495@findex Integer_Value
3496@item Integer_Value
3497@noindent
3498For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
3499function with the following specification:
3500
3501@smallexample
3502function @var{S}'Integer_Value (Arg : Universal_Fixed)
3503 return @var{S};
3504@end smallexample
3505
3506@noindent
3507The value returned is the integer value @var{V}, such that
3508
3509@smallexample
3510Arg = @var{V} * @var{type}'Small
3511@end smallexample
3512
3513@noindent
3514The effect is thus equivalent to first doing an unchecked convert from
3515the fixed-point type to its corresponding implementation type, and then
ad42149c 3516converting the result to the target integer type. This attribute is
41af791f
GB
3517primarily intended for use in implementation of the standard
3518input-output functions for fixed-point values.
3519
3520@cindex Ada 83 attributes
3521@findex Large
3522@item Large
3523@noindent
ad42149c 3524The @code{Large} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3525the Ada 83 reference manual for an exact description of the semantics of
3526this attribute.
3527
3528@findex Machine_Size
3529@item Machine_Size
3530@noindent
ad42149c 3531This attribute is identical to the @code{Object_Size} attribute. It is
41af791f
GB
3532provided for compatibility with the DEC Ada 83 attribute of this name.
3533
3534@cindex Ada 83 attributes
3535@findex Mantissa
3536@item Mantissa
3537@noindent
ad42149c 3538The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3539the Ada 83 reference manual for an exact description of the semantics of
3540this attribute.
3541
3542@cindex Interrupt priority, maximum
3543@findex Max_Interrupt_Priority
3544@item Max_Interrupt_Priority
3545@noindent
3546@code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
3547permissible prefix), provides the value
3548@code{System.Max_Interrupt_Priority} and is intended primarily for
3549constructing this definition in package @code{System}.
3550
3551@cindex Priority, maximum
3552@findex Max_Priority
3553@item Max_Priority
3554@noindent
3555@code{Standard'Max_Priority} (@code{Standard} is the only permissible
3556prefix) provides the value @code{System.Max_Priority} and is intended
3557primarily for constructing this definition in package @code{System}.
3558
3559@cindex Alignment, maximum
3560@findex Maximum_Alignment
3561@item Maximum_Alignment
3562@noindent
3563@code{Standard'Maximum_Alignment} (@code{Standard} is the only
3564permissible prefix) provides the maximum useful alignment value for the
ad42149c 3565target. This is a static value that can be used to specify the alignment
41af791f 3566for an object, guaranteeing that it is properly aligned in all
ad42149c 3567cases. This is useful when an external object is imported and its
41af791f
GB
3568alignment requirements are unknown.
3569
3570@cindex Return values, passing mechanism
3571@cindex Parameters, passing mechanism
3572@findex Mechanism_Code
3573@item Mechanism_Code
3574@noindent
3575@code{@var{function}'Mechanism_Code} yields an integer code for the
3576mechanism used for the result of function, and
3577@code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
3578used for formal parameter number @var{n} (a static integer value with 1
ad42149c 3579meaning the first parameter) of @var{subprogram}. The code returned is:
41af791f
GB
3580
3581@table @asis
3582@item 1
3583by copy (value)
3584@item 2
3585by reference
3586@item 3
3587by descriptor (default descriptor class)
3588@item 4
3589by descriptor (UBS: unaligned bit string)
3590@item 5
3591by descriptor (UBSB: aligned bit string with arbitrary bounds)
3592@item 6
3593by descriptor (UBA: unaligned bit array)
3594@item 7
3595by descriptor (S: string, also scalar access type parameter)
3596@item 8
3597by descriptor (SB: string with arbitrary bounds)
3598@item 9
3599by descriptor (A: contiguous array)
3600@item 10
3601by descriptor (NCA: non-contiguous array)
3602@end table
3603
3604@cindex OpenVMS
ad42149c 3605Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
41af791f
GB
3606
3607@cindex Zero address, passing
3608@findex Null_Parameter
3609@item Null_Parameter
3610@noindent
3611A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
ad42149c 3612type or subtype @var{T} allocated at machine address zero. The attribute
41af791f 3613is allowed only as the default expression of a formal parameter, or as
ad42149c 3614an actual expression of a subprogram call. In either case, the
41af791f
GB
3615subprogram must be imported.
3616
3617The identity of the object is represented by the address zero in the
3618argument list, independent of the passing mechanism (explicit or
3619default).
3620
3621This capability is needed to specify that a zero address should be
3622passed for a record or other composite object passed by reference.
3623There is no way of indicating this without the @code{Null_Parameter}
3624attribute.
3625
3626@cindex Size, used for objects
3627@findex Object_Size
3628@item Object_Size
3629@noindent
3630The size of an object is not necessarily the same as the size of the type
ad42149c
FW
3631of an object. This is because by default object sizes are increased to be
3632a multiple of the alignment of the object. For example,
41af791f
GB
3633@code{Natural'Size} is
363431, but by default objects of type @code{Natural} will have a size of 32 bits.
3635Similarly, a record containing an integer and a character:
3636
3637@smallexample
3638type Rec is record
3639 I : Integer;
3640 C : Character;
3641end record;
3642@end smallexample
3643
3644@noindent
ad42149c 3645will have a size of 40 (that is @code{Rec'Size} will be 40. The
41af791f
GB
3646alignment will be 4, because of the
3647integer field, and so the default size of record objects for this type
3648will be 64 (8 bytes).
3649
3650The @code{@var{type}'Object_Size} attribute
3651has been added to GNAT to allow the
ad42149c 3652default object size of a type to be easily determined. For example,
41af791f
GB
3653@code{Natural'Object_Size} is 32, and
3654@code{Rec'Object_Size} (for the record type in the above example) will be
ad42149c 365564. Note also that, unlike the situation with the
41af791f
GB
3656@code{Size} attribute as defined in the Ada RM, the
3657@code{Object_Size} attribute can be specified individually
ad42149c 3658for different subtypes. For example:
41af791f
GB
3659
3660@smallexample
3661type R is new Integer;
3662subtype R1 is R range 1 .. 10;
3663subtype R2 is R range 1 .. 10;
3664for R2'Object_Size use 8;
3665@end smallexample
3666
3667@noindent
3668In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
366932 since the default object size for a subtype is the same as the object size
ad42149c 3670for the parent subtype. This means that objects of type @code{R}
41af791f 3671or @code{R1} will
ad42149c 3672by default be 32 bits (four bytes). But objects of type
41af791f
GB
3673@code{R2} will be only
36748 bits (one byte), since @code{R2'Object_Size} has been set to 8.
3675
3676@cindex Parameters, when passed by reference
3677@findex Passed_By_Reference
3678@item Passed_By_Reference
3679@noindent
3680@code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
3681a value of type @code{Boolean} value that is @code{True} if the type is
3682normally passed by reference and @code{False} if the type is normally
ad42149c
FW
3683passed by copy in calls. For scalar types, the result is always @code{False}
3684and is static. For non-scalar types, the result is non-static.
41af791f
GB
3685
3686@findex Range_Length
3687@item Range_Length
3688@noindent
3689@code{@var{type}'Range_Length} for any discrete type @var{type} yields
3690the number of values represented by the subtype (zero for a null
ad42149c 3691range). The result is static for static subtypes. @code{Range_Length}
41af791f
GB
3692applied to the index subtype of a one dimensional array always gives the
3693same result as @code{Range} applied to the array itself.
3694
3695@cindex Ada 83 attributes
3696@findex Safe_Emax
3697@item Safe_Emax
3698@noindent
ad42149c 3699The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3700the Ada 83 reference manual for an exact description of the semantics of
3701this attribute.
3702
3703@cindex Ada 83 attributes
3704@findex Safe_Large
3705@item Safe_Large
3706@noindent
ad42149c 3707The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3708the Ada 83 reference manual for an exact description of the semantics of
3709this attribute.
3710
3711@cindex Ada 83 attributes
3712@findex Safe_Large
3713@item Safe_Large
3714@noindent
ad42149c 3715The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
41af791f
GB
3716the Ada 83 reference manual for an exact description of the semantics of
3717this attribute.
3718
3719@cindex Ada 83 attributes
3720@findex Small
3721@item Small
3722@noindent
3723The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
3724GNAT also allows this attribute to be applied to floating-point types
ad42149c 3725for compatibility with Ada 83. See
41af791f
GB
3726the Ada 83 reference manual for an exact description of the semantics of
3727this attribute when applied to floating-point types.
3728
3729@findex Storage_Unit
3730@item Storage_Unit
3731@noindent
3732@code{Standard'Storage_Unit} (@code{Standard} is the only permissible
3733prefix) provides the value @code{System.Storage_Unit} and is intended
3734primarily for constructing this definition in package @code{System}.
3735
3736@findex Tick
3737@item Tick
3738@noindent
3739@code{Standard'Tick} (@code{Standard} is the only permissible prefix)
3740provides the value of @code{System.Tick} and is intended primarily for
3741constructing this definition in package @code{System}.
3742
3743@findex To_Address
3744@item To_Address
3745@noindent
3746The @code{System'To_Address}
3747(@code{System} is the only permissible prefix)
3748denotes a function identical to
3749@code{System.Storage_Elements.To_Address} except that
ad42149c 3750it is a static attribute. This means that if its argument is
41af791f 3751a static expression, then the result of the attribute is a
ad42149c 3752static expression. The result is that such an expression can be
46b58b8c 3753used in contexts (e.g.@: preelaborable packages) which require a
41af791f
GB
3754static expression and where the function call could not be used
3755(since the function call is always non-static, even if its
3756argument is static).
3757
3758@findex Type_Class
3759@item Type_Class
3760@noindent
3761@code{@var{type}'Type_Class} for any type or subtype @var{type} yields
ad42149c 3762the value of the type class for the full type of @var{type}. If
41af791f
GB
3763@var{type} is a generic formal type, the value is the value for the
3764corresponding actual subtype. The value of this attribute is of type
3765@code{System.Aux_DEC.Type_Class}, which has the following definition:
3766
3767@smallexample
3768 type Type_Class is
3769 (Type_Class_Enumeration,
3770 Type_Class_Integer,
3771 Type_Class_Fixed_Point,
3772 Type_Class_Floating_Point,
3773 Type_Class_Array,
3774 Type_Class_Record,
3775 Type_Class_Access,
3776 Type_Class_Task,
3777 Type_Class_Address);
3778@end smallexample
3779
3780@noindent
3781Protected types yield the value @code{Type_Class_Task}, which thus
ad42149c 3782applies to all concurrent types. This attribute is designed to
41af791f
GB
3783be compatible with the DEC Ada 83 attribute of the same name.
3784
3785@findex UET_Address
3786@item UET_Address
3787@noindent
3788The @code{UET_Address} attribute can only be used for a prefix which
ad42149c
FW
3789denotes a library package. It yields the address of the unit exception
3790table when zero cost exception handling is used. This attribute is
3791intended only for use within the GNAT implementation. See the unit
3792@code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
41af791f
GB
3793for details on how this attribute is used in the implementation.
3794
3795@cindex Named numbers, representation of
3796@findex Universal_Literal_String
3797@item Universal_Literal_String
3798@noindent
3799The prefix of @code{Universal_Literal_String} must be a named
ad42149c
FW
3800number. The static result is the string consisting of the characters of
3801the number as defined in the original source. This allows the user
41af791f
GB
3802program to access the actual text of named numbers without intermediate
3803conversions and without the need to enclose the strings in quotes (which
ad42149c 3804would preclude their use as numbers). This is used internally for the
41af791f
GB
3805construction of values of the floating-point attributes from the file
3806@file{ttypef.ads}, but may also be used by user programs.
3807
3808@cindex @code{Access}, unrestricted
3809@findex Unrestricted_Access
3810@item Unrestricted_Access
3811@noindent
3812The @code{Unrestricted_Access} attribute is similar to @code{Access}
ad42149c 3813except that all accessibility and aliased view checks are omitted. This
41af791f
GB
3814is a user-beware attribute. It is similar to
3815@code{Address}, for which it is a desirable replacement where the value
ad42149c 3816desired is an access type. In other words, its effect is identical to
41af791f 3817first applying the @code{Address} attribute and then doing an unchecked
ad42149c 3818conversion to a desired access type. In GNAT, but not necessarily in
41af791f
GB
3819other implementations, the use of static chains for inner level
3820subprograms means that @code{Unrestricted_Access} applied to a
3821subprogram yields a value that can be called as long as the subprogram
3822is in scope (normal Ada 95 accessibility rules restrict this usage).
3823
3824@cindex @code{Size}, VADS compatibility
3825@findex VADS_Size
3826@item VADS_Size
3827@noindent
3828The @code{'VADS_Size} attribute is intended to make it easier to port
3829legacy code which relies on the semantics of @code{'Size} as implemented
ad42149c
FW
3830by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
3831same semantic interpretation. In particular, @code{'VADS_Size} applied
41af791f
GB
3832to a predefined or other primitive type with no Size clause yields the
3833Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
ad42149c 3834typical machines). In addition @code{'VADS_Size} applied to an object
41af791f
GB
3835gives the result that would be obtained by applying the attribute to
3836the corresponding type.
3837
3838@cindex @code{Size}, setting for not-first subtype
3839@findex Value_Size
3840@item Value_Size
3841@code{@var{type}'Value_Size} is the number of bits required to represent
ad42149c 3842a value of the given subtype. It is the same as @code{@var{type}'Size},
41af791f
GB
3843but, unlike @code{Size}, may be set for non-first subtypes.
3844
3845@findex Wchar_T_Size
3846@item Wchar_T_Size
3847@code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
3848prefix) provides the size in bits of the C @code{wchar_t} type
3849primarily for constructing the definition of this type in
3850package @code{Interfaces.C}.
3851
3852@findex Word_Size
3853@item Word_Size
3854@code{Standard'Word_Size} (@code{Standard} is the only permissible
3855prefix) provides the value @code{System.Word_Size} and is intended
3856primarily for constructing this definition in package @code{System}.
3857@end table
3858@node Implementation Advice
3859@chapter Implementation Advice
3860The main text of the Ada 95 Reference Manual describes the required
3861behavior of all Ada 95 compilers, and the GNAT compiler conforms to
3862these requirements.
3863
3864In addition, there are sections throughout the Ada 95
3865reference manual headed
ad42149c 3866by the phrase ``implementation advice''. These sections are not normative,
46b58b8c 3867i.e.@: they do not specify requirements that all compilers must
ad42149c
FW
3868follow. Rather they provide advice on generally desirable behavior. You
3869may wonder why they are not requirements. The most typical answer is
41af791f
GB
3870that they describe behavior that seems generally desirable, but cannot
3871be provided on all systems, or which may be undesirable on some systems.
3872
3873As far as practical, GNAT follows the implementation advice sections in
ad42149c 3874the Ada 95 Reference Manual. This chapter contains a table giving the
41af791f
GB
3875reference manual section number, paragraph number and several keywords
3876for each advice. Each entry consists of the text of the advice followed
ad42149c
FW
3877by the GNAT interpretation of this advice. Most often, this simply says
3878``followed'', which means that GNAT follows the advice. However, in a
41af791f
GB
3879number of cases, GNAT deliberately deviates from this advice, in which
3880case the text describes what GNAT does and why.
3881
3882@table @strong
3883@cindex Error detection
3884@item 1.1.3(20): Error Detection
3885@sp 1
3886@cartouche
3887If an implementation detects the use of an unsupported Specialized Needs
3888Annex feature at run time, it should raise @code{Program_Error} if
3889feasible.
3890@end cartouche
ad42149c 3891Not relevant. All specialized needs annex features are either supported,
41af791f
GB
3892or diagnosed at compile time.
3893
3894@cindex Child Units
3895@item 1.1.3(31): Child Units
3896@sp 1
3897@cartouche
3898If an implementation wishes to provide implementation-defined
3899extensions to the functionality of a language-defined library unit, it
3900should normally do so by adding children to the library unit.
3901@end cartouche
3902Followed.
3903
3904@cindex Bounded errors
3905@item 1.1.5(12): Bounded Errors
3906@sp 1
3907@cartouche
3908If an implementation detects a bounded error or erroneous
3909execution, it should raise @code{Program_Error}.
3910@end cartouche
3911Followed in all cases in which the implementation detects a bounded
ad42149c 3912error or erroneous execution. Not all such situations are detected at
41af791f
GB
3913runtime.
3914
3915@cindex Pragmas
3916@item 2.8(16): Pragmas
3917@sp 1
3918@cartouche
3919Normally, implementation-defined pragmas should have no semantic effect
3920for error-free programs; that is, if the implementation-defined pragmas
3921are removed from a working program, the program should still be legal,
3922and should still have the same semantics.
3923@end cartouche
3924The following implementation defined pragmas are exceptions to this
3925rule:
3926
3927@table @code
3928@item Abort_Defer
3929Affects semantics
3930@item Ada_83
3931Affects legality
3932@item Assert
3933Affects semantics
3934@item CPP_Class
3935Affects semantics
3936@item CPP_Constructor
3937Affects semantics
3938@item CPP_Virtual
3939Affects semantics
3940@item CPP_Vtable
3941Affects semantics
3942@item Debug
3943Affects semantics
3944@item Interface_Name
3945Affects semantics
3946@item Machine_Attribute
3947Affects semantics
3948@item Unimplemented_Unit
3949Affects legality
3950@item Unchecked_Union
3951Affects semantics
3952@end table
3953
3954In each of the above cases, it is essential to the purpose of the pragma
ad42149c 3955that this advice not be followed. For details see the separate section
41af791f
GB
3956on implementation defined pragmas.
3957
3958@item 2.8(17-19): Pragmas
3959@sp 1
3960@cartouche
3961Normally, an implementation should not define pragmas that can
3962make an illegal program legal, except as follows:
3963@end cartouche
3964@sp 1
3965@cartouche
3966A pragma used to complete a declaration, such as a pragma @code{Import};
3967@end cartouche
3968@sp 1
3969@cartouche
3970A pragma used to configure the environment by adding, removing, or
3971replacing @code{library_items}.
3972@end cartouche
3973See response to paragraph 16 of this same section.
3974
3975@cindex Character Sets
3976@cindex Alternative Character Sets
3977@item 3.5.2(5): Alternative Character Sets
3978@sp 1
3979@cartouche
3980If an implementation supports a mode with alternative interpretations
3981for @code{Character} and @code{Wide_Character}, the set of graphic
3982characters of @code{Character} should nevertheless remain a proper
ad42149c 3983subset of the set of graphic characters of @code{Wide_Character}. Any
41af791f
GB
3984character set ``localizations'' should be reflected in the results of
3985the subprograms defined in the language-defined package
ad42149c 3986@code{Characters.Handling} (see A.3) available in such a mode. In a mode with
41af791f
GB
3987an alternative interpretation of @code{Character}, the implementation should
3988also support a corresponding change in what is a legal
3989@code{identifier_letter}.
3990@end cartouche
3991Not all wide character modes follow this advice, in particular the JIS
3992and IEC modes reflect standard usage in Japan, and in these encoding,
3993the upper half of the Latin-1 set is not part of the wide-character
3994subset, since the most significant bit is used for wide character
ad42149c 3995encoding. However, this only applies to the external forms. Internally
41af791f
GB
3996there is no such restriction.
3997
3998@cindex Integer types
3999@item 3.5.4(28): Integer Types
4000
4001@sp 1
4002@cartouche
4003An implementation should support @code{Long_Integer} in addition to
4004@code{Integer} if the target machine supports 32-bit (or longer)
ad42149c
FW
4005arithmetic. No other named integer subtypes are recommended for package
4006@code{Standard}. Instead, appropriate named integer subtypes should be
41af791f
GB
4007provided in the library package @code{Interfaces} (see B.2).
4008@end cartouche
ad42149c
FW
4009@code{Long_Integer} is supported. Other standard integer types are supported
4010so this advice is not fully followed. These types
41af791f
GB
4011are supported for convenient interface to C, and so that all hardware
4012types of the machine are easily available.
4013@item 3.5.4(29): Integer Types
4014
4015@sp 1
4016@cartouche
4017An implementation for a two's complement machine should support
ad42149c 4018modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
41af791f
GB
4019implementation should support a non-binary modules up to @code{Integer'Last}.
4020@end cartouche
4021Followed.
4022
4023@cindex Enumeration values
4024@item 3.5.5(8): Enumeration Values
4025@sp 1
4026@cartouche
4027For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4028subtype, if the value of the operand does not correspond to the internal
4029code for any enumeration literal of its type (perhaps due to an
4030un-initialized variable), then the implementation should raise
ad42149c 4031@code{Program_Error}. This is particularly important for enumeration
41af791f
GB
4032types with noncontiguous internal codes specified by an
4033enumeration_representation_clause.
4034@end cartouche
4035Followed.
4036
4037@cindex Float types
4038@item 3.5.7(17): Float Types
4039@sp 1
4040@cartouche
4041An implementation should support @code{Long_Float} in addition to
4042@code{Float} if the target machine supports 11 or more digits of
ad42149c
FW
4043precision. No other named floating point subtypes are recommended for
4044package @code{Standard}. Instead, appropriate named floating point subtypes
41af791f
GB
4045should be provided in the library package @code{Interfaces} (see B.2).
4046@end cartouche
ad42149c 4047@code{Short_Float} and @code{Long_Long_Float} are also provided. The
41af791f 4048former provides improved compatibility with other implementations
ad42149c
FW
4049supporting this type. The latter corresponds to the highest precision
4050floating-point type supported by the hardware. On most machines, this
41af791f 4051will be the same as @code{Long_Float}, but on some machines, it will
ad42149c 4052correspond to the IEEE extended form. The notable case is all ia32
41af791f
GB
4053(x86) implementations, where @code{Long_Long_Float} corresponds to
4054the 80-bit extended precision format supported in hardware on this
ad42149c 4055processor. Note that the 128-bit format on SPARC is not supported,
41af791f
GB
4056since this is a software rather than a hardware format.
4057
4058@cindex Multidimensional arrays
4059@cindex Arrays, multidimensional
4060@item 3.6.2(11): Multidimensional Arrays
4061@sp 1
4062@cartouche
4063An implementation should normally represent multidimensional arrays in
4064row-major order, consistent with the notation used for multidimensional
ad42149c
FW
4065array aggregates (see 4.3.3). However, if a pragma @code{Convention}
4066(@code{Fortran}, @dots{}) applies to a multidimensional array type, then
41af791f
GB
4067column-major order should be used instead (see B.5, ``Interfacing with
4068Fortran'').
4069@end cartouche
4070Followed.
4071
4072@findex Duration'Small
4073@item 9.6(30-31): Duration'Small
4074@sp 1
4075@cartouche
4076Whenever possible in an implementation, the value of @code{Duration'Small}
4077should be no greater than 100 microseconds.
4078@end cartouche
ad42149c 4079Followed. (@code{Duration'Small} = 10**(@minus{}9)).
41af791f
GB
4080
4081@sp 1
4082@cartouche
4083The time base for @code{delay_relative_statements} should be monotonic;
4084it need not be the same time base as used for @code{Calendar.Clock}.
4085@end cartouche
4086Followed.
4087
4088@item 10.2.1(12): Consistent Representation
4089@sp 1
4090@cartouche
4091In an implementation, a type declared in a pre-elaborated package should
4092have the same representation in every elaboration of a given version of
4093the package, whether the elaborations occur in distinct executions of
4094the same program, or in executions of distinct programs or partitions
4095that include the given version.
4096@end cartouche
ad42149c 4097Followed, except in the case of tagged types. Tagged types involve
41af791f
GB
4098implicit pointers to a local copy of a dispatch table, and these pointers
4099have representations which thus depend on a particular elaboration of the
ad42149c 4100package. It is not easy to see how it would be possible to follow this
41af791f
GB
4101advice without severely impacting efficiency of execution.
4102
4103@cindex Exception information
4104@item 11.4.1(19): Exception Information
4105@sp 1
4106@cartouche
4107@code{Exception_Message} by default and @code{Exception_Information}
4108should produce information useful for
ad42149c
FW
4109debugging. @code{Exception_Message} should be short, about one
4110line. @code{Exception_Information} can be long. @code{Exception_Message}
41af791f 4111should not include the
ad42149c 4112@code{Exception_Name}. @code{Exception_Information} should include both
41af791f
GB
4113the @code{Exception_Name} and the @code{Exception_Message}.
4114@end cartouche
ad42149c 4115Followed. For each exception that doesn't have a specified
41af791f 4116@code{Exception_Message}, the compiler generates one containing the location
ad42149c 4117of the raise statement. This location has the form ``file:line'', where
41af791f 4118file is the short file name (without path information) and line is the line
ad42149c 4119number in the file. Note that in the case of the Zero Cost Exception
41af791f
GB
4120mechanism, these messages become redundant with the Exception_Information that
4121contains a full backtrace of the calling sequence, so they are disabled.
4122To disable explicitly the generation of the source location message, use the
4123Pragma @code{Discard_Names}.
4124
4125@cindex Suppression of checks
4126@cindex Checks, suppression of
4127@item 11.5(28): Suppression of Checks
4128@sp 1
4129@cartouche
4130The implementation should minimize the code executed for checks that
4131have been suppressed.
4132@end cartouche
4133Followed.
4134
4135@cindex Representation clauses
4136@item 13.1 (21-24): Representation Clauses
4137@sp 1
4138@cartouche
4139The recommended level of support for all representation items is
4140qualified as follows:
4141@end cartouche
4142@sp 1
4143@cartouche
4144An implementation need not support representation items containing
4145non-static expressions, except that an implementation should support a
4146representation item for a given entity if each non-static expression in
4147the representation item is a name that statically denotes a constant
4148declared before the entity.
4149@end cartouche
ad42149c
FW
4150Followed. GNAT does not support non-static expressions in representation
4151clauses unless they are constants declared before the entity. For
41af791f
GB
4152example:
4153
4154@smallexample
4155X : typ;
4156for X'Address use To_address (16#2000#);
4157@end smallexample
4158
4159@noindent
ad42149c 4160will be rejected, since the To_Address expression is non-static. Instead
41af791f
GB
4161write:
4162
4163@smallexample
4164X_Address : constant Address : =
4165To_Address ((16#2000#);
4166X : typ;
4167for X'Address use X_Address;
4168@end smallexample
4169
4170@sp 1
4171@cartouche
4172An implementation need not support a specification for the @code{Size}
4173for a given composite subtype, nor the size or storage place for an
4174object (including a component) of a given composite subtype, unless the
4175constraints on the subtype and its composite subcomponents (if any) are
4176all static constraints.
4177@end cartouche
ad42149c 4178Followed. Size Clauses are not permitted on non-static components, as
41af791f
GB
4179described above.
4180
4181@sp 1
4182@cartouche
4183An aliased component, or a component whose type is by-reference, should
4184always be allocated at an addressable location.
4185@end cartouche
4186Followed.
4187
4188@cindex Packed types
4189@item 13.2(6-8): Packed Types
4190@sp 1
4191@cartouche
4192If a type is packed, then the implementation should try to minimize
4193storage allocated to objects of the type, possibly at the expense of
4194speed of accessing components, subject to reasonable complexity in
4195addressing calculations.
4196@end cartouche
4197@sp 1
4198@cartouche
4199The recommended level of support pragma @code{Pack} is:
4200
4201For a packed record type, the components should be packed as tightly as
4202possible subject to the Sizes of the component subtypes, and subject to
4203any @code{record_representation_clause} that applies to the type; the
4204implementation may, but need not, reorder components or cross aligned
ad42149c 4205word boundaries to improve the packing. A component whose @code{Size} is
41af791f
GB
4206greater than the word size may be allocated an integral number of words.
4207@end cartouche
ad42149c 4208Followed. Tight packing of arrays is supported for all component sizes
41af791f
GB
4209up to 64-bits.
4210
4211@sp 1
4212@cartouche
4213An implementation should support Address clauses for imported
4214subprograms.
4215@end cartouche
4216Followed.
4217@cindex @code{Address} clauses
4218@item 13.3(14-19): Address Clauses
4219
4220@sp 1
4221@cartouche
4222For an array @var{X}, @code{@var{X}'Address} should point at the first
4223component of the array, and not at the array bounds.
4224@end cartouche
4225Followed.
4226
4227@sp 1
4228@cartouche
4229The recommended level of support for the @code{Address} attribute is:
4230
4231@code{@var{X}'Address} should produce a useful result if @var{X} is an
4232object that is aliased or of a by-reference type, or is an entity whose
4233@code{Address} has been specified.
4234@end cartouche
4235Followed. A valid address will be produced even if none of those
4236conditions have been met. If necessary, the object is forced into
4237memory to ensure the address is valid.
4238
4239@sp 1
4240@cartouche
4241An implementation should support @code{Address} clauses for imported
4242subprograms.
4243@end cartouche
4244Followed.
4245
4246@sp 1
4247@cartouche
4248Objects (including subcomponents) that are aliased or of a by-reference
4249type should be allocated on storage element boundaries.
4250@end cartouche
4251Followed.
4252
4253@sp 1
4254@cartouche
4255If the @code{Address} of an object is specified, or it is imported or exported,
4256then the implementation should not perform optimizations based on
4257assumptions of no aliases.
4258@end cartouche
4259Followed.
4260
4261@cindex @code{Alignment} clauses
4262@item 13.3(29-35): Alignment Clauses
4263@sp 1
4264@cartouche
4265The recommended level of support for the @code{Alignment} attribute for
4266subtypes is:
4267
4268An implementation should support specified Alignments that are factors
4269and multiples of the number of storage elements per word, subject to the
4270following:
4271@end cartouche
4272Followed.
4273
4274@sp 1
4275@cartouche
4276An implementation need not support specified @code{Alignment}s for
4277combinations of @code{Size}s and @code{Alignment}s that cannot be easily
4278loaded and stored by available machine instructions.
4279@end cartouche
4280Followed.
4281
4282@sp 1
4283@cartouche
4284An implementation need not support specified @code{Alignment}s that are
4285greater than the maximum @code{Alignment} the implementation ever returns by
4286default.
4287@end cartouche
4288Followed.
4289
4290@sp 1
4291@cartouche
4292The recommended level of support for the @code{Alignment} attribute for
4293objects is:
4294
4295Same as above, for subtypes, but in addition:
4296@end cartouche
4297Followed.
4298
4299@sp 1
4300@cartouche
4301For stand-alone library-level objects of statically constrained
4302subtypes, the implementation should support all @code{Alignment}s
ad42149c 4303supported by the target linker. For example, page alignment is likely to
41af791f
GB
4304be supported for such objects, but not for subtypes.
4305@end cartouche
4306Followed.
4307
4308@cindex @code{Size} clauses
4309@item 13.3(42-43): Size Clauses
4310@sp 1
4311@cartouche
4312The recommended level of support for the @code{Size} attribute of
4313objects is:
4314
4315A @code{Size} clause should be supported for an object if the specified
4316@code{Size} is at least as large as its subtype's @code{Size}, and
4317corresponds to a size in storage elements that is a multiple of the
4318object's @code{Alignment} (if the @code{Alignment} is nonzero).
4319@end cartouche
4320Followed.
4321
4322@item 13.3(50-56): Size Clauses
4323@sp 1
4324@cartouche
4325If the @code{Size} of a subtype is specified, and allows for efficient
4326independent addressability (see 9.10) on the target architecture, then
4327the @code{Size} of the following objects of the subtype should equal the
4328@code{Size} of the subtype:
4329
4330Aliased objects (including components).
4331@end cartouche
4332Followed.
4333
4334@sp 1
4335@cartouche
4336@code{Size} clause on a composite subtype should not affect the
4337internal layout of components.
4338@end cartouche
4339Followed.
4340
4341@sp 1
4342@cartouche
4343The recommended level of support for the @code{Size} attribute of subtypes is:
4344@end cartouche
4345@sp 1
4346@cartouche
4347The @code{Size} (if not specified) of a static discrete or fixed point
4348subtype should be the number of bits needed to represent each value
4349belonging to the subtype using an unbiased representation, leaving space
ad42149c 4350for a sign bit only if the subtype contains negative values. If such a
41af791f
GB
4351subtype is a first subtype, then an implementation should support a
4352specified @code{Size} for it that reflects this representation.
4353@end cartouche
4354Followed.
4355
4356@sp 1
4357@cartouche
4358For a subtype implemented with levels of indirection, the @code{Size}
4359should include the size of the pointers, but not the size of what they
4360point at.
4361@end cartouche
4362Followed.
4363
4364@cindex @code{Component_Size} clauses
4365@item 13.3(71-73): Component Size Clauses
4366@sp 1
4367@cartouche
4368The recommended level of support for the @code{Component_Size}
4369attribute is:
4370@end cartouche
4371@sp 1
4372@cartouche
4373An implementation need not support specified @code{Component_Sizes} that are
4374less than the @code{Size} of the component subtype.
4375@end cartouche
4376Followed.
4377
4378@sp 1
4379@cartouche
4380An implementation should support specified @code{Component_Size}s that
ad42149c 4381are factors and multiples of the word size. For such
41af791f 4382@code{Component_Size}s, the array should contain no gaps between
ad42149c 4383components. For other @code{Component_Size}s (if supported), the array
41af791f
GB
4384should contain no gaps between components when packing is also
4385specified; the implementation should forbid this combination in cases
4386where it cannot support a no-gaps representation.
4387@end cartouche
4388Followed.
4389
4390@cindex Enumeration representation clauses
4391@cindex Representation clauses, enumeration
4392@item 13.4(9-10): Enumeration Representation Clauses
4393@sp 1
4394@cartouche
4395The recommended level of support for enumeration representation clauses
4396is:
4397
4398An implementation need not support enumeration representation clauses
4399for boolean types, but should at minimum support the internal codes in
4400the range @code{System.Min_Int.System.Max_Int}.
4401@end cartouche
4402Followed.
4403
4404@cindex Record representation clauses
4405@cindex Representation clauses, records
4406@item 13.5.1(17-22): Record Representation Clauses
4407@sp 1
4408@cartouche
4409The recommended level of support for
4410@*@code{record_representation_clauses} is:
4411
4412An implementation should support storage places that can be extracted
4413with a load, mask, shift sequence of machine code, and set with a load,
4414shift, mask, store sequence, given the available machine instructions
4415and run-time model.
4416@end cartouche
4417Followed.
4418
4419@sp 1
4420@cartouche
4421A storage place should be supported if its size is equal to the
4422@code{Size} of the component subtype, and it starts and ends on a
4423boundary that obeys the @code{Alignment} of the component subtype.
4424@end cartouche
4425Followed.
4426
4427@sp 1
4428@cartouche
4429If the default bit ordering applies to the declaration of a given type,
4430then for a component whose subtype's @code{Size} is less than the word
4431size, any storage place that does not cross an aligned word boundary
4432should be supported.
4433@end cartouche
4434Followed.
4435
4436@sp 1
4437@cartouche
4438An implementation may reserve a storage place for the tag field of a
4439tagged type, and disallow other components from overlapping that place.
4440@end cartouche
ad42149c
FW
4441Followed. The storage place for the tag field is the beginning of the tagged
4442record, and its size is Address'Size. GNAT will reject an explicit component
41af791f
GB
4443clause for the tag field.
4444
4445@sp 1
4446@cartouche
4447An implementation need not support a @code{component_clause} for a
4448component of an extension part if the storage place is not after the
4449storage places of all components of the parent type, whether or not
4450those storage places had been specified.
4451@end cartouche
ad42149c 4452Followed. The above advice on record representation clauses is followed,
41af791f
GB
4453and all mentioned features are implemented.
4454
4455@cindex Storage place attributes
4456@item 13.5.2(5): Storage Place Attributes
4457@sp 1
4458@cartouche
4459If a component is represented using some form of pointer (such as an
4460offset) to the actual data of the component, and this data is contiguous
4461with the rest of the object, then the storage place attributes should
ad42149c 4462reflect the place of the actual data, not the pointer. If a component is
41af791f
GB
4463allocated discontinuously from the rest of the object, then a warning
4464should be generated upon reference to one of its storage place
4465attributes.
4466@end cartouche
ad42149c 4467Followed. There are no such components in GNAT@.
41af791f
GB
4468
4469@cindex Bit ordering
4470@item 13.5.3(7-8): Bit Ordering
4471@sp 1
4472@cartouche
4473The recommended level of support for the non-default bit ordering is:
4474@end cartouche
4475@sp 1
4476@cartouche
4477If @code{Word_Size} = @code{Storage_Unit}, then the implementation
4478should support the non-default bit ordering in addition to the default
4479bit ordering.
4480@end cartouche
ad42149c 4481Followed. Word size does not equal storage size in this implementation.
41af791f
GB
4482Thus non-default bit ordering is not supported.
4483
4484@cindex @code{Address}, as private type
4485@item 13.7(37): Address as Private
4486@sp 1
4487@cartouche
4488@code{Address} should be of a private type.
4489@end cartouche
4490Followed.
4491
4492@cindex Operations, on @code{Address}
4493@cindex @code{Address}, operations of
4494@item 13.7.1(16): Address Operations
4495@sp 1
4496@cartouche
4497Operations in @code{System} and its children should reflect the target
ad42149c
FW
4498environment semantics as closely as is reasonable. For example, on most
4499machines, it makes sense for address arithmetic to ``wrap around''.
41af791f
GB
4500Operations that do not make sense should raise @code{Program_Error}.
4501@end cartouche
ad42149c 4502Followed. Address arithmetic is modular arithmetic that wraps around. No
41af791f
GB
4503operation raises @code{Program_Error}, since all operations make sense.
4504
4505@cindex Unchecked conversion
4506@item 13.9(14-17): Unchecked Conversion
4507@sp 1
4508@cartouche
4509The @code{Size} of an array object should not include its bounds; hence,
4510the bounds should not be part of the converted data.
4511@end cartouche
4512Followed.
4513
4514@sp 1
4515@cartouche
4516The implementation should not generate unnecessary run-time checks to
4517ensure that the representation of @var{S} is a representation of the
ad42149c
FW
4518target type. It should take advantage of the permission to return by
4519reference when possible. Restrictions on unchecked conversions should be
41af791f
GB
4520avoided unless required by the target environment.
4521@end cartouche
ad42149c 4522Followed. There are no restrictions on unchecked conversion. A warning is
41af791f
GB
4523generated if the source and target types do not have the same size since
4524the semantics in this case may be target dependent.
4525
4526@sp 1
4527@cartouche
4528The recommended level of support for unchecked conversions is:
4529@end cartouche
4530@sp 1
4531@cartouche
4532Unchecked conversions should be supported and should be reversible in
ad42149c 4533the cases where this clause defines the result. To enable meaningful use
41af791f
GB
4534of unchecked conversion, a contiguous representation should be used for
4535elementary subtypes, for statically constrained array subtypes whose
4536component subtype is one of the subtypes described in this paragraph,
4537and for record subtypes without discriminants whose component subtypes
4538are described in this paragraph.
4539@end cartouche
4540Followed.
4541
4542@cindex Heap usage, implicit
4543@item 13.11(23-25): Implicit Heap Usage
4544@sp 1
4545@cartouche
4546An implementation should document any cases in which it dynamically
4547allocates heap storage for a purpose other than the evaluation of an
4548allocator.
4549@end cartouche
4550Followed, the only other points at which heap storage is dynamically
4551allocated are as follows:
4552
4553@itemize @bullet
4554@item
4555At initial elaboration time, to allocate dynamically sized global
4556objects.
4557
4558@item
4559To allocate space for a task when a task is created.
4560
4561@item
ad42149c 4562To extend the secondary stack dynamically when needed. The secondary
41af791f
GB
4563stack is used for returning variable length results.
4564@end itemize
4565
4566@sp 1
4567@cartouche
ad42149c
FW
4568A default (implementation-provided) storage pool for an
4569access-to-constant type should not have overhead to support deallocation of
41af791f
GB
4570individual objects.
4571@end cartouche
4572Followed.
4573
4574@sp 1
4575@cartouche
4576A storage pool for an anonymous access type should be created at the
4577point of an allocator for the type, and be reclaimed when the designated
4578object becomes inaccessible.
4579@end cartouche
4580Followed.
4581
4582@cindex Unchecked deallocation
4583@item 13.11.2(17): Unchecked De-allocation
4584@sp 1
4585@cartouche
4586For a standard storage pool, @code{Free} should actually reclaim the
4587storage.
4588@end cartouche
4589Followed.
4590
4591@cindex Stream oriented attributes
4592@item 13.13.2(17): Stream Oriented Attributes
4593@sp 1
4594@cartouche
4595If a stream element is the same size as a storage element, then the
4596normal in-memory representation should be used by @code{Read} and
ad42149c 4597@code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
41af791f
GB
4598should use the smallest number of stream elements needed to represent
4599all values in the base range of the scalar type.
4600@end cartouche
ad42149c 4601Followed. In particular, the interpretation chosen is that of AI-195,
41af791f
GB
4602which specifies that the size to be used is that of the first subtype.
4603
4604@item A.1(52): Implementation Advice
4605@sp 1
4606@cartouche
4607If an implementation provides additional named predefined integer types,
4608then the names should end with @samp{Integer} as in
ad42149c 4609@samp{Long_Integer}. If an implementation provides additional named
41af791f
GB
4610predefined floating point types, then the names should end with
4611@samp{Float} as in @samp{Long_Float}.
4612@end cartouche
4613Followed.
4614
4615@findex Ada.Characters.Handling
4616@item A.3.2(49): @code{Ada.Characters.Handling}
4617@sp 1
4618@cartouche
4619If an implementation provides a localized definition of @code{Character}
4620or @code{Wide_Character}, then the effects of the subprograms in
ad42149c 4621@code{Characters.Handling} should reflect the localizations. See also
41af791f
GB
46223.5.2.
4623@end cartouche
ad42149c 4624Followed. GNAT provides no such localized definitions.
41af791f
GB
4625
4626@cindex Bounded-length strings
4627@item A.4.4(106): Bounded-Length String Handling
4628@sp 1
4629@cartouche
4630Bounded string objects should not be implemented by implicit pointers
4631and dynamic allocation.
4632@end cartouche
ad42149c 4633Followed. No implicit pointers or dynamic allocation are used.
41af791f
GB
4634
4635@cindex Random number generation
4636@item A.5.2(46-47): Random Number Generation
4637@sp 1
4638@cartouche
4639Any storage associated with an object of type @code{Generator} should be
4640reclaimed on exit from the scope of the object.
4641@end cartouche
4642Followed.
4643
4644@sp 1
4645@cartouche
4646If the generator period is sufficiently long in relation to the number
4647of distinct initiator values, then each possible value of
4648@code{Initiator} passed to @code{Reset} should initiate a sequence of
4649random numbers that does not, in a practical sense, overlap the sequence
ad42149c 4650initiated by any other value. If this is not possible, then the mapping
41af791f
GB
4651between initiator values and generator states should be a rapidly
4652varying function of the initiator value.
4653@end cartouche
ad42149c 4654Followed. The generator period is sufficiently long for the first
41af791f
GB
4655condition here to hold true.
4656
4657@findex Get_Immediate
4658@item A.10.7(23): @code{Get_Immediate}
4659@sp 1
4660@cartouche
4661The @code{Get_Immediate} procedures should be implemented with
ad42149c 4662unbuffered input. For a device such as a keyboard, input should be
41af791f 4663@dfn{available} if a key has already been typed, whereas for a disk
ad42149c 4664file, input should always be available except at end of file. For a file
41af791f
GB
4665associated with a keyboard-like device, any line-editing features of the
4666underlying operating system should be disabled during the execution of
4667@code{Get_Immediate}.
4668@end cartouche
4669Followed.
4670
4671@findex Export
4672@item B.1(39-41): Pragma @code{Export}
4673@sp 1
4674@cartouche
4675If an implementation supports pragma @code{Export} to a given language,
4676then it should also allow the main subprogram to be written in that
ad42149c 4677language. It should support some mechanism for invoking the elaboration
41af791f 4678of the Ada library units included in the system, and for invoking the
ad42149c 4679finalization of the environment task. On typical systems, the
41af791f 4680recommended mechanism is to provide two subprograms whose link names are
ad42149c
FW
4681@code{adainit} and @code{adafinal}. @code{adainit} should contain the
4682elaboration code for library units. @code{adafinal} should contain the
4683finalization code. These subprograms should have no effect the second
41af791f
GB
4684and subsequent time they are called.
4685@end cartouche
4686Followed.
4687
4688@sp 1
4689@cartouche
4690Automatic elaboration of pre-elaborated packages should be
ad42149c 4691provided when pragma @code{Export} is supported.
41af791f 4692@end cartouche
ad42149c 4693Followed when the main program is in Ada. If the main program is in a
41af791f
GB
4694foreign language, then
4695@code{adainit} must be called to elaborate pre-elaborated
4696packages.
4697
4698@sp 1
4699@cartouche
4700For each supported convention @var{L} other than @code{Intrinsic}, an
4701implementation should support @code{Import} and @code{Export} pragmas
4702for objects of @var{L}-compatible types and for subprograms, and pragma
4703@code{Convention} for @var{L}-eligible types and for subprograms,
ad42149c 4704presuming the other language has corresponding features. Pragma
41af791f
GB
4705@code{Convention} need not be supported for scalar types.
4706@end cartouche
4707Followed.
4708
4709@cindex Package @code{Interfaces}
4710@findex Interfaces
4711@item B.2(12-13): Package @code{Interfaces}
4712@sp 1
4713@cartouche
4714For each implementation-defined convention identifier, there should be a
ad42149c 4715child package of package Interfaces with the corresponding name. This
41af791f
GB
4716package should contain any declarations that would be useful for
4717interfacing to the language (implementation) represented by the
ad42149c 4718convention. Any declarations useful for interfacing to any language on
41af791f
GB
4719the given hardware architecture should be provided directly in
4720@code{Interfaces}.
4721@end cartouche
ad42149c 4722Followed. An additional package not defined
41af791f
GB
4723in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
4724for interfacing to C++.
4725
4726@sp 1
4727@cartouche
4728An implementation supporting an interface to C, COBOL, or Fortran should
4729provide the corresponding package or packages described in the following
4730clauses.
4731@end cartouche
ad42149c 4732Followed. GNAT provides all the packages described in this section.
41af791f
GB
4733
4734@cindex C, interfacing with
4735@item B.3(63-71): Interfacing with C
4736@sp 1
4737@cartouche
4738An implementation should support the following interface correspondences
46b58b8c 4739between Ada and C@.
41af791f
GB
4740@end cartouche
4741Followed.
4742
4743@sp 1
4744@cartouche
4745An Ada procedure corresponds to a void-returning C function.
4746@end cartouche
4747Followed.
4748
4749@sp 1
4750@cartouche
4751An Ada function corresponds to a non-void C function.
4752@end cartouche
4753Followed.
4754
4755@sp 1
4756@cartouche
4757An Ada @code{in} scalar parameter is passed as a scalar argument to a C
4758function.
4759@end cartouche
4760Followed.
4761
4762@sp 1
4763@cartouche
4764An Ada @code{in} parameter of an access-to-object type with designated
4765type @var{T} is passed as a @code{@var{t}*} argument to a C function,
4766where @var{t} is the C type corresponding to the Ada type @var{T}.
4767@end cartouche
4768Followed.
4769
4770@sp 1
4771@cartouche
4772An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
4773parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
4774argument to a C function, where @var{t} is the C type corresponding to
ad42149c 4775the Ada type @var{T}. In the case of an elementary @code{out} or
41af791f
GB
4776@code{in out} parameter, a pointer to a temporary copy is used to
4777preserve by-copy semantics.
4778@end cartouche
4779Followed.
4780
4781@sp 1
4782@cartouche
4783An Ada parameter of a record type @var{T}, of any mode, is passed as a
4784@code{@var{t}*} argument to a C function, where @var{t} is the C
4785structure corresponding to the Ada type @var{T}.
4786@end cartouche
ad42149c 4787Followed. This convention may be overridden by the use of the C_Pass_By_Copy
41af791f
GB
4788pragma, or Convention, or by explicitly specifying the mechanism for a given
4789call using an extended import or export pragma.
4790
4791@sp 1
4792@cartouche
4793An Ada parameter of an array type with component type @var{T}, of any
4794mode, is passed as a @code{@var{t}*} argument to a C function, where
4795@var{t} is the C type corresponding to the Ada type @var{T}.
4796@end cartouche
4797Followed.
4798
4799@sp 1
4800@cartouche
4801An Ada parameter of an access-to-subprogram type is passed as a pointer
4802to a C function whose prototype corresponds to the designated
4803subprogram's specification.
4804@end cartouche
4805Followed.
4806
4807@cindex COBOL, interfacing with
4808@item B.4(95-98): Interfacing with COBOL
4809@sp 1
4810@cartouche
4811An Ada implementation should support the following interface
46b58b8c 4812correspondences between Ada and COBOL@.
41af791f
GB
4813@end cartouche
4814Followed.
4815
4816@sp 1
4817@cartouche
ad42149c 4818An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
41af791f
GB
4819the COBOL type corresponding to @var{T}.
4820@end cartouche
4821Followed.
4822
4823@sp 1
4824@cartouche
ad42149c 4825An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
41af791f
GB
4826the corresponding COBOL type.
4827@end cartouche
4828Followed.
4829
4830@sp 1
4831@cartouche
ad42149c 4832Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
41af791f
GB
4833COBOL type corresponding to the Ada parameter type; for scalars, a local
4834copy is used if necessary to ensure by-copy semantics.
4835@end cartouche
4836Followed.
4837
4838@cindex Fortran, interfacing with
4839@item B.5(22-26): Interfacing with Fortran
4840@sp 1
4841@cartouche
4842An Ada implementation should support the following interface
4843correspondences between Ada and Fortran:
4844@end cartouche
4845Followed.
4846
4847@sp 1
4848@cartouche
4849An Ada procedure corresponds to a Fortran subroutine.
4850@end cartouche
4851Followed.
4852
4853@sp 1
4854@cartouche
4855An Ada function corresponds to a Fortran function.
4856@end cartouche
4857Followed.
4858
4859@sp 1
4860@cartouche
4861An Ada parameter of an elementary, array, or record type @var{T} is
4862passed as a @var{T} argument to a Fortran procedure, where @var{T} is
4863the Fortran type corresponding to the Ada type @var{T}, and where the
4864INTENT attribute of the corresponding dummy argument matches the Ada
4865formal parameter mode; the Fortran implementation's parameter passing
ad42149c 4866conventions are used. For elementary types, a local copy is used if
41af791f
GB
4867necessary to ensure by-copy semantics.
4868@end cartouche
4869Followed.
4870
4871@sp 1
4872@cartouche
4873An Ada parameter of an access-to-subprogram type is passed as a
4874reference to a Fortran procedure whose interface corresponds to the
4875designated subprogram's specification.
4876@end cartouche
4877Followed.
4878
4879@cindex Machine operations
4880@item C.1(3-5): Access to Machine Operations
4881@sp 1
4882@cartouche
4883The machine code or intrinsic support should allow access to all
4884operations normally available to assembly language programmers for the
4885target environment, including privileged instructions, if any.
4886@end cartouche
4887Followed.
4888
4889@sp 1
4890@cartouche
4891The interfacing pragmas (see Annex B) should support interface to
4892assembler; the default assembler should be associated with the
4893convention identifier @code{Assembler}.
4894@end cartouche
4895Followed.
4896
4897@sp 1
4898@cartouche
4899If an entity is exported to assembly language, then the implementation
4900should allocate it at an addressable location, and should ensure that it
4901is retained by the linking process, even if not otherwise referenced
ad42149c 4902from the Ada code. The implementation should assume that any call to a
41af791f
GB
4903machine code or assembler subprogram is allowed to read or update every
4904object that is specified as exported.
4905@end cartouche
4906Followed.
4907
4908@item C.1(10-16): Access to Machine Operations
4909@sp 1
4910@cartouche
4911The implementation should ensure that little or no overhead is
4912associated with calling intrinsic and machine-code subprograms.
4913@end cartouche
4914Followed for both intrinsics and machine-code subprograms.
4915
4916@sp 1
4917@cartouche
4918It is recommended that intrinsic subprograms be provided for convenient
4919access to any machine operations that provide special capabilities or
4920efficiency and that are not otherwise available through the language
4921constructs.
4922@end cartouche
ad42149c 4923Followed. A full set of machine operation intrinsic subprograms is provided.
41af791f
GB
4924
4925@sp 1
4926@cartouche
ad42149c 4927Atomic read-modify-write operations---e.g.@:, test and set, compare and
41af791f
GB
4928swap, decrement and test, enqueue/dequeue.
4929@end cartouche
4930Followed on any target supporting such operations.
4931
4932@sp 1
4933@cartouche
ad42149c 4934Standard numeric functions---e.g.@:, sin, log.
41af791f
GB
4935@end cartouche
4936Followed on any target supporting such operations.
4937
4938@sp 1
4939@cartouche
ad42149c 4940String manipulation operations---e.g.@:, translate and test.
41af791f
GB
4941@end cartouche
4942Followed on any target supporting such operations.
4943
4944@sp 1
4945@cartouche
ad42149c 4946Vector operations---e.g.@:, compare vector against thresholds.
41af791f
GB
4947@end cartouche
4948Followed on any target supporting such operations.
4949
4950@sp 1
4951@cartouche
4952Direct operations on I/O ports.
4953@end cartouche
4954Followed on any target supporting such operations.
4955
4956@cindex Interrupt support
4957@item C.3(28): Interrupt Support
4958@sp 1
4959@cartouche
4960If the @code{Ceiling_Locking} policy is not in effect, the
4961implementation should provide means for the application to specify which
4962interrupts are to be blocked during protected actions, if the underlying
4963system allows for a finer-grain control of interrupt blocking.
4964@end cartouche
ad42149c 4965Followed. The underlying system does not allow for finer-grain control
41af791f
GB
4966of interrupt blocking.
4967
4968@cindex Protected procedure handlers
4969@item C.3.1(20-21): Protected Procedure Handlers
4970@sp 1
4971@cartouche
4972Whenever possible, the implementation should allow interrupt handlers to
4973be called directly by the hardware.
4974@end cartouche
4975@c SGI info:
4976@ignore
4977This is never possible under IRIX, so this is followed by default.
4978@end ignore
4979Followed on any target where the underlying operating system permits
4980such direct calls.
4981
4982@sp 1
4983@cartouche
4984Whenever practical, violations of any
4985implementation-defined restrictions should be detected before run time.
4986@end cartouche
ad42149c 4987Followed. Compile time warnings are given when possible.
41af791f
GB
4988
4989@cindex Package @code{Interrupts}
4990@findex Interrupts
4991@item C.3.2(25): Package @code{Interrupts}
4992
4993@sp 1
4994@cartouche
4995If implementation-defined forms of interrupt handler procedures are
4996supported, such as protected procedures with parameters, then for each
4997such form of a handler, a type analogous to @code{Parameterless_Handler}
4998should be specified in a child package of @code{Interrupts}, with the
4999same operations as in the predefined package Interrupts.
5000@end cartouche
5001Followed.
5002
5003@cindex Pre-elaboration requirements
5004@item C.4(14): Pre-elaboration Requirements
5005@sp 1
5006@cartouche
5007It is recommended that pre-elaborated packages be implemented in such a
5008way that there should be little or no code executed at run time for the
5009elaboration of entities not already covered by the Implementation
5010Requirements.
5011@end cartouche
ad42149c 5012Followed. Executable code is generated in some cases, e.g.@: loops
41af791f
GB
5013to initialize large arrays.
5014
5015@item C.5(8): Pragma @code{Discard_Names}
5016
5017@sp 1
5018@cartouche
5019If the pragma applies to an entity, then the implementation should
5020reduce the amount of storage used for storing names associated with that
5021entity.
5022@end cartouche
5023Followed.
5024
5025@cindex Package @code{Task_Attributes}
5026@findex Task_Attributes
5027@item C.7.2(30): The Package Task_Attributes
5028@sp 1
5029@cartouche
5030Some implementations are targeted to domains in which memory use at run
ad42149c 5031time must be completely deterministic. For such implementations, it is
41af791f 5032recommended that the storage for task attributes will be pre-allocated
ad42149c 5033statically and not from the heap. This can be accomplished by either
41af791f
GB
5034placing restrictions on the number and the size of the task's
5035attributes, or by using the pre-allocated storage for the first @var{N}
ad42149c 5036attribute objects, and the heap for the others. In the latter case,
41af791f
GB
5037@var{N} should be documented.
5038@end cartouche
ad42149c 5039Not followed. This implementation is not targeted to such a domain.
41af791f
GB
5040
5041@cindex Locking Policies
5042@item D.3(17): Locking Policies
5043
5044@sp 1
5045@cartouche
5046The implementation should use names that end with @samp{_Locking} for
5047locking policies defined by the implementation.
5048@end cartouche
ad42149c 5049Followed. A single implementation-defined locking policy is defined,
41af791f
GB
5050whose name (@code{Inheritance_Locking}) follows this suggestion.
5051
5052@cindex Entry queuing policies
5053@item D.4(16): Entry Queuing Policies
5054@sp 1
5055@cartouche
5056Names that end with @samp{_Queuing} should be used
5057for all implementation-defined queuing policies.
5058@end cartouche
ad42149c 5059Followed. No such implementation-defined queueing policies exist.
41af791f
GB
5060
5061@cindex Preemptive abort
5062@item D.6(9-10): Preemptive Abort
5063@sp 1
5064@cartouche
5065Even though the @code{abort_statement} is included in the list of
5066potentially blocking operations (see 9.5.1), it is recommended that this
5067statement be implemented in a way that never requires the task executing
5068the @code{abort_statement} to block.
5069@end cartouche
5070Followed.
5071
5072@sp 1
5073@cartouche
5074On a multi-processor, the delay associated with aborting a task on
5075another processor should be bounded; the implementation should use
5076periodic polling, if necessary, to achieve this.
5077@end cartouche
5078Followed.
5079
5080@cindex Tasking restrictions
5081@item D.7(21): Tasking Restrictions
5082@sp 1
5083@cartouche
5084When feasible, the implementation should take advantage of the specified
5085restrictions to produce a more efficient implementation.
5086@end cartouche
5087GNAT currently takes advantage of these restrictions by providing an optimized
5088run time when the Ravenscar profile and the GNAT restricted run time set
ad42149c 5089of restrictions are specified. See pragma @code{Ravenscar} and pragma
41af791f
GB
5090@code{Restricted_Run_Time} for more details.
5091
5092@cindex Time, monotonic
5093@item D.8(47-49): Monotonic Time
5094@sp 1
5095@cartouche
5096When appropriate, implementations should provide configuration
5097mechanisms to change the value of @code{Tick}.
5098@end cartouche
5099Such configuration mechanisms are not appropriate to this implementation
5100and are thus not supported.
5101
5102@sp 1
5103@cartouche
5104It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
5105be implemented as transformations of the same time base.
5106@end cartouche
5107Followed.
5108
5109@sp 1
5110@cartouche
5111It is recommended that the @dfn{best} time base which exists in
5112the underlying system be available to the application through
ad42149c 5113@code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
41af791f
GB
5114@end cartouche
5115Followed.
5116
5117@cindex Partition communication subsystem
5118@cindex PCS
5119@item E.5(28-29): Partition Communication Subsystem
5120@sp 1
5121@cartouche
5122Whenever possible, the PCS on the called partition should allow for
5123multiple tasks to call the RPC-receiver with different messages and
5124should allow them to block until the corresponding subprogram body
5125returns.
5126@end cartouche
5127Followed by GLADE, a separately supplied PCS that can be used with
ad42149c 5128GNAT.
41af791f
GB
5129
5130@sp 1
5131@cartouche
5132The @code{Write} operation on a stream of type @code{Params_Stream_Type}
5133should raise @code{Storage_Error} if it runs out of space trying to
5134write the @code{Item} into the stream.
5135@end cartouche
5136Followed by GLADE, a separately supplied PCS that can be used with
ad42149c 5137GNAT@.
41af791f
GB
5138
5139@cindex COBOL support
5140@item F(7): COBOL Support
5141@sp 1
5142@cartouche
5143If COBOL (respectively, C) is widely supported in the target
5144environment, implementations supporting the Information Systems Annex
5145should provide the child package @code{Interfaces.COBOL} (respectively,
5146@code{Interfaces.C}) specified in Annex B and should support a
5147@code{convention_identifier} of COBOL (respectively, C) in the interfacing
5148pragmas (see Annex B), thus allowing Ada programs to interface with
5149programs written in that language.
5150@end cartouche
5151Followed.
5152
5153@cindex Decimal radix support
5154@item F.1(2): Decimal Radix Support
5155@sp 1
5156@cartouche
5157Packed decimal should be used as the internal representation for objects
5158of subtype @var{S} when @var{S}'Machine_Radix = 10.
5159@end cartouche
ad42149c 5160Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
41af791f
GB
5161representations.
5162
5163@cindex Numerics
5164@item G: Numerics
5165@sp 2
5166@cartouche
5167If Fortran (respectively, C) is widely supported in the target
5168environment, implementations supporting the Numerics Annex
5169should provide the child package @code{Interfaces.Fortran} (respectively,
5170@code{Interfaces.C}) specified in Annex B and should support a
5171@code{convention_identifier} of Fortran (respectively, C) in the interfacing
5172pragmas (see Annex B), thus allowing Ada programs to interface with
5173programs written in that language.
5174@end cartouche
5175Followed.
5176
5177@cindex Complex types
5178@item G.1.1(56-58): Complex Types
5179@sp 2
5180@cartouche
5181Because the usual mathematical meaning of multiplication of a complex
5182operand and a real operand is that of the scaling of both components of
5183the former by the latter, an implementation should not perform this
5184operation by first promoting the real operand to complex type and then
ad42149c 5185performing a full complex multiplication. In systems that, in the
41af791f
GB
5186future, support an Ada binding to IEC 559:1989, the latter technique
5187will not generate the required result when one of the components of the
ad42149c 5188complex operand is infinite. (Explicit multiplication of the infinite
41af791f
GB
5189component by the zero component obtained during promotion yields a NaN
5190that propagates into the final result.) Analogous advice applies in the
5191case of multiplication of a complex operand and a pure-imaginary
5192operand, and in the case of division of a complex operand by a real or
5193pure-imaginary operand.
5194@end cartouche
5195Not followed.
5196
5197@sp 1
5198@cartouche
5199Similarly, because the usual mathematical meaning of addition of a
5200complex operand and a real operand is that the imaginary operand remains
5201unchanged, an implementation should not perform this operation by first
5202promoting the real operand to complex type and then performing a full
ad42149c 5203complex addition. In implementations in which the @code{Signed_Zeros}
41af791f
GB
5204attribute of the component type is @code{True} (and which therefore
5205conform to IEC 559:1989 in regard to the handling of the sign of zero in
5206predefined arithmetic operations), the latter technique will not
5207generate the required result when the imaginary component of the complex
ad42149c 5208operand is a negatively signed zero. (Explicit addition of the negative
41af791f
GB
5209zero to the zero obtained during promotion yields a positive zero.)
5210Analogous advice applies in the case of addition of a complex operand
5211and a pure-imaginary operand, and in the case of subtraction of a
5212complex operand and a real or pure-imaginary operand.
5213@end cartouche
5214Not followed.
5215
5216@sp 1
5217@cartouche
5218Implementations in which @code{Real'Signed_Zeros} is @code{True} should
5219attempt to provide a rational treatment of the signs of zero results and
ad42149c 5220result components. As one example, the result of the @code{Argument}
41af791f
GB
5221function should have the sign of the imaginary component of the
5222parameter @code{X} when the point represented by that parameter lies on
5223the positive real axis; as another, the sign of the imaginary component
5224of the @code{Compose_From_Polar} function should be the same as
5225(respectively, the opposite of) that of the @code{Argument} parameter when that
5226parameter has a value of zero and the @code{Modulus} parameter has a
5227nonnegative (respectively, negative) value.
5228@end cartouche
5229Followed.
5230
5231@cindex Complex elementary functions
5232@item G.1.2(49): Complex Elementary Functions
5233@sp 1
5234@cartouche
5235Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
5236@code{True} should attempt to provide a rational treatment of the signs
ad42149c 5237of zero results and result components. For example, many of the complex
41af791f
GB
5238elementary functions have components that are odd functions of one of
5239the parameter components; in these cases, the result component should
ad42149c 5240have the sign of the parameter component at the origin. Other complex
41af791f
GB
5241elementary functions have zero components whose sign is opposite that of
5242a parameter component at the origin, or is always positive or always
5243negative.
5244@end cartouche
5245Followed.
5246
5247@cindex Accuracy requirements
5248@item G.2.4(19): Accuracy Requirements
5249@sp 1
5250@cartouche
5251The versions of the forward trigonometric functions without a
5252@code{Cycle} parameter should not be implemented by calling the
5253corresponding version with a @code{Cycle} parameter of
5254@code{2.0*Numerics.Pi}, since this will not provide the required
ad42149c 5255accuracy in some portions of the domain. For the same reason, the
41af791f
GB
5256version of @code{Log} without a @code{Base} parameter should not be
5257implemented by calling the corresponding version with a @code{Base}
5258parameter of @code{Numerics.e}.
5259@end cartouche
5260Followed.
5261
5262@cindex Complex arithmetic accuracy
5263@cindex Accuracy, complex arithmetic
5264@item G.2.6(15): Complex Arithmetic Accuracy
5265
5266@sp 1
5267@cartouche
5268The version of the @code{Compose_From_Polar} function without a
5269@code{Cycle} parameter should not be implemented by calling the
5270corresponding version with a @code{Cycle} parameter of
5271@code{2.0*Numerics.Pi}, since this will not provide the required
5272accuracy in some portions of the domain.
5273@end cartouche
5274Followed.
5275
5276@end table
5277@node Implementation Defined Characteristics
5278@chapter Implementation Defined Characteristics
5279In addition to the implementation dependent pragmas and attributes, and
5280the implementation advice, there are a number of other features of Ada
ad42149c 528195 that are potentially implementation dependent. These are mentioned
46b58b8c 5282throughout the Ada 95 Reference Manual, and are summarized in annex M@.
41af791f
GB
5283
5284A requirement for conforming Ada compilers is that they provide
5285documentation describing how the implementation deals with each of these
ad42149c 5286issues. In this chapter, you will find each point in annex M listed
41af791f
GB
5287followed by a description in italic font of how GNAT
5288@c SGI info:
5289@ignore
5290in the ProDev Ada
5291implementation on IRIX 5.3 operating system or greater
5292@end ignore
5293handles the implementation dependence.
5294
5295You can use this chapter as a guide to minimizing implementation
5296dependent features in your programs if portability to other compilers
5297and other operating systems is an important consideration. The numbers
5298in each section below correspond to the paragraph number in the Ada 95
5299Reference Manual.
5300
5301@sp 1
5302@cartouche
5303@noindent
5304@strong{2}. Whether or not each recommendation given in Implementation
ad42149c 5305Advice is followed. See 1.1.2(37).
41af791f
GB
5306@end cartouche
5307@noindent
5308@xref{Implementation Advice}.
5309
5310@sp 1
5311@cartouche
5312@noindent
ad42149c 5313@strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
41af791f
GB
5314@end cartouche
5315@noindent
5316The complexity of programs that can be processed is limited only by the
5317total amount of available virtual memory, and disk space for the
5318generated object files.
5319
5320@sp 1
5321@cartouche
5322@noindent
5323@strong{4}. Variations from the standard that are impractical to avoid
ad42149c 5324given the implementation's execution environment. See 1.1.3(6).
41af791f
GB
5325@end cartouche
5326@noindent
5327There are no variations from the standard.
5328
5329@sp 1
5330@cartouche
5331@noindent
5332@strong{5}. Which @code{code_statement}s cause external
ad42149c 5333interactions. See 1.1.3(10).
41af791f
GB
5334@end cartouche
5335@noindent
5336Any @code{code_statement} can potentially cause external interactions.
5337
5338@sp 1
5339@cartouche
5340@noindent
5341@strong{6}. The coded representation for the text of an Ada
ad42149c 5342program. See 2.1(4).
41af791f
GB
5343@end cartouche
5344@noindent
5345See separate section on source representation.
5346
5347@sp 1
5348@cartouche
5349@noindent
ad42149c 5350@strong{7}. The control functions allowed in comments. See 2.1(14).
41af791f
GB
5351@end cartouche
5352@noindent
5353See separate section on source representation.
5354
5355@sp 1
5356@cartouche
5357@noindent
ad42149c 5358@strong{8}. The representation for an end of line. See 2.2(2).
41af791f
GB
5359@end cartouche
5360@noindent
5361See separate section on source representation.
5362
5363@sp 1
5364@cartouche
5365@noindent
5366@strong{9}. Maximum supported line length and lexical element
ad42149c 5367length. See 2.2(15).
41af791f
GB
5368@end cartouche
5369@noindent
5370The maximum line length is 255 characters an the maximum length of a
5371lexical element is also 255 characters.
5372
5373@sp 1
5374@cartouche
5375@noindent
ad42149c 5376@strong{10}. Implementation defined pragmas. See 2.8(14).
41af791f
GB
5377@end cartouche
5378@noindent
5379
5380@xref{Implementation Defined Pragmas}.
5381
5382@sp 1
5383@cartouche
5384@noindent
ad42149c 5385@strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
41af791f
GB
5386@end cartouche
5387@noindent
5388Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
5389parameter, checks that the optimization flag is set, and aborts if it is
5390not.
5391
5392@sp 1
5393@cartouche
5394@noindent
5395@strong{12}. The sequence of characters of the value returned by
5396@code{@var{S}'Image} when some of the graphic characters of
ad42149c 5397@code{@var{S}'Wide_Image} are not defined in @code{Character}. See
41af791f
GB
53983.5(37).
5399@end cartouche
5400@noindent
5401The sequence of characters is as defined by the wide character encoding
ad42149c 5402method used for the source. See section on source representation for
41af791f
GB
5403further details.
5404
5405@sp 1
5406@cartouche
5407@noindent
5408@strong{13}. The predefined integer types declared in
ad42149c 5409@code{Standard}. See 3.5.4(25).
41af791f
GB
5410@end cartouche
5411@noindent
5412@table @code
5413@item Short_Short_Integer
54148 bit signed
5415@item Short_Integer
5416(Short) 16 bit signed
5417@item Integer
541832 bit signed
5419@item Long_Integer
542064 bit signed (Alpha OpenVMS only)
542132 bit signed (all other targets)
5422@item Long_Long_Integer
542364 bit signed
5424@end table
5425
5426@sp 1
5427@cartouche
5428@noindent
5429@strong{14}. Any nonstandard integer types and the operators defined
ad42149c 5430for them. See 3.5.4(26).
41af791f
GB
5431@end cartouche
5432@noindent
5433There are no nonstandard integer types.
5434
5435@sp 1
5436@cartouche
5437@noindent
5438@strong{15}. Any nonstandard real types and the operators defined for
ad42149c 5439them. See 3.5.6(8).
41af791f
GB
5440@end cartouche
5441@noindent
5442There are no nonstandard real types.
5443
5444@sp 1
5445@cartouche
5446@noindent
5447@strong{16}. What combinations of requested decimal precision and range
ad42149c 5448are supported for floating point types. See 3.5.7(7).
41af791f
GB
5449@end cartouche
5450@noindent
5451The precision and range is as defined by the IEEE standard.
5452
5453@sp 1
5454@cartouche
5455@noindent
5456@strong{17}. The predefined floating point types declared in
ad42149c 5457@code{Standard}. See 3.5.7(16).
41af791f
GB
5458@end cartouche
5459@noindent
5460@table @code
5461@item Short_Float
546232 bit IEEE short
5463@item Float
5464(Short) 32 bit IEEE short
5465@item Long_Float
546664 bit IEEE long
5467@item Long_Long_Float
546864 bit IEEE long (80 bit IEEE long on x86 processors)
5469@end table
5470
5471@sp 1
5472@cartouche
5473@noindent
ad42149c 5474@strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
41af791f
GB
5475@end cartouche
5476@noindent
ad42149c 5477@code{Fine_Delta} is 2**(@minus{}63)
41af791f
GB
5478
5479@sp 1
5480@cartouche
5481@noindent
5482@strong{19}. What combinations of small, range, and digits are
ad42149c 5483supported for fixed point types. See 3.5.9(10).
41af791f
GB
5484@end cartouche
5485@noindent
5486Any combinations are permitted that do not result in a small less than
5487@code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
5488If the mantissa is larger than 53 bits on machines where Long_Long_Float
5489is 64 bits (true of all architectures except ia32), then the output from
ad42149c 5490Text_IO is accurate to only 53 bits, rather than the full mantissa. This
41af791f
GB
5491is because floating-point conversions are used to convert fixed point.
5492
5493@sp 1
5494@cartouche
5495@noindent
5496@strong{20}. The result of @code{Tags.Expanded_Name} for types declared
ad42149c 5497within an unnamed @code{block_statement}. See 3.9(10).
41af791f
GB
5498@end cartouche
5499@noindent
5500Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
5501decimal integer are allocated.
5502
5503@sp 1
5504@cartouche
5505@noindent
ad42149c 5506@strong{21}. Implementation-defined attributes. See 4.1.4(12).
41af791f
GB
5507@end cartouche
5508@noindent
5509@xref{Implementation Defined Attributes}.
5510
5511@sp 1
5512@cartouche
5513@noindent
ad42149c 5514@strong{22}. Any implementation-defined time types. See 9.6(6).
41af791f
GB
5515@end cartouche
5516@noindent
5517There are no implementation-defined time types.
5518
5519@sp 1
5520@cartouche
5521@noindent
5522@strong{23}. The time base associated with relative delays.
5523@end cartouche
5524@noindent
ad42149c 5525See 9.6(20). The time base used is that provided by the C library
41af791f
GB
5526function @code{gettimeofday}.
5527
5528@sp 1
5529@cartouche
5530@noindent
ad42149c 5531@strong{24}. The time base of the type @code{Calendar.Time}. See
41af791f
GB
55329.6(23).
5533@end cartouche
5534@noindent
5535The time base used is that provided by the C library function
5536@code{gettimeofday}.
5537
5538@sp 1
5539@cartouche
5540@noindent
5541@strong{25}. The time zone used for package @code{Calendar}
ad42149c 5542operations. See 9.6(24).
41af791f
GB
5543@end cartouche
5544@noindent
5545The time zone used by package @code{Calendar} is the current system time zone
5546setting for local time, as accessed by the C library function
5547@code{localtime}.
5548
5549@sp 1
5550@cartouche
5551@noindent
5552@strong{26}. Any limit on @code{delay_until_statements} of
ad42149c 5553@code{select_statements}. See 9.6(29).
41af791f
GB
5554@end cartouche
5555@noindent
5556There are no such limits.
5557
5558@sp 1
5559@cartouche
5560@noindent
5561@strong{27}. Whether or not two non overlapping parts of a composite
5562object are independently addressable, in the case where packing, record
ad42149c 5563layout, or @code{Component_Size} is specified for the object. See
41af791f
GB
55649.10(1).
5565@end cartouche
5566@noindent
5567Separate components are independently addressable if they do not share
5568overlapping storage units.
5569
5570@sp 1
5571@cartouche
5572@noindent
ad42149c 5573@strong{28}. The representation for a compilation. See 10.1(2).
41af791f
GB
5574@end cartouche
5575@noindent
5576A compilation is represented by a sequence of files presented to the
ad42149c 5577compiler in a single invocation of the @code{gcc} command.
41af791f
GB
5578
5579@sp 1
5580@cartouche
5581@noindent
5582@strong{29}. Any restrictions on compilations that contain multiple
ad42149c 5583compilation_units. See 10.1(4).
41af791f
GB
5584@end cartouche
5585@noindent
5586No single file can contain more than one compilation unit, but any
5587sequence of files can be presented to the compiler as a single
5588compilation.
5589
5590@sp 1
5591@cartouche
5592@noindent
5593@strong{30}. The mechanisms for creating an environment and for adding
ad42149c 5594and replacing compilation units. See 10.1.4(3).
41af791f
GB
5595@end cartouche
5596@noindent
5597See separate section on compilation model.
5598
5599@sp 1
5600@cartouche
5601@noindent
5602@strong{31}. The manner of explicitly assigning library units to a
ad42149c 5603partition. See 10.2(2).
41af791f
GB
5604@end cartouche
5605@noindent
5606If a unit contains an Ada main program, then the Ada units for the partition
5607are determined by recursive application of the rules in the Ada Reference
ad42149c 5608Manual section 10.2(2-6). In other words, the Ada units will be those that
41af791f
GB
5609are needed by the main program, and then this definition of need is applied
5610recursively to those units, and the partition contains the transitive
ad42149c
FW
5611closure determined by this relationship. In short, all the necessary units
5612are included, with no need to explicitly specify the list. If additional
46b58b8c 5613units are required, e.g.@: by foreign language units, then all units must be
41af791f
GB
5614mentioned in the context clause of one of the needed Ada units.
5615
5616If the partition contains no main program, or if the main program is in
5617a language other than Ada, then GNAT
ad42149c 5618provides the binder options @code{-z} and @code{-n} respectively, and in this case a
41af791f
GB
5619list of units can be explicitly supplied to the binder for inclusion in
5620the partition (all units needed by these units will also be included
ad42149c
FW
5621automatically). For full details on the use of these options, refer to
5622the @cite{GNAT User's Guide} sections on Binding and Linking.
41af791f
GB
5623
5624@sp 1
5625@cartouche
5626@noindent
5627@strong{32}. The implementation-defined means, if any, of specifying
ad42149c 5628which compilation units are needed by a given compilation unit. See
41af791f
GB
562910.2(2).
5630@end cartouche
5631@noindent
5632The units needed by a given compilation unit are as defined in
ad42149c 5633the Ada Reference Manual section 10.2(2-6). There are no
41af791f
GB
5634implementation-defined pragmas or other implementation-defined
5635means for specifying needed units.
5636
5637@sp 1
5638@cartouche
5639@noindent
5640@strong{33}. The manner of designating the main subprogram of a
ad42149c 5641partition. See 10.2(7).
41af791f
GB
5642@end cartouche
5643@noindent
5644The main program is designated by providing the name of the
ad42149c 5645corresponding @file{ALI} file as the input parameter to the binder.
41af791f
GB
5646
5647@sp 1
5648@cartouche
5649@noindent
ad42149c 5650@strong{34}. The order of elaboration of @code{library_items}. See
41af791f
GB
565110.2(18).
5652@end cartouche
5653@noindent
5654The first constraint on ordering is that it meets the requirements of
ad42149c 5655chapter 10 of the Ada 95 Reference Manual. This still leaves some
41af791f 5656implementation dependent choices, which are resolved by first
46b58b8c 5657elaborating bodies as early as possible (i.e.@: in preference to specs
41af791f
GB
5658where there is a choice), and second by evaluating the immediate with
5659clauses of a unit to determine the probably best choice, and
5660third by elaborating in alphabetical order of unit names
5661where a choice still remains.
5662
5663@sp 1
5664@cartouche
5665@noindent
5666@strong{35}. Parameter passing and function return for the main
ad42149c 5667subprogram. See 10.2(21).
41af791f
GB
5668@end cartouche
5669@noindent
ad42149c
FW
5670The main program has no parameters. It may be a procedure, or a function
5671returning an integer type. In the latter case, the returned integer
41af791f
GB
5672value is the return code of the program.
5673
5674@sp 1
5675@cartouche
5676@noindent
ad42149c 5677@strong{36}. The mechanisms for building and running partitions. See
41af791f
GB
567810.2(24).
5679@end cartouche
5680@noindent
ad42149c 5681GNAT itself supports programs with only a single partition. The GNATDIST
41af791f
GB
5682tool provided with the GLADE package (which also includes an implementation
5683of the PCS) provides a completely flexible method for building and running
ad42149c 5684programs consisting of multiple partitions. See the separate GLADE manual
41af791f
GB
5685for details.
5686
5687@sp 1
5688@cartouche
5689@noindent
5690@strong{37}. The details of program execution, including program
ad42149c 5691termination. See 10.2(25).
41af791f
GB
5692@end cartouche
5693@noindent
5694See separate section on compilation model.
5695
5696@sp 1
5697@cartouche
5698@noindent
5699@strong{38}. The semantics of any non-active partitions supported by the
ad42149c 5700implementation. See 10.2(28).
41af791f
GB
5701@end cartouche
5702@noindent
5703Passive partitions are supported on targets where shared memory is
ad42149c 5704provided by the operating system. See the GLADE reference manual for
41af791f
GB
5705further details.
5706
5707@sp 1
5708@cartouche
5709@noindent
ad42149c 5710@strong{39}. The information returned by @code{Exception_Message}. See
41af791f
GB
571111.4.1(10).
5712@end cartouche
5713@noindent
5714Exception message returns the null string unless a specific message has
5715been passed by the program.
5716
5717@sp 1
5718@cartouche
5719@noindent
5720@strong{40}. The result of @code{Exceptions.Exception_Name} for types
ad42149c 5721declared within an unnamed @code{block_statement}. See 11.4.1(12).
41af791f
GB
5722@end cartouche
5723@noindent
5724Blocks have implementation defined names of the form @code{B@var{nnn}}
5725where @var{nnn} is an integer.
5726
5727@sp 1
5728@cartouche
5729@noindent
5730@strong{41}. The information returned by
ad42149c 5731@code{Exception_Information}. See 11.4.1(13).
41af791f
GB
5732@end cartouche
5733@noindent
ad42149c
FW
5734@code{Exception_Information} returns a string in the following format:
5735
5736@smallexample
5737@emph{Exception_Name:} nnnnn
5738@emph{Message:} mmmmm
5739@emph{PID:} ppp
5740@emph{Call stack traceback locations:}
57410xhhhh 0xhhhh 0xhhhh ... 0xhhh
5742@end smallexample
5743
5744@noindent
5745where
5746
5747@itemize @bullet
5748@item
5749@code{nnnn} is the fully qualified name of the exception in all upper
5750case letters. This line is always present.
5751
5752@item
5753@code{mmmm} is the message (this line present only if message is non-null)
5754
5755@item
5756@code{ppp} is the Process Id value as a decimal integer (this line is
5757present only if the Process Id is non-zero). Currently we are
5758not making use of this field.
5759
5760@item
5761The Call stack traceback locations line and the following values
5762are present only if at least one traceback location was recorded.
5763The values are given in C style format, with lower case letters
5764for a-f, and only as many digits present as are necessary.
5765@end itemize
5766
5767@noindent
5768The line terminator sequence at the end of each line, including
5769the last line is a single @code{LF} character (@code{16#0A#}).
41af791f
GB
5770
5771@sp 1
5772@cartouche
5773@noindent
ad42149c 5774@strong{42}. Implementation-defined check names. See 11.5(27).
41af791f
GB
5775@end cartouche
5776@noindent
5777No implementation-defined check names are supported.
5778
5779@sp 1
5780@cartouche
5781@noindent
ad42149c 5782@strong{43}. The interpretation of each aspect of representation. See
41af791f
GB
578313.1(20).
5784@end cartouche
5785@noindent
5786See separate section on data representations.
5787
5788@sp 1
5789@cartouche
5790@noindent
ad42149c 5791@strong{44}. Any restrictions placed upon representation items. See
41af791f
GB
579213.1(20).
5793@end cartouche
5794@noindent
5795See separate section on data representations.
5796
5797@sp 1
5798@cartouche
5799@noindent
ad42149c 5800@strong{45}. The meaning of @code{Size} for indefinite subtypes. See
41af791f
GB
580113.3(48).
5802@end cartouche
5803@noindent
5804Size for an indefinite subtype is the maximum possible size, except that
5805for the case of a subprogram parameter, the size of the parameter object
5806is the actual size.
5807
5808@sp 1
5809@cartouche
5810@noindent
ad42149c 5811@strong{46}. The default external representation for a type tag. See
41af791f
GB
581213.3(75).
5813@end cartouche
5814@noindent
5815The default external representation for a type tag is the fully expanded
5816name of the type in upper case letters.
5817
5818@sp 1
5819@cartouche
5820@noindent
5821@strong{47}. What determines whether a compilation unit is the same in
ad42149c 5822two different partitions. See 13.3(76).
41af791f
GB
5823@end cartouche
5824@noindent
5825A compilation unit is the same in two different partitions if and only
5826if it derives from the same source file.
5827
5828@sp 1
5829@cartouche
5830@noindent
ad42149c 5831@strong{48}. Implementation-defined components. See 13.5.1(15).
41af791f
GB
5832@end cartouche
5833@noindent
5834The only implementation defined component is the tag for a tagged type,
5835which contains a pointer to the dispatching table.
5836
5837@sp 1
5838@cartouche
5839@noindent
5840@strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
ad42149c 5841ordering. See 13.5.3(5).
41af791f
GB
5842@end cartouche
5843@noindent
5844@code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
ad42149c 5845implementation, so no non-default bit ordering is supported. The default
41af791f
GB
5846bit ordering corresponds to the natural endianness of the target architecture.
5847
5848@sp 1
5849@cartouche
5850@noindent
5851@strong{50}. The contents of the visible part of package @code{System}
ad42149c 5852and its language-defined children. See 13.7(2).
41af791f
GB
5853@end cartouche
5854@noindent
5855See the definition of these packages in files @file{system.ads} and
5856@file{s-stoele.ads}.
5857
5858@sp 1
5859@cartouche
5860@noindent
5861@strong{51}. The contents of the visible part of package
5862@code{System.Machine_Code}, and the meaning of
ad42149c 5863@code{code_statements}. See 13.8(7).
41af791f
GB
5864@end cartouche
5865@noindent
5866See the definition and documentation in file @file{s-maccod.ads}.
5867
5868@sp 1
5869@cartouche
5870@noindent
ad42149c 5871@strong{52}. The effect of unchecked conversion. See 13.9(11).
41af791f
GB
5872@end cartouche
5873@noindent
5874Unchecked conversion between types of the same size
5875and results in an uninterpreted transmission of the bits from one type
ad42149c 5876to the other. If the types are of unequal sizes, then in the case of
41af791f
GB
5877discrete types, a shorter source is first zero or sign extended as
5878necessary, and a shorter target is simply truncated on the left.
5879For all non-discrete types, the source is first copied if necessary
5880to ensure that the alignment requirements of the target are met, then
5881a pointer is constructed to the source value, and the result is obtained
5882by dereferencing this pointer after converting it to be a pointer to the
5883target type.
5884
5885@sp 1
5886@cartouche
5887@noindent
5888@strong{53}. The manner of choosing a storage pool for an access type
ad42149c 5889when @code{Storage_Pool} is not specified for the type. See 13.11(17).
41af791f
GB
5890@end cartouche
5891@noindent
5892There are 3 different standard pools used by the compiler when
5893@code{Storage_Pool} is not specified depending whether the type is local
5894to a subprogram or defined at the library level and whether
ad42149c 5895@code{Storage_Size}is specified or not. See documentation in the runtime
41af791f
GB
5896library units @code{System.Pool_Global}, @code{System.Pool_Size} and
5897@code{System.Pool_Local} in files @file{s-poosiz.ads},
5898@file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
5899default pools used.
5900
5901@sp 1
5902@cartouche
5903@noindent
5904@strong{54}. Whether or not the implementation provides user-accessible
ad42149c 5905names for the standard pool type(s). See 13.11(17).
41af791f
GB
5906@end cartouche
5907@noindent
5908
5909See documentation in the sources of the run time mentioned in paragraph
ad42149c 5910@strong{53} . All these pools are accessible by means of @code{with}'ing
41af791f
GB
5911these units.
5912
5913@sp 1
5914@cartouche
5915@noindent
ad42149c 5916@strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
41af791f
GB
5917@end cartouche
5918@noindent
5919@code{Storage_Size} is measured in storage units, and refers to the
5920total space available for an access type collection, or to the primary
5921stack space for a task.
5922
5923@sp 1
5924@cartouche
5925@noindent
ad42149c 5926@strong{56}. Implementation-defined aspects of storage pools. See
41af791f
GB
592713.11(22).
5928@end cartouche
5929@noindent
5930See documentation in the sources of the run time mentioned in paragraph
5931@strong{53} for details on GNAT-defined aspects of storage pools.
5932
5933@sp 1
5934@cartouche
5935@noindent
5936@strong{57}. The set of restrictions allowed in a pragma
ad42149c 5937@code{Restrictions}. See 13.12(7).
41af791f
GB
5938@end cartouche
5939@noindent
ad42149c
FW
5940All RM defined Restriction identifiers are implemented. The following
5941additional restriction identifiers are provided. There are two separate
5942lists of implementation dependent restriction identifiers. The first
41af791f
GB
5943set requires consistency throughout a partition (in other words, if the
5944restriction identifier is used for any compilation unit in the partition,
5945then all compilation units in the partition must obey the restriction.
5946
5947@table @code
5948
5949@item Boolean_Entry_Barriers
5950@findex Boolean_Entry_Barriers
5951This restriction ensures at compile time that barriers in entry declarations
5952for protected types are restricted to references to simple boolean variables
ad42149c
FW
5953defined in the private part of the protected type. No other form of entry
5954barriers is permitted. This is one of the restrictions of the Ravenscar
5955profile for limited tasking (see also pragma @code{Ravenscar}).
41af791f
GB
5956
5957@item Max_Entry_Queue_Depth => Expr
5958@findex Max_Entry_Queue_Depth
5959This restriction is a declaration that any protected entry compiled in
5960the scope of the restriction has at most the specified number of
5961tasks waiting on the entry
ad42149c
FW
5962at any one time, and so no queue is required. This restriction is not
5963checked at compile time. A program execution is erroneous if an attempt
41af791f
GB
5964is made to queue more than the specified number of tasks on such an entry.
5965
5966@item No_Calendar
5967@findex No_Calendar
5968This restriction ensures at compile time that there is no implicit or
5969explicit dependence on the package @code{Ada.Calendar}.
5970
5971@item No_Dynamic_Interrupts
5972@findex No_Dynamic_Interrupts
5973This restriction ensures at compile time that there is no attempt to
ad42149c 5974dynamically associate interrupts. Only static association is allowed.
41af791f
GB
5975
5976@item No_Enumeration_Maps
5977@findex No_Enumeration_Maps
5978This restriction ensures at compile time that no operations requiring
5979enumeration maps are used (that is Image and Value attributes applied
5980to enumeration types).
5981
5982@item No_Entry_Calls_In_Elaboration_Code
5983@findex No_Entry_Calls_In_Elaboration_Code
5984This restriction ensures at compile time that no task or protected entry
ad42149c 5985calls are made during elaboration code. As a result of the use of this
41af791f
GB
5986restriction, the compiler can assume that no code past an accept statement
5987in a task can be executed at elaboration time.
5988
5989@item No_Exception_Handlers
5990@findex No_Exception_Handlers
5991This restriction ensures at compile time that there are no explicit
5992exception handlers.
5993
5994@item No_Implicit_Conditionals
5995@findex No_Implicit_Conditionals
5996This restriction ensures that the generated code does not contain any
5997implicit conditionals, either by modifying the generated code where possible,
5998or by rejecting any construct that would otherwise generate an implicit
ad42149c 5999conditional. The details and use of this restriction are described in
41af791f
GB
6000more detail in the High Integrity product documentation.
6001
6002@item No_Implicit_Loops
6003@findex No_Implicit_Loops
6004This restriction ensures that the generated code does not contain any
6005implicit @code{for} loops, either by modifying
6006the generated code where possible,
6007or by rejecting any construct that would otherwise generate an implicit
ad42149c
FW
6008@code{for} loop. The details and use of this restriction are described in
6009more detail in the High Integrity product documentation.
41af791f
GB
6010
6011@item No_Local_Protected_Objects
6012@findex No_Local_Protected_Objects
6013This restriction ensures at compile time that protected objects are
6014only declared at the library level.
6015
6016@item No_Protected_Type_Allocators
6017@findex No_Protected_Type_Allocators
6018This restriction ensures at compile time that there are no allocator
6019expressions that attempt to allocate protected objects.
6020
ad42149c
FW
6021@item No_Secondary_Stack
6022@findex No_Secondary_Stack
6023This restriction ensures at compile time that the generated code does not
6024contain any reference to the secondary stack. The secondary stack is used
6025to implement functions returning unconstrained objects (arrays or records)
6026on some targets.
6027The details and use of this restriction are described in
6028more detail in the High Integrity product documentation.
6029
41af791f
GB
6030@item No_Select_Statements
6031@findex No_Select_Statements
6032This restriction ensures at compile time no select statements of any kind
6033are permitted, that is the keyword @code{select} may not appear.
6034This is one of the restrictions of the Ravenscar
ad42149c 6035profile for limited tasking (see also pragma @code{Ravenscar}).
41af791f
GB
6036
6037@item No_Standard_Storage_Pools
6038@findex No_Standard_Storage_Pools
6039This restriction ensures at compile time that no access types
ad42149c 6040use the standard default storage pool. Any access type declared must
41af791f
GB
6041have an explicit Storage_Pool attribute defined specifying a
6042user-defined storage pool.
6043
6044@item No_Streams
6045@findex No_Streams
6046This restriction ensures at compile time that there are no implicit or
6047explicit dependencies on the package @code{Ada.Streams}.
6048
6049@item No_Task_Attributes
6050@findex No_Task_Attributes
6051This restriction ensures at compile time that there are no implicit or
6052explicit dependencies on the package @code{Ada.Task_Attributes}.
6053
6054@item No_Task_Termination
6055@findex No_Task_Termination
6056This restriction ensures at compile time that no terminate alternatives
6057appear in any task body.
6058
ad42149c
FW
6059@item No_Tasking
6060@findex No_Tasking
6061This restriction prevents the declaration of tasks or task types throughout
6062the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
6063except that violations are caught at compile time and cause an error message
6064to be output either by the compiler or binder.
6065
41af791f
GB
6066@item No_Wide_Characters
6067@findex No_Wide_Characters
6068This restriction ensures at compile time that no uses of the types
6069@code{Wide_Character} or @code{Wide_String}
6070appear, and that no wide character literals
6071appear in the program (that is literals representing characters not in
6072type @code{Character}.
6073
6074@item Static_Priorities
6075@findex Static_Priorities
6076This restriction ensures at compile time that all priority expressions
6077are static, and that there are no dependencies on the package
6078@code{Ada.Dynamic_Priorities}.
6079
6080@item Static_Storage_Size
6081@findex Static_Storage_Size
6082This restriction ensures at compile time that any expression appearing
6083in a Storage_Size pragma or attribute definition clause is static.
6084
6085@end table
6086
6087@noindent
6088The second set of implementation dependent restriction identifiers
6089does not require partition-wide consistency.
6090The restriction may be enforced for a single
6091compilation unit without any effect on any of the
6092other compilation units in the partition.
6093
6094@table @code
6095
6096@item No_Elaboration_Code
6097@findex No_Elaboration_Code
6098This restriction ensures at compile time that no elaboration code is
ad42149c
FW
6099generated. Note that this is not the same condition as is enforced
6100by pragma @code{Preelaborate}. There are cases in which pragma @code{Preelaborate}
46b58b8c 6101still permits code to be generated (e.g.@: code to initialize a large
41af791f 6102array to all zeroes), and there are cases of units which do not meet
ad42149c
FW
6103the requirements for pragma @code{Preelaborate}, but for which no elaboration
6104code is generated. Generally, it is the case that preelaborable units
41af791f
GB
6105will meet the restrictions, with the exception of large aggregates
6106initialized with an others_clause, and exception declarations (which
ad42149c 6107generate calls to a run-time registry procedure). Note that this restriction
41af791f
GB
6108is enforced on a unit by unit basis, it need not be obeyed consistently
6109throughout a partition.
6110
6111@item No_Entry_Queue
6112@findex No_Entry_Queue
6113This restriction is a declaration that any protected entry compiled in
6114the scope of the restriction has at most one task waiting on the entry
ad42149c
FW
6115at any one time, and so no queue is required. This restriction is not
6116checked at compile time. A program execution is erroneous if an attempt
41af791f
GB
6117is made to queue a second task on such an entry.
6118
6119@item No_Implementation_Attributes
6120@findex No_Implementation_Attributes
6121This restriction checks at compile time that no GNAT-defined attributes
ad42149c 6122are present. With this restriction, the only attributes that can be used
41af791f
GB
6123are those defined in the Ada 95 Reference Manual.
6124
6125@item No_Implementation_Pragmas
6126@findex No_Implementation_Pragmas
6127This restriction checks at compile time that no GNAT-defined pragmas
ad42149c 6128are present. With this restriction, the only pragmas that can be used
41af791f
GB
6129are those defined in the Ada 95 Reference Manual.
6130
6131@item No_Implementation_Restrictions
6132@findex No_Implementation_Restrictions
6133This restriction checks at compile time that no GNAT-defined restriction
6134identifiers (other than @code{No_Implementation_Restrictions} itself)
ad42149c 6135are present. With this restriction, the only other restriction identifiers
41af791f
GB
6136that can be used are those defined in the Ada 95 Reference Manual.
6137
6138@end table
6139
6140@sp 1
6141@cartouche
6142@noindent
6143@strong{58}. The consequences of violating limitations on
ad42149c 6144@code{Restrictions} pragmas. See 13.12(9).
41af791f
GB
6145@end cartouche
6146@noindent
6147Restrictions that can be checked at compile time result in illegalities
ad42149c 6148if violated. Currently there are no other consequences of violating
41af791f
GB
6149restrictions.
6150
6151@sp 1
6152@cartouche
6153@noindent
6154@strong{59}. The representation used by the @code{Read} and
6155@code{Write} attributes of elementary types in terms of stream
ad42149c 6156elements. See 13.13.2(9).
41af791f
GB
6157@end cartouche
6158@noindent
6159The representation is the in-memory representation of the base type of
6160the type, using the number of bits corresponding to the
6161@code{@var{type}'Size} value, and the natural ordering of the machine.
6162
6163@sp 1
6164@cartouche
6165@noindent
6166@strong{60}. The names and characteristics of the numeric subtypes
ad42149c 6167declared in the visible part of package @code{Standard}. See A.1(3).
41af791f
GB
6168@end cartouche
6169@noindent
6170See items describing the integer and floating-point types supported.
6171
6172@sp 1
6173@cartouche
6174@noindent
6175@strong{61}. The accuracy actually achieved by the elementary
ad42149c 6176functions. See A.5.1(1).
41af791f
GB
6177@end cartouche
6178@noindent
6179The elementary functions correspond to the functions available in the C
ad42149c 6180library. Only fast math mode is implemented.
41af791f
GB
6181
6182@sp 1
6183@cartouche
6184@noindent
6185@strong{62}. The sign of a zero result from some of the operators or
6186functions in @code{Numerics.Generic_Elementary_Functions}, when
ad42149c 6187@code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
41af791f
GB
6188@end cartouche
6189@noindent
6190The sign of zeroes follows the requirements of the IEEE 754 standard on
6191floating-point.
6192
6193@sp 1
6194@cartouche
6195@noindent
6196@strong{63}. The value of
ad42149c 6197@code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
41af791f
GB
6198@end cartouche
6199@noindent
6200Maximum image width is 649, see library file @file{a-numran.ads}.
6201
6202@sp 1
6203@cartouche
6204@noindent
6205@strong{64}. The value of
ad42149c 6206@code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
41af791f
GB
6207@end cartouche
6208@noindent
6209Maximum image width is 80, see library file @file{a-nudira.ads}.
6210
6211@sp 1
6212@cartouche
6213@noindent
ad42149c 6214@strong{65}. The algorithms for random number generation. See
41af791f
GB
6215A.5.2(32).
6216@end cartouche
6217@noindent
6218The algorithm is documented in the source files @file{a-numran.ads} and
6219@file{a-numran.adb}.
6220
6221@sp 1
6222@cartouche
6223@noindent
6224@strong{66}. The string representation of a random number generator's
ad42149c 6225state. See A.5.2(38).
41af791f
GB
6226@end cartouche
6227@noindent
6228See the documentation contained in the file @file{a-numran.adb}.
6229
6230@sp 1
6231@cartouche
6232@noindent
6233@strong{67}. The minimum time interval between calls to the
6234time-dependent Reset procedure that are guaranteed to initiate different
ad42149c 6235random number sequences. See A.5.2(45).
41af791f
GB
6236@end cartouche
6237@noindent
6238The minimum period between reset calls to guarantee distinct series of
6239random numbers is one microsecond.
6240
6241@sp 1
6242@cartouche
6243@noindent
6244@strong{68}. The values of the @code{Model_Mantissa},
6245@code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
6246@code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
ad42149c 6247Annex is not supported. See A.5.3(72).
41af791f
GB
6248@end cartouche
6249@noindent
6250See the source file @file{ttypef.ads} for the values of all numeric
6251attributes.
6252
6253@sp 1
6254@cartouche
6255@noindent
6256@strong{69}. Any implementation-defined characteristics of the
ad42149c 6257input-output packages. See A.7(14).
41af791f
GB
6258@end cartouche
6259@noindent
6260There are no special implementation defined characteristics for these
6261packages.
6262
6263@sp 1
6264@cartouche
6265@noindent
ad42149c 6266@strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
41af791f
GB
6267A.9(10).
6268@end cartouche
6269@noindent
6270All type representations are contiguous, and the @code{Buffer_Size} is
6271the value of @code{@var{type}'Size} rounded up to the next storage unit
6272boundary.
6273
6274@sp 1
6275@cartouche
6276@noindent
6277@strong{71}. External files for standard input, standard output, and
6278standard error See A.10(5).
6279@end cartouche
6280@noindent
6281These files are mapped onto the files provided by the C streams
ad42149c 6282libraries. See source file @file{i-cstrea.ads} for further details.
41af791f
GB
6283
6284@sp 1
6285@cartouche
6286@noindent
ad42149c 6287@strong{72}. The accuracy of the value produced by @code{Put}. See
41af791f
GB
6288A.10.9(36).
6289@end cartouche
6290@noindent
6291If more digits are requested in the output than are represented by the
6292precision of the value, zeroes are output in the corresponding least
6293significant digit positions.
6294
6295@sp 1
6296@cartouche
6297@noindent
6298@strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
ad42149c 6299@code{Command_Name}. See A.15(1).
41af791f
GB
6300@end cartouche
6301@noindent
6302These are mapped onto the @code{argv} and @code{argc} parameters of the
6303main program in the natural manner.
6304
6305@sp 1
6306@cartouche
6307@noindent
ad42149c 6308@strong{74}. Implementation-defined convention names. See B.1(11).
41af791f
GB
6309@end cartouche
6310@noindent
6311The following convention names are supported
6312
6313@table @code
6314@item Ada
6315Ada
41af791f
GB
6316@item Assembler
6317Assembly language
ad42149c
FW
6318@item Asm
6319Synonym for Assembler
6320@item Assembly
6321Synonym for Assembler
41af791f
GB
6322@item C
6323C
6324@item C_Pass_By_Copy
ad42149c
FW
6325Allowed only for record types, like C, but also notes that record
6326is to be passed by copy rather than reference.
41af791f
GB
6327@item COBOL
6328COBOL
6329@item CPP
6330C++
6331@item Default
6332Treated the same as C
41af791f
GB
6333@item External
6334Treated the same as C
6335@item Fortran
6336Fortran
6337@item Intrinsic
6338For support of pragma @code{Import} with convention Intrinsic, see
6339separate section on Intrinsic Subprograms.
6340@item Stdcall
ad42149c 6341Stdcall (used for Windows implementations only). This convention correspond
41af791f 6342to the WINAPI (previously called Pascal convention) C/C++ convention under
ad42149c
FW
6343Windows. A function with this convention cleans the stack before exit.
6344@item DLL
6345Synonym for Stdcall
6346@item Win32
6347Synonym for Stdcall
41af791f
GB
6348@item Stubbed
6349Stubbed is a special convention used to indicate that the body of the
ad42149c
FW
6350subprogram will be entirely ignored. Any call to the subprogram
6351is converted into a raise of the @code{Program_Error} exception. If a
41af791f 6352pragma @code{Import} specifies convention @code{stubbed} then no body need
ad42149c 6353be present at all. This convention is useful during development for the
41af791f
GB
6354inclusion of subprograms whose body has not yet been written.
6355
6356@end table
6357@noindent
6358In addition, all otherwise unrecognized convention names are also
ad42149c
FW
6359treated as being synonymous with convention C@. In all implementations
6360except for VMS, use of such other names results in a warning. In VMS
41af791f
GB
6361implementations, these names are accepted silently.
6362
6363@sp 1
6364@cartouche
6365@noindent
ad42149c 6366@strong{75}. The meaning of link names. See B.1(36).
41af791f
GB
6367@end cartouche
6368@noindent
6369Link names are the actual names used by the linker.
6370
6371@sp 1
6372@cartouche
6373@noindent
6374@strong{76}. The manner of choosing link names when neither the link
ad42149c 6375name nor the address of an imported or exported entity is specified. See
41af791f
GB
6376B.1(36).
6377@end cartouche
6378@noindent
6379The default linker name is that which would be assigned by the relevant
6380external language, interpreting the Ada name as being in all lower case
6381letters.
6382
6383@sp 1
6384@cartouche
6385@noindent
ad42149c 6386@strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
41af791f
GB
6387@end cartouche
6388@noindent
6389The string passed to @code{Linker_Options} is presented uninterpreted as
6390an argument to the link command, unless it contains Ascii.NUL characters.
6391NUL characters if they appear act as argument separators, so for example
6392
6393@smallexample
6394pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
6395@end smallexample
6396
6397@noindent
ad42149c
FW
6398causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
6399linker. The order of linker options is preserved for a given unit. The final
6400list of options passed to the linker is in reverse order of the elaboration
6401order. For example, linker options fo a body always appear before the options
6402from the corresponding package spec.
41af791f
GB
6403
6404@sp 1
6405@cartouche
6406@noindent
6407@strong{78}. The contents of the visible part of package
ad42149c 6408@code{Interfaces} and its language-defined descendants. See B.2(1).
41af791f
GB
6409@end cartouche
6410@noindent
6411See files with prefix @file{i-} in the distributed library.
6412
6413@sp 1
6414@cartouche
6415@noindent
6416@strong{79}. Implementation-defined children of package
ad42149c
FW
6417@code{Interfaces}. The contents of the visible part of package
6418@code{Interfaces}. See B.2(11).
41af791f
GB
6419@end cartouche
6420@noindent
6421See files with prefix @file{i-} in the distributed library.
6422
6423@sp 1
6424@cartouche
6425@noindent
6426@strong{80}. The types @code{Floating}, @code{Long_Floating},
6427@code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
6428@code{COBOL_Character}; and the initialization of the variables
6429@code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
ad42149c 6430@code{Interfaces.COBOL}. See B.4(50).
41af791f
GB
6431@end cartouche
6432@noindent
6433@table @code
6434@item Floating
6435Float
6436@item Long_Floating
6437(Floating) Long_Float
6438@item Binary
6439Integer
6440@item Long_Binary
6441Long_Long_Integer
6442@item Decimal_Element
6443Character
6444@item COBOL_Character
6445Character
6446@end table
6447
6448For initialization, see the file @file{i-cobol.ads} in the distributed library.
6449
6450@sp 1
6451@cartouche
6452@noindent
ad42149c 6453@strong{81}. Support for access to machine instructions. See C.1(1).
41af791f
GB
6454@end cartouche
6455@noindent
6456See documentation in file @file{s-maccod.ads} in the distributed library.
6457
6458@sp 1
6459@cartouche
6460@noindent
6461@strong{82}. Implementation-defined aspects of access to machine
ad42149c 6462operations. See C.1(9).
41af791f
GB
6463@end cartouche
6464@noindent
6465See documentation in file @file{s-maccod.ads} in the distributed library.
6466
6467@sp 1
6468@cartouche
6469@noindent
ad42149c 6470@strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
41af791f
GB
6471@end cartouche
6472@noindent
ad42149c 6473Interrupts are mapped to signals or conditions as appropriate. See
41af791f
GB
6474definition of unit
6475@code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
6476on the interrupts supported on a particular target.
6477
6478@sp 1
6479@cartouche
6480@noindent
ad42149c 6481@strong{84}. Implementation-defined aspects of pre-elaboration. See
41af791f
GB
6482C.4(13).
6483@end cartouche
6484@noindent
6485GNAT does not permit a partition to be restarted without reloading,
6486except under control of the debugger.
6487
6488@sp 1
6489@cartouche
6490@noindent
ad42149c 6491@strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
41af791f
GB
6492@end cartouche
6493@noindent
6494Pragma @code{Discard_Names} causes names of enumeration literals to
ad42149c 6495be suppressed. In the presence of this pragma, the Image attribute
41af791f
GB
6496provides the image of the Pos of the literal, and Value accepts
6497Pos values.
6498
6499@sp 1
6500@cartouche
6501@noindent
6502@strong{86}. The result of the @code{Task_Identification.Image}
ad42149c 6503attribute. See C.7.1(7).
41af791f
GB
6504@end cartouche
6505@noindent
6506The result of this attribute is an 8-digit hexadecimal string
6507representing the virtual address of the task control block.
6508
6509@sp 1
6510@cartouche
6511@noindent
6512@strong{87}. The value of @code{Current_Task} when in a protected entry
ad42149c 6513or interrupt handler. See C.7.1(17).
41af791f
GB
6514@end cartouche
6515@noindent
6516Protected entries or interrupt handlers can be executed by any
6517convenient thread, so the value of @code{Current_Task} is undefined.
6518
6519@sp 1
6520@cartouche
6521@noindent
6522@strong{88}. The effect of calling @code{Current_Task} from an entry
ad42149c 6523body or interrupt handler. See C.7.1(19).
41af791f
GB
6524@end cartouche
6525@noindent
6526The effect of calling @code{Current_Task} from an entry body or
6527interrupt handler is to return the identification of the task currently
6528executing the code.
6529
6530@sp 1
6531@cartouche
6532@noindent
6533@strong{89}. Implementation-defined aspects of
ad42149c 6534@code{Task_Attributes}. See C.7.2(19).
41af791f
GB
6535@end cartouche
6536@noindent
6537There are no implementation-defined aspects of @code{Task_Attributes}.
6538
6539@sp 1
6540@cartouche
6541@noindent
ad42149c 6542@strong{90}. Values of all @code{Metrics}. See D(2).
41af791f
GB
6543@end cartouche
6544@noindent
6545The metrics information for GNAT depends on the performance of the
ad42149c 6546underlying operating system. The sources of the run-time for tasking
41af791f
GB
6547implementation, together with the output from @code{-gnatG} can be
6548used to determine the exact sequence of operating systems calls made
ad42149c 6549to implement various tasking constructs. Together with appropriate
41af791f
GB
6550information on the performance of the underlying operating system,
6551on the exact target in use, this information can be used to determine
6552the required metrics.
6553
6554@sp 1
6555@cartouche
6556@noindent
6557@strong{91}. The declarations of @code{Any_Priority} and
ad42149c 6558@code{Priority}. See D.1(11).
41af791f
GB
6559@end cartouche
6560@noindent
6561See declarations in file @file{system.ads}.
6562
6563@sp 1
6564@cartouche
6565@noindent
ad42149c 6566@strong{92}. Implementation-defined execution resources. See D.1(15).
41af791f
GB
6567@end cartouche
6568@noindent
6569There are no implementation-defined execution resources.
6570
6571@sp 1
6572@cartouche
6573@noindent
6574@strong{93}. Whether, on a multiprocessor, a task that is waiting for
ad42149c 6575access to a protected object keeps its processor busy. See D.2.1(3).
41af791f
GB
6576@end cartouche
6577@noindent
6578On a multi-processor, a task that is waiting for access to a protected
6579object does not keep its processor busy.
6580
6581@sp 1
6582@cartouche
6583@noindent
6584@strong{94}. The affect of implementation defined execution resources
ad42149c 6585on task dispatching. See D.2.1(9).
41af791f
GB
6586@end cartouche
6587@noindent
6588@c SGI info
6589@ignore
6590Tasks map to IRIX threads, and the dispatching policy is as defined by
6591the IRIX implementation of threads.
6592@end ignore
ad42149c 6593Tasks map to threads in the threads package used by GNAT@. Where possible
41af791f
GB
6594and appropriate, these threads correspond to native threads of the
6595underlying operating system.
6596
6597@sp 1
6598@cartouche
6599@noindent
6600@strong{95}. Implementation-defined @code{policy_identifiers} allowed
ad42149c 6601in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
41af791f
GB
6602@end cartouche
6603@noindent
6604There are no implementation-defined policy-identifiers allowed in this
6605pragma.
6606
6607@sp 1
6608@cartouche
6609@noindent
ad42149c 6610@strong{96}. Implementation-defined aspects of priority inversion. See
41af791f
GB
6611D.2.2(16).
6612@end cartouche
6613@noindent
6614Execution of a task cannot be preempted by the implementation processing
6615of delay expirations for lower priority tasks.
6616
6617@sp 1
6618@cartouche
6619@noindent
ad42149c 6620@strong{97}. Implementation defined task dispatching. See D.2.2(18).
41af791f
GB
6621@end cartouche
6622@noindent
6623@c SGI info:
6624@ignore
6625Tasks map to IRIX threads, and the dispatching policy is as defied by
6626the IRIX implementation of threads.
6627@end ignore
6628The policy is the same as that of the underlying threads implementation.
6629
6630@sp 1
6631@cartouche
6632@noindent
6633@strong{98}. Implementation-defined @code{policy_identifiers} allowed
ad42149c 6634in a pragma @code{Locking_Policy}. See D.3(4).
41af791f
GB
6635@end cartouche
6636@noindent
6637The only implementation defined policy permitted in GNAT is
ad42149c 6638@code{Inheritance_Locking}. On targets that support this policy, locking
46b58b8c 6639is implemented by inheritance, i.e.@: the task owning the lock operates
41af791f
GB
6640at a priority equal to the highest priority of any task currently
6641requesting the lock.
6642
6643@sp 1
6644@cartouche
6645@noindent
ad42149c 6646@strong{99}. Default ceiling priorities. See D.3(10).
41af791f
GB
6647@end cartouche
6648@noindent
6649The ceiling priority of protected objects of the type
6650@code{System.Interrupt_Priority'Last} as described in the Ada 95
6651Reference Manual D.3(10),
6652
6653@sp 1
6654@cartouche
6655@noindent
6656@strong{100}. The ceiling of any protected object used internally by
ad42149c 6657the implementation. See D.3(16).
41af791f
GB
6658@end cartouche
6659@noindent
6660The ceiling priority of internal protected objects is
6661@code{System.Priority'Last}.
6662
6663@sp 1
6664@cartouche
6665@noindent
ad42149c 6666@strong{101}. Implementation-defined queuing policies. See D.4(1).
41af791f
GB
6667@end cartouche
6668@noindent
6669There are no implementation-defined queueing policies.
6670
6671@sp 1
6672@cartouche
6673@noindent
6674@strong{102}. On a multiprocessor, any conditions that cause the
6675completion of an aborted construct to be delayed later than what is
ad42149c 6676specified for a single processor. See D.6(3).
41af791f
GB
6677@end cartouche
6678@noindent
6679The semantics for abort on a multi-processor is the same as on a single
6680processor, there are no further delays.
6681
6682@sp 1
6683@cartouche
6684@noindent
6685@strong{103}. Any operations that implicitly require heap storage
ad42149c 6686allocation. See D.7(8).
41af791f
GB
6687@end cartouche
6688@noindent
6689The only operation that implicitly requires heap storage allocation is
6690task creation.
6691
6692@sp 1
6693@cartouche
6694@noindent
6695@strong{104}. Implementation-defined aspects of pragma
ad42149c 6696@code{Restrictions}. See D.7(20).
41af791f
GB
6697@end cartouche
6698@noindent
6699There are no such implementation-defined aspects.
6700
6701@sp 1
6702@cartouche
6703@noindent
6704@strong{105}. Implementation-defined aspects of package
ad42149c 6705@code{Real_Time}. See D.8(17).
41af791f
GB
6706@end cartouche
6707@noindent
6708There are no implementation defined aspects of package @code{Real_Time}.
6709
6710@sp 1
6711@cartouche
6712@noindent
6713@strong{106}. Implementation-defined aspects of
ad42149c 6714@code{delay_statements}. See D.9(8).
41af791f
GB
6715@end cartouche
6716@noindent
6717Any difference greater than one microsecond will cause the task to be
6718delayed (see D.9(7)).
6719
6720@sp 1
6721@cartouche
6722@noindent
6723@strong{107}. The upper bound on the duration of interrupt blocking
ad42149c 6724caused by the implementation. See D.12(5).
41af791f
GB
6725@end cartouche
6726@noindent
ad42149c 6727The upper bound is determined by the underlying operating system. In
41af791f
GB
6728no cases is it more than 10 milliseconds.
6729
6730@sp 1
6731@cartouche
6732@noindent
6733@strong{108}. The means for creating and executing distributed
ad42149c 6734programs. See E(5).
41af791f
GB
6735@end cartouche
6736@noindent
6737The GLADE package provides a utility GNATDIST for creating and executing
ad42149c 6738distributed programs. See the GLADE reference manual for further details.
41af791f
GB
6739
6740@sp 1
6741@cartouche
6742@noindent
6743@strong{109}. Any events that can result in a partition becoming
ad42149c 6744inaccessible. See E.1(7).
41af791f
GB
6745@end cartouche
6746@noindent
6747See the GLADE reference manual for full details on such events.
6748
6749@sp 1
6750@cartouche
6751@noindent
6752@strong{110}. The scheduling policies, treatment of priorities, and
ad42149c 6753management of shared resources between partitions in certain cases. See
41af791f
GB
6754E.1(11).
6755@end cartouche
6756@noindent
6757See the GLADE reference manual for full details on these aspects of
6758multi-partition execution.
6759
6760@sp 1
6761@cartouche
6762@noindent
6763@strong{111}. Events that cause the version of a compilation unit to
ad42149c 6764change. See E.3(5).
41af791f
GB
6765@end cartouche
6766@noindent
6767Editing the source file of a compilation unit, or the source files of
6768any units on which it is dependent in a significant way cause the version
ad42149c 6769to change. No other actions cause the version number to change. All changes
41af791f
GB
6770are significant except those which affect only layout, capitalization or
6771comments.
6772
6773@sp 1
6774@cartouche
6775@noindent
6776@strong{112}. Whether the execution of the remote subprogram is
ad42149c 6777immediately aborted as a result of cancellation. See E.4(13).
41af791f
GB
6778@end cartouche
6779@noindent
6780See the GLADE reference manual for details on the effect of abort in
6781a distributed application.
6782
6783@sp 1
6784@cartouche
6785@noindent
ad42149c 6786@strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
41af791f
GB
6787@end cartouche
6788@noindent
6789See the GLADE reference manual for a full description of all implementation
46b58b8c 6790defined aspects of the PCS@.
41af791f
GB
6791
6792@sp 1
6793@cartouche
6794@noindent
ad42149c 6795@strong{114}. Implementation-defined interfaces in the PCS@. See
41af791f
GB
6796E.5(26).
6797@end cartouche
6798@noindent
6799See the GLADE reference manual for a full description of all
6800implementation defined interfaces.
6801
6802@sp 1
6803@cartouche
6804@noindent
6805@strong{115}. The values of named numbers in the package
ad42149c 6806@code{Decimal}. See F.2(7).
41af791f
GB
6807@end cartouche
6808@noindent
6809@table @code
6810@item Max_Scale
6811+18
6812@item Min_Scale
6813-18
6814@item Min_Delta
68151.0E-18
6816@item Max_Delta
68171.0E+18
6818@item Max_Decimal_Digits
681918
6820@end table
6821
6822@sp 1
6823@cartouche
6824@noindent
6825@strong{116}. The value of @code{Max_Picture_Length} in the package
ad42149c 6826@code{Text_IO.Editing}. See F.3.3(16).
41af791f
GB
6827@end cartouche
6828@noindent
682964
6830
6831@sp 1
6832@cartouche
6833@noindent
6834@strong{117}. The value of @code{Max_Picture_Length} in the package
ad42149c 6835@code{Wide_Text_IO.Editing}. See F.3.4(5).
41af791f
GB
6836@end cartouche
6837@noindent
683864
6839
6840@sp 1
6841@cartouche
6842@noindent
6843@strong{118}. The accuracy actually achieved by the complex elementary
ad42149c 6844functions and by other complex arithmetic operations. See G.1(1).
41af791f
GB
6845@end cartouche
6846@noindent
6847Standard library functions are used for the complex arithmetic
ad42149c 6848operations. Only fast math mode is currently supported.
41af791f
GB
6849
6850@sp 1
6851@cartouche
6852@noindent
6853@strong{119}. The sign of a zero result (or a component thereof) from
6854any operator or function in @code{Numerics.Generic_Complex_Types}, when
ad42149c 6855@code{Real'Signed_Zeros} is True. See G.1.1(53).
41af791f
GB
6856@end cartouche
6857@noindent
6858The signs of zero values are as recommended by the relevant
6859implementation advice.
6860
6861@sp 1
6862@cartouche
6863@noindent
6864@strong{120}. The sign of a zero result (or a component thereof) from
6865any operator or function in
6866@code{Numerics.Generic_Complex_Elementary_Functions}, when
ad42149c 6867@code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
41af791f
GB
6868@end cartouche
6869@noindent
6870The signs of zero values are as recommended by the relevant
6871implementation advice.
6872
6873@sp 1
6874@cartouche
6875@noindent
6876@strong{121}. Whether the strict mode or the relaxed mode is the
ad42149c 6877default. See G.2(2).
41af791f
GB
6878@end cartouche
6879@noindent
ad42149c 6880The strict mode is the default. There is no separate relaxed mode. GNAT
41af791f
GB
6881provides a highly efficient implementation of strict mode.
6882
6883@sp 1
6884@cartouche
6885@noindent
6886@strong{122}. The result interval in certain cases of fixed-to-float
ad42149c 6887conversion. See G.2.1(10).
41af791f
GB
6888@end cartouche
6889@noindent
6890For cases where the result interval is implementation dependent, the
6891accuracy is that provided by performing all operations in 64-bit IEEE
6892floating-point format.
6893
6894@sp 1
6895@cartouche
6896@noindent
6897@strong{123}. The result of a floating point arithmetic operation in
6898overflow situations, when the @code{Machine_Overflows} attribute of the
ad42149c 6899result type is @code{False}. See G.2.1(13).
41af791f
GB
6900@end cartouche
6901@noindent
6902Infinite and Nan values are produced as dictated by the IEEE
6903floating-point standard.
6904
6905@sp 1
6906@cartouche
6907@noindent
6908@strong{124}. The result interval for division (or exponentiation by a
6909negative exponent), when the floating point hardware implements division
ad42149c 6910as multiplication by a reciprocal. See G.2.1(16).
41af791f
GB
6911@end cartouche
6912@noindent
6913Not relevant, division is IEEE exact.
6914
6915@sp 1
6916@cartouche
6917@noindent
6918@strong{125}. The definition of close result set, which determines the
ad42149c 6919accuracy of certain fixed point multiplications and divisions. See
41af791f
GB
6920G.2.3(5).
6921@end cartouche
6922@noindent
6923Operations in the close result set are performed using IEEE long format
ad42149c 6924floating-point arithmetic. The input operands are converted to
41af791f
GB
6925floating-point, the operation is done in floating-point, and the result
6926is converted to the target type.
6927
6928@sp 1
6929@cartouche
6930@noindent
6931@strong{126}. Conditions on a @code{universal_real} operand of a fixed
6932point multiplication or division for which the result shall be in the
ad42149c 6933perfect result set. See G.2.3(22).
41af791f
GB
6934@end cartouche
6935@noindent
6936The result is only defined to be in the perfect result set if the result
6937can be computed by a single scaling operation involving a scale factor
6938representable in 64-bits.
6939
6940@sp 1
6941@cartouche
6942@noindent
6943@strong{127}. The result of a fixed point arithmetic operation in
6944overflow situations, when the @code{Machine_Overflows} attribute of the
ad42149c 6945result type is @code{False}. See G.2.3(27).
41af791f
GB
6946@end cartouche
6947@noindent
6948Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
6949types.
6950
6951@sp 1
6952@cartouche
6953@noindent
6954@strong{128}. The result of an elementary function reference in
6955overflow situations, when the @code{Machine_Overflows} attribute of the
ad42149c 6956result type is @code{False}. See G.2.4(4).
41af791f
GB
6957@end cartouche
6958@noindent
6959IEEE infinite and Nan values are produced as appropriate.
6960
6961@sp 1
6962@cartouche
6963@noindent
6964@strong{129}. The value of the angle threshold, within which certain
6965elementary functions, complex arithmetic operations, and complex
6966elementary functions yield results conforming to a maximum relative
ad42149c 6967error bound. See G.2.4(10).
41af791f
GB
6968@end cartouche
6969@noindent
6970Information on this subject is not yet available.
6971
6972@sp 1
6973@cartouche
6974@noindent
6975@strong{130}. The accuracy of certain elementary functions for
ad42149c 6976parameters beyond the angle threshold. See G.2.4(10).
41af791f
GB
6977@end cartouche
6978@noindent
6979Information on this subject is not yet available.
6980
6981@sp 1
6982@cartouche
6983@noindent
6984@strong{131}. The result of a complex arithmetic operation or complex
6985elementary function reference in overflow situations, when the
6986@code{Machine_Overflows} attribute of the corresponding real type is
ad42149c 6987@code{False}. See G.2.6(5).
41af791f
GB
6988@end cartouche
6989@noindent
6990IEEE infinite and Nan values are produced as appropriate.
6991
6992@sp 1
6993@cartouche
6994@noindent
6995@strong{132}. The accuracy of certain complex arithmetic operations and
6996certain complex elementary functions for parameters (or components
ad42149c 6997thereof) beyond the angle threshold. See G.2.6(8).
41af791f
GB
6998@end cartouche
6999@noindent
7000Information on those subjects is not yet available.
7001
7002@sp 1
7003@cartouche
7004@noindent
7005@strong{133}. Information regarding bounded errors and erroneous
ad42149c 7006execution. See H.2(1).
41af791f
GB
7007@end cartouche
7008@noindent
7009Information on this subject is not yet available.
7010
7011@sp 1
7012@cartouche
7013@noindent
7014@strong{134}. Implementation-defined aspects of pragma
ad42149c 7015@code{Inspection_Point}. See H.3.2(8).
41af791f
GB
7016@end cartouche
7017@noindent
7018Pragma @code{Inspection_Point} ensures that the variable is live and can
7019be examined by the debugger at the inspection point.
7020
7021@sp 1
7022@cartouche
7023@noindent
7024@strong{135}. Implementation-defined aspects of pragma
ad42149c 7025@code{Restrictions}. See H.4(25).
41af791f
GB
7026@end cartouche
7027@noindent
ad42149c 7028There are no implementation-defined aspects of pragma @code{Restrictions}. The
41af791f 7029use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
ad42149c 7030generated code. Checks must suppressed by use of pragma @code{Suppress}.
41af791f
GB
7031
7032@sp 1
7033@cartouche
7034@noindent
ad42149c 7035@strong{136}. Any restrictions on pragma @code{Restrictions}. See
41af791f
GB
7036H.4(27).
7037@end cartouche
7038@noindent
7039There are no restrictions on pragma @code{Restrictions}.
7040
7041@node Intrinsic Subprograms
7042@chapter Intrinsic Subprograms
7043@cindex Intrinsic Subprograms
7044
7045@menu
7046* Intrinsic Operators::
7047* Enclosing_Entity::
7048* Exception_Information::
7049* Exception_Message::
7050* Exception_Name::
7051* File::
7052* Line::
7053* Rotate_Left::
7054* Rotate_Right::
7055* Shift_Left::
7056* Shift_Right::
7057* Shift_Right_Arithmetic::
7058* Source_Location::
7059@end menu
7060
7061GNAT allows a user application program to write the declaration:
7062
7063@smallexample
7064 pragma Import (Intrinsic, name);
7065@end smallexample
7066
7067@noindent
7068providing that the name corresponds to one of the implemented intrinsic
7069subprograms in GNAT, and that the parameter profile of the referenced
ad42149c 7070subprogram meets the requirements. This chapter describes the set of
41af791f
GB
7071implemented intrinsic subprograms, and the requirements on parameter profiles.
7072Note that no body is supplied; as with other uses of pragma Import, the
ad42149c 7073body is supplied elsewhere (in this case by the compiler itself). Note
41af791f
GB
7074that any use of this feature is potentially non-portable, since the
7075Ada standard does not require Ada compilers to implement this feature.
7076
7077@node Intrinsic Operators
7078@section Intrinsic Operators
7079@cindex Intrinsic operator
7080
7081@noindent
ad42149c
FW
7082All the predefined numeric operators in package Standard
7083in @code{pragma Import (Intrinsic,..)}
7084declarations. In the binary operator case, the operands must have the same
7085size. The operand or operands must also be appropriate for
7086the operator. For example, for addition, the operands must
7087both be floating-point or both be fixed-point, and the
7088right operand for @code{"**"} must have a root type of
7089@code{Standard.Integer'Base}.
7090You can use an intrinsic operator declaration as in the following example:
41af791f
GB
7091
7092@smallexample
7093 type Int1 is new Integer;
7094 type Int2 is new Integer;
7095
7096 function "+" (X1 : Int1; X2 : Int2) return Int1;
7097 function "+" (X1 : Int1; X2 : Int2) return Int2;
7098 pragma Import (Intrinsic, "+");
7099@end smallexample
7100
7101@noindent
ad42149c
FW
7102This declaration would permit ``mixed mode'' arithmetic on items
7103of the differing types @code{Int1} and @code{Int2}.
7104It is also possible to specify such operators for private types, if the
7105full views are appropriate arithmetic types.
41af791f
GB
7106
7107@node Enclosing_Entity
7108@section Enclosing_Entity
7109@cindex Enclosing_Entity
7110@noindent
7111This intrinsic subprogram is used in the implementation of the
ad42149c 7112library routine @code{GNAT.Source_Info}. The only useful use of the
41af791f
GB
7113intrinsic import in this case is the one in this unit, so an
7114application program should simply call the function
7115@code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
7116the current subprogram, package, task, entry, or protected subprogram.
7117
7118@node Exception_Information
7119@section Exception_Information
7120@cindex Exception_Information'
7121@noindent
7122This intrinsic subprogram is used in the implementation of the
ad42149c 7123library routine @code{GNAT.Current_Exception}. The only useful
41af791f
GB
7124use of the intrinsic import in this case is the one in this unit,
7125so an application program should simply call the function
7126@code{GNAT.Current_Exception.Exception_Information} to obtain
7127the exception information associated with the current exception.
7128
7129@node Exception_Message
7130@section Exception_Message
7131@cindex Exception_Message
7132@noindent
7133This intrinsic subprogram is used in the implementation of the
ad42149c 7134library routine @code{GNAT.Current_Exception}. The only useful
41af791f
GB
7135use of the intrinsic import in this case is the one in this unit,
7136so an application program should simply call the function
7137@code{GNAT.Current_Exception.Exception_Message} to obtain
7138the message associated with the current exception.
7139
7140@node Exception_Name
7141@section Exception_Name
7142@cindex Exception_Name
7143@noindent
7144This intrinsic subprogram is used in the implementation of the
ad42149c 7145library routine @code{GNAT.Current_Exception}. The only useful
41af791f
GB
7146use of the intrinsic import in this case is the one in this unit,
7147so an application program should simply call the function
7148@code{GNAT.Current_Exception.Exception_Name} to obtain
7149the name of the current exception.
7150
7151@node File
7152@section File
7153@cindex File
7154@noindent
7155This intrinsic subprogram is used in the implementation of the
ad42149c 7156library routine @code{GNAT.Source_Info}. The only useful use of the
41af791f
GB
7157intrinsic import in this case is the one in this unit, so an
7158application program should simply call the function
7159@code{GNAT.Source_Info.File} to obtain the name of the current
7160file.
7161
7162@node Line
7163@section Line
7164@cindex Line
7165@noindent
7166This intrinsic subprogram is used in the implementation of the
ad42149c 7167library routine @code{GNAT.Source_Info}. The only useful use of the
41af791f
GB
7168intrinsic import in this case is the one in this unit, so an
7169application program should simply call the function
7170@code{GNAT.Source_Info.Line} to obtain the number of the current
7171source line.
7172
7173@node Rotate_Left
7174@section Rotate_Left
7175@cindex Rotate_Left
7176@noindent
7177In standard Ada 95, the @code{Rotate_Left} function is available only
ad42149c 7178for the predefined modular types in package @code{Interfaces}. However, in
41af791f
GB
7179GNAT it is possible to define a Rotate_Left function for a user
7180defined modular type or any signed integer type as in this example:
7181
7182@smallexample
7183 function Shift_Left
7184 (Value : My_Modular_Type;
7185 Amount : Natural)
7186 return My_Modular_Type;
7187@end smallexample
7188
7189@noindent
7190The requirements are that the profile be exactly as in the example
ad42149c 7191above. The only modifications allowed are in the formal parameter
41af791f
GB
7192names, and in the type of @code{Value} and the return type, which
7193must be the same, and must be either a signed integer type, or
7194a modular integer type with a binary modulus, and the size must
ad42149c 7195be 8. 16, 32 or 64 bits.
41af791f
GB
7196
7197@node Rotate_Right
7198@section Rotate_Right
7199@cindex Rotate_Right
7200@noindent
7201A @code{Rotate_Right} function can be defined for any user defined
7202binary modular integer type, or signed integer type, as described
7203above for @code{Rotate_Left}.
7204
7205@node Shift_Left
7206@section Shift_Left
7207@cindex Shift_Left
7208@noindent
7209A @code{Shift_Left} function can be defined for any user defined
7210binary modular integer type, or signed integer type, as described
7211above for @code{Rotate_Left}.
7212
7213@node Shift_Right
7214@section Shift_Right
7215@cindex Shift_Right
7216@noindent
7217A @code{Shift_Right} function can be defined for any user defined
7218binary modular integer type, or signed integer type, as described
7219above for @code{Rotate_Left}.
7220
7221@node Shift_Right_Arithmetic
7222@section Shift_Right_Arithmetic
7223@cindex Shift_Right_Arithmetic
7224@noindent
7225A @code{Shift_Right_Arithmetic} function can be defined for any user
7226defined binary modular integer type, or signed integer type, as described
7227above for @code{Rotate_Left}.
7228
7229@node Source_Location
7230@section Source_Location
7231@cindex Source_Location
7232@noindent
7233This intrinsic subprogram is used in the implementation of the
ad42149c 7234library routine @code{GNAT.Source_Info}. The only useful use of the
41af791f
GB
7235intrinsic import in this case is the one in this unit, so an
7236application program should simply call the function
7237@code{GNAT.Source_Info.Source_Location} to obtain the current
7238source file location.
7239
7240@node Representation Clauses and Pragmas
7241@chapter Representation Clauses and Pragmas
7242@cindex Representation Clauses
7243
7244@menu
7245* Alignment Clauses::
7246* Size Clauses::
7247* Storage_Size Clauses::
7248* Size of Variant Record Objects::
7249* Biased Representation ::
7250* Value_Size and Object_Size Clauses::
7251* Component_Size Clauses::
7252* Bit_Order Clauses::
7253* Effect of Bit_Order on Byte Ordering::
7254* Pragma Pack for Arrays::
7255* Pragma Pack for Records::
7256* Record Representation Clauses::
7257* Enumeration Clauses::
7258* Address Clauses::
7259* Effect of Convention on Representation::
7260* Determining the Representations chosen by GNAT::
7261@end menu
7262
7263@noindent
7264@cindex Representation Clause
7265@cindex Representation Pragma
7266@cindex Pragma, representation
7267This section describes the representation clauses accepted by GNAT, and
7268their effect on the representation of corresponding data objects.
7269
ad42149c 7270GNAT fully implements Annex C (Systems Programming). This means that all
41af791f
GB
7271the implementation advice sections in chapter 13 are fully implemented.
7272However, these sections only require a minimal level of support for
ad42149c 7273representation clauses. GNAT provides much more extensive capabilities,
41af791f
GB
7274and this section describes the additional capabilities provided.
7275
7276@node Alignment Clauses
7277@section Alignment Clauses
7278@cindex Alignment Clause
7279
7280@noindent
7281GNAT requires that all alignment clauses specify a power of 2, and all
ad42149c 7282default alignments are always a power of 2. The default alignment
41af791f
GB
7283values are as follows:
7284
7285@itemize @bullet
7286@item Primitive Types
7287For primitive types, the alignment is the maximum of the actual size of
7288objects of the type, and the maximum alignment supported by the target.
7289For example, for type Long_Float, the object size is 8 bytes, and the
7290default alignment will be 8 on any target that supports alignments
7291this large, but on some targets, the maximum alignment may be smaller
7292than 8, in which case objects of type Long_Float will be maximally
7293aligned.
7294
7295@item Arrays
7296For arrays, the alignment is equal to the alignment of the component type
ad42149c 7297for the normal case where no packing or component size is given. If the
41af791f
GB
7298array is packed, and the packing is effective (see separate section on
7299packed arrays), then the alignment will be one for long packed arrays,
ad42149c 7300or arrays whose length is not known at compile time. For short packed
41af791f 7301arrays, which are handled internally as modular types, the alignment
46b58b8c 7302will be as described for primitive types, e.g.@: a packed array of length
41af791f
GB
730331 bits will have an object size of four bytes, and an alignment of 4.
7304
7305@item Records
7306For the normal non-packed case, the alignment of a record is equal to
ad42149c
FW
7307the maximum alignment of any of its components. For tagged records, this
7308includes the implicit access type used for the tag. If a pragma @code{Pack} is
7309used and all fields are packable (see separate section on pragma @code{Pack}),
41af791f
GB
7310then the resulting alignment is 1.
7311
ad42149c
FW
7312A special case is when the size of the record is given explicitly, or a
7313full record representation clause is given, and the size of the record
7314is 2, 4, or 8 bytes. In this case, an alignment is chosen to match the
7315size of the record. For example, if we have:
7316
7317@smallexample
7318 type Small is record
7319 A, B : Character;
7320 end record;
7321@end smallexample
7322
7323@noindent
7324then the default alignment of the record type @code{Small} is 2, not 1. This
7325leads to more efficient code when the record is treated as a unit, and also
7326allows the type to specified as @code{Atomic} on architectures requiring
7327strict alignment.
7328
41af791f
GB
7329@end itemize
7330
7331@noindent
7332An alignment clause may
7333always specify a larger alignment than the default value, up to some
7334maximum value dependent on the target (obtainable by using the
ad42149c 7335attribute reference System'Maximum_Alignment). The only case in which
41af791f
GB
7336it is permissible to specify a smaller alignment than the default value
7337is in the case of a record for which a record representation clause is
ad42149c 7338given. In this case, packable fields for which a component clause is
41af791f
GB
7339given still result in a default alignment corresponding to the original
7340type, but this may be overridden, since these components in fact only
ad42149c 7341require an alignment of one byte. For example, given
41af791f
GB
7342
7343@smallexample
7344 type v is record
7345 a : integer;
7346 end record;
7347
7348 for v use record
7349 a at 0 range 0 .. 31;
7350 end record;
7351
7352 for v'alignment use 1;
7353@end smallexample
7354
7355@noindent
7356@cindex Alignment, default
7357The default alignment for the type @code{v} is 4, as a result of the
7358integer field in the record, but since this field is placed with a
7359component clause, it is permissible, as shown, to override the default
7360alignment of the record to a smaller value.
7361
7362@node Size Clauses
7363@section Size Clauses
7364@cindex Size Clause
7365
7366@noindent
ad42149c 7367The default size of types is as specified in the reference manual. For
41af791f
GB
7368objects, GNAT will generally increase the type size so that the object
7369size is a multiple of storage units, and also a multiple of the
ad42149c 7370alignment. For example
41af791f
GB
7371
7372@smallexample
7373 type Smallint is range 1 .. 6;
7374
7375 type Rec is record
7376 y1 : integer;
7377 y2 : boolean;
7378 end record;
7379@end smallexample
7380
7381@noindent
7382In this example, @code{Smallint}
7383has a size of 3, as specified by the RM rules,
7384but objects of this type will have a size of 8,
7385since objects by default occupy an integral number
ad42149c 7386of storage units. On some targets, notably older
41af791f
GB
7387versions of the Digital Alpha, the size of stand
7388alone objects of this type may be 32, reflecting
7389the inability of the hardware to do byte load/stores.
7390
7391Similarly, the size of type @code{Rec} is 40 bits, but
7392the alignment is 4, so objects of this type will have
7393their size increased to 64 bits so that it is a multiple
ad42149c 7394of the alignment. The reason for this decision, which is
41af791f
GB
7395in accordance with the specific note in RM 13.3(43):
7396
7397@smallexample
7398A Size clause should be supported for an object if the specified
7399Size is at least as large as its subtype's Size, and corresponds
7400to a size in storage elements that is a multiple of the object's
7401Alignment (if the Alignment is nonzero).
7402@end smallexample
7403
7404@noindent
7405An explicit size clause may be used to override the default size by
ad42149c 7406increasing it. For example, if we have:
41af791f
GB
7407
7408@smallexample
7409 type My_Boolean is new Boolean;
7410 for My_Boolean'Size use 32;
7411@end smallexample
7412
7413@noindent
ad42149c 7414then objects of this type will always be 32 bits long. In the case of
41af791f
GB
7415discrete types, the size can be increased up to 64 bits, with the effect
7416that the entire specified field is used to hold the value, sign- or
ad42149c 7417zero-extended as appropriate. If more than 64 bits is specified, then
41af791f
GB
7418padding space is allocated after the value, and a warning is issued that
7419there are unused bits.
7420
7421Similarly the size of records and arrays may be increased, and the effect
ad42149c 7422is to add padding bits after the value. This also causes a warning message
41af791f
GB
7423to be generated.
7424
ad42149c 7425The largest Size value permitted in GNAT is 2**32@minus{}1. Since this is a
41af791f 7426Size in bits, this corresponds to an object of size 256 megabytes (minus
ad42149c 7427one). This limitation is true on all targets. The reason for this
41af791f
GB
7428limitation is that it improves the quality of the code in many cases
7429if it is known that a Size value can be accommodated in an object of
7430type Integer.
7431
7432@node Storage_Size Clauses
7433@section Storage_Size Clauses
7434@cindex Storage_Size Clause
7435
7436@noindent
7437For tasks, the @code{Storage_Size} clause specifies the amount of space
ad42149c 7438to be allocated for the task stack. This cannot be extended, and if the
41af791f 7439stack is exhausted, then @code{Storage_Error} will be raised if stack
ad42149c 7440checking is enabled. If the default size of 20K bytes is insufficient,
41af791f
GB
7441then you need to use a @code{Storage_Size} attribute definition clause,
7442or a @code{Storage_Size} pragma in the task definition to set the
ad42149c 7443appropriate required size. A useful technique is to include in every
41af791f
GB
7444task definition a pragma of the form:
7445
7446@smallexample
7447 pragma Storage_Size (Default_Stack_Size);
7448@end smallexample
7449
7450@noindent
7451Then Default_Stack_Size can be defined in a global package, and modified
ad42149c 7452as required. Any tasks requiring different task stack sizes from the
41af791f
GB
7453default can have an appropriate alternative reference in the pragma.
7454
7455For access types, the @code{Storage_Size} clause specifies the maximum
ad42149c 7456space available for allocation of objects of the type. If this space is
41af791f
GB
7457exceeded then @code{Storage_Error} will be raised by an allocation attempt.
7458In the case where the access type is declared local to a subprogram, the
7459use of a @code{Storage_Size} clause triggers automatic use of a special
7460predefined storage pool (@code{System.Pool_Size}) that ensures that all
7461space for the pool is automatically reclaimed on exit from the scope in
7462which the type is declared.
7463
7464A special case recognized by the compiler is the specification of a
ad42149c 7465@code{Storage_Size} of zero for an access type. This means that no
41af791f
GB
7466items can be allocated from the pool, and this is recognized at compile
7467time, and all the overhead normally associated with maintaining a fixed
ad42149c 7468size storage pool is eliminated. Consider the following example:
41af791f
GB
7469
7470@smallexample
7471 procedure p is
7472 type R is array (Natural) of Character;
7473 type P is access all R;
7474 for P'Storage_Size use 0;
7475 -- Above access type intended only for interfacing purposes
7476
7477 y : P;
7478
7479 procedure g (m : P);
7480 pragma Import (C, g);
7481
ad42149c 7482 -- @dots{}
41af791f
GB
7483
7484 begin
ad42149c 7485 -- @dots{}
41af791f
GB
7486 y := new R;
7487 end;
7488@end smallexample
7489
7490@noindent
7491As indicated in this example, these dummy storage pools are often useful in
ad42149c 7492connection with interfacing where no object will ever be allocated. If you
41af791f
GB
7493compile the above example, you get the warning:
7494
7495@smallexample
7496 p.adb:16:09: warning: allocation from empty storage pool
7497 p.adb:16:09: warning: Storage_Error will be raised at run time
7498@end smallexample
7499
7500@noindent
7501Of course in practice, there will not be any explicit allocators in the
7502case of such an access declaration.
7503
7504@node Size of Variant Record Objects
7505@section Size of Variant Record Objects
7506@cindex Size, variant record objects
7507@cindex Variant record objects, size
7508
7509@noindent
7510An issue arises in the case of variant record objects of whether Size gives
7511information about a particular variant, or the maximum size required
ad42149c 7512for any variant. Consider the following program
41af791f
GB
7513
7514@smallexample
7515with Text_IO; use Text_IO;
7516procedure q is
7517 type R1 (A : Boolean := False) is record
7518 case A is
7519 when True => X : Character;
7520 when False => null;
7521 end case;
7522 end record;
7523
7524 V1 : R1 (False);
7525 V2 : R1;
7526
7527begin
7528 Put_Line (Integer'Image (V1'Size));
7529 Put_Line (Integer'Image (V2'Size));
7530end q;
7531@end smallexample
7532
7533@noindent
7534Here we are dealing with a variant record, where the True variant
7535requires 16 bits, and the False variant requires 8 bits.
7536In the above example, both V1 and V2 contain the False variant,
ad42149c 7537which is only 8 bits long. However, the result of running the
41af791f
GB
7538program is:
7539
7540@smallexample
75418
754216
7543@end smallexample
7544
7545@noindent
7546The reason for the difference here is that the discriminant value of
ad42149c
FW
7547V1 is fixed, and will always be False. It is not possible to assign
7548a True variant value to V1, therefore 8 bits is sufficient. On the
41af791f
GB
7549other hand, in the case of V2, the initial discriminant value is
7550False (from the default), but it is possible to assign a True
7551variant value to V2, therefore 16 bits must be allocated for V2
7552in the general case, even fewer bits may be needed at any particular
7553point during the program execution.
7554
7555As can be seen from the output of this program, the @code{'Size}
7556attribute applied to such an object in GNAT gives the actual allocated
7557size of the variable, which is the largest size of any of the variants.
7558The Ada Reference Manual is not completely clear on what choice should
7559be made here, but the GNAT behavior seems most consistent with the
46b58b8c 7560language in the RM@.
41af791f
GB
7561
7562In some cases, it may be desirable to obtain the size of the current
ad42149c 7563variant, rather than the size of the largest variant. This can be
41af791f
GB
7564achieved in GNAT by making use of the fact that in the case of a
7565subprogram parameter, GNAT does indeed return the size of the current
7566variant (because a subprogram has no way of knowing how much space
7567is actually allocated for the actual).
7568
7569Consider the following modified version of the above program:
7570
7571@smallexample
7572with Text_IO; use Text_IO;
7573procedure q is
7574 type R1 (A : Boolean := False) is record
7575 case A is
7576 when True => X : Character;
7577 when False => null;
7578 end case;
7579 end record;
7580
7581 V2 : R1;
7582
7583 function Size (V : R1) return Integer is
7584 begin
7585 return V'Size;
7586 end Size;
7587
7588begin
7589 Put_Line (Integer'Image (V2'Size));
7590 Put_Line (Integer'IMage (Size (V2)));
7591 V2 := (True, 'x');
7592 Put_Line (Integer'Image (V2'Size));
7593 Put_Line (Integer'IMage (Size (V2)));
7594end q;
7595@end smallexample
7596
7597@noindent
7598The output from this program is
7599
7600@smallexample
760116
76028
760316
760416
7605@end smallexample
7606
7607@noindent
7608Here we see that while the @code{'Size} attribute always returns
7609the maximum size, regardless of the current variant value, the
7610@code{Size} function does indeed return the size of the current
7611variant value.
7612
7613@node Biased Representation
7614@section Biased Representation
7615@cindex Size for biased representation
7616@cindex Biased representation
7617
7618@noindent
7619In the case of scalars with a range starting at other than zero, it is
7620possible in some cases to specify a size smaller than the default minimum
ad42149c 7621value, and in such cases, GNAT uses an unsigned biased representation,
41af791f
GB
7622in which zero is used to represent the lower bound, and successive values
7623represent successive values of the type.
7624
7625For example, suppose we have the declaration:
7626
7627@smallexample
7628 type Small is range -7 .. -4;
7629 for Small'Size use 2;
7630@end smallexample
7631
7632@noindent
7633Although the default size of type @code{Small} is 4, the @code{Size}
7634clause is accepted by GNAT and results in the following representation
7635scheme:
7636
7637@smallexample
7638 -7 is represented as 2#00#
7639 -6 is represented as 2#01#
7640 -5 is represented as 2#10#
7641 -4 is represented as 2#11#
7642@end smallexample
7643
7644@noindent
7645Biased representation is only used if the specified @code{Size} clause
ad42149c 7646cannot be accepted in any other manner. These reduced sizes that force
41af791f
GB
7647biased representation can be used for all discrete types except for
7648enumeration types for which a representation clause is given.
7649
7650@node Value_Size and Object_Size Clauses
7651@section Value_Size and Object_Size Clauses
7652@findex Value_Size
7653@findex Object_Size
7654@cindex Size, of objects
7655
7656@noindent
7657In Ada 95, the @code{Size} of a discrete type is the minimum number of bits
ad42149c 7658required to hold values of the type. Although this interpretation was
41af791f 7659allowed in Ada 83, it was not required, and this requirement in practice
ad42149c
FW
7660can cause some significant difficulties. For example, in most Ada 83
7661compilers, @code{Natural'Size} was 32. However, in Ada-95,
41af791f 7662@code{Natural'Size} is
ad42149c
FW
7663typically 31. This means that code may change in behavior when moving
7664from Ada 83 to Ada 95. For example, consider:
41af791f
GB
7665
7666@smallexample
7667 type Rec is record;
7668 A : Natural;
7669 B : Natural;
7670 end record;
7671
7672 for Rec use record
7673 for A use at 0 range 0 .. Natural'Size - 1;
7674 for B use at 0 range Natural'Size .. 2 * Natural'Size - 1;
7675 end record;
7676@end smallexample
7677
7678@noindent
7679In the above code, since the typical size of @code{Natural} objects
7680is 32 bits and @code{Natural'Size} is 31, the above code can cause
7681unexpected inefficient packing in Ada 95, and in general there are
7682surprising cases where the fact that the object size can exceed the
7683size of the type causes surprises.
7684
7685To help get around this problem GNAT provides two implementation
ad42149c 7686dependent attributes @code{Value_Size} and @code{Object_Size}. When
41af791f
GB
7687applied to a type, these attributes yield the size of the type
7688(corresponding to the RM defined size attribute), and the size of
7689objects of the type respectively.
7690
7691The @code{Object_Size} is used for determining the default size of
ad42149c
FW
7692objects and components. This size value can be referred to using the
7693@code{Object_Size} attribute. The phrase ``is used'' here means that it is
7694the basis of the determination of the size. The backend is free to
46b58b8c 7695pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
41af791f
GB
7696character might be stored in 32 bits on a machine with no efficient
7697byte access instructions such as the Alpha.
7698
7699The default rules for the value of @code{Object_Size} for fixed-point and
7700discrete types are as follows:
7701
7702@itemize @bullet
7703@item
7704The @code{Object_Size} for base subtypes reflect the natural hardware
ad42149c
FW
7705size in bits (run the utility @code{gnatpsta} to find those values for numeric types).
7706Enumeration types and fixed-point base subtypes have 8, 16, 32 or 64
41af791f
GB
7707bits for this size, depending on the range of values to be stored.
7708
7709@item
7710The @code{Object_Size} of a subtype is the same as the
7711@code{Object_Size} of
7712the type from which it is obtained.
7713
7714@item
7715The @code{Object_Size} of a derived base type is copied from the parent
7716base type, and the @code{Object_Size} of a derived first subtype is copied
7717from the parent first subtype.
7718@end itemize
7719
7720@noindent
7721The @code{Value_Size} attribute
7722is the number of bits required to store a value
ad42149c
FW
7723of the type. This size can be referred to using the @code{Value_Size}
7724attribute. This value is used to determine how tightly to pack
41af791f
GB
7725records or arrays with components of this type, and also affects
7726the semantics of unchecked conversion (unchecked conversions where
7727the @code{Value_Size} values differ generate a warning, and are potentially
7728target dependent).
7729
7730The default rules for the value of @code{Value_Size} are as follows:
7731
7732@itemize @bullet
7733@item
7734The @code{Value_Size} for a base subtype is the minimum number of bits
7735required to store all values of the type (including the sign bit
7736only if negative values are possible).
7737
7738@item
7739If a subtype statically matches the first subtype of a given type, then it has
ad42149c
FW
7740by default the same @code{Value_Size} as the first subtype. This is a
7741consequence of RM 13.1(14) (``if two subtypes statically match,
7742then their subtype-specific aspects are the same''.)
41af791f
GB
7743
7744@item
7745All other subtypes have a @code{Value_Size} corresponding to the minimum
ad42149c 7746number of bits required to store all values of the subtype. For
41af791f
GB
7747dynamic bounds, it is assumed that the value can range down or up
7748to the corresponding bound of the ancestor
7749@end itemize
7750
7751@noindent
7752The RM defined attribute @code{Size} corresponds to the
7753@code{Value_Size} attribute.
7754
ad42149c 7755The @code{Size} attribute may be defined for a first-named subtype. This sets
41af791f
GB
7756the @code{Value_Size} of
7757the first-named subtype to the given value, and the
7758@code{Object_Size} of this first-named subtype to the given value padded up
ad42149c
FW
7759to an appropriate boundary. It is a consequence of the default rules
7760above that this @code{Object_Size} will apply to all further subtypes. On the
41af791f
GB
7761other hand, @code{Value_Size} is affected only for the first subtype, any
7762dynamic subtypes obtained from it directly, and any statically matching
ad42149c 7763subtypes. The @code{Value_Size} of any other static subtypes is not affected.
41af791f
GB
7764
7765@code{Value_Size} and
7766@code{Object_Size} may be explicitly set for any subtype using
ad42149c
FW
7767an attribute definition clause. Note that the use of these attributes
7768can cause the RM 13.1(14) rule to be violated. If two access types
41af791f
GB
7769reference aliased objects whose subtypes have differing @code{Object_Size}
7770values as a result of explicit attribute definition clauses, then it
7771is erroneous to convert from one access subtype to the other.
7772
7773At the implementation level, Esize stores the Object_SIze and the
7774RM_Size field stores the @code{Value_Size} (and hence the value of the
7775@code{Size} attribute,
7776which, as noted above, is equivalent to @code{Value_Size}).
7777
7778To get a feel for the difference, consider the following examples (note
7779that in each case the base is short_short_integer with a size of 8):
7780
7781@smallexample
7782 Object_Size Value_Size
7783
ad42149c 7784type x1 is range 0 .. 5; 8 3
41af791f 7785
ad42149c 7786type x2 is range 0 .. 5;
41af791f
GB
7787for x2'size use 12; 12 12
7788
7789subtype x3 is x2 range 0 .. 3; 12 2
7790
7791subtype x4 is x2'base range 0 .. 10; 8 4
7792
7793subtype x5 is x2 range 0 .. dynamic; 12 (7)
7794
7795subtype x6 is x2'base range 0 .. dynamic; 8 (7)
7796
7797@end smallexample
7798
7799@noindent
7800Note: the entries marked (7) are not actually specified by the Ada 95 RM,
7801but it seems in the spirit of the RM rules to allocate the minimum number
7802of bits known to be large enough to hold the given range of values.
7803
7804So far, so good, but GNAT has to obey the RM rules, so the question is
7805under what conditions must the RM @code{Size} be used.
7806The following is a list
7807of the occasions on which the RM @code{Size} must be used:
7808
7809@itemize @bullet
7810@item
7811Component size for packed arrays or records
7812
7813@item
7814Value of the attribute @code{Size} for a type
7815
7816@item
7817Warning about sizes not matching for unchecked conversion
7818@end itemize
7819
7820@noindent
7821For types other than discrete and fixed-point types, the @code{Object_Size}
7822and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
7823Only @code{Size} may be specified for such types.
7824
7825@node Component_Size Clauses
7826@section Component_Size Clauses
7827@cindex Component_Size Clause
7828
7829@noindent
7830Normally, the value specified in a component clause must be consistent
7831with the subtype of the array component with regard to size and alignment.
7832In other words, the value specified must be at least equal to the size
7833of this subtype, and must be a multiple of the alignment value.
7834
7835In addition, component size clauses are allowed which cause the array
ad42149c
FW
7836to be packed, by specifying a smaller value. The cases in which this
7837is allowed are for component size values in the range 1 through 63. The value
7838specified must not be smaller than the Size of the subtype. GNAT will
7839accurately honor all packing requests in this range. For example, if
41af791f
GB
7840we have:
7841
7842@smallexample
7843type r is array (1 .. 8) of Natural;
7844for r'Size use 31;
7845@end smallexample
7846
7847@noindent
7848then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
7849Of course access to the components of such an array is considerably
7850less efficient than if the natural component size of 32 is used.
7851
7852@node Bit_Order Clauses
7853@section Bit_Order Clauses
7854@cindex Bit_Order Clause
7855@cindex bit ordering
7856@cindex ordering, of bits
7857
7858@noindent
7859For record subtypes, GNAT permits the specification of the @code{Bit_Order}
ad42149c 7860attribute. The specification may either correspond to the default bit
41af791f
GB
7861order for the target, in which case the specification has no effect and
7862places no additional restrictions, or it may be for the non-standard
7863setting (that is the opposite of the default).
7864
7865In the case where the non-standard value is specified, the effect is
7866to renumber bits within each byte, but the ordering of bytes is not
ad42149c 7867affected. There are certain
41af791f
GB
7868restrictions placed on component clauses as follows:
7869
7870@itemize @bullet
7871
7872@item Components fitting within a single storage unit.
7873@noindent
ad42149c 7874These are unrestricted, and the effect is merely to renumber bits. For
41af791f
GB
7875example if we are on a little-endian machine with @code{Low_Order_First}
7876being the default, then the following two declarations have exactly
7877the same effect:
7878
7879@smallexample
7880 type R1 is record
7881 A : Boolean;
7882 B : Integer range 1 .. 120;
7883 end record;
7884
7885 for R1 use record
7886 A at 0 range 0 .. 0;
7887 B at 0 range 1 .. 7;
7888 end record;
7889
7890 type R2 is record
7891 A : Boolean;
7892 B : Integer range 1 .. 120;
7893 end record;
7894
7895 for R2'Bit_Order use High_Order_First;
7896
7897 for R2 use record
7898 A at 0 range 7 .. 7;
7899 B at 0 range 0 .. 6;
7900 end record;
7901@end smallexample
7902
7903@noindent
7904The useful application here is to write the second declaration with the
7905@code{Bit_Order} attribute definition clause, and know that it will be treated
7906the same, regardless of whether the target is little-endian or big-endian.
7907
7908@item Components occupying an integral number of bytes.
7909@noindent
ad42149c 7910These are components that exactly fit in two or more bytes. Such component
41af791f
GB
7911declarations are allowed, but have no effect, since it is important to realize
7912that the @code{Bit_Order} specification does not affect the ordering of bytes.
7913In particular, the following attempt at getting an endian-independent integer
7914does not work:
7915
7916@smallexample
7917 type R2 is record
7918 A : Integer;
7919 end record;
7920
7921 for R2'Bit_Order use High_Order_First;
7922
7923 for R2 use record
7924 A at 0 range 0 .. 31;
7925 end record;
7926@end smallexample
7927
7928@noindent
7929This declaration will result in a little-endian integer on a
7930little-endian machine, and a big-endian integer on a big-endian machine.
7931If byte flipping is required for interoperability between big- and
ad42149c 7932little-endian machines, this must be explicitly programmed. This capability
41af791f
GB
7933is not provided by @code{Bit_Order}.
7934
7935@item Components that are positioned across byte boundaries
7936@noindent
ad42149c 7937but do not occupy an integral number of bytes. Given that bytes are not
41af791f 7938reordered, such fields would occupy a non-contiguous sequence of bits
ad42149c 7939in memory, requiring non-trivial code to reassemble. They are for this
41af791f 7940reason not permitted, and any component clause specifying such a layout
46b58b8c 7941will be flagged as illegal by GNAT@.
41af791f
GB
7942
7943@end itemize
7944
7945@noindent
7946Since the misconception that Bit_Order automatically deals with all
7947endian-related incompatibilities is a common one, the specification of
7948a component field that is an integral number of bytes will always
ad42149c
FW
7949generate a warning. This warning may be suppressed using
7950@code{pragma Suppress} if desired. The following section contains additional
41af791f
GB
7951details regarding the issue of byte ordering.
7952
7953@node Effect of Bit_Order on Byte Ordering
7954@section Effect of Bit_Order on Byte Ordering
7955@cindex byte ordering
7956@cindex ordering, of bytes
7957
7958@noindent
3a77b68d 7959In this section we will review the effect of the @code{Bit_Order} attribute
ad42149c
FW
7960definition clause on byte ordering. Briefly, it has no effect at all, but
7961a detailed example will be helpful. Before giving this
41af791f 7962example, let us review the precise
ad42149c 7963definition of the effect of defining @code{Bit_Order}. The effect of a
41af791f
GB
7964non-standard bit order is described in section 15.5.3 of the Ada
7965Reference Manual:
7966
7967@smallexample
79682 A bit ordering is a method of interpreting the meaning of
7969the storage place attributes.
7970@end smallexample
7971
7972@noindent
7973To understand the precise definition of storage place attributes in
7974this context, we visit section 13.5.1 of the manual:
7975
7976@smallexample
797713 A record_representation_clause (without the mod_clause)
ad42149c 7978specifies the layout. The storage place attributes (see 13.5.2)
41af791f
GB
7979are taken from the values of the position, first_bit, and last_bit
7980expressions after normalizing those values so that first_bit is
7981less than Storage_Unit.
7982@end smallexample
7983
7984@noindent
7985The critical point here is that storage places are taken from
ad42149c
FW
7986the values after normalization, not before. So the @code{Bit_Order}
7987interpretation applies to normalized values. The interpretation
41af791f
GB
7988is described in the later part of the 15.5.3 paragraph:
7989
7990@smallexample
79912 A bit ordering is a method of interpreting the meaning of
7992the storage place attributes. High_Order_First (known in the
ad42149c 7993vernacular as ``big endian'') means that the first bit of a
41af791f
GB
7994storage element (bit 0) is the most significant bit (interpreting
7995the sequence of bits that represent a component as an unsigned
ad42149c
FW
7996integer value). Low_Order_First (known in the vernacular as
7997``little endian'') means the opposite: the first bit is the
41af791f
GB
7998least significant.
7999@end smallexample
8000
8001@noindent
8002Note that the numbering is with respect to the bits of a storage
ad42149c 8003unit. In other words, the specification affects only the numbering
41af791f
GB
8004of bits within a single storage unit.
8005
8006We can make the effect clearer by giving an example.
8007
8008Suppose that we have an external device which presents two bytes, the first
8009byte presented, which is the first (low addressed byte) of the two byte
8010record is called Master, and the second byte is called Slave.
8011
8012The left most (most significant bit is called Control for each byte, and
ad42149c
FW
8013the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
8014(least significant) bit.
41af791f
GB
8015
8016On a big-endian machine, we can write the following representation clause
8017
8018@smallexample
8019 type Data is record
8020 Master_Control : Bit;
8021 Master_V1 : Bit;
8022 Master_V2 : Bit;
8023 Master_V3 : Bit;
8024 Master_V4 : Bit;
8025 Master_V5 : Bit;
8026 Master_V6 : Bit;
8027 Master_V7 : Bit;
8028 Slave_Control : Bit;
8029 Slave_V1 : Bit;
8030 Slave_V2 : Bit;
8031 Slave_V3 : Bit;
8032 Slave_V4 : Bit;
8033 Slave_V5 : Bit;
8034 Slave_V6 : Bit;
8035 Slave_V7 : Bit;
8036 end record;
8037
8038 for Data use record
8039 Master_Control at 0 range 0 .. 0;
8040 Master_V1 at 0 range 1 .. 1;
8041 Master_V2 at 0 range 2 .. 2;
8042 Master_V3 at 0 range 3 .. 3;
8043 Master_V4 at 0 range 4 .. 4;
8044 Master_V5 at 0 range 5 .. 5;
8045 Master_V6 at 0 range 6 .. 6;
8046 Master_V7 at 0 range 7 .. 7;
8047 Slave_Control at 1 range 0 .. 0;
8048 Slave_V1 at 1 range 1 .. 1;
8049 Slave_V2 at 1 range 2 .. 2;
8050 Slave_V3 at 1 range 3 .. 3;
8051 Slave_V4 at 1 range 4 .. 4;
8052 Slave_V5 at 1 range 5 .. 5;
8053 Slave_V6 at 1 range 6 .. 6;
8054 Slave_V7 at 1 range 7 .. 7;
8055 end record;
8056@end smallexample
8057
8058@noindent
8059Now if we move this to a little endian machine, then the bit ordering within
8060the byte is backwards, so we have to rewrite the record rep clause as:
8061
8062@smallexample
8063 for Data use record
8064 Master_Control at 0 range 7 .. 7;
8065 Master_V1 at 0 range 6 .. 6;
8066 Master_V2 at 0 range 5 .. 5;
8067 Master_V3 at 0 range 4 .. 4;
8068 Master_V4 at 0 range 3 .. 3;
8069 Master_V5 at 0 range 2 .. 2;
8070 Master_V6 at 0 range 1 .. 1;
8071 Master_V7 at 0 range 0 .. 0;
8072 Slave_Control at 1 range 7 .. 7;
8073 Slave_V1 at 1 range 6 .. 6;
8074 Slave_V2 at 1 range 5 .. 5;
8075 Slave_V3 at 1 range 4 .. 4;
8076 Slave_V4 at 1 range 3 .. 3;
8077 Slave_V5 at 1 range 2 .. 2;
8078 Slave_V6 at 1 range 1 .. 1;
8079 Slave_V7 at 1 range 0 .. 0;
8080 end record;
8081@end smallexample
8082
8083It is a nuisance to have to rewrite the clause, especially if
ad42149c 8084the code has to be maintained on both machines. However,
41af791f
GB
8085this is a case that we can handle with the
8086@code{Bit_Order} attribute if it is implemented.
8087Note that the implementation is not required on byte addressed
ad42149c 8088machines, but it is indeed implemented in GNAT.
41af791f
GB
8089This means that we can simply use the
8090first record clause, together with the declaration
8091
8092@smallexample
8093 for Data'Bit_Order use High_Order_First;
8094@end smallexample
8095
8096@noindent
8097and the effect is what is desired, namely the layout is exactly the same,
ad42149c 8098independent of whether the code is compiled on a big-endian or little-endian
41af791f
GB
8099machine.
8100
8101The important point to understand is that byte ordering is not affected.
8102A @code{Bit_Order} attribute definition never affects which byte a field
8103ends up in, only where it ends up in that byte.
8104To make this clear, let us rewrite the record rep clause of the previous
8105example as:
8106
8107@smallexample
8108 for Data'Bit_Order use High_Order_First;
8109 for Data use record
ad42149c
FW
8110 Master_Control at 0 range 0 .. 0;
8111 Master_V1 at 0 range 1 .. 1;
8112 Master_V2 at 0 range 2 .. 2;
8113 Master_V3 at 0 range 3 .. 3;
8114 Master_V4 at 0 range 4 .. 4;
8115 Master_V5 at 0 range 5 .. 5;
8116 Master_V6 at 0 range 6 .. 6;
8117 Master_V7 at 0 range 7 .. 7;
8118 Slave_Control at 0 range 8 .. 8;
8119 Slave_V1 at 0 range 9 .. 9;
41af791f
GB
8120 Slave_V2 at 0 range 10 .. 10;
8121 Slave_V3 at 0 range 11 .. 11;
8122 Slave_V4 at 0 range 12 .. 12;
8123 Slave_V5 at 0 range 13 .. 13;
8124 Slave_V6 at 0 range 14 .. 14;
8125 Slave_V7 at 0 range 15 .. 15;
8126 end record;
8127@end smallexample
8128
8129@noindent
8130This is exactly equivalent to saying (a repeat of the first example):
8131
8132@smallexample
8133 for Data'Bit_Order use High_Order_First;
8134 for Data use record
8135 Master_Control at 0 range 0 .. 0;
8136 Master_V1 at 0 range 1 .. 1;
8137 Master_V2 at 0 range 2 .. 2;
8138 Master_V3 at 0 range 3 .. 3;
8139 Master_V4 at 0 range 4 .. 4;
8140 Master_V5 at 0 range 5 .. 5;
8141 Master_V6 at 0 range 6 .. 6;
8142 Master_V7 at 0 range 7 .. 7;
8143 Slave_Control at 1 range 0 .. 0;
8144 Slave_V1 at 1 range 1 .. 1;
8145 Slave_V2 at 1 range 2 .. 2;
8146 Slave_V3 at 1 range 3 .. 3;
8147 Slave_V4 at 1 range 4 .. 4;
8148 Slave_V5 at 1 range 5 .. 5;
8149 Slave_V6 at 1 range 6 .. 6;
8150 Slave_V7 at 1 range 7 .. 7;
8151 end record;
8152@end smallexample
8153
8154@noindent
8155Why are they equivalent? Well take a specific field, the @code{Slave_V2}
ad42149c
FW
8156field. The storage place attributes are obtained by normalizing the
8157values given so that the @code{First_Bit} value is less than 8. After
41af791f
GB
8158nromalizing the values (0,10,10) we get (1,2,2) which is exactly what
8159we specified in the other case.
8160
8161Now one might expect that the @code{Bit_Order} attribute might affect
8162bit numbering within the entire record component (two bytes in this
8163case, thus affecting which byte fields end up in), but that is not
8164the way this feature is defined, it only affects numbering of bits,
8165not which byte they end up in.
8166
8167Consequently it never makes sense to specify a starting bit number
8168greater than 7 (for a byte addressable field) if an attribute
8169definition for @code{Bit_Order} has been given, and indeed it
8170may be actively confusing to specify such a value, so the compiler
8171generates a warning for such usage.
8172
8173If you do need to control byte ordering then appropriate conditional
ad42149c 8174values must be used. If in our example, the slave byte came first on
41af791f
GB
8175some machines we might write:
8176
8177@smallexample
ad42149c 8178 Master_Byte_First constant Boolean := @dots{};
41af791f
GB
8179
8180 Master_Byte : constant Natural :=
8181 1 - Boolean'Pos (Master_Byte_First);
8182 Slave_Byte : constant Natural :=
8183 Boolean'Pos (Master_Byte_First);
8184
8185 for Data'Bit_Order use High_Order_First;
8186 for Data use record
8187 Master_Control at Master_Byte range 0 .. 0;
8188 Master_V1 at Master_Byte range 1 .. 1;
8189 Master_V2 at Master_Byte range 2 .. 2;
8190 Master_V3 at Master_Byte range 3 .. 3;
8191 Master_V4 at Master_Byte range 4 .. 4;
8192 Master_V5 at Master_Byte range 5 .. 5;
8193 Master_V6 at Master_Byte range 6 .. 6;
8194 Master_V7 at Master_Byte range 7 .. 7;
8195 Slave_Control at Slave_Byte range 0 .. 0;
8196 Slave_V1 at Slave_Byte range 1 .. 1;
8197 Slave_V2 at Slave_Byte range 2 .. 2;
8198 Slave_V3 at Slave_Byte range 3 .. 3;
8199 Slave_V4 at Slave_Byte range 4 .. 4;
8200 Slave_V5 at Slave_Byte range 5 .. 5;
8201 Slave_V6 at Slave_Byte range 6 .. 6;
8202 Slave_V7 at Slave_Byte range 7 .. 7;
8203 end record;
8204@end smallexample
8205
8206@noindent
8207Now to switch between machines, all that is necessary is
8208to set the boolean constant @code{Master_Byte_First} in
8209an appropriate manner.
8210
8211@node Pragma Pack for Arrays
8212@section Pragma Pack for Arrays
8213@cindex Pragma Pack (for arrays)
8214
8215@noindent
ad42149c
FW
8216Pragma @code{Pack} applied to an array has no effect unless the component type
8217is packable. For a component type to be packable, it must be one of the
41af791f
GB
8218following cases:
8219
8220@itemize @bullet
8221@item
8222Any scalar type
8223@item
8224Any fixed-point type
8225@item
8226Any type whose size is specified with a size clause
8227@item
8228Any packed array type with a static size
8229@end itemize
8230
8231@noindent
8232For all these cases, if the component subtype size is in the range
ad42149c 82331 through 63, then the effect of the pragma @code{Pack} is exactly as though a
41af791f
GB
8234component size were specified giving the component subtype size.
8235For example if we have:
8236
8237@smallexample
8238 type r is range 0 .. 17;
8239
8240 type ar is array (1 .. 8) of r;
8241 pragma Pack (ar);
8242@end smallexample
8243
8244@noindent
46b58b8c 8245Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
41af791f
GB
8246and the size of the array @code{ar} will be exactly 40 bits.
8247
8248Note that in some cases this rather fierce approach to packing can produce
ad42149c 8249unexpected effects. For example, in Ada 95, type Natural typically has a
41af791f
GB
8250size of 31, meaning that if you pack an array of Natural, you get 31-bit
8251close packing, which saves a few bits, but results in far less efficient
ad42149c
FW
8252access. Since many other Ada compilers will ignore such a packing request,
8253GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
8254might not be what is intended. You can easily remove this warning by
8255using an explicit @code{Component_Size} setting instead, which never generates
41af791f
GB
8256a warning, since the intention of the programmer is clear in this case.
8257
ad42149c 8258GNAT treats packed arrays in one of two ways. If the size of the array is
41af791f
GB
8259known at compile time and is less than 64 bits, then internally the array
8260is represented as a single modular type, of exactly the appropriate number
ad42149c 8261of bits. If the length is greater than 63 bits, or is not known at compile
41af791f
GB
8262time, then the packed array is represented as an array of bytes, and the
8263length is always a multiple of 8 bits.
8264
8265@node Pragma Pack for Records
8266@section Pragma Pack for Records
8267@cindex Pragma Pack (for records)
8268
8269@noindent
ad42149c 8270Pragma @code{Pack} applied to a record will pack the components to reduce wasted
41af791f 8271space from alignment gaps and by reducing the amount of space taken by
ad42149c
FW
8272components. We distinguish between package components and non-packable
8273components. Components of the following types are considered packable:
41af791f
GB
8274
8275@itemize @bullet
8276@item
8277All scalar types are packable.
8278
8279@item
8280All fixed-point types are represented internally as integers, and
8281are packable.
8282
8283@item
8284Small packed arrays, whose size does not exceed 64 bits, and where the
8285size is statically known at compile time, are represented internally
8286as modular integers, and so they are also packable.
8287
8288@end itemize
8289
8290@noindent
8291All packable components occupy the exact number of bits corresponding to
46b58b8c 8292their @code{Size} value, and are packed with no padding bits, i.e.@: they
41af791f
GB
8293can start on an arbitrary bit boundary.
8294
8295All other types are non-packable, they occupy an integral number of
8296storage units, and
8297are placed at a boundary corresponding to their alignment requirements.
8298
8299For example, consider the record
8300
8301@smallexample
8302 type Rb1 is array (1 .. 13) of Boolean;
8303 pragma Pack (rb1);
8304
8305 type Rb2 is array (1 .. 65) of Boolean;
8306 pragma Pack (rb2);
8307
8308 type x2 is record
8309 l1 : Boolean;
8310 l2 : Duration;
8311 l3 : Float;
8312 l4 : Boolean;
8313 l5 : Rb1;
8314 l6 : Rb2;
8315 end record;
8316 pragma Pack (x2);
8317@end smallexample
8318
8319@noindent
8320The representation for the record x2 is as follows:
8321
8322@smallexample
8323for x2'Size use 224;
8324for x2 use record
ad42149c 8325 l1 at 0 range 0 .. 0;
41af791f
GB
8326 l2 at 0 range 1 .. 64;
8327 l3 at 12 range 0 .. 31;
ad42149c 8328 l4 at 16 range 0 .. 0;
41af791f
GB
8329 l5 at 16 range 1 .. 13;
8330 l6 at 18 range 0 .. 71;
8331end record;
8332@end smallexample
8333
8334@noindent
8335Studying this example, we see that the packable fields @code{l1}
8336and @code{l2} are
8337of length equal to their sizes, and placed at specific bit boundaries (and
8338not byte boundaries) to
ad42149c 8339eliminate padding. But @code{l3} is of a non-packable float type, so
41af791f
GB
8340it is on the next appropriate alignment boundary.
8341
8342The next two fields are fully packable, so @code{l4} and @code{l5} are
ad42149c
FW
8343minimally packed with no gaps. However, type @code{Rb2} is a packed
8344array that is longer than 64 bits, so it is itself non-packable. Thus
41af791f 8345the @code{l6} field is aligned to the next byte boundary, and takes an
46b58b8c 8346integral number of bytes, i.e.@: 72 bits.
41af791f
GB
8347
8348@node Record Representation Clauses
8349@section Record Representation Clauses
8350@cindex Record Representation Clause
8351
8352@noindent
8353Record representation clauses may be given for all record types, including
ad42149c
FW
8354types obtained by record extension. Component clauses are allowed for any
8355static component. The restrictions on component clauses depend on the type
41af791f
GB
8356of the component.
8357
8358@cindex Component Clause
8359For all components of an elementary type, the only restriction on component
8360clauses is that the size must be at least the 'Size value of the type
ad42149c 8361(actually the Value_Size). There are no restrictions due to alignment,
41af791f
GB
8362and such components may freely cross storage boundaries.
8363
ad42149c 8364Packed arrays with a size up to and including 64 bits are represented
41af791f 8365internally using a modular type with the appropriate number of bits, and
ad42149c 8366thus the same lack of restriction applies. For example, if you declare:
41af791f
GB
8367
8368@smallexample
8369 type R is array (1 .. 49) of Boolean;
8370 pragma Pack (R);
8371 for R'Size use 49;
8372@end smallexample
8373
8374@noindent
8375then a component clause for a component of type R may start on any
8376specified bit boundary, and may specify a value of 49 bits or greater.
8377
8378For non-primitive types, including packed arrays with a size greater than
ad42149c 837964 bits, component clauses must respect the alignment requirement of the
41af791f
GB
8380type, in particular, always starting on a byte boundary, and the length
8381must be a multiple of the storage unit.
8382
8383The tag field of a tagged type always occupies an address sized field at
ad42149c 8384the start of the record. No component clause may attempt to overlay this
41af791f
GB
8385tag.
8386
8387In the case of a record extension T1, of a type T, no component clause applied
8388to the type T1 can specify a storage location that would overlap the first
8389T'Size bytes of the record.
8390
8391@node Enumeration Clauses
8392@section Enumeration Clauses
8393
8394The only restriction on enumeration clauses is that the range of values
ad42149c 8395must be representable. For the signed case, if one or more of the
41af791f
GB
8396representation values are negative, all values must be in the range:
8397
8398@smallexample
8399 System.Min_Int .. System.Max_Int
8400@end smallexample
8401
8402@noindent
8403For the unsigned case, where all values are non negative, the values must
8404be in the range:
8405
8406@smallexample
8407 0 .. System.Max_Binary_Modulus;
8408@end smallexample
8409
8410@noindent
ad42149c 8411A @emph{confirming} representation clause is one in which the values range
46b58b8c 8412from 0 in sequence, i.e.@: a clause that confirms the default representation
41af791f
GB
8413for an enumeration type.
8414Such a confirming representation
8415is permitted by these rules, and is specially recognized by the compiler so
8416that no extra overhead results from the use of such a clause.
8417
8418If an array has an index type which is an enumeration type to which an
8419enumeration clause has been applied, then the array is stored in a compact
ad42149c 8420manner. Consider the declarations:
41af791f
GB
8421
8422@smallexample
8423 type r is (A, B, C);
8424 for r use (A => 1, B => 5, C => 10);
8425 type t is array (r) of Character;
8426@end smallexample
8427
8428@noindent
8429The array type t corresponds to a vector with exactly three elements and
ad42149c 8430has a default size equal to @code{3*Character'Size}. This ensures efficient
41af791f
GB
8431use of space, but means that accesses to elements of the array will incur
8432the overhead of converting representation values to the corresponding
ad42149c 8433positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
41af791f
GB
8434
8435@node Address Clauses
8436@section Address Clauses
8437@cindex Address Clause
8438
8439The reference manual allows a general restriction on representation clauses,
8440as found in RM 13.1(22):
8441
8442@smallexample
8443 An implementation need not support representation
8444 items containing nonstatic expressions, except that
8445 an implementation should support a representation item
8446 for a given entity if each nonstatic expression in the
8447 representation item is a name that statically denotes
8448 a constant declared before the entity.
8449@end smallexample
8450
8451@noindent
8452In practice this is applicable only to address clauses, since this is the
ad42149c 8453only case in which a non-static expression is permitted by the syntax. As
41af791f
GB
8454the AARM notes in sections 13.1 (22.a-22.h):
8455
8456@smallexample
8457 22.a Reason: This is to avoid the following sort
8458 of thing:
8459
ad42149c
FW
8460 22.b X : Integer := F(@dots{});
8461 Y : Address := G(@dots{});
41af791f
GB
8462 for X'Address use Y;
8463
8464 22.c In the above, we have to evaluate the
8465 initialization expression for X before we
ad42149c 8466 know where to put the result. This seems
41af791f
GB
8467 like an unreasonable implementation burden.
8468
8469 22.d The above code should instead be written
8470 like this:
8471
ad42149c
FW
8472 22.e Y : constant Address := G(@dots{});
8473 X : Integer := F(@dots{});
41af791f
GB
8474 for X'Address use Y;
8475
8476 22.f This allows the expression ``Y'' to be safely
8477 evaluated before X is created.
8478
8479 22.g The constant could be a formal parameter of mode in.
8480
8481 22.h An implementation can support other nonstatic
ad42149c 8482 expressions if it wants to. Expressions of type
41af791f
GB
8483 Address are hardly ever static, but their value
8484 might be known at compile time anyway in many
8485 cases.
8486@end smallexample
8487
8488@noindent
ad42149c 8489GNAT does indeed permit many additional cases of non-static expressions. In
41af791f
GB
8490particular, if the type involved is elementary there are no restrictions
8491(since in this case, holding a temporary copy of the initialization value,
ad42149c
FW
8492if one is present, is inexpensive). In addition, if there is no implicit or
8493explicit initialization, then there are no restrictions. GNAT will reject
41af791f
GB
8494only the case where all three of these conditions hold:
8495
8496@itemize @bullet
8497
8498@item
46b58b8c 8499The type of the item is non-elementary (e.g.@: a record or array).
41af791f
GB
8500
8501@item
8502There is explicit or implicit initialization required for the object.
8503
8504@item
ad42149c 8505The address value is non-static. Here GNAT is more permissive than the
41af791f
GB
8506RM, and allows the address value to be the address of a previously declared
8507stand-alone variable, as long as it does not itself have an address clause.
8508
8509@smallexample
8510 Anchor : Some_Initialized_Type;
8511 Overlay : Some_Initialized_Type;
8512 for Overlay'Address use Anchor'Address;
8513@end smallexample
8514
8515However, the prefix of the address clause cannot be an array component, or
8516a component of a discriminated record.
8517
8518@end itemize
8519
8520@noindent
ad42149c 8521As noted above in section 22.h, address values are typically non-static. In
41af791f 8522particular the To_Address function, even if applied to a literal value, is
ad42149c
FW
8523a non-static function call. To avoid this minor annoyance, GNAT provides
8524the implementation defined attribute 'To_Address. The following two
41af791f
GB
8525expressions have identical values:
8526
ad42149c
FW
8527Another issue with address clauses is the interaction with alignment
8528requirements. When an address clause is given for an object, the address
8529value must be consistent with the alignment of the object (which is usually
8530the same as the alignment of the type of the object). If an address clause
8531is given that specifies an inappropriately aligned address value, then the
8532program execution is erroneous.
8533
8534Since this source of erroneous behavior can have unfortunate effects, GNAT
8535checks (at compile time if possible, generating a warning, or at execution
8536time with a run-time check) that the alignment is appropriate. If the
8537run-time check fails, then @code{Program_Error} is raised. This run-time
8538check is suppressed if range checks are suppressed, or if
8539@code{pragma Restrictions (No_Elaboration_Code)} is in effect.
8540
41af791f
GB
8541@findex Attribute
8542@findex To_Address
8543@smallexample
8544 To_Address (16#1234_0000#)
8545 System'To_Address (16#1234_0000#);
8546@end smallexample
8547
8548@noindent
8549except that the second form is considered to be a static expression, and
8550thus when used as an address clause value is always permitted.
8551
8552@noindent
8553Additionally, GNAT treats as static an address clause that is an
ad42149c 8554unchecked_conversion of a static integer value. This simplifies the porting
41af791f
GB
8555of legacy code, and provides a portable equivalent to the GNAT attribute
8556To_Address.
8557
8558@findex Export
ad42149c 8559An address clause cannot be given for an exported object. More
41af791f 8560understandably the real restriction is that objects with an address
ad42149c 8561clause cannot be exported. This is because such variables are not
41af791f
GB
8562defined by the Ada program, so there is no external object so export.
8563
8564@findex Import
8565It is permissible to give an address clause and a pragma Import for the
ad42149c
FW
8566same object. In this case, the variable is not really defined by the
8567Ada program, so there is no external symbol to be linked. The link name
8568and the external name are ignored in this case. The reason that we allow this
41af791f
GB
8569combination is that it provides a useful idiom to avoid unwanted
8570initializations on objects with address clauses.
8571
8572When an address clause is given for an object that has implicit or
ad42149c 8573explicit initialization, then by default initialization takes place. This
41af791f 8574means that the effect of the object declaration is to overwrite the
ad42149c 8575memory at the specified address. This is almost always not what the
41af791f
GB
8576programmer wants, so GNAT will output a warning:
8577
8578@smallexample
8579 with System;
8580 package G is
8581 type R is record
8582 M : Integer := 0;
8583 end record;
8584
8585 Ext : R;
8586 for Ext'Address use System'To_Address (16#1234_1234#);
8587 |
8588 >>> warning: implicit initialization of "Ext" may
8589 modify overlaid storage
8590 >>> warning: use pragma Import for "Ext" to suppress
8591 initialization (RM B(24))
8592
8593 end G;
8594@end smallexample
8595
8596@noindent
8597As indicated by the warning message, the solution is to use a (dummy) pragma
ad42149c
FW
8598Import to suppress this initialization. The pragma tell the compiler that the
8599object is declared and initialized elsewhere. The following package compiles
41af791f
GB
8600without warnings (and the initialization is suppressed):
8601
8602@smallexample
8603 with System;
8604 package G is
8605 type R is record
8606 M : Integer := 0;
8607 end record;
8608
8609 Ext : R;
8610 for Ext'Address use System'To_Address (16#1234_1234#);
8611 pragma Import (Ada, Ext);
8612 end G;
8613@end smallexample
8614
8615@node Effect of Convention on Representation
8616@section Effect of Convention on Representation
8617@cindex Convention, effect on representation
8618
8619@noindent
8620Normally the specification of a foreign language convention for a type or
ad42149c 8621an object has no effect on the chosen representation. In particular, the
41af791f
GB
8622representation chosen for data in GNAT generally meets the standard system
8623conventions, and for example records are laid out in a manner that is
ad42149c 8624consistent with C@. This means that specifying convention C (for example)
41af791f
GB
8625has no effect.
8626
8627There are three exceptions to this general rule:
8628
8629@itemize @bullet
8630
8631@item Convention Fortran and array subtypes
8632If pragma Convention Fortran is specified for an array subtype, then in
8633accordance with the implementation advice in section 3.6.2(11) of the
8634Ada Reference Manual, the array will be stored in a Fortran-compatible
8635column-major manner, instead of the normal default row-major order.
8636
8637@item Convention C and enumeration types
8638GNAT normally stores enumeration types in 8, 16, or 32 bits as required
ad42149c 8639to accommodate all values of the type. For example, for the enumeration
41af791f
GB
8640type declared by:
8641
8642@smallexample
8643 type Color is (Red, Green, Blue);
8644@end smallexample
8645
8646@noindent
86478 bits is sufficient to store all values of the type, so by default, objects
ad42149c
FW
8648of type @code{Color} will be represented using 8 bits. However, normal C
8649convention is to use 32 bits for all enum values in C, since enum values
8650are essentially of type int. If pragma @code{Convention C} is specified for an
41af791f
GB
8651Ada enumeration type, then the size is modified as necessary (usually to
865232 bits) to be consistent with the C convention for enum values.
8653
8654@item Convention C/Fortran and Boolean types
8655In C, the usual convention for boolean values, that is values used for
8656conditions, is that zero represents false, and nonzero values represent
ad42149c 8657true. In Ada, the normal convention is that two specific values, typically
41af791f
GB
86580/1, are used to represent false/true respectively.
8659
8660Fortran has a similar convention for @code{LOGICAL} values (any nonzero
8661value represents true).
8662
8663To accommodate the Fortran and C conventions, if a pragma Convention specifies
8664C or Fortran convention for a derived Boolean, as in the following example:
8665
8666@smallexample
8667 type C_Switch is new Boolean;
8668 pragma Convention (C, C_Switch);
8669@end smallexample
8670
8671@noindent
ad42149c 8672then the GNAT generated code will treat any nonzero value as true. For truth
41af791f
GB
8673values generated by GNAT, the conventional value 1 will be used for True, but
8674when one of these values is read, any nonzero value is treated as True.
8675
8676@end itemize
8677
8678@node Determining the Representations chosen by GNAT
8679@section Determining the Representations chosen by GNAT
8680@cindex Representation, determination of
ad42149c 8681@cindex @code{-gnatR} switch
41af791f
GB
8682
8683@noindent
8684Although the descriptions in this section are intended to be complete, it is
8685often easier to simply experiment to see what GNAT accepts and what the
8686effect is on the layout of types and objects.
8687
8688As required by the Ada RM, if a representation clause is not accepted, then
ad42149c 8689it must be rejected as illegal by the compiler. However, when a representation
41af791f 8690clause or pragma is accepted, there can still be questions of what the
ad42149c 8691compiler actually does. For example, if a partial record representation
41af791f 8692clause specifies the location of some components and not others, then where
ad42149c 8693are the non-specified components placed? Or if pragma @code{Pack} is used on a
41af791f 8694record, then exactly where are the resulting fields placed? The section
ad42149c 8695on pragma @code{Pack} in this chapter can be used to answer the second question,
41af791f
GB
8696but it is often easier to just see what the compiler does.
8697
ad42149c 8698For this purpose, GNAT provides the option @code{-gnatR}. If you compile
41af791f
GB
8699with this option, then the compiler will output information on the actual
8700representations chosen, in a format similar to source representation
ad42149c 8701clauses. For example, if we compile the package:
41af791f
GB
8702
8703@smallexample
8704package q is
8705 type r (x : boolean) is tagged record
8706 case x is
8707 when True => S : String (1 .. 100);
8708 when False => null;
8709 end case;
8710 end record;
8711
8712 type r2 is new r (false) with record
8713 y2 : integer;
8714 end record;
8715
8716 for r2 use record
8717 y2 at 16 range 0 .. 31;
8718 end record;
8719
8720 type x is record
8721 y : character;
8722 end record;
8723
8724 type x1 is array (1 .. 10) of x;
8725 for x1'component_size use 11;
8726
8727 type ia is access integer;
8728
8729 type Rb1 is array (1 .. 13) of Boolean;
8730 pragma Pack (rb1);
8731
8732 type Rb2 is array (1 .. 65) of Boolean;
8733 pragma Pack (rb2);
8734
8735 type x2 is record
8736 l1 : Boolean;
8737 l2 : Duration;
8738 l3 : Float;
8739 l4 : Boolean;
8740 l5 : Rb1;
8741 l6 : Rb2;
8742 end record;
8743 pragma Pack (x2);
8744end q;
8745@end smallexample
8746
8747@noindent
8748using the switch @code{-gnatR} we obtain the following output:
8749
8750@smallexample
8751Representation information for unit q
8752-------------------------------------
8753
8754for r'Size use ??;
8755for r'Alignment use 4;
8756for r use record
ad42149c 8757 x at 4 range 0 .. 7;
41af791f
GB
8758 _tag at 0 range 0 .. 31;
8759 s at 5 range 0 .. 799;
8760end record;
8761
8762for r2'Size use 160;
8763for r2'Alignment use 4;
8764for r2 use record
ad42149c 8765 x at 4 range 0 .. 7;
41af791f
GB
8766 _tag at 0 range 0 .. 31;
8767 _parent at 0 range 0 .. 63;
8768 y2 at 16 range 0 .. 31;
8769end record;
8770
8771for x'Size use 8;
8772for x'Alignment use 1;
8773for x use record
ad42149c 8774 y at 0 range 0 .. 7;
41af791f
GB
8775end record;
8776
8777for x1'Size use 112;
8778for x1'Alignment use 1;
8779for x1'Component_Size use 11;
8780
8781for rb1'Size use 13;
8782for rb1'Alignment use 2;
8783for rb1'Component_Size use 1;
8784
8785for rb2'Size use 72;
8786for rb2'Alignment use 1;
8787for rb2'Component_Size use 1;
8788
8789for x2'Size use 224;
8790for x2'Alignment use 4;
8791for x2 use record
ad42149c 8792 l1 at 0 range 0 .. 0;
41af791f
GB
8793 l2 at 0 range 1 .. 64;
8794 l3 at 12 range 0 .. 31;
ad42149c 8795 l4 at 16 range 0 .. 0;
41af791f
GB
8796 l5 at 16 range 1 .. 13;
8797 l6 at 18 range 0 .. 71;
8798end record;
8799@end smallexample
8800
8801@noindent
46b58b8c 8802The Size values are actually the Object_Size, i.e.@: the default size that
41af791f
GB
8803will be allocated for objects of the type.
8804The ?? size for type r indicates that we have a variant record, and the
8805actual size of objects will depend on the discriminant value.
8806
8807The Alignment values show the actual alignment chosen by the compiler
8808for each record or array type.
8809
8810The record representation clause for type r shows where all fields
8811are placed, including the compiler generated tag field (whose location
8812cannot be controlled by the programmer).
8813
8814The record representation clause for the type extension r2 shows all the
8815fields present, including the parent field, which is a copy of the fields
46b58b8c 8816of the parent type of r2, i.e.@: r1.
41af791f
GB
8817
8818The component size and size clauses for types rb1 and rb2 show
ad42149c
FW
8819the exact effect of pragma @code{Pack} on these arrays, and the record
8820representation clause for type x2 shows how pragma @code{Pack} affects
41af791f
GB
8821this record type.
8822
8823In some cases, it may be useful to cut and paste the representation clauses
8824generated by the compiler into the original source to fix and guarantee
8825the actual representation to be used.
8826
8827@node Standard Library Routines
8828@chapter Standard Library Routines
8829
8830@noindent
8831The Ada 95 Reference Manual contains in Annex A a full description of an
8832extensive set of standard library routines that can be used in any Ada
ad42149c 8833program, and which must be provided by all Ada compilers. They are
41af791f
GB
8834analogous to the standard C library used by C programs.
8835
8836GNAT implements all of the facilities described in annex A, and for most
8837purposes the description in the Ada 95
8838reference manual, or appropriate Ada
8839text book, will be sufficient for making use of these facilities.
8840
8841In the case of the input-output facilities, @xref{The Implementation of
8842Standard I/O}, gives details on exactly how GNAT interfaces to the
ad42149c
FW
8843file system. For the remaining packages, the Ada 95 reference manual
8844should be sufficient. The following is a list of the packages included,
41af791f
GB
8845together with a brief description of the functionality that is provided.
8846
8847For completeness, references are included to other predefined library
8848routines defined in other sections of the Ada 95 reference manual (these are
8849cross-indexed from annex A).
8850
8851@table @code
8852@item Ada (A.2)
ad42149c 8853This is a parent package for all the standard library packages. It is
41af791f
GB
8854usually included implicitly in your program, and itself contains no
8855useful data or routines.
8856
8857@item Ada.Calendar (9.6)
8858@code{Calendar} provides time of day access, and routines for
8859manipulating times and durations.
8860
8861@item Ada.Characters (A.3.1)
8862This is a dummy parent package that contains no useful entities
8863
8864@item Ada.Characters.Handling (A.3.2)
8865This package provides some basic character handling capabilities,
46b58b8c 8866including classification functions for classes of characters (e.g.@: test
41af791f
GB
8867for letters, or digits).
8868
8869@item Ada.Characters.Latin_1 (A.3.3)
8870This package includes a complete set of definitions of the characters
ad42149c
FW
8871that appear in type CHARACTER@. It is useful for writing programs that
8872will run in international environments. For example, if you want an
41af791f 8873upper case E with an acute accent in a string, it is often better to use
ad42149c 8874the definition of @code{UC_E_Acute} in this package. Then your program
41af791f
GB
8875will print in an understandable manner even if your environment does not
8876support these extended characters.
8877
8878@item Ada.Command_Line (A.15)
8879This package provides access to the command line parameters and the name
ad42149c 8880of the current program (analogous to the use of @code{argc} and @code{argv} in C), and
41af791f
GB
8881also allows the exit status for the program to be set in a
8882system-independent manner.
8883
8884@item Ada.Decimal (F.2)
8885This package provides constants describing the range of decimal numbers
8886implemented, and also a decimal divide routine (analogous to the COBOL
8887verb DIVIDE .. GIVING .. REMAINDER ..)
8888
8889@item Ada.Direct_IO (A.8.4)
8890This package provides input-output using a model of a set of records of
8891fixed-length, containing an arbitrary definite Ada type, indexed by an
8892integer record number.
8893
8894@item Ada.Dynamic_Priorities (D.5)
8895This package allows the priorities of a task to be adjusted dynamically
8896as the task is running.
8897
8898@item Ada.Exceptions (11.4.1)
8899This package provides additional information on exceptions, and also
8900contains facilities for treating exceptions as data objects, and raising
8901exceptions with associated messages.
8902
8903@item Ada.Finalization (7.6)
8904This package contains the declarations and subprograms to support the
8905use of controlled types, providing for automatic initialization and
8906finalization (analogous to the constructors and destructors of C++)
8907
8908@item Ada.Interrupts (C.3.2)
8909This package provides facilities for interfacing to interrupts, which
8910includes the set of signals or conditions that can be raised and
8911recognized as interrupts.
8912
8913@item Ada.Interrupts.Names (C.3.2)
8914This package provides the set of interrupt names (actually signal
46b58b8c 8915or condition names) that can be handled by GNAT@.
41af791f
GB
8916
8917@item Ada.IO_Exceptions (A.13)
8918This package defines the set of exceptions that can be raised by use of
8919the standard IO packages.
8920
8921@item Ada.Numerics
8922This package contains some standard constants and exceptions used
ad42149c 8923throughout the numerics packages. Note that the constants pi and e are
41af791f
GB
8924defined here, and it is better to use these definitions than rolling
8925your own.
8926
8927@item Ada.Numerics.Complex_Elementary_Functions
8928Provides the implementation of standard elementary functions (such as
8929log and trigonometric functions) operating on complex numbers using the
8930standard @code{Float} and the @code{Complex} and @code{Imaginary} types
8931created by the package @code{Numerics.Complex_Types}.
8932
8933@item Ada.Numerics.Complex_Types
8934This is a predefined instantiation of
8935@code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
8936build the type @code{Complex} and @code{Imaginary}.
8937
8938@item Ada.Numerics.Discrete_Random
8939This package provides a random number generator suitable for generating
8940random integer values from a specified range.
8941
8942@item Ada.Numerics.Float_Random
8943This package provides a random number generator suitable for generating
8944uniformly distributed floating point values.
8945
8946@item Ada.Numerics.Generic_Complex_Elementary_Functions
8947This is a generic version of the package that provides the
ad42149c 8948implementation of standard elementary functions (such as log and
41af791f
GB
8949trigonometric functions) for an arbitrary complex type.
8950
ad42149c 8951The following predefined instantiations of this package are provided:
41af791f
GB
8952
8953@table @code
8954@item Short_Float
8955@code{Ada.Numerics.Short_Complex_Elementary_Functions}
8956@item Float
8957@code{Ada.Numerics.Complex_Elementary_Functions}
8958@item Long_Float
8959@code{Ada.Numerics.
8960 Long_Complex_Elementary_Functions}
8961@end table
8962
8963@item Ada.Numerics.Generic_Complex_Types
8964This is a generic package that allows the creation of complex types,
8965with associated complex arithmetic operations.
8966
8967The following predefined instantiations of this package exist
8968@table @code
8969@item Short_Float
8970@code{Ada.Numerics.Short_Complex_Complex_Types}
8971@item Float
8972@code{Ada.Numerics.Complex_Complex_Types}
8973@item Long_Float
8974@code{Ada.Numerics.Long_Complex_Complex_Types}
8975@end table
8976
8977@item Ada.Numerics.Generic_Elementary_Functions
8978This is a generic package that provides the implementation of standard
8979elementary functions (such as log an trigonometric functions) for an
8980arbitrary float type.
8981
8982The following predefined instantiations of this package exist
8983
8984@table @code
8985@item Short_Float
8986@code{Ada.Numerics.Short_Elementary_Functions}
8987@item Float
8988@code{Ada.Numerics.Elementary_Functions}
8989@item Long_Float
8990@code{Ada.Numerics.Long_Elementary_Functions}
8991@end table
8992
8993@item Ada.Real_Time (D.8)
8994This package provides facilities similar to those of @code{Calendar}, but
ad42149c
FW
8995operating with a finer clock suitable for real time control. Note that
8996annex D requires that there be no backward clock jumps, and GNAT generally
8997guarantees this behavior, but of course if the external clock on which
8998the GNAT runtime depends is deliberately reset by some external event,
8999then such a backward jump may occur.
41af791f
GB
9000
9001@item Ada.Sequential_IO (A.8.1)
9002This package provides input-output facilities for sequential files,
9003which can contain a sequence of values of a single type, which can be
9004any Ada type, including indefinite (unconstrained) types.
9005
9006@item Ada.Storage_IO (A.9)
9007This package provides a facility for mapping arbitrary Ada types to and
ad42149c 9008from a storage buffer. It is primarily intended for the creation of new
41af791f
GB
9009IO packages.
9010
9011@item Ada.Streams (13.13.1)
9012This is a generic package that provides the basic support for the
9013concept of streams as used by the stream attributes (@code{Input},
9014@code{Output}, @code{Read} and @code{Write}).
9015
9016@item Ada.Streams.Stream_IO (A.12.1)
9017This package is a specialization of the type @code{Streams} defined in
9018package @code{Streams} together with a set of operations providing
ad42149c 9019Stream_IO capability. The Stream_IO model permits both random and
41af791f
GB
9020sequential access to a file which can contain an arbitrary set of values
9021of one or more Ada types.
9022
9023@item Ada.Strings (A.4.1)
9024This package provides some basic constants used by the string handling
9025packages.
9026
9027@item Ada.Strings.Bounded (A.4.4)
9028This package provides facilities for handling variable length
ad42149c 9029strings. The bounded model requires a maximum length. It is thus
41af791f
GB
9030somewhat more limited than the unbounded model, but avoids the use of
9031dynamic allocation or finalization.
9032
9033@item Ada.Strings.Fixed (A.4.3)
9034This package provides facilities for handling fixed length strings.
9035
9036@item Ada.Strings.Maps (A.4.2)
9037This package provides facilities for handling character mappings and
ad42149c 9038arbitrarily defined subsets of characters. For instance it is useful in
41af791f
GB
9039defining specialized translation tables.
9040
9041@item Ada.Strings.Maps.Constants (A.4.6)
9042This package provides a standard set of predefined mappings and
ad42149c
FW
9043predefined character sets. For example, the standard upper to lower case
9044conversion table is found in this package. Note that upper to lower case
41af791f
GB
9045conversion is non-trivial if you want to take the entire set of
9046characters, including extended characters like E with an acute accent,
ad42149c 9047into account. You should use the mappings in this package (rather than
41af791f
GB
9048adding 32 yourself) to do case mappings.
9049
9050@item Ada.Strings.Unbounded (A.4.5)
9051This package provides facilities for handling variable length
ad42149c 9052strings. The unbounded model allows arbitrary length strings, but
41af791f
GB
9053requires the use of dynamic allocation and finalization.
9054
9055@item Ada.Strings.Wide_Bounded (A.4.7)
9056@itemx Ada.Strings.Wide_Fixed (A.4.7)
9057@itemx Ada.Strings.Wide_Maps (A.4.7)
9058@itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
9059@itemx Ada.Strings.Wide_Unbounded (A.4.7)
9060These package provide analogous capabilities to the corresponding
9061packages without @samp{Wide_} in the name, but operate with the types
9062@code{Wide_String} and @code{Wide_Character} instead of @code{String}
9063and @code{Character}.
9064
9065@item Ada.Synchronous_Task_Control (D.10)
9066This package provides some standard facilities for controlling task
9067communication in a synchronous manner.
9068
9069@item Ada.Tags
9070This package contains definitions for manipulation of the tags of tagged
9071values.
9072
9073@item Ada.Task_Attributes
9074This package provides the capability of associating arbitrary
9075task-specific data with separate tasks.
9076
9077@item Ada.Text_IO
9078This package provides basic text input-output capabilities for
ad42149c 9079character, string and numeric data. The subpackages of this
41af791f
GB
9080package are listed next.
9081
9082@item Ada.Text_IO.Decimal_IO
9083Provides input-output facilities for decimal fixed-point types
9084
9085@item Ada.Text_IO.Enumeration_IO
9086Provides input-output facilities for enumeration types.
9087
9088@item Ada.Text_IO.Fixed_IO
9089Provides input-output facilities for ordinary fixed-point types.
9090
9091@item Ada.Text_IO.Float_IO
ad42149c 9092Provides input-output facilities for float types. The following
41af791f
GB
9093predefined instantiations of this generic package are available:
9094
9095@table @code
9096@item Short_Float
9097@code{Short_Float_Text_IO}
9098@item Float
9099@code{Float_Text_IO}
9100@item Long_Float
9101@code{Long_Float_Text_IO}
9102@end table
9103
9104@item Ada.Text_IO.Integer_IO
ad42149c 9105Provides input-output facilities for integer types. The following
41af791f
GB
9106predefined instantiations of this generic package are available:
9107
9108@table @code
9109@item Short_Short_Integer
9110@code{Ada.Short_Short_Integer_Text_IO}
9111@item Short_Integer
9112@code{Ada.Short_Integer_Text_IO}
9113@item Integer
9114@code{Ada.Integer_Text_IO}
9115@item Long_Integer
9116@code{Ada.Long_Integer_Text_IO}
9117@item Long_Long_Integer
9118@code{Ada.Long_Long_Integer_Text_IO}
9119@end table
9120
9121@item Ada.Text_IO.Modular_IO
9122Provides input-output facilities for modular (unsigned) types
9123
9124@item Ada.Text_IO.Complex_IO (G.1.3)
9125This package provides basic text input-output capabilities for complex
9126data.
9127
9128@item Ada.Text_IO.Editing (F.3.3)
9129This package contains routines for edited output, analogous to the use
ad42149c 9130of pictures in COBOL@. The picture formats used by this package are a
46b58b8c 9131close copy of the facility in COBOL@.
41af791f
GB
9132
9133@item Ada.Text_IO.Text_Streams (A.12.2)
9134This package provides a facility that allows Text_IO files to be treated
9135as streams, so that the stream attributes can be used for writing
9136arbitrary data, including binary data, to Text_IO files.
9137
9138@item Ada.Unchecked_Conversion (13.9)
9139This generic package allows arbitrary conversion from one type to
9140another of the same size, providing for breaking the type safety in
9141special circumstances.
9142
9143If the types have the same Size (more accurately the same Value_Size),
9144then the effect is simply to transfer the bits from the source to the
ad42149c 9145target type without any modification. This usage is well defined, and
41af791f
GB
9146for simple types whose representation is typically the same across
9147all implementations, gives a portable method of performing such
9148conversions.
9149
9150If the types do not have the same size, then the result is implementation
ad42149c 9151defined, and thus may be non-portable. The following describes how GNAT
41af791f
GB
9152handles such unchecked conversion cases.
9153
9154If the types are of different sizes, and are both discrete types, then
9155the effect is of a normal type conversion without any constraint checking.
9156In particular if the result type has a larger size, the result will be
ad42149c 9157zero or sign extended. If the result type has a smaller size, the result
41af791f
GB
9158will be truncated by ignoring high order bits.
9159
9160If the types are of different sizes, and are not both discrete types,
9161then the conversion works as though pointers were created to the source
ad42149c 9162and target, and the pointer value is converted. The effect is that bits
41af791f
GB
9163are copied from successive low order storage units and bits of the source
9164up to the length of the target type.
9165
9166A warning is issued if the lengths differ, since the effect in this
9167case is implementation dependent, and the above behavior may not match
9168that of some other compiler.
9169
9170A pointer to one type may be converted to a pointer to another type using
ad42149c
FW
9171unchecked conversion. The only case in which the effect is undefined is
9172when one or both pointers are pointers to unconstrained array types. In
41af791f
GB
9173this case, the bounds information may get incorrectly transferred, and in
9174particular, GNAT uses double size pointers for such types, and it is
ad42149c 9175meaningless to convert between such pointer types. GNAT will issue a
41af791f
GB
9176warning if the alignment of the target designated type is more strict
9177than the alignment of the source designated type (since the result may
9178be unaligned in this case).
9179
9180A pointer other than a pointer to an unconstrained array type may be
ad42149c 9181converted to and from System.Address. Such usage is common in Ada 83
41af791f 9182programs, but note that Ada.Address_To_Access_Conversions is the
ad42149c 9183preferred method of performing such conversions in Ada 95. Neither
41af791f
GB
9184unchecked conversion nor Ada.Address_To_Access_Conversions should be
9185used in conjunction with pointers to unconstrained objects, since
9186the bounds information cannot be handled correctly in this case.
9187
9188@item Ada.Unchecked_Deallocation (13.11.2)
9189This generic package allows explicit freeing of storage previously
9190allocated by use of an allocator.
9191
9192@item Ada.Wide_Text_IO (A.11)
9193This package is similar to @code{Ada.Text_IO}, except that the external
9194file supports wide character representations, and the internal types are
9195@code{Wide_Character} and @code{Wide_String} instead of @code{Character}
ad42149c 9196and @code{String}. It contains generic subpackages listed next.
41af791f
GB
9197
9198@item Ada.Wide_Text_IO.Decimal_IO
9199Provides input-output facilities for decimal fixed-point types
9200
9201@item Ada.Wide_Text_IO.Enumeration_IO
9202Provides input-output facilities for enumeration types.
9203
9204@item Ada.Wide_Text_IO.Fixed_IO
9205Provides input-output facilities for ordinary fixed-point types.
9206
9207@item Ada.Wide_Text_IO.Float_IO
ad42149c 9208Provides input-output facilities for float types. The following
41af791f
GB
9209predefined instantiations of this generic package are available:
9210
9211@table @code
9212@item Short_Float
9213@code{Short_Float_Wide_Text_IO}
9214@item Float
9215@code{Float_Wide_Text_IO}
9216@item Long_Float
9217@code{Long_Float_Wide_Text_IO}
9218@end table
9219
9220@item Ada.Wide_Text_IO.Integer_IO
ad42149c 9221Provides input-output facilities for integer types. The following
41af791f
GB
9222predefined instantiations of this generic package are available:
9223
9224@table @code
9225@item Short_Short_Integer
9226@code{Ada.Short_Short_Integer_Wide_Text_IO}
9227@item Short_Integer
9228@code{Ada.Short_Integer_Wide_Text_IO}
9229@item Integer
9230@code{Ada.Integer_Wide_Text_IO}
9231@item Long_Integer
9232@code{Ada.Long_Integer_Wide_Text_IO}
9233@item Long_Long_Integer
9234@code{Ada.Long_Long_Integer_Wide_Text_IO}
9235@end table
9236
9237@item Ada.Wide_Text_IO.Modular_IO
9238Provides input-output facilities for modular (unsigned) types
9239
9240@item Ada.Wide_Text_IO.Complex_IO (G.1.3)
9241This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
9242external file supports wide character representations.
9243
9244@item Ada.Wide_Text_IO.Editing (F.3.4)
9245This package is similar to @code{Ada.Text_IO.Editing}, except that the
9246types are @code{Wide_Character} and @code{Wide_String} instead of
9247@code{Character} and @code{String}.
9248
9249@item Ada.Wide_Text_IO.Streams (A.12.3)
9250This package is similar to @code{Ada.Text_IO.Streams}, except that the
9251types are @code{Wide_Character} and @code{Wide_String} instead of
9252@code{Character} and @code{String}.
9253@end table
9254@node The Implementation of Standard I/O
9255@chapter The Implementation of Standard I/O
9256
9257@noindent
9258GNAT implements all the required input-output facilities described in
ad42149c 9259A.6 through A.14. These sections of the Ada 95 reference manual describe the
41af791f
GB
9260required behavior of these packages from the Ada point of view, and if
9261you are writing a portable Ada program that does not need to know the
9262exact manner in which Ada maps to the outside world when it comes to
9263reading or writing external files, then you do not need to read this
ad42149c 9264chapter. As long as your files are all regular files (not pipes or
41af791f
GB
9265devices), and as long as you write and read the files only from Ada, the
9266description in the Ada 95 reference manual is sufficient.
9267
9268However, if you want to do input-output to pipes or other devices, such
9269as the keyboard or screen, or if the files you are dealing with are
9270either generated by some other language, or to be read by some other
9271language, then you need to know more about the details of how the GNAT
9272implementation of these input-output facilities behaves.
9273
9274In this chapter we give a detailed description of exactly how GNAT
ad42149c 9275interfaces to the file system. As always, the sources of the system are
41af791f
GB
9276available to you for answering questions at an even more detailed level,
9277but for most purposes the information in this chapter will suffice.
9278
9279Another reason that you may need to know more about how input-output is
9280implemented arises when you have a program written in mixed languages
9281where, for example, files are shared between the C and Ada sections of
ad42149c 9282the same program. GNAT provides some additional facilities, in the form
41af791f
GB
9283of additional child library packages, that facilitate this sharing, and
9284these additional facilities are also described in this chapter.
9285
9286@menu
9287* Standard I/O Packages::
9288* FORM Strings::
9289* Direct_IO::
9290* Sequential_IO::
9291* Text_IO::
9292* Wide_Text_IO::
9293* Stream_IO::
9294* Shared Files::
9295* Open Modes::
9296* Operations on C Streams::
9297* Interfacing to C Streams::
9298@end menu
9299
9300@node Standard I/O Packages
9301@section Standard I/O Packages
9302
9303@noindent
9304The Standard I/O packages described in Annex A for
9305
9306@itemize @bullet
9307@item
9308Ada.Text_IO
9309@item
9310Ada.Text_IO.Complex_IO
9311@item
9312Ada.Text_IO.Text_Streams,
9313@item
9314Ada.Wide_Text_IO
9315@item
9316Ada.Wide_Text_IO.Complex_IO,
9317@item
9318Ada.Wide_Text_IO.Text_Streams
9319@item
9320Ada.Stream_IO
9321@item
9322Ada.Sequential_IO
9323@item
9324Ada.Direct_IO
9325@end itemize
9326
9327@noindent
9328are implemented using the C
9329library streams facility; where
9330
9331@itemize @bullet
9332@item
9333All files are opened using @code{fopen}.
9334@item
9335All input/output operations use @code{fread}/@code{fwrite}.
9336@end itemize
9337
ad42149c 9338There is no internal buffering of any kind at the Ada library level. The
41af791f 9339only buffering is that provided at the system level in the
ad42149c 9340implementation of the C library routines that support streams. This
41af791f
GB
9341facilitates shared use of these streams by mixed language programs.
9342
9343@node FORM Strings
9344@section FORM Strings
9345
9346@noindent
9347The format of a FORM string in GNAT is:
9348
9349@smallexample
ad42149c 9350"keyword=value,keyword=value,@dots{},keyword=value"
41af791f
GB
9351@end smallexample
9352
9353@noindent
9354where letters may be in upper or lower case, and there are no spaces
ad42149c 9355between values. The order of the entries is not important. Currently
41af791f
GB
9356there are two keywords defined.
9357
9358@smallexample
9359SHARED=[YES|NO]
9360WCEM=[n|h|u|s\e]
9361@end smallexample
9362
9363The use of these parameters is described later in this section.
9364
9365@node Direct_IO
9366@section Direct_IO
9367
9368@noindent
ad42149c 9369Direct_IO can only be instantiated for definite types. This is a
41af791f
GB
9370restriction of the Ada language, which means that the records are fixed
9371length (the length being determined by @code{@var{type}'Size}, rounded
9372up to the next storage unit boundary if necessary).
9373
9374The records of a Direct_IO file are simply written to the file in index
9375sequence, with the first record starting at offset zero, and subsequent
ad42149c 9376records following. There is no control information of any kind. For
41af791f 9377example, if 32-bit integers are being written, each record takes
ad42149c
FW
93784-bytes, so the record at index @var{K} starts at offset
9379(@var{K}@minus{}1)*4.
41af791f
GB
9380
9381There is no limit on the size of Direct_IO files, they are expanded as
9382necessary to accommodate whatever records are written to the file.
9383
9384@node Sequential_IO
9385@section Sequential_IO
9386
9387@noindent
9388Sequential_IO may be instantiated with either a definite (constrained)
9389or indefinite (unconstrained) type.
9390
9391For the definite type case, the elements written to the file are simply
9392the memory images of the data values with no control information of any
ad42149c 9393kind. The resulting file should be read using the same type, no validity
41af791f
GB
9394checking is performed on input.
9395
9396For the indefinite type case, the elements written consist of two
ad42149c 9397parts. First is the size of the data item, written as the memory image
41af791f 9398of a @code{Interfaces.C.size_t} value, followed by the memory image of
ad42149c
FW
9399the data value. The resulting file can only be read using the same
9400(unconstrained) type. Normal assignment checks are performed on these
41af791f 9401read operations, and if these checks fail, @code{Data_Error} is
ad42149c 9402raised. In particular, in the array case, the lengths must match, and in
41af791f
GB
9403the variant record case, if the variable for a particular read operation
9404is constrained, the discriminants must match.
9405
9406Note that it is not possible to use Sequential_IO to write variable
9407length array items, and then read the data back into different length
ad42149c 9408arrays. For example, the following will raise @code{Data_Error}:
41af791f
GB
9409
9410@smallexample
9411 package IO is new Sequential_IO (String);
9412 F : IO.File_Type;
9413 S : String (1..4);
ad42149c 9414 @dots{}
41af791f
GB
9415 IO.Create (F)
9416 IO.Write (F, "hello!")
9417 IO.Reset (F, Mode=>In_File);
9418 IO.Read (F, S);
9419 Put_Line (S);
9420
9421@end smallexample
9422
9423On some Ada implementations, this will print @samp{hell}, but the program is
9424clearly incorrect, since there is only one element in the file, and that
9425element is the string @samp{hello!}.
9426
9427In Ada 95, this kind of behavior can be legitimately achieved using
ad42149c 9428Stream_IO, and this is the preferred mechanism. In particular, the above
41af791f
GB
9429program fragment rewritten to use Stream_IO will work correctly.
9430
9431@node Text_IO
9432@section Text_IO
9433
9434@noindent
9435Text_IO files consist of a stream of characters containing the following
9436special control characters:
9437
9438@smallexample
9439LF (line feed, 16#0A#) Line Mark
9440FF (form feed, 16#0C#) Page Mark
9441@end smallexample
9442
9443A canonical Text_IO file is defined as one in which the following
9444conditions are met:
9445
9446@itemize @bullet
9447@item
46b58b8c 9448The character @code{LF} is used only as a line mark, i.e.@: to mark the end
41af791f
GB
9449of the line.
9450
9451@item
46b58b8c 9452The character @code{FF} is used only as a page mark, i.e.@: to mark the
41af791f
GB
9453end of a page and consequently can appear only immediately following a
9454@code{LF} (line mark) character.
9455
9456@item
9457The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
ad42149c 9458(line mark, page mark). In the former case, the page mark is implicitly
41af791f
GB
9459assumed to be present.
9460@end itemize
9461
9462A file written using Text_IO will be in canonical form provided that no
9463explicit @code{LF} or @code{FF} characters are written using @code{Put}
ad42149c 9464or @code{Put_Line}. There will be no @code{FF} character at the end of
41af791f
GB
9465the file unless an explicit @code{New_Page} operation was performed
9466before closing the file.
9467
46b58b8c 9468A canonical Text_IO file that is a regular file, i.e.@: not a device or a
ad42149c 9469pipe, can be read using any of the routines in Text_IO@. The
41af791f
GB
9470semantics in this case will be exactly as defined in the Ada 95 reference
9471manual and all the routines in Text_IO are fully implemented.
9472
9473A text file that does not meet the requirements for a canonical Text_IO
9474file has one of the following:
9475
9476@itemize @bullet
9477@item
9478The file contains @code{FF} characters not immediately following a
9479@code{LF} character.
9480
9481@item
9482The file contains @code{LF} or @code{FF} characters written by
9483@code{Put} or @code{Put_Line}, which are not logically considered to be
9484line marks or page marks.
9485
9486@item
9487The file ends in a character other than @code{LF} or @code{FF},
46b58b8c 9488i.e.@: there is no explicit line mark or page mark at the end of the file.
41af791f
GB
9489@end itemize
9490
9491Text_IO can be used to read such non-standard text files but subprograms
ad42149c 9492to do with line or page numbers do not have defined meanings. In
41af791f
GB
9493particular, a @code{FF} character that does not follow a @code{LF}
9494character may or may not be treated as a page mark from the point of
ad42149c 9495view of page and line numbering. Every @code{LF} character is considered
41af791f
GB
9496to end a line, and there is an implied @code{LF} character at the end of
9497the file.
9498
9499@menu
9500* Text_IO Stream Pointer Positioning::
9501* Text_IO Reading and Writing Non-Regular Files::
9502* Get_Immediate::
9503* Treating Text_IO Files as Streams::
9504* Text_IO Extensions::
9505* Text_IO Facilities for Unbounded Strings::
9506@end menu
9507@node Text_IO Stream Pointer Positioning
9508
9509@subsection Stream Pointer Positioning
9510
9511@noindent
9512@code{Ada.Text_IO} has a definition of current position for a file that
ad42149c 9513is being read. No internal buffering occurs in Text_IO, and usually the
41af791f 9514physical position in the stream used to implement the file corresponds
ad42149c 9515to this logical position defined by Text_IO@. There are two exceptions:
41af791f
GB
9516
9517@itemize @bullet
9518@item
9519After a call to @code{End_Of_Page} that returns @code{True}, the stream
9520is positioned past the @code{LF} (line mark) that precedes the page
ad42149c 9521mark. Text_IO maintains an internal flag so that subsequent read
41af791f
GB
9522operations properly handle the logical position which is unchanged by
9523the @code{End_Of_Page} call.
9524
9525@item
9526After a call to @code{End_Of_File} that returns @code{True}, if the
9527Text_IO file was positioned before the line mark at the end of file
9528before the call, then the logical position is unchanged, but the stream
9529is physically positioned right at the end of file (past the line mark,
ad42149c 9530and past a possible page mark following the line mark. Again Text_IO
41af791f
GB
9531maintains internal flags so that subsequent read operations properly
9532handle the logical position.
9533@end itemize
9534
9535These discrepancies have no effect on the observable behavior of
9536Text_IO, but if a single Ada stream is shared between a C program and
9537Ada program, or shared (using @samp{shared=yes} in the form string)
9538between two Ada files, then the difference may be observable in some
9539situations.
9540
9541@node Text_IO Reading and Writing Non-Regular Files
9542@subsection Reading and Writing Non-Regular Files
9543
9544@noindent
ad42149c
FW
9545A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
9546can be used for reading and writing. Writing is not affected and the
41af791f
GB
9547sequence of characters output is identical to the normal file case, but
9548for reading, the behavior of Text_IO is modified to avoid undesirable
9549look-ahead as follows:
9550
9551An input file that is not a regular file is considered to have no page
ad42149c 9552marks. Any @code{Ascii.FF} characters (the character normally used for a
41af791f 9553page mark) appearing in the file are considered to be data
ad42149c 9554characters. In particular:
41af791f
GB
9555
9556@itemize @bullet
9557@item
9558@code{Get_Line} and @code{Skip_Line} do not test for a page mark
ad42149c 9559following a line mark. If a page mark appears, it will be treated as a
41af791f
GB
9560data character.
9561
9562@item
9563This avoids the need to wait for an extra character to be typed or
9564entered from the pipe to complete one of these operations.
9565
9566@item
9567@code{End_Of_Page} always returns @code{False}
9568
9569@item
9570@code{End_Of_File} will return @code{False} if there is a page mark at
9571the end of the file.
9572@end itemize
9573
ad42149c 9574Output to non-regular files is the same as for regular files. Page marks
41af791f
GB
9575may be written to non-regular files using @code{New_Page}, but as noted
9576above they will not be treated as page marks on input if the output is
9577piped to another Ada program.
9578
9579Another important discrepancy when reading non-regular files is that the end
ad42149c
FW
9580of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
9581pressing the @key{EOT} key,
41af791f 9582then end of file
46b58b8c 9583is signalled once (i.e.@: the test @code{End_Of_File}
41af791f
GB
9584will yield @code{True}, or a read will
9585raise @code{End_Error}), but then reading can resume
9586to read data past that end of
9587file indication, until another end of file indication is entered.
9588
9589@node Get_Immediate
9590@subsection Get_Immediate
9591@cindex Get_Immediate
9592
9593@noindent
9594Get_Immediate returns the next character (including control characters)
ad42149c
FW
9595from the input file. In particular, Get_Immediate will return LF or FF
9596characters used as line marks or page marks. Such operations leave the
41af791f 9597file positioned past the control character, and it is thus not treated
ad42149c 9598as having its normal function. This means that page, line and column
41af791f 9599counts after this kind of Get_Immediate call are set as though the mark
ad42149c 9600did not occur. In the case where a Get_Immediate leaves the file
41af791f
GB
9601positioned between the line mark and page mark (which is not normally
9602possible), it is undefined whether the FF character will be treated as a
9603page mark.
9604
9605@node Treating Text_IO Files as Streams
9606@subsection Treating Text_IO Files as Streams
9607@cindex Stream files
9608
9609@noindent
9610The package @code{Text_IO.Streams} allows a Text_IO file to be treated
ad42149c
FW
9611as a stream. Data written to a Text_IO file in this stream mode is
9612binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
41af791f 961316#0C# (@code{FF}), the resulting file may have non-standard
ad42149c 9614format. Similarly if read operations are used to read from a Text_IO
41af791f
GB
9615file treated as a stream, then @code{LF} and @code{FF} characters may be
9616skipped and the effect is similar to that described above for
9617@code{Get_Immediate}.
9618
9619@node Text_IO Extensions
9620@subsection Text_IO Extensions
9621@cindex Text_IO extensions
9622
9623@noindent
9624A package GNAT.IO_Aux in the GNAT library provides some useful extensions
9625to the standard @code{Text_IO} package:
9626
9627@itemize @bullet
9628@item function File_Exists (Name : String) return Boolean;
9629Determines if a file of the given name exists and can be successfully
9630opened (without actually performing the open operation).
9631
9632@item function Get_Line return String;
ad42149c 9633Reads a string from the standard input file. The value returned is exactly
41af791f
GB
9634the length of the line that was read.
9635
9636@item function Get_Line (File : Ada.Text_IO.File_Type) return String;
9637Similar, except that the parameter File specifies the file from which
9638the string is to be read.
9639
9640@end itemize
9641
9642@node Text_IO Facilities for Unbounded Strings
9643@subsection Text_IO Facilities for Unbounded Strings
9644@cindex Text_IO for unbounded strings
9645@cindex Unbounded_String, Text_IO operations
9646
9647@noindent
9648The package @code{Ada.Strings.Unbounded.Text_IO}
9649in library files @code{a-suteio.ads/adb} contains some GNAT-specific
9650subprograms useful for Text_IO operations on unbounded strings:
9651
9652@itemize @bullet
9653
9654@item function Get_Line (File : File_Type) return Unbounded_String;
9655Reads a line from the specified file
9656and returns the result as an unbounded string.
9657
9658@item procedure Put (File : File_Type; U : Unbounded_String);
9659Writes the value of the given unbounded string to the specified file
9660Similar to the effect of
9661@code{Put (To_String (U))} except that an extra copy is avoided.
9662
9663@item procedure Put_Line (File : File_Type; U : Unbounded_String);
9664Writes the value of the given unbounded string to the specified file,
9665followed by a @code{New_Line}.
9666Similar to the effect of @code{Put_Line (To_String (U))} except
9667that an extra copy is avoided.
9668@end itemize
9669
9670@noindent
9671In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
ad42149c 9672and is optional. If the parameter is omitted, then the standard input or
41af791f
GB
9673output file is referenced as appropriate.
9674
9675The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
ad42149c 9676files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended @code{Wide_Text_IO}
41af791f
GB
9677functionality for unbounded wide strings.
9678
9679@node Wide_Text_IO
9680@section Wide_Text_IO
9681
9682@noindent
9683@code{Wide_Text_IO} is similar in most respects to Text_IO, except that
9684both input and output files may contain special sequences that represent
ad42149c 9685wide character values. The encoding scheme for a given file may be
41af791f
GB
9686specified using a FORM parameter:
9687
9688@smallexample
9689WCEM=@var{x}
9690@end smallexample
9691
9692@noindent
9693as part of the FORM string (WCEM = wide character encoding method),
9694where @var{x} is one of the following characters
9695
9696@table @samp
9697@item h
9698Hex ESC encoding
9699@item u
9700Upper half encoding
9701@item s
9702Shift-JIS encoding
9703@item e
9704EUC Encoding
9705@item 8
9706UTF-8 encoding
9707@item b
9708Brackets encoding
9709@end table
9710
9711The encoding methods match those that
9712can be used in a source
9713program, but there is no requirement that the encoding method used for
9714the source program be the same as the encoding method used for files,
9715and different files may use different encoding methods.
9716
9717The default encoding method for the standard files, and for opened files
9718for which no WCEM parameter is given in the FORM string matches the
9719wide character encoding specified for the main program (the default
9720being brackets encoding if no coding method was specified with -gnatW).
9721
9722@table @asis
9723@item Hex Coding
9724In this encoding, a wide character is represented by a five character
9725sequence:
9726
9727@smallexample
9728ESC a b c d
9729@end smallexample
9730
9731where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
ad42149c 9732characters (using upper case letters) of the wide character code. For
41af791f 9733example, ESC A345 is used to represent the wide character with code
ad42149c 973416#A345#. This scheme is compatible with use of the full
41af791f
GB
9735@code{Wide_Character} set.
9736
9737@item Upper Half Coding
9738The wide character with encoding 16#abcd#, where the upper bit is on
46b58b8c 9739(i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
ad42149c
FW
974016#cd#. The second byte may never be a format control character, but is
9741not required to be in the upper half. This method can be also used for
41af791f
GB
9742shift-JIS or EUC where the internal coding matches the external coding.
9743
9744@item Shift JIS Coding
9745A wide character is represented by a two character sequence 16#ab# and
974616#cd#, with the restrictions described for upper half encoding as
ad42149c 9747described above. The internal character code is the corresponding JIS
41af791f 9748character according to the standard algorithm for Shift-JIS
ad42149c 9749conversion. Only characters defined in the JIS code set table can be
41af791f
GB
9750used with this encoding method.
9751
9752@item EUC Coding
9753A wide character is represented by a two character sequence 16#ab# and
ad42149c 975416#cd#, with both characters being in the upper half. The internal
41af791f 9755character code is the corresponding JIS character according to the EUC
ad42149c 9756encoding algorithm. Only characters defined in the JIS code set table
41af791f
GB
9757can be used with this encoding method.
9758
9759@item UTF-8 Coding
9760A wide character is represented using
9761UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
976210646-1/Am.2. Depending on the character value, the representation
9763is a one, two, or three byte sequence:
9764
9765@smallexample
976616#0000#-16#007f#: 2#0xxxxxxx#
976716#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
976816#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
9769@end smallexample
9770
9771where the xxx bits correspond to the left-padded bits of the
ad42149c 977216-bit character value. Note that all lower half ASCII characters
41af791f
GB
9773are represented as ASCII bytes and all upper half characters and
9774other wide characters are represented as sequences of upper-half
9775(The full UTF-8 scheme allows for encoding 31-bit characters as
97766-byte sequences, but in this implementation, all UTF-8 sequences
9777of four or more bytes length will raise a Constraint_Error, as
ad42149c 9778will all invalid UTF-8 sequences.)
41af791f
GB
9779
9780@item Brackets Coding
9781In this encoding, a wide character is represented by the following eight
9782character sequence:
9783
9784@smallexample
9785[ " a b c d " ]
9786@end smallexample
9787
9788Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
ad42149c 9789characters (using uppercase letters) of the wide character code. For
41af791f
GB
9790example, @code{["A345"]} is used to represent the wide character with code
9791@code{16#A345#}.
9792This scheme is compatible with use of the full Wide_Character set.
9793On input, brackets coding can also be used for upper half characters,
ad42149c 9794e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
41af791f
GB
9795is only used for wide characters with a code greater than @code{16#FF#}.
9796
9797@end table
9798
9799For the coding schemes other than Hex and Brackets encoding,
9800not all wide character
ad42149c 9801values can be represented. An attempt to output a character that cannot
41af791f 9802be represented using the encoding scheme for the file causes
ad42149c 9803Constraint_Error to be raised. An invalid wide character sequence on
41af791f
GB
9804input also causes Constraint_Error to be raised.
9805
9806@menu
9807* Wide_Text_IO Stream Pointer Positioning::
9808* Wide_Text_IO Reading and Writing Non-Regular Files::
9809@end menu
9810
9811@node Wide_Text_IO Stream Pointer Positioning
9812@subsection Stream Pointer Positioning
9813
9814@noindent
9815@code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
ad42149c 9816of stream pointer positioning (@pxref{Text_IO}). There is one additional
41af791f
GB
9817case:
9818
9819If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
46b58b8c 9820normal lower ASCII set (i.e.@: a character in the range:
41af791f
GB
9821
9822@smallexample
9823Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
9824@end smallexample
9825
9826@noindent
9827then although the logical position of the file pointer is unchanged by
9828the @code{Look_Ahead} call, the stream is physically positioned past the
ad42149c 9829wide character sequence. Again this is to avoid the need for buffering
41af791f
GB
9830or backup, and all @code{Wide_Text_IO} routines check the internal
9831indication that this situation has occurred so that this is not visible
ad42149c 9832to a normal program using @code{Wide_Text_IO}. However, this discrepancy
41af791f
GB
9833can be observed if the wide text file shares a stream with another file.
9834
9835@node Wide_Text_IO Reading and Writing Non-Regular Files
9836@subsection Reading and Writing Non-Regular Files
9837
9838@noindent
9839As in the case of Text_IO, when a non-regular file is read, it is
9840assumed that the file contains no page marks (any form characters are
9841treated as data characters), and @code{End_Of_Page} always returns
ad42149c 9842@code{False}. Similarly, the end of file indication is not sticky, so
41af791f
GB
9843it is possible to read beyond an end of file.
9844
9845@node Stream_IO
9846@section Stream_IO
9847
9848@noindent
9849A stream file is a sequence of bytes, where individual elements are
ad42149c
FW
9850written to the file as described in the Ada 95 reference manual. The type
9851@code{Stream_Element} is simply a byte. There are two ways to read or
41af791f
GB
9852write a stream file.
9853
9854@itemize @bullet
9855@item
9856The operations @code{Read} and @code{Write} directly read or write a
9857sequence of stream elements with no control information.
9858
9859@item
9860The stream attributes applied to a stream file transfer data in the
9861manner described for stream attributes.
9862@end itemize
9863
9864@node Shared Files
9865@section Shared Files
9866
9867@noindent
9868Section A.14 of the Ada 95 Reference Manual allows implementations to
9869provide a wide variety of behavior if an attempt is made to access the
9870same external file with two or more internal files.
9871
9872To provide a full range of functionality, while at the same time
9873minimizing the problems of portability caused by this implementation
9874dependence, GNAT handles file sharing as follows:
9875
9876@itemize @bullet
9877@item
9878In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
9879to open two or more files with the same full name is considered an error
ad42149c
FW
9880and is not supported. The exception @code{Use_Error} will be
9881raised. Note that a file that is not explicitly closed by the program
41af791f
GB
9882remains open until the program terminates.
9883
9884@item
9885If the form parameter @samp{shared=no} appears in the form string, the
9886file can be opened or created with its own separate stream identifier,
9887regardless of whether other files sharing the same external file are
ad42149c 9888opened. The exact effect depends on how the C stream routines handle
41af791f
GB
9889multiple accesses to the same external files using separate streams.
9890
9891@item
9892If the form parameter @samp{shared=yes} appears in the form string for
9893each of two or more files opened using the same full name, the same
9894stream is shared between these files, and the semantics are as described
9895in Ada 95 Reference Manual, Section A.14.
9896@end itemize
9897
9898When a program that opens multiple files with the same name is ported
9899from another Ada compiler to GNAT, the effect will be that
9900@code{Use_Error} is raised.
9901
9902The documentation of the original compiler and the documentation of the
9903program should then be examined to determine if file sharing was
9904expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
9905and @code{Create} calls as required.
9906
9907When a program is ported from GNAT to some other Ada compiler, no
9908special attention is required unless the @samp{shared=@var{xxx}} form
ad42149c 9909parameter is used in the program. In this case, you must examine the
41af791f 9910documentation of the new compiler to see if it supports the required
ad42149c 9911file sharing semantics, and form strings modified appropriately. Of
41af791f 9912course it may be the case that the program cannot be ported if the
ad42149c 9913target compiler does not support the required functionality. The best
41af791f
GB
9914approach in writing portable code is to avoid file sharing (and hence
9915the use of the @samp{shared=@var{xxx}} parameter in the form string)
9916completely.
9917
9918One common use of file sharing in Ada 83 is the use of instantiations of
9919Sequential_IO on the same file with different types, to achieve
ad42149c 9920heterogeneous input-output. Although this approach will work in GNAT if
41af791f
GB
9921@samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
9922for this purpose (using the stream attributes)
9923
9924@node Open Modes
9925@section Open Modes
9926
9927@noindent
9928@code{Open} and @code{Create} calls result in a call to @code{fopen}
9929using the mode shown in Table 6.1
9930
9931@sp 2
9932@center Table 6-1 @code{Open} and @code{Create} Call Modes
9933@smallexample
9934 @b{OPEN } @b{CREATE}
9935Append_File "r+" "w+"
9936In_File "r" "w+"
9937Out_File (Direct_IO) "r+" "w"
9938Out_File (all other cases) "w" "w"
9939Inout_File "r+" "w+"
9940@end smallexample
9941
9942If text file translation is required, then either @samp{b} or @samp{t}
ad42149c 9943is added to the mode, depending on the setting of Text. Text file
41af791f 9944translation refers to the mapping of CR/LF sequences in an external file
ad42149c 9945to LF characters internally. This mapping only occurs in DOS and
41af791f
GB
9946DOS-like systems, and is not relevant to other systems.
9947
ad42149c 9948A special case occurs with Stream_IO@. As shown in the above table, the
41af791f 9949file is initially opened in @samp{r} or @samp{w} mode for the
ad42149c 9950@code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
41af791f
GB
9951subsequently requires switching from reading to writing or vice-versa,
9952then the file is reopened in @samp{r+} mode to permit the required operation.
9953
9954@node Operations on C Streams
9955@section Operations on C Streams
9956The package @code{Interfaces.C_Streams} provides an Ada program with direct
9957access to the C library functions for operations on C streams:
9958
9959@smallexample
9960package Interfaces.C_Streams is
9961 -- Note: the reason we do not use the types that are in
9962 -- Interfaces.C is that we want to avoid dragging in the
9963 -- code in this unit if possible.
9964 subtype chars is System.Address;
9965 -- Pointer to null-terminated array of characters
9966 subtype FILEs is System.Address;
9967 -- Corresponds to the C type FILE*
9968 subtype voids is System.Address;
9969 -- Corresponds to the C type void*
9970 subtype int is Integer;
9971 subtype long is Long_Integer;
9972 -- Note: the above types are subtypes deliberately, and it
9973 -- is part of this spec that the above correspondences are
ad42149c
FW
9974 -- guaranteed. This means that it is legitimate to, for
9975 -- example, use Integer instead of int. We provide these
41af791f
GB
9976 -- synonyms for clarity, but in some cases it may be
9977 -- convenient to use the underlying types (for example to
9978 -- avoid an unnecessary dependency of a spec on the spec
9979 -- of this unit).
9980 type size_t is mod 2 ** Standard'Address_Size;
9981 NULL_Stream : constant FILEs;
9982 -- Value returned (NULL in C) to indicate an
9983 -- fdopen/fopen/tmpfile error
9984 ----------------------------------
9985 -- Constants Defined in stdio.h --
9986 ----------------------------------
9987 EOF : constant int;
9988 -- Used by a number of routines to indicate error or
9989 -- end of file
9990 IOFBF : constant int;
9991 IOLBF : constant int;
9992 IONBF : constant int;
9993 -- Used to indicate buffering mode for setvbuf call
9994 SEEK_CUR : constant int;
9995 SEEK_END : constant int;
9996 SEEK_SET : constant int;
9997 -- Used to indicate origin for fseek call
9998 function stdin return FILEs;
9999 function stdout return FILEs;
10000 function stderr return FILEs;
10001 -- Streams associated with standard files
10002 --------------------------
10003 -- Standard C functions --
10004 --------------------------
10005 -- The functions selected below are ones that are
10006 -- available in DOS, OS/2, UNIX and Xenix (but not
ad42149c
FW
10007 -- necessarily in ANSI C). These are very thin interfaces
10008 -- which copy exactly the C headers. For more
41af791f
GB
10009 -- documentation on these functions, see the Microsoft C
10010 -- "Run-Time Library Reference" (Microsoft Press, 1990,
10011 -- ISBN 1-55615-225-6), which includes useful information
10012 -- on system compatibility.
10013 procedure clearerr (stream : FILEs);
10014 function fclose (stream : FILEs) return int;
10015 function fdopen (handle : int; mode : chars) return FILEs;
10016 function feof (stream : FILEs) return int;
10017 function ferror (stream : FILEs) return int;
10018 function fflush (stream : FILEs) return int;
10019 function fgetc (stream : FILEs) return int;
10020 function fgets (strng : chars; n : int; stream : FILEs)
10021 return chars;
10022 function fileno (stream : FILEs) return int;
10023 function fopen (filename : chars; Mode : chars)
10024 return FILEs;
10025 -- Note: to maintain target independence, use
10026 -- text_translation_required, a boolean variable defined in
10027 -- a-sysdep.c to deal with the target dependent text
ad42149c 10028 -- translation requirement. If this variable is set,
41af791f
GB
10029 -- then b/t should be appended to the standard mode
10030 -- argument to set the text translation mode off or on
10031 -- as required.
10032 function fputc (C : int; stream : FILEs) return int;
10033 function fputs (Strng : chars; Stream : FILEs) return int;
10034 function fread
10035 (buffer : voids;
10036 size : size_t;
10037 count : size_t;
10038 stream : FILEs)
10039 return size_t;
10040 function freopen
10041 (filename : chars;
10042 mode : chars;
10043 stream : FILEs)
10044 return FILEs;
10045 function fseek
10046 (stream : FILEs;
10047 offset : long;
10048 origin : int)
10049 return int;
10050 function ftell (stream : FILEs) return long;
10051 function fwrite
10052 (buffer : voids;
10053 size : size_t;
10054 count : size_t;
10055 stream : FILEs)
10056 return size_t;
10057 function isatty (handle : int) return int;
10058 procedure mktemp (template : chars);
10059 -- The return value (which is just a pointer to template)
10060 -- is discarded
10061 procedure rewind (stream : FILEs);
10062 function rmtmp return int;
10063 function setvbuf
10064 (stream : FILEs;
10065 buffer : chars;
10066 mode : int;
10067 size : size_t)
10068 return int;
10069
10070 function tmpfile return FILEs;
10071 function ungetc (c : int; stream : FILEs) return int;
10072 function unlink (filename : chars) return int;
10073 ---------------------
10074 -- Extra functions --
10075 ---------------------
10076 -- These functions supply slightly thicker bindings than
ad42149c 10077 -- those above. They are derived from functions in the
41af791f
GB
10078 -- C Run-Time Library, but may do a bit more work than
10079 -- just directly calling one of the Library functions.
10080 function is_regular_file (handle : int) return int;
10081 -- Tests if given handle is for a regular file (result 1)
10082 -- or for a non-regular file (pipe or device, result 0).
10083 ---------------------------------
10084 -- Control of Text/Binary Mode --
10085 ---------------------------------
10086 -- If text_translation_required is true, then the following
10087 -- functions may be used to dynamically switch a file from
ad42149c
FW
10088 -- binary to text mode or vice versa. These functions have
10089 -- no effect if text_translation_required is false (i.e. in
10090 -- normal UNIX mode). Use fileno to get a stream handle.
41af791f
GB
10091 procedure set_binary_mode (handle : int);
10092 procedure set_text_mode (handle : int);
10093 ----------------------------
10094 -- Full Path Name support --
10095 ----------------------------
10096 procedure full_name (nam : chars; buffer : chars);
10097 -- Given a NUL terminated string representing a file
10098 -- name, returns in buffer a NUL terminated string
10099 -- representing the full path name for the file name.
10100 -- On systems where it is relevant the drive is also
ad42149c 10101 -- part of the full path name. It is the responsibility
41af791f 10102 -- of the caller to pass an actual parameter for buffer
ad42149c 10103 -- that is big enough for any full path name. Use
41af791f
GB
10104 -- max_path_len given below as the size of buffer.
10105 max_path_len : integer;
10106 -- Maximum length of an allowable full path name on the
10107 -- system, including a terminating NUL character.
10108end Interfaces.C_Streams;
10109@end smallexample
10110
10111@node Interfacing to C Streams
10112@section Interfacing to C Streams
10113
10114@noindent
10115The packages in this section permit interfacing Ada files to C Stream
10116operations.
10117
10118@smallexample
10119 with Interfaces.C_Streams;
10120 package Ada.Sequential_IO.C_Streams is
10121 function C_Stream (F : File_Type)
10122 return Interfaces.C_Streams.FILEs;
10123 procedure Open
10124 (File : in out File_Type;
10125 Mode : in File_Mode;
10126 C_Stream : in Interfaces.C_Streams.FILEs;
10127 Form : in String := "");
10128 end Ada.Sequential_IO.C_Streams;
10129
10130 with Interfaces.C_Streams;
10131 package Ada.Direct_IO.C_Streams is
10132 function C_Stream (F : File_Type)
10133 return Interfaces.C_Streams.FILEs;
10134 procedure Open
10135 (File : in out File_Type;
10136 Mode : in File_Mode;
10137 C_Stream : in Interfaces.C_Streams.FILEs;
10138 Form : in String := "");
10139 end Ada.Direct_IO.C_Streams;
10140
10141 with Interfaces.C_Streams;
10142 package Ada.Text_IO.C_Streams is
10143 function C_Stream (F : File_Type)
10144 return Interfaces.C_Streams.FILEs;
10145 procedure Open
10146 (File : in out File_Type;
10147 Mode : in File_Mode;
10148 C_Stream : in Interfaces.C_Streams.FILEs;
10149 Form : in String := "");
10150 end Ada.Text_IO.C_Streams;
10151
10152 with Interfaces.C_Streams;
10153 package Ada.Wide_Text_IO.C_Streams is
10154 function C_Stream (F : File_Type)
10155 return Interfaces.C_Streams.FILEs;
10156 procedure Open
10157 (File : in out File_Type;
10158 Mode : in File_Mode;
10159 C_Stream : in Interfaces.C_Streams.FILEs;
10160 Form : in String := "");
10161 end Ada.Wide_Text_IO.C_Streams;
10162
10163 with Interfaces.C_Streams;
10164 package Ada.Stream_IO.C_Streams is
10165 function C_Stream (F : File_Type)
10166 return Interfaces.C_Streams.FILEs;
10167 procedure Open
10168 (File : in out File_Type;
10169 Mode : in File_Mode;
10170 C_Stream : in Interfaces.C_Streams.FILEs;
10171 Form : in String := "");
10172 end Ada.Stream_IO.C_Streams;
10173@end smallexample
10174
10175In each of these five packages, the @code{C_Stream} function obtains the
ad42149c 10176@code{FILE} pointer from a currently opened Ada file. It is then
41af791f
GB
10177possible to use the @code{Interfaces.C_Streams} package to operate on
10178this stream, or the stream can be passed to a C program which can
ad42149c 10179operate on it directly. Of course the program is responsible for
41af791f
GB
10180ensuring that only appropriate sequences of operations are executed.
10181
10182One particular use of relevance to an Ada program is that the
10183@code{setvbuf} function can be used to control the buffering of the
ad42149c 10184stream used by an Ada file. In the absence of such a call the standard
41af791f
GB
10185default buffering is used.
10186
10187The @code{Open} procedures in these packages open a file giving an
ad42149c 10188existing C Stream instead of a file name. Typically this stream is
41af791f
GB
10189imported from a C program, allowing an Ada file to operate on an
10190existing C file.
10191
10192@node The GNAT Library
10193@chapter The GNAT Library
10194
10195@noindent
10196The GNAT library contains a number of general and special purpose packages.
10197It represents functionality that the GNAT developers have found useful, and
ad42149c 10198which is made available to GNAT users. The packages described here are fully
41af791f
GB
10199supported, and upwards compatibility will be maintained in future releases,
10200so you can use these facilities with the confidence that the same functionality
10201will be available in future releases.
10202
10203The chapter here simply gives a brief summary of the facilities available.
ad42149c 10204The full documentation is found in the spec file for the package. The full
41af791f 10205sources of these library packages, including both spec and body, are provided
ad42149c 10206with all GNAT releases. For example, to find out the full specifications of
41af791f 10207the SPITBOL pattern matching capability, including a full tutorial and
ad42149c 10208extensive examples, look in the @file{g-spipat.ads} file in the library.
41af791f
GB
10209
10210For each entry here, the package name (as it would appear in a @code{with}
10211clause) is given, followed by the name of the corresponding spec file in
ad42149c 10212parentheses. The packages are children in four hierarchies, @code{Ada},
41af791f
GB
10213@code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
10214GNAT-specific hierarchy.
10215
10216Note that an application program should only use packages in one of these
10217four hierarchies if the package is defined in the Ada Reference Manual,
10218or is listed in this section of the GNAT Programmers Reference Manual.
10219All other units should be considered internal implementation units and
ad42149c 10220should not be directly @code{with}'ed by application code. The use of
41af791f
GB
10221a @code{with} statement that references one of these internal implementation
10222units makes an application potentially dependent on changes in versions
10223of GNAT, and will generate a warning message.
10224
10225@menu
ad42149c 10226* Ada.Characters.Latin_9 (a-chlat9.ads)::
41af791f 10227* Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
ad42149c 10228* Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
41af791f
GB
10229* Ada.Command_Line.Remove (a-colire.ads)::
10230* Ada.Direct_IO.C_Streams (a-diocst.ads)::
10231* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
10232* Ada.Sequential_IO.C_Streams (a-siocst.ads)::
10233* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
10234* Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
10235* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
10236* Ada.Text_IO.C_Streams (a-tiocst.ads)::
10237* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
10238* GNAT.AWK (g-awk.ads)::
10239* GNAT.Bubble_Sort_A (g-busora.ads)::
10240* GNAT.Bubble_Sort_G (g-busorg.ads)::
10241* GNAT.Calendar (g-calend.ads)::
10242* GNAT.Calendar.Time_IO (g-catiio.ads)::
10243* GNAT.CRC32 (g-crc32.ads)::
10244* GNAT.Case_Util (g-casuti.ads)::
10245* GNAT.CGI (g-cgi.ads)::
10246* GNAT.CGI.Cookie (g-cgicoo.ads)::
10247* GNAT.CGI.Debug (g-cgideb.ads)::
10248* GNAT.Command_Line (g-comlin.ads)::
10249* GNAT.Current_Exception (g-curexc.ads)::
10250* GNAT.Debug_Pools (g-debpoo.ads)::
10251* GNAT.Debug_Utilities (g-debuti.ads)::
10252* GNAT.Directory_Operations (g-dirope.ads)::
10253* GNAT.Dynamic_Tables (g-dyntab.ads)::
10254* GNAT.Exception_Traces (g-exctra.ads)::
10255* GNAT.Expect (g-expect.ads)::
10256* GNAT.Float_Control (g-flocon.ads)::
10257* GNAT.Heap_Sort_A (g-hesora.ads)::
10258* GNAT.Heap_Sort_G (g-hesorg.ads)::
10259* GNAT.HTable (g-htable.ads)::
10260* GNAT.IO (g-io.ads)::
10261* GNAT.IO_Aux (g-io_aux.ads)::
10262* GNAT.Lock_Files (g-locfil.ads)::
ad42149c 10263* GNAT.MD5 (g-md5.ads)::
41af791f
GB
10264* GNAT.Most_Recent_Exception (g-moreex.ads)::
10265* GNAT.OS_Lib (g-os_lib.ads)::
10266* GNAT.Regexp (g-regexp.ads)::
10267* GNAT.Registry (g-regist.ads)::
10268* GNAT.Regpat (g-regpat.ads)::
10269* GNAT.Sockets (g-socket.ads)::
10270* GNAT.Source_Info (g-souinf.ads)::
10271* GNAT.Spell_Checker (g-speche.ads)::
10272* GNAT.Spitbol.Patterns (g-spipat.ads)::
10273* GNAT.Spitbol (g-spitbo.ads)::
10274* GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
10275* GNAT.Spitbol.Table_Integer (g-sptain.ads)::
10276* GNAT.Spitbol.Table_VString (g-sptavs.ads)::
10277* GNAT.Table (g-table.ads)::
10278* GNAT.Task_Lock (g-tasloc.ads)::
10279* GNAT.Threads (g-thread.ads)::
10280* GNAT.Traceback (g-traceb.ads)::
10281* GNAT.Traceback.Symbolic (g-trasym.ads)::
10282* Interfaces.C.Extensions (i-cexten.ads)::
10283* Interfaces.C.Streams (i-cstrea.ads)::
10284* Interfaces.CPP (i-cpp.ads)::
10285* Interfaces.Os2lib (i-os2lib.ads)::
10286* Interfaces.Os2lib.Errors (i-os2err.ads)::
10287* Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
10288* Interfaces.Os2lib.Threads (i-os2thr.ads)::
10289* Interfaces.Packed_Decimal (i-pacdec.ads)::
10290* Interfaces.VxWorks (i-vxwork.ads)::
ad42149c 10291* Interfaces.VxWorks.IO (i-vxwoio.ads)::
41af791f
GB
10292* System.Address_Image (s-addima.ads)::
10293* System.Assertions (s-assert.ads)::
10294* System.Partition_Interface (s-parint.ads)::
10295* System.Task_Info (s-tasinf.ads)::
10296* System.Wch_Cnv (s-wchcnv.ads)::
10297* System.Wch_Con (s-wchcon.ads)::
10298@end menu
10299
ad42149c
FW
10300@node Ada.Characters.Latin_9 (a-chlat9.ads)
10301@section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
10302@cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
10303@cindex Latin_9 constants for Character
10304
10305@noindent
10306This child of @code{Ada.Characters}
10307provides a set of definitions corresponding to those in the
10308RM-defined package @code{Ada.Characters.Latin_1} but with the
10309few modifications required for @code{Latin-9}
10310The provision of such a package
10311is specifically authorized by the Ada Reference Manual
10312(RM A.3(27)).
10313
41af791f 10314@node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
ad42149c
FW
10315@section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
10316@cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
10317@cindex Latin_1 constants for Wide_Character
41af791f
GB
10318
10319@noindent
10320This child of @code{Ada.Characters}
10321provides a set of definitions corresponding to those in the
10322RM-defined package @code{Ada.Characters.Latin_1} but with the
10323types of the constants being @code{Wide_Character}
ad42149c
FW
10324instead of @code{Character}. The provision of such a package
10325is specifically authorized by the Ada Reference Manual
10326(RM A.3(27)).
10327
10328@node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
10329@section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
10330@cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
10331@cindex Latin_9 constants for Wide_Character
10332
10333@noindent
10334This child of @code{Ada.Characters}
10335provides a set of definitions corresponding to those in the
10336GNAT defined package @code{Ada.Characters.Latin_9} but with the
10337types of the constants being @code{Wide_Character}
10338instead of @code{Character}. The provision of such a package
41af791f
GB
10339is specifically authorized by the Ada Reference Manual
10340(RM A.3(27)).
10341
10342@node Ada.Command_Line.Remove (a-colire.ads)
ad42149c
FW
10343@section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
10344@cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
10345@cindex Removing command line arguments
10346@cindex Command line, argument removal
41af791f
GB
10347
10348@noindent
10349This child of @code{Ada.Command_Line}
10350provides a mechanism for logically removing
ad42149c 10351arguments from the argument list. Once removed, an argument is not visible
41af791f
GB
10352to further calls on the subprograms in @code{Ada.Command_Line} will not
10353see the removed argument.
10354
10355@node Ada.Direct_IO.C_Streams (a-diocst.ads)
ad42149c
FW
10356@section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
10357@cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
10358@cindex C Streams, Interfacing with Direct_IO
41af791f
GB
10359
10360@noindent
10361This package provides subprograms that allow interfacing between
ad42149c 10362C streams and @code{Direct_IO}. The stream identifier can be
41af791f
GB
10363extracted from a file opened on the Ada side, and an Ada file
10364can be constructed from a stream opened on the C side.
10365
10366@node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
ad42149c
FW
10367@section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
10368@cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
10369@cindex Null_Occurrence, testing for
41af791f
GB
10370
10371@noindent
10372This child subprogram provides a way of testing for the null
10373exception occurrence (@code{Null_Occurrence}) without raising
10374an exception.
10375
10376@node Ada.Sequential_IO.C_Streams (a-siocst.ads)
ad42149c
FW
10377@section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
10378@cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
10379@cindex C Streams, Interfacing with Sequential_IO
41af791f
GB
10380
10381@noindent
10382This package provides subprograms that allow interfacing between
ad42149c 10383C streams and @code{Sequential_IO}. The stream identifier can be
41af791f
GB
10384extracted from a file opened on the Ada side, and an Ada file
10385can be constructed from a stream opened on the C side.
10386
10387@node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
ad42149c
FW
10388@section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
10389@cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
10390@cindex C Streams, Interfacing with Stream_IO
41af791f
GB
10391
10392@noindent
10393This package provides subprograms that allow interfacing between
ad42149c 10394C streams and @code{Stream_IO}. The stream identifier can be
41af791f
GB
10395extracted from a file opened on the Ada side, and an Ada file
10396can be constructed from a stream opened on the C side.
10397
10398@node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
ad42149c
FW
10399@section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
10400@cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
10401@cindex @code{Unbounded_String}, IO support
10402@cindex @code{Text_IO}, extensions for unbounded strings
41af791f
GB
10403
10404@noindent
10405This package provides subprograms for Text_IO for unbounded
10406strings, avoiding the necessity for an intermediate operation
10407with ordinary strings.
10408
10409@node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
ad42149c
FW
10410@section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
10411@cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
10412@cindex @code{Unbounded_Wide_String}, IO support
10413@cindex @code{Text_IO}, extensions for unbounded wide strings
41af791f
GB
10414
10415@noindent
10416This package provides subprograms for Text_IO for unbounded
10417wide strings, avoiding the necessity for an intermediate operation
10418with ordinary wide strings.
10419
10420@node Ada.Text_IO.C_Streams (a-tiocst.ads)
ad42149c
FW
10421@section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
10422@cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
10423@cindex C Streams, Interfacing with @code{Text_IO}
41af791f
GB
10424
10425@noindent
10426This package provides subprograms that allow interfacing between
ad42149c 10427C streams and @code{Text_IO}. The stream identifier can be
41af791f
GB
10428extracted from a file opened on the Ada side, and an Ada file
10429can be constructed from a stream opened on the C side.
10430
10431@node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
ad42149c
FW
10432@section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
10433@cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
10434@cindex C Streams, Interfacing with @code{Wide_Text_IO}
41af791f
GB
10435
10436@noindent
10437This package provides subprograms that allow interfacing between
ad42149c 10438C streams and @code{Wide_Text_IO}. The stream identifier can be
41af791f
GB
10439extracted from a file opened on the Ada side, and an Ada file
10440can be constructed from a stream opened on the C side.
10441
10442@node GNAT.AWK (g-awk.ads)
ad42149c
FW
10443@section @code{GNAT.AWK} (@file{g-awk.ads})
10444@cindex @code{GNAT.AWK} (@file{g-awk.ads})
41af791f 10445@cindex Parsing
ad42149c 10446@cindex AWK
41af791f
GB
10447
10448@noindent
10449Provides AWK-like parsing functions, with an easy interface for parsing one
ad42149c 10450or more files containing formatted data. The file is viewed as a database
41af791f
GB
10451where each record is a line and a field is a data element in this line.
10452
10453@node GNAT.Bubble_Sort_A (g-busora.ads)
ad42149c
FW
10454@section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
10455@cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
41af791f 10456@cindex Sorting
ad42149c 10457@cindex Bubble sort
41af791f
GB
10458
10459@noindent
10460Provides a general implementation of bubble sort usable for sorting arbitrary
ad42149c 10461data items. Move and comparison procedures are provided by passing
41af791f
GB
10462access-to-procedure values.
10463
10464@node GNAT.Bubble_Sort_G (g-busorg.ads)
ad42149c
FW
10465@section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
10466@cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
41af791f 10467@cindex Sorting
ad42149c 10468@cindex Bubble sort
41af791f
GB
10469
10470@noindent
10471Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
10472are provided as generic parameters, this improves efficiency, especially
10473if the procedures can be inlined, at the expense of duplicating code for
10474multiple instantiations.
10475
10476@node GNAT.Calendar (g-calend.ads)
ad42149c
FW
10477@section @code{GNAT.Calendar} (@file{g-calend.ads})
10478@cindex @code{GNAT.Calendar} (@file{g-calend.ads})
10479@cindex @code{Calendar}
41af791f
GB
10480
10481@noindent
10482Extends the facilities provided by @code{Ada.Calendar} to include handling
10483of days of the week, an extended @code{Split} and @code{Time_Of} capability.
10484Also provides conversion of @code{Ada.Calendar.Time} values to and from the
10485C @code{timeval} format.
10486
10487@node GNAT.Calendar.Time_IO (g-catiio.ads)
ad42149c
FW
10488@section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
10489@cindex @code{Calendar}
41af791f 10490@cindex Time
ad42149c 10491@cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
41af791f
GB
10492
10493@node GNAT.CRC32 (g-crc32.ads)
ad42149c
FW
10494@section @code{GNAT.CRC32} (@file{g-crc32.ads})
10495@cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
41af791f 10496@cindex CRC32
ad42149c 10497@cindex Cyclic Redundancy Check
41af791f
GB
10498
10499@noindent
ad42149c 10500This package implements the CRC-32 algorithm. For a full description
41af791f 10501of this algorithm you should have a look at:
ad42149c
FW
10502``Computation of Cyclic Redundancy Checks via Table Look-Up'', @cite{Communications
10503of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013, Aug.@: 1988. Sarwate, D.V@.
41af791f
GB
10504
10505@noindent
10506Provides an extended capability for formatted output of time values with
ad42149c 10507full user control over the format. Modeled on the GNU Date specification.
41af791f
GB
10508
10509@node GNAT.Case_Util (g-casuti.ads)
ad42149c
FW
10510@section @code{GNAT.Case_Util} (@file{g-casuti.ads})
10511@cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
41af791f 10512@cindex Casing utilities
ad42149c 10513@cindex Character handling (@code{GNAT.Case_Util})
41af791f
GB
10514
10515@noindent
10516A set of simple routines for handling upper and lower casing of strings
10517without the overhead of the full casing tables
10518in @code{Ada.Characters.Handling}.
10519
10520@node GNAT.CGI (g-cgi.ads)
ad42149c
FW
10521@section @code{GNAT.CGI} (@file{g-cgi.ads})
10522@cindex @code{GNAT.CGI} (@file{g-cgi.ads})
41af791f
GB
10523@cindex CGI (Common Gateway Interface)
10524
10525@noindent
10526This is a package for interfacing a GNAT program with a Web server via the
ad42149c
FW
10527Common Gateway Interface (CGI)@. Basically this package parses the CGI
10528parameters, which are a set of key/value pairs sent by the Web server. It
41af791f
GB
10529builds a table whose index is the key and provides some services to deal
10530with this table.
10531
10532@node GNAT.CGI.Cookie (g-cgicoo.ads)
ad42149c
FW
10533@section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
10534@cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
10535@cindex CGI (Common Gateway Interface) cookie support
10536@cindex Cookie support in CGI
41af791f
GB
10537
10538@noindent
10539This is a package to interface a GNAT program with a Web server via the
ad42149c 10540Common Gateway Interface (CGI). It exports services to deal with Web
41af791f
GB
10541cookies (piece of information kept in the Web client software).
10542
10543@node GNAT.CGI.Debug (g-cgideb.ads)
ad42149c
FW
10544@section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
10545@cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
41af791f
GB
10546@cindex CGI (Common Gateway Interface) debugging
10547
10548@noindent
10549This is a package to help debugging CGI (Common Gateway Interface)
10550programs written in Ada.
10551
10552@node GNAT.Command_Line (g-comlin.ads)
ad42149c
FW
10553@section @code{GNAT.Command_Line} (@file{g-comlin.ads})
10554@cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
41af791f
GB
10555@cindex Command line
10556
10557@noindent
10558Provides a high level interface to @code{Ada.Command_Line} facilities,
10559including the ability to scan for named switches with optional parameters
10560and expand file names using wild card notations.
10561
10562@node GNAT.Current_Exception (g-curexc.ads)
ad42149c
FW
10563@section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
10564@cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
41af791f
GB
10565@cindex Current exception
10566@cindex Exception retrieval
10567
10568@noindent
10569Provides access to information on the current exception that has been raised
10570without the need for using the Ada-95 exception choice parameter specification
ad42149c 10571syntax. This is particularly useful in simulating typical facilities for
41af791f
GB
10572obtaining information about exceptions provided by Ada 83 compilers.
10573
10574@node GNAT.Debug_Pools (g-debpoo.ads)
ad42149c
FW
10575@section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
10576@cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
41af791f 10577@cindex Debugging
ad42149c
FW
10578@cindex Debug pools
10579@cindex Memory corruption debugging
41af791f
GB
10580
10581@noindent
10582Provide a debugging storage pools that helps tracking memory corruption
ad42149c
FW
10583problems. See section ``Finding memory problems with GNAT Debug Pool'' in
10584the @cite{GNAT User's Guide}.
41af791f
GB
10585
10586@node GNAT.Debug_Utilities (g-debuti.ads)
ad42149c
FW
10587@section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
10588@cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
41af791f
GB
10589@cindex Debugging
10590
10591@noindent
10592Provides a few useful utilities for debugging purposes, including conversion
10593to and from string images of address values.
10594
10595@node GNAT.Directory_Operations (g-dirope.ads)
ad42149c
FW
10596@section @code{GNAT.Directory_Operations} (g-dirope.ads)
10597@cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
41af791f
GB
10598@cindex Directory operations
10599
10600@noindent
10601Provides a set of routines for manipulating directories, including changing
10602the current directory, making new directories, and scanning the files in a
10603directory.
10604
10605@node GNAT.Dynamic_Tables (g-dyntab.ads)
ad42149c
FW
10606@section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
10607@cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
41af791f
GB
10608@cindex Table implementation
10609@cindex Arrays, extendable
10610
10611@noindent
10612A generic package providing a single dimension array abstraction where the
10613length of the array can be dynamically modified.
10614
10615@noindent
10616This package provides a facility similar to that of GNAT.Table, except
10617that this package declares a type that can be used to define dynamic
10618instances of the table, while an instantiation of GNAT.Table creates a
10619single instance of the table type.
10620
10621@node GNAT.Exception_Traces (g-exctra.ads)
ad42149c
FW
10622@section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
10623@cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
41af791f
GB
10624@cindex Exception traces
10625@cindex Debugging
10626
10627@noindent
10628Provides an interface allowing to control automatic output upon exception
10629occurrences.
10630
10631@node GNAT.Expect (g-expect.ads)
ad42149c
FW
10632@section @code{GNAT.Expect} (@file{g-expect.ads})
10633@cindex @code{GNAT.Expect} (@file{g-expect.ads})
41af791f
GB
10634
10635@noindent
10636Provides a set of subprograms similar to what is available
10637with the standard Tcl Expect tool.
10638It allows you to easily spawn and communicate with an external process.
10639You can send commands or inputs to the process, and compare the output
10640with some expected regular expression.
10641Currently GNAT.Expect is implemented on all native GNAT ports except for
ad42149c 10642OpenVMS@. It is not implemented for cross ports, and in particular is not
46b58b8c 10643implemented for VxWorks or LynxOS@.
41af791f
GB
10644
10645@node GNAT.Float_Control (g-flocon.ads)
ad42149c
FW
10646@section @code{GNAT.Float_Control} (@file{g-flocon.ads})
10647@cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
41af791f
GB
10648@cindex Floating-Point Processor
10649
10650@noindent
10651Provides an interface for resetting the floating-point processor into the
ad42149c 10652mode required for correct semantic operation in Ada. Some third party
41af791f
GB
10653library calls may cause this mode to be modified, and the Reset procedure
10654in this package can be used to reestablish the required mode.
10655
10656@node GNAT.Heap_Sort_A (g-hesora.ads)
ad42149c
FW
10657@section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
10658@cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
41af791f
GB
10659@cindex Sorting
10660
10661@noindent
10662Provides a general implementation of heap sort usable for sorting arbitrary
ad42149c
FW
10663data items. Move and comparison procedures are provided by passing
10664access-to-procedure values. The algorithm used is a modified heap sort
41af791f
GB
10665that performs approximately N*log(N) comparisons in the worst case.
10666
10667@node GNAT.Heap_Sort_G (g-hesorg.ads)
ad42149c
FW
10668@section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
10669@cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
41af791f
GB
10670@cindex Sorting
10671
10672@noindent
10673Similar to @code{Heap_Sort_A} except that the move and sorting procedures
10674are provided as generic parameters, this improves efficiency, especially
10675if the procedures can be inlined, at the expense of duplicating code for
10676multiple instantiations.
10677
10678@node GNAT.HTable (g-htable.ads)
ad42149c
FW
10679@section @code{GNAT.HTable} (@file{g-htable.ads})
10680@cindex @code{GNAT.HTable} (@file{g-htable.ads})
41af791f
GB
10681@cindex Hash tables
10682
10683@noindent
10684A generic implementation of hash tables that can be used to hash arbitrary
ad42149c 10685data. Provides two approaches, one a simple static approach, and the other
41af791f
GB
10686allowing arbitrary dynamic hash tables.
10687
10688@node GNAT.IO (g-io.ads)
ad42149c
FW
10689@section @code{GNAT.IO} (@file{g-io.ads})
10690@cindex @code{GNAT.IO} (@file{g-io.ads})
41af791f
GB
10691@cindex Simple I/O
10692@cindex Input/Output facilities
10693
10694@noindent
10695A simple preealborable input-output package that provides a subset of
10696simple Text_IO functions for reading characters and strings from
10697Standard_Input, and writing characters, strings and integers to either
10698Standard_Output or Standard_Error.
10699
10700@node GNAT.IO_Aux (g-io_aux.ads)
ad42149c
FW
10701@section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
10702@cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
41af791f
GB
10703@cindex Text_IO
10704@cindex Input/Output facilities
10705
10706Provides some auxiliary functions for use with Text_IO, including a test
10707for whether a file exists, and functions for reading a line of text.
10708
10709@node GNAT.Lock_Files (g-locfil.ads)
ad42149c
FW
10710@section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
10711@cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
41af791f
GB
10712@cindex File locking
10713@cindex Locking using files
10714
10715@noindent
ad42149c 10716Provides a general interface for using files as locks. Can be used for
41af791f
GB
10717providing program level synchronization.
10718
ad42149c
FW
10719@node GNAT.MD5 (g-md5.ads)
10720@section @code{GNAT.MD5} (@file{g-md5.ads})
10721@cindex @code{GNAT.MD5} (@file{g-md5.ads})
10722@cindex Message Digest MD5
10723
10724@noindent
10725Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
10726
41af791f 10727@node GNAT.Most_Recent_Exception (g-moreex.ads)
ad42149c
FW
10728@section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
10729@cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
41af791f
GB
10730@cindex Exception, obtaining most recent
10731
10732@noindent
ad42149c 10733Provides access to the most recently raised exception. Can be used for
41af791f
GB
10734various logging purposes, including duplicating functionality of some
10735Ada 83 implementation dependent extensions.
10736
10737@node GNAT.OS_Lib (g-os_lib.ads)
ad42149c
FW
10738@section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
10739@cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
41af791f
GB
10740@cindex Operating System interface
10741@cindex Spawn capability
10742
10743@noindent
10744Provides a range of target independent operating system interface functions,
10745including time/date management, file operations, subprocess management,
10746including a portable spawn procedure, and access to environment variables
10747and error return codes.
10748
10749@node GNAT.Regexp (g-regexp.ads)
ad42149c
FW
10750@section @code{GNAT.Regexp} (@file{g-regexp.ads})
10751@cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
41af791f
GB
10752@cindex Regular expressions
10753@cindex Pattern matching
10754
10755@noindent
10756A simple implementation of regular expressions, using a subset of regular
ad42149c 10757expression syntax copied from familiar Unix style utilities. This is the
41af791f 10758simples of the three pattern matching packages provided, and is particularly
ad42149c 10759suitable for ``file globbing'' applications.
41af791f
GB
10760
10761@node GNAT.Registry (g-regist.ads)
ad42149c
FW
10762@section @code{GNAT.Registry} (@file{g-regist.ads})
10763@cindex @code{GNAT.Registry} (@file{g-regist.ads})
41af791f
GB
10764@cindex Windows Registry
10765
10766@noindent
ad42149c
FW
10767This is a high level binding to the Windows registry. It is possible to
10768do simple things like reading a key value, creating a new key. For full
41af791f
GB
10769registry API, but at a lower level of abstraction, refer to the Win32.Winreg
10770package provided with the Win32Ada binding
10771
10772@node GNAT.Regpat (g-regpat.ads)
ad42149c
FW
10773@section @code{GNAT.Regpat} (@file{g-regpat.ads})
10774@cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
41af791f
GB
10775@cindex Regular expressions
10776@cindex Pattern matching
10777
10778@noindent
10779A complete implementation of Unix-style regular expression matching, copied
10780from the original V7 style regular expression library written in C by
10781Henry Spencer (and binary compatible with this C library).
10782
10783@node GNAT.Sockets (g-socket.ads)
ad42149c
FW
10784@section @code{GNAT.Sockets} (@file{g-socket.ads})
10785@cindex @code{GNAT.Sockets} (@file{g-socket.ads})
41af791f
GB
10786@cindex Sockets
10787
10788@noindent
10789A high level and portable interface to develop sockets based applications.
10790This package is based on the sockets thin binding found in GNAT.Sockets.Thin.
10791Currently GNAT.Sockets is implemented on all native GNAT ports except for
ad42149c 10792OpenVMS@. It is not implemented for the LynxOS@ cross port.
41af791f
GB
10793
10794@node GNAT.Source_Info (g-souinf.ads)
ad42149c
FW
10795@section @code{GNAT.Source_Info} (@file{g-souinf.ads})
10796@cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
41af791f
GB
10797@cindex Source Information
10798
10799@noindent
10800Provides subprograms that give access to source code information known at
10801compile time, such as the current file name and line number.
10802
10803@node GNAT.Spell_Checker (g-speche.ads)
ad42149c
FW
10804@section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
10805@cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
41af791f
GB
10806@cindex Spell checking
10807
10808@noindent
10809Provides a function for determining whether one string is a plausible
10810near misspelling of another string.
10811
10812@node GNAT.Spitbol.Patterns (g-spipat.ads)
ad42149c
FW
10813@section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
10814@cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
41af791f
GB
10815@cindex SPITBOL pattern matching
10816@cindex Pattern matching
10817
10818@noindent
ad42149c
FW
10819A complete implementation of SNOBOL4 style pattern matching. This is the
10820most elaborate of the pattern matching packages provided. It fully duplicates
41af791f
GB
10821the SNOBOL4 dynamic pattern construction and matching capabilities, using the
10822efficient algorithm developed by Robert Dewar for the SPITBOL system.
10823
10824@node GNAT.Spitbol (g-spitbo.ads)
ad42149c
FW
10825@section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
10826@cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
41af791f
GB
10827@cindex SPITBOL interface
10828
10829@noindent
10830The top level package of the collection of SPITBOL-style functionality, this
10831package provides basic SNOBOL4 string manipulation functions, such as
10832Pad, Reverse, Trim, Substr capability, as well as a generic table function
10833useful for constructing arbitrary mappings from strings in the style of
10834the SNOBOL4 TABLE function.
10835
10836@node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
ad42149c
FW
10837@section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
10838@cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
41af791f
GB
10839@cindex Sets of strings
10840@cindex SPITBOL Tables
10841
10842@noindent
10843A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10844for type @code{Standard.Boolean}, giving an implementation of sets of
10845string values.
10846
10847@node GNAT.Spitbol.Table_Integer (g-sptain.ads)
ad42149c
FW
10848@section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
10849@cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
41af791f
GB
10850@cindex Integer maps
10851@cindex Maps
10852@cindex SPITBOL Tables
10853
10854@noindent
10855A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
10856for type @code{Standard.Integer}, giving an implementation of maps
10857from string to integer values.
10858
10859@node GNAT.Spitbol.Table_VString (g-sptavs.ads)
ad42149c
FW
10860@section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
10861@cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
41af791f
GB
10862@cindex String maps
10863@cindex Maps
10864@cindex SPITBOL Tables
10865
10866@noindent
10867A library level of instantiation of GNAT.Spitbol.Patterns.Table for
10868a variable length string type, giving an implementation of general
10869maps from strings to strings.
10870
10871@node GNAT.Table (g-table.ads)
ad42149c
FW
10872@section @code{GNAT.Table} (@file{g-table.ads})
10873@cindex @code{GNAT.Table} (@file{g-table.ads})
41af791f
GB
10874@cindex Table implementation
10875@cindex Arrays, extendable
10876
10877@noindent
10878A generic package providing a single dimension array abstraction where the
10879length of the array can be dynamically modified.
10880
10881@noindent
10882This package provides a facility similar to that of GNAT.Dynamic_Tables,
10883except that this package declares a single instance of the table type,
10884while an instantiation of GNAT.Dynamic_Tables creates a type that can be
10885used to define dynamic instances of the table.
10886
10887@node GNAT.Task_Lock (g-tasloc.ads)
ad42149c
FW
10888@section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
10889@cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
41af791f
GB
10890@cindex Task synchronization
10891@cindex Task locking
10892@cindex Locking
10893
10894@noindent
10895A very simple facility for locking and unlocking sections of code using a
ad42149c 10896single global task lock. Appropriate for use in situations where contention
41af791f
GB
10897between tasks is very rarely expected.
10898
10899@node GNAT.Threads (g-thread.ads)
ad42149c
FW
10900@section @code{GNAT.Threads} (@file{g-thread.ads})
10901@cindex @code{GNAT.Threads} (@file{g-thread.ads})
41af791f
GB
10902@cindex Foreign threads
10903@cindex Threads, foreign
10904
10905@noindent
10906Provides facilities for creating and destroying threads with explicit calls.
ad42149c 10907These threads are known to the GNAT run-time system. These subprograms are
41af791f
GB
10908exported C-convention procedures intended to be called from foreign code.
10909By using these primitives rather than directly calling operating systems
10910routines, compatibility with the Ada tasking runt-time is provided.
10911
10912@node GNAT.Traceback (g-traceb.ads)
ad42149c
FW
10913@section @code{GNAT.Traceback} (@file{g-traceb.ads})
10914@cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
41af791f
GB
10915@cindex Trace back facilities
10916
10917@noindent
10918Provides a facility for obtaining non-symbolic traceback information, useful
10919in various debugging situations.
10920
10921@node GNAT.Traceback.Symbolic (g-trasym.ads)
ad42149c
FW
10922@section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
10923@cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
41af791f
GB
10924@cindex Trace back facilities
10925
10926@noindent
10927Provides symbolic traceback information that includes the subprogram
10928name and line number information.
10929
10930@node Interfaces.C.Extensions (i-cexten.ads)
ad42149c
FW
10931@section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
10932@cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
41af791f
GB
10933
10934@noindent
10935This package contains additional C-related definitions, intended
10936for use with either manually or automatically generated bindings
10937to C libraries.
10938
10939@node Interfaces.C.Streams (i-cstrea.ads)
ad42149c
FW
10940@section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
10941@cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
41af791f
GB
10942@cindex C streams, interfacing
10943
10944@noindent
10945This package is a binding for the most commonly used operations
10946on C streams.
10947
10948@node Interfaces.CPP (i-cpp.ads)
ad42149c
FW
10949@section @code{Interfaces.CPP} (@file{i-cpp.ads})
10950@cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
41af791f
GB
10951@cindex C++ interfacing
10952@cindex Interfacing, to C++
10953
10954@noindent
ad42149c 10955This package provides facilities for use in interfacing to C++. It
41af791f
GB
10956is primarily intended to be used in connection with automated tools
10957for the generation of C++ interfaces.
10958
10959@node Interfaces.Os2lib (i-os2lib.ads)
ad42149c
FW
10960@section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
10961@cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
41af791f
GB
10962@cindex Interfacing, to OS/2
10963@cindex OS/2 interfacing
10964
10965@noindent
10966This package provides interface definitions to the OS/2 library.
10967It is a thin binding which is a direct translation of the
10968various @file{<bse@.h>} files.
10969
10970@node Interfaces.Os2lib.Errors (i-os2err.ads)
ad42149c
FW
10971@section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
10972@cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
41af791f
GB
10973@cindex OS/2 Error codes
10974@cindex Interfacing, to OS/2
10975@cindex OS/2 interfacing
10976
10977@noindent
10978This package provides definitions of the OS/2 error codes.
10979
10980@node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
ad42149c
FW
10981@section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
10982@cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
41af791f
GB
10983@cindex Interfacing, to OS/2
10984@cindex Synchronization, OS/2
10985@cindex OS/2 synchronization primitives
10986
10987@noindent
10988This is a child package that provides definitions for interfacing
10989to the @code{OS/2} synchronization primitives.
10990
10991@node Interfaces.Os2lib.Threads (i-os2thr.ads)
ad42149c
FW
10992@section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
10993@cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
41af791f
GB
10994@cindex Interfacing, to OS/2
10995@cindex Thread control, OS/2
10996@cindex OS/2 thread interfacing
10997
10998@noindent
10999This is a child package that provides definitions for interfacing
11000to the @code{OS/2} thread primitives.
11001
11002@node Interfaces.Packed_Decimal (i-pacdec.ads)
ad42149c
FW
11003@section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
11004@cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
41af791f
GB
11005@cindex IBM Packed Format
11006@cindex Packed Decimal
11007
11008@noindent
11009This package provides a set of routines for conversions to and
11010from a packed decimal format compatible with that used on IBM
11011mainframes.
11012
11013@node Interfaces.VxWorks (i-vxwork.ads)
ad42149c
FW
11014@section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
11015@cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
41af791f
GB
11016@cindex Interfacing to VxWorks
11017@cindex VxWorks, interfacing
11018
11019@noindent
ad42149c 11020This package provides a limited binding to the VxWorks API.
41af791f 11021In particular, it interfaces with the
ad42149c
FW
11022VxWorks hardware interrupt facilities.
11023
11024@node Interfaces.VxWorks.IO (i-vxwoio.ads)
11025@section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
11026@cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
11027@cindex Interfacing to VxWorks' I/O
11028@cindex VxWorks, I/O interfacing
11029@cindex VxWorks, Get_Immediate
11030
11031@noindent
11032This package provides a limited binding to the VxWorks' I/O API.
11033In particular, it provides procedures that enable the use of
11034Get_Immediate under VxWorks.
41af791f
GB
11035
11036@node System.Address_Image (s-addima.ads)
ad42149c
FW
11037@section @code{System.Address_Image} (@file{s-addima.ads})
11038@cindex @code{System.Address_Image} (@file{s-addima.ads})
41af791f
GB
11039@cindex Address image
11040@cindex Image, of an address
11041
11042@noindent
11043This function provides a useful debugging
11044function that gives an (implementation dependent)
11045string which identifies an address.
11046
11047@node System.Assertions (s-assert.ads)
ad42149c
FW
11048@section @code{System.Assertions} (@file{s-assert.ads})
11049@cindex @code{System.Assertions} (@file{s-assert.ads})
11050@cindex Assertions
11051@cindex Assert_Failure, exception
41af791f
GB
11052
11053@noindent
11054This package provides the declaration of the exception raised
11055by an run-time assertion failure, as well as the routine that
11056is used internally to raise this assertion.
11057
11058@node System.Partition_Interface (s-parint.ads)
ad42149c
FW
11059@section @code{System.Partition_Interface} (@file{s-parint.ads})
11060@cindex @code{System.Partition_Interface} (@file{s-parint.ads})
41af791f
GB
11061@cindex Partition intefacing functions
11062
11063@noindent
ad42149c 11064This package provides facilities for partition interfacing. It
41af791f
GB
11065is used primarily in a distribution context when using Annex E
11066with @code{GLADE}.
11067
11068@node System.Task_Info (s-tasinf.ads)
ad42149c
FW
11069@section @code{System.Task_Info} (@file{s-tasinf.ads})
11070@cindex @code{System.Task_Info} (@file{s-tasinf.ads})
11071@cindex Task_Info pragma
41af791f
GB
11072
11073@noindent
11074This package provides target dependent functionality that is used
11075to support the @code{Task_Info} pragma
11076
11077@node System.Wch_Cnv (s-wchcnv.ads)
ad42149c
FW
11078@section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
11079@cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
41af791f
GB
11080@cindex Wide Character, Representation
11081@cindex Wide String, Conversion
11082@cindex Representation of wide characters
11083
11084@noindent
11085This package provides routines for converting between
11086wide characters and a representation as a value of type
11087@code{Standard.String}, using a specified wide character
ad42149c
FW
11088encoding method. It uses definitions in
11089package @code{System.Wch_Con}.
41af791f
GB
11090
11091@node System.Wch_Con (s-wchcon.ads)
ad42149c
FW
11092@section @code{System.Wch_Con} (@file{s-wchcon.ads})
11093@cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
41af791f
GB
11094
11095@noindent
11096This package provides definitions and descriptions of
11097the various methods used for encoding wide characters
ad42149c 11098in ordinary strings. These definitions are used by
41af791f
GB
11099the package @code{System.Wch_Cnv}.
11100
11101@node Interfacing to Other Languages
11102@chapter Interfacing to Other Languages
11103@noindent
11104The facilities in annex B of the Ada 95 Reference Manual are fully
11105implemented in GNAT, and in addition, a full interface to C++ is
11106provided.
11107
11108@menu
11109* Interfacing to C::
11110* Interfacing to C++::
11111* Interfacing to COBOL::
11112* Interfacing to Fortran::
11113* Interfacing to non-GNAT Ada code::
11114@end menu
11115
11116@node Interfacing to C
11117@section Interfacing to C
11118
11119@noindent
11120Interfacing to C with GNAT can use one of two approaches:
11121
11122@enumerate
11123@item
11124The types in the package @code{Interfaces.C} may be used.
11125@item
ad42149c 11126Standard Ada types may be used directly. This may be less portable to
41af791f
GB
11127other compilers, but will work on all GNAT compilers, which guarantee
11128correspondence between the C and Ada types.
11129@end enumerate
11130
11131@noindent
11132Pragma @code{Convention C} maybe applied to Ada types, but mostly has no
ad42149c 11133effect, since this is the default. The following table shows the
41af791f
GB
11134correspondence between Ada scalar types and the corresponding C types.
11135
11136@table @code
11137@item Integer
11138@code{int}
11139@item Short_Integer
11140@code{short}
11141@item Short_Short_Integer
11142@code{signed char}
11143@item Long_Integer
11144@code{long}
11145@item Long_Long_Integer
11146@code{long long}
11147@item Short_Float
11148@code{float}
11149@item Float
11150@code{float}
11151@item Long_Float
11152@code{double}
11153@item Long_Long_Float
11154This is the longest floating-point type supported by the hardware.
11155@end table
11156
11157@itemize @bullet
11158@item
11159Ada enumeration types map to C enumeration types directly if pragma
11160@code{Convention C} is specified, which causes them to have int
ad42149c
FW
11161length. Without pragma @code{Convention C}, Ada enumeration types map to
111628, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short}, @code{int}, respectively)
11163depending on the number of values passed. This is the only case in which
41af791f
GB
11164pragma @code{Convention C} affects the representation of an Ada type.
11165
11166@item
11167Ada access types map to C pointers, except for the case of pointers to
11168unconstrained types in Ada, which have no direct C equivalent.
11169
11170@item
11171Ada arrays map directly to C arrays.
11172
11173@item
11174Ada records map directly to C structures.
11175
11176@item
11177Packed Ada records map to C structures where all members are bit fields
11178of the length corresponding to the @code{@var{type}'Size} value in Ada.
11179@end itemize
11180
11181@node Interfacing to C++
11182@section Interfacing to C++
11183
11184@noindent
11185The interface to C++ makes use of the following pragmas, which are
11186primarily intended to be constructed automatically using a binding generator
ad42149c 11187tool, although it is possible to construct them by hand. Ada Core
41af791f
GB
11188Technologies does not currently supply a suitable binding generator tool.
11189
11190Using these pragmas it is possible to achieve complete
11191inter-operability between Ada tagged types and C class definitions.
11192See @ref{Implementation Defined Pragmas} for more details.
11193
11194@table @code
11195@item pragma CPP_Class ([Entity =>] @var{local_name})
11196The argument denotes an entity in the current declarative region that is
ad42149c 11197declared as a tagged or untagged record type. It indicates that the type
41af791f
GB
11198corresponds to an externally declared C++ class type, and is to be laid
11199out the same way that C++ would lay out the type.
11200
11201@item pragma CPP_Constructor ([Entity =>] @var{local_name})
11202This pragma identifies an imported function (imported in the usual way
11203with pragma @code{Import}) as corresponding to a C++ constructor.
11204
11205@item pragma CPP_Vtable @dots{}
11206One @code{CPP_Vtable} pragma can be present for each component of type
11207@code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
11208applies.
11209@end table
11210
11211@node Interfacing to COBOL
11212@section Interfacing to COBOL
11213
11214@noindent
11215Interfacing to COBOL is achieved as described in section B.4 of
11216the Ada 95 reference manual.
11217
11218@node Interfacing to Fortran
11219@section Interfacing to Fortran
11220
11221@noindent
11222Interfacing to Fortran is achieved as described in section B.5 of the
ad42149c
FW
11223reference manual. The pragma @code{Convention Fortran}, applied to a
11224multi-dimensional array causes the array to be stored in column-major
41af791f
GB
11225order as required for convenient interface to Fortran.
11226
11227@node Interfacing to non-GNAT Ada code
11228@section Interfacing to non-GNAT Ada code
11229
ad42149c
FW
11230It is possible to specify the convention @code{Ada} in a pragma @code{Import} or
11231pragma @code{Export}. However this refers to the calling conventions used
41af791f
GB
11232by GNAT, which may or may not be similar enough to those used by
11233some other Ada 83 or Ada 95 compiler to allow interoperation.
11234
11235If arguments types are kept simple, and if the foreign compiler generally
11236follows system calling conventions, then it may be possible to integrate
11237files compiled by other Ada compilers, provided that the elaboration
11238issues are adequately addressed (for example by eliminating the
11239need for any load time elaboration).
11240
11241In particular, GNAT running on VMS is designed to
11242be highly compatible with the DEC Ada 83 compiler, so this is one
11243case in which it is possible to import foreign units of this type,
11244provided that the data items passed are restricted to simple scalar
11245values or simple record types without variants, or simple array
11246types with fixed bounds.
11247
11248@node Machine Code Insertions
11249@chapter Machine Code Insertions
11250
11251@noindent
11252Package @code{Machine_Code} provides machine code support as described
11253in the Ada 95 Reference Manual in two separate forms:
11254@itemize @bullet
11255@item
11256Machine code statements, consisting of qualified expressions that
11257fit the requirements of RM section 13.8.
11258@item
11259An intrinsic callable procedure, providing an alternative mechanism of
11260including machine instructions in a subprogram.
11261@end itemize
11262
11263The two features are similar, and both closely related to the mechanism
ad42149c 11264provided by the asm instruction in the GNU C compiler. Full understanding
41af791f 11265and use of the facilities in this package requires understanding the asm
ad42149c
FW
11266instruction as described in
11267@cite{Using and Porting the GNU Compiler Collection (GCC)} by Richard
41af791f
GB
11268Stallman. Calls to the function @code{Asm} and the procedure @code{Asm}
11269have identical semantic restrictions and effects as described below.
11270Both are provided so that the procedure call can be used as a statement,
11271and the function call can be used to form a code_statement.
11272
ad42149c 11273The first example given in the GCC documentation is the C @code{asm}
41af791f
GB
11274instruction:
11275@smallexample
11276 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
11277@end smallexample
11278
11279@noindent
11280The equivalent can be written for GNAT as:
11281
11282@smallexample
11283Asm ("fsinx %1 %0",
11284 My_Float'Asm_Output ("=f", result),
11285 My_Float'Asm_Input ("f", angle));
11286@end smallexample
11287
11288The first argument to @code{Asm} is the assembler template, and is
ad42149c
FW
11289identical to what is used in GNU C@. This string must be a static
11290expression. The second argument is the output operand list. It is
41af791f
GB
11291either a single @code{Asm_Output} attribute reference, or a list of such
11292references enclosed in parentheses (technically an array aggregate of
11293such references).
11294
11295The @code{Asm_Output} attribute denotes a function that takes two
11296parameters. The first is a string, the second is the name of a variable
ad42149c 11297of the type designated by the attribute prefix. The first (string)
41af791f 11298argument is required to be a static expression and designates the
46b58b8c 11299constraint for the parameter (e.g.@: what kind of register is
ad42149c
FW
11300required). The second argument is the variable to be updated with the
11301result. The possible values for constraint are the same as those used in
41af791f
GB
11302the RTL, and are dependent on the configuration file used to build the
11303GCC back end. If there are no output operands, then this argument may
11304either be omitted, or explicitly given as @code{No_Output_Operands}.
11305
11306The second argument of @code{@var{my_float}'Asm_Output} functions as
11307though it were an @code{out} parameter, which is a little curious, but
11308all names have the form of expressions, so there is no syntactic
11309irregularity, even though normally functions would not be permitted
11310@code{out} parameters. The third argument is the list of input
ad42149c 11311operands. It is either a single @code{Asm_Input} attribute reference, or
41af791f
GB
11312a list of such references enclosed in parentheses (technically an array
11313aggregate of such references).
11314
11315The @code{Asm_Input} attribute denotes a function that takes two
11316parameters. The first is a string, the second is an expression of the
ad42149c 11317type designated by the prefix. The first (string) argument is required
41af791f 11318to be a static expression, and is the constraint for the parameter,
ad42149c
FW
11319(e.g.@: what kind of register is required). The second argument is the
11320value to be used as the input argument. The possible values for the
41af791f
GB
11321constant are the same as those used in the RTL, and are dependent on
11322the configuration file used to built the GCC back end.
11323
11324If there are no input operands, this argument may either be omitted, or
11325explicitly given as @code{No_Input_Operands}. The fourth argument, not
11326present in the above example, is a list of register names, called the
ad42149c 11327@dfn{clobber} argument. This argument, if given, must be a static string
41af791f 11328expression, and is a space or comma separated list of names of registers
ad42149c 11329that must be considered destroyed as a result of the @code{Asm} call. If
41af791f
GB
11330this argument is the null string (the default value), then the code
11331generator assumes that no additional registers are destroyed.
11332
11333The fifth argument, not present in the above example, called the
ad42149c 11334@dfn{volatile} argument, is by default @code{False}. It can be set to
41af791f
GB
11335the literal value @code{True} to indicate to the code generator that all
11336optimizations with respect to the instruction specified should be
11337suppressed, and that in particular, for an instruction that has outputs,
11338the instruction will still be generated, even if none of the outputs are
ad42149c 11339used. See the full description in the GCC manual for further details.
41af791f 11340
ad42149c 11341The @code{Asm} subprograms may be used in two ways. First the procedure
41af791f 11342forms can be used anywhere a procedure call would be valid, and
ad42149c 11343correspond to what the RM calls ``intrinsic'' routines. Such calls can
41af791f
GB
11344be used to intersperse machine instructions with other Ada statements.
11345Second, the function forms, which return a dummy value of the limited
11346private type @code{Asm_Insn}, can be used in code statements, and indeed
11347this is the only context where such calls are allowed. Code statements
11348appear as aggregates of the form:
11349
11350@smallexample
11351Asm_Insn'(Asm (@dots{}));
11352Asm_Insn'(Asm_Volatile (@dots{}));
11353@end smallexample
11354
11355In accordance with RM rules, such code statements are allowed only
11356within subprograms whose entire body consists of such statements. It is
11357not permissible to intermix such statements with other Ada statements.
11358
11359Typically the form using intrinsic procedure calls is more convenient
ad42149c 11360and more flexible. The code statement form is provided to meet the RM
41af791f
GB
11361suggestion that such a facility should be made available. The following
11362is the exact syntax of the call to @code{Asm} (of course if named notation is
11363used, the arguments may be given in arbitrary order, following the
11364normal rules for use of positional and named arguments)
11365
11366@smallexample
11367ASM_CALL ::= Asm (
11368 [Template =>] static_string_EXPRESSION
11369 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
11370 [,[Inputs =>] INPUT_OPERAND_LIST ]
11371 [,[Clobber =>] static_string_EXPRESSION ]
11372 [,[Volatile =>] static_boolean_EXPRESSION] )
11373OUTPUT_OPERAND_LIST ::=
11374 No_Output_Operands
11375| OUTPUT_OPERAND_ATTRIBUTE
11376| (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
11377OUTPUT_OPERAND_ATTRIBUTE ::=
11378 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
11379INPUT_OPERAND_LIST ::=
11380 No_Input_Operands
11381| INPUT_OPERAND_ATTRIBUTE
11382| (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
11383INPUT_OPERAND_ATTRIBUTE ::=
11384 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
11385@end smallexample
11386
11387@node GNAT Implementation of Tasking
11388@chapter GNAT Implementation of Tasking
11389@menu
11390* Mapping Ada Tasks onto the Underlying Kernel Threads::
11391* Ensuring Compliance with the Real-Time Annex::
11392@end menu
11393
11394@node Mapping Ada Tasks onto the Underlying Kernel Threads
11395@section Mapping Ada Tasks onto the Underlying Kernel Threads
11396
11397GNAT run-time system comprises two layers:
11398
11399@itemize @bullet
11400@item GNARL (GNAT Run-time Layer)
11401@item GNULL (GNAT Low-level Library)
11402@end itemize
11403
11404In GNAT, Ada's tasking services rely on a platform and OS independent
ad42149c 11405layer known as GNARL@. This code is responsible for implementing the
41af791f
GB
11406correct semantics of Ada's task creation, rendezvous, protected
11407operations etc.
11408
11409GNARL decomposes Ada's tasking semantics into simpler lower level
11410operations such as create a thread, set the priority of a thread,
ad42149c
FW
11411yield, create a lock, lock/unlock, etc. The spec for these low-level
11412operations constitutes GNULLI, the GNULL Interface. This interface is
46b58b8c 11413directly inspired from the POSIX real-time API@.
41af791f
GB
11414
11415If the underlying executive or OS implements the POSIX standard
11416faithfully, the GNULL Interface maps as is to the services offered by
ad42149c 11417the underlying kernel. Otherwise, some target dependent glue code maps
41af791f 11418the services offered by the underlying kernel to the semantics expected
46b58b8c 11419by GNARL@.
41af791f
GB
11420
11421Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
11422key point is that each Ada task is mapped on a thread in the underlying
ad42149c 11423kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
41af791f
GB
11424
11425In addition Ada task priorities map onto the underlying thread priorities.
11426Mapping Ada tasks onto the underlying kernel threads has several advantages:
11427
11428@enumerate
11429
11430@item
ad42149c 11431The underlying scheduler is used to schedule the Ada tasks. This
41af791f
GB
11432makes Ada tasks as efficient as kernel threads from a scheduling
11433standpoint.
11434
11435@item
11436Interaction with code written in C containing threads is eased
11437since at the lowest level Ada tasks and C threads map onto the same
11438underlying kernel concept.
11439
11440@item
11441When an Ada task is blocked during I/O the remaining Ada tasks are
11442able to proceed.
11443
11444@item
11445On multi-processor systems Ada Tasks can execute in parallel.
11446@end enumerate
11447
11448@node Ensuring Compliance with the Real-Time Annex
11449@section Ensuring Compliance with the Real-Time Annex
11450
11451The reader will be quick to notice that while mapping Ada tasks onto
11452the underlying threads has significant advantages, it does create some
11453complications when it comes to respecting the scheduling semantics
11454specified in the real-time annex (Annex D).
11455
11456For instance Annex D requires that for the FIFO_Within_Priorities
11457scheduling policy we have:
11458
11459@smallexample
11460When the active priority of a ready task that is not running
11461changes, or the setting of its base priority takes effect, the
11462task is removed from the ready queue for its old active priority
11463and is added at the tail of the ready queue for its new active
11464priority, except in the case where the active priority is lowered
11465due to the loss of inherited priority, in which case the task is
11466added at the head of the ready queue for its new active priority.
11467@end smallexample
11468
11469While most kernels do put tasks at the end of the priority queue when
11470a task changes its priority, (which respects the main
11471FIFO_Within_Priorities requirement), almost none keep a thread at the
11472beginning of its priority queue when its priority drops from the loss
11473of inherited priority.
11474
11475As a result most vendors have provided incomplete Annex D implementations.
11476
11477The GNAT run-time, has a nice cooperative solution to this problem
11478which ensures that accurate FIFO_Within_Priorities semantics are
11479respected.
11480
ad42149c 11481The principle is as follows. When an Ada task T is about to start
41af791f
GB
11482running, it checks whether some other Ada task R with the same
11483priority as T has been suspended due to the loss of priority
ad42149c
FW
11484inheritance. If this is the case, T yields and is placed at the end of
11485its priority queue. When R arrives at the front of the queue it
41af791f
GB
11486executes.
11487
11488Note that this simple scheme preserves the relative order of the tasks
11489that were ready to execute in the priority queue where R has been
11490placed at the end.
11491
11492@node Code generation for array aggregates
11493@chapter Code generation for array aggregates
11494
11495@menu
11496* Static constant aggregates with static bounds::
11497* Constant aggregates with an unconstrained nominal types::
11498* Aggregates with static bounds::
11499* Aggregates with non-static bounds::
11500* Aggregates in assignments statements::
11501@end menu
11502
11503Aggregate have a rich syntax and allow the user to specify the values of
ad42149c 11504complex data structures by means of a single construct. As a result, the
41af791f 11505code generated for aggregates can be quite complex and involve loops, case
ad42149c 11506statements and multiple assignments. In the simplest cases, however, the
41af791f
GB
11507compiler will recognize aggregates whose components and constraints are
11508fully static, and in those cases the compiler will generate little or no
ad42149c
FW
11509executable code. The following is an outline of the code that GNAT generates
11510for various aggregate constructs. For further details, the user will find it
41af791f
GB
11511useful to examine the output produced by the -gnatG flag to see the expanded
11512source that is input to the code generator. The user will also want to examine
11513the assembly code generated at various levels of optimization.
11514
11515The code generated for aggregates depends on the context, the component values,
ad42149c
FW
11516and the type. In the context of an object declaration the code generated is
11517generally simpler than in the case of an assignment. As a general rule, static
41af791f
GB
11518component values and static subtypes also lead to simpler code.
11519
11520@node Static constant aggregates with static bounds
11521@section Static constant aggregates with static bounds
11522
11523 For the declarations:
11524@smallexample
11525 type One_Dim is array (1..10) of integer;
11526 ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
11527@end smallexample
11528
11529GNAT generates no executable code: the constant ar0 is placed in static memory.
11530The same is true for constant aggregates with named associations:
11531
11532@smallexample
11533 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
11534 Cr3 : constant One_Dim := (others => 7777);
11535@end smallexample
11536
11537 The same is true for multidimensional constant arrays such as:
11538
11539@smallexample
11540 type two_dim is array (1..3, 1..3) of integer;
11541 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
11542@end smallexample
11543
11544The same is true for arrays of one-dimensional arrays: the following are
11545static:
11546
11547@smallexample
11548type ar1b is array (1..3) of boolean;
11549type ar_ar is array (1..3) of ar1b;
11550None : constant ar1b := (others => false); -- fully static
11551None2 : constant ar_ar := (1..3 => None); -- fully static
11552@end smallexample
11553
11554However, for multidimensional aggregates with named associations, GNAT will
ad42149c 11555generate assignments and loops, even if all associations are static. The
41af791f
GB
11556following two declarations generate a loop for the first dimension, and
11557individual component assignments for the second dimension:
11558
11559@smallexample
11560Zero1: constant two_dim := (1..3 => (1..3 => 0));
11561Zero2: constant two_dim := (others => (others => 0));
11562@end smallexample
11563
11564@node Constant aggregates with an unconstrained nominal types
11565@section Constant aggregates with an unconstrained nominal types
11566
11567In such cases the aggregate itself establishes the subtype, so that associations
ad42149c
FW
11568with @code{others} cannot be used. GNAT determines the bounds for the actual
11569subtype of the aggregate, and allocates the aggregate statically as well. No
41af791f
GB
11570code is generated for the following:
11571
11572@smallexample
11573 type One_Unc is array (natural range <>) of integer;
11574 Cr_Unc : constant One_Unc := (12,24,36);
11575@end smallexample
11576
11577@node Aggregates with static bounds
11578@section Aggregates with static bounds
11579
11580In all previous examples the aggregate was the initial (and immutable) value
ad42149c 11581of a constant. If the aggregate initializes a variable, then code is generated
41af791f 11582for it as a combination of individual assignments and loops over the target
ad42149c 11583object. The declarations
41af791f
GB
11584
11585@smallexample
11586 Cr_Var1 : One_Dim := (2, 5, 7, 11);
11587 Cr_Var2 : One_Dim := (others > -1);
11588@end smallexample
11589
11590generate the equivalent of
11591
11592@smallexample
11593 Cr_Var1 (1) := 2;
11594 Cr_Var1 (2) := 3;
11595 Cr_Var1 (3) := 5;
11596 Cr_Var1 (4) := 11;
11597
11598 for I in Cr_Var2'range loop
11599 Cr_Var2 (I) := =-1;
11600 end loop;
11601@end smallexample
11602
11603@node Aggregates with non-static bounds
11604@section Aggregates with non-static bounds
11605
11606If the bounds of the aggregate are not statically compatible with the bounds
11607of the nominal subtype of the target, then constraint checks have to be
ad42149c 11608generated on the bounds. For a multidimensional array, constraint checks may
41af791f
GB
11609have to be applied to sub-arrays individually, if they do not have statically
11610compatible subtypes.
11611
11612@node Aggregates in assignments statements
11613@section Aggregates in assignments statements
11614
11615In general, aggregate assignment requires the construction of a temporary,
ad42149c 11616and a copy from the temporary to the target of the assignment. This is because
41af791f 11617it is not always possible to convert the assignment into a series of individual
ad42149c 11618component assignments. For example, consider the simple case:
41af791f
GB
11619
11620@smallexample
11621@end smallexample
11622 A := (A(2), A(1));
11623
11624This cannot be converted into:
11625
11626@smallexample
11627 A(1) := A(2);
11628 A(2) := A(1);
11629@end smallexample
11630
11631So the aggregate has to be built first in a separate location, and then
ad42149c 11632copied into the target. GNAT recognizes simple cases where this intermediate
41af791f 11633step is not required, and the assignments can be performed in place, directly
ad42149c 11634into the target. The following sufficient criteria are applied:
41af791f
GB
11635
11636@enumerate
11637@item The bounds of the aggregate are static, and the associations are static.
11638@item The components of the aggregate are static constants, names of
11639 simple variables that are not renamings, or expressions not involving
11640 indexed components whose operands obey these rules.
11641@end enumerate
11642
11643If any of these conditions are violated, the aggregate will be built in
11644a temporary (created either by the front-end or the code generator) and then
11645that temporary will be copied onto the target.
11646
11647
11648@node Specialized Needs Annexes
11649@chapter Specialized Needs Annexes
11650
11651@noindent
11652Ada 95 defines a number of specialized needs annexes, which are not
ad42149c 11653required in all implementations. However, as described in this chapter,
41af791f
GB
11654GNAT implements all of these special needs annexes:
11655
11656@table @asis
11657@item Systems Programming (Annex C)
ad42149c 11658The Systems Programming Annex is fully implemented.
41af791f
GB
11659
11660@item Real-Time Systems (Annex D)
ad42149c 11661The Real-Time Systems Annex is fully implemented.
41af791f
GB
11662
11663@item Distributed Systems (Annex E)
ad42149c
FW
11664Stub generation is fully implemented in the GNAT compiler. In addition,
11665a complete compatible PCS is available as part of the GLADE system,
11666a separate product. When the two
41af791f
GB
11667products are used in conjunction, this annex is fully implemented.
11668
11669@item Information Systems (Annex F)
ad42149c 11670The Information Systems annex is fully implemented.
41af791f
GB
11671
11672@item Numerics (Annex G)
ad42149c 11673The Numerics Annex is fully implemented.
41af791f
GB
11674
11675@item Safety and Security (Annex H)
ad42149c 11676The Safety and Security annex is fully implemented.
41af791f
GB
11677
11678@end table
11679
11680@node Compatibility Guide
11681@chapter Compatibility Guide
11682
11683@noindent
11684This chapter contains sections that describe compatibility issues between
11685GNAT and other Ada 83 and Ada 95 compilation systems, to aid in porting
11686applications developed in other Ada environments.
11687
11688@menu
11689* Compatibility with Ada 83::
11690* Compatibility with DEC Ada 83::
11691* Compatibility with Other Ada 95 Systems::
11692* Representation Clauses::
11693@end menu
11694
11695@node Compatibility with Ada 83
11696@section Compatibility with Ada 83
ad42149c 11697@cindex Compatibility (between Ada 83 and Ada 95)
41af791f
GB
11698
11699@noindent
ad42149c 11700Ada 95 is designed to be highly upwards compatible with Ada 83. In
41af791f
GB
11701particular, the design intention is that the difficulties associated
11702with moving from Ada 83 to Ada 95 should be no greater than those
11703that occur when moving from one Ada 83 system to another.
11704
11705However, there are a number of points at which there are minor
ad42149c 11706incompatibilities. The Ada 95 Annotated Reference Manual contains
41af791f
GB
11707full details of these issues,
11708and should be consulted for a complete treatment.
11709In practice the
11710following are the most likely issues to be encountered.
11711
11712@table @asis
11713@item Character range
ad42149c 11714The range of @code{Standard.Character} is now the full 256 characters of Latin-1,
41af791f 11715whereas in most Ada 83 implementations it was restricted to 128 characters.
ad42149c 11716This may show up as compile time or runtime errors. The desirable fix is to
41af791f
GB
11717adapt the program to accommodate the full character set, but in some cases
11718it may be convenient to define a subtype or derived type of Character that
11719covers only the restricted range.
ad42149c 11720@cindex Latin-1
41af791f
GB
11721
11722@item New reserved words
11723The identifiers @code{abstract}, @code{aliased}, @code{protected},
11724@code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
11725Existing Ada 83 code using any of these identifiers must be edited to
11726use some alternative name.
11727
11728@item Freezing rules
11729The rules in Ada 95 are slightly different with regard to the point at
11730which entities are frozen, and representation pragmas and clauses are
ad42149c 11731not permitted past the freeze point. This shows up most typically in
41af791f
GB
11732the form of an error message complaining that a representation item
11733appears too late, and the appropriate corrective action is to move
11734the item nearer to the declaration of the entity to which it refers.
11735
11736A particular case is that representation pragmas (including the
ad42149c
FW
11737extended DEC Ada 83 compatibility pragmas such as @code{Export_Procedure}), cannot
11738be applied to a subprogram body. If necessary, a separate subprogram
41af791f
GB
11739declaration must be introduced to which the pragma can be applied.
11740
11741@item Optional bodies for library packages
11742In Ada 83, a package that did not require a package body was nevertheless
ad42149c
FW
11743allowed to have one. This lead to certain surprises in compiling large
11744systems (situations in which the body could be unexpectedly ignored). In
41af791f 11745Ada 95, if a package does not require a body then it is not permitted to
ad42149c 11746have a body. To fix this problem, simply remove a redundant body if it
41af791f 11747is empty, or, if it is non-empty, introduce a dummy declaration into the
ad42149c 11748spec that makes the body required. One approach is to add a private part
41af791f
GB
11749to the package declaration (if necessary), and define a parameterless
11750procedure called Requires_Body, which must then be given a dummy
11751procedure body in the package body, which then becomes required.
11752
ad42149c
FW
11753@item @code{Numeric_Error} is now the same as @code{Constraint_Error}
11754In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
41af791f 11755This means that it is illegal to have separate exception handlers for
ad42149c
FW
11756the two exceptions. The fix is simply to remove the handler for the
11757@code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
11758@code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
41af791f
GB
11759
11760@item Indefinite subtypes in generics
ad42149c 11761In Ada 83, it was permissible to pass an indefinite type (e.g.@: @code{String}) as
41af791f
GB
11762the actual for a generic formal private type, but then the instantiation
11763would be illegal if there were any instances of declarations of variables
ad42149c 11764of this type in the generic body. In Ada 95, to avoid this clear violation
41af791f 11765of the contract model, the generic declaration clearly indicates whether
ad42149c
FW
11766or not such instantiations are permitted. If a generic formal parameter
11767has explicit unknown discriminants, indicated by using @code{(<>)} after the
41af791f 11768type name, then it can be instantiated with indefinite types, but no
ad42149c
FW
11769variables can be declared of this type. Any attempt to declare a variable
11770will result in an illegality at the time the generic is declared. If the
11771@code{(<>)} notation is not used, then it is illegal to instantiate the generic
11772with an indefinite type. This will show up as a compile time error, and
11773the fix is usually simply to add the @code{(<>)} to the generic declaration.
41af791f
GB
11774@end table
11775
11776All implementations of GNAT provide a switch that causes GNAT to operate
ad42149c
FW
11777in Ada 83 mode. In this mode, some but not all compatibility problems
11778of the type described above are handled automatically. For example, the
11779new Ada 95 protected keywords are not recognized in this mode. However,
41af791f
GB
11780in practice, it is usually advisable to make the necessary modifications
11781to the program to remove the need for using this switch.
11782
11783@node Compatibility with Other Ada 95 Systems
11784@section Compatibility with Other Ada 95 Systems
11785
11786@noindent
11787Providing that programs avoid the use of implementation dependent and
11788implementation defined features of Ada 95, as documented in the Ada 95
11789reference manual, there should be a high degree of portability between
ad42149c 11790GNAT and other Ada 95 systems. The following are specific items which
41af791f 11791have proved troublesome in moving GNAT programs to other Ada 95
46b58b8c 11792compilers, but do not affect porting code to GNAT@.
41af791f
GB
11793
11794@table @asis
11795@item Ada 83 Pragmas and Attributes
11796Ada 95 compilers are allowed, but not required, to implement the missing
11797Ada 83 pragmas and attributes that are no longer defined in Ada 95.
11798GNAT implements all such pragmas and attributes, eliminating this as
11799a compatibility concern, but some other Ada 95 compilers reject these
11800pragmas and attributes.
11801
11802@item Special-needs Annexes
ad42149c
FW
11803GNAT implements the full set of special needs annexes. At the
11804current time, it is the only Ada 95 compiler to do so. This means that
41af791f
GB
11805programs making use of these features may not be portable to other Ada
1180695 compilation systems.
11807
11808@item Representation Clauses
11809Some other Ada 95 compilers implement only the minimal set of
ad42149c 11810representation clauses required by the Ada 95 reference manual. GNAT goes
41af791f
GB
11811far beyond this minimal set, as described in the next section.
11812@end table
11813
11814@node Representation Clauses
11815@section Representation Clauses
11816
11817@noindent
11818The Ada 83 reference manual was quite vague in describing both the minimal
11819required implementation of representation clauses, and also their precise
ad42149c 11820effects. The Ada 95 reference manual is much more explicit, but the minimal
41af791f
GB
11821set of capabilities required in Ada 95 is quite limited.
11822
11823GNAT implements the full required set of capabilities described in the
11824Ada 95 reference manual, but also goes much beyond this, and in particular
11825an effort has been made to be compatible with existing Ada 83 usage to the
11826greatest extent possible.
11827
11828A few cases exist in which Ada 83 compiler behavior is incompatible with
ad42149c 11829requirements in the Ada 95 reference manual. These are instances of
41af791f 11830intentional or accidental dependence on specific implementation dependent
ad42149c 11831characteristics of these Ada 83 compilers. The following is a list of
41af791f
GB
11832the cases most likely to arise in existing legacy Ada 83 code.
11833
11834@table @asis
11835@item Implicit Packing
11836Some Ada 83 compilers allowed a Size specification to cause implicit
ad42149c 11837packing of an array or record. This could cause expensive implicit
41af791f
GB
11838conversions for change of representation in the presence of derived
11839types, and the Ada design intends to avoid this possibility.
11840Subsequent AI's were issued to make it clear that such implicit
11841change of representation in response to a Size clause is inadvisable,
11842and this recommendation is represented explicitly in the Ada 95 RM
46b58b8c 11843as implementation advice that is followed by GNAT@.
41af791f 11844The problem will show up as an error
ad42149c
FW
11845message rejecting the size clause. The fix is simply to provide
11846the explicit pragma @code{Pack}, or for more fine tuned control, provide
41af791f
GB
11847a Component_Size clause.
11848
11849@item Meaning of Size Attribute
11850The Size attribute in Ada 95 for discrete types is defined as being the
ad42149c 11851minimal number of bits required to hold values of the type. For example,
41af791f 11852on a 32-bit machine, the size of Natural will typically be 31 and not
ad42149c
FW
1185332 (since no sign bit is required). Some Ada 83 compilers gave 31, and
11854some 32 in this situation. This problem will usually show up as a compile
11855time error, but not always. It is a good idea to check all uses of the
11856'Size attribute when porting Ada 83 code. The GNAT specific attribute
41af791f
GB
11857Object_Size can provide a useful way of duplicating the behavior of
11858some Ada 83 compiler systems.
11859
11860@item Size of Access Types
11861A common assumption in Ada 83 code is that an access type is in fact a pointer,
ad42149c
FW
11862and that therefore it will be the same size as a System.Address value. This
11863assumption is true for GNAT in most cases with one exception. For the case of
41af791f 11864a pointer to an unconstrained array type (where the bounds may vary from one
ad42149c 11865value of the access type to another), the default is to use a ``fat pointer'',
41af791f 11866which is represented as two separate pointers, one to the bounds, and one to
ad42149c
FW
11867the array. This representation has a number of advantages, including improved
11868efficiency. However, it may cause some difficulties in porting existing Ada 83
41af791f
GB
11869code which makes the assumption that, for example, pointers fit in 32 bits on
11870a machine with 32-bit addressing.
11871
ad42149c 11872To get around this problem, GNAT also permits the use of ``thin pointers'' for
41af791f 11873access types in this case (where the designated type is an unconstrained array
ad42149c 11874type). These thin pointers are indeed the same size as a System.Address value.
41af791f
GB
11875To specify a thin pointer, use a size clause for the type, for example:
11876
11877@smallexample
11878type X is access all String;
11879for X'Size use Standard'Address_Size;
11880@end smallexample
11881
11882@noindent
ad42149c
FW
11883which will cause the type X to be represented using a single pointer. When using
11884this representation, the bounds are right behind the array. This representation
41af791f
GB
11885is slightly less efficient, and does not allow quite such flexibility in the
11886use of foreign pointers or in using the Unrestricted_Access attribute to create
ad42149c 11887pointers to non-aliased objects. But for any standard portable use of the access
41af791f 11888type it will work in a functionally correct manner and allow porting of existing
ad42149c 11889code. Note that another way of forcing a thin pointer representation is to use
41af791f
GB
11890a component size clause for the element size in an array, or a record
11891representation clause for an access field in a record.
11892@end table
11893
11894@node Compatibility with DEC Ada 83
11895@section Compatibility with DEC Ada 83
11896
11897@noindent
11898The VMS version of GNAT fully implements all the pragmas and attributes
11899provided by DEC Ada 83, as well as providing the standard DEC Ada 83
ad42149c
FW
11900libraries, including Starlet. In addition, data layouts and parameter
11901passing conventions are highly compatible. This means that porting
41af791f 11902existing DEC Ada 83 code to GNAT in VMS systems should be easier than
ad42149c 11903most other porting efforts. The following are some of the most
41af791f
GB
11904significant differences between GNAT and DEC Ada 83.
11905
11906@table @asis
11907@item Default floating-point representation
11908In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83,
ad42149c 11909it is VMS format. GNAT does implement the necessary pragmas
41af791f
GB
11910(Long_Float, Float_Representation) for changing this default.
11911
11912@item System
11913The package System in GNAT exactly corresponds to the definition in the
11914Ada 95 reference manual, which means that it excludes many of the
ad42149c 11915DEC Ada 83 extensions. However, a separate package Aux_DEC is provided
41af791f
GB
11916that contains the additional definitions, and a special pragma,
11917Extend_System allows this package to be treated transparently as an
11918extension of package System.
11919
11920@item To_Address
11921The definitions provided by Aux_DEC are exactly compatible with those
ad42149c 11922in the DEC Ada 83 version of System, with one exception. DEC Ada provides
41af791f
GB
11923the following declarations:
11924
11925@smallexample
11926TO_ADDRESS(INTEGER)
11927TO_ADDRESS(UNSIGNED_LONGWORD)
11928TO_ADDRESS(universal_integer)
11929@end smallexample
11930
11931@noindent
11932The version of TO_ADDRESS taking a universal integer argument is in fact
11933an extension to Ada 83 not strictly compatible with the reference manual.
11934In GNAT, we are constrained to be exactly compatible with the standard,
ad42149c 11935and this means we cannot provide this capability. In DEC Ada 83, the
41af791f
GB
11936point of this definition is to deal with a call like:
11937
11938@smallexample
11939 TO_ADDRESS (16#12777#);
11940@end smallexample
11941
11942@noindent
11943Normally, according to the Ada 83 standard, one would expect this to be
11944ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms
ad42149c 11945of TO_ADDRESS@. However, in DEC Ada 83, there is no ambiguity, since the
41af791f
GB
11946definition using universal_integer takes precedence.
11947
11948In GNAT, since the version with universal_integer cannot be supplied, it is
ad42149c 11949not possible to be 100% compatible. Since there are many programs using
41af791f
GB
11950numeric constants for the argument to TO_ADDRESS, the decision in GNAT was
11951to change the name of the function in the UNSIGNED_LONGWORD case, so the
11952declarations provided in the GNAT version of AUX_Dec are:
11953
11954@smallexample
11955function To_Address (X : Integer) return Address;
11956pragma Pure_Function (To_Address);
11957
11958function To_Address_Long (X : Unsigned_Longword)
11959 return Address;
11960pragma Pure_Function (To_Address_Long);
11961@end smallexample
11962
11963@noindent
11964This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must
46b58b8c 11965change the name to TO_ADDRESS_LONG@.
41af791f
GB
11966
11967@item Task_Id values
11968The Task_Id values assigned will be different in the two systems, and GNAT
11969does not provide a specified value for the Task_Id of the environment task,
11970which in GNAT is treated like any other declared task.
11971@end table
11972
11973For full details on these and other less significant compatibility issues,
ad42149c
FW
11974see appendix E of the Digital publication entitled @cite{DEC Ada, Technical
11975Overview and Comparison on DIGITAL Platforms}.
41af791f
GB
11976
11977For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and
11978attributes are recognized, although only a subset of them can sensibly
ad42149c 11979be implemented. The description of pragmas in this reference manual
41af791f
GB
11980indicates whether or not they are applicable to non-VMS systems.
11981
5c558dd9 11982@include fdl.texi
41af791f
GB
11983@c GNU Free Documentation License
11984
11985@node Index,,GNU Free Documentation License, Top
11986@unnumbered Index
11987
11988@printindex cp
11989
11990@contents
11991
11992@bye