* Merge with edge-vector-mergepoint-20040918.
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob08a668317b2067ba5e5ffa819d05d189c21dd9f3
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
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
11 @c              Copyright (C) 1995-2004 Free Software Foundation              o
12 @c                                                                            o
13 @c                                                                            o
14 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
15 @c                                                                            o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
18 @setfilename gnat_rm.info
20 @set FSFEDITION
22 @settitle GNAT Reference Manual
24 @setchapternewpage odd
25 @syncodeindex fn cp
27 @include gcc-common.texi
29 @dircategory GNU Ada tools
30 @direntry
31 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
32 @end direntry
34 @copying
35 Copyright @copyright{} 1995-2004, Free Software Foundation
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
44 @end copying
46 @titlepage
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author Ada Core Technologies, Inc.
53 @page
54 @vskip 0pt plus 1filll
56 @insertcopying
58 @end titlepage
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
64 @noindent
65 GNAT Reference Manual
67 @noindent
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
71 @noindent
72 Ada Core Technologies, Inc.
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
93  --- The Detailed Node Listing ---
95 About This Guide
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Annotate::
106 * Pragma Assert::
107 * Pragma Ast_Entry::
108 * Pragma C_Pass_By_Copy::
109 * Pragma Comment::
110 * Pragma Common_Object::
111 * Pragma Compile_Time_Warning::
112 * Pragma Complex_Representation::
113 * Pragma Component_Alignment::
114 * Pragma Convention_Identifier::
115 * Pragma CPP_Class::
116 * Pragma CPP_Constructor::
117 * Pragma CPP_Virtual::
118 * Pragma CPP_Vtable::
119 * Pragma Debug::
120 * Pragma Detect_Blocking::
121 * Pragma Elaboration_Checks::
122 * Pragma Eliminate::
123 * Pragma Export_Exception::
124 * Pragma Export_Function::
125 * Pragma Export_Object::
126 * Pragma Export_Procedure::
127 * Pragma Export_Value::
128 * Pragma Export_Valued_Procedure::
129 * Pragma Extend_System::
130 * Pragma External::
131 * Pragma External_Name_Casing::
132 * Pragma Finalize_Storage_Only::
133 * Pragma Float_Representation::
134 * Pragma Ident::
135 * Pragma Import_Exception::
136 * Pragma Import_Function::
137 * Pragma Import_Object::
138 * Pragma Import_Procedure::
139 * Pragma Import_Valued_Procedure::
140 * Pragma Initialize_Scalars::
141 * Pragma Inline_Always::
142 * Pragma Inline_Generic::
143 * Pragma Interface::
144 * Pragma Interface_Name::
145 * Pragma Interrupt_Handler::
146 * Pragma Interrupt_State::
147 * Pragma Keep_Names::
148 * Pragma License::
149 * Pragma Link_With::
150 * Pragma Linker_Alias::
151 * Pragma Linker_Section::
152 * Pragma Long_Float::
153 * Pragma Machine_Attribute::
154 * Pragma Main_Storage::
155 * Pragma No_Return::
156 * Pragma Normalize_Scalars::
157 * Pragma Obsolescent::
158 * Pragma Passive::
159 * Pragma Polling::
160 * Pragma Profile (Ravenscar)::
161 * Pragma Profile (Restricted)::
162 * Pragma Propagate_Exceptions::
163 * Pragma Psect_Object::
164 * Pragma Pure_Function::
165 * Pragma Restriction_Warnings::
166 * Pragma Source_File_Name::
167 * Pragma Source_File_Name_Project::
168 * Pragma Source_Reference::
169 * Pragma Stream_Convert::
170 * Pragma Style_Checks::
171 * Pragma Subtitle::
172 * Pragma Suppress_All::
173 * Pragma Suppress_Exception_Locations::
174 * Pragma Suppress_Initialization::
175 * Pragma Task_Info::
176 * Pragma Task_Name::
177 * Pragma Task_Storage::
178 * Pragma Thread_Body::
179 * Pragma Time_Slice::
180 * Pragma Title::
181 * Pragma Unchecked_Union::
182 * Pragma Unimplemented_Unit::
183 * Pragma Universal_Data::
184 * Pragma Unreferenced::
185 * Pragma Unreserve_All_Interrupts::
186 * Pragma Unsuppress::
187 * Pragma Use_VADS_Size::
188 * Pragma Validity_Checks::
189 * Pragma Volatile::
190 * Pragma Warnings::
191 * Pragma Weak_External::
193 Implementation Defined Attributes
195 * Abort_Signal::
196 * Address_Size::
197 * Asm_Input::
198 * Asm_Output::
199 * AST_Entry::
200 * Bit::
201 * Bit_Position::
202 * Code_Address::
203 * Default_Bit_Order::
204 * Elaborated::
205 * Elab_Body::
206 * Elab_Spec::
207 * Emax::
208 * Enum_Rep::
209 * Epsilon::
210 * Fixed_Value::
211 * Has_Access_Values::
212 * Has_Discriminants::
213 * Img::
214 * Integer_Value::
215 * Large::
216 * Machine_Size::
217 * Mantissa::
218 * Max_Interrupt_Priority::
219 * Max_Priority::
220 * Maximum_Alignment::
221 * Mechanism_Code::
222 * Null_Parameter::
223 * Object_Size::
224 * Passed_By_Reference::
225 * Range_Length::
226 * Safe_Emax::
227 * Safe_Large::
228 * Small::
229 * Storage_Unit::
230 * Target_Name::
231 * Tick::
232 * To_Address::
233 * Type_Class::
234 * UET_Address::
235 * Unconstrained_Array::
236 * Universal_Literal_String::
237 * Unrestricted_Access::
238 * VADS_Size::
239 * Value_Size::
240 * Wchar_T_Size::
241 * Word_Size::
243 The Implementation of Standard I/O
245 * Standard I/O Packages::
246 * FORM Strings::
247 * Direct_IO::
248 * Sequential_IO::
249 * Text_IO::
250 * Wide_Text_IO::
251 * Stream_IO::
252 * Shared Files::
253 * Open Modes::
254 * Operations on C Streams::
255 * Interfacing to C Streams::
257 The GNAT Library
259 * Ada.Characters.Latin_9 (a-chlat9.ads)::
260 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
261 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
262 * Ada.Command_Line.Remove (a-colire.ads)::
263 * Ada.Command_Line.Environment (a-colien.ads)::
264 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
265 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
266 * Ada.Exceptions.Traceback (a-exctra.ads)::
267 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
268 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
269 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
270 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
271 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
272 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
273 * GNAT.Array_Split (g-arrspl.ads)::
274 * GNAT.AWK (g-awk.ads)::
275 * GNAT.Bounded_Buffers (g-boubuf.ads)::
276 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
277 * GNAT.Bubble_Sort (g-bubsor.ads)::
278 * GNAT.Bubble_Sort_A (g-busora.ads)::
279 * GNAT.Bubble_Sort_G (g-busorg.ads)::
280 * GNAT.Calendar (g-calend.ads)::
281 * GNAT.Calendar.Time_IO (g-catiio.ads)::
282 * GNAT.Case_Util (g-casuti.ads)::
283 * GNAT.CGI (g-cgi.ads)::
284 * GNAT.CGI.Cookie (g-cgicoo.ads)::
285 * GNAT.CGI.Debug (g-cgideb.ads)::
286 * GNAT.Command_Line (g-comlin.ads)::
287 * GNAT.Compiler_Version (g-comver.ads)::
288 * GNAT.Ctrl_C (g-ctrl_c.ads)::
289 * GNAT.CRC32 (g-crc32.ads)::
290 * GNAT.Current_Exception (g-curexc.ads)::
291 * GNAT.Debug_Pools (g-debpoo.ads)::
292 * GNAT.Debug_Utilities (g-debuti.ads)::
293 * GNAT.Directory_Operations (g-dirope.ads)::
294 * GNAT.Dynamic_HTables (g-dynhta.ads)::
295 * GNAT.Dynamic_Tables (g-dyntab.ads)::
296 * GNAT.Exception_Actions (g-excact.ads)::
297 * GNAT.Exception_Traces (g-exctra.ads)::
298 * GNAT.Exceptions (g-except.ads)::
299 * GNAT.Expect (g-expect.ads)::
300 * GNAT.Float_Control (g-flocon.ads)::
301 * GNAT.Heap_Sort (g-heasor.ads)::
302 * GNAT.Heap_Sort_A (g-hesora.ads)::
303 * GNAT.Heap_Sort_G (g-hesorg.ads)::
304 * GNAT.HTable (g-htable.ads)::
305 * GNAT.IO (g-io.ads)::
306 * GNAT.IO_Aux (g-io_aux.ads)::
307 * GNAT.Lock_Files (g-locfil.ads)::
308 * GNAT.MD5 (g-md5.ads)::
309 * GNAT.Memory_Dump (g-memdum.ads)::
310 * GNAT.Most_Recent_Exception (g-moreex.ads)::
311 * GNAT.OS_Lib (g-os_lib.ads)::
312 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
313 * GNAT.Regexp (g-regexp.ads)::
314 * GNAT.Registry (g-regist.ads)::
315 * GNAT.Regpat (g-regpat.ads)::
316 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
317 * GNAT.Semaphores (g-semaph.ads)::
318 * GNAT.Signals (g-signal.ads)::
319 * GNAT.Sockets (g-socket.ads)::
320 * GNAT.Source_Info (g-souinf.ads)::
321 * GNAT.Spell_Checker (g-speche.ads)::
322 * GNAT.Spitbol.Patterns (g-spipat.ads)::
323 * GNAT.Spitbol (g-spitbo.ads)::
324 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
325 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
326 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
327 * GNAT.Strings (g-string.ads)::
328 * GNAT.String_Split (g-strspl.ads)::
329 * GNAT.Table (g-table.ads)::
330 * GNAT.Task_Lock (g-tasloc.ads)::
331 * GNAT.Threads (g-thread.ads)::
332 * GNAT.Traceback (g-traceb.ads)::
333 * GNAT.Traceback.Symbolic (g-trasym.ads)::
334 * GNAT.Wide_String_Split (g-wistsp.ads)::
335 * Interfaces.C.Extensions (i-cexten.ads)::
336 * Interfaces.C.Streams (i-cstrea.ads)::
337 * Interfaces.CPP (i-cpp.ads)::
338 * Interfaces.Os2lib (i-os2lib.ads)::
339 * Interfaces.Os2lib.Errors (i-os2err.ads)::
340 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
341 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
342 * Interfaces.Packed_Decimal (i-pacdec.ads)::
343 * Interfaces.VxWorks (i-vxwork.ads)::
344 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
345 * System.Address_Image (s-addima.ads)::
346 * System.Assertions (s-assert.ads)::
347 * System.Memory (s-memory.ads)::
348 * System.Partition_Interface (s-parint.ads)::
349 * System.Restrictions (s-restri.ads)::
350 * System.Rident (s-rident.ads)::
351 * System.Task_Info (s-tasinf.ads)::
352 * System.Wch_Cnv (s-wchcnv.ads)::
353 * System.Wch_Con (s-wchcon.ads)::
355 Text_IO
357 * Text_IO Stream Pointer Positioning::
358 * Text_IO Reading and Writing Non-Regular Files::
359 * Get_Immediate::
360 * Treating Text_IO Files as Streams::
361 * Text_IO Extensions::
362 * Text_IO Facilities for Unbounded Strings::
364 Wide_Text_IO
366 * Wide_Text_IO Stream Pointer Positioning::
367 * Wide_Text_IO Reading and Writing Non-Regular Files::
369 Interfacing to Other Languages
371 * Interfacing to C::
372 * Interfacing to C++::
373 * Interfacing to COBOL::
374 * Interfacing to Fortran::
375 * Interfacing to non-GNAT Ada code::
377 Specialized Needs Annexes
379 Implementation of Specific Ada Features
380 * Machine Code Insertions::
381 * GNAT Implementation of Tasking::
382 * GNAT Implementation of Shared Passive Packages::
383 * Code Generation for Array Aggregates::
384 * The Size of Discriminated Records with Default Discriminants::
386 Project File Reference
388 Obsolescent Features
390 GNU Free Documentation License
392 Index
393 @end menu
395 @end ifnottex
397 @node About This Guide
398 @unnumbered About This Guide
400 @ifclear PROEDITION
401 @noindent
402 This manual contains useful information in writing programs using the
403 GNAT compiler.  It includes information on implementation dependent
404 characteristics of GNAT, including all the information required by Annex
405 M of the standard.
406 @end ifclear
408 @ifset PROEDITION
409 @noindent
410 This manual contains useful information in writing programs using the
411 GNAT Pro compiler.  It includes information on implementation dependent
412 characteristics of GNAT Pro, including all the information required by Annex
413 M of the standard.
414 @end ifset
416 Ada 95 is designed to be highly portable.
417 In general, a program will have the same effect even when compiled by
418 different compilers on different platforms.
419 However, since Ada 95 is designed to be used in a
420 wide variety of applications, it also contains a number of system
421 dependent features to be used in interfacing to the external world.
422 @cindex Implementation-dependent features
423 @cindex Portability
425 Note: Any program that makes use of implementation-dependent features
426 may be non-portable.  You should follow good programming practice and
427 isolate and clearly document any sections of your program that make use
428 of these features in a non-portable manner.
430 @ifset PROEDITION
431 For ease of exposition, ``GNAT Pro'' will be referred to simply as
432 ``GNAT'' in the remainder of this document.
433 @end ifset
435 @menu
436 * What This Reference Manual Contains::
437 * Conventions::
438 * Related Information::
439 @end menu
441 @node What This Reference Manual Contains
442 @unnumberedsec What This Reference Manual Contains
444 @noindent
445 This reference manual contains the following chapters:
447 @itemize @bullet
448 @item
449 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
450 pragmas, which can be used to extend and enhance the functionality of the
451 compiler.
453 @item
454 @ref{Implementation Defined Attributes}, lists GNAT
455 implementation-dependent attributes which can be used to extend and
456 enhance the functionality of the compiler.
458 @item
459 @ref{Implementation Advice}, provides information on generally
460 desirable behavior which are not requirements that all compilers must
461 follow since it cannot be provided on all systems, or which may be
462 undesirable on some systems.
464 @item
465 @ref{Implementation Defined Characteristics}, provides a guide to
466 minimizing implementation dependent features.
468 @item
469 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
470 implemented by GNAT, and how they can be imported into user
471 application programs.
473 @item
474 @ref{Representation Clauses and Pragmas}, describes in detail the
475 way that GNAT represents data, and in particular the exact set
476 of representation clauses and pragmas that is accepted.
478 @item
479 @ref{Standard Library Routines}, provides a listing of packages and a
480 brief description of the functionality that is provided by Ada's
481 extensive set of standard library routines as implemented by GNAT@.
483 @item
484 @ref{The Implementation of Standard I/O}, details how the GNAT
485 implementation of the input-output facilities.
487 @item
488 @ref{The GNAT Library}, is a catalog of packages that complement
489 the Ada predefined library.
491 @item
492 @ref{Interfacing to Other Languages}, describes how programs
493 written in Ada using GNAT can be interfaced to other programming
494 languages.
496 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
497 of the specialized needs annexes.
499 @item
500 @ref{Implementation of Specific Ada Features}, discusses issues related
501 to GNAT's implementation of machine code insertions, tasking, and several
502 other features.
504 @item
505 @ref{Project File Reference}, presents the syntax and semantics
506 of project files.
508 @item
509 @ref{Obsolescent Features} documents implementation dependent features,
510 including pragmas and attributes, which are considered obsolescent, since
511 there are other preferred ways of achieving the same results. These
512 obsolescent forms are retained for backwards compatibilty.
514 @end itemize
516 @cindex Ada 95 ISO/ANSI Standard
517 @noindent
518 This reference manual assumes that you are familiar with Ada 95
519 language, as described in the International Standard
520 ANSI/ISO/IEC-8652:1995, Jan 1995.
522 @node Conventions
523 @unnumberedsec Conventions
524 @cindex Conventions, typographical
525 @cindex Typographical conventions
527 @noindent
528 Following are examples of the typographical and graphic conventions used
529 in this guide:
531 @itemize @bullet
532 @item
533 @code{Functions}, @code{utility program names}, @code{standard names},
534 and @code{classes}.
536 @item
537 @code{Option flags}
539 @item
540 @file{File Names}, @samp{button names}, and @samp{field names}.
542 @item
543 @code{Variables}.
545 @item
546 @emph{Emphasis}.
548 @item
549 [optional information or parameters]
551 @item
552 Examples are described by text
553 @smallexample
554 and then shown this way.
555 @end smallexample
556 @end itemize
558 @noindent
559 Commands that are entered by the user are preceded in this manual by the
560 characters @samp{$ } (dollar sign followed by space).  If your system uses this
561 sequence as a prompt, then the commands will appear exactly as you see them
562 in the manual.  If your system uses some other prompt, then the command will
563 appear with the @samp{$} replaced by whatever prompt character you are using.
565 @node Related Information
566 @unnumberedsec Related Information
567 @noindent
568 See the following documents for further information on GNAT:
570 @itemize @bullet
571 @item
572 @cite{GNAT User's Guide}, which provides information on how to use
573 the GNAT compiler system.
575 @item
576 @cite{Ada 95 Reference Manual}, which contains all reference
577 material for the Ada 95 programming language.
579 @item
580 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
581 of the standard reference manual cited above.  The annotations describe
582 detailed aspects of the design decision, and in particular contain useful
583 sections on Ada 83 compatibility.
585 @item
586 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
587 which contains specific information on compatibility between GNAT and
588 DEC Ada 83 systems.
590 @item
591 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
592 describes in detail the pragmas and attributes provided by the DEC Ada 83
593 compiler system.
595 @end itemize
597 @node Implementation Defined Pragmas
598 @chapter Implementation Defined Pragmas
600 @noindent
601 Ada 95 defines a set of pragmas that can be used to supply additional
602 information to the compiler.  These language defined pragmas are
603 implemented in GNAT and work as described in the Ada 95 Reference
604 Manual.
606 In addition, Ada 95 allows implementations to define additional pragmas
607 whose meaning is defined by the implementation.  GNAT provides a number
608 of these implementation-dependent pragmas which can be used to extend
609 and enhance the functionality of the compiler.  This section of the GNAT
610 Reference Manual describes these additional pragmas.
612 Note that any program using these pragmas may not be portable to other
613 compilers (although GNAT implements this set of pragmas on all
614 platforms).  Therefore if portability to other compilers is an important
615 consideration, the use of these pragmas should be minimized.
617 @menu
618 * Pragma Abort_Defer::
619 * Pragma Ada_83::
620 * Pragma Ada_95::
621 * Pragma Annotate::
622 * Pragma Assert::
623 * Pragma Ast_Entry::
624 * Pragma C_Pass_By_Copy::
625 * Pragma Comment::
626 * Pragma Common_Object::
627 * Pragma Compile_Time_Warning::
628 * Pragma Complex_Representation::
629 * Pragma Component_Alignment::
630 * Pragma Convention_Identifier::
631 * Pragma CPP_Class::
632 * Pragma CPP_Constructor::
633 * Pragma CPP_Virtual::
634 * Pragma CPP_Vtable::
635 * Pragma Debug::
636 * Pragma Detect_Blocking::
637 * Pragma Elaboration_Checks::
638 * Pragma Eliminate::
639 * Pragma Export_Exception::
640 * Pragma Export_Function::
641 * Pragma Export_Object::
642 * Pragma Export_Procedure::
643 * Pragma Export_Value::
644 * Pragma Export_Valued_Procedure::
645 * Pragma Extend_System::
646 * Pragma External::
647 * Pragma External_Name_Casing::
648 * Pragma Finalize_Storage_Only::
649 * Pragma Float_Representation::
650 * Pragma Ident::
651 * Pragma Import_Exception::
652 * Pragma Import_Function::
653 * Pragma Import_Object::
654 * Pragma Import_Procedure::
655 * Pragma Import_Valued_Procedure::
656 * Pragma Initialize_Scalars::
657 * Pragma Inline_Always::
658 * Pragma Inline_Generic::
659 * Pragma Interface::
660 * Pragma Interface_Name::
661 * Pragma Interrupt_Handler::
662 * Pragma Interrupt_State::
663 * Pragma Keep_Names::
664 * Pragma License::
665 * Pragma Link_With::
666 * Pragma Linker_Alias::
667 * Pragma Linker_Section::
668 * Pragma Long_Float::
669 * Pragma Machine_Attribute::
670 * Pragma Main_Storage::
671 * Pragma No_Return::
672 * Pragma Normalize_Scalars::
673 * Pragma Obsolescent::
674 * Pragma Passive::
675 * Pragma Polling::
676 * Pragma Profile (Ravenscar)::
677 * Pragma Profile (Restricted)::
678 * Pragma Propagate_Exceptions::
679 * Pragma Psect_Object::
680 * Pragma Pure_Function::
681 * Pragma Restriction_Warnings::
682 * Pragma Source_File_Name::
683 * Pragma Source_File_Name_Project::
684 * Pragma Source_Reference::
685 * Pragma Stream_Convert::
686 * Pragma Style_Checks::
687 * Pragma Subtitle::
688 * Pragma Suppress_All::
689 * Pragma Suppress_Exception_Locations::
690 * Pragma Suppress_Initialization::
691 * Pragma Task_Info::
692 * Pragma Task_Name::
693 * Pragma Task_Storage::
694 * Pragma Thread_Body::
695 * Pragma Time_Slice::
696 * Pragma Title::
697 * Pragma Unchecked_Union::
698 * Pragma Unimplemented_Unit::
699 * Pragma Universal_Data::
700 * Pragma Unreferenced::
701 * Pragma Unreserve_All_Interrupts::
702 * Pragma Unsuppress::
703 * Pragma Use_VADS_Size::
704 * Pragma Validity_Checks::
705 * Pragma Volatile::
706 * Pragma Warnings::
707 * Pragma Weak_External::
708 @end menu
710 @node Pragma Abort_Defer
711 @unnumberedsec Pragma Abort_Defer
712 @findex Abort_Defer
713 @cindex Deferring aborts
714 @noindent
715 Syntax:
716 @smallexample
717 pragma Abort_Defer;
718 @end smallexample
720 @noindent
721 This pragma must appear at the start of the statement sequence of a
722 handled sequence of statements (right after the @code{begin}).  It has
723 the effect of deferring aborts for the sequence of statements (but not
724 for the declarations or handlers, if any, associated with this statement
725 sequence).
727 @node Pragma Ada_83
728 @unnumberedsec Pragma Ada_83
729 @findex Ada_83
730 @noindent
731 Syntax:
732 @smallexample @c ada
733 pragma Ada_83;
734 @end smallexample
736 @noindent
737 A configuration pragma that establishes Ada 83 mode for the unit to
738 which it applies, regardless of the mode set by the command line
739 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
740 the syntax and semantics of Ada 83, as defined in the original Ada
741 83 Reference Manual as possible.  In particular, the new Ada 95
742 keywords are not recognized, optional package bodies are allowed,
743 and generics may name types with unknown discriminants without using
744 the @code{(<>)} notation.  In addition, some but not all of the additional
745 restrictions of Ada 83 are enforced.
747 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
748 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
749 Secondly, it aids in keeping code backwards compatible with Ada 83.
750 However, there is no guarantee that code that is processed correctly
751 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
752 83 compiler, since GNAT does not enforce all the additional checks
753 required by Ada 83.
755 @node Pragma Ada_95
756 @unnumberedsec Pragma Ada_95
757 @findex Ada_95
758 @noindent
759 Syntax:
760 @smallexample @c ada
761 pragma Ada_95;
762 @end smallexample
764 @noindent
765 A configuration pragma that establishes Ada 95 mode for the unit to which
766 it applies, regardless of the mode set by the command line switches.
767 This mode is set automatically for the @code{Ada} and @code{System}
768 packages and their children, so you need not specify it in these
769 contexts.  This pragma is useful when writing a reusable component that
770 itself uses Ada 95 features, but which is intended to be usable from
771 either Ada 83 or Ada 95 programs.
773 @node Pragma Annotate
774 @unnumberedsec Pragma Annotate
775 @findex Annotate
776 @noindent
777 Syntax:
778 @smallexample @c ada
779 pragma Annotate (IDENTIFIER @{, ARG@});
781 ARG ::= NAME | EXPRESSION
782 @end smallexample
784 @noindent
785 This pragma is used to annotate programs.  @var{identifier} identifies
786 the type of annotation.  GNAT verifies this is an identifier, but does
787 not otherwise analyze it.  The @var{arg} argument
788 can be either a string literal or an
789 expression.  String literals are assumed to be of type
790 @code{Standard.String}.  Names of entities are simply analyzed as entity
791 names.  All other expressions are analyzed as expressions, and must be
792 unambiguous.
794 The analyzed pragma is retained in the tree, but not otherwise processed
795 by any part of the GNAT compiler.  This pragma is intended for use by
796 external tools, including ASIS@.
798 @node Pragma Assert
799 @unnumberedsec Pragma Assert
800 @findex Assert
801 @noindent
802 Syntax:
803 @smallexample @c ada
804 pragma Assert (
805   boolean_EXPRESSION
806   [, static_string_EXPRESSION]);
807 @end smallexample
809 @noindent
810 The effect of this pragma depends on whether the corresponding command
811 line switch is set to activate assertions.  The pragma expands into code
812 equivalent to the following:
814 @smallexample @c ada
815 if assertions-enabled then
816    if not boolean_EXPRESSION then
817       System.Assertions.Raise_Assert_Failure
818         (string_EXPRESSION);
819    end if;
820 end if;
821 @end smallexample
823 @noindent
824 The string argument, if given, is the message that will be associated
825 with the exception occurrence if the exception is raised.  If no second
826 argument is given, the default message is @samp{@var{file}:@var{nnn}},
827 where @var{file} is the name of the source file containing the assert,
828 and @var{nnn} is the line number of the assert.  A pragma is not a
829 statement, so if a statement sequence contains nothing but a pragma
830 assert, then a null statement is required in addition, as in:
832 @smallexample @c ada
833 @dots{}
834 if J > 3 then
835    pragma Assert (K > 3, "Bad value for K");
836    null;
837 end if;
838 @end smallexample
840 @noindent
841 Note that, as with the @code{if} statement to which it is equivalent, the
842 type of the expression is either @code{Standard.Boolean}, or any type derived
843 from this standard type.
845 If assertions are disabled (switch @code{-gnata} not used), then there
846 is no effect (and in particular, any side effects from the expression
847 are suppressed).  More precisely it is not quite true that the pragma
848 has no effect, since the expression is analyzed, and may cause types
849 to be frozen if they are mentioned here for the first time.
851 If assertions are enabled, then the given expression is tested, and if
852 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
853 which results in the raising of @code{Assert_Failure} with the given message.
855 If the boolean expression has side effects, these side effects will turn
856 on and off with the setting of the assertions mode, resulting in
857 assertions that have an effect on the program.  You should generally
858 avoid side effects in the expression arguments of this pragma.  However,
859 the expressions are analyzed for semantic correctness whether or not
860 assertions are enabled, so turning assertions on and off cannot affect
861 the legality of a program.
863 @node Pragma Ast_Entry
864 @unnumberedsec Pragma Ast_Entry
865 @cindex OpenVMS
866 @findex Ast_Entry
867 @noindent
868 Syntax:
869 @smallexample @c ada
870 pragma AST_Entry (entry_IDENTIFIER);
871 @end smallexample
873 @noindent
874 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
875 argument is the simple name of a single entry; at most one @code{AST_Entry}
876 pragma is allowed for any given entry.  This pragma must be used in
877 conjunction with the @code{AST_Entry} attribute, and is only allowed after
878 the entry declaration and in the same task type specification or single task
879 as the entry to which it applies.  This pragma specifies that the given entry
880 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
881 resulting from an OpenVMS system service call.  The pragma does not affect
882 normal use of the entry.  For further details on this pragma, see the
883 DEC Ada Language Reference Manual, section 9.12a.
885 @node Pragma C_Pass_By_Copy
886 @unnumberedsec Pragma C_Pass_By_Copy
887 @cindex Passing by copy
888 @findex C_Pass_By_Copy
889 @noindent
890 Syntax:
891 @smallexample @c ada
892 pragma C_Pass_By_Copy
893   ([Max_Size =>] static_integer_EXPRESSION);
894 @end smallexample
896 @noindent
897 Normally the default mechanism for passing C convention records to C
898 convention subprograms is to pass them by reference, as suggested by RM
899 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
900 this default, by requiring that record formal parameters be passed by
901 copy if all of the following conditions are met:
903 @itemize @bullet
904 @item
905 The size of the record type does not exceed@*@var{static_integer_expression}.
906 @item
907 The record type has @code{Convention C}.
908 @item
909 The formal parameter has this record type, and the subprogram has a
910 foreign (non-Ada) convention.
911 @end itemize
913 @noindent
914 If these conditions are met the argument is passed by copy, i.e.@: in a
915 manner consistent with what C expects if the corresponding formal in the
916 C prototype is a struct (rather than a pointer to a struct).
918 You can also pass records by copy by specifying the convention
919 @code{C_Pass_By_Copy} for the record type, or by using the extended
920 @code{Import} and @code{Export} pragmas, which allow specification of
921 passing mechanisms on a parameter by parameter basis.
923 @node Pragma Comment
924 @unnumberedsec Pragma Comment
925 @findex Comment
926 @noindent
927 Syntax:
929 @smallexample @c ada
930 pragma Comment (static_string_EXPRESSION);
931 @end smallexample
933 @noindent
934 This is almost identical in effect to pragma @code{Ident}.  It allows the
935 placement of a comment into the object file and hence into the
936 executable file if the operating system permits such usage.  The
937 difference is that @code{Comment}, unlike @code{Ident}, has
938 no limitations on placement of the pragma (it can be placed
939 anywhere in the main source unit), and if more than one pragma
940 is used, all comments are retained.
942 @node Pragma Common_Object
943 @unnumberedsec Pragma Common_Object
944 @findex Common_Object
945 @noindent
946 Syntax:
948 @smallexample @c ada
949 pragma Common_Object (
950      [Internal =>] LOCAL_NAME,
951   [, [External =>] EXTERNAL_SYMBOL]
952   [, [Size     =>] EXTERNAL_SYMBOL] );
954 EXTERNAL_SYMBOL ::=
955   IDENTIFIER
956 | static_string_EXPRESSION
957 @end smallexample
959 @noindent
960 This pragma enables the shared use of variables stored in overlaid
961 linker areas corresponding to the use of @code{COMMON}
962 in Fortran.  The single
963 object @var{local_name} is assigned to the area designated by
964 the @var{External} argument.
965 You may define a record to correspond to a series
966 of fields.  The @var{size} argument
967 is syntax checked in GNAT, but otherwise ignored.
969 @code{Common_Object} is not supported on all platforms.  If no
970 support is available, then the code generator will issue a message
971 indicating that the necessary attribute for implementation of this
972 pragma is not available.
974 @node Pragma Compile_Time_Warning
975 @unnumberedsec Pragma Compile_Time_Warning
976 @findex Compile_Time_Warning
977 @noindent
978 Syntax:
980 @smallexample @c ada
981 pragma Compile_Time_Warning
982          (boolean_EXPRESSION, static_string_EXPRESSION);
983 @end smallexample
985 @noindent
986 This pragma can be used to generate additional compile time warnings. It
987 is particularly useful in generics, where warnings can be issued for
988 specific problematic instantiations. The first parameter is a boolean
989 expression. The pragma is effective only if the value of this expression
990 is known at compile time, and has the value True. The set of expressions
991 whose values are known at compile time includes all static boolean
992 expressions, and also other values which the compiler can determine
993 at compile time (e.g. the size of a record type set by an explicit
994 size representation clause, or the value of a variable which was
995 initialized to a constant and is known not to have been modified).
996 If these conditions are met, a warning message is generated using
997 the value given as the second argument. This string value may contain
998 embedded ASCII.LF characters to break the message into multiple lines.
1000 @node Pragma Complex_Representation
1001 @unnumberedsec Pragma Complex_Representation
1002 @findex Complex_Representation
1003 @noindent
1004 Syntax:
1006 @smallexample @c ada
1007 pragma Complex_Representation
1008         ([Entity =>] LOCAL_NAME);
1009 @end smallexample
1011 @noindent
1012 The @var{Entity} argument must be the name of a record type which has
1013 two fields of the same floating-point type.  The effect of this pragma is
1014 to force gcc to use the special internal complex representation form for
1015 this record, which may be more efficient.  Note that this may result in
1016 the code for this type not conforming to standard ABI (application
1017 binary interface) requirements for the handling of record types.  For
1018 example, in some environments, there is a requirement for passing
1019 records by pointer, and the use of this pragma may result in passing
1020 this type in floating-point registers.
1022 @node Pragma Component_Alignment
1023 @unnumberedsec Pragma Component_Alignment
1024 @cindex Alignments of components
1025 @findex Component_Alignment
1026 @noindent
1027 Syntax:
1029 @smallexample @c ada
1030 pragma Component_Alignment (
1031      [Form =>] ALIGNMENT_CHOICE
1032   [, [Name =>] type_LOCAL_NAME]);
1034 ALIGNMENT_CHOICE ::=
1035   Component_Size
1036 | Component_Size_4
1037 | Storage_Unit
1038 | Default
1039 @end smallexample
1041 @noindent
1042 Specifies the alignment of components in array or record types.
1043 The meaning of the @var{Form} argument is as follows:
1045 @table @code
1046 @findex Component_Size
1047 @item Component_Size
1048 Aligns scalar components and subcomponents of the array or record type
1049 on boundaries appropriate to their inherent size (naturally
1050 aligned).  For example, 1-byte components are aligned on byte boundaries,
1051 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1052 integer components are aligned on 4-byte boundaries and so on.  These
1053 alignment rules correspond to the normal rules for C compilers on all
1054 machines except the VAX@.
1056 @findex Component_Size_4
1057 @item Component_Size_4
1058 Naturally aligns components with a size of four or fewer
1059 bytes.  Components that are larger than 4 bytes are placed on the next
1060 4-byte boundary.
1062 @findex Storage_Unit
1063 @item Storage_Unit
1064 Specifies that array or record components are byte aligned, i.e.@:
1065 aligned on boundaries determined by the value of the constant
1066 @code{System.Storage_Unit}.
1068 @cindex OpenVMS
1069 @item Default
1070 Specifies that array or record components are aligned on default
1071 boundaries, appropriate to the underlying hardware or operating system or
1072 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1073 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1074 the @code{Default} choice is the same as @code{Component_Size} (natural
1075 alignment).
1076 @end table
1078 @noindent
1079 If the @code{Name} parameter is present, @var{type_local_name} must
1080 refer to a local record or array type, and the specified alignment
1081 choice applies to the specified type.  The use of
1082 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1083 @code{Component_Alignment} pragma to be ignored.  The use of
1084 @code{Component_Alignment} together with a record representation clause
1085 is only effective for fields not specified by the representation clause.
1087 If the @code{Name} parameter is absent, the pragma can be used as either
1088 a configuration pragma, in which case it applies to one or more units in
1089 accordance with the normal rules for configuration pragmas, or it can be
1090 used within a declarative part, in which case it applies to types that
1091 are declared within this declarative part, or within any nested scope
1092 within this declarative part.  In either case it specifies the alignment
1093 to be applied to any record or array type which has otherwise standard
1094 representation.
1096 If the alignment for a record or array type is not specified (using
1097 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1098 clause), the GNAT uses the default alignment as described previously.
1100 @node Pragma Convention_Identifier
1101 @unnumberedsec Pragma Convention_Identifier
1102 @findex Convention_Identifier
1103 @cindex Conventions, synonyms
1104 @noindent
1105 Syntax:
1107 @smallexample @c ada
1108 pragma Convention_Identifier (
1109          [Name =>]       IDENTIFIER,
1110          [Convention =>] convention_IDENTIFIER);
1111 @end smallexample
1113 @noindent
1114 This pragma provides a mechanism for supplying synonyms for existing
1115 convention identifiers. The @code{Name} identifier can subsequently
1116 be used as a synonym for the given convention in other pragmas (including
1117 for example pragma @code{Import} or another @code{Convention_Identifier}
1118 pragma). As an example of the use of this, suppose you had legacy code
1119 which used Fortran77 as the identifier for Fortran. Then the pragma:
1121 @smallexample @c ada
1122 pragma Convention_Identifier (Fortran77, Fortran);
1123 @end smallexample
1125 @noindent
1126 would allow the use of the convention identifier @code{Fortran77} in
1127 subsequent code, avoiding the need to modify the sources. As another
1128 example, you could use this to parametrize convention requirements
1129 according to systems. Suppose you needed to use @code{Stdcall} on
1130 windows systems, and @code{C} on some other system, then you could
1131 define a convention identifier @code{Library} and use a single
1132 @code{Convention_Identifier} pragma to specify which convention
1133 would be used system-wide.
1135 @node Pragma CPP_Class
1136 @unnumberedsec Pragma CPP_Class
1137 @findex CPP_Class
1138 @cindex Interfacing with C++
1139 @noindent
1140 Syntax:
1142 @smallexample @c ada
1143 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1144 @end smallexample
1146 @noindent
1147 The argument denotes an entity in the current declarative region
1148 that is declared as a tagged or untagged record type.  It indicates that
1149 the type corresponds to an externally declared C++ class type, and is to
1150 be laid out the same way that C++ would lay out the type.
1152 If (and only if) the type is tagged, at least one component in the
1153 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1154 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1155 for dispatching.
1157 Types for which @code{CPP_Class} is specified do not have assignment or
1158 equality operators defined (such operations can be imported or declared
1159 as subprograms as required).  Initialization is allowed only by
1160 constructor functions (see pragma @code{CPP_Constructor}).
1162 Pragma @code{CPP_Class} is intended primarily for automatic generation
1163 using an automatic binding generator tool.
1164 See @ref{Interfacing to C++} for related information.
1166 @node Pragma CPP_Constructor
1167 @unnumberedsec Pragma CPP_Constructor
1168 @cindex Interfacing with C++
1169 @findex CPP_Constructor
1170 @noindent
1171 Syntax:
1173 @smallexample @c ada
1174 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1175 @end smallexample
1177 @noindent
1178 This pragma identifies an imported function (imported in the usual way
1179 with pragma @code{Import}) as corresponding to a C++
1180 constructor.  The argument is a name that must have been
1181 previously mentioned in a pragma @code{Import}
1182 with @code{Convention} = @code{CPP}, and must be of one of the following
1183 forms:
1185 @itemize @bullet
1186 @item
1187 @code{function @var{Fname} return @var{T}'Class}
1189 @item
1190 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1191 @end itemize
1193 @noindent
1194 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1196 The first form is the default constructor, used when an object of type
1197 @var{T} is created on the Ada side with no explicit constructor.  Other
1198 constructors (including the copy constructor, which is simply a special
1199 case of the second form in which the one and only argument is of type
1200 @var{T}), can only appear in two contexts:
1202 @itemize @bullet
1203 @item
1204 On the right side of an initialization of an object of type @var{T}.
1205 @item
1206 In an extension aggregate for an object of a type derived from @var{T}.
1207 @end itemize
1209 @noindent
1210 Although the constructor is described as a function that returns a value
1211 on the Ada side, it is typically a procedure with an extra implicit
1212 argument (the object being initialized) at the implementation
1213 level.  GNAT issues the appropriate call, whatever it is, to get the
1214 object properly initialized.
1216 In the case of derived objects, you may use one of two possible forms
1217 for declaring and creating an object:
1219 @itemize @bullet
1220 @item @code{New_Object : Derived_T}
1221 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1222 @end itemize
1224 @noindent
1225 In the first case the default constructor is called and extension fields
1226 if any are initialized according to the default initialization
1227 expressions in the Ada declaration.  In the second case, the given
1228 constructor is called and the extension aggregate indicates the explicit
1229 values of the extension fields.
1231 If no constructors are imported, it is impossible to create any objects
1232 on the Ada side.  If no default constructor is imported, only the
1233 initialization forms using an explicit call to a constructor are
1234 permitted.
1236 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1237 using an automatic binding generator tool.
1238 See @ref{Interfacing to C++} for more related information.
1240 @node Pragma CPP_Virtual
1241 @unnumberedsec Pragma CPP_Virtual
1242 @cindex Interfacing to C++
1243 @findex CPP_Virtual
1244 @noindent
1245 Syntax:
1247 @smallexample @c ada
1248 pragma CPP_Virtual
1249      [Entity     =>] ENTITY,
1250   [, [Vtable_Ptr =>] vtable_ENTITY,]
1251   [, [Position   =>] static_integer_EXPRESSION]);
1252 @end smallexample
1254 @noindent
1255 This pragma serves the same function as pragma @code{Import} in that
1256 case of a virtual function imported from C++.  The @var{Entity} argument
1257 must be a
1258 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1259 applies.  The @var{Vtable_Ptr} argument specifies
1260 the Vtable_Ptr component which contains the
1261 entry for this virtual function.  The @var{Position} argument
1262 is the sequential number
1263 counting virtual functions for this Vtable starting at 1.
1265 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1266 there is one Vtable_Ptr present (single inheritance case) and all
1267 virtual functions are imported.  In that case the compiler can deduce both
1268 these values.
1270 No @code{External_Name} or @code{Link_Name} arguments are required for a
1271 virtual function, since it is always accessed indirectly via the
1272 appropriate Vtable entry.
1274 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1275 using an automatic binding generator tool.
1276 See @ref{Interfacing to C++} for related information.
1278 @node Pragma CPP_Vtable
1279 @unnumberedsec Pragma CPP_Vtable
1280 @cindex Interfacing with C++
1281 @findex CPP_Vtable
1282 @noindent
1283 Syntax:
1285 @smallexample @c ada
1286 pragma CPP_Vtable (
1287   [Entity      =>] ENTITY,
1288   [Vtable_Ptr  =>] vtable_ENTITY,
1289   [Entry_Count =>] static_integer_EXPRESSION);
1290 @end smallexample
1292 @noindent
1293 Given a record to which the pragma @code{CPP_Class} applies,
1294 this pragma can be specified for each component of type
1295 @code{CPP.Interfaces.Vtable_Ptr}.
1296 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1297 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1298 the number of virtual functions on the C++ side.  Not all of these
1299 functions need to be imported on the Ada side.
1301 You may omit the @code{CPP_Vtable} pragma if there is only one
1302 @code{Vtable_Ptr} component in the record and all virtual functions are
1303 imported on the Ada side (the default value for the entry count in this
1304 case is simply the total number of virtual functions).
1306 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1307 using an automatic binding generator tool.
1308 See @ref{Interfacing to C++} for related information.
1310 @node Pragma Debug
1311 @unnumberedsec Pragma Debug
1312 @findex Debug
1313 @noindent
1314 Syntax:
1316 @smallexample @c ada
1317 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1319 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1320   PROCEDURE_NAME
1321 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1322 @end smallexample
1324 @noindent
1325 The argument has the syntactic form of an expression, meeting the
1326 syntactic requirements for pragmas.
1328 If assertions are not enabled on the command line, this pragma has no
1329 effect.  If asserts are enabled, the semantics of the pragma is exactly
1330 equivalent to the procedure call statement corresponding to the argument
1331 with a terminating semicolon.  Pragmas are permitted in sequences of
1332 declarations, so you can use pragma @code{Debug} to intersperse calls to
1333 debug procedures in the middle of declarations.
1335 @node Pragma Detect_Blocking
1336 @unnumberedsec Pragma Detect_Blocking
1337 @findex Detect_Blocking
1338 @noindent
1339 Syntax:
1341 @smallexample @c ada
1342 pragma Detect_Blocking;
1343 @end smallexample
1345 @noindent
1346 This is a configuration pragma that forces the detection of potentially
1347 blocking operations within a protected operation, and to raise Program_Error
1348 if that happens.
1350 @node Pragma Elaboration_Checks
1351 @unnumberedsec Pragma Elaboration_Checks
1352 @cindex Elaboration control
1353 @findex Elaboration_Checks
1354 @noindent
1355 Syntax:
1357 @smallexample @c ada
1358 pragma Elaboration_Checks (Dynamic | Static);
1359 @end smallexample
1361 @noindent
1362 This is a configuration pragma that provides control over the
1363 elaboration model used by the compilation affected by the
1364 pragma.  If the parameter is @code{Dynamic},
1365 then the dynamic elaboration
1366 model described in the Ada Reference Manual is used, as though
1367 the @code{-gnatE} switch had been specified on the command
1368 line.  If the parameter is @code{Static}, then the default GNAT static
1369 model is used.  This configuration pragma overrides the setting
1370 of the command line.  For full details on the elaboration models
1371 used by the GNAT compiler, see section ``Elaboration Order
1372 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1374 @node Pragma Eliminate
1375 @unnumberedsec Pragma Eliminate
1376 @cindex Elimination of unused subprograms
1377 @findex Eliminate
1378 @noindent
1379 Syntax:
1381 @smallexample @c ada
1382 pragma Eliminate (
1383     [Unit_Name =>] IDENTIFIER |
1384                    SELECTED_COMPONENT);
1386 pragma Eliminate (
1387     [Unit_Name       =>]  IDENTIFIER |
1388                           SELECTED_COMPONENT,
1389     [Entity          =>]  IDENTIFIER |
1390                           SELECTED_COMPONENT |
1391                           STRING_LITERAL
1392     [,OVERLOADING_RESOLUTION]);
1394 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1395                            SOURCE_LOCATION
1397 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1398                                       FUNCTION_PROFILE
1400 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1402 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1403                       Result_Type => result_SUBTYPE_NAME]
1405 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1406 SUBTYPE_NAME    ::= STRING_VALUE
1408 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1409 SOURCE_TRACE    ::= STRING_VALUE
1411 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1412 @end smallexample
1414 @noindent
1415 This pragma indicates that the given entity is not used outside the
1416 compilation unit it is defined in. The entity must be an explicitly declared
1417 subprogram; this includes  generic subprogram instances and
1418 subprograms declared in generic package instances.
1420 If the entity to be eliminated is a library level subprogram, then
1421 the first form of pragma @code{Eliminate} is used with only a single argument.
1422 In this form, the @code{Unit_Name} argument specifies the name of the
1423 library  level unit to be eliminated.
1425 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1426 are required. If item is an entity of a library package, then the first
1427 argument specifies the unit name, and the second argument specifies
1428 the particular entity.  If the second argument is in string form, it must
1429 correspond to the internal manner in which GNAT stores entity names (see
1430 compilation unit Namet in the compiler sources for details).
1432 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1433 to distinguish between overloaded subprograms. If a pragma does not contain
1434 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1435 subprograms denoted by the first two parameters.
1437 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1438 to be eliminated in a manner similar to that used for the extended
1439 @code{Import} and @code{Export} pragmas, except that the subtype names are
1440 always given as strings. At the moment, this form of distinguishing
1441 overloaded subprograms is implemented only partially, so we do not recommend
1442 using it for practical subprogram elimination.
1444 Note, that in case of a parameterless procedure its profile is represented
1445 as @code{Parameter_Types => ("")}
1447 Alternatively, the @code{Source_Location} parameter is used to specify
1448 which overloaded alternative is to be eliminated by pointing to the
1449 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1450 source text. The string literal (or concatenation of string literals)
1451 given as SOURCE_TRACE must have the following format:
1453 @smallexample @c ada
1454 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1456 LBRACKET ::= [
1457 RBRACKET ::= ]
1459 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1460 FILE_NAME       ::= STRING_LITERAL
1461 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1462 @end smallexample
1464 SOURCE_TRACE should be the short name of the source file (with no directory
1465 information), and LINE_NUMBER is supposed to point to the line where the
1466 defining name of the subprogram is located.
1468 For the subprograms that are not a part of generic instantiations, only one
1469 SOURCE_LOCATION is used. If a subprogram is declared in a package
1470 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1471 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1472 second one denotes the declaration of the corresponding subprogram in the
1473 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1474 in case of nested instantiations.
1476 The effect of the pragma is to allow the compiler to eliminate
1477 the code or data associated with the named entity.  Any reference to
1478 an eliminated entity outside the compilation unit it is defined in,
1479 causes a compile time or link time error.
1481 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1482 in a system independent manner, with unused entities eliminated, without
1483 the requirement of modifying the source text.  Normally the required set
1484 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1485 tool. Elimination of unused entities local to a compilation unit is
1486 automatic, without requiring the use of pragma @code{Eliminate}.
1488 Note that the reason this pragma takes string literals where names might
1489 be expected is that a pragma @code{Eliminate} can appear in a context where the
1490 relevant names are not visible.
1492 Note that any change in the source files that includes removing, splitting of
1493 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1494 parameter illegal.
1496 @node Pragma Export_Exception
1497 @unnumberedsec Pragma Export_Exception
1498 @cindex OpenVMS
1499 @findex Export_Exception
1500 @noindent
1501 Syntax:
1503 @smallexample @c ada
1504 pragma Export_Exception (
1505      [Internal =>] LOCAL_NAME,
1506   [, [External =>] EXTERNAL_SYMBOL,]
1507   [, [Form     =>] Ada | VMS]
1508   [, [Code     =>] static_integer_EXPRESSION]);
1510 EXTERNAL_SYMBOL ::=
1511   IDENTIFIER
1512 | static_string_EXPRESSION
1513 @end smallexample
1515 @noindent
1516 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1517 causes the specified exception to be propagated outside of the Ada program,
1518 so that it can be handled by programs written in other OpenVMS languages.
1519 This pragma establishes an external name for an Ada exception and makes the
1520 name available to the OpenVMS Linker as a global symbol.  For further details
1521 on this pragma, see the
1522 DEC Ada Language Reference Manual, section 13.9a3.2.
1524 @node Pragma Export_Function
1525 @unnumberedsec Pragma Export_Function
1526 @cindex Argument passing mechanisms
1527 @findex Export_Function
1529 @noindent
1530 Syntax:
1532 @smallexample @c ada
1533 pragma Export_Function (
1534      [Internal         =>] LOCAL_NAME,
1535   [, [External         =>] EXTERNAL_SYMBOL]
1536   [, [Parameter_Types  =>] PARAMETER_TYPES]
1537   [, [Result_Type      =>] result_SUBTYPE_MARK]
1538   [, [Mechanism        =>] MECHANISM]
1539   [, [Result_Mechanism =>] MECHANISM_NAME]);
1541 EXTERNAL_SYMBOL ::=
1542   IDENTIFIER
1543 | static_string_EXPRESSION
1544 | ""
1546 PARAMETER_TYPES ::=
1547   null
1548 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1550 TYPE_DESIGNATOR ::=
1551   subtype_NAME
1552 | subtype_Name ' Access
1554 MECHANISM ::=
1555   MECHANISM_NAME
1556 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1558 MECHANISM_ASSOCIATION ::=
1559   [formal_parameter_NAME =>] MECHANISM_NAME
1561 MECHANISM_NAME ::=
1562   Value
1563 | Reference
1564 @end smallexample
1566 @noindent
1567 Use this pragma to make a function externally callable and optionally
1568 provide information on mechanisms to be used for passing parameter and
1569 result values.  We recommend, for the purposes of improving portability,
1570 this pragma always be used in conjunction with a separate pragma
1571 @code{Export}, which must precede the pragma @code{Export_Function}.
1572 GNAT does not require a separate pragma @code{Export}, but if none is
1573 present, @code{Convention Ada} is assumed, which is usually
1574 not what is wanted, so it is usually appropriate to use this
1575 pragma in conjunction with a @code{Export} or @code{Convention}
1576 pragma that specifies the desired foreign convention.
1577 Pragma @code{Export_Function}
1578 (and @code{Export}, if present) must appear in the same declarative
1579 region as the function to which they apply.
1581 @var{internal_name} must uniquely designate the function to which the
1582 pragma applies.  If more than one function name exists of this name in
1583 the declarative part you must use the @code{Parameter_Types} and
1584 @code{Result_Type} parameters is mandatory to achieve the required
1585 unique designation.  @var{subtype_ mark}s in these parameters must
1586 exactly match the subtypes in the corresponding function specification,
1587 using positional notation to match parameters with subtype marks.
1588 The form with an @code{'Access} attribute can be used to match an
1589 anonymous access parameter.
1591 @cindex OpenVMS
1592 @cindex Passing by descriptor
1593 Note that passing by descriptor is not supported, even on the OpenVMS
1594 ports of GNAT@.
1596 @cindex Suppressing external name
1597 Special treatment is given if the EXTERNAL is an explicit null
1598 string or a static string expressions that evaluates to the null
1599 string. In this case, no external name is generated. This form
1600 still allows the specification of parameter mechanisms.
1602 @node Pragma Export_Object
1603 @unnumberedsec Pragma Export_Object
1604 @findex Export_Object
1605 @noindent
1606 Syntax:
1608 @smallexample @c ada
1609 pragma Export_Object
1610       [Internal =>] LOCAL_NAME,
1611    [, [External =>] EXTERNAL_SYMBOL]
1612    [, [Size     =>] EXTERNAL_SYMBOL]
1614 EXTERNAL_SYMBOL ::=
1615   IDENTIFIER
1616 | static_string_EXPRESSION
1617 @end smallexample
1619 @noindent
1620 This pragma designates an object as exported, and apart from the
1621 extended rules for external symbols, is identical in effect to the use of
1622 the normal @code{Export} pragma applied to an object.  You may use a
1623 separate Export pragma (and you probably should from the point of view
1624 of portability), but it is not required.  @var{Size} is syntax checked,
1625 but otherwise ignored by GNAT@.
1627 @node Pragma Export_Procedure
1628 @unnumberedsec Pragma Export_Procedure
1629 @findex Export_Procedure
1630 @noindent
1631 Syntax:
1633 @smallexample @c ada
1634 pragma Export_Procedure (
1635      [Internal        =>] LOCAL_NAME
1636   [, [External        =>] EXTERNAL_SYMBOL]
1637   [, [Parameter_Types =>] PARAMETER_TYPES]
1638   [, [Mechanism       =>] MECHANISM]);
1640 EXTERNAL_SYMBOL ::=
1641   IDENTIFIER
1642 | static_string_EXPRESSION
1643 | ""
1645 PARAMETER_TYPES ::=
1646   null
1647 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1649 TYPE_DESIGNATOR ::=
1650   subtype_NAME
1651 | subtype_Name ' Access
1653 MECHANISM ::=
1654   MECHANISM_NAME
1655 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1657 MECHANISM_ASSOCIATION ::=
1658   [formal_parameter_NAME =>] MECHANISM_NAME
1660 MECHANISM_NAME ::=
1661   Value
1662 | Reference
1663 @end smallexample
1665 @noindent
1666 This pragma is identical to @code{Export_Function} except that it
1667 applies to a procedure rather than a function and the parameters
1668 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1669 GNAT does not require a separate pragma @code{Export}, but if none is
1670 present, @code{Convention Ada} is assumed, which is usually
1671 not what is wanted, so it is usually appropriate to use this
1672 pragma in conjunction with a @code{Export} or @code{Convention}
1673 pragma that specifies the desired foreign convention.
1675 @cindex OpenVMS
1676 @cindex Passing by descriptor
1677 Note that passing by descriptor is not supported, even on the OpenVMS
1678 ports of GNAT@.
1680 @cindex Suppressing external name
1681 Special treatment is given if the EXTERNAL is an explicit null
1682 string or a static string expressions that evaluates to the null
1683 string. In this case, no external name is generated. This form
1684 still allows the specification of parameter mechanisms.
1686 @node Pragma Export_Value
1687 @unnumberedsec Pragma Export_Value
1688 @findex Export_Value
1689 @noindent
1690 Syntax:
1692 @smallexample @c ada
1693 pragma Export_Value (
1694   [Value     =>] static_integer_EXPRESSION,
1695   [Link_Name =>] static_string_EXPRESSION);
1696 @end smallexample
1698 @noindent
1699 This pragma serves to export a static integer value for external use.
1700 The first argument specifies the value to be exported. The Link_Name
1701 argument specifies the symbolic name to be associated with the integer
1702 value. This pragma is useful for defining a named static value in Ada
1703 that can be referenced in assembly language units to be linked with
1704 the application. This pragma is currently supported only for the
1705 AAMP target and is ignored for other targets.
1707 @node Pragma Export_Valued_Procedure
1708 @unnumberedsec Pragma Export_Valued_Procedure
1709 @findex Export_Valued_Procedure
1710 @noindent
1711 Syntax:
1713 @smallexample @c ada
1714 pragma Export_Valued_Procedure (
1715      [Internal        =>] LOCAL_NAME
1716   [, [External        =>] EXTERNAL_SYMBOL]
1717   [, [Parameter_Types =>] PARAMETER_TYPES]
1718   [, [Mechanism       =>] MECHANISM]);
1720 EXTERNAL_SYMBOL ::=
1721   IDENTIFIER
1722 | static_string_EXPRESSION
1723 | ""
1725 PARAMETER_TYPES ::=
1726   null
1727 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1729 TYPE_DESIGNATOR ::=
1730   subtype_NAME
1731 | subtype_Name ' Access
1733 MECHANISM ::=
1734   MECHANISM_NAME
1735 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1737 MECHANISM_ASSOCIATION ::=
1738   [formal_parameter_NAME =>] MECHANISM_NAME
1740 MECHANISM_NAME ::=
1741   Value
1742 | Reference
1743 @end smallexample
1745 @noindent
1746 This pragma is identical to @code{Export_Procedure} except that the
1747 first parameter of @var{local_name}, which must be present, must be of
1748 mode @code{OUT}, and externally the subprogram is treated as a function
1749 with this parameter as the result of the function.  GNAT provides for
1750 this capability to allow the use of @code{OUT} and @code{IN OUT}
1751 parameters in interfacing to external functions (which are not permitted
1752 in Ada functions).
1753 GNAT does not require a separate pragma @code{Export}, but if none is
1754 present, @code{Convention Ada} is assumed, which is almost certainly
1755 not what is wanted since the whole point of this pragma is to interface
1756 with foreign language functions, so it is usually appropriate to use this
1757 pragma in conjunction with a @code{Export} or @code{Convention}
1758 pragma that specifies the desired foreign convention.
1760 @cindex OpenVMS
1761 @cindex Passing by descriptor
1762 Note that passing by descriptor is not supported, even on the OpenVMS
1763 ports of GNAT@.
1765 @cindex Suppressing external name
1766 Special treatment is given if the EXTERNAL is an explicit null
1767 string or a static string expressions that evaluates to the null
1768 string. In this case, no external name is generated. This form
1769 still allows the specification of parameter mechanisms.
1771 @node Pragma Extend_System
1772 @unnumberedsec Pragma Extend_System
1773 @cindex @code{system}, extending
1774 @cindex Dec Ada 83
1775 @findex Extend_System
1776 @noindent
1777 Syntax:
1779 @smallexample @c ada
1780 pragma Extend_System ([Name =>] IDENTIFIER);
1781 @end smallexample
1783 @noindent
1784 This pragma is used to provide backwards compatibility with other
1785 implementations that extend the facilities of package @code{System}.  In
1786 GNAT, @code{System} contains only the definitions that are present in
1787 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1788 implementation, provide many extensions to package @code{System}.
1790 For each such implementation accommodated by this pragma, GNAT provides a
1791 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1792 implementation, which provides the required additional definitions.  You
1793 can use this package in two ways.  You can @code{with} it in the normal
1794 way and access entities either by selection or using a @code{use}
1795 clause.  In this case no special processing is required.
1797 However, if existing code contains references such as
1798 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1799 definitions provided in package @code{System}, you may use this pragma
1800 to extend visibility in @code{System} in a non-standard way that
1801 provides greater compatibility with the existing code.  Pragma
1802 @code{Extend_System} is a configuration pragma whose single argument is
1803 the name of the package containing the extended definition
1804 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1805 control of this pragma will be processed using special visibility
1806 processing that looks in package @code{System.Aux_@var{xxx}} where
1807 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1808 package @code{System}, but not found in package @code{System}.
1810 You can use this pragma either to access a predefined @code{System}
1811 extension supplied with the compiler, for example @code{Aux_DEC} or
1812 you can construct your own extension unit following the above
1813 definition.  Note that such a package is a child of @code{System}
1814 and thus is considered part of the implementation.  To compile
1815 it you will have to use the appropriate switch for compiling
1816 system units.  See the GNAT User's Guide for details.
1818 @node Pragma External
1819 @unnumberedsec Pragma External
1820 @findex External
1821 @noindent
1822 Syntax:
1824 @smallexample @c ada
1825 pragma External (
1826   [   Convention    =>] convention_IDENTIFIER,
1827   [   Entity        =>] local_NAME
1828   [, [External_Name =>] static_string_EXPRESSION ]
1829   [, [Link_Name     =>] static_string_EXPRESSION ]);
1830 @end smallexample
1832 @noindent
1833 This pragma is identical in syntax and semantics to pragma
1834 @code{Export} as defined in the Ada Reference Manual.  It is
1835 provided for compatibility with some Ada 83 compilers that
1836 used this pragma for exactly the same purposes as pragma
1837 @code{Export} before the latter was standardized.
1839 @node Pragma External_Name_Casing
1840 @unnumberedsec Pragma External_Name_Casing
1841 @cindex Dec Ada 83 casing compatibility
1842 @cindex External Names, casing
1843 @cindex Casing of External names
1844 @findex External_Name_Casing
1845 @noindent
1846 Syntax:
1848 @smallexample @c ada
1849 pragma External_Name_Casing (
1850   Uppercase | Lowercase
1851   [, Uppercase | Lowercase | As_Is]);
1852 @end smallexample
1854 @noindent
1855 This pragma provides control over the casing of external names associated
1856 with Import and Export pragmas.  There are two cases to consider:
1858 @table @asis
1859 @item Implicit external names
1860 Implicit external names are derived from identifiers.  The most common case
1861 arises when a standard Ada 95 Import or Export pragma is used with only two
1862 arguments, as in:
1864 @smallexample @c ada
1865    pragma Import (C, C_Routine);
1866 @end smallexample
1868 @noindent
1869 Since Ada is a case insensitive language, the spelling of the identifier in
1870 the Ada source program does not provide any information on the desired
1871 casing of the external name, and so a convention is needed.  In GNAT the
1872 default treatment is that such names are converted to all lower case
1873 letters.  This corresponds to the normal C style in many environments.
1874 The first argument of pragma @code{External_Name_Casing} can be used to
1875 control this treatment.  If @code{Uppercase} is specified, then the name
1876 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1877 then the normal default of all lower case letters will be used.
1879 This same implicit treatment is also used in the case of extended DEC Ada 83
1880 compatible Import and Export pragmas where an external name is explicitly
1881 specified using an identifier rather than a string.
1883 @item Explicit external names
1884 Explicit external names are given as string literals.  The most common case
1885 arises when a standard Ada 95 Import or Export pragma is used with three
1886 arguments, as in:
1888 @smallexample @c ada
1889 pragma Import (C, C_Routine, "C_routine");
1890 @end smallexample
1892 @noindent
1893 In this case, the string literal normally provides the exact casing required
1894 for the external name.  The second argument of pragma
1895 @code{External_Name_Casing} may be used to modify this behavior.
1896 If @code{Uppercase} is specified, then the name
1897 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1898 then the name will be forced to all lowercase letters.  A specification of
1899 @code{As_Is} provides the normal default behavior in which the casing is
1900 taken from the string provided.
1901 @end table
1903 @noindent
1904 This pragma may appear anywhere that a pragma is valid.  In particular, it
1905 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1906 case it applies to all subsequent compilations, or it can be used as a program
1907 unit pragma, in which case it only applies to the current unit, or it can
1908 be used more locally to control individual Import/Export pragmas.
1910 It is primarily intended for use with OpenVMS systems, where many
1911 compilers convert all symbols to upper case by default.  For interfacing to
1912 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1913 the pragma:
1915 @smallexample @c ada
1916 pragma External_Name_Casing (Uppercase, Uppercase);
1917 @end smallexample
1919 @noindent
1920 to enforce the upper casing of all external symbols.
1922 @node Pragma Finalize_Storage_Only
1923 @unnumberedsec Pragma Finalize_Storage_Only
1924 @findex Finalize_Storage_Only
1925 @noindent
1926 Syntax:
1928 @smallexample @c ada
1929 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1930 @end smallexample
1932 @noindent
1933 This pragma allows the compiler not to emit a Finalize call for objects
1934 defined at the library level.  This is mostly useful for types where
1935 finalization is only used to deal with storage reclamation since in most
1936 environments it is not necessary to reclaim memory just before terminating
1937 execution, hence the name.
1939 @node Pragma Float_Representation
1940 @unnumberedsec Pragma Float_Representation
1941 @cindex OpenVMS
1942 @findex Float_Representation
1943 @noindent
1944 Syntax:
1946 @smallexample @c ada
1947 pragma Float_Representation (FLOAT_REP);
1949 FLOAT_REP ::= VAX_Float | IEEE_Float
1950 @end smallexample
1952 @noindent
1953 This pragma
1954 allows control over the internal representation chosen for the predefined
1955 floating point types declared in the packages @code{Standard} and
1956 @code{System}. On all systems other than OpenVMS, the argument must
1957 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1958 argument may be @code{VAX_Float} to specify the use of the VAX float
1959 format for the floating-point types in Standard. This requires that
1960 the standard runtime libraries be recompiled. See the
1961 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1962 of the GNAT Users Guide for details on the use of this command.
1964 @node Pragma Ident
1965 @unnumberedsec Pragma Ident
1966 @findex Ident
1967 @noindent
1968 Syntax:
1970 @smallexample @c ada
1971 pragma Ident (static_string_EXPRESSION);
1972 @end smallexample
1974 @noindent
1975 This pragma provides a string identification in the generated object file,
1976 if the system supports the concept of this kind of identification string.
1977 This pragma is allowed only in the outermost declarative part or
1978 declarative items of a compilation unit. If more than one @code{Ident}
1979 pragma is given, only the last one processed is effective.
1980 @cindex OpenVMS
1981 On OpenVMS systems, the effect of the pragma is identical to the effect of
1982 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1983 maximum allowed length is 31 characters, so if it is important to
1984 maintain compatibility with this compiler, you should obey this length
1985 limit.
1987 @node Pragma Import_Exception
1988 @unnumberedsec Pragma Import_Exception
1989 @cindex OpenVMS
1990 @findex Import_Exception
1991 @noindent
1992 Syntax:
1994 @smallexample @c ada
1995 pragma Import_Exception (
1996      [Internal =>] LOCAL_NAME,
1997   [, [External =>] EXTERNAL_SYMBOL,]
1998   [, [Form     =>] Ada | VMS]
1999   [, [Code     =>] static_integer_EXPRESSION]);
2001 EXTERNAL_SYMBOL ::=
2002   IDENTIFIER
2003 | static_string_EXPRESSION
2004 @end smallexample
2006 @noindent
2007 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2008 It allows OpenVMS conditions (for example, from OpenVMS system services or
2009 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2010 The pragma specifies that the exception associated with an exception
2011 declaration in an Ada program be defined externally (in non-Ada code).
2012 For further details on this pragma, see the
2013 DEC Ada Language Reference Manual, section 13.9a.3.1.
2015 @node Pragma Import_Function
2016 @unnumberedsec Pragma Import_Function
2017 @findex Import_Function
2018 @noindent
2019 Syntax:
2021 @smallexample @c ada
2022 pragma Import_Function (
2023      [Internal                 =>] LOCAL_NAME,
2024   [, [External                 =>] EXTERNAL_SYMBOL]
2025   [, [Parameter_Types          =>] PARAMETER_TYPES]
2026   [, [Result_Type              =>] SUBTYPE_MARK]
2027   [, [Mechanism                =>] MECHANISM]
2028   [, [Result_Mechanism         =>] MECHANISM_NAME]
2029   [, [First_Optional_Parameter =>] IDENTIFIER]);
2031 EXTERNAL_SYMBOL ::=
2032   IDENTIFIER
2033 | static_string_EXPRESSION
2035 PARAMETER_TYPES ::=
2036   null
2037 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2039 TYPE_DESIGNATOR ::=
2040   subtype_NAME
2041 | subtype_Name ' Access
2043 MECHANISM ::=
2044   MECHANISM_NAME
2045 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2047 MECHANISM_ASSOCIATION ::=
2048   [formal_parameter_NAME =>] MECHANISM_NAME
2050 MECHANISM_NAME ::=
2051   Value
2052 | Reference
2053 | Descriptor [([Class =>] CLASS_NAME)]
2055 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2056 @end smallexample
2058 @noindent
2059 This pragma is used in conjunction with a pragma @code{Import} to
2060 specify additional information for an imported function.  The pragma
2061 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2062 @code{Import_Function} pragma and both must appear in the same
2063 declarative part as the function specification.
2065 The @var{Internal} argument must uniquely designate
2066 the function to which the
2067 pragma applies.  If more than one function name exists of this name in
2068 the declarative part you must use the @code{Parameter_Types} and
2069 @var{Result_Type} parameters to achieve the required unique
2070 designation.  Subtype marks in these parameters must exactly match the
2071 subtypes in the corresponding function specification, using positional
2072 notation to match parameters with subtype marks.
2073 The form with an @code{'Access} attribute can be used to match an
2074 anonymous access parameter.
2076 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2077 parameters to specify passing mechanisms for the
2078 parameters and result.  If you specify a single mechanism name, it
2079 applies to all parameters.  Otherwise you may specify a mechanism on a
2080 parameter by parameter basis using either positional or named
2081 notation.  If the mechanism is not specified, the default mechanism
2082 is used.
2084 @cindex OpenVMS
2085 @cindex Passing by descriptor
2086 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2088 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2089 It specifies that the designated parameter and all following parameters
2090 are optional, meaning that they are not passed at the generated code
2091 level (this is distinct from the notion of optional parameters in Ada
2092 where the parameters are passed anyway with the designated optional
2093 parameters).  All optional parameters must be of mode @code{IN} and have
2094 default parameter values that are either known at compile time
2095 expressions, or uses of the @code{'Null_Parameter} attribute.
2097 @node Pragma Import_Object
2098 @unnumberedsec Pragma Import_Object
2099 @findex Import_Object
2100 @noindent
2101 Syntax:
2103 @smallexample @c ada
2104 pragma Import_Object
2105      [Internal =>] LOCAL_NAME,
2106   [, [External =>] EXTERNAL_SYMBOL],
2107   [, [Size     =>] EXTERNAL_SYMBOL]);
2109 EXTERNAL_SYMBOL ::=
2110   IDENTIFIER
2111 | static_string_EXPRESSION
2112 @end smallexample
2114 @noindent
2115 This pragma designates an object as imported, and apart from the
2116 extended rules for external symbols, is identical in effect to the use of
2117 the normal @code{Import} pragma applied to an object.  Unlike the
2118 subprogram case, you need not use a separate @code{Import} pragma,
2119 although you may do so (and probably should do so from a portability
2120 point of view).  @var{size} is syntax checked, but otherwise ignored by
2121 GNAT@.
2123 @node Pragma Import_Procedure
2124 @unnumberedsec Pragma Import_Procedure
2125 @findex Import_Procedure
2126 @noindent
2127 Syntax:
2129 @smallexample @c ada
2130 pragma Import_Procedure (
2131      [Internal                 =>] LOCAL_NAME,
2132   [, [External                 =>] EXTERNAL_SYMBOL]
2133   [, [Parameter_Types          =>] PARAMETER_TYPES]
2134   [, [Mechanism                =>] MECHANISM]
2135   [, [First_Optional_Parameter =>] IDENTIFIER]);
2137 EXTERNAL_SYMBOL ::=
2138   IDENTIFIER
2139 | static_string_EXPRESSION
2141 PARAMETER_TYPES ::=
2142   null
2143 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2145 TYPE_DESIGNATOR ::=
2146   subtype_NAME
2147 | subtype_Name ' Access
2149 MECHANISM ::=
2150   MECHANISM_NAME
2151 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2153 MECHANISM_ASSOCIATION ::=
2154   [formal_parameter_NAME =>] MECHANISM_NAME
2156 MECHANISM_NAME ::=
2157   Value
2158 | Reference
2159 | Descriptor [([Class =>] CLASS_NAME)]
2161 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2162 @end smallexample
2164 @noindent
2165 This pragma is identical to @code{Import_Function} except that it
2166 applies to a procedure rather than a function and the parameters
2167 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2169 @node Pragma Import_Valued_Procedure
2170 @unnumberedsec Pragma Import_Valued_Procedure
2171 @findex Import_Valued_Procedure
2172 @noindent
2173 Syntax:
2175 @smallexample @c ada
2176 pragma Import_Valued_Procedure (
2177      [Internal                 =>] LOCAL_NAME,
2178   [, [External                 =>] EXTERNAL_SYMBOL]
2179   [, [Parameter_Types          =>] PARAMETER_TYPES]
2180   [, [Mechanism                =>] MECHANISM]
2181   [, [First_Optional_Parameter =>] IDENTIFIER]);
2183 EXTERNAL_SYMBOL ::=
2184   IDENTIFIER
2185 | static_string_EXPRESSION
2187 PARAMETER_TYPES ::=
2188   null
2189 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2191 TYPE_DESIGNATOR ::=
2192   subtype_NAME
2193 | subtype_Name ' Access
2195 MECHANISM ::=
2196   MECHANISM_NAME
2197 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2199 MECHANISM_ASSOCIATION ::=
2200   [formal_parameter_NAME =>] MECHANISM_NAME
2202 MECHANISM_NAME ::=
2203   Value
2204 | Reference
2205 | Descriptor [([Class =>] CLASS_NAME)]
2207 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2208 @end smallexample
2210 @noindent
2211 This pragma is identical to @code{Import_Procedure} except that the
2212 first parameter of @var{local_name}, which must be present, must be of
2213 mode @code{OUT}, and externally the subprogram is treated as a function
2214 with this parameter as the result of the function.  The purpose of this
2215 capability is to allow the use of @code{OUT} and @code{IN OUT}
2216 parameters in interfacing to external functions (which are not permitted
2217 in Ada functions).  You may optionally use the @code{Mechanism}
2218 parameters to specify passing mechanisms for the parameters.
2219 If you specify a single mechanism name, it applies to all parameters.
2220 Otherwise you may specify a mechanism on a parameter by parameter
2221 basis using either positional or named notation.  If the mechanism is not
2222 specified, the default mechanism is used.
2224 Note that it is important to use this pragma in conjunction with a separate
2225 pragma Import that specifies the desired convention, since otherwise the
2226 default convention is Ada, which is almost certainly not what is required.
2228 @node Pragma Initialize_Scalars
2229 @unnumberedsec Pragma Initialize_Scalars
2230 @findex Initialize_Scalars
2231 @cindex debugging with Initialize_Scalars
2232 @noindent
2233 Syntax:
2235 @smallexample @c ada
2236 pragma Initialize_Scalars;
2237 @end smallexample
2239 @noindent
2240 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2241 two important differences.  First, there is no requirement for the pragma
2242 to be used uniformly in all units of a partition, in particular, it is fine
2243 to use this just for some or all of the application units of a partition,
2244 without needing to recompile the run-time library.
2246 In the case where some units are compiled with the pragma, and some without,
2247 then a declaration of a variable where the type is defined in package
2248 Standard or is locally declared will always be subject to initialization,
2249 as will any declaration of a scalar variable.  For composite variables,
2250 whether the variable is initialized may also depend on whether the package
2251 in which the type of the variable is declared is compiled with the pragma.
2253 The other important difference is that there is control over the value used
2254 for initializing scalar objects.  At bind time, you can select whether to
2255 initialize with invalid values (like Normalize_Scalars), or with high or
2256 low values, or with a specified bit pattern.  See the users guide for binder
2257 options for specifying these cases.
2259 This means that you can compile a program, and then without having to
2260 recompile the program, you can run it with different values being used
2261 for initializing otherwise uninitialized values, to test if your program
2262 behavior depends on the choice.  Of course the behavior should not change,
2263 and if it does, then most likely you have an erroneous reference to an
2264 uninitialized value.
2266 Note that pragma @code{Initialize_Scalars} is particularly useful in
2267 conjunction with the enhanced validity checking that is now provided
2268 in GNAT, which checks for invalid values under more conditions.
2269 Using this feature (see description of the @code{-gnatV} flag in the
2270 users guide) in conjunction with pragma @code{Initialize_Scalars}
2271 provides a powerful new tool to assist in the detection of problems
2272 caused by uninitialized variables.
2274 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2275 effect on the generated code. This may cause your code to be
2276 substantially larger. It may also cause an increase in the amount
2277 of stack required, so it is probably a good idea to turn on stack
2278 checking (see description of stack checking in the GNAT users guide)
2279 when using this pragma.
2281 @node Pragma Inline_Always
2282 @unnumberedsec Pragma Inline_Always
2283 @findex Inline_Always
2284 @noindent
2285 Syntax:
2287 @smallexample @c ada
2288 pragma Inline_Always (NAME [, NAME]);
2289 @end smallexample
2291 @noindent
2292 Similar to pragma @code{Inline} except that inlining is not subject to
2293 the use of option @code{-gnatn} and the inlining happens regardless of
2294 whether this option is used.
2296 @node Pragma Inline_Generic
2297 @unnumberedsec Pragma Inline_Generic
2298 @findex Inline_Generic
2299 @noindent
2300 Syntax:
2302 @smallexample @c ada
2303 pragma Inline_Generic (generic_package_NAME);
2304 @end smallexample
2306 @noindent
2307 This is implemented for compatibility with DEC Ada 83 and is recognized,
2308 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2309 by default when using GNAT@.
2311 @node Pragma Interface
2312 @unnumberedsec Pragma Interface
2313 @findex Interface
2314 @noindent
2315 Syntax:
2317 @smallexample @c ada
2318 pragma Interface (
2319      [Convention    =>] convention_identifier,
2320      [Entity =>] local_name
2321   [, [External_Name =>] static_string_expression],
2322   [, [Link_Name     =>] static_string_expression]);
2323 @end smallexample
2325 @noindent
2326 This pragma is identical in syntax and semantics to
2327 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2328 with Ada 83.  The definition is upwards compatible both with pragma
2329 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2330 with some extended implementations of this pragma in certain Ada 83
2331 implementations.
2333 @node Pragma Interface_Name
2334 @unnumberedsec Pragma Interface_Name
2335 @findex Interface_Name
2336 @noindent
2337 Syntax:
2339 @smallexample @c ada
2340 pragma Interface_Name (
2341      [Entity        =>] LOCAL_NAME
2342   [, [External_Name =>] static_string_EXPRESSION]
2343   [, [Link_Name     =>] static_string_EXPRESSION]);
2344 @end smallexample
2346 @noindent
2347 This pragma provides an alternative way of specifying the interface name
2348 for an interfaced subprogram, and is provided for compatibility with Ada
2349 83 compilers that use the pragma for this purpose.  You must provide at
2350 least one of @var{External_Name} or @var{Link_Name}.
2352 @node Pragma Interrupt_Handler
2353 @unnumberedsec Pragma Interrupt_Handler
2354 @findex Interrupt_Handler
2355 @noindent
2356 Syntax:
2358 @smallexample @c ada
2359 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2360 @end smallexample
2362 @noindent
2363 This program unit pragma is supported for parameterless protected procedures
2364 as described in Annex C of the Ada Reference Manual. On the AAMP target
2365 the pragma can also be specified for nonprotected parameterless procedures
2366 that are declared at the library level (which includes procedures
2367 declared at the top level of a library package). In the case of AAMP,
2368 when this pragma is applied to a nonprotected procedure, the instruction
2369 @code{IERET} is generated for returns from the procedure, enabling
2370 maskable interrupts, in place of the normal return instruction.
2372 @node Pragma Interrupt_State
2373 @unnumberedsec Pragma Interrupt_State
2374 @findex Interrupt_State
2375 @noindent
2376 Syntax:
2378 @smallexample @c ada
2379 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2380 @end smallexample
2382 @noindent
2383 Normally certain interrupts are reserved to the implementation.  Any attempt
2384 to attach an interrupt causes Program_Error to be raised, as described in
2385 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2386 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2387 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2388 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2389 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2390 Ada exceptions, or used to implement run-time functions such as the
2391 @code{abort} statement and stack overflow checking.
2393 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2394 such uses of interrupts.  It subsumes the functionality of pragma
2395 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2396 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2397 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2398 and may be used to mark interrupts required by the board support package
2399 as reserved.
2401 Interrupts can be in one of three states:
2402 @itemize @bullet
2403 @item System
2405 The interrupt is reserved (no Ada handler can be installed), and the
2406 Ada run-time may not install a handler. As a result you are guaranteed
2407 standard system default action if this interrupt is raised.
2409 @item Runtime
2411 The interrupt is reserved (no Ada handler can be installed). The run time
2412 is allowed to install a handler for internal control purposes, but is
2413 not required to do so.
2415 @item User
2417 The interrupt is unreserved.  The user may install a handler to provide
2418 some other action.
2419 @end itemize
2421 @noindent
2422 These states are the allowed values of the @code{State} parameter of the
2423 pragma.  The @code{Name} parameter is a value of the type
2424 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2425 @code{Ada.Interrupts.Names}.
2427 This is a configuration pragma, and the binder will check that there
2428 are no inconsistencies between different units in a partition in how a
2429 given interrupt is specified. It may appear anywhere a pragma is legal.
2431 The effect is to move the interrupt to the specified state.
2433 By declaring interrupts to be SYSTEM, you guarantee the standard system
2434 action, such as a core dump.
2436 By declaring interrupts to be USER, you guarantee that you can install
2437 a handler.
2439 Note that certain signals on many operating systems cannot be caught and
2440 handled by applications.  In such cases, the pragma is ignored.  See the
2441 operating system documentation, or the value of the array @code{Reserved}
2442 declared in the specification of package @code{System.OS_Interface}.
2444 Overriding the default state of signals used by the Ada runtime may interfere
2445 with an application's runtime behavior in the cases of the synchronous signals,
2446 and in the case of the signal used to implement the @code{abort} statement.
2448 @node Pragma Keep_Names
2449 @unnumberedsec Pragma Keep_Names
2450 @findex Keep_Names
2451 @noindent
2452 Syntax:
2454 @smallexample @c ada
2455 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2456 @end smallexample
2458 @noindent
2459 The @var{LOCAL_NAME} argument
2460 must refer to an enumeration first subtype
2461 in the current declarative part. The effect is to retain the enumeration
2462 literal names for use by @code{Image} and @code{Value} even if a global
2463 @code{Discard_Names} pragma applies. This is useful when you want to
2464 generally suppress enumeration literal names and for example you therefore
2465 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2466 want to retain the names for specific enumeration types.
2468 @node Pragma License
2469 @unnumberedsec Pragma License
2470 @findex License
2471 @cindex License checking
2472 @noindent
2473 Syntax:
2475 @smallexample @c ada
2476 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2477 @end smallexample
2479 @noindent
2480 This pragma is provided to allow automated checking for appropriate license
2481 conditions with respect to the standard and modified GPL@.  A pragma
2482 @code{License}, which is a configuration pragma that typically appears at
2483 the start of a source file or in a separate @file{gnat.adc} file, specifies
2484 the licensing conditions of a unit as follows:
2486 @itemize @bullet
2487 @item Unrestricted
2488 This is used for a unit that can be freely used with no license restrictions.
2489 Examples of such units are public domain units, and units from the Ada
2490 Reference Manual.
2492 @item GPL
2493 This is used for a unit that is licensed under the unmodified GPL, and which
2494 therefore cannot be @code{with}'ed by a restricted unit.
2496 @item Modified_GPL
2497 This is used for a unit licensed under the GNAT modified GPL that includes
2498 a special exception paragraph that specifically permits the inclusion of
2499 the unit in programs without requiring the entire program to be released
2500 under the GPL@.  This is the license used for the GNAT run-time which ensures
2501 that the run-time can be used freely in any program without GPL concerns.
2503 @item Restricted
2504 This is used for a unit that is restricted in that it is not permitted to
2505 depend on units that are licensed under the GPL@.  Typical examples are
2506 proprietary code that is to be released under more restrictive license
2507 conditions.  Note that restricted units are permitted to @code{with} units
2508 which are licensed under the modified GPL (this is the whole point of the
2509 modified GPL).
2511 @end itemize
2513 @noindent
2514 Normally a unit with no @code{License} pragma is considered to have an
2515 unknown license, and no checking is done.  However, standard GNAT headers
2516 are recognized, and license information is derived from them as follows.
2518 @itemize @bullet
2520 A GNAT license header starts with a line containing 78 hyphens.  The following
2521 comment text is searched for the appearance of any of the following strings.
2523 If the string ``GNU General Public License'' is found, then the unit is assumed
2524 to have GPL license, unless the string ``As a special exception'' follows, in
2525 which case the license is assumed to be modified GPL@.
2527 If one of the strings
2528 ``This specification is adapted from the Ada Semantic Interface'' or
2529 ``This specification is derived from the Ada Reference Manual'' is found
2530 then the unit is assumed to be unrestricted.
2531 @end itemize
2533 @noindent
2534 These default actions means that a program with a restricted license pragma
2535 will automatically get warnings if a GPL unit is inappropriately
2536 @code{with}'ed.  For example, the program:
2538 @smallexample @c ada
2539 with Sem_Ch3;
2540 with GNAT.Sockets;
2541 procedure Secret_Stuff is
2542   @dots{}
2543 end Secret_Stuff
2544 @end smallexample
2546 @noindent
2547 if compiled with pragma @code{License} (@code{Restricted}) in a
2548 @file{gnat.adc} file will generate the warning:
2550 @smallexample
2551 1.  with Sem_Ch3;
2552         |
2553    >>> license of withed unit "Sem_Ch3" is incompatible
2555 2.  with GNAT.Sockets;
2556 3.  procedure Secret_Stuff is
2557 @end smallexample
2559 @noindent
2560 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2561 compiler and is licensed under the
2562 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2563 run time, and is therefore licensed under the modified GPL@.
2565 @node Pragma Link_With
2566 @unnumberedsec Pragma Link_With
2567 @findex Link_With
2568 @noindent
2569 Syntax:
2571 @smallexample @c ada
2572 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2573 @end smallexample
2575 @noindent
2576 This pragma is provided for compatibility with certain Ada 83 compilers.
2577 It has exactly the same effect as pragma @code{Linker_Options} except
2578 that spaces occurring within one of the string expressions are treated
2579 as separators. For example, in the following case:
2581 @smallexample @c ada
2582 pragma Link_With ("-labc -ldef");
2583 @end smallexample
2585 @noindent
2586 results in passing the strings @code{-labc} and @code{-ldef} as two
2587 separate arguments to the linker. In addition pragma Link_With allows
2588 multiple arguments, with the same effect as successive pragmas.
2590 @node Pragma Linker_Alias
2591 @unnumberedsec Pragma Linker_Alias
2592 @findex Linker_Alias
2593 @noindent
2594 Syntax:
2596 @smallexample @c ada
2597 pragma Linker_Alias (
2598   [Entity =>] LOCAL_NAME
2599   [Alias  =>] static_string_EXPRESSION);
2600 @end smallexample
2602 @noindent
2603 This pragma establishes a linker alias for the given named entity.  For
2604 further details on the exact effect, consult the GCC manual.
2606 @node Pragma Linker_Section
2607 @unnumberedsec Pragma Linker_Section
2608 @findex Linker_Section
2609 @noindent
2610 Syntax:
2612 @smallexample @c ada
2613 pragma Linker_Section (
2614   [Entity  =>] LOCAL_NAME
2615   [Section =>] static_string_EXPRESSION);
2616 @end smallexample
2618 @noindent
2619 This pragma specifies the name of the linker section for the given entity.
2620 For further details on the exact effect, consult the GCC manual.
2622 @node Pragma Long_Float
2623 @unnumberedsec Pragma Long_Float
2624 @cindex OpenVMS
2625 @findex Long_Float
2626 @noindent
2627 Syntax:
2629 @smallexample @c ada
2630 pragma Long_Float (FLOAT_FORMAT);
2632 FLOAT_FORMAT ::= D_Float | G_Float
2633 @end smallexample
2635 @noindent
2636 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2637 It allows control over the internal representation chosen for the predefined
2638 type @code{Long_Float} and for floating point type representations with
2639 @code{digits} specified in the range 7 through 15.
2640 For further details on this pragma, see the
2641 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2642 this pragma, the standard runtime libraries must be recompiled.  See the
2643 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2644 of the GNAT User's Guide for details on the use of this command.
2646 @node Pragma Machine_Attribute
2647 @unnumberedsec Pragma Machine_Attribute
2648 @findex Machine_Attribute
2649 @noindent
2650 Syntax:
2652 @smallexample @c ada
2653 pragma Machine_Attribute (
2654   [Attribute_Name =>] string_EXPRESSION,
2655   [Entity         =>] LOCAL_NAME);
2656 @end smallexample
2658 @noindent
2659 Machine dependent attributes can be specified for types and/or
2660 declarations.  Currently only subprogram entities are supported.  This
2661 pragma is semantically equivalent to
2662 @code{__attribute__((@var{string_expression}))} in GNU C,
2663 where @code{@var{string_expression}} is
2664 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2665 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2666 configuration header file @file{tm.h} for each machine.  See the GCC
2667 manual for further information.
2669 @node Pragma Main_Storage
2670 @unnumberedsec Pragma Main_Storage
2671 @cindex OpenVMS
2672 @findex Main_Storage
2673 @noindent
2674 Syntax:
2676 @smallexample @c ada
2677 pragma Main_Storage
2678   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2680 MAIN_STORAGE_OPTION ::=
2681   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2682 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2684 @end smallexample
2686 @noindent
2687 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2688 no effect in GNAT, other than being syntax checked.  Note that the pragma
2689 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2691 @node Pragma No_Return
2692 @unnumberedsec Pragma No_Return
2693 @findex No_Return
2694 @noindent
2695 Syntax:
2697 @smallexample @c ada
2698 pragma No_Return (procedure_LOCAL_NAME);
2699 @end smallexample
2701 @noindent
2702 @var{procedure_local_NAME} must refer to one or more procedure
2703 declarations in the current declarative part.  A procedure to which this
2704 pragma is applied may not contain any explicit @code{return} statements,
2705 and also may not contain any implicit return statements from falling off
2706 the end of a statement sequence.  One use of this pragma is to identify
2707 procedures whose only purpose is to raise an exception.
2709 Another use of this pragma is to suppress incorrect warnings about
2710 missing returns in functions, where the last statement of a function
2711 statement sequence is a call to such a procedure.
2713 @node Pragma Normalize_Scalars
2714 @unnumberedsec Pragma Normalize_Scalars
2715 @findex Normalize_Scalars
2716 @noindent
2717 Syntax:
2719 @smallexample @c ada
2720 pragma Normalize_Scalars;
2721 @end smallexample
2723 @noindent
2724 This is a language defined pragma which is fully implemented in GNAT@.  The
2725 effect is to cause all scalar objects that are not otherwise initialized
2726 to be initialized.  The initial values are implementation dependent and
2727 are as follows:
2729 @table @code
2730 @item Standard.Character
2731 @noindent
2732 Objects whose root type is Standard.Character are initialized to
2733 Character'Last.  This will be out of range of the subtype only if
2734 the subtype range excludes this value.
2736 @item Standard.Wide_Character
2737 @noindent
2738 Objects whose root type is Standard.Wide_Character are initialized to
2739 Wide_Character'Last.  This will be out of range of the subtype only if
2740 the subtype range excludes this value.
2742 @item Integer types
2743 @noindent
2744 Objects of an integer type are initialized to base_type'First, where
2745 base_type is the base type of the object type.  This will be out of range
2746 of the subtype only if the subtype range excludes this value.  For example,
2747 if you declare the subtype:
2749 @smallexample @c ada
2750 subtype Ityp is integer range 1 .. 10;
2751 @end smallexample
2753 @noindent
2754 then objects of type x will be initialized to Integer'First, a negative
2755 number that is certainly outside the range of subtype @code{Ityp}.
2757 @item Real types
2758 Objects of all real types (fixed and floating) are initialized to
2759 base_type'First, where base_Type is the base type of the object type.
2760 This will be out of range of the subtype only if the subtype range
2761 excludes this value.
2763 @item Modular types
2764 Objects of a modular type are initialized to typ'Last.  This will be out
2765 of range of the subtype only if the subtype excludes this value.
2767 @item Enumeration types
2768 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2769 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2770 enumeration subtype in all cases except where the subtype contains
2771 exactly 2**8, 2**16, or 2**32 elements.
2773 @end table
2775 @node Pragma Obsolescent
2776 @unnumberedsec Pragma Obsolescent
2777 @findex Obsolescent
2778 @noindent
2779 Syntax:
2781 @smallexample @c ada
2782 pragma Obsolescent [(static_string_EXPRESSION)];
2783 @end smallexample
2785 @noindent
2786 This pragma must occur immediately following a subprogram
2787 declaration. It indicates that the associated function or procedure
2788 is considered obsolescent and should not be used. Typically this is
2789 used when an API must be modified by eventually removing or modifying
2790 existing subprograms. The pragma can be used at an intermediate stage
2791 when the subprogram is still present, but will be removed later.
2793 The effect of this pragma is to output a warning message that the
2794 subprogram is obsolescent if the appropriate warning option in the
2795 compiler is activated. If a parameter is present, then a second
2796 warning message is given containing this text.
2798 @node Pragma Passive
2799 @unnumberedsec Pragma Passive
2800 @findex Passive
2801 @noindent
2802 Syntax:
2804 @smallexample @c ada
2805 pragma Passive ([Semaphore | No]);
2806 @end smallexample
2808 @noindent
2809 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2810 compatibility with DEC Ada 83 implementations, where it is used within a
2811 task definition to request that a task be made passive.  If the argument
2812 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2813 treats the pragma as an assertion that the containing task is passive
2814 and that optimization of context switch with this task is permitted and
2815 desired.  If the argument @code{No} is present, the task must not be
2816 optimized.  GNAT does not attempt to optimize any tasks in this manner
2817 (since protected objects are available in place of passive tasks).
2819 @node Pragma Polling
2820 @unnumberedsec Pragma Polling
2821 @findex Polling
2822 @noindent
2823 Syntax:
2825 @smallexample @c ada
2826 pragma Polling (ON | OFF);
2827 @end smallexample
2829 @noindent
2830 This pragma controls the generation of polling code.  This is normally off.
2831 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2832 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2833 runtime library, and can be found in file @file{a-excpol.adb}.
2835 Pragma @code{Polling} can appear as a configuration pragma (for example it
2836 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2837 can be used in the statement or declaration sequence to control polling
2838 more locally.
2840 A call to the polling routine is generated at the start of every loop and
2841 at the start of every subprogram call.  This guarantees that the @code{Poll}
2842 routine is called frequently, and places an upper bound (determined by
2843 the complexity of the code) on the period between two @code{Poll} calls.
2845 The primary purpose of the polling interface is to enable asynchronous
2846 aborts on targets that cannot otherwise support it (for example Windows
2847 NT), but it may be used for any other purpose requiring periodic polling.
2848 The standard version is null, and can be replaced by a user program.  This
2849 will require re-compilation of the @code{Ada.Exceptions} package that can
2850 be found in files @file{a-except.ads} and @file{a-except.adb}.
2852 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2853 distribution) is used to enable the asynchronous abort capability on
2854 targets that do not normally support the capability.  The version of
2855 @code{Poll} in this file makes a call to the appropriate runtime routine
2856 to test for an abort condition.
2858 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2859 the @cite{GNAT User's Guide} for details.
2861 @node Pragma Profile (Ravenscar)
2862 @unnumberedsec Pragma Profile (Ravenscar)
2863 @findex Ravenscar
2864 @noindent
2865 Syntax:
2867 @smallexample @c ada
2868 pragma Profile (Ravenscar);
2869 @end smallexample
2871 @noindent
2872 A configuration pragma that establishes the following set of configuration
2873 pragmas:
2875 @table @code
2876 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2877 [RM D.2.2] Tasks are dispatched following a preemptive
2878 priority-ordered scheduling policy.
2880 @item Locking_Policy (Ceiling_Locking)
2881 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2882 the ceiling priority of the corresponding protected object.
2884 @c @item Detect_Blocking
2885 @c This pragma forces the detection of potentially blocking operations within a
2886 @c protected operation, and to raise Program_Error if that happens.
2887 @end table
2888 @noindent
2890 plus the following set of restrictions:
2892 @table @code
2893 @item Max_Entry_Queue_Length = 1
2894 Defines the maximum number of calls that are queued on a (protected) entry.
2895 Note that this restrictions is checked at run time. Violation of this
2896 restriction results in the raising of Program_Error exception at the point of
2897 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2898 always 1 and hence no task can be queued on a protected entry.
2900 @item Max_Protected_Entries = 1
2901 [RM D.7] Specifies the maximum number of entries per protected type. The
2902 bounds of every entry family of a protected unit shall be static, or shall be
2903 defined by a discriminant of a subtype whose corresponding bound is static.
2904 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2906 @item Max_Task_Entries = 0
2907 [RM D.7] Specifies the maximum number of entries
2908 per task.  The bounds of every entry family
2909 of a task unit shall be static, or shall be
2910 defined by a discriminant of a subtype whose
2911 corresponding bound is static.  A value of zero
2912 indicates that no rendezvous are possible.  For
2913 the Profile (Ravenscar), the value of Max_Task_Entries is always
2914 0 (zero).
2916 @item No_Abort_Statements
2917 [RM D.7] There are no abort_statements, and there are
2918 no calls to Task_Identification.Abort_Task.
2920 @item No_Asynchronous_Control
2921 [RM D.7] There are no semantic dependences on the package
2922 Asynchronous_Task_Control.
2924 @item No_Calendar
2925 There are no semantic dependencies on the package Ada.Calendar.
2927 @item No_Dynamic_Attachment
2928 There is no call to any of the operations defined in package Ada.Interrupts
2929 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2930 Detach_Handler, and Reference).
2932 @item No_Dynamic_Priorities
2933 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2935 @item No_Implicit_Heap_Allocations
2936 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2938 @item No_Local_Protected_Objects
2939 Protected objects and access types that designate
2940 such objects shall be declared only at library level.
2942 @item No_Protected_Type_Allocators
2943 There are no allocators for protected types or
2944 types containing protected subcomponents.
2946 @item No_Relative_Delay
2947 There are no delay_relative statements.
2949 @item No_Requeue_Statements
2950 Requeue statements are not allowed.
2952 @item No_Select_Statements
2953 There are no select_statements.
2955 @item No_Task_Allocators
2956 [RM D.7] There are no allocators for task types
2957 or types containing task subcomponents.
2959 @item No_Task_Attributes_Package
2960 There are no semantic dependencies on the Ada.Task_Attributes package.
2962 @item No_Task_Hierarchy
2963 [RM D.7] All (non-environment) tasks depend
2964 directly on the environment task of the partition.
2966 @item No_Task_Termination
2967 Tasks which terminate are erroneous.
2969 @item Simple_Barriers
2970 Entry barrier condition expressions shall be either static
2971 boolean expressions or boolean objects which are declared in
2972 the protected type which contains the entry.
2973 @end table
2975 @noindent
2976 This set of configuration pragmas and restrictions correspond to the
2977 definition of the ``Ravenscar Profile'' for limited tasking, devised and
2978 published by the @cite{International Real-Time Ada Workshop}, 1997,
2979 and whose most recent description is available at
2980 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2982 The original definition of the profile was revised at subsequent IRTAW
2983 meetings. It has been included in the ISO
2984 @cite{Guide for the Use of the Ada Programming Language in High
2985 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
2986 the next revision of the standard. The formal definition given by
2987 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
2988 AI-305) available at
2989 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
2990 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
2991 respectively.
2993 The above set is a superset of the restrictions provided by pragma
2994 @code{Profile (Restricted)}, it includes six additional restrictions
2995 (@code{Simple_Barriers}, @code{No_Select_Statements},
2996 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
2997 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2998 that pragma @code{Profile (Ravenscar)}, like the pragma
2999 @code{Profile (Restricted)},
3000 automatically causes the use of a simplified,
3001 more efficient version of the tasking run-time system.
3003 @node Pragma Profile (Restricted)
3004 @unnumberedsec Pragma Profile (Restricted)
3005 @findex Restricted Run Time
3006 @noindent
3007 Syntax:
3009 @smallexample @c ada
3010 pragma Profile (Restricted);
3011 @end smallexample
3013 @noindent
3014 A configuration pragma that establishes the following set of restrictions:
3016 @itemize @bullet
3017 @item No_Abort_Statements
3018 @item No_Entry_Queue
3019 @item No_Task_Hierarchy
3020 @item No_Task_Allocators
3021 @item No_Dynamic_Priorities
3022 @item No_Terminate_Alternatives
3023 @item No_Dynamic_Attachment
3024 @item No_Protected_Type_Allocators
3025 @item No_Local_Protected_Objects
3026 @item No_Requeue_Statements
3027 @item No_Task_Attributes_Package
3028 @item Max_Asynchronous_Select_Nesting =  0
3029 @item Max_Task_Entries =  0
3030 @item Max_Protected_Entries = 1
3031 @item Max_Select_Alternatives = 0
3032 @end itemize
3034 @noindent
3035 This set of restrictions causes the automatic selection of a simplified
3036 version of the run time that provides improved performance for the
3037 limited set of tasking functionality permitted by this set of restrictions.
3039 @node Pragma Propagate_Exceptions
3040 @unnumberedsec Pragma Propagate_Exceptions
3041 @findex Propagate_Exceptions
3042 @cindex Zero Cost Exceptions
3043 @noindent
3044 Syntax:
3046 @smallexample @c ada
3047 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
3048 @end smallexample
3050 @noindent
3051 This pragma indicates that the given entity, which is the name of an
3052 imported foreign-language subprogram may receive an Ada exception,
3053 and that the exception should be propagated.  It is relevant only if
3054 zero cost exception handling is in use, and is thus never needed if
3055 the alternative @code{longjmp} / @code{setjmp} implementation of
3056 exceptions is used (although it is harmless to use it in such cases).
3058 The implementation of fast exceptions always properly propagates
3059 exceptions through Ada code, as described in the Ada Reference Manual.
3060 However, this manual is silent about the propagation of exceptions
3061 through foreign code.  For example, consider the
3062 situation where @code{P1} calls
3063 @code{P2}, and @code{P2} calls @code{P3}, where
3064 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3065 @code{P3} raises an Ada exception.  The question is whether or not
3066 it will be propagated through @code{P2} and can be handled in
3067 @code{P1}.
3069 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3070 the answer is always yes.  For some targets on which zero cost exception
3071 handling is implemented, the answer is also always yes.  However, there
3072 are some targets, notably in the current version all x86 architecture
3073 targets, in which the answer is that such propagation does not
3074 happen automatically.  If such propagation is required on these
3075 targets, it is mandatory to use @code{Propagate_Exceptions} to
3076 name all foreign language routines through which Ada exceptions
3077 may be propagated.
3079 @node Pragma Psect_Object
3080 @unnumberedsec Pragma Psect_Object
3081 @findex Psect_Object
3082 @noindent
3083 Syntax:
3085 @smallexample @c ada
3086 pragma Psect_Object (
3087      [Internal =>] LOCAL_NAME,
3088   [, [External =>] EXTERNAL_SYMBOL]
3089   [, [Size     =>] EXTERNAL_SYMBOL]);
3091 EXTERNAL_SYMBOL ::=
3092   IDENTIFIER
3093 | static_string_EXPRESSION
3094 @end smallexample
3096 @noindent
3097 This pragma is identical in effect to pragma @code{Common_Object}.
3099 @node Pragma Pure_Function
3100 @unnumberedsec Pragma Pure_Function
3101 @findex Pure_Function
3102 @noindent
3103 Syntax:
3105 @smallexample @c ada
3106 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3107 @end smallexample
3109 @noindent
3110 This pragma appears in the same declarative part as a function
3111 declaration (or a set of function declarations if more than one
3112 overloaded declaration exists, in which case the pragma applies
3113 to all entities).  It specifies that the function @code{Entity} is
3114 to be considered pure for the purposes of code generation.  This means
3115 that the compiler can assume that there are no side effects, and
3116 in particular that two calls with identical arguments produce the
3117 same result.  It also means that the function can be used in an
3118 address clause.
3120 Note that, quite deliberately, there are no static checks to try
3121 to ensure that this promise is met, so @code{Pure_Function} can be used
3122 with functions that are conceptually pure, even if they do modify
3123 global variables.  For example, a square root function that is
3124 instrumented to count the number of times it is called is still
3125 conceptually pure, and can still be optimized, even though it
3126 modifies a global variable (the count).  Memo functions are another
3127 example (where a table of previous calls is kept and consulted to
3128 avoid re-computation).
3130 @findex Pure
3131 Note: Most functions in a @code{Pure} package are automatically pure, and
3132 there is no need to use pragma @code{Pure_Function} for such functions.  One
3133 exception is any function that has at least one formal of type
3134 @code{System.Address} or a type derived from it.  Such functions are not
3135 considered pure by default, since the compiler assumes that the
3136 @code{Address} parameter may be functioning as a pointer and that the
3137 referenced data may change even if the address value does not.
3138 Similarly, imported functions are not considered to be pure by default,
3139 since there is no way of checking that they are in fact pure.  The use
3140 of pragma @code{Pure_Function} for such a function will override these default
3141 assumption, and cause the compiler to treat a designated subprogram as pure
3142 in these cases.
3144 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3145 applies to the underlying renamed function.  This can be used to
3146 disambiguate cases of overloading where some but not all functions
3147 in a set of overloaded functions are to be designated as pure.
3149 @node Pragma Restriction_Warnings
3150 @unnumberedsec Pragma Restriction_Warnings
3151 @findex Restriction_Warnings
3152 @noindent
3153 Syntax:
3155 @smallexample @c ada
3156 pragma Restriction_Warnings
3157   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3158 @end smallexample
3160 @noindent
3161 This pragma allows a series of restriction identifiers to be
3162 specified (the list of allowed identifiers is the same as for
3163 pragma @code{Restrictions}). For each of these identifiers
3164 the compiler checks for violations of the restriction, but
3165 generates a warning message rather than an error message
3166 if the restriction is violated.
3168 @node Pragma Source_File_Name
3169 @unnumberedsec Pragma Source_File_Name
3170 @findex Source_File_Name
3171 @noindent
3172 Syntax:
3174 @smallexample @c ada
3175 pragma Source_File_Name (
3176   [Unit_Name   =>] unit_NAME,
3177   Spec_File_Name =>  STRING_LITERAL);
3179 pragma Source_File_Name (
3180   [Unit_Name   =>] unit_NAME,
3181   Body_File_Name =>  STRING_LITERAL);
3182 @end smallexample
3184 @noindent
3185 Use this to override the normal naming convention.  It is a configuration
3186 pragma, and so has the usual applicability of configuration pragmas
3187 (i.e.@: it applies to either an entire partition, or to all units in a
3188 compilation, or to a single unit, depending on how it is used.
3189 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3190 the second argument is required, and indicates whether this is the file
3191 name for the spec or for the body.
3193 Another form of the @code{Source_File_Name} pragma allows
3194 the specification of patterns defining alternative file naming schemes
3195 to apply to all files.
3197 @smallexample @c ada
3198 pragma Source_File_Name
3199   (Spec_File_Name => STRING_LITERAL
3200    [,Casing => CASING_SPEC]
3201    [,Dot_Replacement => STRING_LITERAL]);
3203 pragma Source_File_Name
3204   (Body_File_Name => STRING_LITERAL
3205    [,Casing => CASING_SPEC]
3206    [,Dot_Replacement => STRING_LITERAL]);
3208 pragma Source_File_Name
3209   (Subunit_File_Name => STRING_LITERAL
3210    [,Casing => CASING_SPEC]
3211    [,Dot_Replacement => STRING_LITERAL]);
3213 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3214 @end smallexample
3216 @noindent
3217 The first argument is a pattern that contains a single asterisk indicating
3218 the point at which the unit name is to be inserted in the pattern string
3219 to form the file name.  The second argument is optional.  If present it
3220 specifies the casing of the unit name in the resulting file name string.
3221 The default is lower case.  Finally the third argument allows for systematic
3222 replacement of any dots in the unit name by the specified string literal.
3224 A pragma Source_File_Name cannot appear after a
3225 @ref{Pragma Source_File_Name_Project}.
3227 For more details on the use of the @code{Source_File_Name} pragma,
3228 see the sections ``Using Other File Names'' and
3229 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3231 @node Pragma Source_File_Name_Project
3232 @unnumberedsec Pragma Source_File_Name_Project
3233 @findex Source_File_Name_Project
3234 @noindent
3236 This pragma has the same syntax and semantics as pragma Source_File_Name.
3237 It is only allowed as a stand alone configuration pragma.
3238 It cannot appear after a @ref{Pragma Source_File_Name}, and
3239 most importantly, once pragma Source_File_Name_Project appears,
3240 no further Source_File_Name pragmas are allowed.
3242 The intention is that Source_File_Name_Project pragmas are always
3243 generated by the Project Manager in a manner consistent with the naming
3244 specified in a project file, and when naming is controlled in this manner,
3245 it is not permissible to attempt to modify this naming scheme using
3246 Source_File_Name pragmas (which would not be known to the project manager).
3248 @node Pragma Source_Reference
3249 @unnumberedsec Pragma Source_Reference
3250 @findex Source_Reference
3251 @noindent
3252 Syntax:
3254 @smallexample @c ada
3255 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3256 @end smallexample
3258 @noindent
3259 This pragma must appear as the first line of a source file.
3260 @var{integer_literal} is the logical line number of the line following
3261 the pragma line (for use in error messages and debugging
3262 information).  @var{string_literal} is a static string constant that
3263 specifies the file name to be used in error messages and debugging
3264 information.  This is most notably used for the output of @code{gnatchop}
3265 with the @code{-r} switch, to make sure that the original unchopped
3266 source file is the one referred to.
3268 The second argument must be a string literal, it cannot be a static
3269 string expression other than a string literal.  This is because its value
3270 is needed for error messages issued by all phases of the compiler.
3272 @node Pragma Stream_Convert
3273 @unnumberedsec Pragma Stream_Convert
3274 @findex Stream_Convert
3275 @noindent
3276 Syntax:
3278 @smallexample @c ada
3279 pragma Stream_Convert (
3280   [Entity =>] type_LOCAL_NAME,
3281   [Read   =>] function_NAME,
3282   [Write  =>] function_NAME);
3283 @end smallexample
3285 @noindent
3286 This pragma provides an efficient way of providing stream functions for
3287 types defined in packages.  Not only is it simpler to use than declaring
3288 the necessary functions with attribute representation clauses, but more
3289 significantly, it allows the declaration to made in such a way that the
3290 stream packages are not loaded unless they are needed.  The use of
3291 the Stream_Convert pragma adds no overhead at all, unless the stream
3292 attributes are actually used on the designated type.
3294 The first argument specifies the type for which stream functions are
3295 provided.  The second parameter provides a function used to read values
3296 of this type.  It must name a function whose argument type may be any
3297 subtype, and whose returned type must be the type given as the first
3298 argument to the pragma.
3300 The meaning of the @var{Read}
3301 parameter is that if a stream attribute directly
3302 or indirectly specifies reading of the type given as the first parameter,
3303 then a value of the type given as the argument to the Read function is
3304 read from the stream, and then the Read function is used to convert this
3305 to the required target type.
3307 Similarly the @var{Write} parameter specifies how to treat write attributes
3308 that directly or indirectly apply to the type given as the first parameter.
3309 It must have an input parameter of the type specified by the first parameter,
3310 and the return type must be the same as the input type of the Read function.
3311 The effect is to first call the Write function to convert to the given stream
3312 type, and then write the result type to the stream.
3314 The Read and Write functions must not be overloaded subprograms.  If necessary
3315 renamings can be supplied to meet this requirement.
3316 The usage of this attribute is best illustrated by a simple example, taken
3317 from the GNAT implementation of package Ada.Strings.Unbounded:
3319 @smallexample @c ada
3320 function To_Unbounded (S : String)
3321            return Unbounded_String
3322   renames To_Unbounded_String;
3324 pragma Stream_Convert
3325   (Unbounded_String, To_Unbounded, To_String);
3326 @end smallexample
3328 @noindent
3329 The specifications of the referenced functions, as given in the Ada 95
3330 Reference Manual are:
3332 @smallexample @c ada
3333 function To_Unbounded_String (Source : String)
3334   return Unbounded_String;
3336 function To_String (Source : Unbounded_String)
3337   return String;
3338 @end smallexample
3340 @noindent
3341 The effect is that if the value of an unbounded string is written to a
3342 stream, then the representation of the item in the stream is in the same
3343 format used for @code{Standard.String}, and this same representation is
3344 expected when a value of this type is read from the stream.
3346 @node Pragma Style_Checks
3347 @unnumberedsec Pragma Style_Checks
3348 @findex Style_Checks
3349 @noindent
3350 Syntax:
3352 @smallexample @c ada
3353 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3354                      On | Off [, LOCAL_NAME]);
3355 @end smallexample
3357 @noindent
3358 This pragma is used in conjunction with compiler switches to control the
3359 built in style checking provided by GNAT@.  The compiler switches, if set,
3360 provide an initial setting for the switches, and this pragma may be used
3361 to modify these settings, or the settings may be provided entirely by
3362 the use of the pragma.  This pragma can be used anywhere that a pragma
3363 is legal, including use as a configuration pragma (including use in
3364 the @file{gnat.adc} file).
3366 The form with a string literal specifies which style options are to be
3367 activated.  These are additive, so they apply in addition to any previously
3368 set style check options.  The codes for the options are the same as those
3369 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3370 For example the following two methods can be used to enable
3371 layout checking:
3373 @itemize @bullet
3374 @item
3375 @smallexample @c ada
3376 pragma Style_Checks ("l");
3377 @end smallexample
3379 @item
3380 @smallexample
3381 gcc -c -gnatyl @dots{}
3382 @end smallexample
3383 @end itemize
3385 @noindent
3386 The form ALL_CHECKS activates all standard checks (its use is equivalent
3387 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3388 Guide for details.
3390 The forms with @code{Off} and @code{On}
3391 can be used to temporarily disable style checks
3392 as shown in the following example:
3394 @smallexample @c ada
3395 @iftex
3396 @leftskip=0cm
3397 @end iftex
3398 pragma Style_Checks ("k"); -- requires keywords in lower case
3399 pragma Style_Checks (Off); -- turn off style checks
3400 NULL;                      -- this will not generate an error message
3401 pragma Style_Checks (On);  -- turn style checks back on
3402 NULL;                      -- this will generate an error message
3403 @end smallexample
3405 @noindent
3406 Finally the two argument form is allowed only if the first argument is
3407 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3408 for the specified entity, as shown in the following example:
3410 @smallexample @c ada
3411 @iftex
3412 @leftskip=0cm
3413 @end iftex
3414 pragma Style_Checks ("r"); -- require consistency of identifier casing
3415 Arg : Integer;
3416 Rf1 : Integer := ARG;      -- incorrect, wrong case
3417 pragma Style_Checks (Off, Arg);
3418 Rf2 : Integer := ARG;      -- OK, no error
3419 @end smallexample
3421 @node Pragma Subtitle
3422 @unnumberedsec Pragma Subtitle
3423 @findex Subtitle
3424 @noindent
3425 Syntax:
3427 @smallexample @c ada
3428 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3429 @end smallexample
3431 @noindent
3432 This pragma is recognized for compatibility with other Ada compilers
3433 but is ignored by GNAT@.
3435 @node Pragma Suppress_All
3436 @unnumberedsec Pragma Suppress_All
3437 @findex Suppress_All
3438 @noindent
3439 Syntax:
3441 @smallexample @c ada
3442 pragma Suppress_All;
3443 @end smallexample
3445 @noindent
3446 This pragma can only appear immediately following a compilation
3447 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3448 which it follows.  This pragma is implemented for compatibility with DEC
3449 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3450 configuration pragma is the preferred usage in GNAT@.
3452 @node Pragma Suppress_Exception_Locations
3453 @unnumberedsec Pragma Suppress_Exception_Locations
3454 @findex Suppress_Exception_Locations
3455 @noindent
3456 Syntax:
3458 @smallexample @c ada
3459 pragma Suppress_Exception_Locations;
3460 @end smallexample
3462 @noindent
3463 In normal mode, a raise statement for an exception by default generates
3464 an exception message giving the file name and line number for the location
3465 of the raise. This is useful for debugging and logging purposes, but this
3466 entails extra space for the strings for the messages. The configuration
3467 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3468 generation of these strings, with the result that space is saved, but the
3469 exception message for such raises is null. This configuration pragma may
3470 appear in a global configuration pragma file, or in a specific unit as
3471 usual. It is not required that this pragma be used consistently within
3472 a partition, so it is fine to have some units within a partition compiled
3473 with this pragma and others compiled in normal mode without it.
3475 @node Pragma Suppress_Initialization
3476 @unnumberedsec Pragma Suppress_Initialization
3477 @findex Suppress_Initialization
3478 @cindex Suppressing initialization
3479 @cindex Initialization, suppression of
3480 @noindent
3481 Syntax:
3483 @smallexample @c ada
3484 pragma Suppress_Initialization ([Entity =>] type_Name);
3485 @end smallexample
3487 @noindent
3488 This pragma suppresses any implicit or explicit initialization
3489 associated with the given type name for all variables of this type.
3491 @node Pragma Task_Info
3492 @unnumberedsec Pragma Task_Info
3493 @findex Task_Info
3494 @noindent
3495 Syntax
3497 @smallexample @c ada
3498 pragma Task_Info (EXPRESSION);
3499 @end smallexample
3501 @noindent
3502 This pragma appears within a task definition (like pragma
3503 @code{Priority}) and applies to the task in which it appears.  The
3504 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3505 The @code{Task_Info} pragma provides system dependent control over
3506 aspects of tasking implementation, for example, the ability to map
3507 tasks to specific processors.  For details on the facilities available
3508 for the version of GNAT that you are using, see the documentation
3509 in the specification of package System.Task_Info in the runtime
3510 library.
3512 @node Pragma Task_Name
3513 @unnumberedsec Pragma Task_Name
3514 @findex Task_Name
3515 @noindent
3516 Syntax
3518 @smallexample @c ada
3519 pragma Task_Name (string_EXPRESSION);
3520 @end smallexample
3522 @noindent
3523 This pragma appears within a task definition (like pragma
3524 @code{Priority}) and applies to the task in which it appears.  The
3525 argument must be of type String, and provides a name to be used for
3526 the task instance when the task is created.  Note that this expression
3527 is not required to be static, and in particular, it can contain
3528 references to task discriminants.  This facility can be used to
3529 provide different names for different tasks as they are created,
3530 as illustrated in the example below.
3532 The task name is recorded internally in the run-time structures
3533 and is accessible to tools like the debugger.  In addition the
3534 routine @code{Ada.Task_Identification.Image} will return this
3535 string, with a unique task address appended.
3537 @smallexample @c ada
3538 --  Example of the use of pragma Task_Name
3540 with Ada.Task_Identification;
3541 use Ada.Task_Identification;
3542 with Text_IO; use Text_IO;
3543 procedure t3 is
3545    type Astring is access String;
3547    task type Task_Typ (Name : access String) is
3548       pragma Task_Name (Name.all);
3549    end Task_Typ;
3551    task body Task_Typ is
3552       Nam : constant String := Image (Current_Task);
3553    begin
3554       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3555    end Task_Typ;
3557    type Ptr_Task is access Task_Typ;
3558    Task_Var : Ptr_Task;
3560 begin
3561    Task_Var :=
3562      new Task_Typ (new String'("This is task 1"));
3563    Task_Var :=
3564      new Task_Typ (new String'("This is task 2"));
3565 end;
3566 @end smallexample
3568 @node Pragma Task_Storage
3569 @unnumberedsec Pragma Task_Storage
3570 @findex Task_Storage
3571 Syntax:
3573 @smallexample @c ada
3574 pragma Task_Storage (
3575   [Task_Type =>] LOCAL_NAME,
3576   [Top_Guard =>] static_integer_EXPRESSION);
3577 @end smallexample
3579 @noindent
3580 This pragma specifies the length of the guard area for tasks.  The guard
3581 area is an additional storage area allocated to a task.  A value of zero
3582 means that either no guard area is created or a minimal guard area is
3583 created, depending on the target.  This pragma can appear anywhere a
3584 @code{Storage_Size} attribute definition clause is allowed for a task
3585 type.
3587 @node Pragma Thread_Body
3588 @unnumberedsec Pragma Thread_Body
3589 @findex Thread_Body
3590 Syntax:
3592 @smallexample @c ada
3593 pragma Thread_Body (
3594   [Entity =>] LOCAL_NAME,
3595  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3596 @end smallexample
3598 @noindent
3599 This pragma specifies that the subprogram whose name is given as the
3600 @code{Entity} argument is a thread body, which will be activated
3601 by being called via its Address from foreign code. The purpose is
3602 to allow execution and registration of the foreign thread within the
3603 Ada run-time system.
3605 See the library unit @code{System.Threads} for details on the expansion of
3606 a thread body subprogram, including the calls made to subprograms
3607 within System.Threads to register the task.  This unit also lists the
3608 targets and runtime systems for which this pragma is supported.
3610 A thread body subprogram may not be called directly from Ada code, and
3611 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3612 to such a subprogram. The only legitimate way of calling such a subprogram
3613 is to pass its Address to foreign code and then make the call from the
3614 foreign code.
3616 A thread body subprogram may have any parameters, and it may be a function
3617 returning a result. The convention of the thread body subprogram may be
3618 set in the usual manner using @code{pragma Convention}.
3620 The secondary stack size parameter, if given, is used to set the size
3621 of secondary stack for the thread. The secondary stack is allocated as
3622 a local variable of the expanded thread body subprogram, and thus is
3623 allocated out of the main thread stack size. If no secondary stack
3624 size parameter is present, the default size (from the declaration in
3625 @code{System.Secondary_Stack} is used.
3627 @node Pragma Time_Slice
3628 @unnumberedsec Pragma Time_Slice
3629 @findex Time_Slice
3630 @noindent
3631 Syntax:
3633 @smallexample @c ada
3634 pragma Time_Slice (static_duration_EXPRESSION);
3635 @end smallexample
3637 @noindent
3638 For implementations of GNAT on operating systems where it is possible
3639 to supply a time slice value, this pragma may be used for this purpose.
3640 It is ignored if it is used in a system that does not allow this control,
3641 or if it appears in other than the main program unit.
3642 @cindex OpenVMS
3643 Note that the effect of this pragma is identical to the effect of the
3644 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3646 @node Pragma Title
3647 @unnumberedsec Pragma Title
3648 @findex Title
3649 @noindent
3650 Syntax:
3652 @smallexample @c ada
3653 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3655 TITLING_OPTION ::=
3656   [Title    =>] STRING_LITERAL,
3657 | [Subtitle =>] STRING_LITERAL
3658 @end smallexample
3660 @noindent
3661 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3662 pragma used in DEC Ada 83 implementations to provide a title and/or
3663 subtitle for the program listing.  The program listing generated by GNAT
3664 does not have titles or subtitles.
3666 Unlike other pragmas, the full flexibility of named notation is allowed
3667 for this pragma, i.e.@: the parameters may be given in any order if named
3668 notation is used, and named and positional notation can be mixed
3669 following the normal rules for procedure calls in Ada.
3671 @node Pragma Unchecked_Union
3672 @unnumberedsec Pragma Unchecked_Union
3673 @cindex Unions in C
3674 @findex Unchecked_Union
3675 @noindent
3676 Syntax:
3678 @smallexample @c ada
3679 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3680 @end smallexample
3682 @noindent
3683 This pragma is used to declare that the specified type should be represented
3684 in a manner
3685 equivalent to a C union type, and is intended only for use in
3686 interfacing with C code that uses union types.  In Ada terms, the named
3687 type must obey the following rules:
3689 @itemize @bullet
3690 @item
3691 It is a non-tagged non-limited record type.
3692 @item
3693 It has a single discrete discriminant with a default value.
3694 @item
3695 The component list consists of a single variant part.
3696 @item
3697 Each variant has a component list with a single component.
3698 @item
3699 No nested variants are allowed.
3700 @item
3701 No component has an explicit default value.
3702 @item
3703 No component has a non-static constraint.
3704 @end itemize
3706 @noindent
3707 In addition, given a type that meets the above requirements, the
3708 following restrictions apply to its use throughout the program:
3710 @itemize @bullet
3711 @item
3712 The discriminant name can be mentioned only in an aggregate.
3713 @item
3714 No subtypes may be created of this type.
3715 @item
3716 The type may not be constrained by giving a discriminant value.
3717 @item
3718 The type cannot be passed as the actual for a generic formal with a
3719 discriminant.
3720 @end itemize
3722 @noindent
3723 Equality and inequality operations on @code{unchecked_unions} are not
3724 available, since there is no discriminant to compare and the compiler
3725 does not even know how many bits to compare.  It is implementation
3726 dependent whether this is detected at compile time as an illegality or
3727 whether it is undetected and considered to be an erroneous construct.  In
3728 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3729 the composite case (where two composites are compared that contain an
3730 unchecked union component), so such comparisons are simply considered
3731 erroneous.
3733 The layout of the resulting type corresponds exactly to a C union, where
3734 each branch of the union corresponds to a single variant in the Ada
3735 record.  The semantics of the Ada program is not changed in any way by
3736 the pragma, i.e.@: provided the above restrictions are followed, and no
3737 erroneous incorrect references to fields or erroneous comparisons occur,
3738 the semantics is exactly as described by the Ada reference manual.
3739 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3740 type and the default convention is C.
3742 @node Pragma Unimplemented_Unit
3743 @unnumberedsec Pragma Unimplemented_Unit
3744 @findex Unimplemented_Unit
3745 @noindent
3746 Syntax:
3748 @smallexample @c ada
3749 pragma Unimplemented_Unit;
3750 @end smallexample
3752 @noindent
3753 If this pragma occurs in a unit that is processed by the compiler, GNAT
3754 aborts with the message @samp{@var{xxx} not implemented}, where
3755 @var{xxx} is the name of the current compilation unit.  This pragma is
3756 intended to allow the compiler to handle unimplemented library units in
3757 a clean manner.
3759 The abort only happens if code is being generated.  Thus you can use
3760 specs of unimplemented packages in syntax or semantic checking mode.
3762 @node Pragma Universal_Data
3763 @unnumberedsec Pragma Universal_Data
3764 @findex Universal_Data
3765 @noindent
3766 Syntax:
3768 @smallexample @c ada
3769 pragma Universal_Data [(library_unit_Name)];
3770 @end smallexample
3772 @noindent
3773 This pragma is supported only for the AAMP target and is ignored for
3774 other targets. The pragma specifies that all library-level objects
3775 (Counter 0 data) associated with the library unit are to be accessed
3776 and updated using universal addressing (24-bit addresses for AAMP5)
3777 rather than the default of 16-bit Data Environment (DENV) addressing.
3778 Use of this pragma will generally result in less efficient code for
3779 references to global data associated with the library unit, but
3780 allows such data to be located anywhere in memory. This pragma is
3781 a library unit pragma, but can also be used as a configuration pragma
3782 (including use in the @file{gnat.adc} file). The functionality
3783 of this pragma is also available by applying the -univ switch on the
3784 compilations of units where universal addressing of the data is desired.
3786 @node Pragma Unreferenced
3787 @unnumberedsec Pragma Unreferenced
3788 @findex Unreferenced
3789 @cindex Warnings, unreferenced
3790 @noindent
3791 Syntax:
3793 @smallexample @c ada
3794 pragma Unreferenced (local_Name @{, local_Name@});
3795 @end smallexample
3797 @noindent
3798 This pragma signals that the entities whose names are listed are
3799 deliberately not referenced in the current source unit. This
3800 suppresses warnings about the
3801 entities being unreferenced, and in addition a warning will be
3802 generated if one of these entities is in fact referenced in the
3803 same unit as the pragma (or in the corresponding body, or one
3804 of its subunits).
3806 This is particularly useful for clearly signaling that a particular
3807 parameter is not referenced in some particular subprogram implementation
3808 and that this is deliberate. It can also be useful in the case of
3809 objects declared only for their initialization or finalization side
3810 effects.
3812 If @code{local_Name} identifies more than one matching homonym in the
3813 current scope, then the entity most recently declared is the one to which
3814 the pragma applies.
3816 The left hand side of an assignment does not count as a reference for the
3817 purpose of this pragma. Thus it is fine to assign to an entity for which
3818 pragma Unreferenced is given.
3820 @node Pragma Unreserve_All_Interrupts
3821 @unnumberedsec Pragma Unreserve_All_Interrupts
3822 @findex Unreserve_All_Interrupts
3823 @noindent
3824 Syntax:
3826 @smallexample @c ada
3827 pragma Unreserve_All_Interrupts;
3828 @end smallexample
3830 @noindent
3831 Normally certain interrupts are reserved to the implementation.  Any attempt
3832 to attach an interrupt causes Program_Error to be raised, as described in
3833 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3834 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3835 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3836 interrupt execution.
3838 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3839 a program, then all such interrupts are unreserved.  This allows the
3840 program to handle these interrupts, but disables their standard
3841 functions.  For example, if this pragma is used, then pressing
3842 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3843 a program can then handle the @code{SIGINT} interrupt as it chooses.
3845 For a full list of the interrupts handled in a specific implementation,
3846 see the source code for the specification of @code{Ada.Interrupts.Names} in
3847 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3848 list of interrupts recognized for a given target.  The documentation in
3849 this file also specifies what interrupts are affected by the use of
3850 the @code{Unreserve_All_Interrupts} pragma.
3852 For a more general facility for controlling what interrupts can be
3853 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3854 of the @code{Unreserve_All_Interrupts} pragma.
3856 @node Pragma Unsuppress
3857 @unnumberedsec Pragma Unsuppress
3858 @findex Unsuppress
3859 @noindent
3860 Syntax:
3862 @smallexample @c ada
3863 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3864 @end smallexample
3866 @noindent
3867 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3868 there is no corresponding pragma @code{Suppress} in effect, it has no
3869 effect.  The range of the effect is the same as for pragma
3870 @code{Suppress}.  The meaning of the arguments is identical to that used
3871 in pragma @code{Suppress}.
3873 One important application is to ensure that checks are on in cases where
3874 code depends on the checks for its correct functioning, so that the code
3875 will compile correctly even if the compiler switches are set to suppress
3876 checks.
3878 @node Pragma Use_VADS_Size
3879 @unnumberedsec Pragma Use_VADS_Size
3880 @cindex @code{Size}, VADS compatibility
3881 @findex Use_VADS_Size
3882 @noindent
3883 Syntax:
3885 @smallexample @c ada
3886 pragma Use_VADS_Size;
3887 @end smallexample
3889 @noindent
3890 This is a configuration pragma.  In a unit to which it applies, any use
3891 of the 'Size attribute is automatically interpreted as a use of the
3892 'VADS_Size attribute.  Note that this may result in incorrect semantic
3893 processing of valid Ada 95 programs.  This is intended to aid in the
3894 handling of legacy code which depends on the interpretation of Size
3895 as implemented in the VADS compiler.  See description of the VADS_Size
3896 attribute for further details.
3898 @node Pragma Validity_Checks
3899 @unnumberedsec Pragma Validity_Checks
3900 @findex Validity_Checks
3901 @noindent
3902 Syntax:
3904 @smallexample @c ada
3905 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3906 @end smallexample
3908 @noindent
3909 This pragma is used in conjunction with compiler switches to control the
3910 built-in validity checking provided by GNAT@.  The compiler switches, if set
3911 provide an initial setting for the switches, and this pragma may be used
3912 to modify these settings, or the settings may be provided entirely by
3913 the use of the pragma.  This pragma can be used anywhere that a pragma
3914 is legal, including use as a configuration pragma (including use in
3915 the @file{gnat.adc} file).
3917 The form with a string literal specifies which validity options are to be
3918 activated.  The validity checks are first set to include only the default
3919 reference manual settings, and then a string of letters in the string
3920 specifies the exact set of options required.  The form of this string
3921 is exactly as described for the @code{-gnatVx} compiler switch (see the
3922 GNAT users guide for details).  For example the following two methods
3923 can be used to enable validity checking for mode @code{in} and
3924 @code{in out} subprogram parameters:
3926 @itemize @bullet
3927 @item
3928 @smallexample @c ada
3929 pragma Validity_Checks ("im");
3930 @end smallexample
3932 @item
3933 @smallexample
3934 gcc -c -gnatVim @dots{}
3935 @end smallexample
3936 @end itemize
3938 @noindent
3939 The form ALL_CHECKS activates all standard checks (its use is equivalent
3940 to the use of the @code{gnatva} switch.
3942 The forms with @code{Off} and @code{On}
3943 can be used to temporarily disable validity checks
3944 as shown in the following example:
3946 @smallexample @c ada
3947 @iftex
3948 @leftskip=0cm
3949 @end iftex
3950 pragma Validity_Checks ("c"); -- validity checks for copies
3951 pragma Validity_Checks (Off); -- turn off validity checks
3952 A := B;                       -- B will not be validity checked
3953 pragma Validity_Checks (On);  -- turn validity checks back on
3954 A := C;                       -- C will be validity checked
3955 @end smallexample
3957 @node Pragma Volatile
3958 @unnumberedsec Pragma Volatile
3959 @findex Volatile
3960 @noindent
3961 Syntax:
3963 @smallexample @c ada
3964 pragma Volatile (local_NAME);
3965 @end smallexample
3967 @noindent
3968 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3969 implementation is fully conformant with this definition.  The reason it
3970 is mentioned in this section is that a pragma of the same name was supplied
3971 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3972 of pragma Volatile is upwards compatible with the implementation in
3973 Dec Ada 83.
3975 @node Pragma Warnings
3976 @unnumberedsec Pragma Warnings
3977 @findex Warnings
3978 @noindent
3979 Syntax:
3981 @smallexample @c ada
3982 pragma Warnings (On | Off [, LOCAL_NAME]);
3983 @end smallexample
3985 @noindent
3986 Normally warnings are enabled, with the output being controlled by
3987 the command line switch.  Warnings (@code{Off}) turns off generation of
3988 warnings until a Warnings (@code{On}) is encountered or the end of the
3989 current unit.  If generation of warnings is turned off using this
3990 pragma, then no warning messages are output, regardless of the
3991 setting of the command line switches.
3993 The form with a single argument is a configuration pragma.
3995 If the @var{local_name} parameter is present, warnings are suppressed for
3996 the specified entity.  This suppression is effective from the point where
3997 it occurs till the end of the extended scope of the variable (similar to
3998 the scope of @code{Suppress}).
4000 @node Pragma Weak_External
4001 @unnumberedsec Pragma Weak_External
4002 @findex Weak_External
4003 @noindent
4004 Syntax:
4006 @smallexample @c ada
4007 pragma Weak_External ([Entity =>] LOCAL_NAME);
4008 @end smallexample
4010 @noindent
4011 This pragma specifies that the given entity should be marked as a weak
4012 external (one that does not have to be resolved) for the linker.  For
4013 further details, consult the GCC manual.
4015 @node Implementation Defined Attributes
4016 @chapter Implementation Defined Attributes
4017 Ada 95 defines (throughout the Ada 95 reference manual,
4018 summarized in annex K),
4019 a set of attributes that provide useful additional functionality in all
4020 areas of the language.  These language defined attributes are implemented
4021 in GNAT and work as described in the Ada 95 Reference Manual.
4023 In addition, Ada 95 allows implementations to define additional
4024 attributes whose meaning is defined by the implementation.  GNAT provides
4025 a number of these implementation-dependent attributes which can be used
4026 to extend and enhance the functionality of the compiler.  This section of
4027 the GNAT reference manual describes these additional attributes.
4029 Note that any program using these attributes may not be portable to
4030 other compilers (although GNAT implements this set of attributes on all
4031 platforms).  Therefore if portability to other compilers is an important
4032 consideration, you should minimize the use of these attributes.
4034 @menu
4035 * Abort_Signal::
4036 * Address_Size::
4037 * Asm_Input::
4038 * Asm_Output::
4039 * AST_Entry::
4040 * Bit::
4041 * Bit_Position::
4042 * Code_Address::
4043 * Default_Bit_Order::
4044 * Elaborated::
4045 * Elab_Body::
4046 * Elab_Spec::
4047 * Emax::
4048 * Enum_Rep::
4049 * Epsilon::
4050 * Fixed_Value::
4051 * Has_Access_Values::
4052 * Has_Discriminants::
4053 * Img::
4054 * Integer_Value::
4055 * Large::
4056 * Machine_Size::
4057 * Mantissa::
4058 * Max_Interrupt_Priority::
4059 * Max_Priority::
4060 * Maximum_Alignment::
4061 * Mechanism_Code::
4062 * Null_Parameter::
4063 * Object_Size::
4064 * Passed_By_Reference::
4065 * Range_Length::
4066 * Safe_Emax::
4067 * Safe_Large::
4068 * Small::
4069 * Storage_Unit::
4070 * Target_Name::
4071 * Tick::
4072 * To_Address::
4073 * Type_Class::
4074 * UET_Address::
4075 * Unconstrained_Array::
4076 * Universal_Literal_String::
4077 * Unrestricted_Access::
4078 * VADS_Size::
4079 * Value_Size::
4080 * Wchar_T_Size::
4081 * Word_Size::
4082 @end menu
4084 @node Abort_Signal
4085 @unnumberedsec Abort_Signal
4086 @findex Abort_Signal
4087 @noindent
4088 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4089 prefix) provides the entity for the special exception used to signal
4090 task abort or asynchronous transfer of control.  Normally this attribute
4091 should only be used in the tasking runtime (it is highly peculiar, and
4092 completely outside the normal semantics of Ada, for a user program to
4093 intercept the abort exception).
4095 @node Address_Size
4096 @unnumberedsec Address_Size
4097 @cindex Size of @code{Address}
4098 @findex Address_Size
4099 @noindent
4100 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4101 prefix) is a static constant giving the number of bits in an
4102 @code{Address}. It is the same value as System.Address'Size,
4103 but has the advantage of being static, while a direct
4104 reference to System.Address'Size is non-static because Address
4105 is a private type.
4107 @node Asm_Input
4108 @unnumberedsec Asm_Input
4109 @findex Asm_Input
4110 @noindent
4111 The @code{Asm_Input} attribute denotes a function that takes two
4112 parameters.  The first is a string, the second is an expression of the
4113 type designated by the prefix.  The first (string) argument is required
4114 to be a static expression, and is the constraint for the parameter,
4115 (e.g.@: what kind of register is required).  The second argument is the
4116 value to be used as the input argument.  The possible values for the
4117 constant are the same as those used in the RTL, and are dependent on
4118 the configuration file used to built the GCC back end.
4119 @ref{Machine Code Insertions}
4121 @node Asm_Output
4122 @unnumberedsec Asm_Output
4123 @findex Asm_Output
4124 @noindent
4125 The @code{Asm_Output} attribute denotes a function that takes two
4126 parameters.  The first is a string, the second is the name of a variable
4127 of the type designated by the attribute prefix.  The first (string)
4128 argument is required to be a static expression and designates the
4129 constraint for the parameter (e.g.@: what kind of register is
4130 required).  The second argument is the variable to be updated with the
4131 result.  The possible values for constraint are the same as those used in
4132 the RTL, and are dependent on the configuration file used to build the
4133 GCC back end.  If there are no output operands, then this argument may
4134 either be omitted, or explicitly given as @code{No_Output_Operands}.
4135 @ref{Machine Code Insertions}
4137 @node AST_Entry
4138 @unnumberedsec AST_Entry
4139 @cindex OpenVMS
4140 @findex AST_Entry
4141 @noindent
4142 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4143 the name of an entry, it yields a value of the predefined type AST_Handler
4144 (declared in the predefined package System, as extended by the use of
4145 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4146 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4147 Language Reference Manual}, section 9.12a.
4149 @node Bit
4150 @unnumberedsec Bit
4151 @findex Bit
4152 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4153 offset within the storage unit (byte) that contains the first bit of
4154 storage allocated for the object.  The value of this attribute is of the
4155 type @code{Universal_Integer}, and is always a non-negative number not
4156 exceeding the value of @code{System.Storage_Unit}.
4158 For an object that is a variable or a constant allocated in a register,
4159 the value is zero.  (The use of this attribute does not force the
4160 allocation of a variable to memory).
4162 For an object that is a formal parameter, this attribute applies
4163 to either the matching actual parameter or to a copy of the
4164 matching actual parameter.
4166 For an access object the value is zero.  Note that
4167 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4168 designated object.  Similarly for a record component
4169 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4170 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4171 are subject to index checks.
4173 This attribute is designed to be compatible with the DEC Ada 83 definition
4174 and implementation of the @code{Bit} attribute.
4176 @node Bit_Position
4177 @unnumberedsec Bit_Position
4178 @findex Bit_Position
4179 @noindent
4180 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4181 of the fields of the record type, yields the bit
4182 offset within the record contains the first bit of
4183 storage allocated for the object.  The value of this attribute is of the
4184 type @code{Universal_Integer}.  The value depends only on the field
4185 @var{C} and is independent of the alignment of
4186 the containing record @var{R}.
4188 @node Code_Address
4189 @unnumberedsec Code_Address
4190 @findex Code_Address
4191 @cindex Subprogram address
4192 @cindex Address of subprogram code
4193 @noindent
4194 The @code{'Address}
4195 attribute may be applied to subprograms in Ada 95, but the
4196 intended effect from the Ada 95 reference manual seems to be to provide
4197 an address value which can be used to call the subprogram by means of
4198 an address clause as in the following example:
4200 @smallexample @c ada
4201 procedure K is @dots{}
4203 procedure L;
4204 for L'Address use K'Address;
4205 pragma Import (Ada, L);
4206 @end smallexample
4208 @noindent
4209 A call to @code{L} is then expected to result in a call to @code{K}@.
4210 In Ada 83, where there were no access-to-subprogram values, this was
4211 a common work around for getting the effect of an indirect call.
4212 GNAT implements the above use of @code{Address} and the technique
4213 illustrated by the example code works correctly.
4215 However, for some purposes, it is useful to have the address of the start
4216 of the generated code for the subprogram.  On some architectures, this is
4217 not necessarily the same as the @code{Address} value described above.
4218 For example, the @code{Address} value may reference a subprogram
4219 descriptor rather than the subprogram itself.
4221 The @code{'Code_Address} attribute, which can only be applied to
4222 subprogram entities, always returns the address of the start of the
4223 generated code of the specified subprogram, which may or may not be
4224 the same value as is returned by the corresponding @code{'Address}
4225 attribute.
4227 @node Default_Bit_Order
4228 @unnumberedsec Default_Bit_Order
4229 @cindex Big endian
4230 @cindex Little endian
4231 @findex Default_Bit_Order
4232 @noindent
4233 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4234 permissible prefix), provides the value @code{System.Default_Bit_Order}
4235 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4236 @code{Low_Order_First}).  This is used to construct the definition of
4237 @code{Default_Bit_Order} in package @code{System}.
4239 @node Elaborated
4240 @unnumberedsec Elaborated
4241 @findex Elaborated
4242 @noindent
4243 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4244 value is a Boolean which indicates whether or not the given unit has been
4245 elaborated.  This attribute is primarily intended for internal use by the
4246 generated code for dynamic elaboration checking, but it can also be used
4247 in user programs.  The value will always be True once elaboration of all
4248 units has been completed.  An exception is for units which need no
4249 elaboration, the value is always False for such units.
4251 @node Elab_Body
4252 @unnumberedsec Elab_Body
4253 @findex Elab_Body
4254 @noindent
4255 This attribute can only be applied to a program unit name.  It returns
4256 the entity for the corresponding elaboration procedure for elaborating
4257 the body of the referenced unit.  This is used in the main generated
4258 elaboration procedure by the binder and is not normally used in any
4259 other context.  However, there may be specialized situations in which it
4260 is useful to be able to call this elaboration procedure from Ada code,
4261 e.g.@: if it is necessary to do selective re-elaboration to fix some
4262 error.
4264 @node Elab_Spec
4265 @unnumberedsec Elab_Spec
4266 @findex Elab_Spec
4267 @noindent
4268 This attribute can only be applied to a program unit name.  It returns
4269 the entity for the corresponding elaboration procedure for elaborating
4270 the specification of the referenced unit.  This is used in the main
4271 generated elaboration procedure by the binder and is not normally used
4272 in any other context.  However, there may be specialized situations in
4273 which it is useful to be able to call this elaboration procedure from
4274 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4275 some error.
4277 @node Emax
4278 @unnumberedsec Emax
4279 @cindex Ada 83 attributes
4280 @findex Emax
4281 @noindent
4282 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4283 the Ada 83 reference manual for an exact description of the semantics of
4284 this attribute.
4286 @node Enum_Rep
4287 @unnumberedsec Enum_Rep
4288 @cindex Representation of enums
4289 @findex Enum_Rep
4290 @noindent
4291 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4292 function with the following spec:
4294 @smallexample @c ada
4295 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4296   return @i{Universal_Integer};
4297 @end smallexample
4299 @noindent
4300 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4301 enumeration type or to a non-overloaded enumeration
4302 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4303 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4304 enumeration literal or object.
4306 The function returns the representation value for the given enumeration
4307 value.  This will be equal to value of the @code{Pos} attribute in the
4308 absence of an enumeration representation clause.  This is a static
4309 attribute (i.e.@: the result is static if the argument is static).
4311 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4312 in which case it simply returns the integer value.  The reason for this
4313 is to allow it to be used for @code{(<>)} discrete formal arguments in
4314 a generic unit that can be instantiated with either enumeration types
4315 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4316 type whose upper bound exceeds the upper bound of the largest signed
4317 integer type, and the argument is a variable, so that the universal
4318 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4319 may raise @code{Constraint_Error}.
4321 @node Epsilon
4322 @unnumberedsec Epsilon
4323 @cindex Ada 83 attributes
4324 @findex Epsilon
4325 @noindent
4326 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4327 the Ada 83 reference manual for an exact description of the semantics of
4328 this attribute.
4330 @node Fixed_Value
4331 @unnumberedsec Fixed_Value
4332 @findex Fixed_Value
4333 @noindent
4334 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4335 function with the following specification:
4337 @smallexample @c ada
4338 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4339   return @var{S};
4340 @end smallexample
4342 @noindent
4343 The value returned is the fixed-point value @var{V} such that
4345 @smallexample @c ada
4346 @var{V} = Arg * @var{S}'Small
4347 @end smallexample
4349 @noindent
4350 The effect is thus similar to first converting the argument to the
4351 integer type used to represent @var{S}, and then doing an unchecked
4352 conversion to the fixed-point type.  The difference is
4353 that there are full range checks, to ensure that the result is in range.
4354 This attribute is primarily intended for use in implementation of the
4355 input-output functions for fixed-point values.
4357 @node Has_Access_Values
4358 @unnumberedsec Has_Access_Values
4359 @cindex Access values, testing for
4360 @findex Has_Access_Values
4361 @noindent
4362 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4363 is a Boolean value which is True if the is an access type, or is a composite
4364 type with a component (at any nesting depth) that is an access type, and is
4365 False otherwise.
4366 The intended use of this attribute is in conjunction with generic
4367 definitions.  If the attribute is applied to a generic private type, it
4368 indicates whether or not the corresponding actual type has access values.
4370 @node Has_Discriminants
4371 @unnumberedsec Has_Discriminants
4372 @cindex Discriminants, testing for
4373 @findex Has_Discriminants
4374 @noindent
4375 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4376 is a Boolean value which is True if the type has discriminants, and False
4377 otherwise.  The intended use of this attribute is in conjunction with generic
4378 definitions.  If the attribute is applied to a generic private type, it
4379 indicates whether or not the corresponding actual type has discriminants.
4381 @node Img
4382 @unnumberedsec Img
4383 @findex Img
4384 @noindent
4385 The @code{Img} attribute differs from @code{Image} in that it may be
4386 applied to objects as well as types, in which case it gives the
4387 @code{Image} for the subtype of the object.  This is convenient for
4388 debugging:
4390 @smallexample @c ada
4391 Put_Line ("X = " & X'Img);
4392 @end smallexample
4394 @noindent
4395 has the same meaning as the more verbose:
4397 @smallexample @c ada
4398 Put_Line ("X = " & @var{T}'Image (X));
4399 @end smallexample
4401 @noindent
4402 where @var{T} is the (sub)type of the object @code{X}.
4404 @node Integer_Value
4405 @unnumberedsec Integer_Value
4406 @findex Integer_Value
4407 @noindent
4408 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4409 function with the following spec:
4411 @smallexample @c ada
4412 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4413   return @var{S};
4414 @end smallexample
4416 @noindent
4417 The value returned is the integer value @var{V}, such that
4419 @smallexample @c ada
4420 Arg = @var{V} * @var{T}'Small
4421 @end smallexample
4423 @noindent
4424 where @var{T} is the type of @code{Arg}.
4425 The effect is thus similar to first doing an unchecked conversion from
4426 the fixed-point type to its corresponding implementation type, and then
4427 converting the result to the target integer type.  The difference is
4428 that there are full range checks, to ensure that the result is in range.
4429 This attribute is primarily intended for use in implementation of the
4430 standard input-output functions for fixed-point values.
4432 @node Large
4433 @unnumberedsec Large
4434 @cindex Ada 83 attributes
4435 @findex Large
4436 @noindent
4437 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4438 the Ada 83 reference manual for an exact description of the semantics of
4439 this attribute.
4441 @node Machine_Size
4442 @unnumberedsec Machine_Size
4443 @findex Machine_Size
4444 @noindent
4445 This attribute is identical to the @code{Object_Size} attribute.  It is
4446 provided for compatibility with the DEC Ada 83 attribute of this name.
4448 @node Mantissa
4449 @unnumberedsec Mantissa
4450 @cindex Ada 83 attributes
4451 @findex Mantissa
4452 @noindent
4453 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4454 the Ada 83 reference manual for an exact description of the semantics of
4455 this attribute.
4457 @node Max_Interrupt_Priority
4458 @unnumberedsec Max_Interrupt_Priority
4459 @cindex Interrupt priority, maximum
4460 @findex Max_Interrupt_Priority
4461 @noindent
4462 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4463 permissible prefix), provides the same value as
4464 @code{System.Max_Interrupt_Priority}.
4466 @node Max_Priority
4467 @unnumberedsec Max_Priority
4468 @cindex Priority, maximum
4469 @findex Max_Priority
4470 @noindent
4471 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4472 prefix) provides the same value as @code{System.Max_Priority}.
4474 @node Maximum_Alignment
4475 @unnumberedsec Maximum_Alignment
4476 @cindex Alignment, maximum
4477 @findex Maximum_Alignment
4478 @noindent
4479 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4480 permissible prefix) provides the maximum useful alignment value for the
4481 target.  This is a static value that can be used to specify the alignment
4482 for an object, guaranteeing that it is properly aligned in all
4483 cases.
4485 @node Mechanism_Code
4486 @unnumberedsec Mechanism_Code
4487 @cindex Return values, passing mechanism
4488 @cindex Parameters, passing mechanism
4489 @findex Mechanism_Code
4490 @noindent
4491 @code{@var{function}'Mechanism_Code} yields an integer code for the
4492 mechanism used for the result of function, and
4493 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4494 used for formal parameter number @var{n} (a static integer value with 1
4495 meaning the first parameter) of @var{subprogram}.  The code returned is:
4497 @table @asis
4498 @item 1
4499 by copy (value)
4500 @item 2
4501 by reference
4502 @item 3
4503 by descriptor (default descriptor class)
4504 @item 4
4505 by descriptor (UBS: unaligned bit string)
4506 @item 5
4507 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4508 @item 6
4509 by descriptor (UBA: unaligned bit array)
4510 @item 7
4511 by descriptor (S: string, also scalar access type parameter)
4512 @item 8
4513 by descriptor (SB: string with arbitrary bounds)
4514 @item 9
4515 by descriptor (A: contiguous array)
4516 @item 10
4517 by descriptor (NCA: non-contiguous array)
4518 @end table
4520 @noindent
4521 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4522 @cindex OpenVMS
4524 @node Null_Parameter
4525 @unnumberedsec Null_Parameter
4526 @cindex Zero address, passing
4527 @findex Null_Parameter
4528 @noindent
4529 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4530 type or subtype @var{T} allocated at machine address zero.  The attribute
4531 is allowed only as the default expression of a formal parameter, or as
4532 an actual expression of a subprogram call.  In either case, the
4533 subprogram must be imported.
4535 The identity of the object is represented by the address zero in the
4536 argument list, independent of the passing mechanism (explicit or
4537 default).
4539 This capability is needed to specify that a zero address should be
4540 passed for a record or other composite object passed by reference.
4541 There is no way of indicating this without the @code{Null_Parameter}
4542 attribute.
4544 @node Object_Size
4545 @unnumberedsec Object_Size
4546 @cindex Size, used for objects
4547 @findex Object_Size
4548 @noindent
4549 The size of an object is not necessarily the same as the size of the type
4550 of an object.  This is because by default object sizes are increased to be
4551 a multiple of the alignment of the object.  For example,
4552 @code{Natural'Size} is
4553 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4554 Similarly, a record containing an integer and a character:
4556 @smallexample @c ada
4557 type Rec is record
4558    I : Integer;
4559    C : Character;
4560 end record;
4561 @end smallexample
4563 @noindent
4564 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4565 alignment will be 4, because of the
4566 integer field, and so the default size of record objects for this type
4567 will be 64 (8 bytes).
4569 The @code{@var{type}'Object_Size} attribute
4570 has been added to GNAT to allow the
4571 default object size of a type to be easily determined.  For example,
4572 @code{Natural'Object_Size} is 32, and
4573 @code{Rec'Object_Size} (for the record type in the above example) will be
4574 64.  Note also that, unlike the situation with the
4575 @code{Size} attribute as defined in the Ada RM, the
4576 @code{Object_Size} attribute can be specified individually
4577 for different subtypes.  For example:
4579 @smallexample @c ada
4580 type R is new Integer;
4581 subtype R1 is R range 1 .. 10;
4582 subtype R2 is R range 1 .. 10;
4583 for R2'Object_Size use 8;
4584 @end smallexample
4586 @noindent
4587 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4588 32 since the default object size for a subtype is the same as the object size
4589 for the parent subtype.  This means that objects of type @code{R}
4590 or @code{R1} will
4591 by default be 32 bits (four bytes).  But objects of type
4592 @code{R2} will be only
4593 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4595 @node Passed_By_Reference
4596 @unnumberedsec Passed_By_Reference
4597 @cindex Parameters, when passed by reference
4598 @findex Passed_By_Reference
4599 @noindent
4600 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4601 a value of type @code{Boolean} value that is @code{True} if the type is
4602 normally passed by reference and @code{False} if the type is normally
4603 passed by copy in calls.  For scalar types, the result is always @code{False}
4604 and is static.  For non-scalar types, the result is non-static.
4606 @node Range_Length
4607 @unnumberedsec Range_Length
4608 @findex Range_Length
4609 @noindent
4610 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4611 the number of values represented by the subtype (zero for a null
4612 range).  The result is static for static subtypes.  @code{Range_Length}
4613 applied to the index subtype of a one dimensional array always gives the
4614 same result as @code{Range} applied to the array itself.
4616 @node Safe_Emax
4617 @unnumberedsec Safe_Emax
4618 @cindex Ada 83 attributes
4619 @findex Safe_Emax
4620 @noindent
4621 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4622 the Ada 83 reference manual for an exact description of the semantics of
4623 this attribute.
4625 @node Safe_Large
4626 @unnumberedsec Safe_Large
4627 @cindex Ada 83 attributes
4628 @findex Safe_Large
4629 @noindent
4630 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4631 the Ada 83 reference manual for an exact description of the semantics of
4632 this attribute.
4634 @node Small
4635 @unnumberedsec Small
4636 @cindex Ada 83 attributes
4637 @findex Small
4638 @noindent
4639 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4640 GNAT also allows this attribute to be applied to floating-point types
4641 for compatibility with Ada 83.  See
4642 the Ada 83 reference manual for an exact description of the semantics of
4643 this attribute when applied to floating-point types.
4645 @node Storage_Unit
4646 @unnumberedsec Storage_Unit
4647 @findex Storage_Unit
4648 @noindent
4649 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4650 prefix) provides the same value as @code{System.Storage_Unit}.
4652 @node Target_Name
4653 @unnumberedsec Target_Name
4654 @findex Target_Name
4655 @noindent
4656 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4657 prefix) provides a static string value that identifies the target
4658 for the current compilation. For GCC implementations, this is the
4659 standard gcc target name without the terminating slash (for
4660 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4662 @node Tick
4663 @unnumberedsec Tick
4664 @findex Tick
4665 @noindent
4666 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4667 provides the same value as @code{System.Tick},
4669 @node To_Address
4670 @unnumberedsec To_Address
4671 @findex To_Address
4672 @noindent
4673 The @code{System'To_Address}
4674 (@code{System} is the only permissible prefix)
4675 denotes a function identical to
4676 @code{System.Storage_Elements.To_Address} except that
4677 it is a static attribute.  This means that if its argument is
4678 a static expression, then the result of the attribute is a
4679 static expression.  The result is that such an expression can be
4680 used in contexts (e.g.@: preelaborable packages) which require a
4681 static expression and where the function call could not be used
4682 (since the function call is always non-static, even if its
4683 argument is static).
4685 @node Type_Class
4686 @unnumberedsec Type_Class
4687 @findex Type_Class
4688 @noindent
4689 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4690 the value of the type class for the full type of @var{type}.  If
4691 @var{type} is a generic formal type, the value is the value for the
4692 corresponding actual subtype.  The value of this attribute is of type
4693 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4695 @smallexample @c ada
4696   type Type_Class is
4697     (Type_Class_Enumeration,
4698      Type_Class_Integer,
4699      Type_Class_Fixed_Point,
4700      Type_Class_Floating_Point,
4701      Type_Class_Array,
4702      Type_Class_Record,
4703      Type_Class_Access,
4704      Type_Class_Task,
4705      Type_Class_Address);
4706 @end smallexample
4708 @noindent
4709 Protected types yield the value @code{Type_Class_Task}, which thus
4710 applies to all concurrent types.  This attribute is designed to
4711 be compatible with the DEC Ada 83 attribute of the same name.
4713 @node UET_Address
4714 @unnumberedsec UET_Address
4715 @findex UET_Address
4716 @noindent
4717 The @code{UET_Address} attribute can only be used for a prefix which
4718 denotes a library package.  It yields the address of the unit exception
4719 table when zero cost exception handling is used.  This attribute is
4720 intended only for use within the GNAT implementation.  See the unit
4721 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4722 for details on how this attribute is used in the implementation.
4724 @node Unconstrained_Array
4725 @unnumberedsec Unconstrained_Array
4726 @findex Unconstrained_Array
4727 @noindent
4728 The @code{Unconstrained_Array} attribute can be used with a prefix that
4729 denotes any type or subtype. It is a static attribute that yields
4730 @code{True} if the prefix designates an unconstrained array,
4731 and @code{False} otherwise. In a generic instance, the result is
4732 still static, and yields the result of applying this test to the
4733 generic actual.
4735 @node Universal_Literal_String
4736 @unnumberedsec Universal_Literal_String
4737 @cindex Named numbers, representation of
4738 @findex Universal_Literal_String
4739 @noindent
4740 The prefix of @code{Universal_Literal_String} must be a named
4741 number.  The static result is the string consisting of the characters of
4742 the number as defined in the original source.  This allows the user
4743 program to access the actual text of named numbers without intermediate
4744 conversions and without the need to enclose the strings in quotes (which
4745 would preclude their use as numbers).  This is used internally for the
4746 construction of values of the floating-point attributes from the file
4747 @file{ttypef.ads}, but may also be used by user programs.
4749 @node Unrestricted_Access
4750 @unnumberedsec Unrestricted_Access
4751 @cindex @code{Access}, unrestricted
4752 @findex Unrestricted_Access
4753 @noindent
4754 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4755 except that all accessibility and aliased view checks are omitted.  This
4756 is a user-beware attribute.  It is similar to
4757 @code{Address}, for which it is a desirable replacement where the value
4758 desired is an access type.  In other words, its effect is identical to
4759 first applying the @code{Address} attribute and then doing an unchecked
4760 conversion to a desired access type.  In GNAT, but not necessarily in
4761 other implementations, the use of static chains for inner level
4762 subprograms means that @code{Unrestricted_Access} applied to a
4763 subprogram yields a value that can be called as long as the subprogram
4764 is in scope (normal Ada 95 accessibility rules restrict this usage).
4766 It is possible to use @code{Unrestricted_Access} for any type, but care
4767 must be excercised if it is used to create pointers to unconstrained
4768 objects. In this case, the resulting pointer has the same scope as the
4769 context of the attribute, and may not be returned to some enclosing
4770 scope. For instance, a function cannot use @code{Unrestricted_Access}
4771 to create a unconstrained pointer and then return that value to the
4772 caller.
4774 @node VADS_Size
4775 @unnumberedsec VADS_Size
4776 @cindex @code{Size}, VADS compatibility
4777 @findex VADS_Size
4778 @noindent
4779 The @code{'VADS_Size} attribute is intended to make it easier to port
4780 legacy code which relies on the semantics of @code{'Size} as implemented
4781 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4782 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4783 to a predefined or other primitive type with no Size clause yields the
4784 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4785 typical machines).  In addition @code{'VADS_Size} applied to an object
4786 gives the result that would be obtained by applying the attribute to
4787 the corresponding type.
4789 @node Value_Size
4790 @unnumberedsec Value_Size
4791 @cindex @code{Size}, setting for not-first subtype
4792 @findex Value_Size
4793 @code{@var{type}'Value_Size} is the number of bits required to represent
4794 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4795 but, unlike @code{Size}, may be set for non-first subtypes.
4797 @node Wchar_T_Size
4798 @unnumberedsec Wchar_T_Size
4799 @findex Wchar_T_Size
4800 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4801 prefix) provides the size in bits of the C @code{wchar_t} type
4802 primarily for constructing the definition of this type in
4803 package @code{Interfaces.C}.
4805 @node Word_Size
4806 @unnumberedsec Word_Size
4807 @findex Word_Size
4808 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4809 prefix) provides the value @code{System.Word_Size}.
4811 @c ------------------------
4812 @node Implementation Advice
4813 @chapter Implementation Advice
4814 @noindent
4815 The main text of the Ada 95 Reference Manual describes the required
4816 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4817 these requirements.
4819 In addition, there are sections throughout the Ada 95
4820 reference manual headed
4821 by the phrase ``implementation advice''.  These sections are not normative,
4822 i.e.@: they do not specify requirements that all compilers must
4823 follow.  Rather they provide advice on generally desirable behavior.  You
4824 may wonder why they are not requirements.  The most typical answer is
4825 that they describe behavior that seems generally desirable, but cannot
4826 be provided on all systems, or which may be undesirable on some systems.
4828 As far as practical, GNAT follows the implementation advice sections in
4829 the Ada 95 Reference Manual.  This chapter contains a table giving the
4830 reference manual section number, paragraph number and several keywords
4831 for each advice.  Each entry consists of the text of the advice followed
4832 by the GNAT interpretation of this advice.  Most often, this simply says
4833 ``followed'', which means that GNAT follows the advice.  However, in a
4834 number of cases, GNAT deliberately deviates from this advice, in which
4835 case the text describes what GNAT does and why.
4837 @cindex Error detection
4838 @unnumberedsec 1.1.3(20): Error Detection
4839 @sp 1
4840 @cartouche
4841 If an implementation detects the use of an unsupported Specialized Needs
4842 Annex feature at run time, it should raise @code{Program_Error} if
4843 feasible.
4844 @end cartouche
4845 Not relevant.  All specialized needs annex features are either supported,
4846 or diagnosed at compile time.
4848 @cindex Child Units
4849 @unnumberedsec 1.1.3(31): Child Units
4850 @sp 1
4851 @cartouche
4852 If an implementation wishes to provide implementation-defined
4853 extensions to the functionality of a language-defined library unit, it
4854 should normally do so by adding children to the library unit.
4855 @end cartouche
4856 Followed.
4858 @cindex Bounded errors
4859 @unnumberedsec 1.1.5(12): Bounded Errors
4860 @sp 1
4861 @cartouche
4862 If an implementation detects a bounded error or erroneous
4863 execution, it should raise @code{Program_Error}.
4864 @end cartouche
4865 Followed in all cases in which the implementation detects a bounded
4866 error or erroneous execution.  Not all such situations are detected at
4867 runtime.
4869 @cindex Pragmas
4870 @unnumberedsec 2.8(16): Pragmas
4871 @sp 1
4872 @cartouche
4873 Normally, implementation-defined pragmas should have no semantic effect
4874 for error-free programs; that is, if the implementation-defined pragmas
4875 are removed from a working program, the program should still be legal,
4876 and should still have the same semantics.
4877 @end cartouche
4878 The following implementation defined pragmas are exceptions to this
4879 rule:
4881 @table @code
4882 @item Abort_Defer
4883 Affects semantics
4884 @item Ada_83
4885 Affects legality
4886 @item Assert
4887 Affects semantics
4888 @item CPP_Class
4889 Affects semantics
4890 @item CPP_Constructor
4891 Affects semantics
4892 @item CPP_Virtual
4893 Affects semantics
4894 @item CPP_Vtable
4895 Affects semantics
4896 @item Debug
4897 Affects semantics
4898 @item Interface_Name
4899 Affects semantics
4900 @item Machine_Attribute
4901 Affects semantics
4902 @item Unimplemented_Unit
4903 Affects legality
4904 @item Unchecked_Union
4905 Affects semantics
4906 @end table
4908 @noindent
4909 In each of the above cases, it is essential to the purpose of the pragma
4910 that this advice not be followed.  For details see the separate section
4911 on implementation defined pragmas.
4913 @unnumberedsec 2.8(17-19): Pragmas
4914 @sp 1
4915 @cartouche
4916 Normally, an implementation should not define pragmas that can
4917 make an illegal program legal, except as follows:
4918 @end cartouche
4919 @sp 1
4920 @cartouche
4921 A pragma used to complete a declaration, such as a pragma @code{Import};
4922 @end cartouche
4923 @sp 1
4924 @cartouche
4925 A pragma used to configure the environment by adding, removing, or
4926 replacing @code{library_items}.
4927 @end cartouche
4928 See response to paragraph 16 of this same section.
4930 @cindex Character Sets
4931 @cindex Alternative Character Sets
4932 @unnumberedsec 3.5.2(5): Alternative Character Sets
4933 @sp 1
4934 @cartouche
4935 If an implementation supports a mode with alternative interpretations
4936 for @code{Character} and @code{Wide_Character}, the set of graphic
4937 characters of @code{Character} should nevertheless remain a proper
4938 subset of the set of graphic characters of @code{Wide_Character}.  Any
4939 character set ``localizations'' should be reflected in the results of
4940 the subprograms defined in the language-defined package
4941 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4942 an alternative interpretation of @code{Character}, the implementation should
4943 also support a corresponding change in what is a legal
4944 @code{identifier_letter}.
4945 @end cartouche
4946 Not all wide character modes follow this advice, in particular the JIS
4947 and IEC modes reflect standard usage in Japan, and in these encoding,
4948 the upper half of the Latin-1 set is not part of the wide-character
4949 subset, since the most significant bit is used for wide character
4950 encoding.  However, this only applies to the external forms.  Internally
4951 there is no such restriction.
4953 @cindex Integer types
4954 @unnumberedsec 3.5.4(28): Integer Types
4956 @sp 1
4957 @cartouche
4958 An implementation should support @code{Long_Integer} in addition to
4959 @code{Integer} if the target machine supports 32-bit (or longer)
4960 arithmetic.  No other named integer subtypes are recommended for package
4961 @code{Standard}.  Instead, appropriate named integer subtypes should be
4962 provided in the library package @code{Interfaces} (see B.2).
4963 @end cartouche
4964 @code{Long_Integer} is supported.  Other standard integer types are supported
4965 so this advice is not fully followed.  These types
4966 are supported for convenient interface to C, and so that all hardware
4967 types of the machine are easily available.
4968 @unnumberedsec 3.5.4(29): Integer Types
4970 @sp 1
4971 @cartouche
4972 An implementation for a two's complement machine should support
4973 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4974 implementation should support a non-binary modules up to @code{Integer'Last}.
4975 @end cartouche
4976 Followed.
4978 @cindex Enumeration values
4979 @unnumberedsec 3.5.5(8): Enumeration Values
4980 @sp 1
4981 @cartouche
4982 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4983 subtype, if the value of the operand does not correspond to the internal
4984 code for any enumeration literal of its type (perhaps due to an
4985 un-initialized variable), then the implementation should raise
4986 @code{Program_Error}.  This is particularly important for enumeration
4987 types with noncontiguous internal codes specified by an
4988 enumeration_representation_clause.
4989 @end cartouche
4990 Followed.
4992 @cindex Float types
4993 @unnumberedsec 3.5.7(17): Float Types
4994 @sp 1
4995 @cartouche
4996 An implementation should support @code{Long_Float} in addition to
4997 @code{Float} if the target machine supports 11 or more digits of
4998 precision.  No other named floating point subtypes are recommended for
4999 package @code{Standard}.  Instead, appropriate named floating point subtypes
5000 should be provided in the library package @code{Interfaces} (see B.2).
5001 @end cartouche
5002 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5003 former provides improved compatibility with other implementations
5004 supporting this type.  The latter corresponds to the highest precision
5005 floating-point type supported by the hardware.  On most machines, this
5006 will be the same as @code{Long_Float}, but on some machines, it will
5007 correspond to the IEEE extended form.  The notable case is all ia32
5008 (x86) implementations, where @code{Long_Long_Float} corresponds to
5009 the 80-bit extended precision format supported in hardware on this
5010 processor.  Note that the 128-bit format on SPARC is not supported,
5011 since this is a software rather than a hardware format.
5013 @cindex Multidimensional arrays
5014 @cindex Arrays, multidimensional
5015 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5016 @sp 1
5017 @cartouche
5018 An implementation should normally represent multidimensional arrays in
5019 row-major order, consistent with the notation used for multidimensional
5020 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5021 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5022 column-major order should be used instead (see B.5, ``Interfacing with
5023 Fortran'').
5024 @end cartouche
5025 Followed.
5027 @findex Duration'Small
5028 @unnumberedsec 9.6(30-31): Duration'Small
5029 @sp 1
5030 @cartouche
5031 Whenever possible in an implementation, the value of @code{Duration'Small}
5032 should be no greater than 100 microseconds.
5033 @end cartouche
5034 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5036 @sp 1
5037 @cartouche
5038 The time base for @code{delay_relative_statements} should be monotonic;
5039 it need not be the same time base as used for @code{Calendar.Clock}.
5040 @end cartouche
5041 Followed.
5043 @unnumberedsec 10.2.1(12): Consistent Representation
5044 @sp 1
5045 @cartouche
5046 In an implementation, a type declared in a pre-elaborated package should
5047 have the same representation in every elaboration of a given version of
5048 the package, whether the elaborations occur in distinct executions of
5049 the same program, or in executions of distinct programs or partitions
5050 that include the given version.
5051 @end cartouche
5052 Followed, except in the case of tagged types.  Tagged types involve
5053 implicit pointers to a local copy of a dispatch table, and these pointers
5054 have representations which thus depend on a particular elaboration of the
5055 package.  It is not easy to see how it would be possible to follow this
5056 advice without severely impacting efficiency of execution.
5058 @cindex Exception information
5059 @unnumberedsec 11.4.1(19): Exception Information
5060 @sp 1
5061 @cartouche
5062 @code{Exception_Message} by default and @code{Exception_Information}
5063 should produce information useful for
5064 debugging.  @code{Exception_Message} should be short, about one
5065 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5066 should not include the
5067 @code{Exception_Name}.  @code{Exception_Information} should include both
5068 the @code{Exception_Name} and the @code{Exception_Message}.
5069 @end cartouche
5070 Followed.  For each exception that doesn't have a specified
5071 @code{Exception_Message}, the compiler generates one containing the location
5072 of the raise statement.  This location has the form ``file:line'', where
5073 file is the short file name (without path information) and line is the line
5074 number in the file.  Note that in the case of the Zero Cost Exception
5075 mechanism, these messages become redundant with the Exception_Information that
5076 contains a full backtrace of the calling sequence, so they are disabled.
5077 To disable explicitly the generation of the source location message, use the
5078 Pragma @code{Discard_Names}.
5080 @cindex Suppression of checks
5081 @cindex Checks, suppression of
5082 @unnumberedsec 11.5(28): Suppression of Checks
5083 @sp 1
5084 @cartouche
5085 The implementation should minimize the code executed for checks that
5086 have been suppressed.
5087 @end cartouche
5088 Followed.
5090 @cindex Representation clauses
5091 @unnumberedsec 13.1 (21-24): Representation Clauses
5092 @sp 1
5093 @cartouche
5094 The recommended level of support for all representation items is
5095 qualified as follows:
5096 @end cartouche
5097 @sp 1
5098 @cartouche
5099 An implementation need not support representation items containing
5100 non-static expressions, except that an implementation should support a
5101 representation item for a given entity if each non-static expression in
5102 the representation item is a name that statically denotes a constant
5103 declared before the entity.
5104 @end cartouche
5105 Followed.  GNAT does not support non-static expressions in representation
5106 clauses unless they are constants declared before the entity.  For
5107 example:
5109 @smallexample @c ada
5110 X : Some_Type;
5111 for X'Address use To_address (16#2000#);
5112 @end smallexample
5114 @noindent
5115 will be rejected, since the To_Address expression is non-static.  Instead
5116 write:
5118 @smallexample @c ada
5119 X_Address : constant Address : = To_Address (16#2000#);
5120 X         : Some_Type;
5121 for X'Address use X_Address;
5122 @end smallexample
5124 @sp 1
5125 @cartouche
5126 An implementation need not support a specification for the @code{Size}
5127 for a given composite subtype, nor the size or storage place for an
5128 object (including a component) of a given composite subtype, unless the
5129 constraints on the subtype and its composite subcomponents (if any) are
5130 all static constraints.
5131 @end cartouche
5132 Followed.  Size Clauses are not permitted on non-static components, as
5133 described above.
5135 @sp 1
5136 @cartouche
5137 An aliased component, or a component whose type is by-reference, should
5138 always be allocated at an addressable location.
5139 @end cartouche
5140 Followed.
5142 @cindex Packed types
5143 @unnumberedsec 13.2(6-8): Packed Types
5144 @sp 1
5145 @cartouche
5146 If a type is packed, then the implementation should try to minimize
5147 storage allocated to objects of the type, possibly at the expense of
5148 speed of accessing components, subject to reasonable complexity in
5149 addressing calculations.
5150 @end cartouche
5151 @sp 1
5152 @cartouche
5153 The recommended level of support pragma @code{Pack} is:
5155 For a packed record type, the components should be packed as tightly as
5156 possible subject to the Sizes of the component subtypes, and subject to
5157 any @code{record_representation_clause} that applies to the type; the
5158 implementation may, but need not, reorder components or cross aligned
5159 word boundaries to improve the packing.  A component whose @code{Size} is
5160 greater than the word size may be allocated an integral number of words.
5161 @end cartouche
5162 Followed.  Tight packing of arrays is supported for all component sizes
5163 up to 64-bits. If the array component size is 1 (that is to say, if
5164 the component is a boolean type or an enumeration type with two values)
5165 then values of the type are implicitly initialized to zero. This
5166 happens both for objects of the packed type, and for objects that have a
5167 subcomponent of the packed type.
5169 @sp 1
5170 @cartouche
5171 An implementation should support Address clauses for imported
5172 subprograms.
5173 @end cartouche
5174 Followed.
5175 @cindex @code{Address} clauses
5176 @unnumberedsec 13.3(14-19): Address Clauses
5178 @sp 1
5179 @cartouche
5180 For an array @var{X}, @code{@var{X}'Address} should point at the first
5181 component of the array, and not at the array bounds.
5182 @end cartouche
5183 Followed.
5185 @sp 1
5186 @cartouche
5187 The recommended level of support for the @code{Address} attribute is:
5189 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5190 object that is aliased or of a by-reference type, or is an entity whose
5191 @code{Address} has been specified.
5192 @end cartouche
5193 Followed.  A valid address will be produced even if none of those
5194 conditions have been met.  If necessary, the object is forced into
5195 memory to ensure the address is valid.
5197 @sp 1
5198 @cartouche
5199 An implementation should support @code{Address} clauses for imported
5200 subprograms.
5201 @end cartouche
5202 Followed.
5204 @sp 1
5205 @cartouche
5206 Objects (including subcomponents) that are aliased or of a by-reference
5207 type should be allocated on storage element boundaries.
5208 @end cartouche
5209 Followed.
5211 @sp 1
5212 @cartouche
5213 If the @code{Address} of an object is specified, or it is imported or exported,
5214 then the implementation should not perform optimizations based on
5215 assumptions of no aliases.
5216 @end cartouche
5217 Followed.
5219 @cindex @code{Alignment} clauses
5220 @unnumberedsec 13.3(29-35): Alignment Clauses
5221 @sp 1
5222 @cartouche
5223 The recommended level of support for the @code{Alignment} attribute for
5224 subtypes is:
5226 An implementation should support specified Alignments that are factors
5227 and multiples of the number of storage elements per word, subject to the
5228 following:
5229 @end cartouche
5230 Followed.
5232 @sp 1
5233 @cartouche
5234 An implementation need not support specified @code{Alignment}s for
5235 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5236 loaded and stored by available machine instructions.
5237 @end cartouche
5238 Followed.
5240 @sp 1
5241 @cartouche
5242 An implementation need not support specified @code{Alignment}s that are
5243 greater than the maximum @code{Alignment} the implementation ever returns by
5244 default.
5245 @end cartouche
5246 Followed.
5248 @sp 1
5249 @cartouche
5250 The recommended level of support for the @code{Alignment} attribute for
5251 objects is:
5253 Same as above, for subtypes, but in addition:
5254 @end cartouche
5255 Followed.
5257 @sp 1
5258 @cartouche
5259 For stand-alone library-level objects of statically constrained
5260 subtypes, the implementation should support all @code{Alignment}s
5261 supported by the target linker.  For example, page alignment is likely to
5262 be supported for such objects, but not for subtypes.
5263 @end cartouche
5264 Followed.
5266 @cindex @code{Size} clauses
5267 @unnumberedsec 13.3(42-43): Size Clauses
5268 @sp 1
5269 @cartouche
5270 The recommended level of support for the @code{Size} attribute of
5271 objects is:
5273 A @code{Size} clause should be supported for an object if the specified
5274 @code{Size} is at least as large as its subtype's @code{Size}, and
5275 corresponds to a size in storage elements that is a multiple of the
5276 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5277 @end cartouche
5278 Followed.
5280 @unnumberedsec 13.3(50-56): Size Clauses
5281 @sp 1
5282 @cartouche
5283 If the @code{Size} of a subtype is specified, and allows for efficient
5284 independent addressability (see 9.10) on the target architecture, then
5285 the @code{Size} of the following objects of the subtype should equal the
5286 @code{Size} of the subtype:
5288 Aliased objects (including components).
5289 @end cartouche
5290 Followed.
5292 @sp 1
5293 @cartouche
5294 @code{Size} clause on a composite subtype should not affect the
5295 internal layout of components.
5296 @end cartouche
5297 Followed.
5299 @sp 1
5300 @cartouche
5301 The recommended level of support for the @code{Size} attribute of subtypes is:
5302 @end cartouche
5303 @sp 1
5304 @cartouche
5305 The @code{Size} (if not specified) of a static discrete or fixed point
5306 subtype should be the number of bits needed to represent each value
5307 belonging to the subtype using an unbiased representation, leaving space
5308 for a sign bit only if the subtype contains negative values.  If such a
5309 subtype is a first subtype, then an implementation should support a
5310 specified @code{Size} for it that reflects this representation.
5311 @end cartouche
5312 Followed.
5314 @sp 1
5315 @cartouche
5316 For a subtype implemented with levels of indirection, the @code{Size}
5317 should include the size of the pointers, but not the size of what they
5318 point at.
5319 @end cartouche
5320 Followed.
5322 @cindex @code{Component_Size} clauses
5323 @unnumberedsec 13.3(71-73): Component Size Clauses
5324 @sp 1
5325 @cartouche
5326 The recommended level of support for the @code{Component_Size}
5327 attribute is:
5328 @end cartouche
5329 @sp 1
5330 @cartouche
5331 An implementation need not support specified @code{Component_Sizes} that are
5332 less than the @code{Size} of the component subtype.
5333 @end cartouche
5334 Followed.
5336 @sp 1
5337 @cartouche
5338 An implementation should support specified @code{Component_Size}s that
5339 are factors and multiples of the word size.  For such
5340 @code{Component_Size}s, the array should contain no gaps between
5341 components.  For other @code{Component_Size}s (if supported), the array
5342 should contain no gaps between components when packing is also
5343 specified; the implementation should forbid this combination in cases
5344 where it cannot support a no-gaps representation.
5345 @end cartouche
5346 Followed.
5348 @cindex Enumeration representation clauses
5349 @cindex Representation clauses, enumeration
5350 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5351 @sp 1
5352 @cartouche
5353 The recommended level of support for enumeration representation clauses
5356 An implementation need not support enumeration representation clauses
5357 for boolean types, but should at minimum support the internal codes in
5358 the range @code{System.Min_Int.System.Max_Int}.
5359 @end cartouche
5360 Followed.
5362 @cindex Record representation clauses
5363 @cindex Representation clauses, records
5364 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5365 @sp 1
5366 @cartouche
5367 The recommended level of support for
5368 @*@code{record_representation_clauses} is:
5370 An implementation should support storage places that can be extracted
5371 with a load, mask, shift sequence of machine code, and set with a load,
5372 shift, mask, store sequence, given the available machine instructions
5373 and run-time model.
5374 @end cartouche
5375 Followed.
5377 @sp 1
5378 @cartouche
5379 A storage place should be supported if its size is equal to the
5380 @code{Size} of the component subtype, and it starts and ends on a
5381 boundary that obeys the @code{Alignment} of the component subtype.
5382 @end cartouche
5383 Followed.
5385 @sp 1
5386 @cartouche
5387 If the default bit ordering applies to the declaration of a given type,
5388 then for a component whose subtype's @code{Size} is less than the word
5389 size, any storage place that does not cross an aligned word boundary
5390 should be supported.
5391 @end cartouche
5392 Followed.
5394 @sp 1
5395 @cartouche
5396 An implementation may reserve a storage place for the tag field of a
5397 tagged type, and disallow other components from overlapping that place.
5398 @end cartouche
5399 Followed.  The storage place for the tag field is the beginning of the tagged
5400 record, and its size is Address'Size.  GNAT will reject an explicit component
5401 clause for the tag field.
5403 @sp 1
5404 @cartouche
5405 An implementation need not support a @code{component_clause} for a
5406 component of an extension part if the storage place is not after the
5407 storage places of all components of the parent type, whether or not
5408 those storage places had been specified.
5409 @end cartouche
5410 Followed.  The above advice on record representation clauses is followed,
5411 and all mentioned features are implemented.
5413 @cindex Storage place attributes
5414 @unnumberedsec 13.5.2(5): Storage Place Attributes
5415 @sp 1
5416 @cartouche
5417 If a component is represented using some form of pointer (such as an
5418 offset) to the actual data of the component, and this data is contiguous
5419 with the rest of the object, then the storage place attributes should
5420 reflect the place of the actual data, not the pointer.  If a component is
5421 allocated discontinuously from the rest of the object, then a warning
5422 should be generated upon reference to one of its storage place
5423 attributes.
5424 @end cartouche
5425 Followed.  There are no such components in GNAT@.
5427 @cindex Bit ordering
5428 @unnumberedsec 13.5.3(7-8): Bit Ordering
5429 @sp 1
5430 @cartouche
5431 The recommended level of support for the non-default bit ordering is:
5432 @end cartouche
5433 @sp 1
5434 @cartouche
5435 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5436 should support the non-default bit ordering in addition to the default
5437 bit ordering.
5438 @end cartouche
5439 Followed.  Word size does not equal storage size in this implementation.
5440 Thus non-default bit ordering is not supported.
5442 @cindex @code{Address}, as private type
5443 @unnumberedsec 13.7(37): Address as Private
5444 @sp 1
5445 @cartouche
5446 @code{Address} should be of a private type.
5447 @end cartouche
5448 Followed.
5450 @cindex Operations, on @code{Address}
5451 @cindex @code{Address}, operations of
5452 @unnumberedsec 13.7.1(16): Address Operations
5453 @sp 1
5454 @cartouche
5455 Operations in @code{System} and its children should reflect the target
5456 environment semantics as closely as is reasonable.  For example, on most
5457 machines, it makes sense for address arithmetic to ``wrap around''.
5458 Operations that do not make sense should raise @code{Program_Error}.
5459 @end cartouche
5460 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5461 operation raises @code{Program_Error}, since all operations make sense.
5463 @cindex Unchecked conversion
5464 @unnumberedsec 13.9(14-17): Unchecked Conversion
5465 @sp 1
5466 @cartouche
5467 The @code{Size} of an array object should not include its bounds; hence,
5468 the bounds should not be part of the converted data.
5469 @end cartouche
5470 Followed.
5472 @sp 1
5473 @cartouche
5474 The implementation should not generate unnecessary run-time checks to
5475 ensure that the representation of @var{S} is a representation of the
5476 target type.  It should take advantage of the permission to return by
5477 reference when possible.  Restrictions on unchecked conversions should be
5478 avoided unless required by the target environment.
5479 @end cartouche
5480 Followed.  There are no restrictions on unchecked conversion.  A warning is
5481 generated if the source and target types do not have the same size since
5482 the semantics in this case may be target dependent.
5484 @sp 1
5485 @cartouche
5486 The recommended level of support for unchecked conversions is:
5487 @end cartouche
5488 @sp 1
5489 @cartouche
5490 Unchecked conversions should be supported and should be reversible in
5491 the cases where this clause defines the result.  To enable meaningful use
5492 of unchecked conversion, a contiguous representation should be used for
5493 elementary subtypes, for statically constrained array subtypes whose
5494 component subtype is one of the subtypes described in this paragraph,
5495 and for record subtypes without discriminants whose component subtypes
5496 are described in this paragraph.
5497 @end cartouche
5498 Followed.
5500 @cindex Heap usage, implicit
5501 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5502 @sp 1
5503 @cartouche
5504 An implementation should document any cases in which it dynamically
5505 allocates heap storage for a purpose other than the evaluation of an
5506 allocator.
5507 @end cartouche
5508 Followed, the only other points at which heap storage is dynamically
5509 allocated are as follows:
5511 @itemize @bullet
5512 @item
5513 At initial elaboration time, to allocate dynamically sized global
5514 objects.
5516 @item
5517 To allocate space for a task when a task is created.
5519 @item
5520 To extend the secondary stack dynamically when needed.  The secondary
5521 stack is used for returning variable length results.
5522 @end itemize
5524 @sp 1
5525 @cartouche
5526 A default (implementation-provided) storage pool for an
5527 access-to-constant type should not have overhead to support deallocation of
5528 individual objects.
5529 @end cartouche
5530 Followed.
5532 @sp 1
5533 @cartouche
5534 A storage pool for an anonymous access type should be created at the
5535 point of an allocator for the type, and be reclaimed when the designated
5536 object becomes inaccessible.
5537 @end cartouche
5538 Followed.
5540 @cindex Unchecked deallocation
5541 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5542 @sp 1
5543 @cartouche
5544 For a standard storage pool, @code{Free} should actually reclaim the
5545 storage.
5546 @end cartouche
5547 Followed.
5549 @cindex Stream oriented attributes
5550 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5551 @sp 1
5552 @cartouche
5553 If a stream element is the same size as a storage element, then the
5554 normal in-memory representation should be used by @code{Read} and
5555 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5556 should use the smallest number of stream elements needed to represent
5557 all values in the base range of the scalar type.
5558 @end cartouche
5560 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5561 which specifies using the size of the first subtype.
5562 However, such an implementation is based on direct binary
5563 representations and is therefore target- and endianness-dependent.
5564 To address this issue, GNAT also supplies an alternate implementation
5565 of the stream attributes @code{Read} and @code{Write},
5566 which uses the target-independent XDR standard representation
5567 for scalar types.
5568 @cindex XDR representation
5569 @cindex @code{Read} attribute
5570 @cindex @code{Write} attribute
5571 @cindex Stream oriented attributes
5572 The XDR implementation is provided as an alternative body of the
5573 @code{System.Stream_Attributes} package, in the file
5574 @file{s-strxdr.adb} in the GNAT library.
5575 There is no @file{s-strxdr.ads} file.
5576 In order to install the XDR implementation, do the following:
5577 @enumerate
5578 @item Replace the default implementation of the
5579 @code{System.Stream_Attributes} package with the XDR implementation.
5580 For example on a Unix platform issue the commands:
5581 @smallexample
5582 $ mv s-stratt.adb s-strold.adb
5583 $ mv s-strxdr.adb s-stratt.adb
5584 @end smallexample
5586 @item
5587 Rebuild the GNAT run-time library as documented in the
5588 @cite{GNAT User's Guide}
5589 @end enumerate
5591 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5592 @sp 1
5593 @cartouche
5594 If an implementation provides additional named predefined integer types,
5595 then the names should end with @samp{Integer} as in
5596 @samp{Long_Integer}.  If an implementation provides additional named
5597 predefined floating point types, then the names should end with
5598 @samp{Float} as in @samp{Long_Float}.
5599 @end cartouche
5600 Followed.
5602 @findex Ada.Characters.Handling
5603 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5604 @sp 1
5605 @cartouche
5606 If an implementation provides a localized definition of @code{Character}
5607 or @code{Wide_Character}, then the effects of the subprograms in
5608 @code{Characters.Handling} should reflect the localizations.  See also
5609 3.5.2.
5610 @end cartouche
5611 Followed.  GNAT provides no such localized definitions.
5613 @cindex Bounded-length strings
5614 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5615 @sp 1
5616 @cartouche
5617 Bounded string objects should not be implemented by implicit pointers
5618 and dynamic allocation.
5619 @end cartouche
5620 Followed.  No implicit pointers or dynamic allocation are used.
5622 @cindex Random number generation
5623 @unnumberedsec A.5.2(46-47): Random Number Generation
5624 @sp 1
5625 @cartouche
5626 Any storage associated with an object of type @code{Generator} should be
5627 reclaimed on exit from the scope of the object.
5628 @end cartouche
5629 Followed.
5631 @sp 1
5632 @cartouche
5633 If the generator period is sufficiently long in relation to the number
5634 of distinct initiator values, then each possible value of
5635 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5636 random numbers that does not, in a practical sense, overlap the sequence
5637 initiated by any other value.  If this is not possible, then the mapping
5638 between initiator values and generator states should be a rapidly
5639 varying function of the initiator value.
5640 @end cartouche
5641 Followed.  The generator period is sufficiently long for the first
5642 condition here to hold true.
5644 @findex Get_Immediate
5645 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5646 @sp 1
5647 @cartouche
5648 The @code{Get_Immediate} procedures should be implemented with
5649 unbuffered input.  For a device such as a keyboard, input should be
5650 @dfn{available} if a key has already been typed, whereas for a disk
5651 file, input should always be available except at end of file.  For a file
5652 associated with a keyboard-like device, any line-editing features of the
5653 underlying operating system should be disabled during the execution of
5654 @code{Get_Immediate}.
5655 @end cartouche
5656 Followed on all targets except VxWorks. For VxWorks, there is no way to
5657 provide this functionality that does not result in the input buffer being
5658 flushed before the @code{Get_Immediate} call. A special unit
5659 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5660 this functionality.
5662 @findex Export
5663 @unnumberedsec B.1(39-41): Pragma @code{Export}
5664 @sp 1
5665 @cartouche
5666 If an implementation supports pragma @code{Export} to a given language,
5667 then it should also allow the main subprogram to be written in that
5668 language.  It should support some mechanism for invoking the elaboration
5669 of the Ada library units included in the system, and for invoking the
5670 finalization of the environment task.  On typical systems, the
5671 recommended mechanism is to provide two subprograms whose link names are
5672 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5673 elaboration code for library units.  @code{adafinal} should contain the
5674 finalization code.  These subprograms should have no effect the second
5675 and subsequent time they are called.
5676 @end cartouche
5677 Followed.
5679 @sp 1
5680 @cartouche
5681 Automatic elaboration of pre-elaborated packages should be
5682 provided when pragma @code{Export} is supported.
5683 @end cartouche
5684 Followed when the main program is in Ada.  If the main program is in a
5685 foreign language, then
5686 @code{adainit} must be called to elaborate pre-elaborated
5687 packages.
5689 @sp 1
5690 @cartouche
5691 For each supported convention @var{L} other than @code{Intrinsic}, an
5692 implementation should support @code{Import} and @code{Export} pragmas
5693 for objects of @var{L}-compatible types and for subprograms, and pragma
5694 @code{Convention} for @var{L}-eligible types and for subprograms,
5695 presuming the other language has corresponding features.  Pragma
5696 @code{Convention} need not be supported for scalar types.
5697 @end cartouche
5698 Followed.
5700 @cindex Package @code{Interfaces}
5701 @findex Interfaces
5702 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5703 @sp 1
5704 @cartouche
5705 For each implementation-defined convention identifier, there should be a
5706 child package of package Interfaces with the corresponding name.  This
5707 package should contain any declarations that would be useful for
5708 interfacing to the language (implementation) represented by the
5709 convention.  Any declarations useful for interfacing to any language on
5710 the given hardware architecture should be provided directly in
5711 @code{Interfaces}.
5712 @end cartouche
5713 Followed.  An additional package not defined
5714 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5715 for interfacing to C++.
5717 @sp 1
5718 @cartouche
5719 An implementation supporting an interface to C, COBOL, or Fortran should
5720 provide the corresponding package or packages described in the following
5721 clauses.
5722 @end cartouche
5723 Followed.  GNAT provides all the packages described in this section.
5725 @cindex C, interfacing with
5726 @unnumberedsec B.3(63-71): Interfacing with C
5727 @sp 1
5728 @cartouche
5729 An implementation should support the following interface correspondences
5730 between Ada and C@.
5731 @end cartouche
5732 Followed.
5734 @sp 1
5735 @cartouche
5736 An Ada procedure corresponds to a void-returning C function.
5737 @end cartouche
5738 Followed.
5740 @sp 1
5741 @cartouche
5742 An Ada function corresponds to a non-void C function.
5743 @end cartouche
5744 Followed.
5746 @sp 1
5747 @cartouche
5748 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5749 function.
5750 @end cartouche
5751 Followed.
5753 @sp 1
5754 @cartouche
5755 An Ada @code{in} parameter of an access-to-object type with designated
5756 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5757 where @var{t} is the C type corresponding to the Ada type @var{T}.
5758 @end cartouche
5759 Followed.
5761 @sp 1
5762 @cartouche
5763 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5764 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5765 argument to a C function, where @var{t} is the C type corresponding to
5766 the Ada type @var{T}.  In the case of an elementary @code{out} or
5767 @code{in out} parameter, a pointer to a temporary copy is used to
5768 preserve by-copy semantics.
5769 @end cartouche
5770 Followed.
5772 @sp 1
5773 @cartouche
5774 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5775 @code{@var{t}*} argument to a C function, where @var{t} is the C
5776 structure corresponding to the Ada type @var{T}.
5777 @end cartouche
5778 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5779 pragma, or Convention, or by explicitly specifying the mechanism for a given
5780 call using an extended import or export pragma.
5782 @sp 1
5783 @cartouche
5784 An Ada parameter of an array type with component type @var{T}, of any
5785 mode, is passed as a @code{@var{t}*} argument to a C function, where
5786 @var{t} is the C type corresponding to the Ada type @var{T}.
5787 @end cartouche
5788 Followed.
5790 @sp 1
5791 @cartouche
5792 An Ada parameter of an access-to-subprogram type is passed as a pointer
5793 to a C function whose prototype corresponds to the designated
5794 subprogram's specification.
5795 @end cartouche
5796 Followed.
5798 @cindex COBOL, interfacing with
5799 @unnumberedsec B.4(95-98): Interfacing with COBOL
5800 @sp 1
5801 @cartouche
5802 An Ada implementation should support the following interface
5803 correspondences between Ada and COBOL@.
5804 @end cartouche
5805 Followed.
5807 @sp 1
5808 @cartouche
5809 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5810 the COBOL type corresponding to @var{T}.
5811 @end cartouche
5812 Followed.
5814 @sp 1
5815 @cartouche
5816 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5817 the corresponding COBOL type.
5818 @end cartouche
5819 Followed.
5821 @sp 1
5822 @cartouche
5823 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5824 COBOL type corresponding to the Ada parameter type; for scalars, a local
5825 copy is used if necessary to ensure by-copy semantics.
5826 @end cartouche
5827 Followed.
5829 @cindex Fortran, interfacing with
5830 @unnumberedsec B.5(22-26): Interfacing with Fortran
5831 @sp 1
5832 @cartouche
5833 An Ada implementation should support the following interface
5834 correspondences between Ada and Fortran:
5835 @end cartouche
5836 Followed.
5838 @sp 1
5839 @cartouche
5840 An Ada procedure corresponds to a Fortran subroutine.
5841 @end cartouche
5842 Followed.
5844 @sp 1
5845 @cartouche
5846 An Ada function corresponds to a Fortran function.
5847 @end cartouche
5848 Followed.
5850 @sp 1
5851 @cartouche
5852 An Ada parameter of an elementary, array, or record type @var{T} is
5853 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5854 the Fortran type corresponding to the Ada type @var{T}, and where the
5855 INTENT attribute of the corresponding dummy argument matches the Ada
5856 formal parameter mode; the Fortran implementation's parameter passing
5857 conventions are used.  For elementary types, a local copy is used if
5858 necessary to ensure by-copy semantics.
5859 @end cartouche
5860 Followed.
5862 @sp 1
5863 @cartouche
5864 An Ada parameter of an access-to-subprogram type is passed as a
5865 reference to a Fortran procedure whose interface corresponds to the
5866 designated subprogram's specification.
5867 @end cartouche
5868 Followed.
5870 @cindex Machine operations
5871 @unnumberedsec C.1(3-5): Access to Machine Operations
5872 @sp 1
5873 @cartouche
5874 The machine code or intrinsic support should allow access to all
5875 operations normally available to assembly language programmers for the
5876 target environment, including privileged instructions, if any.
5877 @end cartouche
5878 Followed.
5880 @sp 1
5881 @cartouche
5882 The interfacing pragmas (see Annex B) should support interface to
5883 assembler; the default assembler should be associated with the
5884 convention identifier @code{Assembler}.
5885 @end cartouche
5886 Followed.
5888 @sp 1
5889 @cartouche
5890 If an entity is exported to assembly language, then the implementation
5891 should allocate it at an addressable location, and should ensure that it
5892 is retained by the linking process, even if not otherwise referenced
5893 from the Ada code.  The implementation should assume that any call to a
5894 machine code or assembler subprogram is allowed to read or update every
5895 object that is specified as exported.
5896 @end cartouche
5897 Followed.
5899 @unnumberedsec C.1(10-16): Access to Machine Operations
5900 @sp 1
5901 @cartouche
5902 The implementation should ensure that little or no overhead is
5903 associated with calling intrinsic and machine-code subprograms.
5904 @end cartouche
5905 Followed for both intrinsics and machine-code subprograms.
5907 @sp 1
5908 @cartouche
5909 It is recommended that intrinsic subprograms be provided for convenient
5910 access to any machine operations that provide special capabilities or
5911 efficiency and that are not otherwise available through the language
5912 constructs.
5913 @end cartouche
5914 Followed.  A full set of machine operation intrinsic subprograms is provided.
5916 @sp 1
5917 @cartouche
5918 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5919 swap, decrement and test, enqueue/dequeue.
5920 @end cartouche
5921 Followed on any target supporting such operations.
5923 @sp 1
5924 @cartouche
5925 Standard numeric functions---e.g.@:, sin, log.
5926 @end cartouche
5927 Followed on any target supporting such operations.
5929 @sp 1
5930 @cartouche
5931 String manipulation operations---e.g.@:, translate and test.
5932 @end cartouche
5933 Followed on any target supporting such operations.
5935 @sp 1
5936 @cartouche
5937 Vector operations---e.g.@:, compare vector against thresholds.
5938 @end cartouche
5939 Followed on any target supporting such operations.
5941 @sp 1
5942 @cartouche
5943 Direct operations on I/O ports.
5944 @end cartouche
5945 Followed on any target supporting such operations.
5947 @cindex Interrupt support
5948 @unnumberedsec C.3(28): Interrupt Support
5949 @sp 1
5950 @cartouche
5951 If the @code{Ceiling_Locking} policy is not in effect, the
5952 implementation should provide means for the application to specify which
5953 interrupts are to be blocked during protected actions, if the underlying
5954 system allows for a finer-grain control of interrupt blocking.
5955 @end cartouche
5956 Followed.  The underlying system does not allow for finer-grain control
5957 of interrupt blocking.
5959 @cindex Protected procedure handlers
5960 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5961 @sp 1
5962 @cartouche
5963 Whenever possible, the implementation should allow interrupt handlers to
5964 be called directly by the hardware.
5965 @end cartouche
5966 @c SGI info:
5967 @ignore
5968 This is never possible under IRIX, so this is followed by default.
5969 @end ignore
5970 Followed on any target where the underlying operating system permits
5971 such direct calls.
5973 @sp 1
5974 @cartouche
5975 Whenever practical, violations of any
5976 implementation-defined restrictions should be detected before run time.
5977 @end cartouche
5978 Followed.  Compile time warnings are given when possible.
5980 @cindex Package @code{Interrupts}
5981 @findex Interrupts
5982 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5984 @sp 1
5985 @cartouche
5986 If implementation-defined forms of interrupt handler procedures are
5987 supported, such as protected procedures with parameters, then for each
5988 such form of a handler, a type analogous to @code{Parameterless_Handler}
5989 should be specified in a child package of @code{Interrupts}, with the
5990 same operations as in the predefined package Interrupts.
5991 @end cartouche
5992 Followed.
5994 @cindex Pre-elaboration requirements
5995 @unnumberedsec C.4(14): Pre-elaboration Requirements
5996 @sp 1
5997 @cartouche
5998 It is recommended that pre-elaborated packages be implemented in such a
5999 way that there should be little or no code executed at run time for the
6000 elaboration of entities not already covered by the Implementation
6001 Requirements.
6002 @end cartouche
6003 Followed.  Executable code is generated in some cases, e.g.@: loops
6004 to initialize large arrays.
6006 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6008 @sp 1
6009 @cartouche
6010 If the pragma applies to an entity, then the implementation should
6011 reduce the amount of storage used for storing names associated with that
6012 entity.
6013 @end cartouche
6014 Followed.
6016 @cindex Package @code{Task_Attributes}
6017 @findex Task_Attributes
6018 @unnumberedsec C.7.2(30): The Package Task_Attributes
6019 @sp 1
6020 @cartouche
6021 Some implementations are targeted to domains in which memory use at run
6022 time must be completely deterministic.  For such implementations, it is
6023 recommended that the storage for task attributes will be pre-allocated
6024 statically and not from the heap.  This can be accomplished by either
6025 placing restrictions on the number and the size of the task's
6026 attributes, or by using the pre-allocated storage for the first @var{N}
6027 attribute objects, and the heap for the others.  In the latter case,
6028 @var{N} should be documented.
6029 @end cartouche
6030 Not followed.  This implementation is not targeted to such a domain.
6032 @cindex Locking Policies
6033 @unnumberedsec D.3(17): Locking Policies
6035 @sp 1
6036 @cartouche
6037 The implementation should use names that end with @samp{_Locking} for
6038 locking policies defined by the implementation.
6039 @end cartouche
6040 Followed.  A single implementation-defined locking policy is defined,
6041 whose name (@code{Inheritance_Locking}) follows this suggestion.
6043 @cindex Entry queuing policies
6044 @unnumberedsec D.4(16): Entry Queuing Policies
6045 @sp 1
6046 @cartouche
6047 Names that end with @samp{_Queuing} should be used
6048 for all implementation-defined queuing policies.
6049 @end cartouche
6050 Followed.  No such implementation-defined queuing policies exist.
6052 @cindex Preemptive abort
6053 @unnumberedsec D.6(9-10): Preemptive Abort
6054 @sp 1
6055 @cartouche
6056 Even though the @code{abort_statement} is included in the list of
6057 potentially blocking operations (see 9.5.1), it is recommended that this
6058 statement be implemented in a way that never requires the task executing
6059 the @code{abort_statement} to block.
6060 @end cartouche
6061 Followed.
6063 @sp 1
6064 @cartouche
6065 On a multi-processor, the delay associated with aborting a task on
6066 another processor should be bounded; the implementation should use
6067 periodic polling, if necessary, to achieve this.
6068 @end cartouche
6069 Followed.
6071 @cindex Tasking restrictions
6072 @unnumberedsec D.7(21): Tasking Restrictions
6073 @sp 1
6074 @cartouche
6075 When feasible, the implementation should take advantage of the specified
6076 restrictions to produce a more efficient implementation.
6077 @end cartouche
6078 GNAT currently takes advantage of these restrictions by providing an optimized
6079 run time when the Ravenscar profile and the GNAT restricted run time set
6080 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6081 pragma @code{Profile (Restricted)} for more details.
6083 @cindex Time, monotonic
6084 @unnumberedsec D.8(47-49): Monotonic Time
6085 @sp 1
6086 @cartouche
6087 When appropriate, implementations should provide configuration
6088 mechanisms to change the value of @code{Tick}.
6089 @end cartouche
6090 Such configuration mechanisms are not appropriate to this implementation
6091 and are thus not supported.
6093 @sp 1
6094 @cartouche
6095 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6096 be implemented as transformations of the same time base.
6097 @end cartouche
6098 Followed.
6100 @sp 1
6101 @cartouche
6102 It is recommended that the @dfn{best} time base which exists in
6103 the underlying system be available to the application through
6104 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6105 @end cartouche
6106 Followed.
6108 @cindex Partition communication subsystem
6109 @cindex PCS
6110 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6111 @sp 1
6112 @cartouche
6113 Whenever possible, the PCS on the called partition should allow for
6114 multiple tasks to call the RPC-receiver with different messages and
6115 should allow them to block until the corresponding subprogram body
6116 returns.
6117 @end cartouche
6118 Followed by GLADE, a separately supplied PCS that can be used with
6119 GNAT.
6121 @sp 1
6122 @cartouche
6123 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6124 should raise @code{Storage_Error} if it runs out of space trying to
6125 write the @code{Item} into the stream.
6126 @end cartouche
6127 Followed by GLADE, a separately supplied PCS that can be used with
6128 GNAT@.
6130 @cindex COBOL support
6131 @unnumberedsec F(7): COBOL Support
6132 @sp 1
6133 @cartouche
6134 If COBOL (respectively, C) is widely supported in the target
6135 environment, implementations supporting the Information Systems Annex
6136 should provide the child package @code{Interfaces.COBOL} (respectively,
6137 @code{Interfaces.C}) specified in Annex B and should support a
6138 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6139 pragmas (see Annex B), thus allowing Ada programs to interface with
6140 programs written in that language.
6141 @end cartouche
6142 Followed.
6144 @cindex Decimal radix support
6145 @unnumberedsec F.1(2): Decimal Radix Support
6146 @sp 1
6147 @cartouche
6148 Packed decimal should be used as the internal representation for objects
6149 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6150 @end cartouche
6151 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6152 representations.
6154 @cindex Numerics
6155 @unnumberedsec G: Numerics
6156 @sp 2
6157 @cartouche
6158 If Fortran (respectively, C) is widely supported in the target
6159 environment, implementations supporting the Numerics Annex
6160 should provide the child package @code{Interfaces.Fortran} (respectively,
6161 @code{Interfaces.C}) specified in Annex B and should support a
6162 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6163 pragmas (see Annex B), thus allowing Ada programs to interface with
6164 programs written in that language.
6165 @end cartouche
6166 Followed.
6168 @cindex Complex types
6169 @unnumberedsec G.1.1(56-58): Complex Types
6170 @sp 2
6171 @cartouche
6172 Because the usual mathematical meaning of multiplication of a complex
6173 operand and a real operand is that of the scaling of both components of
6174 the former by the latter, an implementation should not perform this
6175 operation by first promoting the real operand to complex type and then
6176 performing a full complex multiplication.  In systems that, in the
6177 future, support an Ada binding to IEC 559:1989, the latter technique
6178 will not generate the required result when one of the components of the
6179 complex operand is infinite.  (Explicit multiplication of the infinite
6180 component by the zero component obtained during promotion yields a NaN
6181 that propagates into the final result.) Analogous advice applies in the
6182 case of multiplication of a complex operand and a pure-imaginary
6183 operand, and in the case of division of a complex operand by a real or
6184 pure-imaginary operand.
6185 @end cartouche
6186 Not followed.
6188 @sp 1
6189 @cartouche
6190 Similarly, because the usual mathematical meaning of addition of a
6191 complex operand and a real operand is that the imaginary operand remains
6192 unchanged, an implementation should not perform this operation by first
6193 promoting the real operand to complex type and then performing a full
6194 complex addition.  In implementations in which the @code{Signed_Zeros}
6195 attribute of the component type is @code{True} (and which therefore
6196 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6197 predefined arithmetic operations), the latter technique will not
6198 generate the required result when the imaginary component of the complex
6199 operand is a negatively signed zero.  (Explicit addition of the negative
6200 zero to the zero obtained during promotion yields a positive zero.)
6201 Analogous advice applies in the case of addition of a complex operand
6202 and a pure-imaginary operand, and in the case of subtraction of a
6203 complex operand and a real or pure-imaginary operand.
6204 @end cartouche
6205 Not followed.
6207 @sp 1
6208 @cartouche
6209 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6210 attempt to provide a rational treatment of the signs of zero results and
6211 result components.  As one example, the result of the @code{Argument}
6212 function should have the sign of the imaginary component of the
6213 parameter @code{X} when the point represented by that parameter lies on
6214 the positive real axis; as another, the sign of the imaginary component
6215 of the @code{Compose_From_Polar} function should be the same as
6216 (respectively, the opposite of) that of the @code{Argument} parameter when that
6217 parameter has a value of zero and the @code{Modulus} parameter has a
6218 nonnegative (respectively, negative) value.
6219 @end cartouche
6220 Followed.
6222 @cindex Complex elementary functions
6223 @unnumberedsec G.1.2(49): Complex Elementary Functions
6224 @sp 1
6225 @cartouche
6226 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6227 @code{True} should attempt to provide a rational treatment of the signs
6228 of zero results and result components.  For example, many of the complex
6229 elementary functions have components that are odd functions of one of
6230 the parameter components; in these cases, the result component should
6231 have the sign of the parameter component at the origin.  Other complex
6232 elementary functions have zero components whose sign is opposite that of
6233 a parameter component at the origin, or is always positive or always
6234 negative.
6235 @end cartouche
6236 Followed.
6238 @cindex Accuracy requirements
6239 @unnumberedsec G.2.4(19): Accuracy Requirements
6240 @sp 1
6241 @cartouche
6242 The versions of the forward trigonometric functions without a
6243 @code{Cycle} parameter should not be implemented by calling the
6244 corresponding version with a @code{Cycle} parameter of
6245 @code{2.0*Numerics.Pi}, since this will not provide the required
6246 accuracy in some portions of the domain.  For the same reason, the
6247 version of @code{Log} without a @code{Base} parameter should not be
6248 implemented by calling the corresponding version with a @code{Base}
6249 parameter of @code{Numerics.e}.
6250 @end cartouche
6251 Followed.
6253 @cindex Complex arithmetic accuracy
6254 @cindex Accuracy, complex arithmetic
6255 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6257 @sp 1
6258 @cartouche
6259 The version of the @code{Compose_From_Polar} function without a
6260 @code{Cycle} parameter should not be implemented by calling the
6261 corresponding version with a @code{Cycle} parameter of
6262 @code{2.0*Numerics.Pi}, since this will not provide the required
6263 accuracy in some portions of the domain.
6264 @end cartouche
6265 Followed.
6267 @c -----------------------------------------
6268 @node Implementation Defined Characteristics
6269 @chapter Implementation Defined Characteristics
6271 @noindent
6272 In addition to the implementation dependent pragmas and attributes, and
6273 the implementation advice, there are a number of other features of Ada
6274 95 that are potentially implementation dependent.  These are mentioned
6275 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6277 A requirement for conforming Ada compilers is that they provide
6278 documentation describing how the implementation deals with each of these
6279 issues.  In this chapter, you will find each point in annex M listed
6280 followed by a description in italic font of how GNAT
6281 @c SGI info:
6282 @ignore
6283 in the ProDev Ada
6284 implementation on IRIX 5.3 operating system or greater
6285 @end ignore
6286 handles the implementation dependence.
6288 You can use this chapter as a guide to minimizing implementation
6289 dependent features in your programs if portability to other compilers
6290 and other operating systems is an important consideration.  The numbers
6291 in each section below correspond to the paragraph number in the Ada 95
6292 Reference Manual.
6294 @sp 1
6295 @cartouche
6296 @noindent
6297 @strong{2}.  Whether or not each recommendation given in Implementation
6298 Advice is followed.  See 1.1.2(37).
6299 @end cartouche
6300 @noindent
6301 @xref{Implementation Advice}.
6303 @sp 1
6304 @cartouche
6305 @noindent
6306 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6307 @end cartouche
6308 @noindent
6309 The complexity of programs that can be processed is limited only by the
6310 total amount of available virtual memory, and disk space for the
6311 generated object files.
6313 @sp 1
6314 @cartouche
6315 @noindent
6316 @strong{4}.  Variations from the standard that are impractical to avoid
6317 given the implementation's execution environment.  See 1.1.3(6).
6318 @end cartouche
6319 @noindent
6320 There are no variations from the standard.
6322 @sp 1
6323 @cartouche
6324 @noindent
6325 @strong{5}.  Which @code{code_statement}s cause external
6326 interactions.  See 1.1.3(10).
6327 @end cartouche
6328 @noindent
6329 Any @code{code_statement} can potentially cause external interactions.
6331 @sp 1
6332 @cartouche
6333 @noindent
6334 @strong{6}.  The coded representation for the text of an Ada
6335 program.  See 2.1(4).
6336 @end cartouche
6337 @noindent
6338 See separate section on source representation.
6340 @sp 1
6341 @cartouche
6342 @noindent
6343 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6344 @end cartouche
6345 @noindent
6346 See separate section on source representation.
6348 @sp 1
6349 @cartouche
6350 @noindent
6351 @strong{8}.  The representation for an end of line.  See 2.2(2).
6352 @end cartouche
6353 @noindent
6354 See separate section on source representation.
6356 @sp 1
6357 @cartouche
6358 @noindent
6359 @strong{9}.  Maximum supported line length and lexical element
6360 length.  See 2.2(15).
6361 @end cartouche
6362 @noindent
6363 The maximum line length is 255 characters an the maximum length of a
6364 lexical element is also 255 characters.
6366 @sp 1
6367 @cartouche
6368 @noindent
6369 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6370 @end cartouche
6371 @noindent
6373 @xref{Implementation Defined Pragmas}.
6375 @sp 1
6376 @cartouche
6377 @noindent
6378 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6379 @end cartouche
6380 @noindent
6381 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6382 parameter, checks that the optimization flag is set, and aborts if it is
6383 not.
6385 @sp 1
6386 @cartouche
6387 @noindent
6388 @strong{12}.  The sequence of characters of the value returned by
6389 @code{@var{S}'Image} when some of the graphic characters of
6390 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6391 3.5(37).
6392 @end cartouche
6393 @noindent
6394 The sequence of characters is as defined by the wide character encoding
6395 method used for the source.  See section on source representation for
6396 further details.
6398 @sp 1
6399 @cartouche
6400 @noindent
6401 @strong{13}.  The predefined integer types declared in
6402 @code{Standard}.  See 3.5.4(25).
6403 @end cartouche
6404 @noindent
6405 @table @code
6406 @item Short_Short_Integer
6407 8 bit signed
6408 @item Short_Integer
6409 (Short) 16 bit signed
6410 @item Integer
6411 32 bit signed
6412 @item Long_Integer
6413 64 bit signed (Alpha OpenVMS only)
6414 32 bit signed (all other targets)
6415 @item Long_Long_Integer
6416 64 bit signed
6417 @end table
6419 @sp 1
6420 @cartouche
6421 @noindent
6422 @strong{14}.  Any nonstandard integer types and the operators defined
6423 for them.  See 3.5.4(26).
6424 @end cartouche
6425 @noindent
6426 There are no nonstandard integer types.
6428 @sp 1
6429 @cartouche
6430 @noindent
6431 @strong{15}.  Any nonstandard real types and the operators defined for
6432 them.  See 3.5.6(8).
6433 @end cartouche
6434 @noindent
6435 There are no nonstandard real types.
6437 @sp 1
6438 @cartouche
6439 @noindent
6440 @strong{16}.  What combinations of requested decimal precision and range
6441 are supported for floating point types.  See 3.5.7(7).
6442 @end cartouche
6443 @noindent
6444 The precision and range is as defined by the IEEE standard.
6446 @sp 1
6447 @cartouche
6448 @noindent
6449 @strong{17}.  The predefined floating point types declared in
6450 @code{Standard}.  See 3.5.7(16).
6451 @end cartouche
6452 @noindent
6453 @table @code
6454 @item Short_Float
6455 32 bit IEEE short
6456 @item Float
6457 (Short) 32 bit IEEE short
6458 @item Long_Float
6459 64 bit IEEE long
6460 @item Long_Long_Float
6461 64 bit IEEE long (80 bit IEEE long on x86 processors)
6462 @end table
6464 @sp 1
6465 @cartouche
6466 @noindent
6467 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6468 @end cartouche
6469 @noindent
6470 @code{Fine_Delta} is 2**(@minus{}63)
6472 @sp 1
6473 @cartouche
6474 @noindent
6475 @strong{19}.  What combinations of small, range, and digits are
6476 supported for fixed point types.  See 3.5.9(10).
6477 @end cartouche
6478 @noindent
6479 Any combinations are permitted that do not result in a small less than
6480 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6481 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6482 is 64 bits (true of all architectures except ia32), then the output from
6483 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6484 is because floating-point conversions are used to convert fixed point.
6486 @sp 1
6487 @cartouche
6488 @noindent
6489 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6490 within an unnamed @code{block_statement}.  See 3.9(10).
6491 @end cartouche
6492 @noindent
6493 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6494 decimal integer are allocated.
6496 @sp 1
6497 @cartouche
6498 @noindent
6499 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6500 @end cartouche
6501 @noindent
6502 @xref{Implementation Defined Attributes}.
6504 @sp 1
6505 @cartouche
6506 @noindent
6507 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6508 @end cartouche
6509 @noindent
6510 There are no implementation-defined time types.
6512 @sp 1
6513 @cartouche
6514 @noindent
6515 @strong{23}.  The time base associated with relative delays.
6516 @end cartouche
6517 @noindent
6518 See 9.6(20).  The time base used is that provided by the C library
6519 function @code{gettimeofday}.
6521 @sp 1
6522 @cartouche
6523 @noindent
6524 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6525 9.6(23).
6526 @end cartouche
6527 @noindent
6528 The time base used is that provided by the C library function
6529 @code{gettimeofday}.
6531 @sp 1
6532 @cartouche
6533 @noindent
6534 @strong{25}.  The time zone used for package @code{Calendar}
6535 operations.  See 9.6(24).
6536 @end cartouche
6537 @noindent
6538 The time zone used by package @code{Calendar} is the current system time zone
6539 setting for local time, as accessed by the C library function
6540 @code{localtime}.
6542 @sp 1
6543 @cartouche
6544 @noindent
6545 @strong{26}.  Any limit on @code{delay_until_statements} of
6546 @code{select_statements}.  See 9.6(29).
6547 @end cartouche
6548 @noindent
6549 There are no such limits.
6551 @sp 1
6552 @cartouche
6553 @noindent
6554 @strong{27}.  Whether or not two non overlapping parts of a composite
6555 object are independently addressable, in the case where packing, record
6556 layout, or @code{Component_Size} is specified for the object.  See
6557 9.10(1).
6558 @end cartouche
6559 @noindent
6560 Separate components are independently addressable if they do not share
6561 overlapping storage units.
6563 @sp 1
6564 @cartouche
6565 @noindent
6566 @strong{28}.  The representation for a compilation.  See 10.1(2).
6567 @end cartouche
6568 @noindent
6569 A compilation is represented by a sequence of files presented to the
6570 compiler in a single invocation of the @code{gcc} command.
6572 @sp 1
6573 @cartouche
6574 @noindent
6575 @strong{29}.  Any restrictions on compilations that contain multiple
6576 compilation_units.  See 10.1(4).
6577 @end cartouche
6578 @noindent
6579 No single file can contain more than one compilation unit, but any
6580 sequence of files can be presented to the compiler as a single
6581 compilation.
6583 @sp 1
6584 @cartouche
6585 @noindent
6586 @strong{30}.  The mechanisms for creating an environment and for adding
6587 and replacing compilation units.  See 10.1.4(3).
6588 @end cartouche
6589 @noindent
6590 See separate section on compilation model.
6592 @sp 1
6593 @cartouche
6594 @noindent
6595 @strong{31}.  The manner of explicitly assigning library units to a
6596 partition.  See 10.2(2).
6597 @end cartouche
6598 @noindent
6599 If a unit contains an Ada main program, then the Ada units for the partition
6600 are determined by recursive application of the rules in the Ada Reference
6601 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6602 are needed by the main program, and then this definition of need is applied
6603 recursively to those units, and the partition contains the transitive
6604 closure determined by this relationship.  In short, all the necessary units
6605 are included, with no need to explicitly specify the list.  If additional
6606 units are required, e.g.@: by foreign language units, then all units must be
6607 mentioned in the context clause of one of the needed Ada units.
6609 If the partition contains no main program, or if the main program is in
6610 a language other than Ada, then GNAT
6611 provides the binder options @code{-z} and @code{-n} respectively, and in
6612 this case a list of units can be explicitly supplied to the binder for
6613 inclusion in the partition (all units needed by these units will also
6614 be included automatically).  For full details on the use of these
6615 options, refer to the @cite{GNAT User's Guide} sections on Binding
6616 and Linking.
6618 @sp 1
6619 @cartouche
6620 @noindent
6621 @strong{32}.  The implementation-defined means, if any, of specifying
6622 which compilation units are needed by a given compilation unit.  See
6623 10.2(2).
6624 @end cartouche
6625 @noindent
6626 The units needed by a given compilation unit are as defined in
6627 the Ada Reference Manual section 10.2(2-6).  There are no
6628 implementation-defined pragmas or other implementation-defined
6629 means for specifying needed units.
6631 @sp 1
6632 @cartouche
6633 @noindent
6634 @strong{33}.  The manner of designating the main subprogram of a
6635 partition.  See 10.2(7).
6636 @end cartouche
6637 @noindent
6638 The main program is designated by providing the name of the
6639 corresponding @file{ALI} file as the input parameter to the binder.
6641 @sp 1
6642 @cartouche
6643 @noindent
6644 @strong{34}.  The order of elaboration of @code{library_items}.  See
6645 10.2(18).
6646 @end cartouche
6647 @noindent
6648 The first constraint on ordering is that it meets the requirements of
6649 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6650 implementation dependent choices, which are resolved by first
6651 elaborating bodies as early as possible (i.e.@: in preference to specs
6652 where there is a choice), and second by evaluating the immediate with
6653 clauses of a unit to determine the probably best choice, and
6654 third by elaborating in alphabetical order of unit names
6655 where a choice still remains.
6657 @sp 1
6658 @cartouche
6659 @noindent
6660 @strong{35}.  Parameter passing and function return for the main
6661 subprogram.  See 10.2(21).
6662 @end cartouche
6663 @noindent
6664 The main program has no parameters.  It may be a procedure, or a function
6665 returning an integer type.  In the latter case, the returned integer
6666 value is the return code of the program (overriding any value that
6667 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6669 @sp 1
6670 @cartouche
6671 @noindent
6672 @strong{36}.  The mechanisms for building and running partitions.  See
6673 10.2(24).
6674 @end cartouche
6675 @noindent
6676 GNAT itself supports programs with only a single partition.  The GNATDIST
6677 tool provided with the GLADE package (which also includes an implementation
6678 of the PCS) provides a completely flexible method for building and running
6679 programs consisting of multiple partitions.  See the separate GLADE manual
6680 for details.
6682 @sp 1
6683 @cartouche
6684 @noindent
6685 @strong{37}.  The details of program execution, including program
6686 termination.  See 10.2(25).
6687 @end cartouche
6688 @noindent
6689 See separate section on compilation model.
6691 @sp 1
6692 @cartouche
6693 @noindent
6694 @strong{38}.  The semantics of any non-active partitions supported by the
6695 implementation.  See 10.2(28).
6696 @end cartouche
6697 @noindent
6698 Passive partitions are supported on targets where shared memory is
6699 provided by the operating system.  See the GLADE reference manual for
6700 further details.
6702 @sp 1
6703 @cartouche
6704 @noindent
6705 @strong{39}.  The information returned by @code{Exception_Message}.  See
6706 11.4.1(10).
6707 @end cartouche
6708 @noindent
6709 Exception message returns the null string unless a specific message has
6710 been passed by the program.
6712 @sp 1
6713 @cartouche
6714 @noindent
6715 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6716 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6717 @end cartouche
6718 @noindent
6719 Blocks have implementation defined names of the form @code{B@var{nnn}}
6720 where @var{nnn} is an integer.
6722 @sp 1
6723 @cartouche
6724 @noindent
6725 @strong{41}.  The information returned by
6726 @code{Exception_Information}.  See 11.4.1(13).
6727 @end cartouche
6728 @noindent
6729 @code{Exception_Information} returns a string in the following format:
6731 @smallexample
6732 @emph{Exception_Name:} nnnnn
6733 @emph{Message:} mmmmm
6734 @emph{PID:} ppp
6735 @emph{Call stack traceback locations:}
6736 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6737 @end smallexample
6739 @noindent
6740 where
6742 @itemize @bullet
6743 @item
6744 @code{nnnn} is the fully qualified name of the exception in all upper
6745 case letters. This line is always present.
6747 @item
6748 @code{mmmm} is the message (this line present only if message is non-null)
6750 @item
6751 @code{ppp} is the Process Id value as a decimal integer (this line is
6752 present only if the Process Id is non-zero). Currently we are
6753 not making use of this field.
6755 @item
6756 The Call stack traceback locations line and the following values
6757 are present only if at least one traceback location was recorded.
6758 The values are given in C style format, with lower case letters
6759 for a-f, and only as many digits present as are necessary.
6760 @end itemize
6762 @noindent
6763 The line terminator sequence at the end of each line, including
6764 the last line is a single @code{LF} character (@code{16#0A#}).
6766 @sp 1
6767 @cartouche
6768 @noindent
6769 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6770 @end cartouche
6771 @noindent
6772 No implementation-defined check names are supported.
6774 @sp 1
6775 @cartouche
6776 @noindent
6777 @strong{43}.  The interpretation of each aspect of representation.  See
6778 13.1(20).
6779 @end cartouche
6780 @noindent
6781 See separate section on data representations.
6783 @sp 1
6784 @cartouche
6785 @noindent
6786 @strong{44}.  Any restrictions placed upon representation items.  See
6787 13.1(20).
6788 @end cartouche
6789 @noindent
6790 See separate section on data representations.
6792 @sp 1
6793 @cartouche
6794 @noindent
6795 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6796 13.3(48).
6797 @end cartouche
6798 @noindent
6799 Size for an indefinite subtype is the maximum possible size, except that
6800 for the case of a subprogram parameter, the size of the parameter object
6801 is the actual size.
6803 @sp 1
6804 @cartouche
6805 @noindent
6806 @strong{46}.  The default external representation for a type tag.  See
6807 13.3(75).
6808 @end cartouche
6809 @noindent
6810 The default external representation for a type tag is the fully expanded
6811 name of the type in upper case letters.
6813 @sp 1
6814 @cartouche
6815 @noindent
6816 @strong{47}.  What determines whether a compilation unit is the same in
6817 two different partitions.  See 13.3(76).
6818 @end cartouche
6819 @noindent
6820 A compilation unit is the same in two different partitions if and only
6821 if it derives from the same source file.
6823 @sp 1
6824 @cartouche
6825 @noindent
6826 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6827 @end cartouche
6828 @noindent
6829 The only implementation defined component is the tag for a tagged type,
6830 which contains a pointer to the dispatching table.
6832 @sp 1
6833 @cartouche
6834 @noindent
6835 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6836 ordering.  See 13.5.3(5).
6837 @end cartouche
6838 @noindent
6839 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6840 implementation, so no non-default bit ordering is supported.  The default
6841 bit ordering corresponds to the natural endianness of the target architecture.
6843 @sp 1
6844 @cartouche
6845 @noindent
6846 @strong{50}.  The contents of the visible part of package @code{System}
6847 and its language-defined children.  See 13.7(2).
6848 @end cartouche
6849 @noindent
6850 See the definition of these packages in files @file{system.ads} and
6851 @file{s-stoele.ads}.
6853 @sp 1
6854 @cartouche
6855 @noindent
6856 @strong{51}.  The contents of the visible part of package
6857 @code{System.Machine_Code}, and the meaning of
6858 @code{code_statements}.  See 13.8(7).
6859 @end cartouche
6860 @noindent
6861 See the definition and documentation in file @file{s-maccod.ads}.
6863 @sp 1
6864 @cartouche
6865 @noindent
6866 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6867 @end cartouche
6868 @noindent
6869 Unchecked conversion between types of the same size
6870 and results in an uninterpreted transmission of the bits from one type
6871 to the other.  If the types are of unequal sizes, then in the case of
6872 discrete types, a shorter source is first zero or sign extended as
6873 necessary, and a shorter target is simply truncated on the left.
6874 For all non-discrete types, the source is first copied if necessary
6875 to ensure that the alignment requirements of the target are met, then
6876 a pointer is constructed to the source value, and the result is obtained
6877 by dereferencing this pointer after converting it to be a pointer to the
6878 target type.
6880 @sp 1
6881 @cartouche
6882 @noindent
6883 @strong{53}.  The manner of choosing a storage pool for an access type
6884 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6885 @end cartouche
6886 @noindent
6887 There are 3 different standard pools used by the compiler when
6888 @code{Storage_Pool} is not specified depending whether the type is local
6889 to a subprogram or defined at the library level and whether
6890 @code{Storage_Size}is specified or not.  See documentation in the runtime
6891 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6892 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6893 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6894 default pools used.
6896 @sp 1
6897 @cartouche
6898 @noindent
6899 @strong{54}.  Whether or not the implementation provides user-accessible
6900 names for the standard pool type(s).  See 13.11(17).
6901 @end cartouche
6902 @noindent
6904 See documentation in the sources of the run time mentioned in paragraph
6905 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6906 these units.
6908 @sp 1
6909 @cartouche
6910 @noindent
6911 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6912 @end cartouche
6913 @noindent
6914 @code{Storage_Size} is measured in storage units, and refers to the
6915 total space available for an access type collection, or to the primary
6916 stack space for a task.
6918 @sp 1
6919 @cartouche
6920 @noindent
6921 @strong{56}.  Implementation-defined aspects of storage pools.  See
6922 13.11(22).
6923 @end cartouche
6924 @noindent
6925 See documentation in the sources of the run time mentioned in paragraph
6926 @strong{53} for details on GNAT-defined aspects of storage pools.
6928 @sp 1
6929 @cartouche
6930 @noindent
6931 @strong{57}.  The set of restrictions allowed in a pragma
6932 @code{Restrictions}.  See 13.12(7).
6933 @end cartouche
6934 @noindent
6935 All RM defined Restriction identifiers are implemented.  The following
6936 additional restriction identifiers are provided.  There are two separate
6937 lists of implementation dependent restriction identifiers.  The first
6938 set requires consistency throughout a partition (in other words, if the
6939 restriction identifier is used for any compilation unit in the partition,
6940 then all compilation units in the partition must obey the restriction.
6942 @table @code
6944 @item Simple_Barriers
6945 @findex Simple_Barriers
6946 This restriction ensures at compile time that barriers in entry declarations
6947 for protected types are restricted to either static boolean expressions or
6948 references to simple boolean variables defined in the private part of the
6949 protected type.  No other form of entry barriers is permitted.  This is one
6950 of the restrictions of the Ravenscar profile for limited tasking (see also
6951 pragma @code{Profile (Ravenscar)}).
6953 @item Max_Entry_Queue_Length => Expr
6954 @findex Max_Entry_Queue_Length
6955 This restriction is a declaration that any protected entry compiled in
6956 the scope of the restriction has at most the specified number of
6957 tasks waiting on the entry
6958 at any one time, and so no queue is required.  This restriction is not
6959 checked at compile time.  A program execution is erroneous if an attempt
6960 is made to queue more than the specified number of tasks on such an entry.
6962 @item No_Calendar
6963 @findex No_Calendar
6964 This restriction ensures at compile time that there is no implicit or
6965 explicit dependence on the package @code{Ada.Calendar}.
6967 @item No_Direct_Boolean_Operators
6968 @findex No_Direct_Boolean_Operators
6969 This restriction ensures that no logical (and/or/xor) or comparison
6970 operators are used on operands of type Boolean (or any type derived
6971 from Boolean). This is intended for use in safety critical programs
6972 where the certification protocol requires the use of short-circuit
6973 (and then, or else) forms for all composite boolean operations.
6975 @item No_Dynamic_Attachment
6976 @findex No_Dynamic_Attachment
6977 This restriction ensures that there is no call to any of the operations
6978 defined in package Ada.Interrupts.
6980 @item No_Enumeration_Maps
6981 @findex No_Enumeration_Maps
6982 This restriction ensures at compile time that no operations requiring
6983 enumeration maps are used (that is Image and Value attributes applied
6984 to enumeration types).
6986 @item No_Entry_Calls_In_Elaboration_Code
6987 @findex No_Entry_Calls_In_Elaboration_Code
6988 This restriction ensures at compile time that no task or protected entry
6989 calls are made during elaboration code.  As a result of the use of this
6990 restriction, the compiler can assume that no code past an accept statement
6991 in a task can be executed at elaboration time.
6993 @item No_Exception_Handlers
6994 @findex No_Exception_Handlers
6995 This restriction ensures at compile time that there are no explicit
6996 exception handlers. It also indicates that no exception propagation will
6997 be provided. In this mode, exceptions may be raised but will result in
6998 an immediate call to the last chance handler, a routine that the user
6999 must define with the following profile:
7001    procedure Last_Chance_Handler
7002      (Source_Location : System.Address; Line : Integer);
7003    pragma Export (C, Last_Chance_Handler,
7004                   "__gnat_last_chance_handler");
7006    The parameter is a C null-terminated string representing a message to be
7007    associated with the exception (typically the source location of the raise
7008    statement generated by the compiler). The Line parameter when non-zero
7009    represents the line number in the source program where the raise occurs.
7011 @item No_Exception_Streams
7012 @findex No_Exception_Streams
7013 This restriction ensures at compile time that no stream operations for
7014 types Exception_Id or Exception_Occurrence are used. This also makes it
7015 impossible to pass exceptions to or from a partition with this restriction
7016 in a distributed environment. If this exception is active, then the generated
7017 code is simplified by omitting the otherwise-required global registration
7018 of exceptions when they are declared.
7020 @item No_Implicit_Conditionals
7021 @findex No_Implicit_Conditionals
7022 This restriction ensures that the generated code does not contain any
7023 implicit conditionals, either by modifying the generated code where possible,
7024 or by rejecting any construct that would otherwise generate an implicit
7025 conditional. Note that this check does not include run time constraint
7026 checks, which on some targets may generate implicit conditionals as
7027 well. To control the latter, constraint checks can be suppressed in the
7028 normal manner.
7030 @item No_Implicit_Dynamic_Code
7031 @findex No_Implicit_Dynamic_Code
7032 This restriction prevents the compiler from building ``trampolines''.
7033 This is a structure that is built on the stack and contains dynamic
7034 code to be executed at run time. A trampoline is needed to indirectly
7035 address a nested subprogram (that is a subprogram that is not at the
7036 library level). The restriction prevents the use of any of the
7037 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7038 being applied to a subprogram that is not at the library level.
7040 @item No_Implicit_Loops
7041 @findex No_Implicit_Loops
7042 This restriction ensures that the generated code does not contain any
7043 implicit @code{for} loops, either by modifying
7044 the generated code where possible,
7045 or by rejecting any construct that would otherwise generate an implicit
7046 @code{for} loop.
7048 @item No_Initialize_Scalars
7049 @findex No_Initialize_Scalars
7050 This restriction ensures that no unit in the partition is compiled with
7051 pragma Initialize_Scalars. This allows the generation of more efficient
7052 code, and in particular eliminates dummy null initialization routines that
7053 are otherwise generated for some record and array types.
7055 @item No_Local_Protected_Objects
7056 @findex No_Local_Protected_Objects
7057 This restriction ensures at compile time that protected objects are
7058 only declared at the library level.
7060 @item No_Protected_Type_Allocators
7061 @findex No_Protected_Type_Allocators
7062 This restriction ensures at compile time that there are no allocator
7063 expressions that attempt to allocate protected objects.
7065 @item No_Secondary_Stack
7066 @findex No_Secondary_Stack
7067 This restriction ensures at compile time that the generated code does not
7068 contain any reference to the secondary stack.  The secondary stack is used
7069 to implement functions returning unconstrained objects (arrays or records)
7070 on some targets.
7072 @item No_Select_Statements
7073 @findex No_Select_Statements
7074 This restriction ensures at compile time no select statements of any kind
7075 are permitted, that is the keyword @code{select} may not appear.
7076 This is one of the restrictions of the Ravenscar
7077 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7079 @item No_Standard_Storage_Pools
7080 @findex No_Standard_Storage_Pools
7081 This restriction ensures at compile time that no access types
7082 use the standard default storage pool.  Any access type declared must
7083 have an explicit Storage_Pool attribute defined specifying a
7084 user-defined storage pool.
7086 @item No_Streams
7087 @findex No_Streams
7088 This restriction ensures at compile time that there are no implicit or
7089 explicit dependencies on the package @code{Ada.Streams}.
7091 @item No_Task_Attributes_Package
7092 @findex No_Task_Attributes_Package
7093 This restriction ensures at compile time that there are no implicit or
7094 explicit dependencies on the package @code{Ada.Task_Attributes}.
7096 @item No_Task_Termination
7097 @findex No_Task_Termination
7098 This restriction ensures at compile time that no terminate alternatives
7099 appear in any task body.
7101 @item No_Tasking
7102 @findex No_Tasking
7103 This restriction prevents the declaration of tasks or task types throughout
7104 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7105 except that violations are caught at compile time and cause an error message
7106 to be output either by the compiler or binder.
7108 @item No_Wide_Characters
7109 @findex No_Wide_Characters
7110 This restriction ensures at compile time that no uses of the types
7111 @code{Wide_Character} or @code{Wide_String}
7112 appear, and that no wide character literals
7113 appear in the program (that is literals representing characters not in
7114 type @code{Character}.
7116 @item Static_Priorities
7117 @findex Static_Priorities
7118 This restriction ensures at compile time that all priority expressions
7119 are static, and that there are no dependencies on the package
7120 @code{Ada.Dynamic_Priorities}.
7122 @item Static_Storage_Size
7123 @findex Static_Storage_Size
7124 This restriction ensures at compile time that any expression appearing
7125 in a Storage_Size pragma or attribute definition clause is static.
7127 @end table
7129 @noindent
7130 The second set of implementation dependent restriction identifiers
7131 does not require partition-wide consistency.
7132 The restriction may be enforced for a single
7133 compilation unit without any effect on any of the
7134 other compilation units in the partition.
7136 @table @code
7138 @item No_Elaboration_Code
7139 @findex No_Elaboration_Code
7140 This restriction ensures at compile time that no elaboration code is
7141 generated.  Note that this is not the same condition as is enforced
7142 by pragma @code{Preelaborate}.  There are cases in which pragma
7143 @code{Preelaborate} still permits code to be generated (e.g.@: code
7144 to initialize a large array to all zeroes), and there are cases of units
7145 which do not meet the requirements for pragma @code{Preelaborate},
7146 but for which no elaboration code is generated.  Generally, it is
7147 the case that preelaborable units will meet the restrictions, with
7148 the exception of large aggregates initialized with an others_clause,
7149 and exception declarations (which generate calls to a run-time
7150 registry procedure).  Note that this restriction is enforced on
7151 a unit by unit basis, it need not be obeyed consistently
7152 throughout a partition.
7154 @item No_Entry_Queue
7155 @findex No_Entry_Queue
7156 This restriction is a declaration that any protected entry compiled in
7157 the scope of the restriction has at most one task waiting on the entry
7158 at any one time, and so no queue is required.  This restriction is not
7159 checked at compile time.  A program execution is erroneous if an attempt
7160 is made to queue a second task on such an entry.
7162 @item No_Implementation_Attributes
7163 @findex No_Implementation_Attributes
7164 This restriction checks at compile time that no GNAT-defined attributes
7165 are present.  With this restriction, the only attributes that can be used
7166 are those defined in the Ada 95 Reference Manual.
7168 @item No_Implementation_Pragmas
7169 @findex No_Implementation_Pragmas
7170 This restriction checks at compile time that no GNAT-defined pragmas
7171 are present.  With this restriction, the only pragmas that can be used
7172 are those defined in the Ada 95 Reference Manual.
7174 @item No_Implementation_Restrictions
7175 @findex No_Implementation_Restrictions
7176 This restriction checks at compile time that no GNAT-defined restriction
7177 identifiers (other than @code{No_Implementation_Restrictions} itself)
7178 are present.  With this restriction, the only other restriction identifiers
7179 that can be used are those defined in the Ada 95 Reference Manual.
7181 @end table
7183 @sp 1
7184 @cartouche
7185 @noindent
7186 @strong{58}.  The consequences of violating limitations on
7187 @code{Restrictions} pragmas.  See 13.12(9).
7188 @end cartouche
7189 @noindent
7190 Restrictions that can be checked at compile time result in illegalities
7191 if violated.  Currently there are no other consequences of violating
7192 restrictions.
7194 @sp 1
7195 @cartouche
7196 @noindent
7197 @strong{59}.  The representation used by the @code{Read} and
7198 @code{Write} attributes of elementary types in terms of stream
7199 elements.  See 13.13.2(9).
7200 @end cartouche
7201 @noindent
7202 The representation is the in-memory representation of the base type of
7203 the type, using the number of bits corresponding to the
7204 @code{@var{type}'Size} value, and the natural ordering of the machine.
7206 @sp 1
7207 @cartouche
7208 @noindent
7209 @strong{60}.  The names and characteristics of the numeric subtypes
7210 declared in the visible part of package @code{Standard}.  See A.1(3).
7211 @end cartouche
7212 @noindent
7213 See items describing the integer and floating-point types supported.
7215 @sp 1
7216 @cartouche
7217 @noindent
7218 @strong{61}.  The accuracy actually achieved by the elementary
7219 functions.  See A.5.1(1).
7220 @end cartouche
7221 @noindent
7222 The elementary functions correspond to the functions available in the C
7223 library.  Only fast math mode is implemented.
7225 @sp 1
7226 @cartouche
7227 @noindent
7228 @strong{62}.  The sign of a zero result from some of the operators or
7229 functions in @code{Numerics.Generic_Elementary_Functions}, when
7230 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7231 @end cartouche
7232 @noindent
7233 The sign of zeroes follows the requirements of the IEEE 754 standard on
7234 floating-point.
7236 @sp 1
7237 @cartouche
7238 @noindent
7239 @strong{63}.  The value of
7240 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7241 @end cartouche
7242 @noindent
7243 Maximum image width is 649, see library file @file{a-numran.ads}.
7245 @sp 1
7246 @cartouche
7247 @noindent
7248 @strong{64}.  The value of
7249 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7250 @end cartouche
7251 @noindent
7252 Maximum image width is 80, see library file @file{a-nudira.ads}.
7254 @sp 1
7255 @cartouche
7256 @noindent
7257 @strong{65}.  The algorithms for random number generation.  See
7258 A.5.2(32).
7259 @end cartouche
7260 @noindent
7261 The algorithm is documented in the source files @file{a-numran.ads} and
7262 @file{a-numran.adb}.
7264 @sp 1
7265 @cartouche
7266 @noindent
7267 @strong{66}.  The string representation of a random number generator's
7268 state.  See A.5.2(38).
7269 @end cartouche
7270 @noindent
7271 See the documentation contained in the file @file{a-numran.adb}.
7273 @sp 1
7274 @cartouche
7275 @noindent
7276 @strong{67}.  The minimum time interval between calls to the
7277 time-dependent Reset procedure that are guaranteed to initiate different
7278 random number sequences.  See A.5.2(45).
7279 @end cartouche
7280 @noindent
7281 The minimum period between reset calls to guarantee distinct series of
7282 random numbers is one microsecond.
7284 @sp 1
7285 @cartouche
7286 @noindent
7287 @strong{68}.  The values of the @code{Model_Mantissa},
7288 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7289 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7290 Annex is not supported.  See A.5.3(72).
7291 @end cartouche
7292 @noindent
7293 See the source file @file{ttypef.ads} for the values of all numeric
7294 attributes.
7296 @sp 1
7297 @cartouche
7298 @noindent
7299 @strong{69}.  Any implementation-defined characteristics of the
7300 input-output packages.  See A.7(14).
7301 @end cartouche
7302 @noindent
7303 There are no special implementation defined characteristics for these
7304 packages.
7306 @sp 1
7307 @cartouche
7308 @noindent
7309 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7310 A.9(10).
7311 @end cartouche
7312 @noindent
7313 All type representations are contiguous, and the @code{Buffer_Size} is
7314 the value of @code{@var{type}'Size} rounded up to the next storage unit
7315 boundary.
7317 @sp 1
7318 @cartouche
7319 @noindent
7320 @strong{71}.  External files for standard input, standard output, and
7321 standard error See A.10(5).
7322 @end cartouche
7323 @noindent
7324 These files are mapped onto the files provided by the C streams
7325 libraries.  See source file @file{i-cstrea.ads} for further details.
7327 @sp 1
7328 @cartouche
7329 @noindent
7330 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7331 A.10.9(36).
7332 @end cartouche
7333 @noindent
7334 If more digits are requested in the output than are represented by the
7335 precision of the value, zeroes are output in the corresponding least
7336 significant digit positions.
7338 @sp 1
7339 @cartouche
7340 @noindent
7341 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7342 @code{Command_Name}.  See A.15(1).
7343 @end cartouche
7344 @noindent
7345 These are mapped onto the @code{argv} and @code{argc} parameters of the
7346 main program in the natural manner.
7348 @sp 1
7349 @cartouche
7350 @noindent
7351 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7352 @end cartouche
7353 @noindent
7354 The following convention names are supported
7356 @table @code
7357 @item  Ada
7359 @item Assembler
7360 Assembly language
7361 @item Asm
7362 Synonym for Assembler
7363 @item Assembly
7364 Synonym for Assembler
7365 @item C
7367 @item C_Pass_By_Copy
7368 Allowed only for record types, like C, but also notes that record
7369 is to be passed by copy rather than reference.
7370 @item COBOL
7371 COBOL
7372 @item CPP
7374 @item Default
7375 Treated the same as C
7376 @item External
7377 Treated the same as C
7378 @item Fortran
7379 Fortran
7380 @item Intrinsic
7381 For support of pragma @code{Import} with convention Intrinsic, see
7382 separate section on Intrinsic Subprograms.
7383 @item Stdcall
7384 Stdcall (used for Windows implementations only).  This convention correspond
7385 to the WINAPI (previously called Pascal convention) C/C++ convention under
7386 Windows.  A function with this convention cleans the stack before exit.
7387 @item DLL
7388 Synonym for Stdcall
7389 @item Win32
7390 Synonym for Stdcall
7391 @item Stubbed
7392 Stubbed is a special convention used to indicate that the body of the
7393 subprogram will be entirely ignored.  Any call to the subprogram
7394 is converted into a raise of the @code{Program_Error} exception.  If a
7395 pragma @code{Import} specifies convention @code{stubbed} then no body need
7396 be present at all.  This convention is useful during development for the
7397 inclusion of subprograms whose body has not yet been written.
7399 @end table
7400 @noindent
7401 In addition, all otherwise unrecognized convention names are also
7402 treated as being synonymous with convention C@.  In all implementations
7403 except for VMS, use of such other names results in a warning.  In VMS
7404 implementations, these names are accepted silently.
7406 @sp 1
7407 @cartouche
7408 @noindent
7409 @strong{75}.  The meaning of link names.  See B.1(36).
7410 @end cartouche
7411 @noindent
7412 Link names are the actual names used by the linker.
7414 @sp 1
7415 @cartouche
7416 @noindent
7417 @strong{76}.  The manner of choosing link names when neither the link
7418 name nor the address of an imported or exported entity is specified.  See
7419 B.1(36).
7420 @end cartouche
7421 @noindent
7422 The default linker name is that which would be assigned by the relevant
7423 external language, interpreting the Ada name as being in all lower case
7424 letters.
7426 @sp 1
7427 @cartouche
7428 @noindent
7429 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7430 @end cartouche
7431 @noindent
7432 The string passed to @code{Linker_Options} is presented uninterpreted as
7433 an argument to the link command, unless it contains Ascii.NUL characters.
7434 NUL characters if they appear act as argument separators, so for example
7436 @smallexample @c ada
7437 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7438 @end smallexample
7440 @noindent
7441 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7442 linker. The order of linker options is preserved for a given unit. The final
7443 list of options passed to the linker is in reverse order of the elaboration
7444 order. For example, linker options fo a body always appear before the options
7445 from the corresponding package spec.
7447 @sp 1
7448 @cartouche
7449 @noindent
7450 @strong{78}.  The contents of the visible part of package
7451 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7452 @end cartouche
7453 @noindent
7454 See files with prefix @file{i-} in the distributed library.
7456 @sp 1
7457 @cartouche
7458 @noindent
7459 @strong{79}.  Implementation-defined children of package
7460 @code{Interfaces}.  The contents of the visible part of package
7461 @code{Interfaces}.  See B.2(11).
7462 @end cartouche
7463 @noindent
7464 See files with prefix @file{i-} in the distributed library.
7466 @sp 1
7467 @cartouche
7468 @noindent
7469 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7470 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7471 @code{COBOL_Character}; and the initialization of the variables
7472 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7473 @code{Interfaces.COBOL}.  See B.4(50).
7474 @end cartouche
7475 @noindent
7476 @table @code
7477 @item Floating
7478 Float
7479 @item Long_Floating
7480 (Floating) Long_Float
7481 @item Binary
7482 Integer
7483 @item Long_Binary
7484 Long_Long_Integer
7485 @item Decimal_Element
7486 Character
7487 @item COBOL_Character
7488 Character
7489 @end table
7491 @noindent
7492 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7494 @sp 1
7495 @cartouche
7496 @noindent
7497 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7498 @end cartouche
7499 @noindent
7500 See documentation in file @file{s-maccod.ads} in the distributed library.
7502 @sp 1
7503 @cartouche
7504 @noindent
7505 @strong{82}.  Implementation-defined aspects of access to machine
7506 operations.  See C.1(9).
7507 @end cartouche
7508 @noindent
7509 See documentation in file @file{s-maccod.ads} in the distributed library.
7511 @sp 1
7512 @cartouche
7513 @noindent
7514 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7515 @end cartouche
7516 @noindent
7517 Interrupts are mapped to signals or conditions as appropriate.  See
7518 definition of unit
7519 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7520 on the interrupts supported on a particular target.
7522 @sp 1
7523 @cartouche
7524 @noindent
7525 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7526 C.4(13).
7527 @end cartouche
7528 @noindent
7529 GNAT does not permit a partition to be restarted without reloading,
7530 except under control of the debugger.
7532 @sp 1
7533 @cartouche
7534 @noindent
7535 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7536 @end cartouche
7537 @noindent
7538 Pragma @code{Discard_Names} causes names of enumeration literals to
7539 be suppressed.  In the presence of this pragma, the Image attribute
7540 provides the image of the Pos of the literal, and Value accepts
7541 Pos values.
7543 @sp 1
7544 @cartouche
7545 @noindent
7546 @strong{86}.  The result of the @code{Task_Identification.Image}
7547 attribute.  See C.7.1(7).
7548 @end cartouche
7549 @noindent
7550 The result of this attribute is an 8-digit hexadecimal string
7551 representing the virtual address of the task control block.
7553 @sp 1
7554 @cartouche
7555 @noindent
7556 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7557 or interrupt handler.  See C.7.1(17).
7558 @end cartouche
7559 @noindent
7560 Protected entries or interrupt handlers can be executed by any
7561 convenient thread, so the value of @code{Current_Task} is undefined.
7563 @sp 1
7564 @cartouche
7565 @noindent
7566 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7567 body or interrupt handler.  See C.7.1(19).
7568 @end cartouche
7569 @noindent
7570 The effect of calling @code{Current_Task} from an entry body or
7571 interrupt handler is to return the identification of the task currently
7572 executing the code.
7574 @sp 1
7575 @cartouche
7576 @noindent
7577 @strong{89}.  Implementation-defined aspects of
7578 @code{Task_Attributes}.  See C.7.2(19).
7579 @end cartouche
7580 @noindent
7581 There are no implementation-defined aspects of @code{Task_Attributes}.
7583 @sp 1
7584 @cartouche
7585 @noindent
7586 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7587 @end cartouche
7588 @noindent
7589 The metrics information for GNAT depends on the performance of the
7590 underlying operating system.  The sources of the run-time for tasking
7591 implementation, together with the output from @code{-gnatG} can be
7592 used to determine the exact sequence of operating systems calls made
7593 to implement various tasking constructs.  Together with appropriate
7594 information on the performance of the underlying operating system,
7595 on the exact target in use, this information can be used to determine
7596 the required metrics.
7598 @sp 1
7599 @cartouche
7600 @noindent
7601 @strong{91}.  The declarations of @code{Any_Priority} and
7602 @code{Priority}.  See D.1(11).
7603 @end cartouche
7604 @noindent
7605 See declarations in file @file{system.ads}.
7607 @sp 1
7608 @cartouche
7609 @noindent
7610 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7611 @end cartouche
7612 @noindent
7613 There are no implementation-defined execution resources.
7615 @sp 1
7616 @cartouche
7617 @noindent
7618 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7619 access to a protected object keeps its processor busy.  See D.2.1(3).
7620 @end cartouche
7621 @noindent
7622 On a multi-processor, a task that is waiting for access to a protected
7623 object does not keep its processor busy.
7625 @sp 1
7626 @cartouche
7627 @noindent
7628 @strong{94}.  The affect of implementation defined execution resources
7629 on task dispatching.  See D.2.1(9).
7630 @end cartouche
7631 @noindent
7632 @c SGI info
7633 @ignore
7634 Tasks map to IRIX threads, and the dispatching policy is as defined by
7635 the IRIX implementation of threads.
7636 @end ignore
7637 Tasks map to threads in the threads package used by GNAT@.  Where possible
7638 and appropriate, these threads correspond to native threads of the
7639 underlying operating system.
7641 @sp 1
7642 @cartouche
7643 @noindent
7644 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7645 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7646 @end cartouche
7647 @noindent
7648 There are no implementation-defined policy-identifiers allowed in this
7649 pragma.
7651 @sp 1
7652 @cartouche
7653 @noindent
7654 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7655 D.2.2(16).
7656 @end cartouche
7657 @noindent
7658 Execution of a task cannot be preempted by the implementation processing
7659 of delay expirations for lower priority tasks.
7661 @sp 1
7662 @cartouche
7663 @noindent
7664 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7665 @end cartouche
7666 @noindent
7667 @c SGI info:
7668 @ignore
7669 Tasks map to IRIX threads, and the dispatching policy is as defied by
7670 the IRIX implementation of threads.
7671 @end ignore
7672 The policy is the same as that of the underlying threads implementation.
7674 @sp 1
7675 @cartouche
7676 @noindent
7677 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7678 in a pragma @code{Locking_Policy}.  See D.3(4).
7679 @end cartouche
7680 @noindent
7681 The only implementation defined policy permitted in GNAT is
7682 @code{Inheritance_Locking}.  On targets that support this policy, locking
7683 is implemented by inheritance, i.e.@: the task owning the lock operates
7684 at a priority equal to the highest priority of any task currently
7685 requesting the lock.
7687 @sp 1
7688 @cartouche
7689 @noindent
7690 @strong{99}.  Default ceiling priorities.  See D.3(10).
7691 @end cartouche
7692 @noindent
7693 The ceiling priority of protected objects of the type
7694 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7695 Reference Manual D.3(10),
7697 @sp 1
7698 @cartouche
7699 @noindent
7700 @strong{100}.  The ceiling of any protected object used internally by
7701 the implementation.  See D.3(16).
7702 @end cartouche
7703 @noindent
7704 The ceiling priority of internal protected objects is
7705 @code{System.Priority'Last}.
7707 @sp 1
7708 @cartouche
7709 @noindent
7710 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7711 @end cartouche
7712 @noindent
7713 There are no implementation-defined queueing policies.
7715 @sp 1
7716 @cartouche
7717 @noindent
7718 @strong{102}.  On a multiprocessor, any conditions that cause the
7719 completion of an aborted construct to be delayed later than what is
7720 specified for a single processor.  See D.6(3).
7721 @end cartouche
7722 @noindent
7723 The semantics for abort on a multi-processor is the same as on a single
7724 processor, there are no further delays.
7726 @sp 1
7727 @cartouche
7728 @noindent
7729 @strong{103}.  Any operations that implicitly require heap storage
7730 allocation.  See D.7(8).
7731 @end cartouche
7732 @noindent
7733 The only operation that implicitly requires heap storage allocation is
7734 task creation.
7736 @sp 1
7737 @cartouche
7738 @noindent
7739 @strong{104}.  Implementation-defined aspects of pragma
7740 @code{Restrictions}.  See D.7(20).
7741 @end cartouche
7742 @noindent
7743 There are no such implementation-defined aspects.
7745 @sp 1
7746 @cartouche
7747 @noindent
7748 @strong{105}.  Implementation-defined aspects of package
7749 @code{Real_Time}.  See D.8(17).
7750 @end cartouche
7751 @noindent
7752 There are no implementation defined aspects of package @code{Real_Time}.
7754 @sp 1
7755 @cartouche
7756 @noindent
7757 @strong{106}.  Implementation-defined aspects of
7758 @code{delay_statements}.  See D.9(8).
7759 @end cartouche
7760 @noindent
7761 Any difference greater than one microsecond will cause the task to be
7762 delayed (see D.9(7)).
7764 @sp 1
7765 @cartouche
7766 @noindent
7767 @strong{107}.  The upper bound on the duration of interrupt blocking
7768 caused by the implementation.  See D.12(5).
7769 @end cartouche
7770 @noindent
7771 The upper bound is determined by the underlying operating system.  In
7772 no cases is it more than 10 milliseconds.
7774 @sp 1
7775 @cartouche
7776 @noindent
7777 @strong{108}.  The means for creating and executing distributed
7778 programs.  See E(5).
7779 @end cartouche
7780 @noindent
7781 The GLADE package provides a utility GNATDIST for creating and executing
7782 distributed programs.  See the GLADE reference manual for further details.
7784 @sp 1
7785 @cartouche
7786 @noindent
7787 @strong{109}.  Any events that can result in a partition becoming
7788 inaccessible.  See E.1(7).
7789 @end cartouche
7790 @noindent
7791 See the GLADE reference manual for full details on such events.
7793 @sp 1
7794 @cartouche
7795 @noindent
7796 @strong{110}.  The scheduling policies, treatment of priorities, and
7797 management of shared resources between partitions in certain cases.  See
7798 E.1(11).
7799 @end cartouche
7800 @noindent
7801 See the GLADE reference manual for full details on these aspects of
7802 multi-partition execution.
7804 @sp 1
7805 @cartouche
7806 @noindent
7807 @strong{111}.  Events that cause the version of a compilation unit to
7808 change.  See E.3(5).
7809 @end cartouche
7810 @noindent
7811 Editing the source file of a compilation unit, or the source files of
7812 any units on which it is dependent in a significant way cause the version
7813 to change.  No other actions cause the version number to change.  All changes
7814 are significant except those which affect only layout, capitalization or
7815 comments.
7817 @sp 1
7818 @cartouche
7819 @noindent
7820 @strong{112}.  Whether the execution of the remote subprogram is
7821 immediately aborted as a result of cancellation.  See E.4(13).
7822 @end cartouche
7823 @noindent
7824 See the GLADE reference manual for details on the effect of abort in
7825 a distributed application.
7827 @sp 1
7828 @cartouche
7829 @noindent
7830 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7831 @end cartouche
7832 @noindent
7833 See the GLADE reference manual for a full description of all implementation
7834 defined aspects of the PCS@.
7836 @sp 1
7837 @cartouche
7838 @noindent
7839 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7840 E.5(26).
7841 @end cartouche
7842 @noindent
7843 See the GLADE reference manual for a full description of all
7844 implementation defined interfaces.
7846 @sp 1
7847 @cartouche
7848 @noindent
7849 @strong{115}.  The values of named numbers in the package
7850 @code{Decimal}.  See F.2(7).
7851 @end cartouche
7852 @noindent
7853 @table @code
7854 @item Max_Scale
7856 @item Min_Scale
7858 @item Min_Delta
7859 1.0E-18
7860 @item Max_Delta
7861 1.0E+18
7862 @item Max_Decimal_Digits
7864 @end table
7866 @sp 1
7867 @cartouche
7868 @noindent
7869 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7870 @code{Text_IO.Editing}.  See F.3.3(16).
7871 @end cartouche
7872 @noindent
7875 @sp 1
7876 @cartouche
7877 @noindent
7878 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7879 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7880 @end cartouche
7881 @noindent
7884 @sp 1
7885 @cartouche
7886 @noindent
7887 @strong{118}.  The accuracy actually achieved by the complex elementary
7888 functions and by other complex arithmetic operations.  See G.1(1).
7889 @end cartouche
7890 @noindent
7891 Standard library functions are used for the complex arithmetic
7892 operations.  Only fast math mode is currently supported.
7894 @sp 1
7895 @cartouche
7896 @noindent
7897 @strong{119}.  The sign of a zero result (or a component thereof) from
7898 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7899 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7900 @end cartouche
7901 @noindent
7902 The signs of zero values are as recommended by the relevant
7903 implementation advice.
7905 @sp 1
7906 @cartouche
7907 @noindent
7908 @strong{120}.  The sign of a zero result (or a component thereof) from
7909 any operator or function in
7910 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7911 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7912 @end cartouche
7913 @noindent
7914 The signs of zero values are as recommended by the relevant
7915 implementation advice.
7917 @sp 1
7918 @cartouche
7919 @noindent
7920 @strong{121}.  Whether the strict mode or the relaxed mode is the
7921 default.  See G.2(2).
7922 @end cartouche
7923 @noindent
7924 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7925 provides a highly efficient implementation of strict mode.
7927 @sp 1
7928 @cartouche
7929 @noindent
7930 @strong{122}.  The result interval in certain cases of fixed-to-float
7931 conversion.  See G.2.1(10).
7932 @end cartouche
7933 @noindent
7934 For cases where the result interval is implementation dependent, the
7935 accuracy is that provided by performing all operations in 64-bit IEEE
7936 floating-point format.
7938 @sp 1
7939 @cartouche
7940 @noindent
7941 @strong{123}.  The result of a floating point arithmetic operation in
7942 overflow situations, when the @code{Machine_Overflows} attribute of the
7943 result type is @code{False}.  See G.2.1(13).
7944 @end cartouche
7945 @noindent
7946 Infinite and Nan values are produced as dictated by the IEEE
7947 floating-point standard.
7949 @sp 1
7950 @cartouche
7951 @noindent
7952 @strong{124}.  The result interval for division (or exponentiation by a
7953 negative exponent), when the floating point hardware implements division
7954 as multiplication by a reciprocal.  See G.2.1(16).
7955 @end cartouche
7956 @noindent
7957 Not relevant, division is IEEE exact.
7959 @sp 1
7960 @cartouche
7961 @noindent
7962 @strong{125}.  The definition of close result set, which determines the
7963 accuracy of certain fixed point multiplications and divisions.  See
7964 G.2.3(5).
7965 @end cartouche
7966 @noindent
7967 Operations in the close result set are performed using IEEE long format
7968 floating-point arithmetic.  The input operands are converted to
7969 floating-point, the operation is done in floating-point, and the result
7970 is converted to the target type.
7972 @sp 1
7973 @cartouche
7974 @noindent
7975 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7976 point multiplication or division for which the result shall be in the
7977 perfect result set.  See G.2.3(22).
7978 @end cartouche
7979 @noindent
7980 The result is only defined to be in the perfect result set if the result
7981 can be computed by a single scaling operation involving a scale factor
7982 representable in 64-bits.
7984 @sp 1
7985 @cartouche
7986 @noindent
7987 @strong{127}.  The result of a fixed point arithmetic operation in
7988 overflow situations, when the @code{Machine_Overflows} attribute of the
7989 result type is @code{False}.  See G.2.3(27).
7990 @end cartouche
7991 @noindent
7992 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7993 types.
7995 @sp 1
7996 @cartouche
7997 @noindent
7998 @strong{128}.  The result of an elementary function reference in
7999 overflow situations, when the @code{Machine_Overflows} attribute of the
8000 result type is @code{False}.  See G.2.4(4).
8001 @end cartouche
8002 @noindent
8003 IEEE infinite and Nan values are produced as appropriate.
8005 @sp 1
8006 @cartouche
8007 @noindent
8008 @strong{129}.  The value of the angle threshold, within which certain
8009 elementary functions, complex arithmetic operations, and complex
8010 elementary functions yield results conforming to a maximum relative
8011 error bound.  See G.2.4(10).
8012 @end cartouche
8013 @noindent
8014 Information on this subject is not yet available.
8016 @sp 1
8017 @cartouche
8018 @noindent
8019 @strong{130}.  The accuracy of certain elementary functions for
8020 parameters beyond the angle threshold.  See G.2.4(10).
8021 @end cartouche
8022 @noindent
8023 Information on this subject is not yet available.
8025 @sp 1
8026 @cartouche
8027 @noindent
8028 @strong{131}.  The result of a complex arithmetic operation or complex
8029 elementary function reference in overflow situations, when the
8030 @code{Machine_Overflows} attribute of the corresponding real type is
8031 @code{False}.  See G.2.6(5).
8032 @end cartouche
8033 @noindent
8034 IEEE infinite and Nan values are produced as appropriate.
8036 @sp 1
8037 @cartouche
8038 @noindent
8039 @strong{132}.  The accuracy of certain complex arithmetic operations and
8040 certain complex elementary functions for parameters (or components
8041 thereof) beyond the angle threshold.  See G.2.6(8).
8042 @end cartouche
8043 @noindent
8044 Information on those subjects is not yet available.
8046 @sp 1
8047 @cartouche
8048 @noindent
8049 @strong{133}.  Information regarding bounded errors and erroneous
8050 execution.  See H.2(1).
8051 @end cartouche
8052 @noindent
8053 Information on this subject is not yet available.
8055 @sp 1
8056 @cartouche
8057 @noindent
8058 @strong{134}.  Implementation-defined aspects of pragma
8059 @code{Inspection_Point}.  See H.3.2(8).
8060 @end cartouche
8061 @noindent
8062 Pragma @code{Inspection_Point} ensures that the variable is live and can
8063 be examined by the debugger at the inspection point.
8065 @sp 1
8066 @cartouche
8067 @noindent
8068 @strong{135}.  Implementation-defined aspects of pragma
8069 @code{Restrictions}.  See H.4(25).
8070 @end cartouche
8071 @noindent
8072 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8073 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8074 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8076 @sp 1
8077 @cartouche
8078 @noindent
8079 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8080 H.4(27).
8081 @end cartouche
8082 @noindent
8083 There are no restrictions on pragma @code{Restrictions}.
8085 @node Intrinsic Subprograms
8086 @chapter Intrinsic Subprograms
8087 @cindex Intrinsic Subprograms
8089 @menu
8090 * Intrinsic Operators::
8091 * Enclosing_Entity::
8092 * Exception_Information::
8093 * Exception_Message::
8094 * Exception_Name::
8095 * File::
8096 * Line::
8097 * Rotate_Left::
8098 * Rotate_Right::
8099 * Shift_Left::
8100 * Shift_Right::
8101 * Shift_Right_Arithmetic::
8102 * Source_Location::
8103 @end menu
8105 @noindent
8106 GNAT allows a user application program to write the declaration:
8108 @smallexample @c ada
8109    pragma Import (Intrinsic, name);
8110 @end smallexample
8112 @noindent
8113 providing that the name corresponds to one of the implemented intrinsic
8114 subprograms in GNAT, and that the parameter profile of the referenced
8115 subprogram meets the requirements.  This chapter describes the set of
8116 implemented intrinsic subprograms, and the requirements on parameter profiles.
8117 Note that no body is supplied; as with other uses of pragma Import, the
8118 body is supplied elsewhere (in this case by the compiler itself).  Note
8119 that any use of this feature is potentially non-portable, since the
8120 Ada standard does not require Ada compilers to implement this feature.
8122 @node Intrinsic Operators
8123 @section Intrinsic Operators
8124 @cindex Intrinsic operator
8126 @noindent
8127 All the predefined numeric operators in package Standard
8128 in @code{pragma Import (Intrinsic,..)}
8129 declarations.  In the binary operator case, the operands must have the same
8130 size.  The operand or operands must also be appropriate for
8131 the operator.  For example, for addition, the operands must
8132 both be floating-point or both be fixed-point, and the
8133 right operand for @code{"**"} must have a root type of
8134 @code{Standard.Integer'Base}.
8135 You can use an intrinsic operator declaration as in the following example:
8137 @smallexample @c ada
8138    type Int1 is new Integer;
8139    type Int2 is new Integer;
8141    function "+" (X1 : Int1; X2 : Int2) return Int1;
8142    function "+" (X1 : Int1; X2 : Int2) return Int2;
8143    pragma Import (Intrinsic, "+");
8144 @end smallexample
8146 @noindent
8147 This declaration would permit ``mixed mode'' arithmetic on items
8148 of the differing types @code{Int1} and @code{Int2}.
8149 It is also possible to specify such operators for private types, if the
8150 full views are appropriate arithmetic types.
8152 @node Enclosing_Entity
8153 @section Enclosing_Entity
8154 @cindex Enclosing_Entity
8155 @noindent
8156 This intrinsic subprogram is used in the implementation of the
8157 library routine @code{GNAT.Source_Info}.  The only useful use of the
8158 intrinsic import in this case is the one in this unit, so an
8159 application program should simply call the function
8160 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8161 the current subprogram, package, task, entry, or protected subprogram.
8163 @node Exception_Information
8164 @section Exception_Information
8165 @cindex Exception_Information'
8166 @noindent
8167 This intrinsic subprogram is used in the implementation of the
8168 library routine @code{GNAT.Current_Exception}.  The only useful
8169 use of the intrinsic import in this case is the one in this unit,
8170 so an application program should simply call the function
8171 @code{GNAT.Current_Exception.Exception_Information} to obtain
8172 the exception information associated with the current exception.
8174 @node Exception_Message
8175 @section Exception_Message
8176 @cindex Exception_Message
8177 @noindent
8178 This intrinsic subprogram is used in the implementation of the
8179 library routine @code{GNAT.Current_Exception}.  The only useful
8180 use of the intrinsic import in this case is the one in this unit,
8181 so an application program should simply call the function
8182 @code{GNAT.Current_Exception.Exception_Message} to obtain
8183 the message associated with the current exception.
8185 @node Exception_Name
8186 @section Exception_Name
8187 @cindex Exception_Name
8188 @noindent
8189 This intrinsic subprogram is used in the implementation of the
8190 library routine @code{GNAT.Current_Exception}.  The only useful
8191 use of the intrinsic import in this case is the one in this unit,
8192 so an application program should simply call the function
8193 @code{GNAT.Current_Exception.Exception_Name} to obtain
8194 the name of the current exception.
8196 @node File
8197 @section File
8198 @cindex File
8199 @noindent
8200 This intrinsic subprogram is used in the implementation of the
8201 library routine @code{GNAT.Source_Info}.  The only useful use of the
8202 intrinsic import in this case is the one in this unit, so an
8203 application program should simply call the function
8204 @code{GNAT.Source_Info.File} to obtain the name of the current
8205 file.
8207 @node Line
8208 @section Line
8209 @cindex Line
8210 @noindent
8211 This intrinsic subprogram is used in the implementation of the
8212 library routine @code{GNAT.Source_Info}.  The only useful use of the
8213 intrinsic import in this case is the one in this unit, so an
8214 application program should simply call the function
8215 @code{GNAT.Source_Info.Line} to obtain the number of the current
8216 source line.
8218 @node Rotate_Left
8219 @section Rotate_Left
8220 @cindex Rotate_Left
8221 @noindent
8222 In standard Ada 95, the @code{Rotate_Left} function is available only
8223 for the predefined modular types in package @code{Interfaces}.  However, in
8224 GNAT it is possible to define a Rotate_Left function for a user
8225 defined modular type or any signed integer type as in this example:
8227 @smallexample @c ada
8228    function Shift_Left
8229      (Value  : My_Modular_Type;
8230       Amount : Natural)
8231       return   My_Modular_Type;
8232 @end smallexample
8234 @noindent
8235 The requirements are that the profile be exactly as in the example
8236 above.  The only modifications allowed are in the formal parameter
8237 names, and in the type of @code{Value} and the return type, which
8238 must be the same, and must be either a signed integer type, or
8239 a modular integer type with a binary modulus, and the size must
8240 be 8.  16, 32 or 64 bits.
8242 @node Rotate_Right
8243 @section Rotate_Right
8244 @cindex Rotate_Right
8245 @noindent
8246 A @code{Rotate_Right} function can be defined for any user defined
8247 binary modular integer type, or signed integer type, as described
8248 above for @code{Rotate_Left}.
8250 @node Shift_Left
8251 @section Shift_Left
8252 @cindex Shift_Left
8253 @noindent
8254 A @code{Shift_Left} function can be defined for any user defined
8255 binary modular integer type, or signed integer type, as described
8256 above for @code{Rotate_Left}.
8258 @node Shift_Right
8259 @section Shift_Right
8260 @cindex Shift_Right
8261 @noindent
8262 A @code{Shift_Right} function can be defined for any user defined
8263 binary modular integer type, or signed integer type, as described
8264 above for @code{Rotate_Left}.
8266 @node Shift_Right_Arithmetic
8267 @section Shift_Right_Arithmetic
8268 @cindex Shift_Right_Arithmetic
8269 @noindent
8270 A @code{Shift_Right_Arithmetic} function can be defined for any user
8271 defined binary modular integer type, or signed integer type, as described
8272 above for @code{Rotate_Left}.
8274 @node Source_Location
8275 @section Source_Location
8276 @cindex Source_Location
8277 @noindent
8278 This intrinsic subprogram is used in the implementation of the
8279 library routine @code{GNAT.Source_Info}.  The only useful use of the
8280 intrinsic import in this case is the one in this unit, so an
8281 application program should simply call the function
8282 @code{GNAT.Source_Info.Source_Location} to obtain the current
8283 source file location.
8285 @node Representation Clauses and Pragmas
8286 @chapter Representation Clauses and Pragmas
8287 @cindex Representation Clauses
8289 @menu
8290 * Alignment Clauses::
8291 * Size Clauses::
8292 * Storage_Size Clauses::
8293 * Size of Variant Record Objects::
8294 * Biased Representation ::
8295 * Value_Size and Object_Size Clauses::
8296 * Component_Size Clauses::
8297 * Bit_Order Clauses::
8298 * Effect of Bit_Order on Byte Ordering::
8299 * Pragma Pack for Arrays::
8300 * Pragma Pack for Records::
8301 * Record Representation Clauses::
8302 * Enumeration Clauses::
8303 * Address Clauses::
8304 * Effect of Convention on Representation::
8305 * Determining the Representations chosen by GNAT::
8306 @end menu
8308 @noindent
8309 @cindex Representation Clause
8310 @cindex Representation Pragma
8311 @cindex Pragma, representation
8312 This section describes the representation clauses accepted by GNAT, and
8313 their effect on the representation of corresponding data objects.
8315 GNAT fully implements Annex C (Systems Programming).  This means that all
8316 the implementation advice sections in chapter 13 are fully implemented.
8317 However, these sections only require a minimal level of support for
8318 representation clauses.  GNAT provides much more extensive capabilities,
8319 and this section describes the additional capabilities provided.
8321 @node Alignment Clauses
8322 @section Alignment Clauses
8323 @cindex Alignment Clause
8325 @noindent
8326 GNAT requires that all alignment clauses specify a power of 2, and all
8327 default alignments are always a power of 2.  The default alignment
8328 values are as follows:
8330 @itemize @bullet
8331 @item @emph{Primitive Types}.
8332 For primitive types, the alignment is the minimum of the actual size of
8333 objects of the type divided by @code{Storage_Unit},
8334 and the maximum alignment supported by the target.
8335 (This maximum alignment is given by the GNAT-specific attribute
8336 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8337 @cindex @code{Maximum_Alignment} attribute
8338 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8339 default alignment will be 8 on any target that supports alignments
8340 this large, but on some targets, the maximum alignment may be smaller
8341 than 8, in which case objects of type @code{Long_Float} will be maximally
8342 aligned.
8344 @item @emph{Arrays}.
8345 For arrays, the alignment is equal to the alignment of the component type
8346 for the normal case where no packing or component size is given.  If the
8347 array is packed, and the packing is effective (see separate section on
8348 packed arrays), then the alignment will be one for long packed arrays,
8349 or arrays whose length is not known at compile time.  For short packed
8350 arrays, which are handled internally as modular types, the alignment
8351 will be as described for primitive types, e.g.@: a packed array of length
8352 31 bits will have an object size of four bytes, and an alignment of 4.
8354 @item @emph{Records}.
8355 For the normal non-packed case, the alignment of a record is equal to
8356 the maximum alignment of any of its components.  For tagged records, this
8357 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8358 used and all fields are packable (see separate section on pragma @code{Pack}),
8359 then the resulting alignment is 1.
8361 A special case is when:
8362 @itemize @bullet
8363 @item
8364 the size of the record is given explicitly, or a
8365 full record representation clause is given, and
8366 @item
8367 the size of the record is 2, 4, or 8 bytes.
8368 @end itemize
8369 @noindent
8370 In this case, an alignment is chosen to match the
8371 size of the record. For example, if we have:
8373 @smallexample @c ada
8374    type Small is record
8375       A, B : Character;
8376    end record;
8377    for Small'Size use 16;
8378 @end smallexample
8380 @noindent
8381 then the default alignment of the record type @code{Small} is 2, not 1. This
8382 leads to more efficient code when the record is treated as a unit, and also
8383 allows the type to specified as @code{Atomic} on architectures requiring
8384 strict alignment.
8386 @end itemize
8388 @noindent
8389 An alignment clause may
8390 always specify a larger alignment than the default value, up to some
8391 maximum value dependent on the target (obtainable by using the
8392 attribute reference @code{Standard'Maximum_Alignment}).
8393 The only case where
8394 it is permissible to specify a smaller alignment than the default value
8395 is for a record with a record representation clause.
8396 In this case, packable fields for which a component clause is
8397 given still result in a default alignment corresponding to the original
8398 type, but this may be overridden, since these components in fact only
8399 require an alignment of one byte.  For example, given
8401 @smallexample @c ada
8402   type V is record
8403      A : Integer;
8404   end record;
8406   for V use record
8407      A at 0  range 0 .. 31;
8408   end record;
8410   for V'alignment use 1;
8411 @end smallexample
8413 @noindent
8414 @cindex Alignment, default
8415 The default alignment for the type @code{V} is 4, as a result of the
8416 Integer field in the record, but since this field is placed with a
8417 component clause, it is permissible, as shown, to override the default
8418 alignment of the record with a smaller value.
8420 @node Size Clauses
8421 @section Size Clauses
8422 @cindex Size Clause
8424 @noindent
8425 The default size for a type @code{T} is obtainable through the
8426 language-defined attribute @code{T'Size} and also through the
8427 equivalent GNAT-defined attribute @code{T'Value_Size}.
8428 For objects of type @code{T}, GNAT will generally increase the type size
8429 so that the object size (obtainable through the GNAT-defined attribute
8430 @code{T'Object_Size})
8431 is a multiple of @code{T'Alignment * Storage_Unit}.
8432 For example
8434 @smallexample @c ada
8435    type Smallint is range 1 .. 6;
8437    type Rec is record
8438       Y1 : integer;
8439       Y2 : boolean;
8440    end record;
8441 @end smallexample
8443 @noindent
8444 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8445 as specified by the RM rules,
8446 but objects of this type will have a size of 8
8447 (@code{Smallint'Object_Size} = 8),
8448 since objects by default occupy an integral number
8449 of storage units.  On some targets, notably older
8450 versions of the Digital Alpha, the size of stand
8451 alone objects of this type may be 32, reflecting
8452 the inability of the hardware to do byte load/stores.
8454 Similarly, the size of type @code{Rec} is 40 bits
8455 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8456 the alignment is 4, so objects of this type will have
8457 their size increased to 64 bits so that it is a multiple
8458 of the alignment (in bits).  This decision is
8459 in accordance with the specific Implementation Advice in RM 13.3(43):
8461 @quotation
8462 A @code{Size} clause should be supported for an object if the specified
8463 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8464 to a size in storage elements that is a multiple of the object's
8465 @code{Alignment} (if the @code{Alignment} is nonzero).
8466 @end quotation
8468 @noindent
8469 An explicit size clause may be used to override the default size by
8470 increasing it.  For example, if we have:
8472 @smallexample @c ada
8473    type My_Boolean is new Boolean;
8474    for My_Boolean'Size use 32;
8475 @end smallexample
8477 @noindent
8478 then values of this type will always be 32 bits long.  In the case of
8479 discrete types, the size can be increased up to 64 bits, with the effect
8480 that the entire specified field is used to hold the value, sign- or
8481 zero-extended as appropriate.  If more than 64 bits is specified, then
8482 padding space is allocated after the value, and a warning is issued that
8483 there are unused bits.
8485 Similarly the size of records and arrays may be increased, and the effect
8486 is to add padding bits after the value.  This also causes a warning message
8487 to be generated.
8489 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8490 Size in bits, this corresponds to an object of size 256 megabytes (minus
8491 one).  This limitation is true on all targets.  The reason for this
8492 limitation is that it improves the quality of the code in many cases
8493 if it is known that a Size value can be accommodated in an object of
8494 type Integer.
8496 @node Storage_Size Clauses
8497 @section Storage_Size Clauses
8498 @cindex Storage_Size Clause
8500 @noindent
8501 For tasks, the @code{Storage_Size} clause specifies the amount of space
8502 to be allocated for the task stack.  This cannot be extended, and if the
8503 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8504 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8505 or a @code{Storage_Size} pragma in the task definition to set the
8506 appropriate required size.  A useful technique is to include in every
8507 task definition a pragma of the form:
8509 @smallexample @c ada
8510    pragma Storage_Size (Default_Stack_Size);
8511 @end smallexample
8513 @noindent
8514 Then @code{Default_Stack_Size} can be defined in a global package, and
8515 modified as required.  Any tasks requiring stack sizes different from the
8516 default can have an appropriate alternative reference in the pragma.
8518 For access types, the @code{Storage_Size} clause specifies the maximum
8519 space available for allocation of objects of the type.  If this space is
8520 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8521 In the case where the access type is declared local to a subprogram, the
8522 use of a @code{Storage_Size} clause triggers automatic use of a special
8523 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8524 space for the pool is automatically reclaimed on exit from the scope in
8525 which the type is declared.
8527 A special case recognized by the compiler is the specification of a
8528 @code{Storage_Size} of zero for an access type.  This means that no
8529 items can be allocated from the pool, and this is recognized at compile
8530 time, and all the overhead normally associated with maintaining a fixed
8531 size storage pool is eliminated.  Consider the following example:
8533 @smallexample @c ada
8534    procedure p is
8535       type R is array (Natural) of Character;
8536       type P is access all R;
8537       for P'Storage_Size use 0;
8538       --  Above access type intended only for interfacing purposes
8540       y : P;
8542       procedure g (m : P);
8543       pragma Import (C, g);
8545       --  @dots{}
8547    begin
8548       --  @dots{}
8549       y := new R;
8550    end;
8551 @end smallexample
8553 @noindent
8554 As indicated in this example, these dummy storage pools are often useful in
8555 connection with interfacing where no object will ever be allocated.  If you
8556 compile the above example, you get the warning:
8558 @smallexample
8559    p.adb:16:09: warning: allocation from empty storage pool
8560    p.adb:16:09: warning: Storage_Error will be raised at run time
8561 @end smallexample
8563 @noindent
8564 Of course in practice, there will not be any explicit allocators in the
8565 case of such an access declaration.
8567 @node Size of Variant Record Objects
8568 @section Size of Variant Record Objects
8569 @cindex Size, variant record objects
8570 @cindex Variant record objects, size
8572 @noindent
8573 In the case of variant record objects, there is a question whether Size gives
8574 information about a particular variant, or the maximum size required
8575 for any variant.  Consider the following program
8577 @smallexample @c ada
8578 with Text_IO; use Text_IO;
8579 procedure q is
8580    type R1 (A : Boolean := False) is record
8581      case A is
8582        when True  => X : Character;
8583        when False => null;
8584      end case;
8585    end record;
8587    V1 : R1 (False);
8588    V2 : R1;
8590 begin
8591    Put_Line (Integer'Image (V1'Size));
8592    Put_Line (Integer'Image (V2'Size));
8593 end q;
8594 @end smallexample
8596 @noindent
8597 Here we are dealing with a variant record, where the True variant
8598 requires 16 bits, and the False variant requires 8 bits.
8599 In the above example, both V1 and V2 contain the False variant,
8600 which is only 8 bits long.  However, the result of running the
8601 program is:
8603 @smallexample
8606 @end smallexample
8608 @noindent
8609 The reason for the difference here is that the discriminant value of
8610 V1 is fixed, and will always be False.  It is not possible to assign
8611 a True variant value to V1, therefore 8 bits is sufficient.  On the
8612 other hand, in the case of V2, the initial discriminant value is
8613 False (from the default), but it is possible to assign a True
8614 variant value to V2, therefore 16 bits must be allocated for V2
8615 in the general case, even fewer bits may be needed at any particular
8616 point during the program execution.
8618 As can be seen from the output of this program, the @code{'Size}
8619 attribute applied to such an object in GNAT gives the actual allocated
8620 size of the variable, which is the largest size of any of the variants.
8621 The Ada Reference Manual is not completely clear on what choice should
8622 be made here, but the GNAT behavior seems most consistent with the
8623 language in the RM@.
8625 In some cases, it may be desirable to obtain the size of the current
8626 variant, rather than the size of the largest variant.  This can be
8627 achieved in GNAT by making use of the fact that in the case of a
8628 subprogram parameter, GNAT does indeed return the size of the current
8629 variant (because a subprogram has no way of knowing how much space
8630 is actually allocated for the actual).
8632 Consider the following modified version of the above program:
8634 @smallexample @c ada
8635 with Text_IO; use Text_IO;
8636 procedure q is
8637    type R1 (A : Boolean := False) is record
8638      case A is
8639        when True  => X : Character;
8640        when False => null;
8641      end case;
8642    end record;
8644    V2 : R1;
8646    function Size (V : R1) return Integer is
8647    begin
8648       return V'Size;
8649    end Size;
8651 begin
8652    Put_Line (Integer'Image (V2'Size));
8653    Put_Line (Integer'IMage (Size (V2)));
8654    V2 := (True, 'x');
8655    Put_Line (Integer'Image (V2'Size));
8656    Put_Line (Integer'IMage (Size (V2)));
8657 end q;
8658 @end smallexample
8660 @noindent
8661 The output from this program is
8663 @smallexample
8668 @end smallexample
8670 @noindent
8671 Here we see that while the @code{'Size} attribute always returns
8672 the maximum size, regardless of the current variant value, the
8673 @code{Size} function does indeed return the size of the current
8674 variant value.
8676 @node Biased Representation
8677 @section Biased Representation
8678 @cindex Size for biased representation
8679 @cindex Biased representation
8681 @noindent
8682 In the case of scalars with a range starting at other than zero, it is
8683 possible in some cases to specify a size smaller than the default minimum
8684 value, and in such cases, GNAT uses an unsigned biased representation,
8685 in which zero is used to represent the lower bound, and successive values
8686 represent successive values of the type.
8688 For example, suppose we have the declaration:
8690 @smallexample @c ada
8691    type Small is range -7 .. -4;
8692    for Small'Size use 2;
8693 @end smallexample
8695 @noindent
8696 Although the default size of type @code{Small} is 4, the @code{Size}
8697 clause is accepted by GNAT and results in the following representation
8698 scheme:
8700 @smallexample
8701   -7 is represented as 2#00#
8702   -6 is represented as 2#01#
8703   -5 is represented as 2#10#
8704   -4 is represented as 2#11#
8705 @end smallexample
8707 @noindent
8708 Biased representation is only used if the specified @code{Size} clause
8709 cannot be accepted in any other manner.  These reduced sizes that force
8710 biased representation can be used for all discrete types except for
8711 enumeration types for which a representation clause is given.
8713 @node Value_Size and Object_Size Clauses
8714 @section Value_Size and Object_Size Clauses
8715 @findex Value_Size
8716 @findex Object_Size
8717 @cindex Size, of objects
8719 @noindent
8720 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8721 required to hold values of type @code{T}.  Although this interpretation was
8722 allowed in Ada 83, it was not required, and this requirement in practice
8723 can cause some significant difficulties.  For example, in most Ada 83
8724 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8725 @code{Natural'Size} is
8726 typically 31.  This means that code may change in behavior when moving
8727 from Ada 83 to Ada 95.  For example, consider:
8729 @smallexample @c ada
8730    type Rec is record;
8731       A : Natural;
8732       B : Natural;
8733    end record;
8735    for Rec use record
8736       at 0  range 0 .. Natural'Size - 1;
8737       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8738    end record;
8739 @end smallexample
8741 @noindent
8742 In the above code, since the typical size of @code{Natural} objects
8743 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8744 unexpected inefficient packing in Ada 95, and in general there are
8745 cases where the fact that the object size can exceed the
8746 size of the type causes surprises.
8748 To help get around this problem GNAT provides two implementation
8749 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8750 applied to a type, these attributes yield the size of the type
8751 (corresponding to the RM defined size attribute), and the size of
8752 objects of the type respectively.
8754 The @code{Object_Size} is used for determining the default size of
8755 objects and components.  This size value can be referred to using the
8756 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8757 the basis of the determination of the size.  The backend is free to
8758 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8759 character might be stored in 32 bits on a machine with no efficient
8760 byte access instructions such as the Alpha.
8762 The default rules for the value of @code{Object_Size} for
8763 discrete types are as follows:
8765 @itemize @bullet
8766 @item
8767 The @code{Object_Size} for base subtypes reflect the natural hardware
8768 size in bits (run the compiler with @option{-gnatS} to find those values
8769 for numeric types). Enumeration types and fixed-point base subtypes have
8770 8, 16, 32 or 64 bits for this size, depending on the range of values
8771 to be stored.
8773 @item
8774 The @code{Object_Size} of a subtype is the same as the
8775 @code{Object_Size} of
8776 the type from which it is obtained.
8778 @item
8779 The @code{Object_Size} of a derived base type is copied from the parent
8780 base type, and the @code{Object_Size} of a derived first subtype is copied
8781 from the parent first subtype.
8782 @end itemize
8784 @noindent
8785 The @code{Value_Size} attribute
8786 is the (minimum) number of bits required to store a value
8787 of the type.
8788 This value is used to determine how tightly to pack
8789 records or arrays with components of this type, and also affects
8790 the semantics of unchecked conversion (unchecked conversions where
8791 the @code{Value_Size} values differ generate a warning, and are potentially
8792 target dependent).
8794 The default rules for the value of @code{Value_Size} are as follows:
8796 @itemize @bullet
8797 @item
8798 The @code{Value_Size} for a base subtype is the minimum number of bits
8799 required to store all values of the type (including the sign bit
8800 only if negative values are possible).
8802 @item
8803 If a subtype statically matches the first subtype of a given type, then it has
8804 by default the same @code{Value_Size} as the first subtype.  This is a
8805 consequence of RM 13.1(14) (``if two subtypes statically match,
8806 then their subtype-specific aspects are the same''.)
8808 @item
8809 All other subtypes have a @code{Value_Size} corresponding to the minimum
8810 number of bits required to store all values of the subtype.  For
8811 dynamic bounds, it is assumed that the value can range down or up
8812 to the corresponding bound of the ancestor
8813 @end itemize
8815 @noindent
8816 The RM defined attribute @code{Size} corresponds to the
8817 @code{Value_Size} attribute.
8819 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8820 the @code{Value_Size} of
8821 the first-named subtype to the given value, and the
8822 @code{Object_Size} of this first-named subtype to the given value padded up
8823 to an appropriate boundary.  It is a consequence of the default rules
8824 above that this @code{Object_Size} will apply to all further subtypes.  On the
8825 other hand, @code{Value_Size} is affected only for the first subtype, any
8826 dynamic subtypes obtained from it directly, and any statically matching
8827 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8829 @code{Value_Size} and
8830 @code{Object_Size} may be explicitly set for any subtype using
8831 an attribute definition clause.  Note that the use of these attributes
8832 can cause the RM 13.1(14) rule to be violated.  If two access types
8833 reference aliased objects whose subtypes have differing @code{Object_Size}
8834 values as a result of explicit attribute definition clauses, then it
8835 is erroneous to convert from one access subtype to the other.
8837 At the implementation level, Esize stores the Object_Size and the
8838 RM_Size field stores the @code{Value_Size} (and hence the value of the
8839 @code{Size} attribute,
8840 which, as noted above, is equivalent to @code{Value_Size}).
8842 To get a feel for the difference, consider the following examples (note
8843 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8845 @smallexample
8846                                        Object_Size     Value_Size
8848 type x1 is range 0 .. 5;                    8               3
8850 type x2 is range 0 .. 5;
8851 for x2'size use 12;                        16              12
8853 subtype x3 is x2 range 0 .. 3;             16               2
8855 subtype x4 is x2'base range 0 .. 10;        8               4
8857 subtype x5 is x2 range 0 .. dynamic;       16               3*
8859 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8861 @end smallexample
8863 @noindent
8864 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8865 but it seems in the spirit of the RM rules to allocate the minimum number
8866 of bits (here 3, given the range for @code{x2})
8867 known to be large enough to hold the given range of values.
8869 So far, so good, but GNAT has to obey the RM rules, so the question is
8870 under what conditions must the RM @code{Size} be used.
8871 The following is a list
8872 of the occasions on which the RM @code{Size} must be used:
8874 @itemize @bullet
8875 @item
8876 Component size for packed arrays or records
8878 @item
8879 Value of the attribute @code{Size} for a type
8881 @item
8882 Warning about sizes not matching for unchecked conversion
8883 @end itemize
8885 @noindent
8886 For record types, the @code{Object_Size} is always a multiple of the
8887 alignment of the type (this is true for all types). In some cases the
8888 @code{Value_Size} can be smaller. Consider:
8890 @smallexample
8891    type R is record
8892      X : Integer;
8893      Y : Character;
8894    end record;
8895 @end smallexample
8897 @noindent
8898 On a typical 32-bit architecture, the X component will be four bytes, and
8899 require four-byte alignment, and the Y component will be one byte. In this
8900 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8901 required to store a value of this type, and for example, it is permissible
8902 to have a component of type R in an outer record whose component size is
8903 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8904 since it must be rounded up so that this value is a multiple of the
8905 alignment (4 bytes = 32 bits).
8907 @noindent
8908 For all other types, the @code{Object_Size}
8909 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8910 Only @code{Size} may be specified for such types.
8912 @node Component_Size Clauses
8913 @section Component_Size Clauses
8914 @cindex Component_Size Clause
8916 @noindent
8917 Normally, the value specified in a component clause must be consistent
8918 with the subtype of the array component with regard to size and alignment.
8919 In other words, the value specified must be at least equal to the size
8920 of this subtype, and must be a multiple of the alignment value.
8922 In addition, component size clauses are allowed which cause the array
8923 to be packed, by specifying a smaller value.  The cases in which this
8924 is allowed are for component size values in the range 1 through 63.  The value
8925 specified must not be smaller than the Size of the subtype.  GNAT will
8926 accurately honor all packing requests in this range.  For example, if
8927 we have:
8929 @smallexample @c ada
8930 type r is array (1 .. 8) of Natural;
8931 for r'Component_Size use 31;
8932 @end smallexample
8934 @noindent
8935 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8936 Of course access to the components of such an array is considerably
8937 less efficient than if the natural component size of 32 is used.
8939 @node Bit_Order Clauses
8940 @section Bit_Order Clauses
8941 @cindex Bit_Order Clause
8942 @cindex bit ordering
8943 @cindex ordering, of bits
8945 @noindent
8946 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8947 attribute.  The specification may either correspond to the default bit
8948 order for the target, in which case the specification has no effect and
8949 places no additional restrictions, or it may be for the non-standard
8950 setting (that is the opposite of the default).
8952 In the case where the non-standard value is specified, the effect is
8953 to renumber bits within each byte, but the ordering of bytes is not
8954 affected.  There are certain
8955 restrictions placed on component clauses as follows:
8957 @itemize @bullet
8959 @item Components fitting within a single storage unit.
8960 @noindent
8961 These are unrestricted, and the effect is merely to renumber bits.  For
8962 example if we are on a little-endian machine with @code{Low_Order_First}
8963 being the default, then the following two declarations have exactly
8964 the same effect:
8966 @smallexample @c ada
8967    type R1 is record
8968       A : Boolean;
8969       B : Integer range 1 .. 120;
8970    end record;
8972    for R1 use record
8973       A at 0 range 0 .. 0;
8974       B at 0 range 1 .. 7;
8975    end record;
8977    type R2 is record
8978       A : Boolean;
8979       B : Integer range 1 .. 120;
8980    end record;
8982    for R2'Bit_Order use High_Order_First;
8984    for R2 use record
8985       A at 0 range 7 .. 7;
8986       B at 0 range 0 .. 6;
8987    end record;
8988 @end smallexample
8990 @noindent
8991 The useful application here is to write the second declaration with the
8992 @code{Bit_Order} attribute definition clause, and know that it will be treated
8993 the same, regardless of whether the target is little-endian or big-endian.
8995 @item Components occupying an integral number of bytes.
8996 @noindent
8997 These are components that exactly fit in two or more bytes.  Such component
8998 declarations are allowed, but have no effect, since it is important to realize
8999 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9000 In particular, the following attempt at getting an endian-independent integer
9001 does not work:
9003 @smallexample @c ada
9004    type R2 is record
9005       A : Integer;
9006    end record;
9008    for R2'Bit_Order use High_Order_First;
9010    for R2 use record
9011       A at 0 range 0 .. 31;
9012    end record;
9013 @end smallexample
9015 @noindent
9016 This declaration will result in a little-endian integer on a
9017 little-endian machine, and a big-endian integer on a big-endian machine.
9018 If byte flipping is required for interoperability between big- and
9019 little-endian machines, this must be explicitly programmed.  This capability
9020 is not provided by @code{Bit_Order}.
9022 @item Components that are positioned across byte boundaries
9023 @noindent
9024 but do not occupy an integral number of bytes.  Given that bytes are not
9025 reordered, such fields would occupy a non-contiguous sequence of bits
9026 in memory, requiring non-trivial code to reassemble.  They are for this
9027 reason not permitted, and any component clause specifying such a layout
9028 will be flagged as illegal by GNAT@.
9030 @end itemize
9032 @noindent
9033 Since the misconception that Bit_Order automatically deals with all
9034 endian-related incompatibilities is a common one, the specification of
9035 a component field that is an integral number of bytes will always
9036 generate a warning.  This warning may be suppressed using
9037 @code{pragma Suppress} if desired.  The following section contains additional
9038 details regarding the issue of byte ordering.
9040 @node Effect of Bit_Order on Byte Ordering
9041 @section Effect of Bit_Order on Byte Ordering
9042 @cindex byte ordering
9043 @cindex ordering, of bytes
9045 @noindent
9046 In this section we will review the effect of the @code{Bit_Order} attribute
9047 definition clause on byte ordering.  Briefly, it has no effect at all, but
9048 a detailed example will be helpful.  Before giving this
9049 example, let us review the precise
9050 definition of the effect of defining @code{Bit_Order}.  The effect of a
9051 non-standard bit order is described in section 15.5.3 of the Ada
9052 Reference Manual:
9054 @quotation
9055 2   A bit ordering is a method of interpreting the meaning of
9056 the storage place attributes.
9057 @end quotation
9059 @noindent
9060 To understand the precise definition of storage place attributes in
9061 this context, we visit section 13.5.1 of the manual:
9063 @quotation
9064 13   A record_representation_clause (without the mod_clause)
9065 specifies the layout.  The storage place attributes (see 13.5.2)
9066 are taken from the values of the position, first_bit, and last_bit
9067 expressions after normalizing those values so that first_bit is
9068 less than Storage_Unit.
9069 @end quotation
9071 @noindent
9072 The critical point here is that storage places are taken from
9073 the values after normalization, not before.  So the @code{Bit_Order}
9074 interpretation applies to normalized values.  The interpretation
9075 is described in the later part of the 15.5.3 paragraph:
9077 @quotation
9078 2   A bit ordering is a method of interpreting the meaning of
9079 the storage place attributes.  High_Order_First (known in the
9080 vernacular as ``big endian'') means that the first bit of a
9081 storage element (bit 0) is the most significant bit (interpreting
9082 the sequence of bits that represent a component as an unsigned
9083 integer value).  Low_Order_First (known in the vernacular as
9084 ``little endian'') means the opposite: the first bit is the
9085 least significant.
9086 @end quotation
9088 @noindent
9089 Note that the numbering is with respect to the bits of a storage
9090 unit.  In other words, the specification affects only the numbering
9091 of bits within a single storage unit.
9093 We can make the effect clearer by giving an example.
9095 Suppose that we have an external device which presents two bytes, the first
9096 byte presented, which is the first (low addressed byte) of the two byte
9097 record is called Master, and the second byte is called Slave.
9099 The left most (most significant bit is called Control for each byte, and
9100 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9101 (least significant) bit.
9103 On a big-endian machine, we can write the following representation clause
9105 @smallexample @c ada
9106    type Data is record
9107       Master_Control : Bit;
9108       Master_V1      : Bit;
9109       Master_V2      : Bit;
9110       Master_V3      : Bit;
9111       Master_V4      : Bit;
9112       Master_V5      : Bit;
9113       Master_V6      : Bit;
9114       Master_V7      : Bit;
9115       Slave_Control  : Bit;
9116       Slave_V1       : Bit;
9117       Slave_V2       : Bit;
9118       Slave_V3       : Bit;
9119       Slave_V4       : Bit;
9120       Slave_V5       : Bit;
9121       Slave_V6       : Bit;
9122       Slave_V7       : Bit;
9123    end record;
9125    for Data use record
9126       Master_Control at 0 range 0 .. 0;
9127       Master_V1      at 0 range 1 .. 1;
9128       Master_V2      at 0 range 2 .. 2;
9129       Master_V3      at 0 range 3 .. 3;
9130       Master_V4      at 0 range 4 .. 4;
9131       Master_V5      at 0 range 5 .. 5;
9132       Master_V6      at 0 range 6 .. 6;
9133       Master_V7      at 0 range 7 .. 7;
9134       Slave_Control  at 1 range 0 .. 0;
9135       Slave_V1       at 1 range 1 .. 1;
9136       Slave_V2       at 1 range 2 .. 2;
9137       Slave_V3       at 1 range 3 .. 3;
9138       Slave_V4       at 1 range 4 .. 4;
9139       Slave_V5       at 1 range 5 .. 5;
9140       Slave_V6       at 1 range 6 .. 6;
9141       Slave_V7       at 1 range 7 .. 7;
9142    end record;
9143 @end smallexample
9145 @noindent
9146 Now if we move this to a little endian machine, then the bit ordering within
9147 the byte is backwards, so we have to rewrite the record rep clause as:
9149 @smallexample @c ada
9150    for Data use record
9151       Master_Control at 0 range 7 .. 7;
9152       Master_V1      at 0 range 6 .. 6;
9153       Master_V2      at 0 range 5 .. 5;
9154       Master_V3      at 0 range 4 .. 4;
9155       Master_V4      at 0 range 3 .. 3;
9156       Master_V5      at 0 range 2 .. 2;
9157       Master_V6      at 0 range 1 .. 1;
9158       Master_V7      at 0 range 0 .. 0;
9159       Slave_Control  at 1 range 7 .. 7;
9160       Slave_V1       at 1 range 6 .. 6;
9161       Slave_V2       at 1 range 5 .. 5;
9162       Slave_V3       at 1 range 4 .. 4;
9163       Slave_V4       at 1 range 3 .. 3;
9164       Slave_V5       at 1 range 2 .. 2;
9165       Slave_V6       at 1 range 1 .. 1;
9166       Slave_V7       at 1 range 0 .. 0;
9167    end record;
9168 @end smallexample
9170 @noindent
9171 It is a nuisance to have to rewrite the clause, especially if
9172 the code has to be maintained on both machines.  However,
9173 this is a case that we can handle with the
9174 @code{Bit_Order} attribute if it is implemented.
9175 Note that the implementation is not required on byte addressed
9176 machines, but it is indeed implemented in GNAT.
9177 This means that we can simply use the
9178 first record clause, together with the declaration
9180 @smallexample @c ada
9181    for Data'Bit_Order use High_Order_First;
9182 @end smallexample
9184 @noindent
9185 and the effect is what is desired, namely the layout is exactly the same,
9186 independent of whether the code is compiled on a big-endian or little-endian
9187 machine.
9189 The important point to understand is that byte ordering is not affected.
9190 A @code{Bit_Order} attribute definition never affects which byte a field
9191 ends up in, only where it ends up in that byte.
9192 To make this clear, let us rewrite the record rep clause of the previous
9193 example as:
9195 @smallexample @c ada
9196    for Data'Bit_Order use High_Order_First;
9197    for Data use record
9198       Master_Control at 0 range  0 .. 0;
9199       Master_V1      at 0 range  1 .. 1;
9200       Master_V2      at 0 range  2 .. 2;
9201       Master_V3      at 0 range  3 .. 3;
9202       Master_V4      at 0 range  4 .. 4;
9203       Master_V5      at 0 range  5 .. 5;
9204       Master_V6      at 0 range  6 .. 6;
9205       Master_V7      at 0 range  7 .. 7;
9206       Slave_Control  at 0 range  8 .. 8;
9207       Slave_V1       at 0 range  9 .. 9;
9208       Slave_V2       at 0 range 10 .. 10;
9209       Slave_V3       at 0 range 11 .. 11;
9210       Slave_V4       at 0 range 12 .. 12;
9211       Slave_V5       at 0 range 13 .. 13;
9212       Slave_V6       at 0 range 14 .. 14;
9213       Slave_V7       at 0 range 15 .. 15;
9214    end record;
9215 @end smallexample
9217 @noindent
9218 This is exactly equivalent to saying (a repeat of the first example):
9220 @smallexample @c ada
9221    for Data'Bit_Order use High_Order_First;
9222    for Data use record
9223       Master_Control at 0 range 0 .. 0;
9224       Master_V1      at 0 range 1 .. 1;
9225       Master_V2      at 0 range 2 .. 2;
9226       Master_V3      at 0 range 3 .. 3;
9227       Master_V4      at 0 range 4 .. 4;
9228       Master_V5      at 0 range 5 .. 5;
9229       Master_V6      at 0 range 6 .. 6;
9230       Master_V7      at 0 range 7 .. 7;
9231       Slave_Control  at 1 range 0 .. 0;
9232       Slave_V1       at 1 range 1 .. 1;
9233       Slave_V2       at 1 range 2 .. 2;
9234       Slave_V3       at 1 range 3 .. 3;
9235       Slave_V4       at 1 range 4 .. 4;
9236       Slave_V5       at 1 range 5 .. 5;
9237       Slave_V6       at 1 range 6 .. 6;
9238       Slave_V7       at 1 range 7 .. 7;
9239    end record;
9240 @end smallexample
9242 @noindent
9243 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9244 field.  The storage place attributes are obtained by normalizing the
9245 values given so that the @code{First_Bit} value is less than 8.  After
9246 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9247 we specified in the other case.
9249 Now one might expect that the @code{Bit_Order} attribute might affect
9250 bit numbering within the entire record component (two bytes in this
9251 case, thus affecting which byte fields end up in), but that is not
9252 the way this feature is defined, it only affects numbering of bits,
9253 not which byte they end up in.
9255 Consequently it never makes sense to specify a starting bit number
9256 greater than 7 (for a byte addressable field) if an attribute
9257 definition for @code{Bit_Order} has been given, and indeed it
9258 may be actively confusing to specify such a value, so the compiler
9259 generates a warning for such usage.
9261 If you do need to control byte ordering then appropriate conditional
9262 values must be used.  If in our example, the slave byte came first on
9263 some machines we might write:
9265 @smallexample @c ada
9266    Master_Byte_First constant Boolean := @dots{};
9268    Master_Byte : constant Natural :=
9269                    1 - Boolean'Pos (Master_Byte_First);
9270    Slave_Byte  : constant Natural :=
9271                    Boolean'Pos (Master_Byte_First);
9273    for Data'Bit_Order use High_Order_First;
9274    for Data use record
9275       Master_Control at Master_Byte range 0 .. 0;
9276       Master_V1      at Master_Byte range 1 .. 1;
9277       Master_V2      at Master_Byte range 2 .. 2;
9278       Master_V3      at Master_Byte range 3 .. 3;
9279       Master_V4      at Master_Byte range 4 .. 4;
9280       Master_V5      at Master_Byte range 5 .. 5;
9281       Master_V6      at Master_Byte range 6 .. 6;
9282       Master_V7      at Master_Byte range 7 .. 7;
9283       Slave_Control  at Slave_Byte  range 0 .. 0;
9284       Slave_V1       at Slave_Byte  range 1 .. 1;
9285       Slave_V2       at Slave_Byte  range 2 .. 2;
9286       Slave_V3       at Slave_Byte  range 3 .. 3;
9287       Slave_V4       at Slave_Byte  range 4 .. 4;
9288       Slave_V5       at Slave_Byte  range 5 .. 5;
9289       Slave_V6       at Slave_Byte  range 6 .. 6;
9290       Slave_V7       at Slave_Byte  range 7 .. 7;
9291    end record;
9292 @end smallexample
9294 @noindent
9295 Now to switch between machines, all that is necessary is
9296 to set the boolean constant @code{Master_Byte_First} in
9297 an appropriate manner.
9299 @node Pragma Pack for Arrays
9300 @section Pragma Pack for Arrays
9301 @cindex Pragma Pack (for arrays)
9303 @noindent
9304 Pragma @code{Pack} applied to an array has no effect unless the component type
9305 is packable.  For a component type to be packable, it must be one of the
9306 following cases:
9308 @itemize @bullet
9309 @item
9310 Any scalar type
9311 @item
9312 Any type whose size is specified with a size clause
9313 @item
9314 Any packed array type with a static size
9315 @end itemize
9317 @noindent
9318 For all these cases, if the component subtype size is in the range
9319 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9320 component size were specified giving the component subtype size.
9321 For example if we have:
9323 @smallexample @c ada
9324    type r is range 0 .. 17;
9326    type ar is array (1 .. 8) of r;
9327    pragma Pack (ar);
9328 @end smallexample
9330 @noindent
9331 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9332 and the size of the array @code{ar} will be exactly 40 bits.
9334 Note that in some cases this rather fierce approach to packing can produce
9335 unexpected effects.  For example, in Ada 95, type Natural typically has a
9336 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9337 close packing, which saves a few bits, but results in far less efficient
9338 access.  Since many other Ada compilers will ignore such a packing request,
9339 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9340 might not be what is intended.  You can easily remove this warning by
9341 using an explicit @code{Component_Size} setting instead, which never generates
9342 a warning, since the intention of the programmer is clear in this case.
9344 GNAT treats packed arrays in one of two ways.  If the size of the array is
9345 known at compile time and is less than 64 bits, then internally the array
9346 is represented as a single modular type, of exactly the appropriate number
9347 of bits.  If the length is greater than 63 bits, or is not known at compile
9348 time, then the packed array is represented as an array of bytes, and the
9349 length is always a multiple of 8 bits.
9351 Note that to represent a packed array as a modular type, the alignment must
9352 be suitable for the modular type involved. For example, on typical machines
9353 a 32-bit packed array will be represented by a 32-bit modular integer with
9354 an alignment of four bytes. If you explicitly override the default alignment
9355 with an alignment clause that is too small, the modular representation
9356 cannot be used. For example, consider the following set of declarations:
9358 @smallexample @c ada
9359    type R is range 1 .. 3;
9360    type S is array (1 .. 31) of R;
9361    for S'Component_Size use 2;
9362    for S'Size use 62;
9363    for S'Alignment use 1;
9364 @end smallexample
9366 @noindent
9367 If the alignment clause were not present, then a 62-bit modular
9368 representation would be chosen (typically with an alignment of 4 or 8
9369 bytes depending on the target). But the default alignment is overridden
9370 with the explicit alignment clause. This means that the modular
9371 representation cannot be used, and instead the array of bytes
9372 representation must be used, meaning that the length must be a multiple
9373 of 8. Thus the above set of declarations will result in a diagnostic
9374 rejecting the size clause and noting that the minimum size allowed is 64.
9376 @cindex Pragma Pack (for type Natural)
9377 @cindex Pragma Pack warning
9379 One special case that is worth noting occurs when the base type of the
9380 component size is 8/16/32 and the subtype is one bit less. Notably this
9381 occurs with subtype @code{Natural}. Consider:
9383 @smallexample @c ada
9384    type Arr is array (1 .. 32) of Natural;
9385    pragma Pack (Arr);
9386 @end smallexample
9388 @noindent
9389 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9390 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9391 Ada 83 compilers did not attempt 31 bit packing.
9393 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9394 does pack 31-bit subtype to 31 bits. This may result in a substantial
9395 unintended performance penalty when porting legacy Ada 83 code. To help
9396 prevent this, GNAT generates a warning in such cases. If you really want 31
9397 bit packing in a case like this, you can set the component size explicitly:
9399 @smallexample @c ada
9400    type Arr is array (1 .. 32) of Natural;
9401    for Arr'Component_Size use 31;
9402 @end smallexample
9404 @noindent
9405 Here 31-bit packing is achieved as required, and no warning is generated,
9406 since in this case the programmer intention is clear.
9408 @node Pragma Pack for Records
9409 @section Pragma Pack for Records
9410 @cindex Pragma Pack (for records)
9412 @noindent
9413 Pragma @code{Pack} applied to a record will pack the components to reduce
9414 wasted space from alignment gaps and by reducing the amount of space
9415 taken by components.  We distinguish between @emph{packable} components and
9416 @emph{non-packable} components.
9417 Components of the following types are considered packable:
9418 @itemize @bullet
9419 @item
9420 All primitive types are packable.
9422 @item
9423 Small packed arrays, whose size does not exceed 64 bits, and where the
9424 size is statically known at compile time, are represented internally
9425 as modular integers, and so they are also packable.
9427 @end itemize
9429 @noindent
9430 All packable components occupy the exact number of bits corresponding to
9431 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9432 can start on an arbitrary bit boundary.
9434 All other types are non-packable, they occupy an integral number of
9435 storage units, and
9436 are placed at a boundary corresponding to their alignment requirements.
9438 For example, consider the record
9440 @smallexample @c ada
9441    type Rb1 is array (1 .. 13) of Boolean;
9442    pragma Pack (rb1);
9444    type Rb2 is array (1 .. 65) of Boolean;
9445    pragma Pack (rb2);
9447    type x2 is record
9448       l1 : Boolean;
9449       l2 : Duration;
9450       l3 : Float;
9451       l4 : Boolean;
9452       l5 : Rb1;
9453       l6 : Rb2;
9454    end record;
9455    pragma Pack (x2);
9456 @end smallexample
9458 @noindent
9459 The representation for the record x2 is as follows:
9461 @smallexample @c ada
9462 for x2'Size use 224;
9463 for x2 use record
9464    l1 at  0 range  0 .. 0;
9465    l2 at  0 range  1 .. 64;
9466    l3 at 12 range  0 .. 31;
9467    l4 at 16 range  0 .. 0;
9468    l5 at 16 range  1 .. 13;
9469    l6 at 18 range  0 .. 71;
9470 end record;
9471 @end smallexample
9473 @noindent
9474 Studying this example, we see that the packable fields @code{l1}
9475 and @code{l2} are
9476 of length equal to their sizes, and placed at specific bit boundaries (and
9477 not byte boundaries) to
9478 eliminate padding.  But @code{l3} is of a non-packable float type, so
9479 it is on the next appropriate alignment boundary.
9481 The next two fields are fully packable, so @code{l4} and @code{l5} are
9482 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9483 array that is longer than 64 bits, so it is itself non-packable.  Thus
9484 the @code{l6} field is aligned to the next byte boundary, and takes an
9485 integral number of bytes, i.e.@: 72 bits.
9487 @node Record Representation Clauses
9488 @section Record Representation Clauses
9489 @cindex Record Representation Clause
9491 @noindent
9492 Record representation clauses may be given for all record types, including
9493 types obtained by record extension.  Component clauses are allowed for any
9494 static component.  The restrictions on component clauses depend on the type
9495 of the component.
9497 @cindex Component Clause
9498 For all components of an elementary type, the only restriction on component
9499 clauses is that the size must be at least the 'Size value of the type
9500 (actually the Value_Size).  There are no restrictions due to alignment,
9501 and such components may freely cross storage boundaries.
9503 Packed arrays with a size up to and including 64 bits are represented
9504 internally using a modular type with the appropriate number of bits, and
9505 thus the same lack of restriction applies.  For example, if you declare:
9507 @smallexample @c ada
9508    type R is array (1 .. 49) of Boolean;
9509    pragma Pack (R);
9510    for R'Size use 49;
9511 @end smallexample
9513 @noindent
9514 then a component clause for a component of type R may start on any
9515 specified bit boundary, and may specify a value of 49 bits or greater.
9517 Packed bit arrays that are longer than 64 bits must always be placed
9518 on a storage unit (byte) boundary. Any component clause that does not
9519 meet this requirement will be rejected.
9521 The rules for other types are different for GNAT 3 and GNAT 5 versions
9522 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9523 (other than packed arrays)
9524 may also be placed on arbitrary boundaries, so for example, the following
9525 is permitted:
9527 @smallexample @c ada
9528    type R is array (1 .. 10) of Boolean;
9529    for R'Size use 80;
9531    type Q is record
9532       G, H : Boolean;
9533       L, M : R;
9534    end record;
9536    for Q use record
9537       G at 0 range  0 ..   0;
9538       H at 0 range  1 ..   1;
9539       L at 0 range  2 ..  81;
9540       R at 0 range 82 .. 161;
9541    end record;
9542 @end smallexample
9544 @noindent
9545 In GNAT 3, there are more severe restrictions on larger components.
9546 For non-primitive types, including packed arrays with a size greater than
9547 64 bits, component clauses must respect the alignment requirement of the
9548 type, in particular, always starting on a byte boundary, and the length
9549 must be a multiple of the storage unit.
9551 The following rules regarding tagged types are enforced in both GNAT 3 and
9552 GNAT 5:
9554 The tag field of a tagged type always occupies an address sized field at
9555 the start of the record.  No component clause may attempt to overlay this
9556 tag.
9558 In the case of a record extension T1, of a type T, no component clause applied
9559 to the type T1 can specify a storage location that would overlap the first
9560 T'Size bytes of the record.
9562 @node Enumeration Clauses
9563 @section Enumeration Clauses
9565 The only restriction on enumeration clauses is that the range of values
9566 must be representable.  For the signed case, if one or more of the
9567 representation values are negative, all values must be in the range:
9569 @smallexample @c ada
9570    System.Min_Int .. System.Max_Int
9571 @end smallexample
9573 @noindent
9574 For the unsigned case, where all values are non negative, the values must
9575 be in the range:
9577 @smallexample @c ada
9578    0 .. System.Max_Binary_Modulus;
9579 @end smallexample
9581 @noindent
9582 A @emph{confirming} representation clause is one in which the values range
9583 from 0 in sequence, i.e.@: a clause that confirms the default representation
9584 for an enumeration type.
9585 Such a confirming representation
9586 is permitted by these rules, and is specially recognized by the compiler so
9587 that no extra overhead results from the use of such a clause.
9589 If an array has an index type which is an enumeration type to which an
9590 enumeration clause has been applied, then the array is stored in a compact
9591 manner.  Consider the declarations:
9593 @smallexample @c ada
9594    type r is (A, B, C);
9595    for r use (A => 1, B => 5, C => 10);
9596    type t is array (r) of Character;
9597 @end smallexample
9599 @noindent
9600 The array type t corresponds to a vector with exactly three elements and
9601 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9602 use of space, but means that accesses to elements of the array will incur
9603 the overhead of converting representation values to the corresponding
9604 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9606 @node Address Clauses
9607 @section Address Clauses
9608 @cindex Address Clause
9610 The reference manual allows a general restriction on representation clauses,
9611 as found in RM 13.1(22):
9613 @quotation
9614 An implementation need not support representation
9615 items containing nonstatic expressions, except that
9616 an implementation should support a representation item
9617 for a given entity if each nonstatic expression in the
9618 representation item is a name that statically denotes
9619 a constant declared before the entity.
9620 @end quotation
9622 @noindent
9623 In practice this is applicable only to address clauses, since this is the
9624 only case in which a non-static expression is permitted by the syntax.  As
9625 the AARM notes in sections 13.1 (22.a-22.h):
9627 @display
9628   22.a   Reason: This is to avoid the following sort of thing:
9630   22.b        X : Integer := F(@dots{});
9631               Y : Address := G(@dots{});
9632               for X'Address use Y;
9634   22.c   In the above, we have to evaluate the
9635          initialization expression for X before we
9636          know where to put the result.  This seems
9637          like an unreasonable implementation burden.
9639   22.d   The above code should instead be written
9640          like this:
9642   22.e        Y : constant Address := G(@dots{});
9643               X : Integer := F(@dots{});
9644               for X'Address use Y;
9646   22.f   This allows the expression ``Y'' to be safely
9647          evaluated before X is created.
9649   22.g   The constant could be a formal parameter of mode in.
9651   22.h   An implementation can support other nonstatic
9652          expressions if it wants to.  Expressions of type
9653          Address are hardly ever static, but their value
9654          might be known at compile time anyway in many
9655          cases.
9656 @end display
9658 @noindent
9659 GNAT does indeed permit many additional cases of non-static expressions.  In
9660 particular, if the type involved is elementary there are no restrictions
9661 (since in this case, holding a temporary copy of the initialization value,
9662 if one is present, is inexpensive).  In addition, if there is no implicit or
9663 explicit initialization, then there are no restrictions.  GNAT will reject
9664 only the case where all three of these conditions hold:
9666 @itemize @bullet
9668 @item
9669 The type of the item is non-elementary (e.g.@: a record or array).
9671 @item
9672 There is explicit or implicit initialization required for the object.
9673 Note that access values are always implicitly initialized, and also
9674 in GNAT, certain bit-packed arrays (those having a dynamic length or
9675 a length greater than 64) will also be implicitly initialized to zero.
9677 @item
9678 The address value is non-static.  Here GNAT is more permissive than the
9679 RM, and allows the address value to be the address of a previously declared
9680 stand-alone variable, as long as it does not itself have an address clause.
9682 @smallexample @c ada
9683            Anchor  : Some_Initialized_Type;
9684            Overlay : Some_Initialized_Type;
9685            for Overlay'Address use Anchor'Address;
9686 @end smallexample
9688 @noindent
9689 However, the prefix of the address clause cannot be an array component, or
9690 a component of a discriminated record.
9692 @end itemize
9694 @noindent
9695 As noted above in section 22.h, address values are typically non-static.  In
9696 particular the To_Address function, even if applied to a literal value, is
9697 a non-static function call.  To avoid this minor annoyance, GNAT provides
9698 the implementation defined attribute 'To_Address.  The following two
9699 expressions have identical values:
9701 @findex Attribute
9702 @findex To_Address
9703 @smallexample @c ada
9704    To_Address (16#1234_0000#)
9705    System'To_Address (16#1234_0000#);
9706 @end smallexample
9708 @noindent
9709 except that the second form is considered to be a static expression, and
9710 thus when used as an address clause value is always permitted.
9712 @noindent
9713 Additionally, GNAT treats as static an address clause that is an
9714 unchecked_conversion of a static integer value.  This simplifies the porting
9715 of legacy code, and provides a portable equivalent to the GNAT attribute
9716 @code{To_Address}.
9718 Another issue with address clauses is the interaction with alignment
9719 requirements.  When an address clause is given for an object, the address
9720 value must be consistent with the alignment of the object (which is usually
9721 the same as the alignment of the type of the object).  If an address clause
9722 is given that specifies an inappropriately aligned address value, then the
9723 program execution is erroneous.
9725 Since this source of erroneous behavior can have unfortunate effects, GNAT
9726 checks (at compile time if possible, generating a warning, or at execution
9727 time with a run-time check) that the alignment is appropriate.  If the
9728 run-time check fails, then @code{Program_Error} is raised.  This run-time
9729 check is suppressed if range checks are suppressed, or if
9730 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9732 @findex Export
9733 An address clause cannot be given for an exported object.  More
9734 understandably the real restriction is that objects with an address
9735 clause cannot be exported.  This is because such variables are not
9736 defined by the Ada program, so there is no external object to export.
9738 @findex Import
9739 It is permissible to give an address clause and a pragma Import for the
9740 same object.  In this case, the variable is not really defined by the
9741 Ada program, so there is no external symbol to be linked.  The link name
9742 and the external name are ignored in this case.  The reason that we allow this
9743 combination is that it provides a useful idiom to avoid unwanted
9744 initializations on objects with address clauses.
9746 When an address clause is given for an object that has implicit or
9747 explicit initialization, then by default initialization takes place.  This
9748 means that the effect of the object declaration is to overwrite the
9749 memory at the specified address.  This is almost always not what the
9750 programmer wants, so GNAT will output a warning:
9752 @smallexample
9753   with System;
9754   package G is
9755      type R is record
9756         M : Integer := 0;
9757      end record;
9759      Ext : R;
9760      for Ext'Address use System'To_Address (16#1234_1234#);
9761          |
9762   >>> warning: implicit initialization of "Ext" may
9763       modify overlaid storage
9764   >>> warning: use pragma Import for "Ext" to suppress
9765       initialization (RM B(24))
9767   end G;
9768 @end smallexample
9770 @noindent
9771 As indicated by the warning message, the solution is to use a (dummy) pragma
9772 Import to suppress this initialization.  The pragma tell the compiler that the
9773 object is declared and initialized elsewhere.  The following package compiles
9774 without warnings (and the initialization is suppressed):
9776 @smallexample @c ada
9777    with System;
9778    package G is
9779       type R is record
9780          M : Integer := 0;
9781       end record;
9783       Ext : R;
9784       for Ext'Address use System'To_Address (16#1234_1234#);
9785       pragma Import (Ada, Ext);
9786    end G;
9787 @end smallexample
9789 @noindent
9790 A final issue with address clauses involves their use for overlaying
9791 variables, as in the following example:
9792 @cindex Overlaying of objects
9794 @smallexample @c ada
9795   A : Integer;
9796   B : Integer;
9797   for B'Address use A'Address;
9798 @end smallexample
9800 @noindent
9801 or alternatively, using the form recommended by the RM:
9803 @smallexample @c ada
9804   A    : Integer;
9805   Addr : constant Address := A'Address;
9806   B    : Integer;
9807   for B'Address use Addr;
9808 @end smallexample
9810 @noindent
9811 In both of these cases, @code{A}
9812 and @code{B} become aliased to one another via the
9813 address clause. This use of address clauses to overlay
9814 variables, achieving an effect similar to unchecked
9815 conversion was erroneous in Ada 83, but in Ada 95
9816 the effect is implementation defined. Furthermore, the
9817 Ada 95 RM specifically recommends that in a situation
9818 like this, @code{B} should be subject to the following
9819 implementation advice (RM 13.3(19)):
9821 @quotation
9822 19  If the Address of an object is specified, or it is imported
9823     or exported, then the implementation should not perform
9824     optimizations based on assumptions of no aliases.
9825 @end quotation
9827 @noindent
9828 GNAT follows this recommendation, and goes further by also applying
9829 this recommendation to the overlaid variable (@code{A}
9830 in the above example) in this case. This means that the overlay
9831 works "as expected", in that a modification to one of the variables
9832 will affect the value of the other.
9834 @node Effect of Convention on Representation
9835 @section Effect of Convention on Representation
9836 @cindex Convention, effect on representation
9838 @noindent
9839 Normally the specification of a foreign language convention for a type or
9840 an object has no effect on the chosen representation.  In particular, the
9841 representation chosen for data in GNAT generally meets the standard system
9842 conventions, and for example records are laid out in a manner that is
9843 consistent with C@.  This means that specifying convention C (for example)
9844 has no effect.
9846 There are three exceptions to this general rule:
9848 @itemize @bullet
9850 @item Convention Fortran and array subtypes
9851 If pragma Convention Fortran is specified for an array subtype, then in
9852 accordance with the implementation advice in section 3.6.2(11) of the
9853 Ada Reference Manual, the array will be stored in a Fortran-compatible
9854 column-major manner, instead of the normal default row-major order.
9856 @item Convention C and enumeration types
9857 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9858 to accommodate all values of the type.  For example, for the enumeration
9859 type declared by:
9861 @smallexample @c ada
9862    type Color is (Red, Green, Blue);
9863 @end smallexample
9865 @noindent
9866 8 bits is sufficient to store all values of the type, so by default, objects
9867 of type @code{Color} will be represented using 8 bits.  However, normal C
9868 convention is to use 32 bits for all enum values in C, since enum values
9869 are essentially of type int.  If pragma @code{Convention C} is specified for an
9870 Ada enumeration type, then the size is modified as necessary (usually to
9871 32 bits) to be consistent with the C convention for enum values.
9873 @item Convention C/Fortran and Boolean types
9874 In C, the usual convention for boolean values, that is values used for
9875 conditions, is that zero represents false, and nonzero values represent
9876 true.  In Ada, the normal convention is that two specific values, typically
9877 0/1, are used to represent false/true respectively.
9879 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9880 value represents true).
9882 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9883 C or Fortran convention for a derived Boolean, as in the following example:
9885 @smallexample @c ada
9886    type C_Switch is new Boolean;
9887    pragma Convention (C, C_Switch);
9888 @end smallexample
9890 @noindent
9891 then the GNAT generated code will treat any nonzero value as true.  For truth
9892 values generated by GNAT, the conventional value 1 will be used for True, but
9893 when one of these values is read, any nonzero value is treated as True.
9895 @end itemize
9897 @node Determining the Representations chosen by GNAT
9898 @section Determining the Representations chosen by GNAT
9899 @cindex Representation, determination of
9900 @cindex @code{-gnatR} switch
9902 @noindent
9903 Although the descriptions in this section are intended to be complete, it is
9904 often easier to simply experiment to see what GNAT accepts and what the
9905 effect is on the layout of types and objects.
9907 As required by the Ada RM, if a representation clause is not accepted, then
9908 it must be rejected as illegal by the compiler.  However, when a
9909 representation clause or pragma is accepted, there can still be questions
9910 of what the compiler actually does.  For example, if a partial record
9911 representation clause specifies the location of some components and not
9912 others, then where are the non-specified components placed? Or if pragma
9913 @code{Pack} is used on a record, then exactly where are the resulting
9914 fields placed? The section on pragma @code{Pack} in this chapter can be
9915 used to answer the second question, but it is often easier to just see
9916 what the compiler does.
9918 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9919 with this option, then the compiler will output information on the actual
9920 representations chosen, in a format similar to source representation
9921 clauses.  For example, if we compile the package:
9923 @smallexample @c ada
9924 package q is
9925    type r (x : boolean) is tagged record
9926       case x is
9927          when True => S : String (1 .. 100);
9928          when False => null;
9929       end case;
9930    end record;
9932    type r2 is new r (false) with record
9933       y2 : integer;
9934    end record;
9936    for r2 use record
9937       y2 at 16 range 0 .. 31;
9938    end record;
9940    type x is record
9941       y : character;
9942    end record;
9944    type x1 is array (1 .. 10) of x;
9945    for x1'component_size use 11;
9947    type ia is access integer;
9949    type Rb1 is array (1 .. 13) of Boolean;
9950    pragma Pack (rb1);
9952    type Rb2 is array (1 .. 65) of Boolean;
9953    pragma Pack (rb2);
9955    type x2 is record
9956       l1 : Boolean;
9957       l2 : Duration;
9958       l3 : Float;
9959       l4 : Boolean;
9960       l5 : Rb1;
9961       l6 : Rb2;
9962    end record;
9963    pragma Pack (x2);
9964 end q;
9965 @end smallexample
9967 @noindent
9968 using the switch @code{-gnatR} we obtain the following output:
9970 @smallexample
9971 Representation information for unit q
9972 -------------------------------------
9974 for r'Size use ??;
9975 for r'Alignment use 4;
9976 for r use record
9977    x    at 4 range  0 .. 7;
9978    _tag at 0 range  0 .. 31;
9979    s    at 5 range  0 .. 799;
9980 end record;
9982 for r2'Size use 160;
9983 for r2'Alignment use 4;
9984 for r2 use record
9985    x       at  4 range  0 .. 7;
9986    _tag    at  0 range  0 .. 31;
9987    _parent at  0 range  0 .. 63;
9988    y2      at 16 range  0 .. 31;
9989 end record;
9991 for x'Size use 8;
9992 for x'Alignment use 1;
9993 for x use record
9994    y at 0 range  0 .. 7;
9995 end record;
9997 for x1'Size use 112;
9998 for x1'Alignment use 1;
9999 for x1'Component_Size use 11;
10001 for rb1'Size use 13;
10002 for rb1'Alignment use 2;
10003 for rb1'Component_Size use 1;
10005 for rb2'Size use 72;
10006 for rb2'Alignment use 1;
10007 for rb2'Component_Size use 1;
10009 for x2'Size use 224;
10010 for x2'Alignment use 4;
10011 for x2 use record
10012    l1 at  0 range  0 .. 0;
10013    l2 at  0 range  1 .. 64;
10014    l3 at 12 range  0 .. 31;
10015    l4 at 16 range  0 .. 0;
10016    l5 at 16 range  1 .. 13;
10017    l6 at 18 range  0 .. 71;
10018 end record;
10019 @end smallexample
10021 @noindent
10022 The Size values are actually the Object_Size, i.e.@: the default size that
10023 will be allocated for objects of the type.
10024 The ?? size for type r indicates that we have a variant record, and the
10025 actual size of objects will depend on the discriminant value.
10027 The Alignment values show the actual alignment chosen by the compiler
10028 for each record or array type.
10030 The record representation clause for type r shows where all fields
10031 are placed, including the compiler generated tag field (whose location
10032 cannot be controlled by the programmer).
10034 The record representation clause for the type extension r2 shows all the
10035 fields present, including the parent field, which is a copy of the fields
10036 of the parent type of r2, i.e.@: r1.
10038 The component size and size clauses for types rb1 and rb2 show
10039 the exact effect of pragma @code{Pack} on these arrays, and the record
10040 representation clause for type x2 shows how pragma @code{Pack} affects
10041 this record type.
10043 In some cases, it may be useful to cut and paste the representation clauses
10044 generated by the compiler into the original source to fix and guarantee
10045 the actual representation to be used.
10047 @node Standard Library Routines
10048 @chapter Standard Library Routines
10050 @noindent
10051 The Ada 95 Reference Manual contains in Annex A a full description of an
10052 extensive set of standard library routines that can be used in any Ada
10053 program, and which must be provided by all Ada compilers.  They are
10054 analogous to the standard C library used by C programs.
10056 GNAT implements all of the facilities described in annex A, and for most
10057 purposes the description in the Ada 95
10058 reference manual, or appropriate Ada
10059 text book, will be sufficient for making use of these facilities.
10061 In the case of the input-output facilities, @xref{The Implementation of
10062 Standard I/O}, gives details on exactly how GNAT interfaces to the
10063 file system.  For the remaining packages, the Ada 95 reference manual
10064 should be sufficient.  The following is a list of the packages included,
10065 together with a brief description of the functionality that is provided.
10067 For completeness, references are included to other predefined library
10068 routines defined in other sections of the Ada 95 reference manual (these are
10069 cross-indexed from annex A).
10071 @table @code
10072 @item Ada (A.2)
10073 This is a parent package for all the standard library packages.  It is
10074 usually included implicitly in your program, and itself contains no
10075 useful data or routines.
10077 @item Ada.Calendar (9.6)
10078 @code{Calendar} provides time of day access, and routines for
10079 manipulating times and durations.
10081 @item Ada.Characters (A.3.1)
10082 This is a dummy parent package that contains no useful entities
10084 @item Ada.Characters.Handling (A.3.2)
10085 This package provides some basic character handling capabilities,
10086 including classification functions for classes of characters (e.g.@: test
10087 for letters, or digits).
10089 @item Ada.Characters.Latin_1 (A.3.3)
10090 This package includes a complete set of definitions of the characters
10091 that appear in type CHARACTER@.  It is useful for writing programs that
10092 will run in international environments.  For example, if you want an
10093 upper case E with an acute accent in a string, it is often better to use
10094 the definition of @code{UC_E_Acute} in this package.  Then your program
10095 will print in an understandable manner even if your environment does not
10096 support these extended characters.
10098 @item Ada.Command_Line (A.15)
10099 This package provides access to the command line parameters and the name
10100 of the current program (analogous to the use of @code{argc} and @code{argv}
10101 in C), and also allows the exit status for the program to be set in a
10102 system-independent manner.
10104 @item Ada.Decimal (F.2)
10105 This package provides constants describing the range of decimal numbers
10106 implemented, and also a decimal divide routine (analogous to the COBOL
10107 verb DIVIDE .. GIVING .. REMAINDER ..)
10109 @item Ada.Direct_IO (A.8.4)
10110 This package provides input-output using a model of a set of records of
10111 fixed-length, containing an arbitrary definite Ada type, indexed by an
10112 integer record number.
10114 @item Ada.Dynamic_Priorities (D.5)
10115 This package allows the priorities of a task to be adjusted dynamically
10116 as the task is running.
10118 @item Ada.Exceptions (11.4.1)
10119 This package provides additional information on exceptions, and also
10120 contains facilities for treating exceptions as data objects, and raising
10121 exceptions with associated messages.
10123 @item Ada.Finalization (7.6)
10124 This package contains the declarations and subprograms to support the
10125 use of controlled types, providing for automatic initialization and
10126 finalization (analogous to the constructors and destructors of C++)
10128 @item Ada.Interrupts (C.3.2)
10129 This package provides facilities for interfacing to interrupts, which
10130 includes the set of signals or conditions that can be raised and
10131 recognized as interrupts.
10133 @item Ada.Interrupts.Names (C.3.2)
10134 This package provides the set of interrupt names (actually signal
10135 or condition names) that can be handled by GNAT@.
10137 @item Ada.IO_Exceptions (A.13)
10138 This package defines the set of exceptions that can be raised by use of
10139 the standard IO packages.
10141 @item Ada.Numerics
10142 This package contains some standard constants and exceptions used
10143 throughout the numerics packages.  Note that the constants pi and e are
10144 defined here, and it is better to use these definitions than rolling
10145 your own.
10147 @item Ada.Numerics.Complex_Elementary_Functions
10148 Provides the implementation of standard elementary functions (such as
10149 log and trigonometric functions) operating on complex numbers using the
10150 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10151 created by the package @code{Numerics.Complex_Types}.
10153 @item Ada.Numerics.Complex_Types
10154 This is a predefined instantiation of
10155 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10156 build the type @code{Complex} and @code{Imaginary}.
10158 @item Ada.Numerics.Discrete_Random
10159 This package provides a random number generator suitable for generating
10160 random integer values from a specified range.
10162 @item Ada.Numerics.Float_Random
10163 This package provides a random number generator suitable for generating
10164 uniformly distributed floating point values.
10166 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10167 This is a generic version of the package that provides the
10168 implementation of standard elementary functions (such as log and
10169 trigonometric functions) for an arbitrary complex type.
10171 The following predefined instantiations of this package are provided:
10173 @table @code
10174 @item Short_Float
10175 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10176 @item Float
10177 @code{Ada.Numerics.Complex_Elementary_Functions}
10178 @item Long_Float
10179 @code{Ada.Numerics.
10180  Long_Complex_Elementary_Functions}
10181 @end table
10183 @item Ada.Numerics.Generic_Complex_Types
10184 This is a generic package that allows the creation of complex types,
10185 with associated complex arithmetic operations.
10187 The following predefined instantiations of this package exist
10188 @table @code
10189 @item Short_Float
10190 @code{Ada.Numerics.Short_Complex_Complex_Types}
10191 @item Float
10192 @code{Ada.Numerics.Complex_Complex_Types}
10193 @item Long_Float
10194 @code{Ada.Numerics.Long_Complex_Complex_Types}
10195 @end table
10197 @item Ada.Numerics.Generic_Elementary_Functions
10198 This is a generic package that provides the implementation of standard
10199 elementary functions (such as log an trigonometric functions) for an
10200 arbitrary float type.
10202 The following predefined instantiations of this package exist
10204 @table @code
10205 @item Short_Float
10206 @code{Ada.Numerics.Short_Elementary_Functions}
10207 @item Float
10208 @code{Ada.Numerics.Elementary_Functions}
10209 @item Long_Float
10210 @code{Ada.Numerics.Long_Elementary_Functions}
10211 @end table
10213 @item Ada.Real_Time (D.8)
10214 This package provides facilities similar to those of @code{Calendar}, but
10215 operating with a finer clock suitable for real time control. Note that
10216 annex D requires that there be no backward clock jumps, and GNAT generally
10217 guarantees this behavior, but of course if the external clock on which
10218 the GNAT runtime depends is deliberately reset by some external event,
10219 then such a backward jump may occur.
10221 @item Ada.Sequential_IO (A.8.1)
10222 This package provides input-output facilities for sequential files,
10223 which can contain a sequence of values of a single type, which can be
10224 any Ada type, including indefinite (unconstrained) types.
10226 @item Ada.Storage_IO (A.9)
10227 This package provides a facility for mapping arbitrary Ada types to and
10228 from a storage buffer.  It is primarily intended for the creation of new
10229 IO packages.
10231 @item Ada.Streams (13.13.1)
10232 This is a generic package that provides the basic support for the
10233 concept of streams as used by the stream attributes (@code{Input},
10234 @code{Output}, @code{Read} and @code{Write}).
10236 @item Ada.Streams.Stream_IO (A.12.1)
10237 This package is a specialization of the type @code{Streams} defined in
10238 package @code{Streams} together with a set of operations providing
10239 Stream_IO capability.  The Stream_IO model permits both random and
10240 sequential access to a file which can contain an arbitrary set of values
10241 of one or more Ada types.
10243 @item Ada.Strings (A.4.1)
10244 This package provides some basic constants used by the string handling
10245 packages.
10247 @item Ada.Strings.Bounded (A.4.4)
10248 This package provides facilities for handling variable length
10249 strings.  The bounded model requires a maximum length.  It is thus
10250 somewhat more limited than the unbounded model, but avoids the use of
10251 dynamic allocation or finalization.
10253 @item Ada.Strings.Fixed (A.4.3)
10254 This package provides facilities for handling fixed length strings.
10256 @item Ada.Strings.Maps (A.4.2)
10257 This package provides facilities for handling character mappings and
10258 arbitrarily defined subsets of characters.  For instance it is useful in
10259 defining specialized translation tables.
10261 @item Ada.Strings.Maps.Constants (A.4.6)
10262 This package provides a standard set of predefined mappings and
10263 predefined character sets.  For example, the standard upper to lower case
10264 conversion table is found in this package.  Note that upper to lower case
10265 conversion is non-trivial if you want to take the entire set of
10266 characters, including extended characters like E with an acute accent,
10267 into account.  You should use the mappings in this package (rather than
10268 adding 32 yourself) to do case mappings.
10270 @item Ada.Strings.Unbounded (A.4.5)
10271 This package provides facilities for handling variable length
10272 strings.  The unbounded model allows arbitrary length strings, but
10273 requires the use of dynamic allocation and finalization.
10275 @item Ada.Strings.Wide_Bounded (A.4.7)
10276 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10277 @itemx Ada.Strings.Wide_Maps (A.4.7)
10278 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10279 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10280 These packages provide analogous capabilities to the corresponding
10281 packages without @samp{Wide_} in the name, but operate with the types
10282 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10283 and @code{Character}.
10285 @item Ada.Synchronous_Task_Control (D.10)
10286 This package provides some standard facilities for controlling task
10287 communication in a synchronous manner.
10289 @item Ada.Tags
10290 This package contains definitions for manipulation of the tags of tagged
10291 values.
10293 @item Ada.Task_Attributes
10294 This package provides the capability of associating arbitrary
10295 task-specific data with separate tasks.
10297 @item Ada.Text_IO
10298 This package provides basic text input-output capabilities for
10299 character, string and numeric data.  The subpackages of this
10300 package are listed next.
10302 @item Ada.Text_IO.Decimal_IO
10303 Provides input-output facilities for decimal fixed-point types
10305 @item Ada.Text_IO.Enumeration_IO
10306 Provides input-output facilities for enumeration types.
10308 @item Ada.Text_IO.Fixed_IO
10309 Provides input-output facilities for ordinary fixed-point types.
10311 @item Ada.Text_IO.Float_IO
10312 Provides input-output facilities for float types.  The following
10313 predefined instantiations of this generic package are available:
10315 @table @code
10316 @item Short_Float
10317 @code{Short_Float_Text_IO}
10318 @item Float
10319 @code{Float_Text_IO}
10320 @item Long_Float
10321 @code{Long_Float_Text_IO}
10322 @end table
10324 @item Ada.Text_IO.Integer_IO
10325 Provides input-output facilities for integer types.  The following
10326 predefined instantiations of this generic package are available:
10328 @table @code
10329 @item Short_Short_Integer
10330 @code{Ada.Short_Short_Integer_Text_IO}
10331 @item Short_Integer
10332 @code{Ada.Short_Integer_Text_IO}
10333 @item Integer
10334 @code{Ada.Integer_Text_IO}
10335 @item Long_Integer
10336 @code{Ada.Long_Integer_Text_IO}
10337 @item Long_Long_Integer
10338 @code{Ada.Long_Long_Integer_Text_IO}
10339 @end table
10341 @item Ada.Text_IO.Modular_IO
10342 Provides input-output facilities for modular (unsigned) types
10344 @item Ada.Text_IO.Complex_IO (G.1.3)
10345 This package provides basic text input-output capabilities for complex
10346 data.
10348 @item Ada.Text_IO.Editing (F.3.3)
10349 This package contains routines for edited output, analogous to the use
10350 of pictures in COBOL@.  The picture formats used by this package are a
10351 close copy of the facility in COBOL@.
10353 @item Ada.Text_IO.Text_Streams (A.12.2)
10354 This package provides a facility that allows Text_IO files to be treated
10355 as streams, so that the stream attributes can be used for writing
10356 arbitrary data, including binary data, to Text_IO files.
10358 @item Ada.Unchecked_Conversion (13.9)
10359 This generic package allows arbitrary conversion from one type to
10360 another of the same size, providing for breaking the type safety in
10361 special circumstances.
10363 If the types have the same Size (more accurately the same Value_Size),
10364 then the effect is simply to transfer the bits from the source to the
10365 target type without any modification.  This usage is well defined, and
10366 for simple types whose representation is typically the same across
10367 all implementations, gives a portable method of performing such
10368 conversions.
10370 If the types do not have the same size, then the result is implementation
10371 defined, and thus may be non-portable.  The following describes how GNAT
10372 handles such unchecked conversion cases.
10374 If the types are of different sizes, and are both discrete types, then
10375 the effect is of a normal type conversion without any constraint checking.
10376 In particular if the result type has a larger size, the result will be
10377 zero or sign extended.  If the result type has a smaller size, the result
10378 will be truncated by ignoring high order bits.
10380 If the types are of different sizes, and are not both discrete types,
10381 then the conversion works as though pointers were created to the source
10382 and target, and the pointer value is converted.  The effect is that bits
10383 are copied from successive low order storage units and bits of the source
10384 up to the length of the target type.
10386 A warning is issued if the lengths differ, since the effect in this
10387 case is implementation dependent, and the above behavior may not match
10388 that of some other compiler.
10390 A pointer to one type may be converted to a pointer to another type using
10391 unchecked conversion.  The only case in which the effect is undefined is
10392 when one or both pointers are pointers to unconstrained array types.  In
10393 this case, the bounds information may get incorrectly transferred, and in
10394 particular, GNAT uses double size pointers for such types, and it is
10395 meaningless to convert between such pointer types.  GNAT will issue a
10396 warning if the alignment of the target designated type is more strict
10397 than the alignment of the source designated type (since the result may
10398 be unaligned in this case).
10400 A pointer other than a pointer to an unconstrained array type may be
10401 converted to and from System.Address.  Such usage is common in Ada 83
10402 programs, but note that Ada.Address_To_Access_Conversions is the
10403 preferred method of performing such conversions in Ada 95.  Neither
10404 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10405 used in conjunction with pointers to unconstrained objects, since
10406 the bounds information cannot be handled correctly in this case.
10408 @item Ada.Unchecked_Deallocation (13.11.2)
10409 This generic package allows explicit freeing of storage previously
10410 allocated by use of an allocator.
10412 @item Ada.Wide_Text_IO (A.11)
10413 This package is similar to @code{Ada.Text_IO}, except that the external
10414 file supports wide character representations, and the internal types are
10415 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10416 and @code{String}.  It contains generic subpackages listed next.
10418 @item Ada.Wide_Text_IO.Decimal_IO
10419 Provides input-output facilities for decimal fixed-point types
10421 @item Ada.Wide_Text_IO.Enumeration_IO
10422 Provides input-output facilities for enumeration types.
10424 @item Ada.Wide_Text_IO.Fixed_IO
10425 Provides input-output facilities for ordinary fixed-point types.
10427 @item Ada.Wide_Text_IO.Float_IO
10428 Provides input-output facilities for float types.  The following
10429 predefined instantiations of this generic package are available:
10431 @table @code
10432 @item Short_Float
10433 @code{Short_Float_Wide_Text_IO}
10434 @item Float
10435 @code{Float_Wide_Text_IO}
10436 @item Long_Float
10437 @code{Long_Float_Wide_Text_IO}
10438 @end table
10440 @item Ada.Wide_Text_IO.Integer_IO
10441 Provides input-output facilities for integer types.  The following
10442 predefined instantiations of this generic package are available:
10444 @table @code
10445 @item Short_Short_Integer
10446 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10447 @item Short_Integer
10448 @code{Ada.Short_Integer_Wide_Text_IO}
10449 @item Integer
10450 @code{Ada.Integer_Wide_Text_IO}
10451 @item Long_Integer
10452 @code{Ada.Long_Integer_Wide_Text_IO}
10453 @item Long_Long_Integer
10454 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10455 @end table
10457 @item Ada.Wide_Text_IO.Modular_IO
10458 Provides input-output facilities for modular (unsigned) types
10460 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10461 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10462 external file supports wide character representations.
10464 @item Ada.Wide_Text_IO.Editing (F.3.4)
10465 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10466 types are @code{Wide_Character} and @code{Wide_String} instead of
10467 @code{Character} and @code{String}.
10469 @item Ada.Wide_Text_IO.Streams (A.12.3)
10470 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10471 types are @code{Wide_Character} and @code{Wide_String} instead of
10472 @code{Character} and @code{String}.
10473 @end table
10475 @node The Implementation of Standard I/O
10476 @chapter The Implementation of Standard I/O
10478 @noindent
10479 GNAT implements all the required input-output facilities described in
10480 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10481 required behavior of these packages from the Ada point of view, and if
10482 you are writing a portable Ada program that does not need to know the
10483 exact manner in which Ada maps to the outside world when it comes to
10484 reading or writing external files, then you do not need to read this
10485 chapter.  As long as your files are all regular files (not pipes or
10486 devices), and as long as you write and read the files only from Ada, the
10487 description in the Ada 95 reference manual is sufficient.
10489 However, if you want to do input-output to pipes or other devices, such
10490 as the keyboard or screen, or if the files you are dealing with are
10491 either generated by some other language, or to be read by some other
10492 language, then you need to know more about the details of how the GNAT
10493 implementation of these input-output facilities behaves.
10495 In this chapter we give a detailed description of exactly how GNAT
10496 interfaces to the file system.  As always, the sources of the system are
10497 available to you for answering questions at an even more detailed level,
10498 but for most purposes the information in this chapter will suffice.
10500 Another reason that you may need to know more about how input-output is
10501 implemented arises when you have a program written in mixed languages
10502 where, for example, files are shared between the C and Ada sections of
10503 the same program.  GNAT provides some additional facilities, in the form
10504 of additional child library packages, that facilitate this sharing, and
10505 these additional facilities are also described in this chapter.
10507 @menu
10508 * Standard I/O Packages::
10509 * FORM Strings::
10510 * Direct_IO::
10511 * Sequential_IO::
10512 * Text_IO::
10513 * Wide_Text_IO::
10514 * Stream_IO::
10515 * Shared Files::
10516 * Open Modes::
10517 * Operations on C Streams::
10518 * Interfacing to C Streams::
10519 @end menu
10521 @node Standard I/O Packages
10522 @section Standard I/O Packages
10524 @noindent
10525 The Standard I/O packages described in Annex A for
10527 @itemize @bullet
10528 @item
10529 Ada.Text_IO
10530 @item
10531 Ada.Text_IO.Complex_IO
10532 @item
10533 Ada.Text_IO.Text_Streams,
10534 @item
10535 Ada.Wide_Text_IO
10536 @item
10537 Ada.Wide_Text_IO.Complex_IO,
10538 @item
10539 Ada.Wide_Text_IO.Text_Streams
10540 @item
10541 Ada.Stream_IO
10542 @item
10543 Ada.Sequential_IO
10544 @item
10545 Ada.Direct_IO
10546 @end itemize
10548 @noindent
10549 are implemented using the C
10550 library streams facility; where
10552 @itemize @bullet
10553 @item
10554 All files are opened using @code{fopen}.
10555 @item
10556 All input/output operations use @code{fread}/@code{fwrite}.
10557 @end itemize
10559 @noindent
10560 There is no internal buffering of any kind at the Ada library level.  The
10561 only buffering is that provided at the system level in the
10562 implementation of the C library routines that support streams.  This
10563 facilitates shared use of these streams by mixed language programs.
10565 @node FORM Strings
10566 @section FORM Strings
10568 @noindent
10569 The format of a FORM string in GNAT is:
10571 @smallexample
10572 "keyword=value,keyword=value,@dots{},keyword=value"
10573 @end smallexample
10575 @noindent
10576 where letters may be in upper or lower case, and there are no spaces
10577 between values.  The order of the entries is not important.  Currently
10578 there are two keywords defined.
10580 @smallexample
10581 SHARED=[YES|NO]
10582 WCEM=[n|h|u|s\e]
10583 @end smallexample
10585 @noindent
10586 The use of these parameters is described later in this section.
10588 @node Direct_IO
10589 @section Direct_IO
10591 @noindent
10592 Direct_IO can only be instantiated for definite types.  This is a
10593 restriction of the Ada language, which means that the records are fixed
10594 length (the length being determined by @code{@var{type}'Size}, rounded
10595 up to the next storage unit boundary if necessary).
10597 The records of a Direct_IO file are simply written to the file in index
10598 sequence, with the first record starting at offset zero, and subsequent
10599 records following.  There is no control information of any kind.  For
10600 example, if 32-bit integers are being written, each record takes
10601 4-bytes, so the record at index @var{K} starts at offset
10602 (@var{K}@minus{}1)*4.
10604 There is no limit on the size of Direct_IO files, they are expanded as
10605 necessary to accommodate whatever records are written to the file.
10607 @node Sequential_IO
10608 @section Sequential_IO
10610 @noindent
10611 Sequential_IO may be instantiated with either a definite (constrained)
10612 or indefinite (unconstrained) type.
10614 For the definite type case, the elements written to the file are simply
10615 the memory images of the data values with no control information of any
10616 kind.  The resulting file should be read using the same type, no validity
10617 checking is performed on input.
10619 For the indefinite type case, the elements written consist of two
10620 parts.  First is the size of the data item, written as the memory image
10621 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10622 the data value.  The resulting file can only be read using the same
10623 (unconstrained) type.  Normal assignment checks are performed on these
10624 read operations, and if these checks fail, @code{Data_Error} is
10625 raised.  In particular, in the array case, the lengths must match, and in
10626 the variant record case, if the variable for a particular read operation
10627 is constrained, the discriminants must match.
10629 Note that it is not possible to use Sequential_IO to write variable
10630 length array items, and then read the data back into different length
10631 arrays.  For example, the following will raise @code{Data_Error}:
10633 @smallexample @c ada
10634  package IO is new Sequential_IO (String);
10635  F : IO.File_Type;
10636  S : String (1..4);
10637  @dots{}
10638  IO.Create (F)
10639  IO.Write (F, "hello!")
10640  IO.Reset (F, Mode=>In_File);
10641  IO.Read (F, S);
10642  Put_Line (S);
10644 @end smallexample
10646 @noindent
10647 On some Ada implementations, this will print @code{hell}, but the program is
10648 clearly incorrect, since there is only one element in the file, and that
10649 element is the string @code{hello!}.
10651 In Ada 95, this kind of behavior can be legitimately achieved using
10652 Stream_IO, and this is the preferred mechanism.  In particular, the above
10653 program fragment rewritten to use Stream_IO will work correctly.
10655 @node Text_IO
10656 @section Text_IO
10658 @noindent
10659 Text_IO files consist of a stream of characters containing the following
10660 special control characters:
10662 @smallexample
10663 LF (line feed, 16#0A#) Line Mark
10664 FF (form feed, 16#0C#) Page Mark
10665 @end smallexample
10667 @noindent
10668 A canonical Text_IO file is defined as one in which the following
10669 conditions are met:
10671 @itemize @bullet
10672 @item
10673 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10674 of the line.
10676 @item
10677 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10678 end of a page and consequently can appear only immediately following a
10679 @code{LF} (line mark) character.
10681 @item
10682 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10683 (line mark, page mark).  In the former case, the page mark is implicitly
10684 assumed to be present.
10685 @end itemize
10687 @noindent
10688 A file written using Text_IO will be in canonical form provided that no
10689 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10690 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10691 the file unless an explicit @code{New_Page} operation was performed
10692 before closing the file.
10694 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10695 pipe, can be read using any of the routines in Text_IO@.  The
10696 semantics in this case will be exactly as defined in the Ada 95 reference
10697 manual and all the routines in Text_IO are fully implemented.
10699 A text file that does not meet the requirements for a canonical Text_IO
10700 file has one of the following:
10702 @itemize @bullet
10703 @item
10704 The file contains @code{FF} characters not immediately following a
10705 @code{LF} character.
10707 @item
10708 The file contains @code{LF} or @code{FF} characters written by
10709 @code{Put} or @code{Put_Line}, which are not logically considered to be
10710 line marks or page marks.
10712 @item
10713 The file ends in a character other than @code{LF} or @code{FF},
10714 i.e.@: there is no explicit line mark or page mark at the end of the file.
10715 @end itemize
10717 @noindent
10718 Text_IO can be used to read such non-standard text files but subprograms
10719 to do with line or page numbers do not have defined meanings.  In
10720 particular, a @code{FF} character that does not follow a @code{LF}
10721 character may or may not be treated as a page mark from the point of
10722 view of page and line numbering.  Every @code{LF} character is considered
10723 to end a line, and there is an implied @code{LF} character at the end of
10724 the file.
10726 @menu
10727 * Text_IO Stream Pointer Positioning::
10728 * Text_IO Reading and Writing Non-Regular Files::
10729 * Get_Immediate::
10730 * Treating Text_IO Files as Streams::
10731 * Text_IO Extensions::
10732 * Text_IO Facilities for Unbounded Strings::
10733 @end menu
10735 @node Text_IO Stream Pointer Positioning
10736 @subsection Stream Pointer Positioning
10738 @noindent
10739 @code{Ada.Text_IO} has a definition of current position for a file that
10740 is being read.  No internal buffering occurs in Text_IO, and usually the
10741 physical position in the stream used to implement the file corresponds
10742 to this logical position defined by Text_IO@.  There are two exceptions:
10744 @itemize @bullet
10745 @item
10746 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10747 is positioned past the @code{LF} (line mark) that precedes the page
10748 mark.  Text_IO maintains an internal flag so that subsequent read
10749 operations properly handle the logical position which is unchanged by
10750 the @code{End_Of_Page} call.
10752 @item
10753 After a call to @code{End_Of_File} that returns @code{True}, if the
10754 Text_IO file was positioned before the line mark at the end of file
10755 before the call, then the logical position is unchanged, but the stream
10756 is physically positioned right at the end of file (past the line mark,
10757 and past a possible page mark following the line mark.  Again Text_IO
10758 maintains internal flags so that subsequent read operations properly
10759 handle the logical position.
10760 @end itemize
10762 @noindent
10763 These discrepancies have no effect on the observable behavior of
10764 Text_IO, but if a single Ada stream is shared between a C program and
10765 Ada program, or shared (using @samp{shared=yes} in the form string)
10766 between two Ada files, then the difference may be observable in some
10767 situations.
10769 @node Text_IO Reading and Writing Non-Regular Files
10770 @subsection Reading and Writing Non-Regular Files
10772 @noindent
10773 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10774 can be used for reading and writing.  Writing is not affected and the
10775 sequence of characters output is identical to the normal file case, but
10776 for reading, the behavior of Text_IO is modified to avoid undesirable
10777 look-ahead as follows:
10779 An input file that is not a regular file is considered to have no page
10780 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10781 page mark) appearing in the file are considered to be data
10782 characters.  In particular:
10784 @itemize @bullet
10785 @item
10786 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10787 following a line mark.  If a page mark appears, it will be treated as a
10788 data character.
10790 @item
10791 This avoids the need to wait for an extra character to be typed or
10792 entered from the pipe to complete one of these operations.
10794 @item
10795 @code{End_Of_Page} always returns @code{False}
10797 @item
10798 @code{End_Of_File} will return @code{False} if there is a page mark at
10799 the end of the file.
10800 @end itemize
10802 @noindent
10803 Output to non-regular files is the same as for regular files.  Page marks
10804 may be written to non-regular files using @code{New_Page}, but as noted
10805 above they will not be treated as page marks on input if the output is
10806 piped to another Ada program.
10808 Another important discrepancy when reading non-regular files is that the end
10809 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10810 pressing the @key{EOT} key,
10811 then end of file
10812 is signaled once (i.e.@: the test @code{End_Of_File}
10813 will yield @code{True}, or a read will
10814 raise @code{End_Error}), but then reading can resume
10815 to read data past that end of
10816 file indication, until another end of file indication is entered.
10818 @node Get_Immediate
10819 @subsection Get_Immediate
10820 @cindex Get_Immediate
10822 @noindent
10823 Get_Immediate returns the next character (including control characters)
10824 from the input file.  In particular, Get_Immediate will return LF or FF
10825 characters used as line marks or page marks.  Such operations leave the
10826 file positioned past the control character, and it is thus not treated
10827 as having its normal function.  This means that page, line and column
10828 counts after this kind of Get_Immediate call are set as though the mark
10829 did not occur.  In the case where a Get_Immediate leaves the file
10830 positioned between the line mark and page mark (which is not normally
10831 possible), it is undefined whether the FF character will be treated as a
10832 page mark.
10834 @node Treating Text_IO Files as Streams
10835 @subsection Treating Text_IO Files as Streams
10836 @cindex Stream files
10838 @noindent
10839 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10840 as a stream.  Data written to a Text_IO file in this stream mode is
10841 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10842 16#0C# (@code{FF}), the resulting file may have non-standard
10843 format.  Similarly if read operations are used to read from a Text_IO
10844 file treated as a stream, then @code{LF} and @code{FF} characters may be
10845 skipped and the effect is similar to that described above for
10846 @code{Get_Immediate}.
10848 @node Text_IO Extensions
10849 @subsection Text_IO Extensions
10850 @cindex Text_IO extensions
10852 @noindent
10853 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10854 to the standard @code{Text_IO} package:
10856 @itemize @bullet
10857 @item function File_Exists (Name : String) return Boolean;
10858 Determines if a file of the given name exists.
10860 @item function Get_Line return String;
10861 Reads a string from the standard input file.  The value returned is exactly
10862 the length of the line that was read.
10864 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10865 Similar, except that the parameter File specifies the file from which
10866 the string is to be read.
10868 @end itemize
10870 @node Text_IO Facilities for Unbounded Strings
10871 @subsection Text_IO Facilities for Unbounded Strings
10872 @cindex Text_IO for unbounded strings
10873 @cindex Unbounded_String, Text_IO operations
10875 @noindent
10876 The package @code{Ada.Strings.Unbounded.Text_IO}
10877 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10878 subprograms useful for Text_IO operations on unbounded strings:
10880 @itemize @bullet
10882 @item function Get_Line (File : File_Type) return Unbounded_String;
10883 Reads a line from the specified file
10884 and returns the result as an unbounded string.
10886 @item procedure Put (File : File_Type; U : Unbounded_String);
10887 Writes the value of the given unbounded string to the specified file
10888 Similar to the effect of
10889 @code{Put (To_String (U))} except that an extra copy is avoided.
10891 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10892 Writes the value of the given unbounded string to the specified file,
10893 followed by a @code{New_Line}.
10894 Similar to the effect of @code{Put_Line (To_String (U))} except
10895 that an extra copy is avoided.
10896 @end itemize
10898 @noindent
10899 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10900 and is optional.  If the parameter is omitted, then the standard input or
10901 output file is referenced as appropriate.
10903 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10904 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10905 @code{Wide_Text_IO} functionality for unbounded wide strings.
10907 @node Wide_Text_IO
10908 @section Wide_Text_IO
10910 @noindent
10911 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10912 both input and output files may contain special sequences that represent
10913 wide character values.  The encoding scheme for a given file may be
10914 specified using a FORM parameter:
10916 @smallexample
10917 WCEM=@var{x}
10918 @end smallexample
10920 @noindent
10921 as part of the FORM string (WCEM = wide character encoding method),
10922 where @var{x} is one of the following characters
10924 @table @samp
10925 @item h
10926 Hex ESC encoding
10927 @item u
10928 Upper half encoding
10929 @item s
10930 Shift-JIS encoding
10931 @item e
10932 EUC Encoding
10933 @item 8
10934 UTF-8 encoding
10935 @item b
10936 Brackets encoding
10937 @end table
10939 @noindent
10940 The encoding methods match those that
10941 can be used in a source
10942 program, but there is no requirement that the encoding method used for
10943 the source program be the same as the encoding method used for files,
10944 and different files may use different encoding methods.
10946 The default encoding method for the standard files, and for opened files
10947 for which no WCEM parameter is given in the FORM string matches the
10948 wide character encoding specified for the main program (the default
10949 being brackets encoding if no coding method was specified with -gnatW).
10951 @table @asis
10952 @item Hex Coding
10953 In this encoding, a wide character is represented by a five character
10954 sequence:
10956 @smallexample
10957 ESC a b c d
10958 @end smallexample
10960 @noindent
10961 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10962 characters (using upper case letters) of the wide character code.  For
10963 example, ESC A345 is used to represent the wide character with code
10964 16#A345#.  This scheme is compatible with use of the full
10965 @code{Wide_Character} set.
10967 @item Upper Half Coding
10968 The wide character with encoding 16#abcd#, where the upper bit is on
10969 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10970 16#cd#.  The second byte may never be a format control character, but is
10971 not required to be in the upper half.  This method can be also used for
10972 shift-JIS or EUC where the internal coding matches the external coding.
10974 @item Shift JIS Coding
10975 A wide character is represented by a two character sequence 16#ab# and
10976 16#cd#, with the restrictions described for upper half encoding as
10977 described above.  The internal character code is the corresponding JIS
10978 character according to the standard algorithm for Shift-JIS
10979 conversion.  Only characters defined in the JIS code set table can be
10980 used with this encoding method.
10982 @item EUC Coding
10983 A wide character is represented by a two character sequence 16#ab# and
10984 16#cd#, with both characters being in the upper half.  The internal
10985 character code is the corresponding JIS character according to the EUC
10986 encoding algorithm.  Only characters defined in the JIS code set table
10987 can be used with this encoding method.
10989 @item UTF-8 Coding
10990 A wide character is represented using
10991 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10992 10646-1/Am.2.  Depending on the character value, the representation
10993 is a one, two, or three byte sequence:
10995 @smallexample
10996 16#0000#-16#007f#: 2#0xxxxxxx#
10997 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10998 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10999 @end smallexample
11001 @noindent
11002 where the xxx bits correspond to the left-padded bits of the
11003 16-bit character value.  Note that all lower half ASCII characters
11004 are represented as ASCII bytes and all upper half characters and
11005 other wide characters are represented as sequences of upper-half
11006 (The full UTF-8 scheme allows for encoding 31-bit characters as
11007 6-byte sequences, but in this implementation, all UTF-8 sequences
11008 of four or more bytes length will raise a Constraint_Error, as
11009 will all invalid UTF-8 sequences.)
11011 @item Brackets Coding
11012 In this encoding, a wide character is represented by the following eight
11013 character sequence:
11015 @smallexample
11016 [ " a b c d " ]
11017 @end smallexample
11019 @noindent
11020 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11021 characters (using uppercase letters) of the wide character code.  For
11022 example, @code{["A345"]} is used to represent the wide character with code
11023 @code{16#A345#}.
11024 This scheme is compatible with use of the full Wide_Character set.
11025 On input, brackets coding can also be used for upper half characters,
11026 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11027 is only used for wide characters with a code greater than @code{16#FF#}.
11029 @end table
11031 @noindent
11032 For the coding schemes other than Hex and Brackets encoding,
11033 not all wide character
11034 values can be represented.  An attempt to output a character that cannot
11035 be represented using the encoding scheme for the file causes
11036 Constraint_Error to be raised.  An invalid wide character sequence on
11037 input also causes Constraint_Error to be raised.
11039 @menu
11040 * Wide_Text_IO Stream Pointer Positioning::
11041 * Wide_Text_IO Reading and Writing Non-Regular Files::
11042 @end menu
11044 @node Wide_Text_IO Stream Pointer Positioning
11045 @subsection Stream Pointer Positioning
11047 @noindent
11048 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11049 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11050 case:
11052 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11053 normal lower ASCII set (i.e.@: a character in the range:
11055 @smallexample @c ada
11056 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11057 @end smallexample
11059 @noindent
11060 then although the logical position of the file pointer is unchanged by
11061 the @code{Look_Ahead} call, the stream is physically positioned past the
11062 wide character sequence.  Again this is to avoid the need for buffering
11063 or backup, and all @code{Wide_Text_IO} routines check the internal
11064 indication that this situation has occurred so that this is not visible
11065 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11066 can be observed if the wide text file shares a stream with another file.
11068 @node Wide_Text_IO Reading and Writing Non-Regular Files
11069 @subsection Reading and Writing Non-Regular Files
11071 @noindent
11072 As in the case of Text_IO, when a non-regular file is read, it is
11073 assumed that the file contains no page marks (any form characters are
11074 treated as data characters), and @code{End_Of_Page} always returns
11075 @code{False}.  Similarly, the end of file indication is not sticky, so
11076 it is possible to read beyond an end of file.
11078 @node Stream_IO
11079 @section Stream_IO
11081 @noindent
11082 A stream file is a sequence of bytes, where individual elements are
11083 written to the file as described in the Ada 95 reference manual.  The type
11084 @code{Stream_Element} is simply a byte.  There are two ways to read or
11085 write a stream file.
11087 @itemize @bullet
11088 @item
11089 The operations @code{Read} and @code{Write} directly read or write a
11090 sequence of stream elements with no control information.
11092 @item
11093 The stream attributes applied to a stream file transfer data in the
11094 manner described for stream attributes.
11095 @end itemize
11097 @node Shared Files
11098 @section Shared Files
11100 @noindent
11101 Section A.14 of the Ada 95 Reference Manual allows implementations to
11102 provide a wide variety of behavior if an attempt is made to access the
11103 same external file with two or more internal files.
11105 To provide a full range of functionality, while at the same time
11106 minimizing the problems of portability caused by this implementation
11107 dependence, GNAT handles file sharing as follows:
11109 @itemize @bullet
11110 @item
11111 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11112 to open two or more files with the same full name is considered an error
11113 and is not supported.  The exception @code{Use_Error} will be
11114 raised.  Note that a file that is not explicitly closed by the program
11115 remains open until the program terminates.
11117 @item
11118 If the form parameter @samp{shared=no} appears in the form string, the
11119 file can be opened or created with its own separate stream identifier,
11120 regardless of whether other files sharing the same external file are
11121 opened.  The exact effect depends on how the C stream routines handle
11122 multiple accesses to the same external files using separate streams.
11124 @item
11125 If the form parameter @samp{shared=yes} appears in the form string for
11126 each of two or more files opened using the same full name, the same
11127 stream is shared between these files, and the semantics are as described
11128 in Ada 95 Reference Manual, Section A.14.
11129 @end itemize
11131 @noindent
11132 When a program that opens multiple files with the same name is ported
11133 from another Ada compiler to GNAT, the effect will be that
11134 @code{Use_Error} is raised.
11136 The documentation of the original compiler and the documentation of the
11137 program should then be examined to determine if file sharing was
11138 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11139 and @code{Create} calls as required.
11141 When a program is ported from GNAT to some other Ada compiler, no
11142 special attention is required unless the @samp{shared=@var{xxx}} form
11143 parameter is used in the program.  In this case, you must examine the
11144 documentation of the new compiler to see if it supports the required
11145 file sharing semantics, and form strings modified appropriately.  Of
11146 course it may be the case that the program cannot be ported if the
11147 target compiler does not support the required functionality.  The best
11148 approach in writing portable code is to avoid file sharing (and hence
11149 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11150 completely.
11152 One common use of file sharing in Ada 83 is the use of instantiations of
11153 Sequential_IO on the same file with different types, to achieve
11154 heterogeneous input-output.  Although this approach will work in GNAT if
11155 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11156 for this purpose (using the stream attributes)
11158 @node Open Modes
11159 @section Open Modes
11161 @noindent
11162 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11163 using the mode shown in the following table:
11165 @sp 2
11166 @center @code{Open} and @code{Create} Call Modes
11167 @smallexample
11168                                @b{OPEN }           @b{CREATE}
11169 Append_File                    "r+"             "w+"
11170 In_File                        "r"              "w+"
11171 Out_File (Direct_IO)           "r+"             "w"
11172 Out_File (all other cases)     "w"              "w"
11173 Inout_File                     "r+"             "w+"
11174 @end smallexample
11176 @noindent
11177 If text file translation is required, then either @samp{b} or @samp{t}
11178 is added to the mode, depending on the setting of Text.  Text file
11179 translation refers to the mapping of CR/LF sequences in an external file
11180 to LF characters internally.  This mapping only occurs in DOS and
11181 DOS-like systems, and is not relevant to other systems.
11183 A special case occurs with Stream_IO@.  As shown in the above table, the
11184 file is initially opened in @samp{r} or @samp{w} mode for the
11185 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11186 subsequently requires switching from reading to writing or vice-versa,
11187 then the file is reopened in @samp{r+} mode to permit the required operation.
11189 @node Operations on C Streams
11190 @section Operations on C Streams
11191 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11192 access to the C library functions for operations on C streams:
11194 @smallexample @c adanocomment
11195 package Interfaces.C_Streams is
11196   -- Note: the reason we do not use the types that are in
11197   -- Interfaces.C is that we want to avoid dragging in the
11198   -- code in this unit if possible.
11199   subtype chars is System.Address;
11200   -- Pointer to null-terminated array of characters
11201   subtype FILEs is System.Address;
11202   -- Corresponds to the C type FILE*
11203   subtype voids is System.Address;
11204   -- Corresponds to the C type void*
11205   subtype int is Integer;
11206   subtype long is Long_Integer;
11207   -- Note: the above types are subtypes deliberately, and it
11208   -- is part of this spec that the above correspondences are
11209   -- guaranteed.  This means that it is legitimate to, for
11210   -- example, use Integer instead of int.  We provide these
11211   -- synonyms for clarity, but in some cases it may be
11212   -- convenient to use the underlying types (for example to
11213   -- avoid an unnecessary dependency of a spec on the spec
11214   -- of this unit).
11215   type size_t is mod 2 ** Standard'Address_Size;
11216   NULL_Stream : constant FILEs;
11217   -- Value returned (NULL in C) to indicate an
11218   -- fdopen/fopen/tmpfile error
11219   ----------------------------------
11220   -- Constants Defined in stdio.h --
11221   ----------------------------------
11222   EOF : constant int;
11223   -- Used by a number of routines to indicate error or
11224   -- end of file
11225   IOFBF : constant int;
11226   IOLBF : constant int;
11227   IONBF : constant int;
11228   -- Used to indicate buffering mode for setvbuf call
11229   SEEK_CUR : constant int;
11230   SEEK_END : constant int;
11231   SEEK_SET : constant int;
11232   -- Used to indicate origin for fseek call
11233   function stdin return FILEs;
11234   function stdout return FILEs;
11235   function stderr return FILEs;
11236   -- Streams associated with standard files
11237   --------------------------
11238   -- Standard C functions --
11239   --------------------------
11240   -- The functions selected below are ones that are
11241   -- available in DOS, OS/2, UNIX and Xenix (but not
11242   -- necessarily in ANSI C).  These are very thin interfaces
11243   -- which copy exactly the C headers.  For more
11244   -- documentation on these functions, see the Microsoft C
11245   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11246   -- ISBN 1-55615-225-6), which includes useful information
11247   -- on system compatibility.
11248   procedure clearerr (stream : FILEs);
11249   function fclose (stream : FILEs) return int;
11250   function fdopen (handle : int; mode : chars) return FILEs;
11251   function feof (stream : FILEs) return int;
11252   function ferror (stream : FILEs) return int;
11253   function fflush (stream : FILEs) return int;
11254   function fgetc (stream : FILEs) return int;
11255   function fgets (strng : chars; n : int; stream : FILEs)
11256       return chars;
11257   function fileno (stream : FILEs) return int;
11258   function fopen (filename : chars; Mode : chars)
11259       return FILEs;
11260   -- Note: to maintain target independence, use
11261   -- text_translation_required, a boolean variable defined in
11262   -- a-sysdep.c to deal with the target dependent text
11263   -- translation requirement.  If this variable is set,
11264   -- then  b/t should be appended to the standard mode
11265   -- argument to set the text translation mode off or on
11266   -- as required.
11267   function fputc (C : int; stream : FILEs) return int;
11268   function fputs (Strng : chars; Stream : FILEs) return int;
11269   function fread
11270      (buffer : voids;
11271       size : size_t;
11272       count : size_t;
11273       stream : FILEs)
11274       return size_t;
11275   function freopen
11276      (filename : chars;
11277       mode : chars;
11278       stream : FILEs)
11279       return FILEs;
11280   function fseek
11281      (stream : FILEs;
11282       offset : long;
11283       origin : int)
11284       return int;
11285   function ftell (stream : FILEs) return long;
11286   function fwrite
11287      (buffer : voids;
11288       size : size_t;
11289       count : size_t;
11290       stream : FILEs)
11291       return size_t;
11292   function isatty (handle : int) return int;
11293   procedure mktemp (template : chars);
11294   -- The return value (which is just a pointer to template)
11295   -- is discarded
11296   procedure rewind (stream : FILEs);
11297   function rmtmp return int;
11298   function setvbuf
11299      (stream : FILEs;
11300       buffer : chars;
11301       mode : int;
11302       size : size_t)
11303       return int;
11305   function tmpfile return FILEs;
11306   function ungetc (c : int; stream : FILEs) return int;
11307   function unlink (filename : chars) return int;
11308   ---------------------
11309   -- Extra functions --
11310   ---------------------
11311   -- These functions supply slightly thicker bindings than
11312   -- those above.  They are derived from functions in the
11313   -- C Run-Time Library, but may do a bit more work than
11314   -- just directly calling one of the Library functions.
11315   function is_regular_file (handle : int) return int;
11316   -- Tests if given handle is for a regular file (result 1)
11317   -- or for a non-regular file (pipe or device, result 0).
11318   ---------------------------------
11319   -- Control of Text/Binary Mode --
11320   ---------------------------------
11321   -- If text_translation_required is true, then the following
11322   -- functions may be used to dynamically switch a file from
11323   -- binary to text mode or vice versa.  These functions have
11324   -- no effect if text_translation_required is false (i.e.  in
11325   -- normal UNIX mode).  Use fileno to get a stream handle.
11326   procedure set_binary_mode (handle : int);
11327   procedure set_text_mode (handle : int);
11328   ----------------------------
11329   -- Full Path Name support --
11330   ----------------------------
11331   procedure full_name (nam : chars; buffer : chars);
11332   -- Given a NUL terminated string representing a file
11333   -- name, returns in buffer a NUL terminated string
11334   -- representing the full path name for the file name.
11335   -- On systems where it is relevant the   drive is also
11336   -- part of the full path name.  It is the responsibility
11337   -- of the caller to pass an actual parameter for buffer
11338   -- that is big enough for any full path name.  Use
11339   -- max_path_len given below as the size of buffer.
11340   max_path_len : integer;
11341   -- Maximum length of an allowable full path name on the
11342   -- system, including a terminating NUL character.
11343 end Interfaces.C_Streams;
11344 @end smallexample
11346 @node Interfacing to C Streams
11347 @section Interfacing to C Streams
11349 @noindent
11350 The packages in this section permit interfacing Ada files to C Stream
11351 operations.
11353 @smallexample @c ada
11354  with Interfaces.C_Streams;
11355  package Ada.Sequential_IO.C_Streams is
11356     function C_Stream (F : File_Type)
11357        return Interfaces.C_Streams.FILEs;
11358     procedure Open
11359       (File : in out File_Type;
11360        Mode : in File_Mode;
11361        C_Stream : in Interfaces.C_Streams.FILEs;
11362        Form : in String := "");
11363  end Ada.Sequential_IO.C_Streams;
11365   with Interfaces.C_Streams;
11366   package Ada.Direct_IO.C_Streams is
11367      function C_Stream (F : File_Type)
11368         return Interfaces.C_Streams.FILEs;
11369      procedure Open
11370        (File : in out File_Type;
11371         Mode : in File_Mode;
11372         C_Stream : in Interfaces.C_Streams.FILEs;
11373         Form : in String := "");
11374   end Ada.Direct_IO.C_Streams;
11376   with Interfaces.C_Streams;
11377   package Ada.Text_IO.C_Streams is
11378      function C_Stream (F : File_Type)
11379         return Interfaces.C_Streams.FILEs;
11380      procedure Open
11381        (File : in out File_Type;
11382         Mode : in File_Mode;
11383         C_Stream : in Interfaces.C_Streams.FILEs;
11384         Form : in String := "");
11385   end Ada.Text_IO.C_Streams;
11387   with Interfaces.C_Streams;
11388   package Ada.Wide_Text_IO.C_Streams is
11389      function C_Stream (F : File_Type)
11390         return Interfaces.C_Streams.FILEs;
11391      procedure Open
11392        (File : in out File_Type;
11393         Mode : in File_Mode;
11394         C_Stream : in Interfaces.C_Streams.FILEs;
11395         Form : in String := "");
11396  end Ada.Wide_Text_IO.C_Streams;
11398  with Interfaces.C_Streams;
11399  package Ada.Stream_IO.C_Streams is
11400     function C_Stream (F : File_Type)
11401        return Interfaces.C_Streams.FILEs;
11402     procedure Open
11403       (File : in out File_Type;
11404        Mode : in File_Mode;
11405        C_Stream : in Interfaces.C_Streams.FILEs;
11406        Form : in String := "");
11407  end Ada.Stream_IO.C_Streams;
11408 @end smallexample
11410 @noindent
11411 In each of these five packages, the @code{C_Stream} function obtains the
11412 @code{FILE} pointer from a currently opened Ada file.  It is then
11413 possible to use the @code{Interfaces.C_Streams} package to operate on
11414 this stream, or the stream can be passed to a C program which can
11415 operate on it directly.  Of course the program is responsible for
11416 ensuring that only appropriate sequences of operations are executed.
11418 One particular use of relevance to an Ada program is that the
11419 @code{setvbuf} function can be used to control the buffering of the
11420 stream used by an Ada file.  In the absence of such a call the standard
11421 default buffering is used.
11423 The @code{Open} procedures in these packages open a file giving an
11424 existing C Stream instead of a file name.  Typically this stream is
11425 imported from a C program, allowing an Ada file to operate on an
11426 existing C file.
11428 @node The GNAT Library
11429 @chapter The GNAT Library
11431 @noindent
11432 The GNAT library contains a number of general and special purpose packages.
11433 It represents functionality that the GNAT developers have found useful, and
11434 which is made available to GNAT users.  The packages described here are fully
11435 supported, and upwards compatibility will be maintained in future releases,
11436 so you can use these facilities with the confidence that the same functionality
11437 will be available in future releases.
11439 The chapter here simply gives a brief summary of the facilities available.
11440 The full documentation is found in the spec file for the package.  The full
11441 sources of these library packages, including both spec and body, are provided
11442 with all GNAT releases.  For example, to find out the full specifications of
11443 the SPITBOL pattern matching capability, including a full tutorial and
11444 extensive examples, look in the @file{g-spipat.ads} file in the library.
11446 For each entry here, the package name (as it would appear in a @code{with}
11447 clause) is given, followed by the name of the corresponding spec file in
11448 parentheses.  The packages are children in four hierarchies, @code{Ada},
11449 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11450 GNAT-specific hierarchy.
11452 Note that an application program should only use packages in one of these
11453 four hierarchies if the package is defined in the Ada Reference Manual,
11454 or is listed in this section of the GNAT Programmers Reference Manual.
11455 All other units should be considered internal implementation units and
11456 should not be directly @code{with}'ed by application code.  The use of
11457 a @code{with} statement that references one of these internal implementation
11458 units makes an application potentially dependent on changes in versions
11459 of GNAT, and will generate a warning message.
11461 @menu
11462 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11463 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11464 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11465 * Ada.Command_Line.Remove (a-colire.ads)::
11466 * Ada.Command_Line.Environment (a-colien.ads)::
11467 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11468 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11469 * Ada.Exceptions.Traceback (a-exctra.ads)::
11470 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11471 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11472 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11473 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11474 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11475 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11476 * GNAT.Array_Split (g-arrspl.ads)::
11477 * GNAT.AWK (g-awk.ads)::
11478 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11479 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11480 * GNAT.Bubble_Sort (g-bubsor.ads)::
11481 * GNAT.Bubble_Sort_A (g-busora.ads)::
11482 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11483 * GNAT.Calendar (g-calend.ads)::
11484 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11485 * GNAT.CRC32 (g-crc32.ads)::
11486 * GNAT.Case_Util (g-casuti.ads)::
11487 * GNAT.CGI (g-cgi.ads)::
11488 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11489 * GNAT.CGI.Debug (g-cgideb.ads)::
11490 * GNAT.Command_Line (g-comlin.ads)::
11491 * GNAT.Compiler_Version (g-comver.ads)::
11492 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11493 * GNAT.Current_Exception (g-curexc.ads)::
11494 * GNAT.Debug_Pools (g-debpoo.ads)::
11495 * GNAT.Debug_Utilities (g-debuti.ads)::
11496 * GNAT.Directory_Operations (g-dirope.ads)::
11497 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11498 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11499 * GNAT.Exception_Actions (g-excact.ads)::
11500 * GNAT.Exception_Traces (g-exctra.ads)::
11501 * GNAT.Exceptions (g-except.ads)::
11502 * GNAT.Expect (g-expect.ads)::
11503 * GNAT.Float_Control (g-flocon.ads)::
11504 * GNAT.Heap_Sort (g-heasor.ads)::
11505 * GNAT.Heap_Sort_A (g-hesora.ads)::
11506 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11507 * GNAT.HTable (g-htable.ads)::
11508 * GNAT.IO (g-io.ads)::
11509 * GNAT.IO_Aux (g-io_aux.ads)::
11510 * GNAT.Lock_Files (g-locfil.ads)::
11511 * GNAT.MD5 (g-md5.ads)::
11512 * GNAT.Memory_Dump (g-memdum.ads)::
11513 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11514 * GNAT.OS_Lib (g-os_lib.ads)::
11515 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
11516 * GNAT.Regexp (g-regexp.ads)::
11517 * GNAT.Registry (g-regist.ads)::
11518 * GNAT.Regpat (g-regpat.ads)::
11519 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11520 * GNAT.Semaphores (g-semaph.ads)::
11521 * GNAT.Signals (g-signal.ads)::
11522 * GNAT.Sockets (g-socket.ads)::
11523 * GNAT.Source_Info (g-souinf.ads)::
11524 * GNAT.Spell_Checker (g-speche.ads)::
11525 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11526 * GNAT.Spitbol (g-spitbo.ads)::
11527 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11528 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11529 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11530 * GNAT.Strings (g-string.ads)::
11531 * GNAT.String_Split (g-strspl.ads)::
11532 * GNAT.Table (g-table.ads)::
11533 * GNAT.Task_Lock (g-tasloc.ads)::
11534 * GNAT.Threads (g-thread.ads)::
11535 * GNAT.Traceback (g-traceb.ads)::
11536 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11537 * GNAT.Wide_String_Split (g-wistsp.ads)::
11538 * Interfaces.C.Extensions (i-cexten.ads)::
11539 * Interfaces.C.Streams (i-cstrea.ads)::
11540 * Interfaces.CPP (i-cpp.ads)::
11541 * Interfaces.Os2lib (i-os2lib.ads)::
11542 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11543 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11544 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11545 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11546 * Interfaces.VxWorks (i-vxwork.ads)::
11547 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11548 * System.Address_Image (s-addima.ads)::
11549 * System.Assertions (s-assert.ads)::
11550 * System.Memory (s-memory.ads)::
11551 * System.Partition_Interface (s-parint.ads)::
11552 * System.Restrictions (s-restri.ads)::
11553 * System.Rident (s-rident.ads)::
11554 * System.Task_Info (s-tasinf.ads)::
11555 * System.Wch_Cnv (s-wchcnv.ads)::
11556 * System.Wch_Con (s-wchcon.ads)::
11557 @end menu
11559 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11560 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11561 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11562 @cindex Latin_9 constants for Character
11564 @noindent
11565 This child of @code{Ada.Characters}
11566 provides a set of definitions corresponding to those in the
11567 RM-defined package @code{Ada.Characters.Latin_1} but with the
11568 few modifications required for @code{Latin-9}
11569 The provision of such a package
11570 is specifically authorized by the Ada Reference Manual
11571 (RM A.3(27)).
11573 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11574 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11575 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11576 @cindex Latin_1 constants for Wide_Character
11578 @noindent
11579 This child of @code{Ada.Characters}
11580 provides a set of definitions corresponding to those in the
11581 RM-defined package @code{Ada.Characters.Latin_1} but with the
11582 types of the constants being @code{Wide_Character}
11583 instead of @code{Character}.  The provision of such a package
11584 is specifically authorized by the Ada Reference Manual
11585 (RM A.3(27)).
11587 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11588 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11589 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11590 @cindex Latin_9 constants for Wide_Character
11592 @noindent
11593 This child of @code{Ada.Characters}
11594 provides a set of definitions corresponding to those in the
11595 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11596 types of the constants being @code{Wide_Character}
11597 instead of @code{Character}.  The provision of such a package
11598 is specifically authorized by the Ada Reference Manual
11599 (RM A.3(27)).
11601 @node Ada.Command_Line.Remove (a-colire.ads)
11602 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11603 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11604 @cindex Removing command line arguments
11605 @cindex Command line, argument removal
11607 @noindent
11608 This child of @code{Ada.Command_Line}
11609 provides a mechanism for logically removing
11610 arguments from the argument list.  Once removed, an argument is not visible
11611 to further calls on the subprograms in @code{Ada.Command_Line} will not
11612 see the removed argument.
11614 @node Ada.Command_Line.Environment (a-colien.ads)
11615 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11616 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11617 @cindex Environment entries
11619 @noindent
11620 This child of @code{Ada.Command_Line}
11621 provides a mechanism for obtaining environment values on systems
11622 where this concept makes sense.
11624 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11625 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11626 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11627 @cindex C Streams, Interfacing with Direct_IO
11629 @noindent
11630 This package provides subprograms that allow interfacing between
11631 C streams and @code{Direct_IO}.  The stream identifier can be
11632 extracted from a file opened on the Ada side, and an Ada file
11633 can be constructed from a stream opened on the C side.
11635 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11636 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11637 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11638 @cindex Null_Occurrence, testing for
11640 @noindent
11641 This child subprogram provides a way of testing for the null
11642 exception occurrence (@code{Null_Occurrence}) without raising
11643 an exception.
11645 @node Ada.Exceptions.Traceback (a-exctra.ads)
11646 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11647 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11648 @cindex Traceback for Exception Occurrence
11650 @noindent
11651 This child package provides the subprogram (@code{Tracebacks}) to
11652 give a traceback array of addresses based on an exception
11653 occurrence.
11655 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11656 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11657 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11658 @cindex C Streams, Interfacing with Sequential_IO
11660 @noindent
11661 This package provides subprograms that allow interfacing between
11662 C streams and @code{Sequential_IO}.  The stream identifier can be
11663 extracted from a file opened on the Ada side, and an Ada file
11664 can be constructed from a stream opened on the C side.
11666 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11667 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11668 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11669 @cindex C Streams, Interfacing with Stream_IO
11671 @noindent
11672 This package provides subprograms that allow interfacing between
11673 C streams and @code{Stream_IO}.  The stream identifier can be
11674 extracted from a file opened on the Ada side, and an Ada file
11675 can be constructed from a stream opened on the C side.
11677 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11678 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11679 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11680 @cindex @code{Unbounded_String}, IO support
11681 @cindex @code{Text_IO}, extensions for unbounded strings
11683 @noindent
11684 This package provides subprograms for Text_IO for unbounded
11685 strings, avoiding the necessity for an intermediate operation
11686 with ordinary strings.
11688 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11689 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11690 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11691 @cindex @code{Unbounded_Wide_String}, IO support
11692 @cindex @code{Text_IO}, extensions for unbounded wide strings
11694 @noindent
11695 This package provides subprograms for Text_IO for unbounded
11696 wide strings, avoiding the necessity for an intermediate operation
11697 with ordinary wide strings.
11699 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11700 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11701 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11702 @cindex C Streams, Interfacing with @code{Text_IO}
11704 @noindent
11705 This package provides subprograms that allow interfacing between
11706 C streams and @code{Text_IO}.  The stream identifier can be
11707 extracted from a file opened on the Ada side, and an Ada file
11708 can be constructed from a stream opened on the C side.
11710 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11711 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11712 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11713 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11715 @noindent
11716 This package provides subprograms that allow interfacing between
11717 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11718 extracted from a file opened on the Ada side, and an Ada file
11719 can be constructed from a stream opened on the C side.
11721 @node GNAT.Array_Split (g-arrspl.ads)
11722 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11723 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11724 @cindex Array splitter
11726 @noindent
11727 Useful array-manipulation routines: given a set of separators, split
11728 an array wherever the separators appear, and provide direct access
11729 to the resulting slices.
11731 @node GNAT.AWK (g-awk.ads)
11732 @section @code{GNAT.AWK} (@file{g-awk.ads})
11733 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11734 @cindex Parsing
11735 @cindex AWK
11737 @noindent
11738 Provides AWK-like parsing functions, with an easy interface for parsing one
11739 or more files containing formatted data.  The file is viewed as a database
11740 where each record is a line and a field is a data element in this line.
11742 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11743 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11744 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11745 @cindex Parsing
11746 @cindex Bounded Buffers
11748 @noindent
11749 Provides a concurrent generic bounded buffer abstraction.  Instances are
11750 useful directly or as parts of the implementations of other abstractions,
11751 such as mailboxes.
11753 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11754 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11755 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11756 @cindex Parsing
11757 @cindex Mailboxes
11759 @noindent
11760 Provides a thread-safe asynchronous intertask mailbox communication facility.
11762 @node GNAT.Bubble_Sort (g-bubsor.ads)
11763 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11764 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11765 @cindex Sorting
11766 @cindex Bubble sort
11768 @noindent
11769 Provides a general implementation of bubble sort usable for sorting arbitrary
11770 data items.  Exchange and comparison procedures are provided by passing
11771 access-to-procedure values.
11773 @node GNAT.Bubble_Sort_A (g-busora.ads)
11774 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11775 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11776 @cindex Sorting
11777 @cindex Bubble sort
11779 @noindent
11780 Provides a general implementation of bubble sort usable for sorting arbitrary
11781 data items.  Move and comparison procedures are provided by passing
11782 access-to-procedure values. This is an older version, retained for
11783 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11785 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11786 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11787 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11788 @cindex Sorting
11789 @cindex Bubble sort
11791 @noindent
11792 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11793 are provided as generic parameters, this improves efficiency, especially
11794 if the procedures can be inlined, at the expense of duplicating code for
11795 multiple instantiations.
11797 @node GNAT.Calendar (g-calend.ads)
11798 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11799 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11800 @cindex @code{Calendar}
11802 @noindent
11803 Extends the facilities provided by @code{Ada.Calendar} to include handling
11804 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11805 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11806 C @code{timeval} format.
11808 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11809 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11810 @cindex @code{Calendar}
11811 @cindex Time
11812 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11814 @node GNAT.CRC32 (g-crc32.ads)
11815 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11816 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11817 @cindex CRC32
11818 @cindex Cyclic Redundancy Check
11820 @noindent
11821 This package implements the CRC-32 algorithm.  For a full description
11822 of this algorithm see
11823 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11824 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11825 Aug.@: 1988.  Sarwate, D.V@.
11827 @noindent
11828 Provides an extended capability for formatted output of time values with
11829 full user control over the format.  Modeled on the GNU Date specification.
11831 @node GNAT.Case_Util (g-casuti.ads)
11832 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11833 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11834 @cindex Casing utilities
11835 @cindex Character handling (@code{GNAT.Case_Util})
11837 @noindent
11838 A set of simple routines for handling upper and lower casing of strings
11839 without the overhead of the full casing tables
11840 in @code{Ada.Characters.Handling}.
11842 @node GNAT.CGI (g-cgi.ads)
11843 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11844 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11845 @cindex CGI (Common Gateway Interface)
11847 @noindent
11848 This is a package for interfacing a GNAT program with a Web server via the
11849 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11850 parameters, which are a set of key/value pairs sent by the Web server.  It
11851 builds a table whose index is the key and provides some services to deal
11852 with this table.
11854 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11855 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11856 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11857 @cindex CGI (Common Gateway Interface) cookie support
11858 @cindex Cookie support in CGI
11860 @noindent
11861 This is a package to interface a GNAT program with a Web server via the
11862 Common Gateway Interface (CGI).  It exports services to deal with Web
11863 cookies (piece of information kept in the Web client software).
11865 @node GNAT.CGI.Debug (g-cgideb.ads)
11866 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11867 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11868 @cindex CGI (Common Gateway Interface) debugging
11870 @noindent
11871 This is a package to help debugging CGI (Common Gateway Interface)
11872 programs written in Ada.
11874 @node GNAT.Command_Line (g-comlin.ads)
11875 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11876 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11877 @cindex Command line
11879 @noindent
11880 Provides a high level interface to @code{Ada.Command_Line} facilities,
11881 including the ability to scan for named switches with optional parameters
11882 and expand file names using wild card notations.
11884 @node GNAT.Compiler_Version (g-comver.ads)
11885 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11886 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11887 @cindex Compiler Version
11888 @cindex Version, of compiler
11890 @noindent
11891 Provides a routine for obtaining the version of the compiler used to
11892 compile the program. More accurately this is the version of the binder
11893 used to bind the program (this will normally be the same as the version
11894 of the compiler if a consistent tool set is used to compile all units
11895 of a partition).
11897 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11898 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11899 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11900 @cindex Interrupt
11902 @noindent
11903 Provides a simple interface to handle Ctrl-C keyboard events.
11905 @node GNAT.Current_Exception (g-curexc.ads)
11906 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11907 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11908 @cindex Current exception
11909 @cindex Exception retrieval
11911 @noindent
11912 Provides access to information on the current exception that has been raised
11913 without the need for using the Ada-95 exception choice parameter specification
11914 syntax.  This is particularly useful in simulating typical facilities for
11915 obtaining information about exceptions provided by Ada 83 compilers.
11917 @node GNAT.Debug_Pools (g-debpoo.ads)
11918 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11919 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11920 @cindex Debugging
11921 @cindex Debug pools
11922 @cindex Memory corruption debugging
11924 @noindent
11925 Provide a debugging storage pools that helps tracking memory corruption
11926 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11927 the @cite{GNAT User's Guide}.
11929 @node GNAT.Debug_Utilities (g-debuti.ads)
11930 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11931 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11932 @cindex Debugging
11934 @noindent
11935 Provides a few useful utilities for debugging purposes, including conversion
11936 to and from string images of address values. Supports both C and Ada formats
11937 for hexadecimal literals.
11939 @node GNAT.Directory_Operations (g-dirope.ads)
11940 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11941 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11942 @cindex Directory operations
11944 @noindent
11945 Provides a set of routines for manipulating directories, including changing
11946 the current directory, making new directories, and scanning the files in a
11947 directory.
11949 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11950 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11951 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11952 @cindex Hash tables
11954 @noindent
11955 A generic implementation of hash tables that can be used to hash arbitrary
11956 data.  Provided in two forms, a simple form with built in hash functions,
11957 and a more complex form in which the hash function is supplied.
11959 @noindent
11960 This package provides a facility similar to that of @code{GNAT.HTable},
11961 except that this package declares a type that can be used to define
11962 dynamic instances of the hash table, while an instantiation of
11963 @code{GNAT.HTable} creates a single instance of the hash table.
11965 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11966 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11967 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11968 @cindex Table implementation
11969 @cindex Arrays, extendable
11971 @noindent
11972 A generic package providing a single dimension array abstraction where the
11973 length of the array can be dynamically modified.
11975 @noindent
11976 This package provides a facility similar to that of @code{GNAT.Table},
11977 except that this package declares a type that can be used to define
11978 dynamic instances of the table, while an instantiation of
11979 @code{GNAT.Table} creates a single instance of the table type.
11981 @node GNAT.Exception_Actions (g-excact.ads)
11982 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11983 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11984 @cindex Exception actions
11986 @noindent
11987 Provides callbacks when an exception is raised. Callbacks can be registered
11988 for specific exceptions, or when any exception is raised. This
11989 can be used for instance to force a core dump to ease debugging.
11991 @node GNAT.Exception_Traces (g-exctra.ads)
11992 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11993 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11994 @cindex Exception traces
11995 @cindex Debugging
11997 @noindent
11998 Provides an interface allowing to control automatic output upon exception
11999 occurrences.
12001 @node GNAT.Exceptions (g-except.ads)
12002 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12003 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12004 @cindex Exceptions, Pure
12005 @cindex Pure packages, exceptions
12007 @noindent
12008 Normally it is not possible to raise an exception with
12009 a message from a subprogram in a pure package, since the
12010 necessary types and subprograms are in @code{Ada.Exceptions}
12011 which is not a pure unit. @code{GNAT.Exceptions} provides a
12012 facility for getting around this limitation for a few
12013 predefined exceptions, and for example allow raising
12014 @code{Constraint_Error} with a message from a pure subprogram.
12016 @node GNAT.Expect (g-expect.ads)
12017 @section @code{GNAT.Expect} (@file{g-expect.ads})
12018 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12020 @noindent
12021 Provides a set of subprograms similar to what is available
12022 with the standard Tcl Expect tool.
12023 It allows you to easily spawn and communicate with an external process.
12024 You can send commands or inputs to the process, and compare the output
12025 with some expected regular expression. Currently @code{GNAT.Expect}
12026 is implemented on all native GNAT ports except for OpenVMS@.
12027 It is not implemented for cross ports, and in particular is not
12028 implemented for VxWorks or LynxOS@.
12030 @node GNAT.Float_Control (g-flocon.ads)
12031 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12032 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12033 @cindex Floating-Point Processor
12035 @noindent
12036 Provides an interface for resetting the floating-point processor into the
12037 mode required for correct semantic operation in Ada.  Some third party
12038 library calls may cause this mode to be modified, and the Reset procedure
12039 in this package can be used to reestablish the required mode.
12041 @node GNAT.Heap_Sort (g-heasor.ads)
12042 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12043 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12044 @cindex Sorting
12046 @noindent
12047 Provides a general implementation of heap sort usable for sorting arbitrary
12048 data items. Exchange and comparison procedures are provided by passing
12049 access-to-procedure values.  The algorithm used is a modified heap sort
12050 that performs approximately N*log(N) comparisons in the worst case.
12052 @node GNAT.Heap_Sort_A (g-hesora.ads)
12053 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12054 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12055 @cindex Sorting
12057 @noindent
12058 Provides a general implementation of heap sort usable for sorting arbitrary
12059 data items. Move and comparison procedures are provided by passing
12060 access-to-procedure values.  The algorithm used is a modified heap sort
12061 that performs approximately N*log(N) comparisons in the worst case.
12062 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12063 interface, but may be slightly more efficient.
12065 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12066 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12067 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12068 @cindex Sorting
12070 @noindent
12071 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12072 are provided as generic parameters, this improves efficiency, especially
12073 if the procedures can be inlined, at the expense of duplicating code for
12074 multiple instantiations.
12076 @node GNAT.HTable (g-htable.ads)
12077 @section @code{GNAT.HTable} (@file{g-htable.ads})
12078 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12079 @cindex Hash tables
12081 @noindent
12082 A generic implementation of hash tables that can be used to hash arbitrary
12083 data.  Provides two approaches, one a simple static approach, and the other
12084 allowing arbitrary dynamic hash tables.
12086 @node GNAT.IO (g-io.ads)
12087 @section @code{GNAT.IO} (@file{g-io.ads})
12088 @cindex @code{GNAT.IO} (@file{g-io.ads})
12089 @cindex Simple I/O
12090 @cindex Input/Output facilities
12092 @noindent
12093 A simple preelaborable input-output package that provides a subset of
12094 simple Text_IO functions for reading characters and strings from
12095 Standard_Input, and writing characters, strings and integers to either
12096 Standard_Output or Standard_Error.
12098 @node GNAT.IO_Aux (g-io_aux.ads)
12099 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12100 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12101 @cindex Text_IO
12102 @cindex Input/Output facilities
12104 Provides some auxiliary functions for use with Text_IO, including a test
12105 for whether a file exists, and functions for reading a line of text.
12107 @node GNAT.Lock_Files (g-locfil.ads)
12108 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12109 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12110 @cindex File locking
12111 @cindex Locking using files
12113 @noindent
12114 Provides a general interface for using files as locks.  Can be used for
12115 providing program level synchronization.
12117 @node GNAT.MD5 (g-md5.ads)
12118 @section @code{GNAT.MD5} (@file{g-md5.ads})
12119 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12120 @cindex Message Digest MD5
12122 @noindent
12123 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12125 @node GNAT.Memory_Dump (g-memdum.ads)
12126 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12127 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12128 @cindex Dump Memory
12130 @noindent
12131 Provides a convenient routine for dumping raw memory to either the
12132 standard output or standard error files. Uses GNAT.IO for actual
12133 output.
12135 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12136 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12137 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12138 @cindex Exception, obtaining most recent
12140 @noindent
12141 Provides access to the most recently raised exception.  Can be used for
12142 various logging purposes, including duplicating functionality of some
12143 Ada 83 implementation dependent extensions.
12145 @node GNAT.OS_Lib (g-os_lib.ads)
12146 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12147 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12148 @cindex Operating System interface
12149 @cindex Spawn capability
12151 @noindent
12152 Provides a range of target independent operating system interface functions,
12153 including time/date management, file operations, subprocess management,
12154 including a portable spawn procedure, and access to environment variables
12155 and error return codes.
12157 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
12158 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12159 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12160 @cindex Hash functions
12162 @noindent
12163 Provides a generator of static minimal perfect hash functions. No
12164 collisions occur and each item can be retrieved from the table in one
12165 probe (perfect property). The hash table size corresponds to the exact
12166 size of the key set and no larger (minimal property). The key set has to
12167 be know in advance (static property). The hash functions are also order
12168 preservering. If w2 is inserted after w1 in the generator, their
12169 hashcode are in the same order. These hashing functions are very
12170 convenient for use with realtime applications.
12172 @node GNAT.Regexp (g-regexp.ads)
12173 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12174 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12175 @cindex Regular expressions
12176 @cindex Pattern matching
12178 @noindent
12179 A simple implementation of regular expressions, using a subset of regular
12180 expression syntax copied from familiar Unix style utilities.  This is the
12181 simples of the three pattern matching packages provided, and is particularly
12182 suitable for ``file globbing'' applications.
12184 @node GNAT.Registry (g-regist.ads)
12185 @section @code{GNAT.Registry} (@file{g-regist.ads})
12186 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12187 @cindex Windows Registry
12189 @noindent
12190 This is a high level binding to the Windows registry.  It is possible to
12191 do simple things like reading a key value, creating a new key.  For full
12192 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12193 package provided with the Win32Ada binding
12195 @node GNAT.Regpat (g-regpat.ads)
12196 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12197 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12198 @cindex Regular expressions
12199 @cindex Pattern matching
12201 @noindent
12202 A complete implementation of Unix-style regular expression matching, copied
12203 from the original V7 style regular expression library written in C by
12204 Henry Spencer (and binary compatible with this C library).
12206 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12207 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12208 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12209 @cindex Secondary Stack Info
12211 @noindent
12212 Provide the capability to query the high water mark of the current task's
12213 secondary stack.
12215 @node GNAT.Semaphores (g-semaph.ads)
12216 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12217 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12218 @cindex Semaphores
12220 @noindent
12221 Provides classic counting and binary semaphores using protected types.
12223 @node GNAT.Signals (g-signal.ads)
12224 @section @code{GNAT.Signals} (@file{g-signal.ads})
12225 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12226 @cindex Signals
12228 @noindent
12229 Provides the ability to manipulate the blocked status of signals on supported
12230 targets.
12232 @node GNAT.Sockets (g-socket.ads)
12233 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12234 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12235 @cindex Sockets
12237 @noindent
12238 A high level and portable interface to develop sockets based applications.
12239 This package is based on the sockets thin binding found in
12240 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12241 on all native GNAT ports except for OpenVMS@.  It is not implemented
12242 for the LynxOS@ cross port.
12244 @node GNAT.Source_Info (g-souinf.ads)
12245 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12246 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12247 @cindex Source Information
12249 @noindent
12250 Provides subprograms that give access to source code information known at
12251 compile time, such as the current file name and line number.
12253 @node GNAT.Spell_Checker (g-speche.ads)
12254 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12255 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12256 @cindex Spell checking
12258 @noindent
12259 Provides a function for determining whether one string is a plausible
12260 near misspelling of another string.
12262 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12263 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12264 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12265 @cindex SPITBOL pattern matching
12266 @cindex Pattern matching
12268 @noindent
12269 A complete implementation of SNOBOL4 style pattern matching.  This is the
12270 most elaborate of the pattern matching packages provided.  It fully duplicates
12271 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12272 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12274 @node GNAT.Spitbol (g-spitbo.ads)
12275 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12276 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12277 @cindex SPITBOL interface
12279 @noindent
12280 The top level package of the collection of SPITBOL-style functionality, this
12281 package provides basic SNOBOL4 string manipulation functions, such as
12282 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12283 useful for constructing arbitrary mappings from strings in the style of
12284 the SNOBOL4 TABLE function.
12286 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12287 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12288 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12289 @cindex Sets of strings
12290 @cindex SPITBOL Tables
12292 @noindent
12293 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12294 for type @code{Standard.Boolean}, giving an implementation of sets of
12295 string values.
12297 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12298 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12299 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12300 @cindex Integer maps
12301 @cindex Maps
12302 @cindex SPITBOL Tables
12304 @noindent
12305 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12306 for type @code{Standard.Integer}, giving an implementation of maps
12307 from string to integer values.
12309 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12310 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12311 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12312 @cindex String maps
12313 @cindex Maps
12314 @cindex SPITBOL Tables
12316 @noindent
12317 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12318 a variable length string type, giving an implementation of general
12319 maps from strings to strings.
12321 @node GNAT.Strings (g-string.ads)
12322 @section @code{GNAT.Strings} (@file{g-string.ads})
12323 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12325 @noindent
12326 Common String access types and related subprograms. Basically it
12327 defines a string access and an array of string access types.
12329 @node GNAT.String_Split (g-strspl.ads)
12330 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12331 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12332 @cindex String splitter
12334 @noindent
12335 Useful string-manipulation routines: given a set of separators, split
12336 a string wherever the separators appear, and provide direct access
12337 to the resulting slices. This package is instantiated from
12338 @code{GNAT.Array_Split}.
12340 @node GNAT.Table (g-table.ads)
12341 @section @code{GNAT.Table} (@file{g-table.ads})
12342 @cindex @code{GNAT.Table} (@file{g-table.ads})
12343 @cindex Table implementation
12344 @cindex Arrays, extendable
12346 @noindent
12347 A generic package providing a single dimension array abstraction where the
12348 length of the array can be dynamically modified.
12350 @noindent
12351 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12352 except that this package declares a single instance of the table type,
12353 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12354 used to define dynamic instances of the table.
12356 @node GNAT.Task_Lock (g-tasloc.ads)
12357 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12358 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12359 @cindex Task synchronization
12360 @cindex Task locking
12361 @cindex Locking
12363 @noindent
12364 A very simple facility for locking and unlocking sections of code using a
12365 single global task lock.  Appropriate for use in situations where contention
12366 between tasks is very rarely expected.
12368 @node GNAT.Threads (g-thread.ads)
12369 @section @code{GNAT.Threads} (@file{g-thread.ads})
12370 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12371 @cindex Foreign threads
12372 @cindex Threads, foreign
12374 @noindent
12375 Provides facilities for creating and destroying threads with explicit calls.
12376 These threads are known to the GNAT run-time system.  These subprograms are
12377 exported C-convention procedures intended to be called from foreign code.
12378 By using these primitives rather than directly calling operating systems
12379 routines, compatibility with the Ada tasking runt-time is provided.
12381 @node GNAT.Traceback (g-traceb.ads)
12382 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12383 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12384 @cindex Trace back facilities
12386 @noindent
12387 Provides a facility for obtaining non-symbolic traceback information, useful
12388 in various debugging situations.
12390 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12391 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12392 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12393 @cindex Trace back facilities
12395 @noindent
12396 Provides symbolic traceback information that includes the subprogram
12397 name and line number information.
12399 @node GNAT.Wide_String_Split (g-wistsp.ads)
12400 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12401 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12402 @cindex Wide_String splitter
12404 @noindent
12405 Useful wide_string-manipulation routines: given a set of separators, split
12406 a wide_string wherever the separators appear, and provide direct access
12407 to the resulting slices. This package is instantiated from
12408 @code{GNAT.Array_Split}.
12410 @node Interfaces.C.Extensions (i-cexten.ads)
12411 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12412 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12414 @noindent
12415 This package contains additional C-related definitions, intended
12416 for use with either manually or automatically generated bindings
12417 to C libraries.
12419 @node Interfaces.C.Streams (i-cstrea.ads)
12420 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12421 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12422 @cindex  C streams, interfacing
12424 @noindent
12425 This package is a binding for the most commonly used operations
12426 on C streams.
12428 @node Interfaces.CPP (i-cpp.ads)
12429 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12430 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12431 @cindex  C++ interfacing
12432 @cindex  Interfacing, to C++
12434 @noindent
12435 This package provides facilities for use in interfacing to C++.  It
12436 is primarily intended to be used in connection with automated tools
12437 for the generation of C++ interfaces.
12439 @node Interfaces.Os2lib (i-os2lib.ads)
12440 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12441 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12442 @cindex Interfacing, to OS/2
12443 @cindex OS/2 interfacing
12445 @noindent
12446 This package provides interface definitions to the OS/2 library.
12447 It is a thin binding which is a direct translation of the
12448 various @file{<bse@.h>} files.
12450 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12451 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12452 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12453 @cindex OS/2 Error codes
12454 @cindex Interfacing, to OS/2
12455 @cindex OS/2 interfacing
12457 @noindent
12458 This package provides definitions of the OS/2 error codes.
12460 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12461 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12462 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12463 @cindex Interfacing, to OS/2
12464 @cindex Synchronization, OS/2
12465 @cindex OS/2 synchronization primitives
12467 @noindent
12468 This is a child package that provides definitions for interfacing
12469 to the @code{OS/2} synchronization primitives.
12471 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12472 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12473 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12474 @cindex Interfacing, to OS/2
12475 @cindex Thread control, OS/2
12476 @cindex OS/2 thread interfacing
12478 @noindent
12479 This is a child package that provides definitions for interfacing
12480 to the @code{OS/2} thread primitives.
12482 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12483 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12484 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12485 @cindex  IBM Packed Format
12486 @cindex  Packed Decimal
12488 @noindent
12489 This package provides a set of routines for conversions to and
12490 from a packed decimal format compatible with that used on IBM
12491 mainframes.
12493 @node Interfaces.VxWorks (i-vxwork.ads)
12494 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12495 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12496 @cindex Interfacing to VxWorks
12497 @cindex VxWorks, interfacing
12499 @noindent
12500 This package provides a limited binding to the VxWorks API.
12501 In particular, it interfaces with the
12502 VxWorks hardware interrupt facilities.
12504 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12505 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12506 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12507 @cindex Interfacing to VxWorks' I/O
12508 @cindex VxWorks, I/O interfacing
12509 @cindex VxWorks, Get_Immediate
12510 @cindex Get_Immediate, VxWorks
12512 @noindent
12513 This package provides a binding to the ioctl (IO/Control)
12514 function of VxWorks, defining a set of option values and
12515 function codes. A particular use of this package is
12516 to enable the use of Get_Immediate under VxWorks.
12518 @node System.Address_Image (s-addima.ads)
12519 @section @code{System.Address_Image} (@file{s-addima.ads})
12520 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12521 @cindex Address image
12522 @cindex Image, of an address
12524 @noindent
12525 This function provides a useful debugging
12526 function that gives an (implementation dependent)
12527 string which identifies an address.
12529 @node System.Assertions (s-assert.ads)
12530 @section @code{System.Assertions} (@file{s-assert.ads})
12531 @cindex @code{System.Assertions} (@file{s-assert.ads})
12532 @cindex Assertions
12533 @cindex Assert_Failure, exception
12535 @noindent
12536 This package provides the declaration of the exception raised
12537 by an run-time assertion failure, as well as the routine that
12538 is used internally to raise this assertion.
12540 @node System.Memory (s-memory.ads)
12541 @section @code{System.Memory} (@file{s-memory.ads})
12542 @cindex @code{System.Memory} (@file{s-memory.ads})
12543 @cindex Memory allocation
12545 @noindent
12546 This package provides the interface to the low level routines used
12547 by the generated code for allocation and freeing storage for the
12548 default storage pool (analogous to the C routines malloc and free.
12549 It also provides a reallocation interface analogous to the C routine
12550 realloc. The body of this unit may be modified to provide alternative
12551 allocation mechanisms for the default pool, and in addition, direct
12552 calls to this unit may be made for low level allocation uses (for
12553 example see the body of @code{GNAT.Tables}).
12555 @node System.Partition_Interface (s-parint.ads)
12556 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12557 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12558 @cindex Partition intefacing functions
12560 @noindent
12561 This package provides facilities for partition interfacing.  It
12562 is used primarily in a distribution context when using Annex E
12563 with @code{GLADE}.
12565 @node System.Restrictions (s-restri.ads)
12566 @section @code{System.Restrictions} (@file{s-restri.ads})
12567 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12568 @cindex Run-time restrictions access
12570 @noindent
12571 This package provides facilities for accessing at run-time
12572 the status of restrictions specified at compile time for
12573 the partition. Information is available both with regard
12574 to actual restrictions specified, and with regard to
12575 compiler determined information on which restrictions
12576 are violated by one or more packages in the partition.
12578 @node System.Rident (s-rident.ads)
12579 @section @code{System.Rident} (@file{s-rident.ads})
12580 @cindex @code{System.Rident} (@file{s-rident.ads})
12581 @cindex Restrictions definitions
12583 @noindent
12584 This package provides definitions of the restrictions
12585 identifiers supported by GNAT, and also the format of
12586 the restrictions provided in package System.Restrictions.
12587 It is not normally necessary to @code{with} this generic package
12588 since the necessary instantiation is included in
12589 package System.Restrictions.
12591 @node System.Task_Info (s-tasinf.ads)
12592 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12593 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12594 @cindex Task_Info pragma
12596 @noindent
12597 This package provides target dependent functionality that is used
12598 to support the @code{Task_Info} pragma
12600 @node System.Wch_Cnv (s-wchcnv.ads)
12601 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12602 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12603 @cindex Wide Character, Representation
12604 @cindex Wide String, Conversion
12605 @cindex Representation of wide characters
12607 @noindent
12608 This package provides routines for converting between
12609 wide characters and a representation as a value of type
12610 @code{Standard.String}, using a specified wide character
12611 encoding method.  It uses definitions in
12612 package @code{System.Wch_Con}.
12614 @node System.Wch_Con (s-wchcon.ads)
12615 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12616 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12618 @noindent
12619 This package provides definitions and descriptions of
12620 the various methods used for encoding wide characters
12621 in ordinary strings.  These definitions are used by
12622 the package @code{System.Wch_Cnv}.
12624 @node Interfacing to Other Languages
12625 @chapter Interfacing to Other Languages
12626 @noindent
12627 The facilities in annex B of the Ada 95 Reference Manual are fully
12628 implemented in GNAT, and in addition, a full interface to C++ is
12629 provided.
12631 @menu
12632 * Interfacing to C::
12633 * Interfacing to C++::
12634 * Interfacing to COBOL::
12635 * Interfacing to Fortran::
12636 * Interfacing to non-GNAT Ada code::
12637 @end menu
12639 @node Interfacing to C
12640 @section Interfacing to C
12642 @noindent
12643 Interfacing to C with GNAT can use one of two approaches:
12645 @itemize @bullet
12646 @item
12647 The types in the package @code{Interfaces.C} may be used.
12648 @item
12649 Standard Ada types may be used directly.  This may be less portable to
12650 other compilers, but will work on all GNAT compilers, which guarantee
12651 correspondence between the C and Ada types.
12652 @end itemize
12654 @noindent
12655 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12656 effect, since this is the default.  The following table shows the
12657 correspondence between Ada scalar types and the corresponding C types.
12659 @table @code
12660 @item Integer
12661 @code{int}
12662 @item Short_Integer
12663 @code{short}
12664 @item Short_Short_Integer
12665 @code{signed char}
12666 @item Long_Integer
12667 @code{long}
12668 @item Long_Long_Integer
12669 @code{long long}
12670 @item Short_Float
12671 @code{float}
12672 @item Float
12673 @code{float}
12674 @item Long_Float
12675 @code{double}
12676 @item Long_Long_Float
12677 This is the longest floating-point type supported by the hardware.
12678 @end table
12680 @noindent
12681 Additionally, there are the following general correspondences between Ada
12682 and C types:
12683 @itemize @bullet
12684 @item
12685 Ada enumeration types map to C enumeration types directly if pragma
12686 @code{Convention C} is specified, which causes them to have int
12687 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12688 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12689 @code{int}, respectively) depending on the number of values passed.
12690 This is the only case in which pragma @code{Convention C} affects the
12691 representation of an Ada type.
12693 @item
12694 Ada access types map to C pointers, except for the case of pointers to
12695 unconstrained types in Ada, which have no direct C equivalent.
12697 @item
12698 Ada arrays map directly to C arrays.
12700 @item
12701 Ada records map directly to C structures.
12703 @item
12704 Packed Ada records map to C structures where all members are bit fields
12705 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12706 @end itemize
12708 @node Interfacing to C++
12709 @section Interfacing to C++
12711 @noindent
12712 The interface to C++ makes use of the following pragmas, which are
12713 primarily intended to be constructed automatically using a binding generator
12714 tool, although it is possible to construct them by hand.  No suitable binding
12715 generator tool is supplied with GNAT though.
12717 Using these pragmas it is possible to achieve complete
12718 inter-operability between Ada tagged types and C class definitions.
12719 See @ref{Implementation Defined Pragmas}, for more details.
12721 @table @code
12722 @item pragma CPP_Class ([Entity =>] @var{local_name})
12723 The argument denotes an entity in the current declarative region that is
12724 declared as a tagged or untagged record type.  It indicates that the type
12725 corresponds to an externally declared C++ class type, and is to be laid
12726 out the same way that C++ would lay out the type.
12728 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12729 This pragma identifies an imported function (imported in the usual way
12730 with pragma @code{Import}) as corresponding to a C++ constructor.
12732 @item pragma CPP_Vtable @dots{}
12733 One @code{CPP_Vtable} pragma can be present for each component of type
12734 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12735 applies.
12736 @end table
12738 @node Interfacing to COBOL
12739 @section Interfacing to COBOL
12741 @noindent
12742 Interfacing to COBOL is achieved as described in section B.4 of
12743 the Ada 95 reference manual.
12745 @node Interfacing to Fortran
12746 @section Interfacing to Fortran
12748 @noindent
12749 Interfacing to Fortran is achieved as described in section B.5 of the
12750 reference manual.  The pragma @code{Convention Fortran}, applied to a
12751 multi-dimensional array causes the array to be stored in column-major
12752 order as required for convenient interface to Fortran.
12754 @node Interfacing to non-GNAT Ada code
12755 @section Interfacing to non-GNAT Ada code
12757 It is possible to specify the convention @code{Ada} in a pragma
12758 @code{Import} or pragma @code{Export}.  However this refers to
12759 the calling conventions used by GNAT, which may or may not be
12760 similar enough to those used by some other Ada 83 or Ada 95
12761 compiler to allow interoperation.
12763 If arguments types are kept simple, and if the foreign compiler generally
12764 follows system calling conventions, then it may be possible to integrate
12765 files compiled by other Ada compilers, provided that the elaboration
12766 issues are adequately addressed (for example by eliminating the
12767 need for any load time elaboration).
12769 In particular, GNAT running on VMS is designed to
12770 be highly compatible with the DEC Ada 83 compiler, so this is one
12771 case in which it is possible to import foreign units of this type,
12772 provided that the data items passed are restricted to simple scalar
12773 values or simple record types without variants, or simple array
12774 types with fixed bounds.
12776 @node Specialized Needs Annexes
12777 @chapter Specialized Needs Annexes
12779 @noindent
12780 Ada 95 defines a number of specialized needs annexes, which are not
12781 required in all implementations.  However, as described in this chapter,
12782 GNAT implements all of these special needs annexes:
12784 @table @asis
12785 @item Systems Programming (Annex C)
12786 The Systems Programming Annex is fully implemented.
12788 @item Real-Time Systems (Annex D)
12789 The Real-Time Systems Annex is fully implemented.
12791 @item Distributed Systems (Annex E)
12792 Stub generation is fully implemented in the GNAT compiler.  In addition,
12793 a complete compatible PCS is available as part of the GLADE system,
12794 a separate product.  When the two
12795 products are used in conjunction, this annex is fully implemented.
12797 @item Information Systems (Annex F)
12798 The Information Systems annex is fully implemented.
12800 @item Numerics (Annex G)
12801 The Numerics Annex is fully implemented.
12803 @item Safety and Security (Annex H)
12804 The Safety and Security annex is fully implemented.
12805 @end table
12807 @node Implementation of Specific Ada Features
12808 @chapter Implementation of Specific Ada Features
12810 @noindent
12811 This chapter describes the GNAT implementation of several Ada language
12812 facilities.
12814 @menu
12815 * Machine Code Insertions::
12816 * GNAT Implementation of Tasking::
12817 * GNAT Implementation of Shared Passive Packages::
12818 * Code Generation for Array Aggregates::
12819 * The Size of Discriminated Records with Default Discriminants::
12820 @end menu
12822 @node Machine Code Insertions
12823 @section Machine Code Insertions
12825 @noindent
12826 Package @code{Machine_Code} provides machine code support as described
12827 in the Ada 95 Reference Manual in two separate forms:
12828 @itemize @bullet
12829 @item
12830 Machine code statements, consisting of qualified expressions that
12831 fit the requirements of RM section 13.8.
12832 @item
12833 An intrinsic callable procedure, providing an alternative mechanism of
12834 including machine instructions in a subprogram.
12835 @end itemize
12837 @noindent
12838 The two features are similar, and both are closely related to the mechanism
12839 provided by the asm instruction in the GNU C compiler.  Full understanding
12840 and use of the facilities in this package requires understanding the asm
12841 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12842 by Richard Stallman. The relevant section is titled ``Extensions to the C
12843 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12845 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12846 semantic restrictions and effects as described below.  Both are provided so
12847 that the procedure call can be used as a statement, and the function call
12848 can be used to form a code_statement.
12850 The first example given in the GCC documentation is the C @code{asm}
12851 instruction:
12852 @smallexample
12853    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12854 @end smallexample
12856 @noindent
12857 The equivalent can be written for GNAT as:
12859 @smallexample @c ada
12860 Asm ("fsinx %1 %0",
12861      My_Float'Asm_Output ("=f", result),
12862      My_Float'Asm_Input  ("f",  angle));
12863 @end smallexample
12865 @noindent
12866 The first argument to @code{Asm} is the assembler template, and is
12867 identical to what is used in GNU C@.  This string must be a static
12868 expression.  The second argument is the output operand list.  It is
12869 either a single @code{Asm_Output} attribute reference, or a list of such
12870 references enclosed in parentheses (technically an array aggregate of
12871 such references).
12873 The @code{Asm_Output} attribute denotes a function that takes two
12874 parameters.  The first is a string, the second is the name of a variable
12875 of the type designated by the attribute prefix.  The first (string)
12876 argument is required to be a static expression and designates the
12877 constraint for the parameter (e.g.@: what kind of register is
12878 required).  The second argument is the variable to be updated with the
12879 result.  The possible values for constraint are the same as those used in
12880 the RTL, and are dependent on the configuration file used to build the
12881 GCC back end.  If there are no output operands, then this argument may
12882 either be omitted, or explicitly given as @code{No_Output_Operands}.
12884 The second argument of @code{@var{my_float}'Asm_Output} functions as
12885 though it were an @code{out} parameter, which is a little curious, but
12886 all names have the form of expressions, so there is no syntactic
12887 irregularity, even though normally functions would not be permitted
12888 @code{out} parameters.  The third argument is the list of input
12889 operands.  It is either a single @code{Asm_Input} attribute reference, or
12890 a list of such references enclosed in parentheses (technically an array
12891 aggregate of such references).
12893 The @code{Asm_Input} attribute denotes a function that takes two
12894 parameters.  The first is a string, the second is an expression of the
12895 type designated by the prefix.  The first (string) argument is required
12896 to be a static expression, and is the constraint for the parameter,
12897 (e.g.@: what kind of register is required).  The second argument is the
12898 value to be used as the input argument.  The possible values for the
12899 constant are the same as those used in the RTL, and are dependent on
12900 the configuration file used to built the GCC back end.
12902 If there are no input operands, this argument may either be omitted, or
12903 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12904 present in the above example, is a list of register names, called the
12905 @dfn{clobber} argument.  This argument, if given, must be a static string
12906 expression, and is a space or comma separated list of names of registers
12907 that must be considered destroyed as a result of the @code{Asm} call.  If
12908 this argument is the null string (the default value), then the code
12909 generator assumes that no additional registers are destroyed.
12911 The fifth argument, not present in the above example, called the
12912 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12913 the literal value @code{True} to indicate to the code generator that all
12914 optimizations with respect to the instruction specified should be
12915 suppressed, and that in particular, for an instruction that has outputs,
12916 the instruction will still be generated, even if none of the outputs are
12917 used.  See the full description in the GCC manual for further details.
12919 The @code{Asm} subprograms may be used in two ways.  First the procedure
12920 forms can be used anywhere a procedure call would be valid, and
12921 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12922 be used to intersperse machine instructions with other Ada statements.
12923 Second, the function forms, which return a dummy value of the limited
12924 private type @code{Asm_Insn}, can be used in code statements, and indeed
12925 this is the only context where such calls are allowed.  Code statements
12926 appear as aggregates of the form:
12928 @smallexample @c ada
12929 Asm_Insn'(Asm (@dots{}));
12930 Asm_Insn'(Asm_Volatile (@dots{}));
12931 @end smallexample
12933 @noindent
12934 In accordance with RM rules, such code statements are allowed only
12935 within subprograms whose entire body consists of such statements.  It is
12936 not permissible to intermix such statements with other Ada statements.
12938 Typically the form using intrinsic procedure calls is more convenient
12939 and more flexible.  The code statement form is provided to meet the RM
12940 suggestion that such a facility should be made available.  The following
12941 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12942 is used, the arguments may be given in arbitrary order, following the
12943 normal rules for use of positional and named arguments)
12945 @smallexample
12946 ASM_CALL ::= Asm (
12947                  [Template =>] static_string_EXPRESSION
12948                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12949                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12950                [,[Clobber  =>] static_string_EXPRESSION ]
12951                [,[Volatile =>] static_boolean_EXPRESSION] )
12953 OUTPUT_OPERAND_LIST ::=
12954   [PREFIX.]No_Output_Operands
12955 | OUTPUT_OPERAND_ATTRIBUTE
12956 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12958 OUTPUT_OPERAND_ATTRIBUTE ::=
12959   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12961 INPUT_OPERAND_LIST ::=
12962   [PREFIX.]No_Input_Operands
12963 | INPUT_OPERAND_ATTRIBUTE
12964 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12966 INPUT_OPERAND_ATTRIBUTE ::=
12967   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12968 @end smallexample
12970 @noindent
12971 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12972 are declared in the package @code{Machine_Code} and must be referenced
12973 according to normal visibility rules. In particular if there is no
12974 @code{use} clause for this package, then appropriate package name
12975 qualification is required.
12977 @node GNAT Implementation of Tasking
12978 @section GNAT Implementation of Tasking
12980 @noindent
12981 This chapter outlines the basic GNAT approach to tasking (in particular,
12982 a multi-layered library for portability) and discusses issues related
12983 to compliance with the Real-Time Systems Annex.
12985 @menu
12986 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12987 * Ensuring Compliance with the Real-Time Annex::
12988 @end menu
12990 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12991 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12993 @noindent
12994 GNAT's run-time support comprises two layers:
12996 @itemize @bullet
12997 @item GNARL (GNAT Run-time Layer)
12998 @item GNULL (GNAT Low-level Library)
12999 @end itemize
13001 @noindent
13002 In GNAT, Ada's tasking services rely on a platform and OS independent
13003 layer known as GNARL@.  This code is responsible for implementing the
13004 correct semantics of Ada's task creation, rendezvous, protected
13005 operations etc.
13007 GNARL decomposes Ada's tasking semantics into simpler lower level
13008 operations such as create a thread, set the priority of a thread,
13009 yield, create a lock, lock/unlock, etc.  The spec for these low-level
13010 operations constitutes GNULLI, the GNULL Interface.  This interface is
13011 directly inspired from the POSIX real-time API@.
13013 If the underlying executive or OS implements the POSIX standard
13014 faithfully, the GNULL Interface maps as is to the services offered by
13015 the underlying kernel.  Otherwise, some target dependent glue code maps
13016 the services offered by the underlying kernel to the semantics expected
13017 by GNARL@.
13019 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13020 key point is that each Ada task is mapped on a thread in the underlying
13021 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
13023 In addition Ada task priorities map onto the underlying thread priorities.
13024 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13026 @itemize @bullet
13027 @item
13028 The underlying scheduler is used to schedule the Ada tasks.  This
13029 makes Ada tasks as efficient as kernel threads from a scheduling
13030 standpoint.
13032 @item
13033 Interaction with code written in C containing threads is eased
13034 since at the lowest level Ada tasks and C threads map onto the same
13035 underlying kernel concept.
13037 @item
13038 When an Ada task is blocked during I/O the remaining Ada tasks are
13039 able to proceed.
13041 @item
13042 On multiprocessor systems Ada tasks can execute in parallel.
13043 @end itemize
13045 @noindent
13046 Some threads libraries offer a mechanism to fork a new process, with the
13047 child process duplicating the threads from the parent.
13048 GNAT does not
13049 support this functionality when the parent contains more than one task.
13050 @cindex Forking a new process
13052 @node Ensuring Compliance with the Real-Time Annex
13053 @subsection Ensuring Compliance with the Real-Time Annex
13054 @cindex Real-Time Systems Annex compliance
13056 @noindent
13057 Although mapping Ada tasks onto
13058 the underlying threads has significant advantages, it does create some
13059 complications when it comes to respecting the scheduling semantics
13060 specified in the real-time annex (Annex D).
13062 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13063 scheduling policy states:
13065 @quotation
13066 @emph{When the active priority of a ready task that is not running
13067 changes, or the setting of its base priority takes effect, the
13068 task is removed from the ready queue for its old active priority
13069 and is added at the tail of the ready queue for its new active
13070 priority, except in the case where the active priority is lowered
13071 due to the loss of inherited priority, in which case the task is
13072 added at the head of the ready queue for its new active priority.}
13073 @end quotation
13075 @noindent
13076 While most kernels do put tasks at the end of the priority queue when
13077 a task changes its priority, (which respects the main
13078 FIFO_Within_Priorities requirement), almost none keep a thread at the
13079 beginning of its priority queue when its priority drops from the loss
13080 of inherited priority.
13082 As a result most vendors have provided incomplete Annex D implementations.
13084 The GNAT run-time, has a nice cooperative solution to this problem
13085 which ensures that accurate FIFO_Within_Priorities semantics are
13086 respected.
13088 The principle is as follows.  When an Ada task T is about to start
13089 running, it checks whether some other Ada task R with the same
13090 priority as T has been suspended due to the loss of priority
13091 inheritance.  If this is the case, T yields and is placed at the end of
13092 its priority queue.  When R arrives at the front of the queue it
13093 executes.
13095 Note that this simple scheme preserves the relative order of the tasks
13096 that were ready to execute in the priority queue where R has been
13097 placed at the end.
13099 @node GNAT Implementation of Shared Passive Packages
13100 @section GNAT Implementation of Shared Passive Packages
13101 @cindex Shared passive packages
13103 @noindent
13104 GNAT fully implements the pragma @code{Shared_Passive} for
13105 @cindex pragma @code{Shared_Passive}
13106 the purpose of designating shared passive packages.
13107 This allows the use of passive partitions in the
13108 context described in the Ada Reference Manual; i.e. for communication
13109 between separate partitions of a distributed application using the
13110 features in Annex E.
13111 @cindex Annex E
13112 @cindex Distribution Systems Annex
13114 However, the implementation approach used by GNAT provides for more
13115 extensive usage as follows:
13117 @table @emph
13118 @item Communication between separate programs
13120 This allows separate programs to access the data in passive
13121 partitions, using protected objects for synchronization where
13122 needed. The only requirement is that the two programs have a
13123 common shared file system. It is even possible for programs
13124 running on different machines with different architectures
13125 (e.g. different endianness) to communicate via the data in
13126 a passive partition.
13128 @item Persistence between program runs
13130 The data in a passive package can persist from one run of a
13131 program to another, so that a later program sees the final
13132 values stored by a previous run of the same program.
13134 @end table
13136 @noindent
13137 The implementation approach used is to store the data in files. A
13138 separate stream file is created for each object in the package, and
13139 an access to an object causes the corresponding file to be read or
13140 written.
13142 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13143 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13144 set to the directory to be used for these files.
13145 The files in this directory
13146 have names that correspond to their fully qualified names. For
13147 example, if we have the package
13149 @smallexample @c ada
13150 package X is
13151   pragma Shared_Passive (X);
13152   Y : Integer;
13153   Z : Float;
13154 end X;
13155 @end smallexample
13157 @noindent
13158 and the environment variable is set to @code{/stemp/}, then the files created
13159 will have the names:
13161 @smallexample
13162 /stemp/x.y
13163 /stemp/x.z
13164 @end smallexample
13166 @noindent
13167 These files are created when a value is initially written to the object, and
13168 the files are retained until manually deleted. This provides the persistence
13169 semantics. If no file exists, it means that no partition has assigned a value
13170 to the variable; in this case the initial value declared in the package
13171 will be used. This model ensures that there are no issues in synchronizing
13172 the elaboration process, since elaboration of passive packages elaborates the
13173 initial values, but does not create the files.
13175 The files are written using normal @code{Stream_IO} access.
13176 If you want to be able
13177 to communicate between programs or partitions running on different
13178 architectures, then you should use the XDR versions of the stream attribute
13179 routines, since these are architecture independent.
13181 If active synchronization is required for access to the variables in the
13182 shared passive package, then as described in the Ada Reference Manual, the
13183 package may contain protected objects used for this purpose. In this case
13184 a lock file (whose name is @file{___lock} (three underscores)
13185 is created in the shared memory directory.
13186 @cindex @file{___lock} file (for shared passive packages)
13187 This is used to provide the required locking
13188 semantics for proper protected object synchronization.
13190 As of January 2003, GNAT supports shared passive packages on all platforms
13191 except for OpenVMS.
13193 @node Code Generation for Array Aggregates
13194 @section Code Generation for Array Aggregates
13196 @menu
13197 * Static constant aggregates with static bounds::
13198 * Constant aggregates with an unconstrained nominal types::
13199 * Aggregates with static bounds::
13200 * Aggregates with non-static bounds::
13201 * Aggregates in assignment statements::
13202 @end menu
13204 @noindent
13205 Aggregate have a rich syntax and allow the user to specify the values of
13206 complex data structures by means of a single construct.  As a result, the
13207 code generated for aggregates can be quite complex and involve loops, case
13208 statements and multiple assignments.  In the simplest cases, however, the
13209 compiler will recognize aggregates whose components and constraints are
13210 fully static, and in those cases the compiler will generate little or no
13211 executable code.  The following is an outline of the code that GNAT generates
13212 for various aggregate constructs.  For further details, the user will find it
13213 useful to examine the output produced by the -gnatG flag to see the expanded
13214 source that is input to the code generator.  The user will also want to examine
13215 the assembly code generated at various levels of optimization.
13217 The code generated for aggregates depends on the context, the component values,
13218 and the type.  In the context of an object declaration the code generated is
13219 generally simpler than in the case of an assignment.  As a general rule, static
13220 component values and static subtypes also lead to simpler code.
13222 @node Static constant aggregates with static bounds
13223 @subsection Static constant aggregates with static bounds
13225 @noindent
13226 For the declarations:
13227 @smallexample @c ada
13228     type One_Dim is array (1..10) of integer;
13229     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13230 @end smallexample
13232 @noindent
13233 GNAT generates no executable code: the constant ar0 is placed in static memory.
13234 The same is true for constant aggregates with named associations:
13236 @smallexample @c ada
13237     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13238     Cr3 : constant One_Dim := (others => 7777);
13239 @end smallexample
13241 @noindent
13242 The same is true for multidimensional constant arrays such as:
13244 @smallexample @c ada
13245     type two_dim is array (1..3, 1..3) of integer;
13246     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13247 @end smallexample
13249 @noindent
13250 The same is true for arrays of one-dimensional arrays: the following are
13251 static:
13253 @smallexample @c ada
13254 type ar1b  is array (1..3) of boolean;
13255 type ar_ar is array (1..3) of ar1b;
13256 None  : constant ar1b := (others => false);     --  fully static
13257 None2 : constant ar_ar := (1..3 => None);       --  fully static
13258 @end smallexample
13260 @noindent
13261 However, for multidimensional aggregates with named associations, GNAT will
13262 generate assignments and loops, even if all associations are static.  The
13263 following two declarations generate a loop for the first dimension, and
13264 individual component assignments for the second dimension:
13266 @smallexample @c ada
13267 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13268 Zero2: constant two_dim := (others => (others => 0));
13269 @end smallexample
13271 @node Constant aggregates with an unconstrained nominal types
13272 @subsection Constant aggregates with an unconstrained nominal types
13274 @noindent
13275 In such cases the aggregate itself establishes the subtype, so that
13276 associations with @code{others} cannot be used.  GNAT determines the
13277 bounds for the actual subtype of the aggregate, and allocates the
13278 aggregate statically as well.  No code is generated for the following:
13280 @smallexample @c ada
13281     type One_Unc is array (natural range <>) of integer;
13282     Cr_Unc : constant One_Unc := (12,24,36);
13283 @end smallexample
13285 @node Aggregates with static bounds
13286 @subsection Aggregates with static bounds
13288 @noindent
13289 In all previous examples the aggregate was the initial (and immutable) value
13290 of a constant.  If the aggregate initializes a variable, then code is generated
13291 for it as a combination of individual assignments and loops over the target
13292 object.  The declarations
13294 @smallexample @c ada
13295        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13296        Cr_Var2 : One_Dim := (others > -1);
13297 @end smallexample
13299 @noindent
13300 generate the equivalent of
13302 @smallexample @c ada
13303        Cr_Var1 (1) := 2;
13304        Cr_Var1 (2) := 3;
13305        Cr_Var1 (3) := 5;
13306        Cr_Var1 (4) := 11;
13308        for I in Cr_Var2'range loop
13309           Cr_Var2 (I) := =-1;
13310        end loop;
13311 @end smallexample
13313 @node Aggregates with non-static bounds
13314 @subsection Aggregates with non-static bounds
13316 @noindent
13317 If the bounds of the aggregate are not statically compatible with the bounds
13318 of the nominal subtype  of the target, then constraint checks have to be
13319 generated on the bounds.  For a multidimensional array, constraint checks may
13320 have to be applied to sub-arrays individually, if they do not have statically
13321 compatible subtypes.
13323 @node Aggregates in assignment statements
13324 @subsection Aggregates in assignment statements
13326 @noindent
13327 In general, aggregate assignment requires the construction of a temporary,
13328 and a copy from the temporary to the target of the assignment.  This is because
13329 it is not always possible to convert the assignment into a series of individual
13330 component assignments.  For example, consider the simple case:
13332 @smallexample @c ada
13333         A := (A(2), A(1));
13334 @end smallexample
13336 @noindent
13337 This cannot be converted into:
13339 @smallexample @c ada
13340         A(1) := A(2);
13341         A(2) := A(1);
13342 @end smallexample
13344 @noindent
13345 So the aggregate has to be built first in a separate location, and then
13346 copied into the target.  GNAT recognizes simple cases where this intermediate
13347 step is not required, and the assignments can be performed in place, directly
13348 into the target.  The following sufficient criteria are applied:
13350 @itemize @bullet
13351 @item
13352 The bounds of the aggregate are static, and the associations are static.
13353 @item
13354 The components of the aggregate are static constants, names of
13355 simple variables that are not renamings, or expressions not involving
13356 indexed components whose operands obey these rules.
13357 @end itemize
13359 @noindent
13360 If any of these conditions are violated, the aggregate will be built in
13361 a temporary (created either by the front-end or the code generator) and then
13362 that temporary will be copied onto the target.
13365 @node The Size of Discriminated Records with Default Discriminants
13366 @section The Size of Discriminated Records with Default Discriminants
13368 @noindent
13369 If a discriminated type @code{T} has discriminants with default values, it is
13370 possible to declare an object of this type without providing an explicit
13371 constraint:
13373 @smallexample @c ada
13374 @group
13375 type Size is range 1..100;
13377 type Rec (D : Size := 15) is record
13378    Name : String (1..D);
13379 end T;
13381 Word : Rec;
13382 @end group
13383 @end smallexample
13385 @noindent 
13386 Such an object is said to be @emph{unconstrained}.
13387 The discriminant of the object
13388 can be modified by a full assignment to the object, as long as it preserves the
13389 relation between the value of the discriminant, and the value of the components
13390 that depend on it:
13392 @smallexample @c ada
13393 @group
13394 Word := (3, "yes");
13396 Word := (5, "maybe");
13398 Word := (5, "no"); -- raises Constraint_Error
13399 @end group
13400 @end smallexample
13402 @noindent
13403 In order to support this behavior efficiently, an unconstrained object is
13404 given the maximum size that any value of the type requires. In the case
13405 above, @code{Word} has storage for the discriminant and for
13406 a @code{String} of length 100.
13407 It is important to note that unconstrained objects do not require dynamic
13408 allocation. It would be an improper implementation to place on the heap those
13409 components whose size depends on discriminants. (This improper implementation
13410 was used by some Ada83 compilers, where the @code{Name} component above
13411 would have
13412 been stored as a pointer to a dynamic string). Following the principle that
13413 dynamic storage management should never be introduced implicitly,
13414 an Ada95 compiler should reserve the full size for an unconstrained declared
13415 object, and place it on the stack.
13417 This maximum size approach
13418 has been a source of surprise to some users, who expect the default
13419 values of the discriminants to determine the size reserved for an
13420 unconstrained object: ``If the default is 15, why should the object occupy
13421 a larger size?''
13422 The answer, of course, is that the discriminant may be later modified,
13423 and its full range of values must be taken into account. This is why the
13424 declaration:
13426 @smallexample
13427 @group
13428 type Rec (D : Positive := 15) is record
13429    Name : String (1..D);
13430 end record;
13432 Too_Large : Rec;
13433 @end group
13434 @end smallexample
13436 @noindent
13437 is flagged by the compiler with a warning:
13438 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
13439 because the required size includes @code{Positive'Last}
13440 bytes. As the first example indicates, the proper approach is to declare an
13441 index type of ``reasonable'' range so that unconstrained objects are not too
13442 large.
13444 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
13445 created in the heap by means of an allocator, then it is @emph{not}
13446 unconstrained:
13447 it is constrained by the default values of the discriminants, and those values
13448 cannot be modified by full assignment. This is because in the presence of
13449 aliasing all views of the object (which may be manipulated by different tasks,
13450 say) must be consistent, so it is imperative that the object, once created,
13451 remain invariant.
13456 @node Project File Reference
13457 @chapter Project File Reference
13459 @noindent
13460 This chapter describes the syntax and semantics of project files.
13461 Project files specify the options to be used when building a system.
13462 Project files can specify global settings for all tools,
13463 as well as tool-specific settings.
13464 See the chapter on project files in the GNAT Users guide for examples of use.
13466 @menu
13467 * Reserved Words::
13468 * Lexical Elements::
13469 * Declarations::
13470 * Empty declarations::
13471 * Typed string declarations::
13472 * Variables::
13473 * Expressions::
13474 * Attributes::
13475 * Project Attributes::
13476 * Attribute References::
13477 * External Values::
13478 * Case Construction::
13479 * Packages::
13480 * Package Renamings::
13481 * Projects::
13482 * Project Extensions::
13483 * Project File Elaboration::
13484 @end menu
13486 @node Reserved Words
13487 @section Reserved Words
13489 @noindent
13490 All Ada95 reserved words are reserved in project files, and cannot be used
13491 as variable names or project names. In addition, the following are
13492 also reserved in project files:
13494 @itemize
13495 @item @code{extends}
13497 @item @code{external}
13499 @item @code{project}
13501 @end itemize
13503 @node Lexical Elements
13504 @section Lexical Elements
13506 @noindent
13507 Rules for identifiers are the same as in Ada95. Identifiers
13508 are case-insensitive.  Strings are case sensitive, except where noted.
13509 Comments have the same form as in Ada95.
13511 @noindent
13512 Syntax:
13514 @smallexample
13515 simple_name ::=
13516   identifier
13518 name ::=
13519   simple_name @{. simple_name@}
13520 @end smallexample
13522 @node Declarations
13523 @section Declarations
13525 @noindent
13526 Declarations introduce new entities that denote types, variables, attributes,
13527 and packages. Some declarations can only appear immediately within a project
13528 declaration. Others can appear within a project or within a package.
13530 Syntax:
13531 @smallexample
13532 declarative_item ::=
13533   simple_declarative_item |
13534   typed_string_declaration |
13535   package_declaration
13537 simple_declarative_item ::=
13538   variable_declaration |
13539   typed_variable_declaration |
13540   attribute_declaration |
13541   case_construction |
13542   empty_declaration
13543 @end smallexample
13545 @node Empty declarations
13546 @section Empty declarations
13548 @smallexample
13549 empty_declaration ::=
13550   @b{null} ;
13551 @end smallexample
13553 An empty declaration is allowed anywhere a declaration is allowed.
13554 It has no effect.
13556 @node Typed string declarations
13557 @section Typed string declarations
13559 @noindent
13560 Typed strings are sequences of string literals. Typed strings are the only
13561 named types in project files. They are used in case constructions, where they
13562 provide support for conditional attribute definitions.
13564 Syntax:
13565 @smallexample
13566 typed_string_declaration ::=
13567   @b{type} <typed_string_>_simple_name @b{is}
13568    ( string_literal @{, string_literal@} );
13569 @end smallexample
13571 @noindent
13572 A typed string declaration can only appear immediately within a project
13573 declaration.
13575 All the string literals in a typed string declaration must be distinct.
13577 @node Variables
13578 @section Variables
13580 @noindent
13581 Variables denote values, and appear as constituents of expressions.
13583 @smallexample
13584 typed_variable_declaration ::=
13585   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13587 variable_declaration ::=
13588   <variable_>simple_name := expression;
13589 @end smallexample
13591 @noindent
13592 The elaboration of a variable declaration introduces the variable and
13593 assigns to it the value of the expression. The name of the variable is
13594 available after the assignment symbol.
13596 @noindent
13597 A typed_variable can only be declare once.
13599 @noindent
13600 a non typed variable can be declared multiple times.
13602 @noindent
13603 Before the completion of its first declaration, the value of variable
13604 is the null string.
13606 @node Expressions
13607 @section Expressions
13609 @noindent
13610 An expression is a formula that defines a computation or retrieval of a value.
13611 In a project file the value of an expression is either a string or a list
13612 of strings. A string value in an expression is either a literal, the current
13613 value of a variable, an external value, an attribute reference, or a
13614 concatenation operation.
13616 Syntax:
13618 @smallexample
13619 expression ::=
13620   term @{& term@}
13622 term ::=
13623   string_literal |
13624   string_list |
13625   <variable_>name |
13626   external_value |
13627   attribute_reference
13629 string_literal ::=
13630   (same as Ada)
13632 string_list ::=
13633   ( <string_>expression @{ , <string_>expression @} )
13634 @end smallexample
13636 @subsection Concatenation
13637 @noindent
13638 The following concatenation functions are defined:
13640 @smallexample @c ada
13641   function "&" (X : String;      Y : String)      return String;
13642   function "&" (X : String_List; Y : String)      return String_List;
13643   function "&" (X : String_List; Y : String_List) return String_List;
13644 @end smallexample
13646 @node Attributes
13647 @section Attributes
13649 @noindent
13650 An attribute declaration defines a property of a project or package. This
13651 property can later be queried by means of an attribute reference.
13652 Attribute values are strings or string lists.
13654 Some attributes are associative arrays. These attributes are mappings whose
13655 domain is a set of strings. These attributes are declared one association
13656 at a time, by specifying a point in the domain and the corresponding image
13657 of the attribute. They may also be declared as a full associative array,
13658 getting the same associations as the corresponding attribute in an imported
13659 or extended project.
13661 Attributes that are not associative arrays are called simple attributes.
13663 Syntax:
13664 @smallexample
13665 attribute_declaration ::=
13666   full_associative_array_declaration |
13667   @b{for} attribute_designator @b{use} expression ;
13669 full_associative_array_declaration ::=
13670   @b{for} <associative_array_attribute_>simple_name @b{use}
13671   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13673 attribute_designator ::=
13674   <simple_attribute_>simple_name |
13675   <associative_array_attribute_>simple_name ( string_literal )
13676 @end smallexample
13678 @noindent
13679 Some attributes are project-specific, and can only appear immediately within
13680 a project declaration. Others are package-specific, and can only appear within
13681 the proper package.
13683 The expression in an attribute definition must be a string or a string_list.
13684 The string literal appearing in the attribute_designator of an associative
13685 array attribute is case-insensitive.
13687 @node Project Attributes
13688 @section Project Attributes
13690 @noindent
13691 The following attributes apply to a project. All of them are simple
13692 attributes.
13694 @table @code
13695 @item   Object_Dir
13696 Expression must be a path name. The attribute defines the
13697 directory in which the object files created by the build are to be placed. If
13698 not specified, object files are placed in the project directory.
13700 @item   Exec_Dir
13701 Expression must be a path name. The attribute defines the
13702 directory in which the executables created by the build are to be placed.
13703 If not specified, executables are placed in the object directory.
13705 @item  Source_Dirs
13706 Expression must be a list of path names. The attribute
13707 defines the directories in which the source files for the project are to be
13708 found. If not specified, source files are found in the project directory.
13710 @item  Source_Files
13711 Expression must be a list of file names. The attribute
13712 defines the individual files, in the project directory, which are to be used
13713 as sources for the project. File names are path_names that contain no directory
13714 information. If the project has no sources the attribute must be declared
13715 explicitly with an empty list.
13717 @item  Source_List_File
13718 Expression must a single path name. The attribute
13719 defines a text file that contains a list of source file names to be used
13720 as sources for the project
13722 @item  Library_Dir
13723 Expression must be a path name. The attribute defines the
13724 directory in which a  library is to be built.  The directory must exist, must
13725 be distinct from the project's object directory, and must be writable.
13727 @item  Library_Name
13728 Expression must be a string that is a legal file name,
13729 without extension. The attribute defines a string that is used to generate
13730 the name of the library to be built by the project.
13732 @item  Library_Kind
13733 Argument must be a string value that must be one of the
13734 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13735 string is case-insensitive. If this attribute is not specified, the library is
13736 a static library. Otherwise, the library may be dynamic or relocatable. This
13737 distinction is operating-system dependent.
13739 @item  Library_Version
13740 Expression must be a string value whose interpretation
13741 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13742 libraries as the internal name of the library (the @code{"soname"}). If the
13743 library file name (built from the @code{Library_Name}) is different from the
13744 @code{Library_Version}, then the library file will be a symbolic link to the
13745 actual file whose name will be @code{Library_Version}.
13747 @item Library_Interface
13748 Expression must be a string list. Each element of the string list
13749 must designate a unit of the project.
13750 If this attribute is present in a Library Project File, then the project
13751 file is a Stand-alone Library_Project_File.
13753 @item Library_Auto_Init
13754 Expression must be a single string "true" or "false", case-insensitive.
13755 If this attribute is present in a Stand-alone Library Project File,
13756 it indicates if initialization is automatic when the dynamic library
13757 is loaded.
13759 @item Library_Options
13760 Expression must be a string list. Indicates additional switches that
13761 are to be used when building a shared library.
13763 @item Library_GCC
13764 Expression must be a single string. Designates an alternative to "gcc"
13765 for building shared libraries.
13767 @item  Library_Src_Dir
13768 Expression must be a path name. The attribute defines the
13769 directory in which the sources of the interfaces of a Stand-alone Library will
13770 be copied.  The directory must exist, must be distinct from the project's
13771 object directory and source directories, and must be writable.
13773 @item  Main
13774 Expression must be a list of strings that are legal file names.
13775 These file names designate existing compilation units in the source directory
13776 that are legal main subprograms.
13778 When a project file is elaborated, as part of the execution of a gnatmake
13779 command, one or several executables are built and placed in the Exec_Dir.
13780 If the gnatmake command does not include explicit file names, the executables
13781 that are built correspond to the files specified by this attribute.
13783 @item Main_Language
13784 This is a simple attribute. Its value is a string that specifies the
13785 language of the main program.
13787 @item  Languages
13788 Expression must be a string list. Each string designates
13789 a programming language that is known to GNAT. The strings are case-insensitive.
13791 @item  Locally_Removed_Files
13792 This attribute is legal only in a project file that extends another.
13793 Expression must be a list of strings that are legal file names.
13794 Each file name must designate a source that would normally be inherited
13795 by the current project file. It cannot designate an immediate source that is
13796 not inherited. Each of the source files in the list are not considered to
13797 be sources of the project file: they are not inherited.
13798 @end table
13800 @node Attribute References
13801 @section Attribute References
13803 @noindent
13804 Attribute references are used to retrieve the value of previously defined
13805 attribute for a package or project.
13806 Syntax:
13807 @smallexample
13808 attribute_reference ::=
13809   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13811 attribute_prefix ::=
13812   @b{project} |
13813   <project_simple_name | package_identifier |
13814   <project_>simple_name . package_identifier
13815 @end smallexample
13817 @noindent
13818 If an attribute has not been specified for a given package or project, its
13819 value is the null string or the empty list.
13821 @node External Values
13822 @section External Values
13824 @noindent
13825 An external value is an expression whose value is obtained from the command
13826 that invoked the processing of the current project file (typically a
13827 gnatmake command).
13829 Syntax:
13830 @smallexample
13831 external_value ::=
13832   @b{external} ( string_literal [, string_literal] )
13833 @end smallexample
13835 @noindent
13836 The first string_literal is the string to be used on the command line or
13837 in the environment to specify the external value. The second string_literal,
13838 if present, is the default to use if there is no specification for this
13839 external value either on the command line or in the environment.
13841 @node Case Construction
13842 @section Case Construction
13844 @noindent
13845 A case construction supports attribute declarations that depend on the value of
13846 a previously declared variable.
13848 Syntax:
13849 @smallexample
13850 case_construction ::=
13851   @b{case} <typed_variable_>name @b{is}
13852     @{case_item@}
13853   @b{end case} ;
13855 case_item ::=
13856   @b{when} discrete_choice_list =>
13857     @{case_construction | attribute_declaration | empty_declaration@}
13859 discrete_choice_list ::=
13860   string_literal @{| string_literal@} |
13861     @b{others}
13862 @end smallexample
13864 @noindent
13865 All choices in a choice list must be distinct. The choice lists of two
13866 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13867 alternatives do not need to include all values of the type. An @code{others}
13868 choice must appear last in the list of alternatives.
13870 @node Packages
13871 @section Packages
13873 @noindent
13874 A package provides a grouping of variable declarations and attribute
13875 declarations to be used when invoking various GNAT tools. The name of
13876 the package indicates the tool(s) to which it applies.
13877 Syntax:
13879 @smallexample
13880 package_declaration ::=
13881   package_specification | package_renaming
13883 package_specification ::=
13884   @b{package} package_identifier @b{is}
13885     @{simple_declarative_item@}
13886   @b{end} package_identifier ;
13888 package_identifier ::=
13889   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13890   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13891   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13892 @end smallexample
13894 @subsection Package Naming
13896 @noindent
13897 The attributes of a @code{Naming} package specifies the naming conventions
13898 that apply to the source files in a project. When invoking other GNAT tools,
13899 they will use the sources in the source directories that satisfy these
13900 naming conventions.
13902 The following attributes apply to a @code{Naming} package:
13904 @table @code
13905 @item Casing
13906 This is a simple attribute whose value is a string. Legal values of this
13907 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13908 These strings are themselves case insensitive.
13910 @noindent
13911 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13913 @item Dot_Replacement
13914 This is a simple attribute whose string value satisfies the following
13915 requirements:
13917 @itemize @bullet
13918 @item It must not be empty
13919 @item It cannot start or end with an alphanumeric character
13920 @item It cannot be a single underscore
13921 @item It cannot start with an underscore followed by an alphanumeric
13922 @item It cannot contain a dot @code{'.'} if longer than one character
13923 @end itemize
13925 @noindent
13926 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13928 @item Spec_Suffix
13929 This is an associative array attribute, defined on language names,
13930 whose image is a string that must satisfy the following
13931 conditions:
13933 @itemize @bullet
13934 @item It must not be empty
13935 @item It cannot start with an alphanumeric character
13936 @item It cannot start with an underscore followed by an alphanumeric character
13937 @end itemize
13939 @noindent
13940 For Ada, the attribute denotes the suffix used in file names that contain
13941 library unit declarations, that is to say units that are package and
13942 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13943 specified, then the default is @code{".ads"}.
13945 For C and C++, the attribute denotes the suffix used in file names that
13946 contain prototypes.
13948 @item Body_Suffix
13949 This is an associative array attribute defined on language names,
13950 whose image is a string that must satisfy the following
13951 conditions:
13953 @itemize @bullet
13954 @item It must not be empty
13955 @item It cannot start with an alphanumeric character
13956 @item It cannot start with an underscore followed by an alphanumeric character
13957 @item It cannot be a suffix of @code{Spec_Suffix}
13958 @end itemize
13960 @noindent
13961 For Ada, the attribute denotes the suffix used in file names that contain
13962 library bodies, that is to say units that are package and subprogram bodies.
13963 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13964 @code{".adb"}.
13966 For C and C++, the attribute denotes the suffix used in file names that contain
13967 source code.
13969 @item Separate_Suffix
13970 This is a simple attribute whose value satisfies the same conditions as
13971 @code{Body_Suffix}.
13973 This attribute is specific to Ada. It denotes the suffix used in file names
13974 that contain separate bodies. If it is not specified, then it defaults to same
13975 value as @code{Body_Suffix ("Ada")}.
13977 @item Spec
13978 This is an associative array attribute, specific to Ada, defined over
13979 compilation unit names. The image is a string that is the name of the file
13980 that contains that library unit. The file name is case sensitive if the
13981 conventions of the host operating system require it.
13983 @item Body
13984 This is an associative array attribute, specific to Ada, defined over
13985 compilation unit names. The image is a string that is the name of the file
13986 that contains the library unit body for the named unit. The file name is case
13987 sensitive if the conventions of the host operating system require it.
13989 @item Specification_Exceptions
13990 This is an associative array attribute defined on language names,
13991 whose value is a list of strings.
13993 This attribute is not significant for Ada.
13995 For C and C++, each string in the list denotes the name of a file that
13996 contains prototypes, but whose suffix is not necessarily the
13997 @code{Spec_Suffix} for the language.
13999 @item Implementation_Exceptions
14000 This is an associative array attribute defined on language names,
14001 whose value is a list of strings.
14003 This attribute is not significant for Ada.
14005 For C and C++, each string in the list denotes the name of a file that
14006 contains source code, but whose suffix is not necessarily the
14007 @code{Body_Suffix} for the language.
14008 @end table
14010 The following attributes of package @code{Naming} are obsolescent. They are
14011 kept as synonyms of other attributes for compatibility with previous versions
14012 of the Project Manager.
14014 @table @code
14015 @item Specification_Suffix
14016 This is a synonym of @code{Spec_Suffix}.
14018 @item Implementation_Suffix
14019 This is a synonym of @code{Body_Suffix}.
14021 @item Specification
14022 This is a synonym of @code{Spec}.
14024 @item Implementation
14025 This is a synonym of @code{Body}.
14026 @end table
14028 @subsection package Compiler
14030 @noindent
14031 The attributes of the @code{Compiler} package specify the compilation options
14032 to be used by the underlying compiler.
14034 @table @code
14035 @item  Default_Switches
14036 This is an associative array attribute. Its
14037 domain is a set of language names. Its range is a string list that
14038 specifies the compilation options to be used when compiling a component
14039 written in that language, for which no file-specific switches have been
14040 specified..
14042 @item  Switches
14043 This is an associative array attribute. Its domain is
14044 a set of file names. Its range is a string list that specifies the
14045 compilation options to be used when compiling the named file. If a file
14046 is not specified in the Switches attribute, it is compiled with the
14047 settings specified by Default_Switches.
14049 @item  Local_Configuration_Pragmas.
14050 This is a simple attribute, whose
14051 value is a path name that designates a file containing configuration pragmas
14052 to be used for all invocations of the compiler for immediate sources of the
14053 project.
14055 @item Executable
14056 This is an associative array attribute. Its domain is
14057 a set of main source file names. Its range is a simple string that specifies
14058 the executable file name to be used when linking the specified main source.
14059 If a main source is not specified in the Executable attribute, the executable
14060 file name is deducted from the main source file name.
14061 @end table
14063 @subsection package Builder
14065 @noindent
14066 The attributes of package @code{Builder} specify the compilation, binding, and
14067 linking options to be used when building an executable for a project. The
14068 following attributes apply to package @code{Builder}:
14070 @table @code
14071 @item Default_Switches
14072 As above.
14074 @item Switches
14075 As above.
14077 @item Global_Configuration_Pragmas
14078 This is a simple attribute, whose
14079 value is a path name that designates a file that contains configuration pragmas
14080 to be used in every build of an executable. If both local and global
14081 configuration pragmas are specified, a compilation makes use of both sets.
14083 @item Executable
14084 This is an associative array attribute, defined over
14085 compilation unit names. The image is a string that is the name of the
14086 executable file corresponding to the main source file index.
14087 This attribute has no effect if its value is the empty string.
14089 @item Executable_Suffix
14090 This is a simple attribute whose value is a suffix to be added to
14091 the executables that don't have an attribute Executable specified.
14092 @end table
14094 @subsection package Gnatls
14096 @noindent
14097 The attributes of package @code{Gnatls} specify the tool options to be used
14098 when invoking the library browser @command{gnatls}.
14099 The following attributes apply to package @code{Gnatls}:
14101 @table @code
14102 @item Switches
14103 As above.
14104 @end table
14106 @subsection package Binder
14108 @noindent
14109 The attributes of package @code{Binder} specify the options to be used
14110 when invoking the binder in the construction of an executable.
14111 The following attributes apply to package @code{Binder}:
14113 @table @code
14114 @item     Default_Switches
14115 As above.
14116 @item     Switches
14117 As above.
14118 @end table
14120 @subsection package Linker
14122 @noindent
14123 The attributes of package @code{Linker} specify the options to be used when
14124 invoking the linker in the construction of an executable.
14125 The following attributes apply to package @code{Linker}:
14127 @table @code
14128 @item     Default_Switches
14129 As above
14130 @item     Switches
14131 As above.
14132 @end table
14134 @subsection package Cross_Reference
14136 @noindent
14137 The attributes of package @code{Cross_Reference} specify the tool options
14138 to be used
14139 when invoking the library tool @command{gnatxref}.
14140 The following attributes apply to package @code{Cross_Reference}:
14142 @table @code
14143 @item     Default_Switches
14144 As above.
14145 @item     Switches
14146 As above.
14147 @end table
14149 @subsection package   Finder
14151 @noindent
14152 The attributes of package @code{Finder} specify the tool options to be used
14153 when invoking the search tool @command{gnatfind}.
14154 The following attributes apply to package @code{Finder}:
14156 @table @code
14157 @item     Default_Switches
14158 As above.
14159 @item     Switches
14160 As above.
14161 @end table
14163 @subsection package Pretty_Printer
14165 @noindent
14166 The attributes of package @code{Pretty_Printer}
14167 specify the tool options to be used
14168 when invoking the formatting tool @command{gnatpp}.
14169 The following attributes apply to package @code{Pretty_Printer}:
14171 @table @code
14172 @item     Default_switches
14173 As above.
14174 @item     Switches
14175 As above.
14176 @end table
14178 @subsection  package IDE
14180 @noindent
14181 The attributes of package @code{IDE} specify the options to be used when using
14182 an Integrated Development Environment such as @command{GPS}.
14184 @table @code
14185 @item Remote_Host
14186 This is a simple attribute. Its value is a string that designates the remote
14187 host in a cross-compilation environment, to be used for remote compilation and
14188 debugging. This field should not be specified when running on the local
14189 machine.
14191 @item Program_Host
14192 This is a simple attribute. Its value is a string that specifies the
14193 name of IP address of the embedded target in a cross-compilation environment,
14194 on which the program should execute.
14196 @item Communication_Protocol
14197 This is a simple string attribute. Its value is the name of the protocol
14198 to use to communicate with the target in a cross-compilation environment,
14199 e.g. @code{"wtx"} or @code{"vxworks"}.
14201 @item Compiler_Command
14202 This is an associative array attribute, whose domain is a language name. Its
14203 value is  string that denotes the command to be used to invoke the compiler.
14204 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14205 gnatmake, in particular in the handling of switches.
14207 @item Debugger_Command
14208 This is simple attribute, Its value is a string that specifies the name of
14209 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14211 @item Default_Switches
14212 This is an associative array attribute. Its indexes are the name of the
14213 external tools that the GNAT Programming System (GPS) is supporting. Its
14214 value is a list of switches to use when invoking that tool.
14216 @item  Gnatlist
14217 This is a simple attribute.  Its value is a string that specifies the name
14218 of the @command{gnatls} utility to be used to retrieve information about the
14219 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14221 @item VCS_Kind
14222 This is a simple atribute. Is value is a string used to specify the
14223 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14224 ClearCase or Perforce.
14226 @item VCS_File_Check
14227 This is a simple attribute. Its value is a string that specifies the
14228 command used by the VCS to check the validity of a file, either
14229 when the user explicitly asks for a check, or as a sanity check before
14230 doing the check-in.
14232 @item VCS_Log_Check
14233 This is a simple attribute. Its value is a string that specifies
14234 the command used by the VCS to check the validity of a log file.
14236 @end table
14238 @node Package Renamings
14239 @section Package Renamings
14241 @noindent
14242 A package can be defined by a renaming declaration. The new package renames
14243 a package declared in a different project file, and has the same attributes
14244 as the package it renames.
14245 Syntax:
14246 @smallexample
14247 package_renaming ::==
14248   @b{package} package_identifier @b{renames}
14249        <project_>simple_name.package_identifier ;
14250 @end smallexample
14252 @noindent
14253 The package_identifier of the renamed package must be the same as the
14254 package_identifier. The project whose name is the prefix of the renamed
14255 package must contain a package declaration with this name. This project
14256 must appear in the context_clause of the enclosing project declaration,
14257 or be the parent project of the enclosing child project.
14259 @node Projects
14260 @section Projects
14262 @noindent
14263 A project file specifies a set of rules for constructing a software system.
14264 A project file can be self-contained, or depend on other project files.
14265 Dependencies are expressed through a context clause that names other projects.
14267 Syntax:
14269 @smallexample
14270 project ::=
14271   context_clause project_declaration
14273 project_declaration ::=
14274   simple_project_declaration | project_extension
14276 simple_project_declaration ::=
14277   @b{project} <project_>simple_name @b{is}
14278     @{declarative_item@}
14279   @b{end} <project_>simple_name;
14281 context_clause ::=
14282   @{with_clause@}
14284 with_clause ::=
14285   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14287 path_name ::=
14288    string_literal
14289 @end smallexample
14291 @noindent
14292 A path name denotes a project file. A path name can be absolute or relative.
14293 An absolute path name includes a sequence of directories, in the syntax of
14294 the host operating system, that identifies uniquely the project file in the
14295 file system. A relative path name identifies the project file, relative
14296 to the directory that contains the current project, or relative to a
14297 directory listed in the environment variable ADA_PROJECT_PATH.
14298 Path names are case sensitive if file names in the host operating system
14299 are case sensitive.
14301 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14302 directory names separated by colons (semicolons on Windows).
14304 A given project name can appear only once in a context_clause.
14306 It is illegal for a project imported by a context clause to refer, directly
14307 or indirectly, to the project in which this context clause appears (the
14308 dependency graph cannot contain cycles), except when one of the with_clause
14309 in the cycle is a @code{limited with}.
14311 @node Project Extensions
14312 @section Project Extensions
14314 @noindent
14315 A project extension introduces a new project, which inherits the declarations
14316 of another project.
14317 Syntax:
14318 @smallexample
14320 project_extension ::=
14321   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14322     @{declarative_item@}
14323   @b{end} <project_>simple_name;
14324 @end smallexample
14326 @noindent
14327 The project extension declares a child project. The child project inherits
14328 all the declarations and all the files of the parent project, These inherited
14329 declaration can be overridden in the child project, by means of suitable
14330 declarations.
14332 @node Project File Elaboration
14333 @section Project File Elaboration
14335 @noindent
14336 A project file is processed as part of the invocation of a gnat tool that
14337 uses the project option. Elaboration of the process file consists in the
14338 sequential elaboration of all its declarations. The computed values of
14339 attributes and variables in the project are then used to establish the
14340 environment in which the gnat tool will execute.
14342 @node Obsolescent Features
14343 @chapter Obsolescent Features
14345 @noindent
14346 This chapter describes features that are provided by GNAT, but are
14347 considered obsolescent since there are preferred ways of achieving
14348 the same effect. These features are provided solely for historical
14349 compatibility purposes.
14351 @menu
14352 * pragma No_Run_Time::
14353 * pragma Ravenscar::
14354 * pragma Restricted_Run_Time::
14355 @end menu
14357 @node pragma No_Run_Time
14358 @section pragma No_Run_Time
14360 The pragma @code{No_Run_Time} is used to achieve an affect similar
14361 to the use of the "Zero Foot Print" configurable run time, but without
14362 requiring a specially configured run time. The result of using this
14363 pragma, which must be used for all units in a partition, is to restrict
14364 the use of any language features requiring run-time support code. The
14365 preferred usage is to use an appropriately configured run-time that
14366 includes just those features that are to be made accessible.
14368 @node pragma Ravenscar
14369 @section pragma Ravenscar
14371 The pragma @code{Ravenscar} has exactly the same effect as pragma
14372 @code{Profile (Ravenscar)}. The latter usage is preferred since it
14373 is part of the new Ada 2005 standard.
14375 @node pragma Restricted_Run_Time
14376 @section pragma Restricted_Run_Time
14378 The pragma @code{Restricted_Run_Time} has exactly the same effect as
14379 pragma @code{Profile (Restricted)}. The latter usage is
14380 preferred since the Ada 2005 pragma @code{Profile} is intended for
14381 this kind of implementation dependent addition.
14383 @include fdl.texi
14384 @c GNU Free Documentation License
14386 @node Index,,GNU Free Documentation License, Top
14387 @unnumbered Index
14389 @printindex cp
14391 @contents
14393 @bye