Daily bump.
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobfad7e14652e75495351c47599deaeba7352d9efb
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-2006 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 EDITION GNAT
21 @settitle GNAT Reference Manual
23 @setchapternewpage odd
24 @syncodeindex fn cp
26 @include gcc-common.texi
28 @dircategory GNU Ada tools
29 @direntry
30 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
31 @end direntry
33 @copying
34 Copyright @copyright{} 1995-2004, Free Software Foundation
36 Permission is granted to copy, distribute and/or modify this document
37 under the terms of the GNU Free Documentation License, Version 1.2
38 or any later version published by the Free Software Foundation;
39 with the Invariant Sections being ``GNU Free Documentation License'',
40 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
41 no Back-Cover Texts. A copy of the license is included in the section
42 entitled ``GNU Free Documentation License''.
43 @end copying
45 @titlepage
47 @title GNAT Reference Manual
48 @subtitle GNAT, The GNU Ada 95 Compiler
49 @subtitle GCC version @value{version-GCC}
50 @author AdaCore
52 @page
53 @vskip 0pt plus 1filll
55 @insertcopying
57 @end titlepage
59 @ifnottex
60 @node Top, About This Guide, (dir), (dir)
61 @top GNAT Reference Manual
63 @noindent
64 GNAT Reference Manual
66 @noindent
67 GNAT, The GNU Ada 95 Compiler@*
68 GCC version @value{version-GCC}@*
70 @noindent
71 AdaCore
73 @menu
74 * About This Guide::
75 * Implementation Defined Pragmas::
76 * Implementation Defined Attributes::
77 * Implementation Advice::
78 * Implementation Defined Characteristics::
79 * Intrinsic Subprograms::
80 * Representation Clauses and Pragmas::
81 * Standard Library Routines::
82 * The Implementation of Standard I/O::
83 * The GNAT Library::
84 * Interfacing to Other Languages::
85 * Specialized Needs Annexes::
86 * Implementation of Specific Ada Features::
87 * Project File Reference::
88 * Obsolescent Features::
89 * GNU Free Documentation License::
90 * Index::
92  --- The Detailed Node Listing ---
94 About This Guide
96 * What This Reference Manual Contains::
97 * Related Information::
99 Implementation Defined Pragmas
101 * Pragma Abort_Defer::
102 * Pragma Ada_83::
103 * Pragma Ada_95::
104 * Pragma Ada_05::
105 * Pragma Ada_2005::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Ast_Entry::
109 * Pragma C_Pass_By_Copy::
110 * Pragma Comment::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Warning::
113 * Pragma Complete_Representation::
114 * Pragma Complex_Representation::
115 * Pragma Component_Alignment::
116 * Pragma Convention_Identifier::
117 * Pragma CPP_Class::
118 * Pragma CPP_Constructor::
119 * Pragma CPP_Virtual::
120 * Pragma CPP_Vtable::
121 * Pragma Debug::
122 * Pragma Debug_Policy::
123 * Pragma Detect_Blocking::
124 * Pragma Elaboration_Checks::
125 * Pragma Eliminate::
126 * Pragma Export_Exception::
127 * Pragma Export_Function::
128 * Pragma Export_Object::
129 * Pragma Export_Procedure::
130 * Pragma Export_Value::
131 * Pragma Export_Valued_Procedure::
132 * Pragma Extend_System::
133 * Pragma External::
134 * Pragma External_Name_Casing::
135 * Pragma Finalize_Storage_Only::
136 * Pragma Float_Representation::
137 * Pragma Ident::
138 * Pragma Import_Exception::
139 * Pragma Import_Function::
140 * Pragma Import_Object::
141 * Pragma Import_Procedure::
142 * Pragma Import_Valued_Procedure::
143 * Pragma Initialize_Scalars::
144 * Pragma Inline_Always::
145 * Pragma Inline_Generic::
146 * Pragma Interface::
147 * Pragma Interface_Name::
148 * Pragma Interrupt_Handler::
149 * Pragma Interrupt_State::
150 * Pragma Keep_Names::
151 * Pragma License::
152 * Pragma Link_With::
153 * Pragma Linker_Alias::
154 * Pragma Linker_Constructor::
155 * Pragma Linker_Destructor::
156 * Pragma Linker_Section::
157 * Pragma Long_Float::
158 * Pragma Machine_Attribute::
159 * Pragma Main_Storage::
160 * Pragma No_Return::
161 * Pragma No_Strict_Aliasing ::
162 * Pragma Normalize_Scalars::
163 * Pragma Obsolescent::
164 * Pragma Passive::
165 * Pragma Persistent_BSS::
166 * Pragma Polling::
167 * Pragma Profile (Ravenscar)::
168 * Pragma Profile (Restricted)::
169 * Pragma Psect_Object::
170 * Pragma Pure_Function::
171 * Pragma Restriction_Warnings::
172 * Pragma Source_File_Name::
173 * Pragma Source_File_Name_Project::
174 * Pragma Source_Reference::
175 * Pragma Stream_Convert::
176 * Pragma Style_Checks::
177 * Pragma Subtitle::
178 * Pragma Suppress::
179 * Pragma Suppress_All::
180 * Pragma Suppress_Exception_Locations::
181 * Pragma Suppress_Initialization::
182 * Pragma Task_Info::
183 * Pragma Task_Name::
184 * Pragma Task_Storage::
185 * Pragma Thread_Body::
186 * Pragma Time_Slice::
187 * Pragma Title::
188 * Pragma Unchecked_Union::
189 * Pragma Unimplemented_Unit::
190 * Pragma Universal_Data::
191 * Pragma Unreferenced::
192 * Pragma Unreserve_All_Interrupts::
193 * Pragma Unsuppress::
194 * Pragma Use_VADS_Size::
195 * Pragma Validity_Checks::
196 * Pragma Volatile::
197 * Pragma Warnings::
198 * Pragma Weak_External::
199 * Pragma Wide_Character_Encoding::
201 Implementation Defined Attributes
203 * Abort_Signal::
204 * Address_Size::
205 * Asm_Input::
206 * Asm_Output::
207 * AST_Entry::
208 * Bit::
209 * Bit_Position::
210 * Code_Address::
211 * Default_Bit_Order::
212 * Elaborated::
213 * Elab_Body::
214 * Elab_Spec::
215 * Emax::
216 * Enum_Rep::
217 * Epsilon::
218 * Fixed_Value::
219 * Has_Access_Values::
220 * Has_Discriminants::
221 * Img::
222 * Integer_Value::
223 * Large::
224 * Machine_Size::
225 * Mantissa::
226 * Max_Interrupt_Priority::
227 * Max_Priority::
228 * Maximum_Alignment::
229 * Mechanism_Code::
230 * Null_Parameter::
231 * Object_Size::
232 * Passed_By_Reference::
233 * Range_Length::
234 * Safe_Emax::
235 * Safe_Large::
236 * Small::
237 * Storage_Unit::
238 * Stub_Type::
239 * Target_Name::
240 * Tick::
241 * To_Address::
242 * Type_Class::
243 * UET_Address::
244 * Unconstrained_Array::
245 * Universal_Literal_String::
246 * Unrestricted_Access::
247 * VADS_Size::
248 * Value_Size::
249 * Wchar_T_Size::
250 * Word_Size::
252 The Implementation of Standard I/O
254 * Standard I/O Packages::
255 * FORM Strings::
256 * Direct_IO::
257 * Sequential_IO::
258 * Text_IO::
259 * Wide_Text_IO::
260 * Wide_Wide_Text_IO::
261 * Stream_IO::
262 * Shared Files::
263 * Open Modes::
264 * Operations on C Streams::
265 * Interfacing to C Streams::
267 The GNAT Library
269 * Ada.Characters.Latin_9 (a-chlat9.ads)::
270 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
271 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
272 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
273 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
274 * Ada.Command_Line.Remove (a-colire.ads)::
275 * Ada.Command_Line.Environment (a-colien.ads)::
276 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
277 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
278 * Ada.Exceptions.Traceback (a-exctra.ads)::
279 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
280 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
281 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
282 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
283 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
284 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
285 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
286 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
287 * GNAT.Altivec (g-altive.ads)::
288 * GNAT.Altivec.Conversions (g-altcon.ads)::
289 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
290 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
291 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
292 * GNAT.Array_Split (g-arrspl.ads)::
293 * GNAT.AWK (g-awk.ads)::
294 * GNAT.Bounded_Buffers (g-boubuf.ads)::
295 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
296 * GNAT.Bubble_Sort (g-bubsor.ads)::
297 * GNAT.Bubble_Sort_A (g-busora.ads)::
298 * GNAT.Bubble_Sort_G (g-busorg.ads)::
299 * GNAT.Calendar (g-calend.ads)::
300 * GNAT.Calendar.Time_IO (g-catiio.ads)::
301 * GNAT.Case_Util (g-casuti.ads)::
302 * GNAT.CGI (g-cgi.ads)::
303 * GNAT.CGI.Cookie (g-cgicoo.ads)::
304 * GNAT.CGI.Debug (g-cgideb.ads)::
305 * GNAT.Command_Line (g-comlin.ads)::
306 * GNAT.Compiler_Version (g-comver.ads)::
307 * GNAT.Ctrl_C (g-ctrl_c.ads)::
308 * GNAT.CRC32 (g-crc32.ads)::
309 * GNAT.Current_Exception (g-curexc.ads)::
310 * GNAT.Debug_Pools (g-debpoo.ads)::
311 * GNAT.Debug_Utilities (g-debuti.ads)::
312 * GNAT.Directory_Operations (g-dirope.ads)::
313 * GNAT.Dynamic_HTables (g-dynhta.ads)::
314 * GNAT.Dynamic_Tables (g-dyntab.ads)::
315 * GNAT.Exception_Actions (g-excact.ads)::
316 * GNAT.Exception_Traces (g-exctra.ads)::
317 * GNAT.Exceptions (g-except.ads)::
318 * GNAT.Expect (g-expect.ads)::
319 * GNAT.Float_Control (g-flocon.ads)::
320 * GNAT.Heap_Sort (g-heasor.ads)::
321 * GNAT.Heap_Sort_A (g-hesora.ads)::
322 * GNAT.Heap_Sort_G (g-hesorg.ads)::
323 * GNAT.HTable (g-htable.ads)::
324 * GNAT.IO (g-io.ads)::
325 * GNAT.IO_Aux (g-io_aux.ads)::
326 * GNAT.Lock_Files (g-locfil.ads)::
327 * GNAT.MD5 (g-md5.ads)::
328 * GNAT.Memory_Dump (g-memdum.ads)::
329 * GNAT.Most_Recent_Exception (g-moreex.ads)::
330 * GNAT.OS_Lib (g-os_lib.ads)::
331 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
332 * GNAT.Regexp (g-regexp.ads)::
333 * GNAT.Registry (g-regist.ads)::
334 * GNAT.Regpat (g-regpat.ads)::
335 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
336 * GNAT.Semaphores (g-semaph.ads)::
337 * GNAT.Signals (g-signal.ads)::
338 * GNAT.Sockets (g-socket.ads)::
339 * GNAT.Source_Info (g-souinf.ads)::
340 * GNAT.Spell_Checker (g-speche.ads)::
341 * GNAT.Spitbol.Patterns (g-spipat.ads)::
342 * GNAT.Spitbol (g-spitbo.ads)::
343 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
344 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
345 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
346 * GNAT.Strings (g-string.ads)::
347 * GNAT.String_Split (g-strspl.ads)::
348 * GNAT.Table (g-table.ads)::
349 * GNAT.Task_Lock (g-tasloc.ads)::
350 * GNAT.Threads (g-thread.ads)::
351 * GNAT.Traceback (g-traceb.ads)::
352 * GNAT.Traceback.Symbolic (g-trasym.ads)::
353 * GNAT.Wide_String_Split (g-wistsp.ads)::
354 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
355 * Interfaces.C.Extensions (i-cexten.ads)::
356 * Interfaces.C.Streams (i-cstrea.ads)::
357 * Interfaces.CPP (i-cpp.ads)::
358 * Interfaces.Os2lib (i-os2lib.ads)::
359 * Interfaces.Os2lib.Errors (i-os2err.ads)::
360 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
361 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
362 * Interfaces.Packed_Decimal (i-pacdec.ads)::
363 * Interfaces.VxWorks (i-vxwork.ads)::
364 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
365 * System.Address_Image (s-addima.ads)::
366 * System.Assertions (s-assert.ads)::
367 * System.Memory (s-memory.ads)::
368 * System.Partition_Interface (s-parint.ads)::
369 * System.Restrictions (s-restri.ads)::
370 * System.Rident (s-rident.ads)::
371 * System.Task_Info (s-tasinf.ads)::
372 * System.Wch_Cnv (s-wchcnv.ads)::
373 * System.Wch_Con (s-wchcon.ads)::
375 Text_IO
377 * Text_IO Stream Pointer Positioning::
378 * Text_IO Reading and Writing Non-Regular Files::
379 * Get_Immediate::
380 * Treating Text_IO Files as Streams::
381 * Text_IO Extensions::
382 * Text_IO Facilities for Unbounded Strings::
384 Wide_Text_IO
386 * Wide_Text_IO Stream Pointer Positioning::
387 * Wide_Text_IO Reading and Writing Non-Regular Files::
389 Wide_Wide_Text_IO
391 * Wide_Wide_Text_IO Stream Pointer Positioning::
392 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
394 Interfacing to Other Languages
396 * Interfacing to C::
397 * Interfacing to C++::
398 * Interfacing to COBOL::
399 * Interfacing to Fortran::
400 * Interfacing to non-GNAT Ada code::
402 Specialized Needs Annexes
404 Implementation of Specific Ada Features
405 * Machine Code Insertions::
406 * GNAT Implementation of Tasking::
407 * GNAT Implementation of Shared Passive Packages::
408 * Code Generation for Array Aggregates::
409 * The Size of Discriminated Records with Default Discriminants::
410 * Strict Conformance to the Ada 95 Reference Manual::
412 Project File Reference
414 Obsolescent Features
416 GNU Free Documentation License
418 Index
419 @end menu
421 @end ifnottex
423 @node About This Guide
424 @unnumbered About This Guide
426 @ifclear PROEDITION
427 @noindent
428 This manual contains useful information in writing programs using the
429 GNAT compiler.  It includes information on implementation dependent
430 characteristics of GNAT, including all the information required by Annex
431 M of the standard.
432 @end ifclear
434 @ifset PROEDITION
435 @noindent
436 This manual contains useful information in writing programs using the
437 GNAT Pro compiler.  It includes information on implementation dependent
438 characteristics of GNAT Pro, including all the information required by Annex
439 M of the standard.
440 @end ifset
442 Ada 95 is designed to be highly portable.
443 In general, a program will have the same effect even when compiled by
444 different compilers on different platforms.
445 However, since Ada 95 is designed to be used in a
446 wide variety of applications, it also contains a number of system
447 dependent features to be used in interfacing to the external world.
448 @cindex Implementation-dependent features
449 @cindex Portability
451 Note: Any program that makes use of implementation-dependent features
452 may be non-portable.  You should follow good programming practice and
453 isolate and clearly document any sections of your program that make use
454 of these features in a non-portable manner.
456 @ifset PROEDITION
457 For ease of exposition, ``GNAT Pro'' will be referred to simply as
458 ``GNAT'' in the remainder of this document.
459 @end ifset
461 @menu
462 * What This Reference Manual Contains::
463 * Conventions::
464 * Related Information::
465 @end menu
467 @node What This Reference Manual Contains
468 @unnumberedsec What This Reference Manual Contains
470 @noindent
471 This reference manual contains the following chapters:
473 @itemize @bullet
474 @item
475 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
476 pragmas, which can be used to extend and enhance the functionality of the
477 compiler.
479 @item
480 @ref{Implementation Defined Attributes}, lists GNAT
481 implementation-dependent attributes which can be used to extend and
482 enhance the functionality of the compiler.
484 @item
485 @ref{Implementation Advice}, provides information on generally
486 desirable behavior which are not requirements that all compilers must
487 follow since it cannot be provided on all systems, or which may be
488 undesirable on some systems.
490 @item
491 @ref{Implementation Defined Characteristics}, provides a guide to
492 minimizing implementation dependent features.
494 @item
495 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
496 implemented by GNAT, and how they can be imported into user
497 application programs.
499 @item
500 @ref{Representation Clauses and Pragmas}, describes in detail the
501 way that GNAT represents data, and in particular the exact set
502 of representation clauses and pragmas that is accepted.
504 @item
505 @ref{Standard Library Routines}, provides a listing of packages and a
506 brief description of the functionality that is provided by Ada's
507 extensive set of standard library routines as implemented by GNAT@.
509 @item
510 @ref{The Implementation of Standard I/O}, details how the GNAT
511 implementation of the input-output facilities.
513 @item
514 @ref{The GNAT Library}, is a catalog of packages that complement
515 the Ada predefined library.
517 @item
518 @ref{Interfacing to Other Languages}, describes how programs
519 written in Ada using GNAT can be interfaced to other programming
520 languages.
522 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
523 of the specialized needs annexes.
525 @item
526 @ref{Implementation of Specific Ada Features}, discusses issues related
527 to GNAT's implementation of machine code insertions, tasking, and several
528 other features.
530 @item
531 @ref{Project File Reference}, presents the syntax and semantics
532 of project files.
534 @item
535 @ref{Obsolescent Features} documents implementation dependent features,
536 including pragmas and attributes, which are considered obsolescent, since
537 there are other preferred ways of achieving the same results. These
538 obsolescent forms are retained for backwards compatibility.
540 @end itemize
542 @cindex Ada 95 ISO/ANSI Standard
543 @noindent
544 This reference manual assumes that you are familiar with Ada 95
545 language, as described in the International Standard
546 ANSI/ISO/IEC-8652:1995, Jan 1995.
548 @node Conventions
549 @unnumberedsec Conventions
550 @cindex Conventions, typographical
551 @cindex Typographical conventions
553 @noindent
554 Following are examples of the typographical and graphic conventions used
555 in this guide:
557 @itemize @bullet
558 @item
559 @code{Functions}, @code{utility program names}, @code{standard names},
560 and @code{classes}.
562 @item
563 @code{Option flags}
565 @item
566 @file{File Names}, @samp{button names}, and @samp{field names}.
568 @item
569 @code{Variables}.
571 @item
572 @emph{Emphasis}.
574 @item
575 [optional information or parameters]
577 @item
578 Examples are described by text
579 @smallexample
580 and then shown this way.
581 @end smallexample
582 @end itemize
584 @noindent
585 Commands that are entered by the user are preceded in this manual by the
586 characters @samp{$ } (dollar sign followed by space).  If your system uses this
587 sequence as a prompt, then the commands will appear exactly as you see them
588 in the manual.  If your system uses some other prompt, then the command will
589 appear with the @samp{$} replaced by whatever prompt character you are using.
591 @node Related Information
592 @unnumberedsec Related Information
593 @noindent
594 See the following documents for further information on GNAT:
596 @itemize @bullet
597 @item
598 @cite{GNAT User's Guide}, which provides information on how to use
599 the GNAT compiler system.
601 @item
602 @cite{Ada 95 Reference Manual}, which contains all reference
603 material for the Ada 95 programming language.
605 @item
606 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
607 of the standard reference manual cited above.  The annotations describe
608 detailed aspects of the design decision, and in particular contain useful
609 sections on Ada 83 compatibility.
611 @item
612 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
613 which contains specific information on compatibility between GNAT and
614 DEC Ada 83 systems.
616 @item
617 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
618 describes in detail the pragmas and attributes provided by the DEC Ada 83
619 compiler system.
621 @end itemize
623 @node Implementation Defined Pragmas
624 @chapter Implementation Defined Pragmas
626 @noindent
627 Ada 95 defines a set of pragmas that can be used to supply additional
628 information to the compiler.  These language defined pragmas are
629 implemented in GNAT and work as described in the Ada 95 Reference
630 Manual.
632 In addition, Ada 95 allows implementations to define additional pragmas
633 whose meaning is defined by the implementation.  GNAT provides a number
634 of these implementation-dependent pragmas which can be used to extend
635 and enhance the functionality of the compiler.  This section of the GNAT
636 Reference Manual describes these additional pragmas.
638 Note that any program using these pragmas may not be portable to other
639 compilers (although GNAT implements this set of pragmas on all
640 platforms).  Therefore if portability to other compilers is an important
641 consideration, the use of these pragmas should be minimized.
643 @menu
644 * Pragma Abort_Defer::
645 * Pragma Ada_83::
646 * Pragma Ada_95::
647 * Pragma Ada_05::
648 * Pragma Ada_2005::
649 * Pragma Annotate::
650 * Pragma Assert::
651 * Pragma Ast_Entry::
652 * Pragma C_Pass_By_Copy::
653 * Pragma Comment::
654 * Pragma Common_Object::
655 * Pragma Compile_Time_Warning::
656 * Pragma Complete_Representation::
657 * Pragma Complex_Representation::
658 * Pragma Component_Alignment::
659 * Pragma Convention_Identifier::
660 * Pragma CPP_Class::
661 * Pragma CPP_Constructor::
662 * Pragma CPP_Virtual::
663 * Pragma CPP_Vtable::
664 * Pragma Debug::
665 * Pragma Debug_Policy::
666 * Pragma Detect_Blocking::
667 * Pragma Elaboration_Checks::
668 * Pragma Eliminate::
669 * Pragma Export_Exception::
670 * Pragma Export_Function::
671 * Pragma Export_Object::
672 * Pragma Export_Procedure::
673 * Pragma Export_Value::
674 * Pragma Export_Valued_Procedure::
675 * Pragma Extend_System::
676 * Pragma External::
677 * Pragma External_Name_Casing::
678 * Pragma Finalize_Storage_Only::
679 * Pragma Float_Representation::
680 * Pragma Ident::
681 * Pragma Import_Exception::
682 * Pragma Import_Function::
683 * Pragma Import_Object::
684 * Pragma Import_Procedure::
685 * Pragma Import_Valued_Procedure::
686 * Pragma Initialize_Scalars::
687 * Pragma Inline_Always::
688 * Pragma Inline_Generic::
689 * Pragma Interface::
690 * Pragma Interface_Name::
691 * Pragma Interrupt_Handler::
692 * Pragma Interrupt_State::
693 * Pragma Keep_Names::
694 * Pragma License::
695 * Pragma Link_With::
696 * Pragma Linker_Alias::
697 * Pragma Linker_Constructor::
698 * Pragma Linker_Destructor::
699 * Pragma Linker_Section::
700 * Pragma Long_Float::
701 * Pragma Machine_Attribute::
702 * Pragma Main_Storage::
703 * Pragma No_Return::
704 * Pragma No_Strict_Aliasing::
705 * Pragma Normalize_Scalars::
706 * Pragma Obsolescent::
707 * Pragma Passive::
708 * Pragma Persistent_BSS::
709 * Pragma Polling::
710 * Pragma Profile (Ravenscar)::
711 * Pragma Profile (Restricted)::
712 * Pragma Psect_Object::
713 * Pragma Pure_Function::
714 * Pragma Restriction_Warnings::
715 * Pragma Source_File_Name::
716 * Pragma Source_File_Name_Project::
717 * Pragma Source_Reference::
718 * Pragma Stream_Convert::
719 * Pragma Style_Checks::
720 * Pragma Subtitle::
721 * Pragma Suppress::
722 * Pragma Suppress_All::
723 * Pragma Suppress_Exception_Locations::
724 * Pragma Suppress_Initialization::
725 * Pragma Task_Info::
726 * Pragma Task_Name::
727 * Pragma Task_Storage::
728 * Pragma Thread_Body::
729 * Pragma Time_Slice::
730 * Pragma Title::
731 * Pragma Unchecked_Union::
732 * Pragma Unimplemented_Unit::
733 * Pragma Universal_Data::
734 * Pragma Unreferenced::
735 * Pragma Unreserve_All_Interrupts::
736 * Pragma Unsuppress::
737 * Pragma Use_VADS_Size::
738 * Pragma Validity_Checks::
739 * Pragma Volatile::
740 * Pragma Warnings::
741 * Pragma Weak_External::
742 * Pragma Wide_Character_Encoding::
743 @end menu
745 @node Pragma Abort_Defer
746 @unnumberedsec Pragma Abort_Defer
747 @findex Abort_Defer
748 @cindex Deferring aborts
749 @noindent
750 Syntax:
751 @smallexample
752 pragma Abort_Defer;
753 @end smallexample
755 @noindent
756 This pragma must appear at the start of the statement sequence of a
757 handled sequence of statements (right after the @code{begin}).  It has
758 the effect of deferring aborts for the sequence of statements (but not
759 for the declarations or handlers, if any, associated with this statement
760 sequence).
762 @node Pragma Ada_83
763 @unnumberedsec Pragma Ada_83
764 @findex Ada_83
765 @noindent
766 Syntax:
767 @smallexample @c ada
768 pragma Ada_83;
769 @end smallexample
771 @noindent
772 A configuration pragma that establishes Ada 83 mode for the unit to
773 which it applies, regardless of the mode set by the command line
774 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
775 the syntax and semantics of Ada 83, as defined in the original Ada
776 83 Reference Manual as possible.  In particular, the new Ada 95
777 keywords are not recognized, optional package bodies are allowed,
778 and generics may name types with unknown discriminants without using
779 the @code{(<>)} notation.  In addition, some but not all of the additional
780 restrictions of Ada 83 are enforced.
782 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
783 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
784 Secondly, it aids in keeping code backwards compatible with Ada 83.
785 However, there is no guarantee that code that is processed correctly
786 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
787 83 compiler, since GNAT does not enforce all the additional checks
788 required by Ada 83.
790 @node Pragma Ada_95
791 @unnumberedsec Pragma Ada_95
792 @findex Ada_95
793 @noindent
794 Syntax:
795 @smallexample @c ada
796 pragma Ada_95;
797 @end smallexample
799 @noindent
800 A configuration pragma that establishes Ada 95 mode for the unit to which
801 it applies, regardless of the mode set by the command line switches.
802 This mode is set automatically for the @code{Ada} and @code{System}
803 packages and their children, so you need not specify it in these
804 contexts.  This pragma is useful when writing a reusable component that
805 itself uses Ada 95 features, but which is intended to be usable from
806 either Ada 83 or Ada 95 programs.
808 @node Pragma Ada_05
809 @unnumberedsec Pragma Ada_05
810 @findex Ada_05
811 @noindent
812 Syntax:
813 @smallexample @c ada
814 pragma Ada_05;
815 @end smallexample
817 @noindent
818 A configuration pragma that establishes Ada 2005 mode for the unit to which
819 it applies, regardless of the mode set by the command line switches.
820 This mode is set automatically for the @code{Ada} and @code{System}
821 packages and their children, so you need not specify it in these
822 contexts.  This pragma is useful when writing a reusable component that
823 itself uses Ada 2005 features, but which is intended to be usable from
824 either Ada 83 or Ada 95 programs.
826 @node Pragma Ada_2005
827 @unnumberedsec Pragma Ada_2005
828 @findex Ada_2005
829 @noindent
830 Syntax:
831 @smallexample @c ada
832 pragma Ada_2005;
833 @end smallexample
835 @noindent
836 This configuration pragma is a synonym for pragma Ada_05 and has the
837 same syntax and effect.
839 @node Pragma Annotate
840 @unnumberedsec Pragma Annotate
841 @findex Annotate
842 @noindent
843 Syntax:
844 @smallexample @c ada
845 pragma Annotate (IDENTIFIER @{, ARG@});
847 ARG ::= NAME | EXPRESSION
848 @end smallexample
850 @noindent
851 This pragma is used to annotate programs.  @var{identifier} identifies
852 the type of annotation.  GNAT verifies this is an identifier, but does
853 not otherwise analyze it.  The @var{arg} argument
854 can be either a string literal or an
855 expression.  String literals are assumed to be of type
856 @code{Standard.String}.  Names of entities are simply analyzed as entity
857 names.  All other expressions are analyzed as expressions, and must be
858 unambiguous.
860 The analyzed pragma is retained in the tree, but not otherwise processed
861 by any part of the GNAT compiler.  This pragma is intended for use by
862 external tools, including ASIS@.
864 @node Pragma Assert
865 @unnumberedsec Pragma Assert
866 @findex Assert
867 @noindent
868 Syntax:
869 @smallexample @c ada
870 pragma Assert (
871   boolean_EXPRESSION
872   [, static_string_EXPRESSION]);
873 @end smallexample
875 @noindent
876 The effect of this pragma depends on whether the corresponding command
877 line switch is set to activate assertions.  The pragma expands into code
878 equivalent to the following:
880 @smallexample @c ada
881 if assertions-enabled then
882    if not boolean_EXPRESSION then
883       System.Assertions.Raise_Assert_Failure
884         (string_EXPRESSION);
885    end if;
886 end if;
887 @end smallexample
889 @noindent
890 The string argument, if given, is the message that will be associated
891 with the exception occurrence if the exception is raised.  If no second
892 argument is given, the default message is @samp{@var{file}:@var{nnn}},
893 where @var{file} is the name of the source file containing the assert,
894 and @var{nnn} is the line number of the assert.  A pragma is not a
895 statement, so if a statement sequence contains nothing but a pragma
896 assert, then a null statement is required in addition, as in:
898 @smallexample @c ada
899 @dots{}
900 if J > 3 then
901    pragma Assert (K > 3, "Bad value for K");
902    null;
903 end if;
904 @end smallexample
906 @noindent
907 Note that, as with the @code{if} statement to which it is equivalent, the
908 type of the expression is either @code{Standard.Boolean}, or any type derived
909 from this standard type.
911 If assertions are disabled (switch @code{-gnata} not used), then there
912 is no effect (and in particular, any side effects from the expression
913 are suppressed).  More precisely it is not quite true that the pragma
914 has no effect, since the expression is analyzed, and may cause types
915 to be frozen if they are mentioned here for the first time.
917 If assertions are enabled, then the given expression is tested, and if
918 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
919 which results in the raising of @code{Assert_Failure} with the given message.
921 If the boolean expression has side effects, these side effects will turn
922 on and off with the setting of the assertions mode, resulting in
923 assertions that have an effect on the program.  You should generally
924 avoid side effects in the expression arguments of this pragma.  However,
925 the expressions are analyzed for semantic correctness whether or not
926 assertions are enabled, so turning assertions on and off cannot affect
927 the legality of a program.
929 @node Pragma Ast_Entry
930 @unnumberedsec Pragma Ast_Entry
931 @cindex OpenVMS
932 @findex Ast_Entry
933 @noindent
934 Syntax:
935 @smallexample @c ada
936 pragma AST_Entry (entry_IDENTIFIER);
937 @end smallexample
939 @noindent
940 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
941 argument is the simple name of a single entry; at most one @code{AST_Entry}
942 pragma is allowed for any given entry.  This pragma must be used in
943 conjunction with the @code{AST_Entry} attribute, and is only allowed after
944 the entry declaration and in the same task type specification or single task
945 as the entry to which it applies.  This pragma specifies that the given entry
946 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
947 resulting from an OpenVMS system service call.  The pragma does not affect
948 normal use of the entry.  For further details on this pragma, see the
949 DEC Ada Language Reference Manual, section 9.12a.
951 @node Pragma C_Pass_By_Copy
952 @unnumberedsec Pragma C_Pass_By_Copy
953 @cindex Passing by copy
954 @findex C_Pass_By_Copy
955 @noindent
956 Syntax:
957 @smallexample @c ada
958 pragma C_Pass_By_Copy
959   ([Max_Size =>] static_integer_EXPRESSION);
960 @end smallexample
962 @noindent
963 Normally the default mechanism for passing C convention records to C
964 convention subprograms is to pass them by reference, as suggested by RM
965 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
966 this default, by requiring that record formal parameters be passed by
967 copy if all of the following conditions are met:
969 @itemize @bullet
970 @item
971 The size of the record type does not exceed@*@var{static_integer_expression}.
972 @item
973 The record type has @code{Convention C}.
974 @item
975 The formal parameter has this record type, and the subprogram has a
976 foreign (non-Ada) convention.
977 @end itemize
979 @noindent
980 If these conditions are met the argument is passed by copy, i.e.@: in a
981 manner consistent with what C expects if the corresponding formal in the
982 C prototype is a struct (rather than a pointer to a struct).
984 You can also pass records by copy by specifying the convention
985 @code{C_Pass_By_Copy} for the record type, or by using the extended
986 @code{Import} and @code{Export} pragmas, which allow specification of
987 passing mechanisms on a parameter by parameter basis.
989 @node Pragma Comment
990 @unnumberedsec Pragma Comment
991 @findex Comment
992 @noindent
993 Syntax:
995 @smallexample @c ada
996 pragma Comment (static_string_EXPRESSION);
997 @end smallexample
999 @noindent
1000 This is almost identical in effect to pragma @code{Ident}.  It allows the
1001 placement of a comment into the object file and hence into the
1002 executable file if the operating system permits such usage.  The
1003 difference is that @code{Comment}, unlike @code{Ident}, has
1004 no limitations on placement of the pragma (it can be placed
1005 anywhere in the main source unit), and if more than one pragma
1006 is used, all comments are retained.
1008 @node Pragma Common_Object
1009 @unnumberedsec Pragma Common_Object
1010 @findex Common_Object
1011 @noindent
1012 Syntax:
1014 @smallexample @c ada
1015 pragma Common_Object (
1016      [Internal =>] local_NAME,
1017   [, [External =>] EXTERNAL_SYMBOL]
1018   [, [Size     =>] EXTERNAL_SYMBOL] );
1020 EXTERNAL_SYMBOL ::=
1021   IDENTIFIER
1022 | static_string_EXPRESSION
1023 @end smallexample
1025 @noindent
1026 This pragma enables the shared use of variables stored in overlaid
1027 linker areas corresponding to the use of @code{COMMON}
1028 in Fortran.  The single
1029 object @var{local_NAME} is assigned to the area designated by
1030 the @var{External} argument.
1031 You may define a record to correspond to a series
1032 of fields.  The @var{size} argument
1033 is syntax checked in GNAT, but otherwise ignored.
1035 @code{Common_Object} is not supported on all platforms.  If no
1036 support is available, then the code generator will issue a message
1037 indicating that the necessary attribute for implementation of this
1038 pragma is not available.
1040 @node Pragma Compile_Time_Warning
1041 @unnumberedsec Pragma Compile_Time_Warning
1042 @findex Compile_Time_Warning
1043 @noindent
1044 Syntax:
1046 @smallexample @c ada
1047 pragma Compile_Time_Warning
1048          (boolean_EXPRESSION, static_string_EXPRESSION);
1049 @end smallexample
1051 @noindent
1052 This pragma can be used to generate additional compile time warnings. It
1053 is particularly useful in generics, where warnings can be issued for
1054 specific problematic instantiations. The first parameter is a boolean
1055 expression. The pragma is effective only if the value of this expression
1056 is known at compile time, and has the value True. The set of expressions
1057 whose values are known at compile time includes all static boolean
1058 expressions, and also other values which the compiler can determine
1059 at compile time (e.g. the size of a record type set by an explicit
1060 size representation clause, or the value of a variable which was
1061 initialized to a constant and is known not to have been modified).
1062 If these conditions are met, a warning message is generated using
1063 the value given as the second argument. This string value may contain
1064 embedded ASCII.LF characters to break the message into multiple lines.
1066 @node Pragma Complete_Representation
1067 @unnumberedsec Pragma Complete_Representation
1068 @findex Complete_Representation
1069 @noindent
1070 Syntax:
1072 @smallexample @c ada
1073 pragma Complete_Representation;
1074 @end smallexample
1076 @noindent
1077 This pragma must appear immediately within a record representation
1078 clause. Typical placements are before the first component clause
1079 or after the last component clause. The effect is to give an error
1080 message if any component is missing a component clause. This pragma
1081 may be used to ensure that a record representation clause is
1082 complete, and that this invariant is maintained if fields are
1083 added to the record in the future.
1085 @node Pragma Complex_Representation
1086 @unnumberedsec Pragma Complex_Representation
1087 @findex Complex_Representation
1088 @noindent
1089 Syntax:
1091 @smallexample @c ada
1092 pragma Complex_Representation
1093         ([Entity =>] local_NAME);
1094 @end smallexample
1096 @noindent
1097 The @var{Entity} argument must be the name of a record type which has
1098 two fields of the same floating-point type.  The effect of this pragma is
1099 to force gcc to use the special internal complex representation form for
1100 this record, which may be more efficient.  Note that this may result in
1101 the code for this type not conforming to standard ABI (application
1102 binary interface) requirements for the handling of record types.  For
1103 example, in some environments, there is a requirement for passing
1104 records by pointer, and the use of this pragma may result in passing
1105 this type in floating-point registers.
1107 @node Pragma Component_Alignment
1108 @unnumberedsec Pragma Component_Alignment
1109 @cindex Alignments of components
1110 @findex Component_Alignment
1111 @noindent
1112 Syntax:
1114 @smallexample @c ada
1115 pragma Component_Alignment (
1116      [Form =>] ALIGNMENT_CHOICE
1117   [, [Name =>] type_local_NAME]);
1119 ALIGNMENT_CHOICE ::=
1120   Component_Size
1121 | Component_Size_4
1122 | Storage_Unit
1123 | Default
1124 @end smallexample
1126 @noindent
1127 Specifies the alignment of components in array or record types.
1128 The meaning of the @var{Form} argument is as follows:
1130 @table @code
1131 @findex Component_Size
1132 @item Component_Size
1133 Aligns scalar components and subcomponents of the array or record type
1134 on boundaries appropriate to their inherent size (naturally
1135 aligned).  For example, 1-byte components are aligned on byte boundaries,
1136 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1137 integer components are aligned on 4-byte boundaries and so on.  These
1138 alignment rules correspond to the normal rules for C compilers on all
1139 machines except the VAX@.
1141 @findex Component_Size_4
1142 @item Component_Size_4
1143 Naturally aligns components with a size of four or fewer
1144 bytes.  Components that are larger than 4 bytes are placed on the next
1145 4-byte boundary.
1147 @findex Storage_Unit
1148 @item Storage_Unit
1149 Specifies that array or record components are byte aligned, i.e.@:
1150 aligned on boundaries determined by the value of the constant
1151 @code{System.Storage_Unit}.
1153 @cindex OpenVMS
1154 @item Default
1155 Specifies that array or record components are aligned on default
1156 boundaries, appropriate to the underlying hardware or operating system or
1157 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1158 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1159 the @code{Default} choice is the same as @code{Component_Size} (natural
1160 alignment).
1161 @end table
1163 @noindent
1164 If the @code{Name} parameter is present, @var{type_local_NAME} must
1165 refer to a local record or array type, and the specified alignment
1166 choice applies to the specified type.  The use of
1167 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1168 @code{Component_Alignment} pragma to be ignored.  The use of
1169 @code{Component_Alignment} together with a record representation clause
1170 is only effective for fields not specified by the representation clause.
1172 If the @code{Name} parameter is absent, the pragma can be used as either
1173 a configuration pragma, in which case it applies to one or more units in
1174 accordance with the normal rules for configuration pragmas, or it can be
1175 used within a declarative part, in which case it applies to types that
1176 are declared within this declarative part, or within any nested scope
1177 within this declarative part.  In either case it specifies the alignment
1178 to be applied to any record or array type which has otherwise standard
1179 representation.
1181 If the alignment for a record or array type is not specified (using
1182 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1183 clause), the GNAT uses the default alignment as described previously.
1185 @node Pragma Convention_Identifier
1186 @unnumberedsec Pragma Convention_Identifier
1187 @findex Convention_Identifier
1188 @cindex Conventions, synonyms
1189 @noindent
1190 Syntax:
1192 @smallexample @c ada
1193 pragma Convention_Identifier (
1194          [Name =>]       IDENTIFIER,
1195          [Convention =>] convention_IDENTIFIER);
1196 @end smallexample
1198 @noindent
1199 This pragma provides a mechanism for supplying synonyms for existing
1200 convention identifiers. The @code{Name} identifier can subsequently
1201 be used as a synonym for the given convention in other pragmas (including
1202 for example pragma @code{Import} or another @code{Convention_Identifier}
1203 pragma). As an example of the use of this, suppose you had legacy code
1204 which used Fortran77 as the identifier for Fortran. Then the pragma:
1206 @smallexample @c ada
1207 pragma Convention_Identifier (Fortran77, Fortran);
1208 @end smallexample
1210 @noindent
1211 would allow the use of the convention identifier @code{Fortran77} in
1212 subsequent code, avoiding the need to modify the sources. As another
1213 example, you could use this to parametrize convention requirements
1214 according to systems. Suppose you needed to use @code{Stdcall} on
1215 windows systems, and @code{C} on some other system, then you could
1216 define a convention identifier @code{Library} and use a single
1217 @code{Convention_Identifier} pragma to specify which convention
1218 would be used system-wide.
1220 @node Pragma CPP_Class
1221 @unnumberedsec Pragma CPP_Class
1222 @findex CPP_Class
1223 @cindex Interfacing with C++
1224 @noindent
1225 Syntax:
1227 @smallexample @c ada
1228 pragma CPP_Class ([Entity =>] local_NAME);
1229 @end smallexample
1231 @noindent
1232 The argument denotes an entity in the current declarative region
1233 that is declared as a tagged or untagged record type.  It indicates that
1234 the type corresponds to an externally declared C++ class type, and is to
1235 be laid out the same way that C++ would lay out the type.
1237 If (and only if) the type is tagged, at least one component in the
1238 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1239 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1240 for dispatching.
1242 Types for which @code{CPP_Class} is specified do not have assignment or
1243 equality operators defined (such operations can be imported or declared
1244 as subprograms as required).  Initialization is allowed only by
1245 constructor functions (see pragma @code{CPP_Constructor}).
1247 Pragma @code{CPP_Class} is intended primarily for automatic generation
1248 using an automatic binding generator tool.
1249 See @ref{Interfacing to C++} for related information.
1251 @node Pragma CPP_Constructor
1252 @unnumberedsec Pragma CPP_Constructor
1253 @cindex Interfacing with C++
1254 @findex CPP_Constructor
1255 @noindent
1256 Syntax:
1258 @smallexample @c ada
1259 pragma CPP_Constructor ([Entity =>] local_NAME);
1260 @end smallexample
1262 @noindent
1263 This pragma identifies an imported function (imported in the usual way
1264 with pragma @code{Import}) as corresponding to a C++
1265 constructor.  The argument is a name that must have been
1266 previously mentioned in a pragma @code{Import}
1267 with @code{Convention} = @code{CPP}, and must be of one of the following
1268 forms:
1270 @itemize @bullet
1271 @item
1272 @code{function @var{Fname} return @var{T}'Class}
1274 @item
1275 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1276 @end itemize
1278 @noindent
1279 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1281 The first form is the default constructor, used when an object of type
1282 @var{T} is created on the Ada side with no explicit constructor.  Other
1283 constructors (including the copy constructor, which is simply a special
1284 case of the second form in which the one and only argument is of type
1285 @var{T}), can only appear in two contexts:
1287 @itemize @bullet
1288 @item
1289 On the right side of an initialization of an object of type @var{T}.
1290 @item
1291 In an extension aggregate for an object of a type derived from @var{T}.
1292 @end itemize
1294 @noindent
1295 Although the constructor is described as a function that returns a value
1296 on the Ada side, it is typically a procedure with an extra implicit
1297 argument (the object being initialized) at the implementation
1298 level.  GNAT issues the appropriate call, whatever it is, to get the
1299 object properly initialized.
1301 In the case of derived objects, you may use one of two possible forms
1302 for declaring and creating an object:
1304 @itemize @bullet
1305 @item @code{New_Object : Derived_T}
1306 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1307 @end itemize
1309 @noindent
1310 In the first case the default constructor is called and extension fields
1311 if any are initialized according to the default initialization
1312 expressions in the Ada declaration.  In the second case, the given
1313 constructor is called and the extension aggregate indicates the explicit
1314 values of the extension fields.
1316 If no constructors are imported, it is impossible to create any objects
1317 on the Ada side.  If no default constructor is imported, only the
1318 initialization forms using an explicit call to a constructor are
1319 permitted.
1321 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1322 using an automatic binding generator tool.
1323 See @ref{Interfacing to C++} for more related information.
1325 @node Pragma CPP_Virtual
1326 @unnumberedsec Pragma CPP_Virtual
1327 @cindex Interfacing to C++
1328 @findex CPP_Virtual
1329 @noindent
1330 Syntax:
1332 @smallexample @c ada
1333 pragma CPP_Virtual
1334      [Entity     =>] ENTITY,
1335   [, [Vtable_Ptr =>] vtable_ENTITY,]
1336   [, [Position   =>] static_integer_EXPRESSION]);
1337 @end smallexample
1339 @noindent
1340 This pragma serves the same function as pragma @code{Import} in that
1341 case of a virtual function imported from C++.  The @var{Entity} argument
1342 must be a
1343 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1344 applies.  The @var{Vtable_Ptr} argument specifies
1345 the Vtable_Ptr component which contains the
1346 entry for this virtual function.  The @var{Position} argument
1347 is the sequential number
1348 counting virtual functions for this Vtable starting at 1.
1350 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1351 there is one Vtable_Ptr present (single inheritance case) and all
1352 virtual functions are imported.  In that case the compiler can deduce both
1353 these values.
1355 No @code{External_Name} or @code{Link_Name} arguments are required for a
1356 virtual function, since it is always accessed indirectly via the
1357 appropriate Vtable entry.
1359 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1360 using an automatic binding generator tool.
1361 See @ref{Interfacing to C++} for related information.
1363 @node Pragma CPP_Vtable
1364 @unnumberedsec Pragma CPP_Vtable
1365 @cindex Interfacing with C++
1366 @findex CPP_Vtable
1367 @noindent
1368 Syntax:
1370 @smallexample @c ada
1371 pragma CPP_Vtable (
1372   [Entity      =>] ENTITY,
1373   [Vtable_Ptr  =>] vtable_ENTITY,
1374   [Entry_Count =>] static_integer_EXPRESSION);
1375 @end smallexample
1377 @noindent
1378 Given a record to which the pragma @code{CPP_Class} applies,
1379 this pragma can be specified for each component of type
1380 @code{CPP.Interfaces.Vtable_Ptr}.
1381 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1382 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1383 the number of virtual functions on the C++ side.  Not all of these
1384 functions need to be imported on the Ada side.
1386 You may omit the @code{CPP_Vtable} pragma if there is only one
1387 @code{Vtable_Ptr} component in the record and all virtual functions are
1388 imported on the Ada side (the default value for the entry count in this
1389 case is simply the total number of virtual functions).
1391 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1392 using an automatic binding generator tool.
1393 See @ref{Interfacing to C++} for related information.
1395 @node Pragma Debug
1396 @unnumberedsec Pragma Debug
1397 @findex Debug
1398 @noindent
1399 Syntax:
1401 @smallexample @c ada
1402 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1404 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1405   PROCEDURE_NAME
1406 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1407 @end smallexample
1409 @noindent
1410 The procedure call argument has the syntactic form of an expression, meeting
1411 the syntactic requirements for pragmas.
1413 If debug pragmas are not enabled or if the condition is present and evaluates
1414 to False, this pragma has no effect. If debug pragmas are enabled, the
1415 semantics of the pragma is exactly equivalent to the procedure call statement
1416 corresponding to the argument with a terminating semicolon. Pragmas are
1417 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1418 intersperse calls to debug procedures in the middle of declarations. Debug
1419 pragmas can be enabled either by use of the command line switch @code{-gnata}
1420 or by use of the configuration pragma @code{Debug_Policy}.
1422 @node Pragma Debug_Policy
1423 @unnumberedsec Pragma Debug_Policy
1424 @findex Debug_Policy
1425 @noindent
1426 Syntax:
1428 @smallexample @c ada
1429 pragma Debug_Policy (CHECK | IGNORE);
1430 @end smallexample
1432 @noindent
1433 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1434 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1435 This pragma overrides the effect of the @code{-gnata} switch on the
1436 command line.
1438 @node Pragma Detect_Blocking
1439 @unnumberedsec Pragma Detect_Blocking
1440 @findex Detect_Blocking
1441 @noindent
1442 Syntax:
1444 @smallexample @c ada
1445 pragma Detect_Blocking;
1446 @end smallexample
1448 @noindent
1449 This is a configuration pragma that forces the detection of potentially
1450 blocking operations within a protected operation, and to raise Program_Error
1451 if that happens.
1453 @node Pragma Elaboration_Checks
1454 @unnumberedsec Pragma Elaboration_Checks
1455 @cindex Elaboration control
1456 @findex Elaboration_Checks
1457 @noindent
1458 Syntax:
1460 @smallexample @c ada
1461 pragma Elaboration_Checks (Dynamic | Static);
1462 @end smallexample
1464 @noindent
1465 This is a configuration pragma that provides control over the
1466 elaboration model used by the compilation affected by the
1467 pragma.  If the parameter is @code{Dynamic},
1468 then the dynamic elaboration
1469 model described in the Ada Reference Manual is used, as though
1470 the @code{-gnatE} switch had been specified on the command
1471 line.  If the parameter is @code{Static}, then the default GNAT static
1472 model is used.  This configuration pragma overrides the setting
1473 of the command line.  For full details on the elaboration models
1474 used by the GNAT compiler, see section ``Elaboration Order
1475 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1477 @node Pragma Eliminate
1478 @unnumberedsec Pragma Eliminate
1479 @cindex Elimination of unused subprograms
1480 @findex Eliminate
1481 @noindent
1482 Syntax:
1484 @smallexample @c ada
1485 pragma Eliminate (
1486     [Unit_Name =>] IDENTIFIER |
1487                    SELECTED_COMPONENT);
1489 pragma Eliminate (
1490     [Unit_Name       =>]  IDENTIFIER |
1491                           SELECTED_COMPONENT,
1492     [Entity          =>]  IDENTIFIER |
1493                           SELECTED_COMPONENT |
1494                           STRING_LITERAL
1495     [,OVERLOADING_RESOLUTION]);
1497 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1498                            SOURCE_LOCATION
1500 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1501                                       FUNCTION_PROFILE
1503 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1505 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1506                       Result_Type => result_SUBTYPE_NAME]
1508 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1509 SUBTYPE_NAME    ::= STRING_VALUE
1511 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1512 SOURCE_TRACE    ::= STRING_VALUE
1514 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1515 @end smallexample
1517 @noindent
1518 This pragma indicates that the given entity is not used outside the
1519 compilation unit it is defined in. The entity must be an explicitly declared
1520 subprogram; this includes  generic subprogram instances and
1521 subprograms declared in generic package instances.
1523 If the entity to be eliminated is a library level subprogram, then
1524 the first form of pragma @code{Eliminate} is used with only a single argument.
1525 In this form, the @code{Unit_Name} argument specifies the name of the
1526 library  level unit to be eliminated.
1528 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1529 are required. If item is an entity of a library package, then the first
1530 argument specifies the unit name, and the second argument specifies
1531 the particular entity.  If the second argument is in string form, it must
1532 correspond to the internal manner in which GNAT stores entity names (see
1533 compilation unit Namet in the compiler sources for details).
1535 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1536 to distinguish between overloaded subprograms. If a pragma does not contain
1537 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1538 subprograms denoted by the first two parameters.
1540 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1541 to be eliminated in a manner similar to that used for the extended
1542 @code{Import} and @code{Export} pragmas, except that the subtype names are
1543 always given as strings. At the moment, this form of distinguishing
1544 overloaded subprograms is implemented only partially, so we do not recommend
1545 using it for practical subprogram elimination.
1547 Note, that in case of a parameterless procedure its profile is represented
1548 as @code{Parameter_Types => ("")}
1550 Alternatively, the @code{Source_Location} parameter is used to specify
1551 which overloaded alternative is to be eliminated by pointing to the
1552 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1553 source text. The string literal (or concatenation of string literals)
1554 given as SOURCE_TRACE must have the following format:
1556 @smallexample @c ada
1557 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1559 LBRACKET ::= [
1560 RBRACKET ::= ]
1562 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1563 FILE_NAME       ::= STRING_LITERAL
1564 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1565 @end smallexample
1567 SOURCE_TRACE should be the short name of the source file (with no directory
1568 information), and LINE_NUMBER is supposed to point to the line where the
1569 defining name of the subprogram is located.
1571 For the subprograms that are not a part of generic instantiations, only one
1572 SOURCE_LOCATION is used. If a subprogram is declared in a package
1573 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1574 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1575 second one denotes the declaration of the corresponding subprogram in the
1576 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1577 in case of nested instantiations.
1579 The effect of the pragma is to allow the compiler to eliminate
1580 the code or data associated with the named entity.  Any reference to
1581 an eliminated entity outside the compilation unit it is defined in,
1582 causes a compile time or link time error.
1584 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1585 in a system independent manner, with unused entities eliminated, without
1586 the requirement of modifying the source text.  Normally the required set
1587 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1588 tool. Elimination of unused entities local to a compilation unit is
1589 automatic, without requiring the use of pragma @code{Eliminate}.
1591 Note that the reason this pragma takes string literals where names might
1592 be expected is that a pragma @code{Eliminate} can appear in a context where the
1593 relevant names are not visible.
1595 Note that any change in the source files that includes removing, splitting of
1596 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1597 parameter illegal.
1599 @node Pragma Export_Exception
1600 @unnumberedsec Pragma Export_Exception
1601 @cindex OpenVMS
1602 @findex Export_Exception
1603 @noindent
1604 Syntax:
1606 @smallexample @c ada
1607 pragma Export_Exception (
1608      [Internal =>] local_NAME,
1609   [, [External =>] EXTERNAL_SYMBOL,]
1610   [, [Form     =>] Ada | VMS]
1611   [, [Code     =>] static_integer_EXPRESSION]);
1613 EXTERNAL_SYMBOL ::=
1614   IDENTIFIER
1615 | static_string_EXPRESSION
1616 @end smallexample
1618 @noindent
1619 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1620 causes the specified exception to be propagated outside of the Ada program,
1621 so that it can be handled by programs written in other OpenVMS languages.
1622 This pragma establishes an external name for an Ada exception and makes the
1623 name available to the OpenVMS Linker as a global symbol.  For further details
1624 on this pragma, see the
1625 DEC Ada Language Reference Manual, section 13.9a3.2.
1627 @node Pragma Export_Function
1628 @unnumberedsec Pragma Export_Function
1629 @cindex Argument passing mechanisms
1630 @findex Export_Function
1632 @noindent
1633 Syntax:
1635 @smallexample @c ada
1636 pragma Export_Function (
1637      [Internal         =>] local_NAME,
1638   [, [External         =>] EXTERNAL_SYMBOL]
1639   [, [Parameter_Types  =>] PARAMETER_TYPES]
1640   [, [Result_Type      =>] result_SUBTYPE_MARK]
1641   [, [Mechanism        =>] MECHANISM]
1642   [, [Result_Mechanism =>] MECHANISM_NAME]);
1644 EXTERNAL_SYMBOL ::=
1645   IDENTIFIER
1646 | static_string_EXPRESSION
1647 | ""
1649 PARAMETER_TYPES ::=
1650   null
1651 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1653 TYPE_DESIGNATOR ::=
1654   subtype_NAME
1655 | subtype_Name ' Access
1657 MECHANISM ::=
1658   MECHANISM_NAME
1659 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1661 MECHANISM_ASSOCIATION ::=
1662   [formal_parameter_NAME =>] MECHANISM_NAME
1664 MECHANISM_NAME ::=
1665   Value
1666 | Reference
1667 @end smallexample
1669 @noindent
1670 Use this pragma to make a function externally callable and optionally
1671 provide information on mechanisms to be used for passing parameter and
1672 result values.  We recommend, for the purposes of improving portability,
1673 this pragma always be used in conjunction with a separate pragma
1674 @code{Export}, which must precede the pragma @code{Export_Function}.
1675 GNAT does not require a separate pragma @code{Export}, but if none is
1676 present, @code{Convention Ada} is assumed, which is usually
1677 not what is wanted, so it is usually appropriate to use this
1678 pragma in conjunction with a @code{Export} or @code{Convention}
1679 pragma that specifies the desired foreign convention.
1680 Pragma @code{Export_Function}
1681 (and @code{Export}, if present) must appear in the same declarative
1682 region as the function to which they apply.
1684 @var{internal_name} must uniquely designate the function to which the
1685 pragma applies.  If more than one function name exists of this name in
1686 the declarative part you must use the @code{Parameter_Types} and
1687 @code{Result_Type} parameters is mandatory to achieve the required
1688 unique designation.  @var{subtype_ mark}s in these parameters must
1689 exactly match the subtypes in the corresponding function specification,
1690 using positional notation to match parameters with subtype marks.
1691 The form with an @code{'Access} attribute can be used to match an
1692 anonymous access parameter.
1694 @cindex OpenVMS
1695 @cindex Passing by descriptor
1696 Note that passing by descriptor is not supported, even on the OpenVMS
1697 ports of GNAT@.
1699 @cindex Suppressing external name
1700 Special treatment is given if the EXTERNAL is an explicit null
1701 string or a static string expressions that evaluates to the null
1702 string. In this case, no external name is generated. This form
1703 still allows the specification of parameter mechanisms.
1705 @node Pragma Export_Object
1706 @unnumberedsec Pragma Export_Object
1707 @findex Export_Object
1708 @noindent
1709 Syntax:
1711 @smallexample @c ada
1712 pragma Export_Object
1713       [Internal =>] local_NAME,
1714    [, [External =>] EXTERNAL_SYMBOL]
1715    [, [Size     =>] EXTERNAL_SYMBOL]
1717 EXTERNAL_SYMBOL ::=
1718   IDENTIFIER
1719 | static_string_EXPRESSION
1720 @end smallexample
1722 @noindent
1723 This pragma designates an object as exported, and apart from the
1724 extended rules for external symbols, is identical in effect to the use of
1725 the normal @code{Export} pragma applied to an object.  You may use a
1726 separate Export pragma (and you probably should from the point of view
1727 of portability), but it is not required.  @var{Size} is syntax checked,
1728 but otherwise ignored by GNAT@.
1730 @node Pragma Export_Procedure
1731 @unnumberedsec Pragma Export_Procedure
1732 @findex Export_Procedure
1733 @noindent
1734 Syntax:
1736 @smallexample @c ada
1737 pragma Export_Procedure (
1738      [Internal        =>] local_NAME
1739   [, [External        =>] EXTERNAL_SYMBOL]
1740   [, [Parameter_Types =>] PARAMETER_TYPES]
1741   [, [Mechanism       =>] MECHANISM]);
1743 EXTERNAL_SYMBOL ::=
1744   IDENTIFIER
1745 | static_string_EXPRESSION
1746 | ""
1748 PARAMETER_TYPES ::=
1749   null
1750 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1752 TYPE_DESIGNATOR ::=
1753   subtype_NAME
1754 | subtype_Name ' Access
1756 MECHANISM ::=
1757   MECHANISM_NAME
1758 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1760 MECHANISM_ASSOCIATION ::=
1761   [formal_parameter_NAME =>] MECHANISM_NAME
1763 MECHANISM_NAME ::=
1764   Value
1765 | Reference
1766 @end smallexample
1768 @noindent
1769 This pragma is identical to @code{Export_Function} except that it
1770 applies to a procedure rather than a function and the parameters
1771 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1772 GNAT does not require a separate pragma @code{Export}, but if none is
1773 present, @code{Convention Ada} is assumed, which is usually
1774 not what is wanted, so it is usually appropriate to use this
1775 pragma in conjunction with a @code{Export} or @code{Convention}
1776 pragma that specifies the desired foreign convention.
1778 @cindex OpenVMS
1779 @cindex Passing by descriptor
1780 Note that passing by descriptor is not supported, even on the OpenVMS
1781 ports of GNAT@.
1783 @cindex Suppressing external name
1784 Special treatment is given if the EXTERNAL is an explicit null
1785 string or a static string expressions that evaluates to the null
1786 string. In this case, no external name is generated. This form
1787 still allows the specification of parameter mechanisms.
1789 @node Pragma Export_Value
1790 @unnumberedsec Pragma Export_Value
1791 @findex Export_Value
1792 @noindent
1793 Syntax:
1795 @smallexample @c ada
1796 pragma Export_Value (
1797   [Value     =>] static_integer_EXPRESSION,
1798   [Link_Name =>] static_string_EXPRESSION);
1799 @end smallexample
1801 @noindent
1802 This pragma serves to export a static integer value for external use.
1803 The first argument specifies the value to be exported. The Link_Name
1804 argument specifies the symbolic name to be associated with the integer
1805 value. This pragma is useful for defining a named static value in Ada
1806 that can be referenced in assembly language units to be linked with
1807 the application. This pragma is currently supported only for the
1808 AAMP target and is ignored for other targets.
1810 @node Pragma Export_Valued_Procedure
1811 @unnumberedsec Pragma Export_Valued_Procedure
1812 @findex Export_Valued_Procedure
1813 @noindent
1814 Syntax:
1816 @smallexample @c ada
1817 pragma Export_Valued_Procedure (
1818      [Internal        =>] local_NAME
1819   [, [External        =>] EXTERNAL_SYMBOL]
1820   [, [Parameter_Types =>] PARAMETER_TYPES]
1821   [, [Mechanism       =>] MECHANISM]);
1823 EXTERNAL_SYMBOL ::=
1824   IDENTIFIER
1825 | static_string_EXPRESSION
1826 | ""
1828 PARAMETER_TYPES ::=
1829   null
1830 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1832 TYPE_DESIGNATOR ::=
1833   subtype_NAME
1834 | subtype_Name ' Access
1836 MECHANISM ::=
1837   MECHANISM_NAME
1838 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1840 MECHANISM_ASSOCIATION ::=
1841   [formal_parameter_NAME =>] MECHANISM_NAME
1843 MECHANISM_NAME ::=
1844   Value
1845 | Reference
1846 @end smallexample
1848 @noindent
1849 This pragma is identical to @code{Export_Procedure} except that the
1850 first parameter of @var{local_NAME}, which must be present, must be of
1851 mode @code{OUT}, and externally the subprogram is treated as a function
1852 with this parameter as the result of the function.  GNAT provides for
1853 this capability to allow the use of @code{OUT} and @code{IN OUT}
1854 parameters in interfacing to external functions (which are not permitted
1855 in Ada functions).
1856 GNAT does not require a separate pragma @code{Export}, but if none is
1857 present, @code{Convention Ada} is assumed, which is almost certainly
1858 not what is wanted since the whole point of this pragma is to interface
1859 with foreign language functions, so it is usually appropriate to use this
1860 pragma in conjunction with a @code{Export} or @code{Convention}
1861 pragma that specifies the desired foreign convention.
1863 @cindex OpenVMS
1864 @cindex Passing by descriptor
1865 Note that passing by descriptor is not supported, even on the OpenVMS
1866 ports of GNAT@.
1868 @cindex Suppressing external name
1869 Special treatment is given if the EXTERNAL is an explicit null
1870 string or a static string expressions that evaluates to the null
1871 string. In this case, no external name is generated. This form
1872 still allows the specification of parameter mechanisms.
1874 @node Pragma Extend_System
1875 @unnumberedsec Pragma Extend_System
1876 @cindex @code{system}, extending
1877 @cindex Dec Ada 83
1878 @findex Extend_System
1879 @noindent
1880 Syntax:
1882 @smallexample @c ada
1883 pragma Extend_System ([Name =>] IDENTIFIER);
1884 @end smallexample
1886 @noindent
1887 This pragma is used to provide backwards compatibility with other
1888 implementations that extend the facilities of package @code{System}.  In
1889 GNAT, @code{System} contains only the definitions that are present in
1890 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1891 implementation, provide many extensions to package @code{System}.
1893 For each such implementation accommodated by this pragma, GNAT provides a
1894 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1895 implementation, which provides the required additional definitions.  You
1896 can use this package in two ways.  You can @code{with} it in the normal
1897 way and access entities either by selection or using a @code{use}
1898 clause.  In this case no special processing is required.
1900 However, if existing code contains references such as
1901 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1902 definitions provided in package @code{System}, you may use this pragma
1903 to extend visibility in @code{System} in a non-standard way that
1904 provides greater compatibility with the existing code.  Pragma
1905 @code{Extend_System} is a configuration pragma whose single argument is
1906 the name of the package containing the extended definition
1907 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1908 control of this pragma will be processed using special visibility
1909 processing that looks in package @code{System.Aux_@var{xxx}} where
1910 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1911 package @code{System}, but not found in package @code{System}.
1913 You can use this pragma either to access a predefined @code{System}
1914 extension supplied with the compiler, for example @code{Aux_DEC} or
1915 you can construct your own extension unit following the above
1916 definition.  Note that such a package is a child of @code{System}
1917 and thus is considered part of the implementation.  To compile
1918 it you will have to use the appropriate switch for compiling
1919 system units.  See the GNAT User's Guide for details.
1921 @node Pragma External
1922 @unnumberedsec Pragma External
1923 @findex External
1924 @noindent
1925 Syntax:
1927 @smallexample @c ada
1928 pragma External (
1929   [   Convention    =>] convention_IDENTIFIER,
1930   [   Entity        =>] local_NAME
1931   [, [External_Name =>] static_string_EXPRESSION ]
1932   [, [Link_Name     =>] static_string_EXPRESSION ]);
1933 @end smallexample
1935 @noindent
1936 This pragma is identical in syntax and semantics to pragma
1937 @code{Export} as defined in the Ada Reference Manual.  It is
1938 provided for compatibility with some Ada 83 compilers that
1939 used this pragma for exactly the same purposes as pragma
1940 @code{Export} before the latter was standardized.
1942 @node Pragma External_Name_Casing
1943 @unnumberedsec Pragma External_Name_Casing
1944 @cindex Dec Ada 83 casing compatibility
1945 @cindex External Names, casing
1946 @cindex Casing of External names
1947 @findex External_Name_Casing
1948 @noindent
1949 Syntax:
1951 @smallexample @c ada
1952 pragma External_Name_Casing (
1953   Uppercase | Lowercase
1954   [, Uppercase | Lowercase | As_Is]);
1955 @end smallexample
1957 @noindent
1958 This pragma provides control over the casing of external names associated
1959 with Import and Export pragmas.  There are two cases to consider:
1961 @table @asis
1962 @item Implicit external names
1963 Implicit external names are derived from identifiers.  The most common case
1964 arises when a standard Ada 95 Import or Export pragma is used with only two
1965 arguments, as in:
1967 @smallexample @c ada
1968    pragma Import (C, C_Routine);
1969 @end smallexample
1971 @noindent
1972 Since Ada is a case insensitive language, the spelling of the identifier in
1973 the Ada source program does not provide any information on the desired
1974 casing of the external name, and so a convention is needed.  In GNAT the
1975 default treatment is that such names are converted to all lower case
1976 letters.  This corresponds to the normal C style in many environments.
1977 The first argument of pragma @code{External_Name_Casing} can be used to
1978 control this treatment.  If @code{Uppercase} is specified, then the name
1979 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1980 then the normal default of all lower case letters will be used.
1982 This same implicit treatment is also used in the case of extended DEC Ada 83
1983 compatible Import and Export pragmas where an external name is explicitly
1984 specified using an identifier rather than a string.
1986 @item Explicit external names
1987 Explicit external names are given as string literals.  The most common case
1988 arises when a standard Ada 95 Import or Export pragma is used with three
1989 arguments, as in:
1991 @smallexample @c ada
1992 pragma Import (C, C_Routine, "C_routine");
1993 @end smallexample
1995 @noindent
1996 In this case, the string literal normally provides the exact casing required
1997 for the external name.  The second argument of pragma
1998 @code{External_Name_Casing} may be used to modify this behavior.
1999 If @code{Uppercase} is specified, then the name
2000 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2001 then the name will be forced to all lowercase letters.  A specification of
2002 @code{As_Is} provides the normal default behavior in which the casing is
2003 taken from the string provided.
2004 @end table
2006 @noindent
2007 This pragma may appear anywhere that a pragma is valid.  In particular, it
2008 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2009 case it applies to all subsequent compilations, or it can be used as a program
2010 unit pragma, in which case it only applies to the current unit, or it can
2011 be used more locally to control individual Import/Export pragmas.
2013 It is primarily intended for use with OpenVMS systems, where many
2014 compilers convert all symbols to upper case by default.  For interfacing to
2015 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2016 the pragma:
2018 @smallexample @c ada
2019 pragma External_Name_Casing (Uppercase, Uppercase);
2020 @end smallexample
2022 @noindent
2023 to enforce the upper casing of all external symbols.
2025 @node Pragma Finalize_Storage_Only
2026 @unnumberedsec Pragma Finalize_Storage_Only
2027 @findex Finalize_Storage_Only
2028 @noindent
2029 Syntax:
2031 @smallexample @c ada
2032 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2033 @end smallexample
2035 @noindent
2036 This pragma allows the compiler not to emit a Finalize call for objects
2037 defined at the library level.  This is mostly useful for types where
2038 finalization is only used to deal with storage reclamation since in most
2039 environments it is not necessary to reclaim memory just before terminating
2040 execution, hence the name.
2042 @node Pragma Float_Representation
2043 @unnumberedsec Pragma Float_Representation
2044 @cindex OpenVMS
2045 @findex Float_Representation
2046 @noindent
2047 Syntax:
2049 @smallexample @c ada
2050 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2052 FLOAT_REP ::= VAX_Float | IEEE_Float
2053 @end smallexample
2055 @noindent
2056 In the one argument form, this pragma is a configuration pragma which
2057 allows control over the internal representation chosen for the predefined
2058 floating point types declared in the packages @code{Standard} and
2059 @code{System}. On all systems other than OpenVMS, the argument must
2060 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2061 argument may be @code{VAX_Float} to specify the use of the VAX float
2062 format for the floating-point types in Standard. This requires that
2063 the standard runtime libraries be recompiled. See the
2064 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2065 of the GNAT Users Guide for details on the use of this command.
2067 The two argument form specifies the representation to be used for
2068 the specified floating-point type. On all systems other than OpenVMS,
2069 the argument must
2070 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2071 argument may be @code{VAX_Float} to specify the use of the VAX float
2072 format, as follows:
2074 @itemize @bullet
2075 @item
2076 For digits values up to 6, F float format will be used.
2077 @item
2078 For digits values from 7 to 9, G float format will be used.
2079 @item
2080 For digits values from 10 to 15, F float format will be used.
2081 @item
2082 Digits values above 15 are not allowed.
2083 @end itemize
2085 @node Pragma Ident
2086 @unnumberedsec Pragma Ident
2087 @findex Ident
2088 @noindent
2089 Syntax:
2091 @smallexample @c ada
2092 pragma Ident (static_string_EXPRESSION);
2093 @end smallexample
2095 @noindent
2096 This pragma provides a string identification in the generated object file,
2097 if the system supports the concept of this kind of identification string.
2098 This pragma is allowed only in the outermost declarative part or
2099 declarative items of a compilation unit. If more than one @code{Ident}
2100 pragma is given, only the last one processed is effective.
2101 @cindex OpenVMS
2102 On OpenVMS systems, the effect of the pragma is identical to the effect of
2103 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2104 maximum allowed length is 31 characters, so if it is important to
2105 maintain compatibility with this compiler, you should obey this length
2106 limit.
2108 @node Pragma Import_Exception
2109 @unnumberedsec Pragma Import_Exception
2110 @cindex OpenVMS
2111 @findex Import_Exception
2112 @noindent
2113 Syntax:
2115 @smallexample @c ada
2116 pragma Import_Exception (
2117      [Internal =>] local_NAME,
2118   [, [External =>] EXTERNAL_SYMBOL,]
2119   [, [Form     =>] Ada | VMS]
2120   [, [Code     =>] static_integer_EXPRESSION]);
2122 EXTERNAL_SYMBOL ::=
2123   IDENTIFIER
2124 | static_string_EXPRESSION
2125 @end smallexample
2127 @noindent
2128 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2129 It allows OpenVMS conditions (for example, from OpenVMS system services or
2130 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2131 The pragma specifies that the exception associated with an exception
2132 declaration in an Ada program be defined externally (in non-Ada code).
2133 For further details on this pragma, see the
2134 DEC Ada Language Reference Manual, section 13.9a.3.1.
2136 @node Pragma Import_Function
2137 @unnumberedsec Pragma Import_Function
2138 @findex Import_Function
2139 @noindent
2140 Syntax:
2142 @smallexample @c ada
2143 pragma Import_Function (
2144      [Internal                 =>] local_NAME,
2145   [, [External                 =>] EXTERNAL_SYMBOL]
2146   [, [Parameter_Types          =>] PARAMETER_TYPES]
2147   [, [Result_Type              =>] SUBTYPE_MARK]
2148   [, [Mechanism                =>] MECHANISM]
2149   [, [Result_Mechanism         =>] MECHANISM_NAME]
2150   [, [First_Optional_Parameter =>] IDENTIFIER]);
2152 EXTERNAL_SYMBOL ::=
2153   IDENTIFIER
2154 | static_string_EXPRESSION
2156 PARAMETER_TYPES ::=
2157   null
2158 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2160 TYPE_DESIGNATOR ::=
2161   subtype_NAME
2162 | subtype_Name ' Access
2164 MECHANISM ::=
2165   MECHANISM_NAME
2166 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2168 MECHANISM_ASSOCIATION ::=
2169   [formal_parameter_NAME =>] MECHANISM_NAME
2171 MECHANISM_NAME ::=
2172   Value
2173 | Reference
2174 | Descriptor [([Class =>] CLASS_NAME)]
2176 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2177 @end smallexample
2179 @noindent
2180 This pragma is used in conjunction with a pragma @code{Import} to
2181 specify additional information for an imported function.  The pragma
2182 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2183 @code{Import_Function} pragma and both must appear in the same
2184 declarative part as the function specification.
2186 The @var{Internal} argument must uniquely designate
2187 the function to which the
2188 pragma applies.  If more than one function name exists of this name in
2189 the declarative part you must use the @code{Parameter_Types} and
2190 @var{Result_Type} parameters to achieve the required unique
2191 designation.  Subtype marks in these parameters must exactly match the
2192 subtypes in the corresponding function specification, using positional
2193 notation to match parameters with subtype marks.
2194 The form with an @code{'Access} attribute can be used to match an
2195 anonymous access parameter.
2197 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2198 parameters to specify passing mechanisms for the
2199 parameters and result.  If you specify a single mechanism name, it
2200 applies to all parameters.  Otherwise you may specify a mechanism on a
2201 parameter by parameter basis using either positional or named
2202 notation.  If the mechanism is not specified, the default mechanism
2203 is used.
2205 @cindex OpenVMS
2206 @cindex Passing by descriptor
2207 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2209 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2210 It specifies that the designated parameter and all following parameters
2211 are optional, meaning that they are not passed at the generated code
2212 level (this is distinct from the notion of optional parameters in Ada
2213 where the parameters are passed anyway with the designated optional
2214 parameters).  All optional parameters must be of mode @code{IN} and have
2215 default parameter values that are either known at compile time
2216 expressions, or uses of the @code{'Null_Parameter} attribute.
2218 @node Pragma Import_Object
2219 @unnumberedsec Pragma Import_Object
2220 @findex Import_Object
2221 @noindent
2222 Syntax:
2224 @smallexample @c ada
2225 pragma Import_Object
2226      [Internal =>] local_NAME,
2227   [, [External =>] EXTERNAL_SYMBOL],
2228   [, [Size     =>] EXTERNAL_SYMBOL]);
2230 EXTERNAL_SYMBOL ::=
2231   IDENTIFIER
2232 | static_string_EXPRESSION
2233 @end smallexample
2235 @noindent
2236 This pragma designates an object as imported, and apart from the
2237 extended rules for external symbols, is identical in effect to the use of
2238 the normal @code{Import} pragma applied to an object.  Unlike the
2239 subprogram case, you need not use a separate @code{Import} pragma,
2240 although you may do so (and probably should do so from a portability
2241 point of view).  @var{size} is syntax checked, but otherwise ignored by
2242 GNAT@.
2244 @node Pragma Import_Procedure
2245 @unnumberedsec Pragma Import_Procedure
2246 @findex Import_Procedure
2247 @noindent
2248 Syntax:
2250 @smallexample @c ada
2251 pragma Import_Procedure (
2252      [Internal                 =>] local_NAME,
2253   [, [External                 =>] EXTERNAL_SYMBOL]
2254   [, [Parameter_Types          =>] PARAMETER_TYPES]
2255   [, [Mechanism                =>] MECHANISM]
2256   [, [First_Optional_Parameter =>] IDENTIFIER]);
2258 EXTERNAL_SYMBOL ::=
2259   IDENTIFIER
2260 | static_string_EXPRESSION
2262 PARAMETER_TYPES ::=
2263   null
2264 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2266 TYPE_DESIGNATOR ::=
2267   subtype_NAME
2268 | subtype_Name ' Access
2270 MECHANISM ::=
2271   MECHANISM_NAME
2272 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2274 MECHANISM_ASSOCIATION ::=
2275   [formal_parameter_NAME =>] MECHANISM_NAME
2277 MECHANISM_NAME ::=
2278   Value
2279 | Reference
2280 | Descriptor [([Class =>] CLASS_NAME)]
2282 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2283 @end smallexample
2285 @noindent
2286 This pragma is identical to @code{Import_Function} except that it
2287 applies to a procedure rather than a function and the parameters
2288 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2290 @node Pragma Import_Valued_Procedure
2291 @unnumberedsec Pragma Import_Valued_Procedure
2292 @findex Import_Valued_Procedure
2293 @noindent
2294 Syntax:
2296 @smallexample @c ada
2297 pragma Import_Valued_Procedure (
2298      [Internal                 =>] local_NAME,
2299   [, [External                 =>] EXTERNAL_SYMBOL]
2300   [, [Parameter_Types          =>] PARAMETER_TYPES]
2301   [, [Mechanism                =>] MECHANISM]
2302   [, [First_Optional_Parameter =>] IDENTIFIER]);
2304 EXTERNAL_SYMBOL ::=
2305   IDENTIFIER
2306 | static_string_EXPRESSION
2308 PARAMETER_TYPES ::=
2309   null
2310 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2312 TYPE_DESIGNATOR ::=
2313   subtype_NAME
2314 | subtype_Name ' Access
2316 MECHANISM ::=
2317   MECHANISM_NAME
2318 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2320 MECHANISM_ASSOCIATION ::=
2321   [formal_parameter_NAME =>] MECHANISM_NAME
2323 MECHANISM_NAME ::=
2324   Value
2325 | Reference
2326 | Descriptor [([Class =>] CLASS_NAME)]
2328 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2329 @end smallexample
2331 @noindent
2332 This pragma is identical to @code{Import_Procedure} except that the
2333 first parameter of @var{local_NAME}, which must be present, must be of
2334 mode @code{OUT}, and externally the subprogram is treated as a function
2335 with this parameter as the result of the function.  The purpose of this
2336 capability is to allow the use of @code{OUT} and @code{IN OUT}
2337 parameters in interfacing to external functions (which are not permitted
2338 in Ada functions).  You may optionally use the @code{Mechanism}
2339 parameters to specify passing mechanisms for the parameters.
2340 If you specify a single mechanism name, it applies to all parameters.
2341 Otherwise you may specify a mechanism on a parameter by parameter
2342 basis using either positional or named notation.  If the mechanism is not
2343 specified, the default mechanism is used.
2345 Note that it is important to use this pragma in conjunction with a separate
2346 pragma Import that specifies the desired convention, since otherwise the
2347 default convention is Ada, which is almost certainly not what is required.
2349 @node Pragma Initialize_Scalars
2350 @unnumberedsec Pragma Initialize_Scalars
2351 @findex Initialize_Scalars
2352 @cindex debugging with Initialize_Scalars
2353 @noindent
2354 Syntax:
2356 @smallexample @c ada
2357 pragma Initialize_Scalars;
2358 @end smallexample
2360 @noindent
2361 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2362 two important differences.  First, there is no requirement for the pragma
2363 to be used uniformly in all units of a partition, in particular, it is fine
2364 to use this just for some or all of the application units of a partition,
2365 without needing to recompile the run-time library.
2367 In the case where some units are compiled with the pragma, and some without,
2368 then a declaration of a variable where the type is defined in package
2369 Standard or is locally declared will always be subject to initialization,
2370 as will any declaration of a scalar variable.  For composite variables,
2371 whether the variable is initialized may also depend on whether the package
2372 in which the type of the variable is declared is compiled with the pragma.
2374 The other important difference is that you can control the value used
2375 for initializing scalar objects.  At bind time, you can select several
2376 options for initialization. You can
2377 initialize with invalid values (similar to Normalize_Scalars, though for
2378 Initialize_Scalars it is not always possible to determine the invalid
2379 values in complex cases like signed component fields with non-standard
2380 sizes). You can also initialize with high or
2381 low values, or with a specified bit pattern.  See the users guide for binder
2382 options for specifying these cases.
2384 This means that you can compile a program, and then without having to
2385 recompile the program, you can run it with different values being used
2386 for initializing otherwise uninitialized values, to test if your program
2387 behavior depends on the choice.  Of course the behavior should not change,
2388 and if it does, then most likely you have an erroneous reference to an
2389 uninitialized value.
2391 It is even possible to change the value at execution time eliminating even
2392 the need to rebind with a different switch using an environment variable.
2393 See the GNAT users guide for details.
2395 Note that pragma @code{Initialize_Scalars} is particularly useful in
2396 conjunction with the enhanced validity checking that is now provided
2397 in GNAT, which checks for invalid values under more conditions.
2398 Using this feature (see description of the @code{-gnatV} flag in the
2399 users guide) in conjunction with pragma @code{Initialize_Scalars}
2400 provides a powerful new tool to assist in the detection of problems
2401 caused by uninitialized variables.
2403 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2404 effect on the generated code. This may cause your code to be
2405 substantially larger. It may also cause an increase in the amount
2406 of stack required, so it is probably a good idea to turn on stack
2407 checking (see description of stack checking in the GNAT users guide)
2408 when using this pragma.
2410 @node Pragma Inline_Always
2411 @unnumberedsec Pragma Inline_Always
2412 @findex Inline_Always
2413 @noindent
2414 Syntax:
2416 @smallexample @c ada
2417 pragma Inline_Always (NAME [, NAME]);
2418 @end smallexample
2420 @noindent
2421 Similar to pragma @code{Inline} except that inlining is not subject to
2422 the use of option @code{-gnatn} and the inlining happens regardless of
2423 whether this option is used.
2425 @node Pragma Inline_Generic
2426 @unnumberedsec Pragma Inline_Generic
2427 @findex Inline_Generic
2428 @noindent
2429 Syntax:
2431 @smallexample @c ada
2432 pragma Inline_Generic (generic_package_NAME);
2433 @end smallexample
2435 @noindent
2436 This is implemented for compatibility with DEC Ada 83 and is recognized,
2437 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2438 by default when using GNAT@.
2440 @node Pragma Interface
2441 @unnumberedsec Pragma Interface
2442 @findex Interface
2443 @noindent
2444 Syntax:
2446 @smallexample @c ada
2447 pragma Interface (
2448      [Convention    =>] convention_identifier,
2449      [Entity =>] local_NAME
2450   [, [External_Name =>] static_string_expression],
2451   [, [Link_Name     =>] static_string_expression]);
2452 @end smallexample
2454 @noindent
2455 This pragma is identical in syntax and semantics to
2456 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2457 with Ada 83.  The definition is upwards compatible both with pragma
2458 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2459 with some extended implementations of this pragma in certain Ada 83
2460 implementations.
2462 @node Pragma Interface_Name
2463 @unnumberedsec Pragma Interface_Name
2464 @findex Interface_Name
2465 @noindent
2466 Syntax:
2468 @smallexample @c ada
2469 pragma Interface_Name (
2470      [Entity        =>] local_NAME
2471   [, [External_Name =>] static_string_EXPRESSION]
2472   [, [Link_Name     =>] static_string_EXPRESSION]);
2473 @end smallexample
2475 @noindent
2476 This pragma provides an alternative way of specifying the interface name
2477 for an interfaced subprogram, and is provided for compatibility with Ada
2478 83 compilers that use the pragma for this purpose.  You must provide at
2479 least one of @var{External_Name} or @var{Link_Name}.
2481 @node Pragma Interrupt_Handler
2482 @unnumberedsec Pragma Interrupt_Handler
2483 @findex Interrupt_Handler
2484 @noindent
2485 Syntax:
2487 @smallexample @c ada
2488 pragma Interrupt_Handler (procedure_local_NAME);
2489 @end smallexample
2491 @noindent
2492 This program unit pragma is supported for parameterless protected procedures
2493 as described in Annex C of the Ada Reference Manual. On the AAMP target
2494 the pragma can also be specified for nonprotected parameterless procedures
2495 that are declared at the library level (which includes procedures
2496 declared at the top level of a library package). In the case of AAMP,
2497 when this pragma is applied to a nonprotected procedure, the instruction
2498 @code{IERET} is generated for returns from the procedure, enabling
2499 maskable interrupts, in place of the normal return instruction.
2501 @node Pragma Interrupt_State
2502 @unnumberedsec Pragma Interrupt_State
2503 @findex Interrupt_State
2504 @noindent
2505 Syntax:
2507 @smallexample @c ada
2508 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2509 @end smallexample
2511 @noindent
2512 Normally certain interrupts are reserved to the implementation.  Any attempt
2513 to attach an interrupt causes Program_Error to be raised, as described in
2514 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2515 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2516 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2517 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2518 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2519 Ada exceptions, or used to implement run-time functions such as the
2520 @code{abort} statement and stack overflow checking.
2522 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2523 such uses of interrupts.  It subsumes the functionality of pragma
2524 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2525 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2526 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2527 and may be used to mark interrupts required by the board support package
2528 as reserved.
2530 Interrupts can be in one of three states:
2531 @itemize @bullet
2532 @item System
2534 The interrupt is reserved (no Ada handler can be installed), and the
2535 Ada run-time may not install a handler. As a result you are guaranteed
2536 standard system default action if this interrupt is raised.
2538 @item Runtime
2540 The interrupt is reserved (no Ada handler can be installed). The run time
2541 is allowed to install a handler for internal control purposes, but is
2542 not required to do so.
2544 @item User
2546 The interrupt is unreserved.  The user may install a handler to provide
2547 some other action.
2548 @end itemize
2550 @noindent
2551 These states are the allowed values of the @code{State} parameter of the
2552 pragma.  The @code{Name} parameter is a value of the type
2553 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2554 @code{Ada.Interrupts.Names}.
2556 This is a configuration pragma, and the binder will check that there
2557 are no inconsistencies between different units in a partition in how a
2558 given interrupt is specified. It may appear anywhere a pragma is legal.
2560 The effect is to move the interrupt to the specified state.
2562 By declaring interrupts to be SYSTEM, you guarantee the standard system
2563 action, such as a core dump.
2565 By declaring interrupts to be USER, you guarantee that you can install
2566 a handler.
2568 Note that certain signals on many operating systems cannot be caught and
2569 handled by applications.  In such cases, the pragma is ignored.  See the
2570 operating system documentation, or the value of the array @code{Reserved}
2571 declared in the specification of package @code{System.OS_Interface}.
2573 Overriding the default state of signals used by the Ada runtime may interfere
2574 with an application's runtime behavior in the cases of the synchronous signals,
2575 and in the case of the signal used to implement the @code{abort} statement.
2577 @node Pragma Keep_Names
2578 @unnumberedsec Pragma Keep_Names
2579 @findex Keep_Names
2580 @noindent
2581 Syntax:
2583 @smallexample @c ada
2584 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2585 @end smallexample
2587 @noindent
2588 The @var{local_NAME} argument
2589 must refer to an enumeration first subtype
2590 in the current declarative part. The effect is to retain the enumeration
2591 literal names for use by @code{Image} and @code{Value} even if a global
2592 @code{Discard_Names} pragma applies. This is useful when you want to
2593 generally suppress enumeration literal names and for example you therefore
2594 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2595 want to retain the names for specific enumeration types.
2597 @node Pragma License
2598 @unnumberedsec Pragma License
2599 @findex License
2600 @cindex License checking
2601 @noindent
2602 Syntax:
2604 @smallexample @c ada
2605 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2606 @end smallexample
2608 @noindent
2609 This pragma is provided to allow automated checking for appropriate license
2610 conditions with respect to the standard and modified GPL@.  A pragma
2611 @code{License}, which is a configuration pragma that typically appears at
2612 the start of a source file or in a separate @file{gnat.adc} file, specifies
2613 the licensing conditions of a unit as follows:
2615 @itemize @bullet
2616 @item Unrestricted
2617 This is used for a unit that can be freely used with no license restrictions.
2618 Examples of such units are public domain units, and units from the Ada
2619 Reference Manual.
2621 @item GPL
2622 This is used for a unit that is licensed under the unmodified GPL, and which
2623 therefore cannot be @code{with}'ed by a restricted unit.
2625 @item Modified_GPL
2626 This is used for a unit licensed under the GNAT modified GPL that includes
2627 a special exception paragraph that specifically permits the inclusion of
2628 the unit in programs without requiring the entire program to be released
2629 under the GPL@.
2631 @item Restricted
2632 This is used for a unit that is restricted in that it is not permitted to
2633 depend on units that are licensed under the GPL@.  Typical examples are
2634 proprietary code that is to be released under more restrictive license
2635 conditions.  Note that restricted units are permitted to @code{with} units
2636 which are licensed under the modified GPL (this is the whole point of the
2637 modified GPL).
2639 @end itemize
2641 @noindent
2642 Normally a unit with no @code{License} pragma is considered to have an
2643 unknown license, and no checking is done.  However, standard GNAT headers
2644 are recognized, and license information is derived from them as follows.
2646 @itemize @bullet
2648 A GNAT license header starts with a line containing 78 hyphens.  The following
2649 comment text is searched for the appearance of any of the following strings.
2651 If the string ``GNU General Public License'' is found, then the unit is assumed
2652 to have GPL license, unless the string ``As a special exception'' follows, in
2653 which case the license is assumed to be modified GPL@.
2655 If one of the strings
2656 ``This specification is adapted from the Ada Semantic Interface'' or
2657 ``This specification is derived from the Ada Reference Manual'' is found
2658 then the unit is assumed to be unrestricted.
2659 @end itemize
2661 @noindent
2662 These default actions means that a program with a restricted license pragma
2663 will automatically get warnings if a GPL unit is inappropriately
2664 @code{with}'ed.  For example, the program:
2666 @smallexample @c ada
2667 with Sem_Ch3;
2668 with GNAT.Sockets;
2669 procedure Secret_Stuff is
2670   @dots{}
2671 end Secret_Stuff
2672 @end smallexample
2674 @noindent
2675 if compiled with pragma @code{License} (@code{Restricted}) in a
2676 @file{gnat.adc} file will generate the warning:
2678 @smallexample
2679 1.  with Sem_Ch3;
2680         |
2681    >>> license of withed unit "Sem_Ch3" is incompatible
2683 2.  with GNAT.Sockets;
2684 3.  procedure Secret_Stuff is
2685 @end smallexample
2687 @noindent
2688 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2689 compiler and is licensed under the
2690 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2691 run time, and is therefore licensed under the modified GPL@.
2693 @node Pragma Link_With
2694 @unnumberedsec Pragma Link_With
2695 @findex Link_With
2696 @noindent
2697 Syntax:
2699 @smallexample @c ada
2700 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2701 @end smallexample
2703 @noindent
2704 This pragma is provided for compatibility with certain Ada 83 compilers.
2705 It has exactly the same effect as pragma @code{Linker_Options} except
2706 that spaces occurring within one of the string expressions are treated
2707 as separators. For example, in the following case:
2709 @smallexample @c ada
2710 pragma Link_With ("-labc -ldef");
2711 @end smallexample
2713 @noindent
2714 results in passing the strings @code{-labc} and @code{-ldef} as two
2715 separate arguments to the linker. In addition pragma Link_With allows
2716 multiple arguments, with the same effect as successive pragmas.
2718 @node Pragma Linker_Alias
2719 @unnumberedsec Pragma Linker_Alias
2720 @findex Linker_Alias
2721 @noindent
2722 Syntax:
2724 @smallexample @c ada
2725 pragma Linker_Alias (
2726   [Entity =>] local_NAME
2727   [Target =>] static_string_EXPRESSION);
2728 @end smallexample
2730 @noindent
2731 @var{local_NAME} must refer to an object that is declared at the library
2732 level. This pragma establishes the given entity as a linker alias for the
2733 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2734 and causes @var{local_NAME} to be emitted as an alias for the symbol
2735 @var{static_string_EXPRESSION} in the object file, that is to say no space
2736 is reserved for @var{local_NAME} by the assembler and it will be resolved
2737 to the same address as @var{static_string_EXPRESSION} by the linker.
2739 The actual linker name for the target must be used (e.g. the fully
2740 encoded name with qualification in Ada, or the mangled name in C++),
2741 or it must be declared using the C convention with @code{pragma Import}
2742 or @code{pragma Export}.
2744 Not all target machines support this pragma. On some of them it is accepted
2745 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2747 @smallexample @c ada
2748 --  Example of the use of pragma Linker_Alias
2750 package p is
2751   i : Integer := 1;
2752   pragma Export (C, i);
2754   new_name_for_i : Integer;
2755   pragma Linker_Alias (new_name_for_i, "i");
2756 end p;
2757 @end smallexample
2759 @node Pragma Linker_Constructor
2760 @unnumberedsec Pragma Linker_Constructor
2761 @findex Linker_Constructor
2762 @noindent
2763 Syntax:
2765 @smallexample @c ada
2766 pragma Linker_Constructor (procedure_LOCAL_NAME);
2767 @end smallexample
2769 @noindent
2770 @var{procedure_local_NAME} must refer to a parameterless procedure that
2771 is declared at the library level. A procedure to which this pragma is
2772 applied will be treated as an initialization routine by the linker.
2773 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2774 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2775 of the executable is called (or immediately after the shared library is
2776 loaded if the procedure is linked in a shared library), in particular
2777 before the Ada run-time environment is set up.
2779 Because of these specific contexts, the set of operations such a procedure
2780 can perform is very limited and the type of objects it can manipulate is
2781 essentially restricted to the elementary types. In particular, it must only
2782 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2784 This pragma is used by GNAT to implement auto-initialization of shared Stand
2785 Alone Libraries, which provides a related capability without the restrictions
2786 listed above. Where possible, the use of Stand Alone Libraries is preferable
2787 to the use of this pragma.
2789 @node Pragma Linker_Destructor
2790 @unnumberedsec Pragma Linker_Destructor
2791 @findex Linker_Destructor
2792 @noindent
2793 Syntax:
2795 @smallexample @c ada
2796 pragma Linker_Destructor (procedure_LOCAL_NAME);
2797 @end smallexample
2799 @noindent
2800 @var{procedure_local_NAME} must refer to a parameterless procedure that
2801 is declared at the library level. A procedure to which this pragma is
2802 applied will be treated as a finalization routine by the linker.
2803 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2804 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2805 of the executable has exited (or immediately before the shared library
2806 is unloaded if the procedure is linked in a shared library), in particular
2807 after the Ada run-time environment is shut down.
2809 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2810 because of these specific contexts.
2812 @node Pragma Linker_Section
2813 @unnumberedsec Pragma Linker_Section
2814 @findex Linker_Section
2815 @noindent
2816 Syntax:
2818 @smallexample @c ada
2819 pragma Linker_Section (
2820   [Entity  =>] local_NAME
2821   [Section =>] static_string_EXPRESSION);
2822 @end smallexample
2824 @noindent
2825 @var{local_NAME} must refer to an object that is declared at the library
2826 level. This pragma specifies the name of the linker section for the given
2827 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2828 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2829 section of the executable (assuming the linker doesn't rename the section).
2831 The compiler normally places library-level objects in standard sections
2832 depending on their type: procedures and functions generally go in the
2833 @code{.text} section, initialized variables in the @code{.data} section
2834 and uninitialized variables in the @code{.bss} section.
2836 Other, special sections may exist on given target machines to map special
2837 hardware, for example I/O ports or flash memory. This pragma is a means to
2838 defer the final layout of the executable to the linker, thus fully working
2839 at the symbolic level with the compiler.
2841 Some file formats do not support arbitrary sections so not all target
2842 machines support this pragma. The use of this pragma may cause a program
2843 execution to be erroneous if it is used to place an entity into an
2844 inappropriate section (e.g. a modified variable into the @code{.text}
2845 section). See also @code{pragma Persistent_BSS}.
2847 @smallexample @c ada
2848 --  Example of the use of pragma Linker_Section
2850 package IO_Card is
2851   Port_A : Integer;
2852   pragma Volatile (Port_A);
2853   pragma Linker_Section (Port_A, ".bss.port_a");
2855   Port_B : Integer;
2856   pragma Volatile (Port_B);
2857   pragma Linker_Section (Port_B, ".bss.port_b");
2858 end IO_Card;
2859 @end smallexample
2861 @node Pragma Long_Float
2862 @unnumberedsec Pragma Long_Float
2863 @cindex OpenVMS
2864 @findex Long_Float
2865 @noindent
2866 Syntax:
2868 @smallexample @c ada
2869 pragma Long_Float (FLOAT_FORMAT);
2871 FLOAT_FORMAT ::= D_Float | G_Float
2872 @end smallexample
2874 @noindent
2875 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2876 It allows control over the internal representation chosen for the predefined
2877 type @code{Long_Float} and for floating point type representations with
2878 @code{digits} specified in the range 7 through 15.
2879 For further details on this pragma, see the
2880 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2881 this pragma, the standard runtime libraries must be recompiled.  See the
2882 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2883 of the GNAT User's Guide for details on the use of this command.
2885 @node Pragma Machine_Attribute
2886 @unnumberedsec Pragma Machine_Attribute
2887 @findex Machine_Attribute
2888 @noindent
2889 Syntax:
2891 @smallexample @c ada
2892 pragma Machine_Attribute (
2893   [Attribute_Name =>] string_EXPRESSION,
2894   [Entity         =>] local_NAME);
2895 @end smallexample
2897 @noindent
2898 Machine-dependent attributes can be specified for types and/or
2899 declarations.  This pragma is semantically equivalent to
2900 @code{__attribute__((@var{string_expression}))} in GNU C,
2901 where @code{@var{string_expression}} is
2902 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2903 defined for each machine.  See the GCC manual for further information.
2904 It is not possible to specify attributes defined by other languages,
2905 only attributes defined by the machine the code is intended to run on.
2907 @node Pragma Main_Storage
2908 @unnumberedsec Pragma Main_Storage
2909 @cindex OpenVMS
2910 @findex Main_Storage
2911 @noindent
2912 Syntax:
2914 @smallexample @c ada
2915 pragma Main_Storage
2916   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2918 MAIN_STORAGE_OPTION ::=
2919   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2920 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2922 @end smallexample
2924 @noindent
2925 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2926 no effect in GNAT, other than being syntax checked.  Note that the pragma
2927 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2929 @node Pragma No_Return
2930 @unnumberedsec Pragma No_Return
2931 @findex No_Return
2932 @noindent
2933 Syntax:
2935 @smallexample @c ada
2936 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
2937 @end smallexample
2939 @noindent
2940 Each @var{procedure_local_NAME} argument must refer to one or more procedure
2941 declarations in the current declarative part.  A procedure to which this
2942 pragma is applied may not contain any explicit @code{return} statements.
2943 In addition, if the procedure contains any implicit returns from falling
2944 off the end of a statement sequence, then execution of that implicit
2945 return will cause Program_Error to be raised.
2947 One use of this pragma is to identify procedures whose only purpose is to raise
2948 an exception. Another use of this pragma is to suppress incorrect warnings
2949 about missing returns in functions, where the last statement of a function
2950 statement sequence is a call to such a procedure.
2952 Note that in Ada 2005 mode, this pragma is part of the language, and is
2953 identical in effect to the pragma as implemented in Ada 95 mode.
2955 @node Pragma No_Strict_Aliasing
2956 @unnumberedsec Pragma No_Strict_Aliasing
2957 @findex No_Strict_Aliasing
2958 @noindent
2959 Syntax:
2961 @smallexample @c ada
2962 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
2963 @end smallexample
2965 @noindent
2966 @var{type_LOCAL_NAME} must refer to an access type
2967 declaration in the current declarative part.  The effect is to inhibit
2968 strict aliasing optimization for the given type.  The form with no
2969 arguments is a configuration pragma which applies to all access types
2970 declared in units to which the pragma applies. For a detailed
2971 description of the strict aliasing optimization, and the situations
2972 in which it must be suppressed, see section
2973 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
2975 @node Pragma Normalize_Scalars
2976 @unnumberedsec Pragma Normalize_Scalars
2977 @findex Normalize_Scalars
2978 @noindent
2979 Syntax:
2981 @smallexample @c ada
2982 pragma Normalize_Scalars;
2983 @end smallexample
2985 @noindent
2986 This is a language defined pragma which is fully implemented in GNAT@.  The
2987 effect is to cause all scalar objects that are not otherwise initialized
2988 to be initialized.  The initial values are implementation dependent and
2989 are as follows:
2991 @table @code
2992 @item Standard.Character
2993 @noindent
2994 Objects whose root type is Standard.Character are initialized to
2995 Character'Last unless the subtype range excludes NUL (in which case
2996 NUL is used). This choice will always generate an invalid value if
2997 one exists.
2999 @item Standard.Wide_Character
3000 @noindent
3001 Objects whose root type is Standard.Wide_Character are initialized to
3002 Wide_Character'Last unless the subtype range excludes NUL (in which case
3003 NUL is used). This choice will always generate an invalid value if
3004 one exists.
3006 @item Standard.Wide_Wide_Character
3007 @noindent
3008 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3009 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3010 which case NUL is used). This choice will always generate an invalid value if
3011 one exists.
3013 @item Integer types
3014 @noindent
3015 Objects of an integer type are treated differently depending on whether
3016 negative values are present in the subtype. If no negative values are
3017 present, then all one bits is used as the initial value except in the
3018 special case where zero is excluded from the subtype, in which case
3019 all zero bits are used. This choice will always generate an invalid
3020 value if one exists.
3022 For subtypes with negative values present, the largest negative number
3023 is used, except in the unusual case where this largest negative number
3024 is in the subtype, and the largest positive number is not, in which case
3025 the largest positive value is used. This choice will always generate
3026 an invalid value if one exists.
3028 @item Floating-Point Types
3029 Objects of all floating-point types are initialized to all 1-bits. For
3030 standard IEEE format, this corresponds to a NaN (not a number) which is
3031 indeed an invalid value.
3033 @item Fixed-Point Types
3034 Objects of all fixed-point types are treated as described above for integers,
3035 with the rules applying to the underlying integer value used to represent
3036 the fixed-point value.
3038 @item Modular types
3039 Objects of a modular type are initialized to all one bits, except in
3040 the special case where zero is excluded from the subtype, in which
3041 case all zero bits are used. This choice will always generate an
3042 invalid value if one exists.
3044 @item Enumeration types
3045 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3046 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3047 whose Pos value is zero, in which case a code of zero is used. This choice
3048 will always generate an invalid value if one exists.
3050 @end table
3052 @node Pragma Obsolescent
3053 @unnumberedsec Pragma Obsolescent
3054 @findex Obsolescent
3055 @noindent
3056 Syntax:
3058 @smallexample @c ada
3059 pragma Obsolescent
3060   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3061 @end smallexample
3063 @noindent
3064 This pragma can occur immediately following a declaration of an entity,
3065 including the case of a record component, and usually the Entity name
3066 must match the name of the entity declared by this declaration.
3067 Alternatively, the pragma can immediately follow an
3068 enumeration type declaration, where the entity argument names one of the
3069 enumeration literals.
3071 This pragma is used to indicate that the named entity
3072 is considered obsolescent and should not be used. Typically this is
3073 used when an API must be modified by eventually removing or modifying
3074 existing subprograms or other entities. The pragma can be used at an
3075 intermediate stage when the entity is still present, but will be
3076 removed later.
3078 The effect of this pragma is to output a warning message on
3079 a call to a program thus marked that the
3080 subprogram is obsolescent if the appropriate warning option in the
3081 compiler is activated. If the string parameter is present, then a second
3082 warning message is given containing this text.
3083 In addition, a call to such a program is considered a violation of
3084 pragma Restrictions (No_Obsolescent_Features).
3086 This pragma can also be used as a program unit pragma for a package,
3087 in which case the entity name is the name of the package, and the
3088 pragma indicates that the entire package is considered
3089 obsolescent. In this case a client @code{with}'ing such a package
3090 violates the restriction, and the @code{with} statement is
3091 flagged with warnings if the warning option is set.
3093 If the optional third parameter is present (which must be exactly
3094 the identifier Ada_05, no other argument is allowed), then the
3095 indication of obsolescence applies only when compiling in Ada 2005
3096 mode. This is primarily intended for dealing with the situations
3097 in the predefined library where subprograms or packages
3098 have become defined as obsolescent in Ada 2005
3099 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3101 The following examples show typical uses of this pragma:
3103 @smallexample @c ada
3104 package p is
3105    pragma Obsolescent
3106      (Entity => p, "use pp instead of p");
3107 end p;
3109 package q is
3110    procedure q2;
3111    pragma Obsolescent
3112      (Entity => q2, "use q2new instead");
3114    type R is new integer;
3115    pragma Obsolescent
3116      (Entity => R, "use RR in Ada 2005", Ada_05);
3118    type M is record
3119       F1 : Integer;
3120       F2 : Integer;
3121       pragma Obsolescent (Entity => F2);
3122       F3 : Integer;
3123    end record;
3125    type E is (a, bc, 'd', quack);
3126    pragma Obsolescent (Entity => bc)
3127    pragma Obsolescent (Entity => 'd')
3129    function "+"
3130      (a, b : character) return character;
3131    pragma Obsolescent (Entity => "+");
3132 end;
3133 @end smallexample
3135 @noindent
3136 In an earlier version of GNAT, the Entity parameter was not required,
3137 and this form is still accepted for compatibility purposes. If the
3138 Entity parameter is omitted, then the pragma applies to the declaration
3139 immediately preceding the pragma (this form cannot be used for the
3140 enumeration literal case).
3142 @node Pragma Passive
3143 @unnumberedsec Pragma Passive
3144 @findex Passive
3145 @noindent
3146 Syntax:
3148 @smallexample @c ada
3149 pragma Passive ([Semaphore | No]);
3150 @end smallexample
3152 @noindent
3153 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3154 compatibility with DEC Ada 83 implementations, where it is used within a
3155 task definition to request that a task be made passive.  If the argument
3156 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3157 treats the pragma as an assertion that the containing task is passive
3158 and that optimization of context switch with this task is permitted and
3159 desired.  If the argument @code{No} is present, the task must not be
3160 optimized.  GNAT does not attempt to optimize any tasks in this manner
3161 (since protected objects are available in place of passive tasks).
3163 @node Pragma Persistent_BSS
3164 @unnumberedsec Pragma Persistent_BSS
3165 @findex Persistent_BSS
3166 @noindent
3167 Syntax:
3169 @smallexample @c ada
3170 pragma Persistent_BSS [local_NAME]
3171 @end smallexample
3173 @noindent
3174 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3175 section. On some targets the linker and loader provide for special
3176 treatment of this section, allowing a program to be reloaded without
3177 affecting the contents of this data (hence the name persistent).
3179 There are two forms of usage. If an argument is given, it must be the
3180 local name of a library level object, with no explicit initialization
3181 and whose type is potentially persistent. If no argument is given, then
3182 the pragma is a configuration pragma, and applies to all library level
3183 objects with no explicit initialization of potentially persistent types.
3185 A potentially persistent type is a scalar type, or a non-tagged,
3186 non-discriminated record, all of whose components have no explicit
3187 initialization and are themselves of a potentially persistent type,
3188 or an array, all of whose constraints are static, and whose component
3189 type is potentially persistent.
3191 If this pragma is used on a target where this feature is not supported,
3192 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3194 @node Pragma Polling
3195 @unnumberedsec Pragma Polling
3196 @findex Polling
3197 @noindent
3198 Syntax:
3200 @smallexample @c ada
3201 pragma Polling (ON | OFF);
3202 @end smallexample
3204 @noindent
3205 This pragma controls the generation of polling code.  This is normally off.
3206 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3207 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3208 runtime library, and can be found in file @file{a-excpol.adb}.
3210 Pragma @code{Polling} can appear as a configuration pragma (for example it
3211 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3212 can be used in the statement or declaration sequence to control polling
3213 more locally.
3215 A call to the polling routine is generated at the start of every loop and
3216 at the start of every subprogram call.  This guarantees that the @code{Poll}
3217 routine is called frequently, and places an upper bound (determined by
3218 the complexity of the code) on the period between two @code{Poll} calls.
3220 The primary purpose of the polling interface is to enable asynchronous
3221 aborts on targets that cannot otherwise support it (for example Windows
3222 NT), but it may be used for any other purpose requiring periodic polling.
3223 The standard version is null, and can be replaced by a user program.  This
3224 will require re-compilation of the @code{Ada.Exceptions} package that can
3225 be found in files @file{a-except.ads} and @file{a-except.adb}.
3227 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3228 distribution) is used to enable the asynchronous abort capability on
3229 targets that do not normally support the capability.  The version of
3230 @code{Poll} in this file makes a call to the appropriate runtime routine
3231 to test for an abort condition.
3233 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
3234 the @cite{GNAT User's Guide} for details.
3236 @node Pragma Profile (Ravenscar)
3237 @unnumberedsec Pragma Profile (Ravenscar)
3238 @findex Ravenscar
3239 @noindent
3240 Syntax:
3242 @smallexample @c ada
3243 pragma Profile (Ravenscar);
3244 @end smallexample
3246 @noindent
3247 A configuration pragma that establishes the following set of configuration
3248 pragmas:
3250 @table @code
3251 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3252 [RM D.2.2] Tasks are dispatched following a preemptive
3253 priority-ordered scheduling policy.
3255 @item Locking_Policy (Ceiling_Locking)
3256 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3257 the ceiling priority of the corresponding protected object.
3259 @c @item Detect_Blocking
3260 @c This pragma forces the detection of potentially blocking operations within a
3261 @c protected operation, and to raise Program_Error if that happens.
3262 @end table
3263 @noindent
3265 plus the following set of restrictions:
3267 @table @code
3268 @item Max_Entry_Queue_Length = 1
3269 Defines the maximum number of calls that are queued on a (protected) entry.
3270 Note that this restrictions is checked at run time. Violation of this
3271 restriction results in the raising of Program_Error exception at the point of
3272 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3273 always 1 and hence no task can be queued on a protected entry.
3275 @item Max_Protected_Entries = 1
3276 [RM D.7] Specifies the maximum number of entries per protected type. The
3277 bounds of every entry family of a protected unit shall be static, or shall be
3278 defined by a discriminant of a subtype whose corresponding bound is static.
3279 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3281 @item Max_Task_Entries = 0
3282 [RM D.7] Specifies the maximum number of entries
3283 per task.  The bounds of every entry family
3284 of a task unit shall be static, or shall be
3285 defined by a discriminant of a subtype whose
3286 corresponding bound is static.  A value of zero
3287 indicates that no rendezvous are possible.  For
3288 the Profile (Ravenscar), the value of Max_Task_Entries is always
3289 0 (zero).
3291 @item No_Abort_Statements
3292 [RM D.7] There are no abort_statements, and there are
3293 no calls to Task_Identification.Abort_Task.
3295 @item No_Asynchronous_Control
3296 [RM D.7] There are no semantic dependences on the package
3297 Asynchronous_Task_Control.
3299 @item No_Calendar
3300 There are no semantic dependencies on the package Ada.Calendar.
3302 @item No_Dynamic_Attachment
3303 There is no call to any of the operations defined in package Ada.Interrupts
3304 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3305 Detach_Handler, and Reference).
3307 @item No_Dynamic_Priorities
3308 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3310 @item No_Implicit_Heap_Allocations
3311 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3313 @item No_Local_Protected_Objects
3314 Protected objects and access types that designate
3315 such objects shall be declared only at library level.
3317 @item No_Protected_Type_Allocators
3318 There are no allocators for protected types or
3319 types containing protected subcomponents.
3321 @item No_Relative_Delay
3322 There are no delay_relative statements.
3324 @item No_Requeue_Statements
3325 Requeue statements are not allowed.
3327 @item No_Select_Statements
3328 There are no select_statements.
3330 @item No_Task_Allocators
3331 [RM D.7] There are no allocators for task types
3332 or types containing task subcomponents.
3334 @item No_Task_Attributes_Package
3335 There are no semantic dependencies on the Ada.Task_Attributes package.
3337 @item No_Task_Hierarchy
3338 [RM D.7] All (non-environment) tasks depend
3339 directly on the environment task of the partition.
3341 @item No_Task_Termination
3342 Tasks which terminate are erroneous.
3344 @item Simple_Barriers
3345 Entry barrier condition expressions shall be either static
3346 boolean expressions or boolean objects which are declared in
3347 the protected type which contains the entry.
3348 @end table
3350 @noindent
3351 This set of configuration pragmas and restrictions correspond to the
3352 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3353 published by the @cite{International Real-Time Ada Workshop}, 1997,
3354 and whose most recent description is available at
3355 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3357 The original definition of the profile was revised at subsequent IRTAW
3358 meetings. It has been included in the ISO
3359 @cite{Guide for the Use of the Ada Programming Language in High
3360 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3361 the next revision of the standard. The formal definition given by
3362 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3363 AI-305) available at
3364 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3365 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3366 respectively.
3368 The above set is a superset of the restrictions provided by pragma
3369 @code{Profile (Restricted)}, it includes six additional restrictions
3370 (@code{Simple_Barriers}, @code{No_Select_Statements},
3371 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3372 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3373 that pragma @code{Profile (Ravenscar)}, like the pragma
3374 @code{Profile (Restricted)},
3375 automatically causes the use of a simplified,
3376 more efficient version of the tasking run-time system.
3378 @node Pragma Profile (Restricted)
3379 @unnumberedsec Pragma Profile (Restricted)
3380 @findex Restricted Run Time
3381 @noindent
3382 Syntax:
3384 @smallexample @c ada
3385 pragma Profile (Restricted);
3386 @end smallexample
3388 @noindent
3389 A configuration pragma that establishes the following set of restrictions:
3391 @itemize @bullet
3392 @item No_Abort_Statements
3393 @item No_Entry_Queue
3394 @item No_Task_Hierarchy
3395 @item No_Task_Allocators
3396 @item No_Dynamic_Priorities
3397 @item No_Terminate_Alternatives
3398 @item No_Dynamic_Attachment
3399 @item No_Protected_Type_Allocators
3400 @item No_Local_Protected_Objects
3401 @item No_Requeue_Statements
3402 @item No_Task_Attributes_Package
3403 @item Max_Asynchronous_Select_Nesting =  0
3404 @item Max_Task_Entries =  0
3405 @item Max_Protected_Entries = 1
3406 @item Max_Select_Alternatives = 0
3407 @end itemize
3409 @noindent
3410 This set of restrictions causes the automatic selection of a simplified
3411 version of the run time that provides improved performance for the
3412 limited set of tasking functionality permitted by this set of restrictions.
3414 @node Pragma Psect_Object
3415 @unnumberedsec Pragma Psect_Object
3416 @findex Psect_Object
3417 @noindent
3418 Syntax:
3420 @smallexample @c ada
3421 pragma Psect_Object (
3422      [Internal =>] local_NAME,
3423   [, [External =>] EXTERNAL_SYMBOL]
3424   [, [Size     =>] EXTERNAL_SYMBOL]);
3426 EXTERNAL_SYMBOL ::=
3427   IDENTIFIER
3428 | static_string_EXPRESSION
3429 @end smallexample
3431 @noindent
3432 This pragma is identical in effect to pragma @code{Common_Object}.
3434 @node Pragma Pure_Function
3435 @unnumberedsec Pragma Pure_Function
3436 @findex Pure_Function
3437 @noindent
3438 Syntax:
3440 @smallexample @c ada
3441 pragma Pure_Function ([Entity =>] function_local_NAME);
3442 @end smallexample
3444 @noindent
3445 This pragma appears in the same declarative part as a function
3446 declaration (or a set of function declarations if more than one
3447 overloaded declaration exists, in which case the pragma applies
3448 to all entities).  It specifies that the function @code{Entity} is
3449 to be considered pure for the purposes of code generation.  This means
3450 that the compiler can assume that there are no side effects, and
3451 in particular that two calls with identical arguments produce the
3452 same result.  It also means that the function can be used in an
3453 address clause.
3455 Note that, quite deliberately, there are no static checks to try
3456 to ensure that this promise is met, so @code{Pure_Function} can be used
3457 with functions that are conceptually pure, even if they do modify
3458 global variables.  For example, a square root function that is
3459 instrumented to count the number of times it is called is still
3460 conceptually pure, and can still be optimized, even though it
3461 modifies a global variable (the count).  Memo functions are another
3462 example (where a table of previous calls is kept and consulted to
3463 avoid re-computation).
3465 @findex Pure
3466 Note: Most functions in a @code{Pure} package are automatically pure, and
3467 there is no need to use pragma @code{Pure_Function} for such functions.  One
3468 exception is any function that has at least one formal of type
3469 @code{System.Address} or a type derived from it.  Such functions are not
3470 considered pure by default, since the compiler assumes that the
3471 @code{Address} parameter may be functioning as a pointer and that the
3472 referenced data may change even if the address value does not.
3473 Similarly, imported functions are not considered to be pure by default,
3474 since there is no way of checking that they are in fact pure.  The use
3475 of pragma @code{Pure_Function} for such a function will override these default
3476 assumption, and cause the compiler to treat a designated subprogram as pure
3477 in these cases.
3479 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3480 applies to the underlying renamed function.  This can be used to
3481 disambiguate cases of overloading where some but not all functions
3482 in a set of overloaded functions are to be designated as pure.
3484 If pragma @code{Pure_Function} is applied to a library level function, the
3485 function is also considered pure from an optimization point of view, but the
3486 unit is not a Pure unit in the categorization sense. So for example, a function
3487 thus marked is free to @code{with} non-pure units.
3489 @node Pragma Restriction_Warnings
3490 @unnumberedsec Pragma Restriction_Warnings
3491 @findex Restriction_Warnings
3492 @noindent
3493 Syntax:
3495 @smallexample @c ada
3496 pragma Restriction_Warnings
3497   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3498 @end smallexample
3500 @noindent
3501 This pragma allows a series of restriction identifiers to be
3502 specified (the list of allowed identifiers is the same as for
3503 pragma @code{Restrictions}). For each of these identifiers
3504 the compiler checks for violations of the restriction, but
3505 generates a warning message rather than an error message
3506 if the restriction is violated.
3508 @node Pragma Source_File_Name
3509 @unnumberedsec Pragma Source_File_Name
3510 @findex Source_File_Name
3511 @noindent
3512 Syntax:
3514 @smallexample @c ada
3515 pragma Source_File_Name (
3516   [Unit_Name   =>] unit_NAME,
3517   Spec_File_Name =>  STRING_LITERAL);
3519 pragma Source_File_Name (
3520   [Unit_Name   =>] unit_NAME,
3521   Body_File_Name =>  STRING_LITERAL);
3522 @end smallexample
3524 @noindent
3525 Use this to override the normal naming convention.  It is a configuration
3526 pragma, and so has the usual applicability of configuration pragmas
3527 (i.e.@: it applies to either an entire partition, or to all units in a
3528 compilation, or to a single unit, depending on how it is used.
3529 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3530 the second argument is required, and indicates whether this is the file
3531 name for the spec or for the body.
3533 Another form of the @code{Source_File_Name} pragma allows
3534 the specification of patterns defining alternative file naming schemes
3535 to apply to all files.
3537 @smallexample @c ada
3538 pragma Source_File_Name
3539   (Spec_File_Name => STRING_LITERAL
3540    [,Casing => CASING_SPEC]
3541    [,Dot_Replacement => STRING_LITERAL]);
3543 pragma Source_File_Name
3544   (Body_File_Name => STRING_LITERAL
3545    [,Casing => CASING_SPEC]
3546    [,Dot_Replacement => STRING_LITERAL]);
3548 pragma Source_File_Name
3549   (Subunit_File_Name => STRING_LITERAL
3550    [,Casing => CASING_SPEC]
3551    [,Dot_Replacement => STRING_LITERAL]);
3553 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3554 @end smallexample
3556 @noindent
3557 The first argument is a pattern that contains a single asterisk indicating
3558 the point at which the unit name is to be inserted in the pattern string
3559 to form the file name.  The second argument is optional.  If present it
3560 specifies the casing of the unit name in the resulting file name string.
3561 The default is lower case.  Finally the third argument allows for systematic
3562 replacement of any dots in the unit name by the specified string literal.
3564 A pragma Source_File_Name cannot appear after a
3565 @ref{Pragma Source_File_Name_Project}.
3567 For more details on the use of the @code{Source_File_Name} pragma,
3568 see the sections ``Using Other File Names'' and
3569 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3571 @node Pragma Source_File_Name_Project
3572 @unnumberedsec Pragma Source_File_Name_Project
3573 @findex Source_File_Name_Project
3574 @noindent
3576 This pragma has the same syntax and semantics as pragma Source_File_Name.
3577 It is only allowed as a stand alone configuration pragma.
3578 It cannot appear after a @ref{Pragma Source_File_Name}, and
3579 most importantly, once pragma Source_File_Name_Project appears,
3580 no further Source_File_Name pragmas are allowed.
3582 The intention is that Source_File_Name_Project pragmas are always
3583 generated by the Project Manager in a manner consistent with the naming
3584 specified in a project file, and when naming is controlled in this manner,
3585 it is not permissible to attempt to modify this naming scheme using
3586 Source_File_Name pragmas (which would not be known to the project manager).
3588 @node Pragma Source_Reference
3589 @unnumberedsec Pragma Source_Reference
3590 @findex Source_Reference
3591 @noindent
3592 Syntax:
3594 @smallexample @c ada
3595 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3596 @end smallexample
3598 @noindent
3599 This pragma must appear as the first line of a source file.
3600 @var{integer_literal} is the logical line number of the line following
3601 the pragma line (for use in error messages and debugging
3602 information).  @var{string_literal} is a static string constant that
3603 specifies the file name to be used in error messages and debugging
3604 information.  This is most notably used for the output of @code{gnatchop}
3605 with the @code{-r} switch, to make sure that the original unchopped
3606 source file is the one referred to.
3608 The second argument must be a string literal, it cannot be a static
3609 string expression other than a string literal.  This is because its value
3610 is needed for error messages issued by all phases of the compiler.
3612 @node Pragma Stream_Convert
3613 @unnumberedsec Pragma Stream_Convert
3614 @findex Stream_Convert
3615 @noindent
3616 Syntax:
3618 @smallexample @c ada
3619 pragma Stream_Convert (
3620   [Entity =>] type_local_NAME,
3621   [Read   =>] function_NAME,
3622   [Write  =>] function_NAME);
3623 @end smallexample
3625 @noindent
3626 This pragma provides an efficient way of providing stream functions for
3627 types defined in packages.  Not only is it simpler to use than declaring
3628 the necessary functions with attribute representation clauses, but more
3629 significantly, it allows the declaration to made in such a way that the
3630 stream packages are not loaded unless they are needed.  The use of
3631 the Stream_Convert pragma adds no overhead at all, unless the stream
3632 attributes are actually used on the designated type.
3634 The first argument specifies the type for which stream functions are
3635 provided.  The second parameter provides a function used to read values
3636 of this type.  It must name a function whose argument type may be any
3637 subtype, and whose returned type must be the type given as the first
3638 argument to the pragma.
3640 The meaning of the @var{Read}
3641 parameter is that if a stream attribute directly
3642 or indirectly specifies reading of the type given as the first parameter,
3643 then a value of the type given as the argument to the Read function is
3644 read from the stream, and then the Read function is used to convert this
3645 to the required target type.
3647 Similarly the @var{Write} parameter specifies how to treat write attributes
3648 that directly or indirectly apply to the type given as the first parameter.
3649 It must have an input parameter of the type specified by the first parameter,
3650 and the return type must be the same as the input type of the Read function.
3651 The effect is to first call the Write function to convert to the given stream
3652 type, and then write the result type to the stream.
3654 The Read and Write functions must not be overloaded subprograms.  If necessary
3655 renamings can be supplied to meet this requirement.
3656 The usage of this attribute is best illustrated by a simple example, taken
3657 from the GNAT implementation of package Ada.Strings.Unbounded:
3659 @smallexample @c ada
3660 function To_Unbounded (S : String)
3661            return Unbounded_String
3662   renames To_Unbounded_String;
3664 pragma Stream_Convert
3665   (Unbounded_String, To_Unbounded, To_String);
3666 @end smallexample
3668 @noindent
3669 The specifications of the referenced functions, as given in the Ada 95
3670 Reference Manual are:
3672 @smallexample @c ada
3673 function To_Unbounded_String (Source : String)
3674   return Unbounded_String;
3676 function To_String (Source : Unbounded_String)
3677   return String;
3678 @end smallexample
3680 @noindent
3681 The effect is that if the value of an unbounded string is written to a
3682 stream, then the representation of the item in the stream is in the same
3683 format used for @code{Standard.String}, and this same representation is
3684 expected when a value of this type is read from the stream.
3686 @node Pragma Style_Checks
3687 @unnumberedsec Pragma Style_Checks
3688 @findex Style_Checks
3689 @noindent
3690 Syntax:
3692 @smallexample @c ada
3693 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3694                      On | Off [, local_NAME]);
3695 @end smallexample
3697 @noindent
3698 This pragma is used in conjunction with compiler switches to control the
3699 built in style checking provided by GNAT@.  The compiler switches, if set,
3700 provide an initial setting for the switches, and this pragma may be used
3701 to modify these settings, or the settings may be provided entirely by
3702 the use of the pragma.  This pragma can be used anywhere that a pragma
3703 is legal, including use as a configuration pragma (including use in
3704 the @file{gnat.adc} file).
3706 The form with a string literal specifies which style options are to be
3707 activated.  These are additive, so they apply in addition to any previously
3708 set style check options.  The codes for the options are the same as those
3709 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3710 For example the following two methods can be used to enable
3711 layout checking:
3713 @itemize @bullet
3714 @item
3715 @smallexample @c ada
3716 pragma Style_Checks ("l");
3717 @end smallexample
3719 @item
3720 @smallexample
3721 gcc -c -gnatyl @dots{}
3722 @end smallexample
3723 @end itemize
3725 @noindent
3726 The form ALL_CHECKS activates all standard checks (its use is equivalent
3727 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3728 Guide for details.
3730 The forms with @code{Off} and @code{On}
3731 can be used to temporarily disable style checks
3732 as shown in the following example:
3734 @smallexample @c ada
3735 @iftex
3736 @leftskip=0cm
3737 @end iftex
3738 pragma Style_Checks ("k"); -- requires keywords in lower case
3739 pragma Style_Checks (Off); -- turn off style checks
3740 NULL;                      -- this will not generate an error message
3741 pragma Style_Checks (On);  -- turn style checks back on
3742 NULL;                      -- this will generate an error message
3743 @end smallexample
3745 @noindent
3746 Finally the two argument form is allowed only if the first argument is
3747 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3748 for the specified entity, as shown in the following example:
3750 @smallexample @c ada
3751 @iftex
3752 @leftskip=0cm
3753 @end iftex
3754 pragma Style_Checks ("r"); -- require consistency of identifier casing
3755 Arg : Integer;
3756 Rf1 : Integer := ARG;      -- incorrect, wrong case
3757 pragma Style_Checks (Off, Arg);
3758 Rf2 : Integer := ARG;      -- OK, no error
3759 @end smallexample
3761 @node Pragma Subtitle
3762 @unnumberedsec Pragma Subtitle
3763 @findex Subtitle
3764 @noindent
3765 Syntax:
3767 @smallexample @c ada
3768 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3769 @end smallexample
3771 @noindent
3772 This pragma is recognized for compatibility with other Ada compilers
3773 but is ignored by GNAT@.
3775 @node Pragma Suppress
3776 @unnumberedsec Pragma Suppress
3777 @findex Suppress
3778 @noindent
3779 Syntax:
3781 @smallexample @c ada
3782 pragma Suppress (Identifier [, [On =>] Name]);
3783 @end smallexample
3785 @noindent
3786 This is a standard pragma, and supports all the check names required in
3787 the RM. It is included here because GNAT recognizes one additional check
3788 name: @code{Alignment_Check} which can be used to suppress alignment checks
3789 on addresses used in address clauses. Such checks can also be suppressed
3790 by suppressing range checks, but the specific use of @code{Alignment_Check}
3791 allows suppression of alignment checks without suppressing other range checks.
3793 @node Pragma Suppress_All
3794 @unnumberedsec Pragma Suppress_All
3795 @findex Suppress_All
3796 @noindent
3797 Syntax:
3799 @smallexample @c ada
3800 pragma Suppress_All;
3801 @end smallexample
3803 @noindent
3804 This pragma can only appear immediately following a compilation
3805 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3806 which it follows.  This pragma is implemented for compatibility with DEC
3807 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3808 configuration pragma is the preferred usage in GNAT@.
3810 @node Pragma Suppress_Exception_Locations
3811 @unnumberedsec Pragma Suppress_Exception_Locations
3812 @findex Suppress_Exception_Locations
3813 @noindent
3814 Syntax:
3816 @smallexample @c ada
3817 pragma Suppress_Exception_Locations;
3818 @end smallexample
3820 @noindent
3821 In normal mode, a raise statement for an exception by default generates
3822 an exception message giving the file name and line number for the location
3823 of the raise. This is useful for debugging and logging purposes, but this
3824 entails extra space for the strings for the messages. The configuration
3825 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3826 generation of these strings, with the result that space is saved, but the
3827 exception message for such raises is null. This configuration pragma may
3828 appear in a global configuration pragma file, or in a specific unit as
3829 usual. It is not required that this pragma be used consistently within
3830 a partition, so it is fine to have some units within a partition compiled
3831 with this pragma and others compiled in normal mode without it.
3833 @node Pragma Suppress_Initialization
3834 @unnumberedsec Pragma Suppress_Initialization
3835 @findex Suppress_Initialization
3836 @cindex Suppressing initialization
3837 @cindex Initialization, suppression of
3838 @noindent
3839 Syntax:
3841 @smallexample @c ada
3842 pragma Suppress_Initialization ([Entity =>] type_Name);
3843 @end smallexample
3845 @noindent
3846 This pragma suppresses any implicit or explicit initialization
3847 associated with the given type name for all variables of this type.
3849 @node Pragma Task_Info
3850 @unnumberedsec Pragma Task_Info
3851 @findex Task_Info
3852 @noindent
3853 Syntax
3855 @smallexample @c ada
3856 pragma Task_Info (EXPRESSION);
3857 @end smallexample
3859 @noindent
3860 This pragma appears within a task definition (like pragma
3861 @code{Priority}) and applies to the task in which it appears.  The
3862 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3863 The @code{Task_Info} pragma provides system dependent control over
3864 aspects of tasking implementation, for example, the ability to map
3865 tasks to specific processors.  For details on the facilities available
3866 for the version of GNAT that you are using, see the documentation
3867 in the specification of package System.Task_Info in the runtime
3868 library.
3870 @node Pragma Task_Name
3871 @unnumberedsec Pragma Task_Name
3872 @findex Task_Name
3873 @noindent
3874 Syntax
3876 @smallexample @c ada
3877 pragma Task_Name (string_EXPRESSION);
3878 @end smallexample
3880 @noindent
3881 This pragma appears within a task definition (like pragma
3882 @code{Priority}) and applies to the task in which it appears.  The
3883 argument must be of type String, and provides a name to be used for
3884 the task instance when the task is created.  Note that this expression
3885 is not required to be static, and in particular, it can contain
3886 references to task discriminants.  This facility can be used to
3887 provide different names for different tasks as they are created,
3888 as illustrated in the example below.
3890 The task name is recorded internally in the run-time structures
3891 and is accessible to tools like the debugger.  In addition the
3892 routine @code{Ada.Task_Identification.Image} will return this
3893 string, with a unique task address appended.
3895 @smallexample @c ada
3896 --  Example of the use of pragma Task_Name
3898 with Ada.Task_Identification;
3899 use Ada.Task_Identification;
3900 with Text_IO; use Text_IO;
3901 procedure t3 is
3903    type Astring is access String;
3905    task type Task_Typ (Name : access String) is
3906       pragma Task_Name (Name.all);
3907    end Task_Typ;
3909    task body Task_Typ is
3910       Nam : constant String := Image (Current_Task);
3911    begin
3912       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3913    end Task_Typ;
3915    type Ptr_Task is access Task_Typ;
3916    Task_Var : Ptr_Task;
3918 begin
3919    Task_Var :=
3920      new Task_Typ (new String'("This is task 1"));
3921    Task_Var :=
3922      new Task_Typ (new String'("This is task 2"));
3923 end;
3924 @end smallexample
3926 @node Pragma Task_Storage
3927 @unnumberedsec Pragma Task_Storage
3928 @findex Task_Storage
3929 Syntax:
3931 @smallexample @c ada
3932 pragma Task_Storage (
3933   [Task_Type =>] local_NAME,
3934   [Top_Guard =>] static_integer_EXPRESSION);
3935 @end smallexample
3937 @noindent
3938 This pragma specifies the length of the guard area for tasks.  The guard
3939 area is an additional storage area allocated to a task.  A value of zero
3940 means that either no guard area is created or a minimal guard area is
3941 created, depending on the target.  This pragma can appear anywhere a
3942 @code{Storage_Size} attribute definition clause is allowed for a task
3943 type.
3945 @node Pragma Thread_Body
3946 @unnumberedsec Pragma Thread_Body
3947 @findex Thread_Body
3948 Syntax:
3950 @smallexample @c ada
3951 pragma Thread_Body (
3952   [Entity =>] local_NAME,
3953  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3954 @end smallexample
3956 @noindent
3957 This pragma specifies that the subprogram whose name is given as the
3958 @code{Entity} argument is a thread body, which will be activated
3959 by being called via its Address from foreign code. The purpose is
3960 to allow execution and registration of the foreign thread within the
3961 Ada run-time system.
3963 See the library unit @code{System.Threads} for details on the expansion of
3964 a thread body subprogram, including the calls made to subprograms
3965 within System.Threads to register the task.  This unit also lists the
3966 targets and runtime systems for which this pragma is supported.
3968 A thread body subprogram may not be called directly from Ada code, and
3969 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3970 to such a subprogram. The only legitimate way of calling such a subprogram
3971 is to pass its Address to foreign code and then make the call from the
3972 foreign code.
3974 A thread body subprogram may have any parameters, and it may be a function
3975 returning a result. The convention of the thread body subprogram may be
3976 set in the usual manner using @code{pragma Convention}.
3978 The secondary stack size parameter, if given, is used to set the size
3979 of secondary stack for the thread. The secondary stack is allocated as
3980 a local variable of the expanded thread body subprogram, and thus is
3981 allocated out of the main thread stack size. If no secondary stack
3982 size parameter is present, the default size (from the declaration in
3983 @code{System.Secondary_Stack} is used.
3985 @node Pragma Time_Slice
3986 @unnumberedsec Pragma Time_Slice
3987 @findex Time_Slice
3988 @noindent
3989 Syntax:
3991 @smallexample @c ada
3992 pragma Time_Slice (static_duration_EXPRESSION);
3993 @end smallexample
3995 @noindent
3996 For implementations of GNAT on operating systems where it is possible
3997 to supply a time slice value, this pragma may be used for this purpose.
3998 It is ignored if it is used in a system that does not allow this control,
3999 or if it appears in other than the main program unit.
4000 @cindex OpenVMS
4001 Note that the effect of this pragma is identical to the effect of the
4002 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4004 @node Pragma Title
4005 @unnumberedsec Pragma Title
4006 @findex Title
4007 @noindent
4008 Syntax:
4010 @smallexample @c ada
4011 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4013 TITLING_OPTION ::=
4014   [Title    =>] STRING_LITERAL,
4015 | [Subtitle =>] STRING_LITERAL
4016 @end smallexample
4018 @noindent
4019 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4020 pragma used in DEC Ada 83 implementations to provide a title and/or
4021 subtitle for the program listing.  The program listing generated by GNAT
4022 does not have titles or subtitles.
4024 Unlike other pragmas, the full flexibility of named notation is allowed
4025 for this pragma, i.e.@: the parameters may be given in any order if named
4026 notation is used, and named and positional notation can be mixed
4027 following the normal rules for procedure calls in Ada.
4029 @node Pragma Unchecked_Union
4030 @unnumberedsec Pragma Unchecked_Union
4031 @cindex Unions in C
4032 @findex Unchecked_Union
4033 @noindent
4034 Syntax:
4036 @smallexample @c ada
4037 pragma Unchecked_Union (first_subtype_local_NAME);
4038 @end smallexample
4040 @noindent
4041 This pragma is used to specify a representation of a record type that is
4042 equivalent to a C union. It was introduced as a GNAT implementation defined
4043 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4044 pragma, making it language defined, and GNAT fully implements this extended
4045 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4046 details, consult the Ada 2005 RM, section 8.3.3.
4048 @node Pragma Unimplemented_Unit
4049 @unnumberedsec Pragma Unimplemented_Unit
4050 @findex Unimplemented_Unit
4051 @noindent
4052 Syntax:
4054 @smallexample @c ada
4055 pragma Unimplemented_Unit;
4056 @end smallexample
4058 @noindent
4059 If this pragma occurs in a unit that is processed by the compiler, GNAT
4060 aborts with the message @samp{@var{xxx} not implemented}, where
4061 @var{xxx} is the name of the current compilation unit.  This pragma is
4062 intended to allow the compiler to handle unimplemented library units in
4063 a clean manner.
4065 The abort only happens if code is being generated.  Thus you can use
4066 specs of unimplemented packages in syntax or semantic checking mode.
4068 @node Pragma Universal_Data
4069 @unnumberedsec Pragma Universal_Data
4070 @findex Universal_Data
4071 @noindent
4072 Syntax:
4074 @smallexample @c ada
4075 pragma Universal_Data [(library_unit_Name)];
4076 @end smallexample
4078 @noindent
4079 This pragma is supported only for the AAMP target and is ignored for
4080 other targets. The pragma specifies that all library-level objects
4081 (Counter 0 data) associated with the library unit are to be accessed
4082 and updated using universal addressing (24-bit addresses for AAMP5)
4083 rather than the default of 16-bit Data Environment (DENV) addressing.
4084 Use of this pragma will generally result in less efficient code for
4085 references to global data associated with the library unit, but
4086 allows such data to be located anywhere in memory. This pragma is
4087 a library unit pragma, but can also be used as a configuration pragma
4088 (including use in the @file{gnat.adc} file). The functionality
4089 of this pragma is also available by applying the -univ switch on the
4090 compilations of units where universal addressing of the data is desired.
4092 @node Pragma Unreferenced
4093 @unnumberedsec Pragma Unreferenced
4094 @findex Unreferenced
4095 @cindex Warnings, unreferenced
4096 @noindent
4097 Syntax:
4099 @smallexample @c ada
4100 pragma Unreferenced (local_NAME @{, local_NAME@});
4101 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4102 @end smallexample
4104 @noindent
4105 This pragma signals that the entities whose names are listed are
4106 deliberately not referenced in the current source unit. This
4107 suppresses warnings about the
4108 entities being unreferenced, and in addition a warning will be
4109 generated if one of these entities is in fact referenced in the
4110 same unit as the pragma (or in the corresponding body, or one
4111 of its subunits).
4113 This is particularly useful for clearly signaling that a particular
4114 parameter is not referenced in some particular subprogram implementation
4115 and that this is deliberate. It can also be useful in the case of
4116 objects declared only for their initialization or finalization side
4117 effects.
4119 If @code{local_NAME} identifies more than one matching homonym in the
4120 current scope, then the entity most recently declared is the one to which
4121 the pragma applies. Note that in the case of accept formals, the pragma
4122 Unreferenced may appear immediately after the keyword @code{do} which
4123 allows the indication of whether or not accept formals are referenced
4124 or not to be given individually for each accept statement.
4126 The left hand side of an assignment does not count as a reference for the
4127 purpose of this pragma. Thus it is fine to assign to an entity for which
4128 pragma Unreferenced is given.
4130 Note that if a warning is desired for all calls to a given subprogram,
4131 regardless of whether they occur in the same unit as the subprogram
4132 declaration, then this pragma should not be used (calls from another
4133 unit would not be flagged); pragma Obsolescent can be used instead
4134 for this purpose, see @xref{Pragma Obsolescent}.
4136 The second form of pragma @code{Unreferenced} is used within a context
4137 clause. In this case the arguments must be unit names of units previously
4138 mentioned in @code{with} clauses (similar to the usage of pragma
4139 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4140 units.
4142 @node Pragma Unreserve_All_Interrupts
4143 @unnumberedsec Pragma Unreserve_All_Interrupts
4144 @findex Unreserve_All_Interrupts
4145 @noindent
4146 Syntax:
4148 @smallexample @c ada
4149 pragma Unreserve_All_Interrupts;
4150 @end smallexample
4152 @noindent
4153 Normally certain interrupts are reserved to the implementation.  Any attempt
4154 to attach an interrupt causes Program_Error to be raised, as described in
4155 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4156 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4157 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4158 interrupt execution.
4160 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4161 a program, then all such interrupts are unreserved.  This allows the
4162 program to handle these interrupts, but disables their standard
4163 functions.  For example, if this pragma is used, then pressing
4164 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4165 a program can then handle the @code{SIGINT} interrupt as it chooses.
4167 For a full list of the interrupts handled in a specific implementation,
4168 see the source code for the specification of @code{Ada.Interrupts.Names} in
4169 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4170 list of interrupts recognized for a given target.  The documentation in
4171 this file also specifies what interrupts are affected by the use of
4172 the @code{Unreserve_All_Interrupts} pragma.
4174 For a more general facility for controlling what interrupts can be
4175 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4176 of the @code{Unreserve_All_Interrupts} pragma.
4178 @node Pragma Unsuppress
4179 @unnumberedsec Pragma Unsuppress
4180 @findex Unsuppress
4181 @noindent
4182 Syntax:
4184 @smallexample @c ada
4185 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4186 @end smallexample
4188 @noindent
4189 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4190 there is no corresponding pragma @code{Suppress} in effect, it has no
4191 effect.  The range of the effect is the same as for pragma
4192 @code{Suppress}.  The meaning of the arguments is identical to that used
4193 in pragma @code{Suppress}.
4195 One important application is to ensure that checks are on in cases where
4196 code depends on the checks for its correct functioning, so that the code
4197 will compile correctly even if the compiler switches are set to suppress
4198 checks.
4200 @node Pragma Use_VADS_Size
4201 @unnumberedsec Pragma Use_VADS_Size
4202 @cindex @code{Size}, VADS compatibility
4203 @findex Use_VADS_Size
4204 @noindent
4205 Syntax:
4207 @smallexample @c ada
4208 pragma Use_VADS_Size;
4209 @end smallexample
4211 @noindent
4212 This is a configuration pragma.  In a unit to which it applies, any use
4213 of the 'Size attribute is automatically interpreted as a use of the
4214 'VADS_Size attribute.  Note that this may result in incorrect semantic
4215 processing of valid Ada 95 programs.  This is intended to aid in the
4216 handling of legacy code which depends on the interpretation of Size
4217 as implemented in the VADS compiler.  See description of the VADS_Size
4218 attribute for further details.
4220 @node Pragma Validity_Checks
4221 @unnumberedsec Pragma Validity_Checks
4222 @findex Validity_Checks
4223 @noindent
4224 Syntax:
4226 @smallexample @c ada
4227 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4228 @end smallexample
4230 @noindent
4231 This pragma is used in conjunction with compiler switches to control the
4232 built-in validity checking provided by GNAT@.  The compiler switches, if set
4233 provide an initial setting for the switches, and this pragma may be used
4234 to modify these settings, or the settings may be provided entirely by
4235 the use of the pragma.  This pragma can be used anywhere that a pragma
4236 is legal, including use as a configuration pragma (including use in
4237 the @file{gnat.adc} file).
4239 The form with a string literal specifies which validity options are to be
4240 activated.  The validity checks are first set to include only the default
4241 reference manual settings, and then a string of letters in the string
4242 specifies the exact set of options required.  The form of this string
4243 is exactly as described for the @code{-gnatVx} compiler switch (see the
4244 GNAT users guide for details).  For example the following two methods
4245 can be used to enable validity checking for mode @code{in} and
4246 @code{in out} subprogram parameters:
4248 @itemize @bullet
4249 @item
4250 @smallexample @c ada
4251 pragma Validity_Checks ("im");
4252 @end smallexample
4254 @item
4255 @smallexample
4256 gcc -c -gnatVim @dots{}
4257 @end smallexample
4258 @end itemize
4260 @noindent
4261 The form ALL_CHECKS activates all standard checks (its use is equivalent
4262 to the use of the @code{gnatva} switch.
4264 The forms with @code{Off} and @code{On}
4265 can be used to temporarily disable validity checks
4266 as shown in the following example:
4268 @smallexample @c ada
4269 @iftex
4270 @leftskip=0cm
4271 @end iftex
4272 pragma Validity_Checks ("c"); -- validity checks for copies
4273 pragma Validity_Checks (Off); -- turn off validity checks
4274 A := B;                       -- B will not be validity checked
4275 pragma Validity_Checks (On);  -- turn validity checks back on
4276 A := C;                       -- C will be validity checked
4277 @end smallexample
4279 @node Pragma Volatile
4280 @unnumberedsec Pragma Volatile
4281 @findex Volatile
4282 @noindent
4283 Syntax:
4285 @smallexample @c ada
4286 pragma Volatile (local_NAME);
4287 @end smallexample
4289 @noindent
4290 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4291 implementation is fully conformant with this definition.  The reason it
4292 is mentioned in this section is that a pragma of the same name was supplied
4293 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
4294 of pragma Volatile is upwards compatible with the implementation in
4295 Dec Ada 83.
4297 @node Pragma Warnings
4298 @unnumberedsec Pragma Warnings
4299 @findex Warnings
4300 @noindent
4301 Syntax:
4303 @smallexample @c ada
4304 pragma Warnings (On | Off);
4305 pragma Warnings (On | Off, local_NAME);
4306 pragma Warnings (static_string_EXPRESSION);
4307 pragma Warnings (On | Off, static_string_EXPRESSION);
4308 @end smallexample
4310 @noindent
4311 Normally warnings are enabled, with the output being controlled by
4312 the command line switch.  Warnings (@code{Off}) turns off generation of
4313 warnings until a Warnings (@code{On}) is encountered or the end of the
4314 current unit.  If generation of warnings is turned off using this
4315 pragma, then no warning messages are output, regardless of the
4316 setting of the command line switches.
4318 The form with a single argument may be used as a configuration pragma.
4320 If the @var{local_NAME} parameter is present, warnings are suppressed for
4321 the specified entity.  This suppression is effective from the point where
4322 it occurs till the end of the extended scope of the variable (similar to
4323 the scope of @code{Suppress}).
4325 The form with a single static_string_EXPRESSION argument provides more precise
4326 control over which warnings are active. The string is a list of letters
4327 specifying which warnings are to be activated and which deactivated. The
4328 code for these letters is the same as the string used in the command
4329 line switch controlling warnings. The following is a brief summary. For
4330 full details see the GNAT Users Guide:
4332 @smallexample
4333 a   turn on all optional warnings (except d,h,l)
4334 A   turn off all optional warnings
4335 b   turn on warnings for bad fixed value (not multiple of small)
4336 B   turn off warnings for bad fixed value (not multiple of small)
4337 c   turn on warnings for constant conditional
4338 C   turn off warnings for constant conditional
4339 d   turn on warnings for implicit dereference
4340 D   turn off warnings for implicit dereference
4341 e   treat all warnings as errors
4342 f   turn on warnings for unreferenced formal
4343 F   turn off warnings for unreferenced formal
4344 g   turn on warnings for unrecognized pragma
4345 G   turn off warnings for unrecognized pragma
4346 h   turn on warnings for hiding variable
4347 H   turn off warnings for hiding variable
4348 i   turn on warnings for implementation unit
4349 I   turn off warnings for implementation unit
4350 j   turn on warnings for obsolescent (annex J) feature
4351 J   turn off warnings for obsolescent (annex J) feature
4352 k   turn on warnings on constant variable
4353 K   turn off warnings on constant variable
4354 l   turn on warnings for missing elaboration pragma
4355 L   turn off warnings for missing elaboration pragma
4356 m   turn on warnings for variable assigned but not read
4357 M   turn off warnings for variable assigned but not read
4358 n   normal warning mode (cancels -gnatws/-gnatwe)
4359 o   turn on warnings for address clause overlay
4360 O   turn off warnings for address clause overlay
4361 p   turn on warnings for ineffective pragma Inline
4362 P   turn off warnings for ineffective pragma Inline
4363 r   turn on warnings for redundant construct
4364 R   turn off warnings for redundant construct
4365 s   suppress all warnings
4366 u   turn on warnings for unused entity
4367 U   turn off warnings for unused entity
4368 v   turn on warnings for unassigned variable
4369 V   turn off warnings for unassigned variable
4370 w   turn on warnings for wrong low bound assumption
4371 W   turn off warnings for wrong low bound assumption
4372 x   turn on warnings for export/import
4373 X   turn off warnings for export/import
4374 y   turn on warnings for Ada 2005 incompatibility
4375 Y   turn off warnings for Ada 2005 incompatibility
4376 z   turn on size/align warnings for unchecked conversion
4377 Z   turn off size/align warnings for unchecked conversion
4378 @end smallexample
4380 @noindent
4381 The specified warnings will be in effect until the end of the program
4382 or another pragma Warnings is encountered. The effect of the pragma is
4383 cumulative. Initially the set of warnings is the standard default set
4384 as possibly modified by compiler switches. Then each pragma Warning
4385 modifies this set of warnings as specified. This form of the pragma may
4386 also be used as a configuration pragma.
4388 The fourth form, with an On|Off parameter and a string, is used to
4389 control individual messages, based on their text. The string argument
4390 is a pattern that is used to match against the text of individual
4391 warning messages (not including the initial "warnings: " tag).
4393 The pattern may start with an asterisk, which matches otherwise unmatched
4394 characters at the start of the message, and it may also end with an asterisk
4395 which matches otherwise unmatched characters at the end of the message. For
4396 example, the string "*alignment*" could be used to match any warnings about
4397 alignment problems. Within the string, the sequence "*" can be used to match
4398 any sequence of characters enclosed in quotation marks. No other regular
4399 expression notations are permitted. All characters other than asterisk in
4400 these three specific cases are treated as literal characters in the match.
4402 There are two ways to use this pragma. The OFF form can be used as a
4403 configuration pragma. The effect is to suppress all warnings (if any)
4404 that match the pattern string throughout the compilation.
4406 The second usage is to suppress a warning locally, and in this case, two
4407 pragmas must appear in sequence:
4409 @smallexample @c ada
4410 pragma Warnings (Off, Pattern);
4411 .. code where given warning is to be suppressed
4412 pragma Warnings (On, Pattern);
4413 @end smallexample
4415 @noindent
4416 In this usage, the pattern string must match in the Off and On pragmas,
4417 and at least one matching warning must be suppressed.
4419 @node Pragma Weak_External
4420 @unnumberedsec Pragma Weak_External
4421 @findex Weak_External
4422 @noindent
4423 Syntax:
4425 @smallexample @c ada
4426 pragma Weak_External ([Entity =>] local_NAME);
4427 @end smallexample
4429 @noindent
4430 @var{local_NAME} must refer to an object that is declared at the library
4431 level. This pragma specifies that the given entity should be marked as a
4432 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4433 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4434 of a regular symbol, that is to say a symbol that does not have to be
4435 resolved by the linker if used in conjunction with a pragma Import.
4437 When a weak symbol is not resolved by the linker, its address is set to
4438 zero. This is useful in writing interfaces to external modules that may
4439 or may not be linked in the final executable, for example depending on
4440 configuration settings.
4442 If a program references at run time an entity to which this pragma has been
4443 applied, and the corresponding symbol was not resolved at link time, then
4444 the execution of the program is erroneous. It is not erroneous to take the
4445 Address of such an entity, for example to guard potential references,
4446 as shown in the example below.
4448 Some file formats do not support weak symbols so not all target machines
4449 support this pragma.
4451 @smallexample @c ada
4452 --  Example of the use of pragma Weak_External
4454 package External_Module is
4455   key : Integer;
4456   pragma Import (C, key);
4457   pragma Weak_External (key);
4458   function Present return boolean;
4459 end External_Module;
4461 with System; use System;
4462 package body External_Module is
4463   function Present return boolean is
4464   begin
4465     return key'Address /= System.Null_Address;
4466   end Present;
4467 end External_Module;
4468 @end smallexample
4470 @node Pragma Wide_Character_Encoding
4471 @unnumberedsec Pragma Wide_Character_Encoding
4472 @findex Wide_Character_Encoding
4473 @noindent
4474 Syntax:
4476 @smallexample @c ada
4477 pragma Wide_Character_Encoding (IDENTIFIER | CHRARACTER_LITERAL);
4478 @end smallexample
4480 @noindent
4481 This pragma specifies the wide character encoding to be used in program
4482 source text appearing subsequently. It is a configuration pragma, but may
4483 also be used at any point that a pragma is allowed, and it is permissible
4484 to have more than one such pragma in a file, allowing multiple encodings
4485 to appear within the same file.
4487 The argument can be an identifier or a character literal. In the identifier
4488 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4489 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4490 case it is correspondingly one of the characters h,u,s,e,8,b.
4492 Note that when the pragma is used within a file, it affects only the
4493 encoding within that file, and does not affect withed units, specs,
4494 or subunits.
4496 @node Implementation Defined Attributes
4497 @chapter Implementation Defined Attributes
4498 Ada 95 defines (throughout the Ada 95 reference manual,
4499 summarized in annex K),
4500 a set of attributes that provide useful additional functionality in all
4501 areas of the language.  These language defined attributes are implemented
4502 in GNAT and work as described in the Ada 95 Reference Manual.
4504 In addition, Ada 95 allows implementations to define additional
4505 attributes whose meaning is defined by the implementation.  GNAT provides
4506 a number of these implementation-dependent attributes which can be used
4507 to extend and enhance the functionality of the compiler.  This section of
4508 the GNAT reference manual describes these additional attributes.
4510 Note that any program using these attributes may not be portable to
4511 other compilers (although GNAT implements this set of attributes on all
4512 platforms).  Therefore if portability to other compilers is an important
4513 consideration, you should minimize the use of these attributes.
4515 @menu
4516 * Abort_Signal::
4517 * Address_Size::
4518 * Asm_Input::
4519 * Asm_Output::
4520 * AST_Entry::
4521 * Bit::
4522 * Bit_Position::
4523 * Code_Address::
4524 * Default_Bit_Order::
4525 * Elaborated::
4526 * Elab_Body::
4527 * Elab_Spec::
4528 * Emax::
4529 * Enum_Rep::
4530 * Epsilon::
4531 * Fixed_Value::
4532 * Has_Access_Values::
4533 * Has_Discriminants::
4534 * Img::
4535 * Integer_Value::
4536 * Large::
4537 * Machine_Size::
4538 * Mantissa::
4539 * Max_Interrupt_Priority::
4540 * Max_Priority::
4541 * Maximum_Alignment::
4542 * Mechanism_Code::
4543 * Null_Parameter::
4544 * Object_Size::
4545 * Passed_By_Reference::
4546 * Range_Length::
4547 * Safe_Emax::
4548 * Safe_Large::
4549 * Small::
4550 * Storage_Unit::
4551 * Stub_Type::
4552 * Target_Name::
4553 * Tick::
4554 * To_Address::
4555 * Type_Class::
4556 * UET_Address::
4557 * Unconstrained_Array::
4558 * Universal_Literal_String::
4559 * Unrestricted_Access::
4560 * VADS_Size::
4561 * Value_Size::
4562 * Wchar_T_Size::
4563 * Word_Size::
4564 @end menu
4566 @node Abort_Signal
4567 @unnumberedsec Abort_Signal
4568 @findex Abort_Signal
4569 @noindent
4570 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4571 prefix) provides the entity for the special exception used to signal
4572 task abort or asynchronous transfer of control.  Normally this attribute
4573 should only be used in the tasking runtime (it is highly peculiar, and
4574 completely outside the normal semantics of Ada, for a user program to
4575 intercept the abort exception).
4577 @node Address_Size
4578 @unnumberedsec Address_Size
4579 @cindex Size of @code{Address}
4580 @findex Address_Size
4581 @noindent
4582 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4583 prefix) is a static constant giving the number of bits in an
4584 @code{Address}. It is the same value as System.Address'Size,
4585 but has the advantage of being static, while a direct
4586 reference to System.Address'Size is non-static because Address
4587 is a private type.
4589 @node Asm_Input
4590 @unnumberedsec Asm_Input
4591 @findex Asm_Input
4592 @noindent
4593 The @code{Asm_Input} attribute denotes a function that takes two
4594 parameters.  The first is a string, the second is an expression of the
4595 type designated by the prefix.  The first (string) argument is required
4596 to be a static expression, and is the constraint for the parameter,
4597 (e.g.@: what kind of register is required).  The second argument is the
4598 value to be used as the input argument.  The possible values for the
4599 constant are the same as those used in the RTL, and are dependent on
4600 the configuration file used to built the GCC back end.
4601 @ref{Machine Code Insertions}
4603 @node Asm_Output
4604 @unnumberedsec Asm_Output
4605 @findex Asm_Output
4606 @noindent
4607 The @code{Asm_Output} attribute denotes a function that takes two
4608 parameters.  The first is a string, the second is the name of a variable
4609 of the type designated by the attribute prefix.  The first (string)
4610 argument is required to be a static expression and designates the
4611 constraint for the parameter (e.g.@: what kind of register is
4612 required).  The second argument is the variable to be updated with the
4613 result.  The possible values for constraint are the same as those used in
4614 the RTL, and are dependent on the configuration file used to build the
4615 GCC back end.  If there are no output operands, then this argument may
4616 either be omitted, or explicitly given as @code{No_Output_Operands}.
4617 @ref{Machine Code Insertions}
4619 @node AST_Entry
4620 @unnumberedsec AST_Entry
4621 @cindex OpenVMS
4622 @findex AST_Entry
4623 @noindent
4624 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4625 the name of an entry, it yields a value of the predefined type AST_Handler
4626 (declared in the predefined package System, as extended by the use of
4627 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4628 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4629 Language Reference Manual}, section 9.12a.
4631 @node Bit
4632 @unnumberedsec Bit
4633 @findex Bit
4634 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4635 offset within the storage unit (byte) that contains the first bit of
4636 storage allocated for the object.  The value of this attribute is of the
4637 type @code{Universal_Integer}, and is always a non-negative number not
4638 exceeding the value of @code{System.Storage_Unit}.
4640 For an object that is a variable or a constant allocated in a register,
4641 the value is zero.  (The use of this attribute does not force the
4642 allocation of a variable to memory).
4644 For an object that is a formal parameter, this attribute applies
4645 to either the matching actual parameter or to a copy of the
4646 matching actual parameter.
4648 For an access object the value is zero.  Note that
4649 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4650 designated object.  Similarly for a record component
4651 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4652 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4653 are subject to index checks.
4655 This attribute is designed to be compatible with the DEC Ada 83 definition
4656 and implementation of the @code{Bit} attribute.
4658 @node Bit_Position
4659 @unnumberedsec Bit_Position
4660 @findex Bit_Position
4661 @noindent
4662 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4663 of the fields of the record type, yields the bit
4664 offset within the record contains the first bit of
4665 storage allocated for the object.  The value of this attribute is of the
4666 type @code{Universal_Integer}.  The value depends only on the field
4667 @var{C} and is independent of the alignment of
4668 the containing record @var{R}.
4670 @node Code_Address
4671 @unnumberedsec Code_Address
4672 @findex Code_Address
4673 @cindex Subprogram address
4674 @cindex Address of subprogram code
4675 @noindent
4676 The @code{'Address}
4677 attribute may be applied to subprograms in Ada 95, but the
4678 intended effect from the Ada 95 reference manual seems to be to provide
4679 an address value which can be used to call the subprogram by means of
4680 an address clause as in the following example:
4682 @smallexample @c ada
4683 procedure K is @dots{}
4685 procedure L;
4686 for L'Address use K'Address;
4687 pragma Import (Ada, L);
4688 @end smallexample
4690 @noindent
4691 A call to @code{L} is then expected to result in a call to @code{K}@.
4692 In Ada 83, where there were no access-to-subprogram values, this was
4693 a common work around for getting the effect of an indirect call.
4694 GNAT implements the above use of @code{Address} and the technique
4695 illustrated by the example code works correctly.
4697 However, for some purposes, it is useful to have the address of the start
4698 of the generated code for the subprogram.  On some architectures, this is
4699 not necessarily the same as the @code{Address} value described above.
4700 For example, the @code{Address} value may reference a subprogram
4701 descriptor rather than the subprogram itself.
4703 The @code{'Code_Address} attribute, which can only be applied to
4704 subprogram entities, always returns the address of the start of the
4705 generated code of the specified subprogram, which may or may not be
4706 the same value as is returned by the corresponding @code{'Address}
4707 attribute.
4709 @node Default_Bit_Order
4710 @unnumberedsec Default_Bit_Order
4711 @cindex Big endian
4712 @cindex Little endian
4713 @findex Default_Bit_Order
4714 @noindent
4715 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4716 permissible prefix), provides the value @code{System.Default_Bit_Order}
4717 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4718 @code{Low_Order_First}).  This is used to construct the definition of
4719 @code{Default_Bit_Order} in package @code{System}.
4721 @node Elaborated
4722 @unnumberedsec Elaborated
4723 @findex Elaborated
4724 @noindent
4725 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4726 value is a Boolean which indicates whether or not the given unit has been
4727 elaborated.  This attribute is primarily intended for internal use by the
4728 generated code for dynamic elaboration checking, but it can also be used
4729 in user programs.  The value will always be True once elaboration of all
4730 units has been completed.  An exception is for units which need no
4731 elaboration, the value is always False for such units.
4733 @node Elab_Body
4734 @unnumberedsec Elab_Body
4735 @findex Elab_Body
4736 @noindent
4737 This attribute can only be applied to a program unit name.  It returns
4738 the entity for the corresponding elaboration procedure for elaborating
4739 the body of the referenced unit.  This is used in the main generated
4740 elaboration procedure by the binder and is not normally used in any
4741 other context.  However, there may be specialized situations in which it
4742 is useful to be able to call this elaboration procedure from Ada code,
4743 e.g.@: if it is necessary to do selective re-elaboration to fix some
4744 error.
4746 @node Elab_Spec
4747 @unnumberedsec Elab_Spec
4748 @findex Elab_Spec
4749 @noindent
4750 This attribute can only be applied to a program unit name.  It returns
4751 the entity for the corresponding elaboration procedure for elaborating
4752 the specification of the referenced unit.  This is used in the main
4753 generated elaboration procedure by the binder and is not normally used
4754 in any other context.  However, there may be specialized situations in
4755 which it is useful to be able to call this elaboration procedure from
4756 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4757 some error.
4759 @node Emax
4760 @unnumberedsec Emax
4761 @cindex Ada 83 attributes
4762 @findex Emax
4763 @noindent
4764 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4765 the Ada 83 reference manual for an exact description of the semantics of
4766 this attribute.
4768 @node Enum_Rep
4769 @unnumberedsec Enum_Rep
4770 @cindex Representation of enums
4771 @findex Enum_Rep
4772 @noindent
4773 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4774 function with the following spec:
4776 @smallexample @c ada
4777 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4778   return @i{Universal_Integer};
4779 @end smallexample
4781 @noindent
4782 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4783 enumeration type or to a non-overloaded enumeration
4784 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4785 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4786 enumeration literal or object.
4788 The function returns the representation value for the given enumeration
4789 value.  This will be equal to value of the @code{Pos} attribute in the
4790 absence of an enumeration representation clause.  This is a static
4791 attribute (i.e.@: the result is static if the argument is static).
4793 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4794 in which case it simply returns the integer value.  The reason for this
4795 is to allow it to be used for @code{(<>)} discrete formal arguments in
4796 a generic unit that can be instantiated with either enumeration types
4797 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4798 type whose upper bound exceeds the upper bound of the largest signed
4799 integer type, and the argument is a variable, so that the universal
4800 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4801 may raise @code{Constraint_Error}.
4803 @node Epsilon
4804 @unnumberedsec Epsilon
4805 @cindex Ada 83 attributes
4806 @findex Epsilon
4807 @noindent
4808 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4809 the Ada 83 reference manual for an exact description of the semantics of
4810 this attribute.
4812 @node Fixed_Value
4813 @unnumberedsec Fixed_Value
4814 @findex Fixed_Value
4815 @noindent
4816 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4817 function with the following specification:
4819 @smallexample @c ada
4820 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4821   return @var{S};
4822 @end smallexample
4824 @noindent
4825 The value returned is the fixed-point value @var{V} such that
4827 @smallexample @c ada
4828 @var{V} = Arg * @var{S}'Small
4829 @end smallexample
4831 @noindent
4832 The effect is thus similar to first converting the argument to the
4833 integer type used to represent @var{S}, and then doing an unchecked
4834 conversion to the fixed-point type.  The difference is
4835 that there are full range checks, to ensure that the result is in range.
4836 This attribute is primarily intended for use in implementation of the
4837 input-output functions for fixed-point values.
4839 @node Has_Access_Values
4840 @unnumberedsec Has_Access_Values
4841 @cindex Access values, testing for
4842 @findex Has_Access_Values
4843 @noindent
4844 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4845 is a Boolean value which is True if the is an access type, or is a composite
4846 type with a component (at any nesting depth) that is an access type, and is
4847 False otherwise.
4848 The intended use of this attribute is in conjunction with generic
4849 definitions.  If the attribute is applied to a generic private type, it
4850 indicates whether or not the corresponding actual type has access values.
4852 @node Has_Discriminants
4853 @unnumberedsec Has_Discriminants
4854 @cindex Discriminants, testing for
4855 @findex Has_Discriminants
4856 @noindent
4857 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4858 is a Boolean value which is True if the type has discriminants, and False
4859 otherwise.  The intended use of this attribute is in conjunction with generic
4860 definitions.  If the attribute is applied to a generic private type, it
4861 indicates whether or not the corresponding actual type has discriminants.
4863 @node Img
4864 @unnumberedsec Img
4865 @findex Img
4866 @noindent
4867 The @code{Img} attribute differs from @code{Image} in that it may be
4868 applied to objects as well as types, in which case it gives the
4869 @code{Image} for the subtype of the object.  This is convenient for
4870 debugging:
4872 @smallexample @c ada
4873 Put_Line ("X = " & X'Img);
4874 @end smallexample
4876 @noindent
4877 has the same meaning as the more verbose:
4879 @smallexample @c ada
4880 Put_Line ("X = " & @var{T}'Image (X));
4881 @end smallexample
4883 @noindent
4884 where @var{T} is the (sub)type of the object @code{X}.
4886 @node Integer_Value
4887 @unnumberedsec Integer_Value
4888 @findex Integer_Value
4889 @noindent
4890 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4891 function with the following spec:
4893 @smallexample @c ada
4894 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4895   return @var{S};
4896 @end smallexample
4898 @noindent
4899 The value returned is the integer value @var{V}, such that
4901 @smallexample @c ada
4902 Arg = @var{V} * @var{T}'Small
4903 @end smallexample
4905 @noindent
4906 where @var{T} is the type of @code{Arg}.
4907 The effect is thus similar to first doing an unchecked conversion from
4908 the fixed-point type to its corresponding implementation type, and then
4909 converting the result to the target integer type.  The difference is
4910 that there are full range checks, to ensure that the result is in range.
4911 This attribute is primarily intended for use in implementation of the
4912 standard input-output functions for fixed-point values.
4914 @node Large
4915 @unnumberedsec Large
4916 @cindex Ada 83 attributes
4917 @findex Large
4918 @noindent
4919 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4920 the Ada 83 reference manual for an exact description of the semantics of
4921 this attribute.
4923 @node Machine_Size
4924 @unnumberedsec Machine_Size
4925 @findex Machine_Size
4926 @noindent
4927 This attribute is identical to the @code{Object_Size} attribute.  It is
4928 provided for compatibility with the DEC Ada 83 attribute of this name.
4930 @node Mantissa
4931 @unnumberedsec Mantissa
4932 @cindex Ada 83 attributes
4933 @findex Mantissa
4934 @noindent
4935 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4936 the Ada 83 reference manual for an exact description of the semantics of
4937 this attribute.
4939 @node Max_Interrupt_Priority
4940 @unnumberedsec Max_Interrupt_Priority
4941 @cindex Interrupt priority, maximum
4942 @findex Max_Interrupt_Priority
4943 @noindent
4944 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4945 permissible prefix), provides the same value as
4946 @code{System.Max_Interrupt_Priority}.
4948 @node Max_Priority
4949 @unnumberedsec Max_Priority
4950 @cindex Priority, maximum
4951 @findex Max_Priority
4952 @noindent
4953 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4954 prefix) provides the same value as @code{System.Max_Priority}.
4956 @node Maximum_Alignment
4957 @unnumberedsec Maximum_Alignment
4958 @cindex Alignment, maximum
4959 @findex Maximum_Alignment
4960 @noindent
4961 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4962 permissible prefix) provides the maximum useful alignment value for the
4963 target.  This is a static value that can be used to specify the alignment
4964 for an object, guaranteeing that it is properly aligned in all
4965 cases.
4967 @node Mechanism_Code
4968 @unnumberedsec Mechanism_Code
4969 @cindex Return values, passing mechanism
4970 @cindex Parameters, passing mechanism
4971 @findex Mechanism_Code
4972 @noindent
4973 @code{@var{function}'Mechanism_Code} yields an integer code for the
4974 mechanism used for the result of function, and
4975 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4976 used for formal parameter number @var{n} (a static integer value with 1
4977 meaning the first parameter) of @var{subprogram}.  The code returned is:
4979 @table @asis
4980 @item 1
4981 by copy (value)
4982 @item 2
4983 by reference
4984 @item 3
4985 by descriptor (default descriptor class)
4986 @item 4
4987 by descriptor (UBS: unaligned bit string)
4988 @item 5
4989 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4990 @item 6
4991 by descriptor (UBA: unaligned bit array)
4992 @item 7
4993 by descriptor (S: string, also scalar access type parameter)
4994 @item 8
4995 by descriptor (SB: string with arbitrary bounds)
4996 @item 9
4997 by descriptor (A: contiguous array)
4998 @item 10
4999 by descriptor (NCA: non-contiguous array)
5000 @end table
5002 @noindent
5003 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5004 @cindex OpenVMS
5006 @node Null_Parameter
5007 @unnumberedsec Null_Parameter
5008 @cindex Zero address, passing
5009 @findex Null_Parameter
5010 @noindent
5011 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5012 type or subtype @var{T} allocated at machine address zero.  The attribute
5013 is allowed only as the default expression of a formal parameter, or as
5014 an actual expression of a subprogram call.  In either case, the
5015 subprogram must be imported.
5017 The identity of the object is represented by the address zero in the
5018 argument list, independent of the passing mechanism (explicit or
5019 default).
5021 This capability is needed to specify that a zero address should be
5022 passed for a record or other composite object passed by reference.
5023 There is no way of indicating this without the @code{Null_Parameter}
5024 attribute.
5026 @node Object_Size
5027 @unnumberedsec Object_Size
5028 @cindex Size, used for objects
5029 @findex Object_Size
5030 @noindent
5031 The size of an object is not necessarily the same as the size of the type
5032 of an object.  This is because by default object sizes are increased to be
5033 a multiple of the alignment of the object.  For example,
5034 @code{Natural'Size} is
5035 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5036 Similarly, a record containing an integer and a character:
5038 @smallexample @c ada
5039 type Rec is record
5040    I : Integer;
5041    C : Character;
5042 end record;
5043 @end smallexample
5045 @noindent
5046 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5047 alignment will be 4, because of the
5048 integer field, and so the default size of record objects for this type
5049 will be 64 (8 bytes).
5051 The @code{@var{type}'Object_Size} attribute
5052 has been added to GNAT to allow the
5053 default object size of a type to be easily determined.  For example,
5054 @code{Natural'Object_Size} is 32, and
5055 @code{Rec'Object_Size} (for the record type in the above example) will be
5056 64.  Note also that, unlike the situation with the
5057 @code{Size} attribute as defined in the Ada RM, the
5058 @code{Object_Size} attribute can be specified individually
5059 for different subtypes.  For example:
5061 @smallexample @c ada
5062 type R is new Integer;
5063 subtype R1 is R range 1 .. 10;
5064 subtype R2 is R range 1 .. 10;
5065 for R2'Object_Size use 8;
5066 @end smallexample
5068 @noindent
5069 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5070 32 since the default object size for a subtype is the same as the object size
5071 for the parent subtype.  This means that objects of type @code{R}
5072 or @code{R1} will
5073 by default be 32 bits (four bytes).  But objects of type
5074 @code{R2} will be only
5075 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5077 @node Passed_By_Reference
5078 @unnumberedsec Passed_By_Reference
5079 @cindex Parameters, when passed by reference
5080 @findex Passed_By_Reference
5081 @noindent
5082 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5083 a value of type @code{Boolean} value that is @code{True} if the type is
5084 normally passed by reference and @code{False} if the type is normally
5085 passed by copy in calls.  For scalar types, the result is always @code{False}
5086 and is static.  For non-scalar types, the result is non-static.
5088 @node Range_Length
5089 @unnumberedsec Range_Length
5090 @findex Range_Length
5091 @noindent
5092 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5093 the number of values represented by the subtype (zero for a null
5094 range).  The result is static for static subtypes.  @code{Range_Length}
5095 applied to the index subtype of a one dimensional array always gives the
5096 same result as @code{Range} applied to the array itself.
5098 @node Safe_Emax
5099 @unnumberedsec Safe_Emax
5100 @cindex Ada 83 attributes
5101 @findex Safe_Emax
5102 @noindent
5103 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5104 the Ada 83 reference manual for an exact description of the semantics of
5105 this attribute.
5107 @node Safe_Large
5108 @unnumberedsec Safe_Large
5109 @cindex Ada 83 attributes
5110 @findex Safe_Large
5111 @noindent
5112 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5113 the Ada 83 reference manual for an exact description of the semantics of
5114 this attribute.
5116 @node Small
5117 @unnumberedsec Small
5118 @cindex Ada 83 attributes
5119 @findex Small
5120 @noindent
5121 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
5122 GNAT also allows this attribute to be applied to floating-point types
5123 for compatibility with Ada 83.  See
5124 the Ada 83 reference manual for an exact description of the semantics of
5125 this attribute when applied to floating-point types.
5127 @node Storage_Unit
5128 @unnumberedsec Storage_Unit
5129 @findex Storage_Unit
5130 @noindent
5131 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5132 prefix) provides the same value as @code{System.Storage_Unit}.
5134 @node Stub_Type
5135 @unnumberedsec Stub_Type
5136 @findex Stub_Type
5137 @noindent
5138 The GNAT implementation of remote access-to-classwide types is
5139 organized as described in AARM section E.4 (20.t): a value of an RACW type
5140 (designating a remote object) is represented as a normal access
5141 value, pointing to a "stub" object which in turn contains the
5142 necessary information to contact the designated remote object. A
5143 call on any dispatching operation of such a stub object does the
5144 remote call, if necessary, using the information in the stub object
5145 to locate the target partition, etc.
5147 For a prefix @code{T} that denotes a remote access-to-classwide type,
5148 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5150 By construction, the layout of @code{T'Stub_Type} is identical to that of
5151 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5152 unit @code{System.Partition_Interface}. Use of this attribute will create
5153 an implicit dependency on this unit.
5155 @node Target_Name
5156 @unnumberedsec Target_Name
5157 @findex Target_Name
5158 @noindent
5159 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5160 prefix) provides a static string value that identifies the target
5161 for the current compilation. For GCC implementations, this is the
5162 standard gcc target name without the terminating slash (for
5163 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5165 @node Tick
5166 @unnumberedsec Tick
5167 @findex Tick
5168 @noindent
5169 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5170 provides the same value as @code{System.Tick},
5172 @node To_Address
5173 @unnumberedsec To_Address
5174 @findex To_Address
5175 @noindent
5176 The @code{System'To_Address}
5177 (@code{System} is the only permissible prefix)
5178 denotes a function identical to
5179 @code{System.Storage_Elements.To_Address} except that
5180 it is a static attribute.  This means that if its argument is
5181 a static expression, then the result of the attribute is a
5182 static expression.  The result is that such an expression can be
5183 used in contexts (e.g.@: preelaborable packages) which require a
5184 static expression and where the function call could not be used
5185 (since the function call is always non-static, even if its
5186 argument is static).
5188 @node Type_Class
5189 @unnumberedsec Type_Class
5190 @findex Type_Class
5191 @noindent
5192 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5193 the value of the type class for the full type of @var{type}.  If
5194 @var{type} is a generic formal type, the value is the value for the
5195 corresponding actual subtype.  The value of this attribute is of type
5196 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5198 @smallexample @c ada
5199   type Type_Class is
5200     (Type_Class_Enumeration,
5201      Type_Class_Integer,
5202      Type_Class_Fixed_Point,
5203      Type_Class_Floating_Point,
5204      Type_Class_Array,
5205      Type_Class_Record,
5206      Type_Class_Access,
5207      Type_Class_Task,
5208      Type_Class_Address);
5209 @end smallexample
5211 @noindent
5212 Protected types yield the value @code{Type_Class_Task}, which thus
5213 applies to all concurrent types.  This attribute is designed to
5214 be compatible with the DEC Ada 83 attribute of the same name.
5216 @node UET_Address
5217 @unnumberedsec UET_Address
5218 @findex UET_Address
5219 @noindent
5220 The @code{UET_Address} attribute can only be used for a prefix which
5221 denotes a library package.  It yields the address of the unit exception
5222 table when zero cost exception handling is used.  This attribute is
5223 intended only for use within the GNAT implementation.  See the unit
5224 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5225 for details on how this attribute is used in the implementation.
5227 @node Unconstrained_Array
5228 @unnumberedsec Unconstrained_Array
5229 @findex Unconstrained_Array
5230 @noindent
5231 The @code{Unconstrained_Array} attribute can be used with a prefix that
5232 denotes any type or subtype. It is a static attribute that yields
5233 @code{True} if the prefix designates an unconstrained array,
5234 and @code{False} otherwise. In a generic instance, the result is
5235 still static, and yields the result of applying this test to the
5236 generic actual.
5238 @node Universal_Literal_String
5239 @unnumberedsec Universal_Literal_String
5240 @cindex Named numbers, representation of
5241 @findex Universal_Literal_String
5242 @noindent
5243 The prefix of @code{Universal_Literal_String} must be a named
5244 number.  The static result is the string consisting of the characters of
5245 the number as defined in the original source.  This allows the user
5246 program to access the actual text of named numbers without intermediate
5247 conversions and without the need to enclose the strings in quotes (which
5248 would preclude their use as numbers).  This is used internally for the
5249 construction of values of the floating-point attributes from the file
5250 @file{ttypef.ads}, but may also be used by user programs.
5252 For example, the following program prints the first 50 digits of pi:
5254 @smallexample @c ada
5255 with Text_IO; use Text_IO;
5256 with Ada.Numerics;
5257 procedure Pi is
5258 begin
5259    Put (Ada.Numerics.Pi'Universal_Literal_String);
5260 end;
5261 @end smallexample
5263 @node Unrestricted_Access
5264 @unnumberedsec Unrestricted_Access
5265 @cindex @code{Access}, unrestricted
5266 @findex Unrestricted_Access
5267 @noindent
5268 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5269 except that all accessibility and aliased view checks are omitted.  This
5270 is a user-beware attribute.  It is similar to
5271 @code{Address}, for which it is a desirable replacement where the value
5272 desired is an access type.  In other words, its effect is identical to
5273 first applying the @code{Address} attribute and then doing an unchecked
5274 conversion to a desired access type.  In GNAT, but not necessarily in
5275 other implementations, the use of static chains for inner level
5276 subprograms means that @code{Unrestricted_Access} applied to a
5277 subprogram yields a value that can be called as long as the subprogram
5278 is in scope (normal Ada 95 accessibility rules restrict this usage).
5280 It is possible to use @code{Unrestricted_Access} for any type, but care
5281 must be exercised if it is used to create pointers to unconstrained
5282 objects. In this case, the resulting pointer has the same scope as the
5283 context of the attribute, and may not be returned to some enclosing
5284 scope. For instance, a function cannot use @code{Unrestricted_Access}
5285 to create a unconstrained pointer and then return that value to the
5286 caller.
5288 @node VADS_Size
5289 @unnumberedsec VADS_Size
5290 @cindex @code{Size}, VADS compatibility
5291 @findex VADS_Size
5292 @noindent
5293 The @code{'VADS_Size} attribute is intended to make it easier to port
5294 legacy code which relies on the semantics of @code{'Size} as implemented
5295 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5296 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5297 to a predefined or other primitive type with no Size clause yields the
5298 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5299 typical machines).  In addition @code{'VADS_Size} applied to an object
5300 gives the result that would be obtained by applying the attribute to
5301 the corresponding type.
5303 @node Value_Size
5304 @unnumberedsec Value_Size
5305 @cindex @code{Size}, setting for not-first subtype
5306 @findex Value_Size
5307 @code{@var{type}'Value_Size} is the number of bits required to represent
5308 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5309 but, unlike @code{Size}, may be set for non-first subtypes.
5311 @node Wchar_T_Size
5312 @unnumberedsec Wchar_T_Size
5313 @findex Wchar_T_Size
5314 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5315 prefix) provides the size in bits of the C @code{wchar_t} type
5316 primarily for constructing the definition of this type in
5317 package @code{Interfaces.C}.
5319 @node Word_Size
5320 @unnumberedsec Word_Size
5321 @findex Word_Size
5322 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5323 prefix) provides the value @code{System.Word_Size}.
5325 @c ------------------------
5326 @node Implementation Advice
5327 @chapter Implementation Advice
5328 @noindent
5329 The main text of the Ada 95 Reference Manual describes the required
5330 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
5331 these requirements.
5333 In addition, there are sections throughout the Ada 95
5334 reference manual headed
5335 by the phrase ``implementation advice''.  These sections are not normative,
5336 i.e.@: they do not specify requirements that all compilers must
5337 follow.  Rather they provide advice on generally desirable behavior.  You
5338 may wonder why they are not requirements.  The most typical answer is
5339 that they describe behavior that seems generally desirable, but cannot
5340 be provided on all systems, or which may be undesirable on some systems.
5342 As far as practical, GNAT follows the implementation advice sections in
5343 the Ada 95 Reference Manual.  This chapter contains a table giving the
5344 reference manual section number, paragraph number and several keywords
5345 for each advice.  Each entry consists of the text of the advice followed
5346 by the GNAT interpretation of this advice.  Most often, this simply says
5347 ``followed'', which means that GNAT follows the advice.  However, in a
5348 number of cases, GNAT deliberately deviates from this advice, in which
5349 case the text describes what GNAT does and why.
5351 @cindex Error detection
5352 @unnumberedsec 1.1.3(20): Error Detection
5353 @sp 1
5354 @cartouche
5355 If an implementation detects the use of an unsupported Specialized Needs
5356 Annex feature at run time, it should raise @code{Program_Error} if
5357 feasible.
5358 @end cartouche
5359 Not relevant.  All specialized needs annex features are either supported,
5360 or diagnosed at compile time.
5362 @cindex Child Units
5363 @unnumberedsec 1.1.3(31): Child Units
5364 @sp 1
5365 @cartouche
5366 If an implementation wishes to provide implementation-defined
5367 extensions to the functionality of a language-defined library unit, it
5368 should normally do so by adding children to the library unit.
5369 @end cartouche
5370 Followed.
5372 @cindex Bounded errors
5373 @unnumberedsec 1.1.5(12): Bounded Errors
5374 @sp 1
5375 @cartouche
5376 If an implementation detects a bounded error or erroneous
5377 execution, it should raise @code{Program_Error}.
5378 @end cartouche
5379 Followed in all cases in which the implementation detects a bounded
5380 error or erroneous execution.  Not all such situations are detected at
5381 runtime.
5383 @cindex Pragmas
5384 @unnumberedsec 2.8(16): Pragmas
5385 @sp 1
5386 @cartouche
5387 Normally, implementation-defined pragmas should have no semantic effect
5388 for error-free programs; that is, if the implementation-defined pragmas
5389 are removed from a working program, the program should still be legal,
5390 and should still have the same semantics.
5391 @end cartouche
5392 The following implementation defined pragmas are exceptions to this
5393 rule:
5395 @table @code
5396 @item Abort_Defer
5397 Affects semantics
5398 @item Ada_83
5399 Affects legality
5400 @item Assert
5401 Affects semantics
5402 @item CPP_Class
5403 Affects semantics
5404 @item CPP_Constructor
5405 Affects semantics
5406 @item CPP_Virtual
5407 Affects semantics
5408 @item CPP_Vtable
5409 Affects semantics
5410 @item Debug
5411 Affects semantics
5412 @item Interface_Name
5413 Affects semantics
5414 @item Machine_Attribute
5415 Affects semantics
5416 @item Unimplemented_Unit
5417 Affects legality
5418 @item Unchecked_Union
5419 Affects semantics
5420 @end table
5422 @noindent
5423 In each of the above cases, it is essential to the purpose of the pragma
5424 that this advice not be followed.  For details see the separate section
5425 on implementation defined pragmas.
5427 @unnumberedsec 2.8(17-19): Pragmas
5428 @sp 1
5429 @cartouche
5430 Normally, an implementation should not define pragmas that can
5431 make an illegal program legal, except as follows:
5432 @end cartouche
5433 @sp 1
5434 @cartouche
5435 A pragma used to complete a declaration, such as a pragma @code{Import};
5436 @end cartouche
5437 @sp 1
5438 @cartouche
5439 A pragma used to configure the environment by adding, removing, or
5440 replacing @code{library_items}.
5441 @end cartouche
5442 See response to paragraph 16 of this same section.
5444 @cindex Character Sets
5445 @cindex Alternative Character Sets
5446 @unnumberedsec 3.5.2(5): Alternative Character Sets
5447 @sp 1
5448 @cartouche
5449 If an implementation supports a mode with alternative interpretations
5450 for @code{Character} and @code{Wide_Character}, the set of graphic
5451 characters of @code{Character} should nevertheless remain a proper
5452 subset of the set of graphic characters of @code{Wide_Character}.  Any
5453 character set ``localizations'' should be reflected in the results of
5454 the subprograms defined in the language-defined package
5455 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5456 an alternative interpretation of @code{Character}, the implementation should
5457 also support a corresponding change in what is a legal
5458 @code{identifier_letter}.
5459 @end cartouche
5460 Not all wide character modes follow this advice, in particular the JIS
5461 and IEC modes reflect standard usage in Japan, and in these encoding,
5462 the upper half of the Latin-1 set is not part of the wide-character
5463 subset, since the most significant bit is used for wide character
5464 encoding.  However, this only applies to the external forms.  Internally
5465 there is no such restriction.
5467 @cindex Integer types
5468 @unnumberedsec 3.5.4(28): Integer Types
5470 @sp 1
5471 @cartouche
5472 An implementation should support @code{Long_Integer} in addition to
5473 @code{Integer} if the target machine supports 32-bit (or longer)
5474 arithmetic.  No other named integer subtypes are recommended for package
5475 @code{Standard}.  Instead, appropriate named integer subtypes should be
5476 provided in the library package @code{Interfaces} (see B.2).
5477 @end cartouche
5478 @code{Long_Integer} is supported.  Other standard integer types are supported
5479 so this advice is not fully followed.  These types
5480 are supported for convenient interface to C, and so that all hardware
5481 types of the machine are easily available.
5482 @unnumberedsec 3.5.4(29): Integer Types
5484 @sp 1
5485 @cartouche
5486 An implementation for a two's complement machine should support
5487 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5488 implementation should support a non-binary modules up to @code{Integer'Last}.
5489 @end cartouche
5490 Followed.
5492 @cindex Enumeration values
5493 @unnumberedsec 3.5.5(8): Enumeration Values
5494 @sp 1
5495 @cartouche
5496 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5497 subtype, if the value of the operand does not correspond to the internal
5498 code for any enumeration literal of its type (perhaps due to an
5499 un-initialized variable), then the implementation should raise
5500 @code{Program_Error}.  This is particularly important for enumeration
5501 types with noncontiguous internal codes specified by an
5502 enumeration_representation_clause.
5503 @end cartouche
5504 Followed.
5506 @cindex Float types
5507 @unnumberedsec 3.5.7(17): Float Types
5508 @sp 1
5509 @cartouche
5510 An implementation should support @code{Long_Float} in addition to
5511 @code{Float} if the target machine supports 11 or more digits of
5512 precision.  No other named floating point subtypes are recommended for
5513 package @code{Standard}.  Instead, appropriate named floating point subtypes
5514 should be provided in the library package @code{Interfaces} (see B.2).
5515 @end cartouche
5516 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5517 former provides improved compatibility with other implementations
5518 supporting this type.  The latter corresponds to the highest precision
5519 floating-point type supported by the hardware.  On most machines, this
5520 will be the same as @code{Long_Float}, but on some machines, it will
5521 correspond to the IEEE extended form.  The notable case is all ia32
5522 (x86) implementations, where @code{Long_Long_Float} corresponds to
5523 the 80-bit extended precision format supported in hardware on this
5524 processor.  Note that the 128-bit format on SPARC is not supported,
5525 since this is a software rather than a hardware format.
5527 @cindex Multidimensional arrays
5528 @cindex Arrays, multidimensional
5529 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5530 @sp 1
5531 @cartouche
5532 An implementation should normally represent multidimensional arrays in
5533 row-major order, consistent with the notation used for multidimensional
5534 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5535 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5536 column-major order should be used instead (see B.5, ``Interfacing with
5537 Fortran'').
5538 @end cartouche
5539 Followed.
5541 @findex Duration'Small
5542 @unnumberedsec 9.6(30-31): Duration'Small
5543 @sp 1
5544 @cartouche
5545 Whenever possible in an implementation, the value of @code{Duration'Small}
5546 should be no greater than 100 microseconds.
5547 @end cartouche
5548 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5550 @sp 1
5551 @cartouche
5552 The time base for @code{delay_relative_statements} should be monotonic;
5553 it need not be the same time base as used for @code{Calendar.Clock}.
5554 @end cartouche
5555 Followed.
5557 @unnumberedsec 10.2.1(12): Consistent Representation
5558 @sp 1
5559 @cartouche
5560 In an implementation, a type declared in a pre-elaborated package should
5561 have the same representation in every elaboration of a given version of
5562 the package, whether the elaborations occur in distinct executions of
5563 the same program, or in executions of distinct programs or partitions
5564 that include the given version.
5565 @end cartouche
5566 Followed, except in the case of tagged types.  Tagged types involve
5567 implicit pointers to a local copy of a dispatch table, and these pointers
5568 have representations which thus depend on a particular elaboration of the
5569 package.  It is not easy to see how it would be possible to follow this
5570 advice without severely impacting efficiency of execution.
5572 @cindex Exception information
5573 @unnumberedsec 11.4.1(19): Exception Information
5574 @sp 1
5575 @cartouche
5576 @code{Exception_Message} by default and @code{Exception_Information}
5577 should produce information useful for
5578 debugging.  @code{Exception_Message} should be short, about one
5579 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5580 should not include the
5581 @code{Exception_Name}.  @code{Exception_Information} should include both
5582 the @code{Exception_Name} and the @code{Exception_Message}.
5583 @end cartouche
5584 Followed.  For each exception that doesn't have a specified
5585 @code{Exception_Message}, the compiler generates one containing the location
5586 of the raise statement.  This location has the form ``file:line'', where
5587 file is the short file name (without path information) and line is the line
5588 number in the file.  Note that in the case of the Zero Cost Exception
5589 mechanism, these messages become redundant with the Exception_Information that
5590 contains a full backtrace of the calling sequence, so they are disabled.
5591 To disable explicitly the generation of the source location message, use the
5592 Pragma @code{Discard_Names}.
5594 @cindex Suppression of checks
5595 @cindex Checks, suppression of
5596 @unnumberedsec 11.5(28): Suppression of Checks
5597 @sp 1
5598 @cartouche
5599 The implementation should minimize the code executed for checks that
5600 have been suppressed.
5601 @end cartouche
5602 Followed.
5604 @cindex Representation clauses
5605 @unnumberedsec 13.1 (21-24): Representation Clauses
5606 @sp 1
5607 @cartouche
5608 The recommended level of support for all representation items is
5609 qualified as follows:
5610 @end cartouche
5611 @sp 1
5612 @cartouche
5613 An implementation need not support representation items containing
5614 non-static expressions, except that an implementation should support a
5615 representation item for a given entity if each non-static expression in
5616 the representation item is a name that statically denotes a constant
5617 declared before the entity.
5618 @end cartouche
5619 Followed.  In fact, GNAT goes beyond the recommended level of support
5620 by allowing nonstatic expressions in some representation clauses even
5621 without the need to declare constants initialized with the values of
5622 such expressions.
5623 For example:
5625 @smallexample @c ada
5626   X : Integer;
5627   Y : Float;
5628   for Y'Address use X'Address;>>
5629 @end smallexample
5632 @sp 1
5633 @cartouche
5634 An implementation need not support a specification for the @code{Size}
5635 for a given composite subtype, nor the size or storage place for an
5636 object (including a component) of a given composite subtype, unless the
5637 constraints on the subtype and its composite subcomponents (if any) are
5638 all static constraints.
5639 @end cartouche
5640 Followed.  Size Clauses are not permitted on non-static components, as
5641 described above.
5643 @sp 1
5644 @cartouche
5645 An aliased component, or a component whose type is by-reference, should
5646 always be allocated at an addressable location.
5647 @end cartouche
5648 Followed.
5650 @cindex Packed types
5651 @unnumberedsec 13.2(6-8): Packed Types
5652 @sp 1
5653 @cartouche
5654 If a type is packed, then the implementation should try to minimize
5655 storage allocated to objects of the type, possibly at the expense of
5656 speed of accessing components, subject to reasonable complexity in
5657 addressing calculations.
5658 @end cartouche
5659 @sp 1
5660 @cartouche
5661 The recommended level of support pragma @code{Pack} is:
5663 For a packed record type, the components should be packed as tightly as
5664 possible subject to the Sizes of the component subtypes, and subject to
5665 any @code{record_representation_clause} that applies to the type; the
5666 implementation may, but need not, reorder components or cross aligned
5667 word boundaries to improve the packing.  A component whose @code{Size} is
5668 greater than the word size may be allocated an integral number of words.
5669 @end cartouche
5670 Followed.  Tight packing of arrays is supported for all component sizes
5671 up to 64-bits. If the array component size is 1 (that is to say, if
5672 the component is a boolean type or an enumeration type with two values)
5673 then values of the type are implicitly initialized to zero. This
5674 happens both for objects of the packed type, and for objects that have a
5675 subcomponent of the packed type.
5677 @sp 1
5678 @cartouche
5679 An implementation should support Address clauses for imported
5680 subprograms.
5681 @end cartouche
5682 Followed.
5683 @cindex @code{Address} clauses
5684 @unnumberedsec 13.3(14-19): Address Clauses
5686 @sp 1
5687 @cartouche
5688 For an array @var{X}, @code{@var{X}'Address} should point at the first
5689 component of the array, and not at the array bounds.
5690 @end cartouche
5691 Followed.
5693 @sp 1
5694 @cartouche
5695 The recommended level of support for the @code{Address} attribute is:
5697 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5698 object that is aliased or of a by-reference type, or is an entity whose
5699 @code{Address} has been specified.
5700 @end cartouche
5701 Followed.  A valid address will be produced even if none of those
5702 conditions have been met.  If necessary, the object is forced into
5703 memory to ensure the address is valid.
5705 @sp 1
5706 @cartouche
5707 An implementation should support @code{Address} clauses for imported
5708 subprograms.
5709 @end cartouche
5710 Followed.
5712 @sp 1
5713 @cartouche
5714 Objects (including subcomponents) that are aliased or of a by-reference
5715 type should be allocated on storage element boundaries.
5716 @end cartouche
5717 Followed.
5719 @sp 1
5720 @cartouche
5721 If the @code{Address} of an object is specified, or it is imported or exported,
5722 then the implementation should not perform optimizations based on
5723 assumptions of no aliases.
5724 @end cartouche
5725 Followed.
5727 @cindex @code{Alignment} clauses
5728 @unnumberedsec 13.3(29-35): Alignment Clauses
5729 @sp 1
5730 @cartouche
5731 The recommended level of support for the @code{Alignment} attribute for
5732 subtypes is:
5734 An implementation should support specified Alignments that are factors
5735 and multiples of the number of storage elements per word, subject to the
5736 following:
5737 @end cartouche
5738 Followed.
5740 @sp 1
5741 @cartouche
5742 An implementation need not support specified @code{Alignment}s for
5743 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5744 loaded and stored by available machine instructions.
5745 @end cartouche
5746 Followed.
5748 @sp 1
5749 @cartouche
5750 An implementation need not support specified @code{Alignment}s that are
5751 greater than the maximum @code{Alignment} the implementation ever returns by
5752 default.
5753 @end cartouche
5754 Followed.
5756 @sp 1
5757 @cartouche
5758 The recommended level of support for the @code{Alignment} attribute for
5759 objects is:
5761 Same as above, for subtypes, but in addition:
5762 @end cartouche
5763 Followed.
5765 @sp 1
5766 @cartouche
5767 For stand-alone library-level objects of statically constrained
5768 subtypes, the implementation should support all @code{Alignment}s
5769 supported by the target linker.  For example, page alignment is likely to
5770 be supported for such objects, but not for subtypes.
5771 @end cartouche
5772 Followed.
5774 @cindex @code{Size} clauses
5775 @unnumberedsec 13.3(42-43): Size Clauses
5776 @sp 1
5777 @cartouche
5778 The recommended level of support for the @code{Size} attribute of
5779 objects is:
5781 A @code{Size} clause should be supported for an object if the specified
5782 @code{Size} is at least as large as its subtype's @code{Size}, and
5783 corresponds to a size in storage elements that is a multiple of the
5784 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5785 @end cartouche
5786 Followed.
5788 @unnumberedsec 13.3(50-56): Size Clauses
5789 @sp 1
5790 @cartouche
5791 If the @code{Size} of a subtype is specified, and allows for efficient
5792 independent addressability (see 9.10) on the target architecture, then
5793 the @code{Size} of the following objects of the subtype should equal the
5794 @code{Size} of the subtype:
5796 Aliased objects (including components).
5797 @end cartouche
5798 Followed.
5800 @sp 1
5801 @cartouche
5802 @code{Size} clause on a composite subtype should not affect the
5803 internal layout of components.
5804 @end cartouche
5805 Followed.
5807 @sp 1
5808 @cartouche
5809 The recommended level of support for the @code{Size} attribute of subtypes is:
5810 @end cartouche
5811 @sp 1
5812 @cartouche
5813 The @code{Size} (if not specified) of a static discrete or fixed point
5814 subtype should be the number of bits needed to represent each value
5815 belonging to the subtype using an unbiased representation, leaving space
5816 for a sign bit only if the subtype contains negative values.  If such a
5817 subtype is a first subtype, then an implementation should support a
5818 specified @code{Size} for it that reflects this representation.
5819 @end cartouche
5820 Followed.
5822 @sp 1
5823 @cartouche
5824 For a subtype implemented with levels of indirection, the @code{Size}
5825 should include the size of the pointers, but not the size of what they
5826 point at.
5827 @end cartouche
5828 Followed.
5830 @cindex @code{Component_Size} clauses
5831 @unnumberedsec 13.3(71-73): Component Size Clauses
5832 @sp 1
5833 @cartouche
5834 The recommended level of support for the @code{Component_Size}
5835 attribute is:
5836 @end cartouche
5837 @sp 1
5838 @cartouche
5839 An implementation need not support specified @code{Component_Sizes} that are
5840 less than the @code{Size} of the component subtype.
5841 @end cartouche
5842 Followed.
5844 @sp 1
5845 @cartouche
5846 An implementation should support specified @code{Component_Size}s that
5847 are factors and multiples of the word size.  For such
5848 @code{Component_Size}s, the array should contain no gaps between
5849 components.  For other @code{Component_Size}s (if supported), the array
5850 should contain no gaps between components when packing is also
5851 specified; the implementation should forbid this combination in cases
5852 where it cannot support a no-gaps representation.
5853 @end cartouche
5854 Followed.
5856 @cindex Enumeration representation clauses
5857 @cindex Representation clauses, enumeration
5858 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5859 @sp 1
5860 @cartouche
5861 The recommended level of support for enumeration representation clauses
5864 An implementation need not support enumeration representation clauses
5865 for boolean types, but should at minimum support the internal codes in
5866 the range @code{System.Min_Int.System.Max_Int}.
5867 @end cartouche
5868 Followed.
5870 @cindex Record representation clauses
5871 @cindex Representation clauses, records
5872 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5873 @sp 1
5874 @cartouche
5875 The recommended level of support for
5876 @*@code{record_representation_clauses} is:
5878 An implementation should support storage places that can be extracted
5879 with a load, mask, shift sequence of machine code, and set with a load,
5880 shift, mask, store sequence, given the available machine instructions
5881 and run-time model.
5882 @end cartouche
5883 Followed.
5885 @sp 1
5886 @cartouche
5887 A storage place should be supported if its size is equal to the
5888 @code{Size} of the component subtype, and it starts and ends on a
5889 boundary that obeys the @code{Alignment} of the component subtype.
5890 @end cartouche
5891 Followed.
5893 @sp 1
5894 @cartouche
5895 If the default bit ordering applies to the declaration of a given type,
5896 then for a component whose subtype's @code{Size} is less than the word
5897 size, any storage place that does not cross an aligned word boundary
5898 should be supported.
5899 @end cartouche
5900 Followed.
5902 @sp 1
5903 @cartouche
5904 An implementation may reserve a storage place for the tag field of a
5905 tagged type, and disallow other components from overlapping that place.
5906 @end cartouche
5907 Followed.  The storage place for the tag field is the beginning of the tagged
5908 record, and its size is Address'Size.  GNAT will reject an explicit component
5909 clause for the tag field.
5911 @sp 1
5912 @cartouche
5913 An implementation need not support a @code{component_clause} for a
5914 component of an extension part if the storage place is not after the
5915 storage places of all components of the parent type, whether or not
5916 those storage places had been specified.
5917 @end cartouche
5918 Followed.  The above advice on record representation clauses is followed,
5919 and all mentioned features are implemented.
5921 @cindex Storage place attributes
5922 @unnumberedsec 13.5.2(5): Storage Place Attributes
5923 @sp 1
5924 @cartouche
5925 If a component is represented using some form of pointer (such as an
5926 offset) to the actual data of the component, and this data is contiguous
5927 with the rest of the object, then the storage place attributes should
5928 reflect the place of the actual data, not the pointer.  If a component is
5929 allocated discontinuously from the rest of the object, then a warning
5930 should be generated upon reference to one of its storage place
5931 attributes.
5932 @end cartouche
5933 Followed.  There are no such components in GNAT@.
5935 @cindex Bit ordering
5936 @unnumberedsec 13.5.3(7-8): Bit Ordering
5937 @sp 1
5938 @cartouche
5939 The recommended level of support for the non-default bit ordering is:
5940 @end cartouche
5941 @sp 1
5942 @cartouche
5943 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5944 should support the non-default bit ordering in addition to the default
5945 bit ordering.
5946 @end cartouche
5947 Followed.  Word size does not equal storage size in this implementation.
5948 Thus non-default bit ordering is not supported.
5950 @cindex @code{Address}, as private type
5951 @unnumberedsec 13.7(37): Address as Private
5952 @sp 1
5953 @cartouche
5954 @code{Address} should be of a private type.
5955 @end cartouche
5956 Followed.
5958 @cindex Operations, on @code{Address}
5959 @cindex @code{Address}, operations of
5960 @unnumberedsec 13.7.1(16): Address Operations
5961 @sp 1
5962 @cartouche
5963 Operations in @code{System} and its children should reflect the target
5964 environment semantics as closely as is reasonable.  For example, on most
5965 machines, it makes sense for address arithmetic to ``wrap around''.
5966 Operations that do not make sense should raise @code{Program_Error}.
5967 @end cartouche
5968 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5969 operation raises @code{Program_Error}, since all operations make sense.
5971 @cindex Unchecked conversion
5972 @unnumberedsec 13.9(14-17): Unchecked Conversion
5973 @sp 1
5974 @cartouche
5975 The @code{Size} of an array object should not include its bounds; hence,
5976 the bounds should not be part of the converted data.
5977 @end cartouche
5978 Followed.
5980 @sp 1
5981 @cartouche
5982 The implementation should not generate unnecessary run-time checks to
5983 ensure that the representation of @var{S} is a representation of the
5984 target type.  It should take advantage of the permission to return by
5985 reference when possible.  Restrictions on unchecked conversions should be
5986 avoided unless required by the target environment.
5987 @end cartouche
5988 Followed.  There are no restrictions on unchecked conversion.  A warning is
5989 generated if the source and target types do not have the same size since
5990 the semantics in this case may be target dependent.
5992 @sp 1
5993 @cartouche
5994 The recommended level of support for unchecked conversions is:
5995 @end cartouche
5996 @sp 1
5997 @cartouche
5998 Unchecked conversions should be supported and should be reversible in
5999 the cases where this clause defines the result.  To enable meaningful use
6000 of unchecked conversion, a contiguous representation should be used for
6001 elementary subtypes, for statically constrained array subtypes whose
6002 component subtype is one of the subtypes described in this paragraph,
6003 and for record subtypes without discriminants whose component subtypes
6004 are described in this paragraph.
6005 @end cartouche
6006 Followed.
6008 @cindex Heap usage, implicit
6009 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6010 @sp 1
6011 @cartouche
6012 An implementation should document any cases in which it dynamically
6013 allocates heap storage for a purpose other than the evaluation of an
6014 allocator.
6015 @end cartouche
6016 Followed, the only other points at which heap storage is dynamically
6017 allocated are as follows:
6019 @itemize @bullet
6020 @item
6021 At initial elaboration time, to allocate dynamically sized global
6022 objects.
6024 @item
6025 To allocate space for a task when a task is created.
6027 @item
6028 To extend the secondary stack dynamically when needed.  The secondary
6029 stack is used for returning variable length results.
6030 @end itemize
6032 @sp 1
6033 @cartouche
6034 A default (implementation-provided) storage pool for an
6035 access-to-constant type should not have overhead to support deallocation of
6036 individual objects.
6037 @end cartouche
6038 Followed.
6040 @sp 1
6041 @cartouche
6042 A storage pool for an anonymous access type should be created at the
6043 point of an allocator for the type, and be reclaimed when the designated
6044 object becomes inaccessible.
6045 @end cartouche
6046 Followed.
6048 @cindex Unchecked deallocation
6049 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6050 @sp 1
6051 @cartouche
6052 For a standard storage pool, @code{Free} should actually reclaim the
6053 storage.
6054 @end cartouche
6055 Followed.
6057 @cindex Stream oriented attributes
6058 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6059 @sp 1
6060 @cartouche
6061 If a stream element is the same size as a storage element, then the
6062 normal in-memory representation should be used by @code{Read} and
6063 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6064 should use the smallest number of stream elements needed to represent
6065 all values in the base range of the scalar type.
6066 @end cartouche
6068 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6069 which specifies using the size of the first subtype.
6070 However, such an implementation is based on direct binary
6071 representations and is therefore target- and endianness-dependent.
6072 To address this issue, GNAT also supplies an alternate implementation
6073 of the stream attributes @code{Read} and @code{Write},
6074 which uses the target-independent XDR standard representation
6075 for scalar types.
6076 @cindex XDR representation
6077 @cindex @code{Read} attribute
6078 @cindex @code{Write} attribute
6079 @cindex Stream oriented attributes
6080 The XDR implementation is provided as an alternative body of the
6081 @code{System.Stream_Attributes} package, in the file
6082 @file{s-strxdr.adb} in the GNAT library.
6083 There is no @file{s-strxdr.ads} file.
6084 In order to install the XDR implementation, do the following:
6085 @enumerate
6086 @item Replace the default implementation of the
6087 @code{System.Stream_Attributes} package with the XDR implementation.
6088 For example on a Unix platform issue the commands:
6089 @smallexample
6090 $ mv s-stratt.adb s-strold.adb
6091 $ mv s-strxdr.adb s-stratt.adb
6092 @end smallexample
6094 @item
6095 Rebuild the GNAT run-time library as documented in the
6096 @cite{GNAT User's Guide}
6097 @end enumerate
6099 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6100 @sp 1
6101 @cartouche
6102 If an implementation provides additional named predefined integer types,
6103 then the names should end with @samp{Integer} as in
6104 @samp{Long_Integer}.  If an implementation provides additional named
6105 predefined floating point types, then the names should end with
6106 @samp{Float} as in @samp{Long_Float}.
6107 @end cartouche
6108 Followed.
6110 @findex Ada.Characters.Handling
6111 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6112 @sp 1
6113 @cartouche
6114 If an implementation provides a localized definition of @code{Character}
6115 or @code{Wide_Character}, then the effects of the subprograms in
6116 @code{Characters.Handling} should reflect the localizations.  See also
6117 3.5.2.
6118 @end cartouche
6119 Followed.  GNAT provides no such localized definitions.
6121 @cindex Bounded-length strings
6122 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6123 @sp 1
6124 @cartouche
6125 Bounded string objects should not be implemented by implicit pointers
6126 and dynamic allocation.
6127 @end cartouche
6128 Followed.  No implicit pointers or dynamic allocation are used.
6130 @cindex Random number generation
6131 @unnumberedsec A.5.2(46-47): Random Number Generation
6132 @sp 1
6133 @cartouche
6134 Any storage associated with an object of type @code{Generator} should be
6135 reclaimed on exit from the scope of the object.
6136 @end cartouche
6137 Followed.
6139 @sp 1
6140 @cartouche
6141 If the generator period is sufficiently long in relation to the number
6142 of distinct initiator values, then each possible value of
6143 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6144 random numbers that does not, in a practical sense, overlap the sequence
6145 initiated by any other value.  If this is not possible, then the mapping
6146 between initiator values and generator states should be a rapidly
6147 varying function of the initiator value.
6148 @end cartouche
6149 Followed.  The generator period is sufficiently long for the first
6150 condition here to hold true.
6152 @findex Get_Immediate
6153 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6154 @sp 1
6155 @cartouche
6156 The @code{Get_Immediate} procedures should be implemented with
6157 unbuffered input.  For a device such as a keyboard, input should be
6158 @dfn{available} if a key has already been typed, whereas for a disk
6159 file, input should always be available except at end of file.  For a file
6160 associated with a keyboard-like device, any line-editing features of the
6161 underlying operating system should be disabled during the execution of
6162 @code{Get_Immediate}.
6163 @end cartouche
6164 Followed on all targets except VxWorks. For VxWorks, there is no way to
6165 provide this functionality that does not result in the input buffer being
6166 flushed before the @code{Get_Immediate} call. A special unit
6167 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6168 this functionality.
6170 @findex Export
6171 @unnumberedsec B.1(39-41): Pragma @code{Export}
6172 @sp 1
6173 @cartouche
6174 If an implementation supports pragma @code{Export} to a given language,
6175 then it should also allow the main subprogram to be written in that
6176 language.  It should support some mechanism for invoking the elaboration
6177 of the Ada library units included in the system, and for invoking the
6178 finalization of the environment task.  On typical systems, the
6179 recommended mechanism is to provide two subprograms whose link names are
6180 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6181 elaboration code for library units.  @code{adafinal} should contain the
6182 finalization code.  These subprograms should have no effect the second
6183 and subsequent time they are called.
6184 @end cartouche
6185 Followed.
6187 @sp 1
6188 @cartouche
6189 Automatic elaboration of pre-elaborated packages should be
6190 provided when pragma @code{Export} is supported.
6191 @end cartouche
6192 Followed when the main program is in Ada.  If the main program is in a
6193 foreign language, then
6194 @code{adainit} must be called to elaborate pre-elaborated
6195 packages.
6197 @sp 1
6198 @cartouche
6199 For each supported convention @var{L} other than @code{Intrinsic}, an
6200 implementation should support @code{Import} and @code{Export} pragmas
6201 for objects of @var{L}-compatible types and for subprograms, and pragma
6202 @code{Convention} for @var{L}-eligible types and for subprograms,
6203 presuming the other language has corresponding features.  Pragma
6204 @code{Convention} need not be supported for scalar types.
6205 @end cartouche
6206 Followed.
6208 @cindex Package @code{Interfaces}
6209 @findex Interfaces
6210 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6211 @sp 1
6212 @cartouche
6213 For each implementation-defined convention identifier, there should be a
6214 child package of package Interfaces with the corresponding name.  This
6215 package should contain any declarations that would be useful for
6216 interfacing to the language (implementation) represented by the
6217 convention.  Any declarations useful for interfacing to any language on
6218 the given hardware architecture should be provided directly in
6219 @code{Interfaces}.
6220 @end cartouche
6221 Followed.  An additional package not defined
6222 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
6223 for interfacing to C++.
6225 @sp 1
6226 @cartouche
6227 An implementation supporting an interface to C, COBOL, or Fortran should
6228 provide the corresponding package or packages described in the following
6229 clauses.
6230 @end cartouche
6231 Followed.  GNAT provides all the packages described in this section.
6233 @cindex C, interfacing with
6234 @unnumberedsec B.3(63-71): Interfacing with C
6235 @sp 1
6236 @cartouche
6237 An implementation should support the following interface correspondences
6238 between Ada and C@.
6239 @end cartouche
6240 Followed.
6242 @sp 1
6243 @cartouche
6244 An Ada procedure corresponds to a void-returning C function.
6245 @end cartouche
6246 Followed.
6248 @sp 1
6249 @cartouche
6250 An Ada function corresponds to a non-void C function.
6251 @end cartouche
6252 Followed.
6254 @sp 1
6255 @cartouche
6256 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6257 function.
6258 @end cartouche
6259 Followed.
6261 @sp 1
6262 @cartouche
6263 An Ada @code{in} parameter of an access-to-object type with designated
6264 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6265 where @var{t} is the C type corresponding to the Ada type @var{T}.
6266 @end cartouche
6267 Followed.
6269 @sp 1
6270 @cartouche
6271 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6272 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6273 argument to a C function, where @var{t} is the C type corresponding to
6274 the Ada type @var{T}.  In the case of an elementary @code{out} or
6275 @code{in out} parameter, a pointer to a temporary copy is used to
6276 preserve by-copy semantics.
6277 @end cartouche
6278 Followed.
6280 @sp 1
6281 @cartouche
6282 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6283 @code{@var{t}*} argument to a C function, where @var{t} is the C
6284 structure corresponding to the Ada type @var{T}.
6285 @end cartouche
6286 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6287 pragma, or Convention, or by explicitly specifying the mechanism for a given
6288 call using an extended import or export pragma.
6290 @sp 1
6291 @cartouche
6292 An Ada parameter of an array type with component type @var{T}, of any
6293 mode, is passed as a @code{@var{t}*} argument to a C function, where
6294 @var{t} is the C type corresponding to the Ada type @var{T}.
6295 @end cartouche
6296 Followed.
6298 @sp 1
6299 @cartouche
6300 An Ada parameter of an access-to-subprogram type is passed as a pointer
6301 to a C function whose prototype corresponds to the designated
6302 subprogram's specification.
6303 @end cartouche
6304 Followed.
6306 @cindex COBOL, interfacing with
6307 @unnumberedsec B.4(95-98): Interfacing with COBOL
6308 @sp 1
6309 @cartouche
6310 An Ada implementation should support the following interface
6311 correspondences between Ada and COBOL@.
6312 @end cartouche
6313 Followed.
6315 @sp 1
6316 @cartouche
6317 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6318 the COBOL type corresponding to @var{T}.
6319 @end cartouche
6320 Followed.
6322 @sp 1
6323 @cartouche
6324 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6325 the corresponding COBOL type.
6326 @end cartouche
6327 Followed.
6329 @sp 1
6330 @cartouche
6331 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6332 COBOL type corresponding to the Ada parameter type; for scalars, a local
6333 copy is used if necessary to ensure by-copy semantics.
6334 @end cartouche
6335 Followed.
6337 @cindex Fortran, interfacing with
6338 @unnumberedsec B.5(22-26): Interfacing with Fortran
6339 @sp 1
6340 @cartouche
6341 An Ada implementation should support the following interface
6342 correspondences between Ada and Fortran:
6343 @end cartouche
6344 Followed.
6346 @sp 1
6347 @cartouche
6348 An Ada procedure corresponds to a Fortran subroutine.
6349 @end cartouche
6350 Followed.
6352 @sp 1
6353 @cartouche
6354 An Ada function corresponds to a Fortran function.
6355 @end cartouche
6356 Followed.
6358 @sp 1
6359 @cartouche
6360 An Ada parameter of an elementary, array, or record type @var{T} is
6361 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6362 the Fortran type corresponding to the Ada type @var{T}, and where the
6363 INTENT attribute of the corresponding dummy argument matches the Ada
6364 formal parameter mode; the Fortran implementation's parameter passing
6365 conventions are used.  For elementary types, a local copy is used if
6366 necessary to ensure by-copy semantics.
6367 @end cartouche
6368 Followed.
6370 @sp 1
6371 @cartouche
6372 An Ada parameter of an access-to-subprogram type is passed as a
6373 reference to a Fortran procedure whose interface corresponds to the
6374 designated subprogram's specification.
6375 @end cartouche
6376 Followed.
6378 @cindex Machine operations
6379 @unnumberedsec C.1(3-5): Access to Machine Operations
6380 @sp 1
6381 @cartouche
6382 The machine code or intrinsic support should allow access to all
6383 operations normally available to assembly language programmers for the
6384 target environment, including privileged instructions, if any.
6385 @end cartouche
6386 Followed.
6388 @sp 1
6389 @cartouche
6390 The interfacing pragmas (see Annex B) should support interface to
6391 assembler; the default assembler should be associated with the
6392 convention identifier @code{Assembler}.
6393 @end cartouche
6394 Followed.
6396 @sp 1
6397 @cartouche
6398 If an entity is exported to assembly language, then the implementation
6399 should allocate it at an addressable location, and should ensure that it
6400 is retained by the linking process, even if not otherwise referenced
6401 from the Ada code.  The implementation should assume that any call to a
6402 machine code or assembler subprogram is allowed to read or update every
6403 object that is specified as exported.
6404 @end cartouche
6405 Followed.
6407 @unnumberedsec C.1(10-16): Access to Machine Operations
6408 @sp 1
6409 @cartouche
6410 The implementation should ensure that little or no overhead is
6411 associated with calling intrinsic and machine-code subprograms.
6412 @end cartouche
6413 Followed for both intrinsics and machine-code subprograms.
6415 @sp 1
6416 @cartouche
6417 It is recommended that intrinsic subprograms be provided for convenient
6418 access to any machine operations that provide special capabilities or
6419 efficiency and that are not otherwise available through the language
6420 constructs.
6421 @end cartouche
6422 Followed.  A full set of machine operation intrinsic subprograms is provided.
6424 @sp 1
6425 @cartouche
6426 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6427 swap, decrement and test, enqueue/dequeue.
6428 @end cartouche
6429 Followed on any target supporting such operations.
6431 @sp 1
6432 @cartouche
6433 Standard numeric functions---e.g.@:, sin, log.
6434 @end cartouche
6435 Followed on any target supporting such operations.
6437 @sp 1
6438 @cartouche
6439 String manipulation operations---e.g.@:, translate and test.
6440 @end cartouche
6441 Followed on any target supporting such operations.
6443 @sp 1
6444 @cartouche
6445 Vector operations---e.g.@:, compare vector against thresholds.
6446 @end cartouche
6447 Followed on any target supporting such operations.
6449 @sp 1
6450 @cartouche
6451 Direct operations on I/O ports.
6452 @end cartouche
6453 Followed on any target supporting such operations.
6455 @cindex Interrupt support
6456 @unnumberedsec C.3(28): Interrupt Support
6457 @sp 1
6458 @cartouche
6459 If the @code{Ceiling_Locking} policy is not in effect, the
6460 implementation should provide means for the application to specify which
6461 interrupts are to be blocked during protected actions, if the underlying
6462 system allows for a finer-grain control of interrupt blocking.
6463 @end cartouche
6464 Followed.  The underlying system does not allow for finer-grain control
6465 of interrupt blocking.
6467 @cindex Protected procedure handlers
6468 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6469 @sp 1
6470 @cartouche
6471 Whenever possible, the implementation should allow interrupt handlers to
6472 be called directly by the hardware.
6473 @end cartouche
6474 @c SGI info:
6475 @ignore
6476 This is never possible under IRIX, so this is followed by default.
6477 @end ignore
6478 Followed on any target where the underlying operating system permits
6479 such direct calls.
6481 @sp 1
6482 @cartouche
6483 Whenever practical, violations of any
6484 implementation-defined restrictions should be detected before run time.
6485 @end cartouche
6486 Followed.  Compile time warnings are given when possible.
6488 @cindex Package @code{Interrupts}
6489 @findex Interrupts
6490 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6492 @sp 1
6493 @cartouche
6494 If implementation-defined forms of interrupt handler procedures are
6495 supported, such as protected procedures with parameters, then for each
6496 such form of a handler, a type analogous to @code{Parameterless_Handler}
6497 should be specified in a child package of @code{Interrupts}, with the
6498 same operations as in the predefined package Interrupts.
6499 @end cartouche
6500 Followed.
6502 @cindex Pre-elaboration requirements
6503 @unnumberedsec C.4(14): Pre-elaboration Requirements
6504 @sp 1
6505 @cartouche
6506 It is recommended that pre-elaborated packages be implemented in such a
6507 way that there should be little or no code executed at run time for the
6508 elaboration of entities not already covered by the Implementation
6509 Requirements.
6510 @end cartouche
6511 Followed.  Executable code is generated in some cases, e.g.@: loops
6512 to initialize large arrays.
6514 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6516 @sp 1
6517 @cartouche
6518 If the pragma applies to an entity, then the implementation should
6519 reduce the amount of storage used for storing names associated with that
6520 entity.
6521 @end cartouche
6522 Followed.
6524 @cindex Package @code{Task_Attributes}
6525 @findex Task_Attributes
6526 @unnumberedsec C.7.2(30): The Package Task_Attributes
6527 @sp 1
6528 @cartouche
6529 Some implementations are targeted to domains in which memory use at run
6530 time must be completely deterministic.  For such implementations, it is
6531 recommended that the storage for task attributes will be pre-allocated
6532 statically and not from the heap.  This can be accomplished by either
6533 placing restrictions on the number and the size of the task's
6534 attributes, or by using the pre-allocated storage for the first @var{N}
6535 attribute objects, and the heap for the others.  In the latter case,
6536 @var{N} should be documented.
6537 @end cartouche
6538 Not followed.  This implementation is not targeted to such a domain.
6540 @cindex Locking Policies
6541 @unnumberedsec D.3(17): Locking Policies
6543 @sp 1
6544 @cartouche
6545 The implementation should use names that end with @samp{_Locking} for
6546 locking policies defined by the implementation.
6547 @end cartouche
6548 Followed.  A single implementation-defined locking policy is defined,
6549 whose name (@code{Inheritance_Locking}) follows this suggestion.
6551 @cindex Entry queuing policies
6552 @unnumberedsec D.4(16): Entry Queuing Policies
6553 @sp 1
6554 @cartouche
6555 Names that end with @samp{_Queuing} should be used
6556 for all implementation-defined queuing policies.
6557 @end cartouche
6558 Followed.  No such implementation-defined queuing policies exist.
6560 @cindex Preemptive abort
6561 @unnumberedsec D.6(9-10): Preemptive Abort
6562 @sp 1
6563 @cartouche
6564 Even though the @code{abort_statement} is included in the list of
6565 potentially blocking operations (see 9.5.1), it is recommended that this
6566 statement be implemented in a way that never requires the task executing
6567 the @code{abort_statement} to block.
6568 @end cartouche
6569 Followed.
6571 @sp 1
6572 @cartouche
6573 On a multi-processor, the delay associated with aborting a task on
6574 another processor should be bounded; the implementation should use
6575 periodic polling, if necessary, to achieve this.
6576 @end cartouche
6577 Followed.
6579 @cindex Tasking restrictions
6580 @unnumberedsec D.7(21): Tasking Restrictions
6581 @sp 1
6582 @cartouche
6583 When feasible, the implementation should take advantage of the specified
6584 restrictions to produce a more efficient implementation.
6585 @end cartouche
6586 GNAT currently takes advantage of these restrictions by providing an optimized
6587 run time when the Ravenscar profile and the GNAT restricted run time set
6588 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6589 pragma @code{Profile (Restricted)} for more details.
6591 @cindex Time, monotonic
6592 @unnumberedsec D.8(47-49): Monotonic Time
6593 @sp 1
6594 @cartouche
6595 When appropriate, implementations should provide configuration
6596 mechanisms to change the value of @code{Tick}.
6597 @end cartouche
6598 Such configuration mechanisms are not appropriate to this implementation
6599 and are thus not supported.
6601 @sp 1
6602 @cartouche
6603 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6604 be implemented as transformations of the same time base.
6605 @end cartouche
6606 Followed.
6608 @sp 1
6609 @cartouche
6610 It is recommended that the @dfn{best} time base which exists in
6611 the underlying system be available to the application through
6612 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6613 @end cartouche
6614 Followed.
6616 @cindex Partition communication subsystem
6617 @cindex PCS
6618 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6619 @sp 1
6620 @cartouche
6621 Whenever possible, the PCS on the called partition should allow for
6622 multiple tasks to call the RPC-receiver with different messages and
6623 should allow them to block until the corresponding subprogram body
6624 returns.
6625 @end cartouche
6626 Followed by GLADE, a separately supplied PCS that can be used with
6627 GNAT.
6629 @sp 1
6630 @cartouche
6631 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6632 should raise @code{Storage_Error} if it runs out of space trying to
6633 write the @code{Item} into the stream.
6634 @end cartouche
6635 Followed by GLADE, a separately supplied PCS that can be used with
6636 GNAT@.
6638 @cindex COBOL support
6639 @unnumberedsec F(7): COBOL Support
6640 @sp 1
6641 @cartouche
6642 If COBOL (respectively, C) is widely supported in the target
6643 environment, implementations supporting the Information Systems Annex
6644 should provide the child package @code{Interfaces.COBOL} (respectively,
6645 @code{Interfaces.C}) specified in Annex B and should support a
6646 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6647 pragmas (see Annex B), thus allowing Ada programs to interface with
6648 programs written in that language.
6649 @end cartouche
6650 Followed.
6652 @cindex Decimal radix support
6653 @unnumberedsec F.1(2): Decimal Radix Support
6654 @sp 1
6655 @cartouche
6656 Packed decimal should be used as the internal representation for objects
6657 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6658 @end cartouche
6659 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6660 representations.
6662 @cindex Numerics
6663 @unnumberedsec G: Numerics
6664 @sp 2
6665 @cartouche
6666 If Fortran (respectively, C) is widely supported in the target
6667 environment, implementations supporting the Numerics Annex
6668 should provide the child package @code{Interfaces.Fortran} (respectively,
6669 @code{Interfaces.C}) specified in Annex B and should support a
6670 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6671 pragmas (see Annex B), thus allowing Ada programs to interface with
6672 programs written in that language.
6673 @end cartouche
6674 Followed.
6676 @cindex Complex types
6677 @unnumberedsec G.1.1(56-58): Complex Types
6678 @sp 2
6679 @cartouche
6680 Because the usual mathematical meaning of multiplication of a complex
6681 operand and a real operand is that of the scaling of both components of
6682 the former by the latter, an implementation should not perform this
6683 operation by first promoting the real operand to complex type and then
6684 performing a full complex multiplication.  In systems that, in the
6685 future, support an Ada binding to IEC 559:1989, the latter technique
6686 will not generate the required result when one of the components of the
6687 complex operand is infinite.  (Explicit multiplication of the infinite
6688 component by the zero component obtained during promotion yields a NaN
6689 that propagates into the final result.) Analogous advice applies in the
6690 case of multiplication of a complex operand and a pure-imaginary
6691 operand, and in the case of division of a complex operand by a real or
6692 pure-imaginary operand.
6693 @end cartouche
6694 Not followed.
6696 @sp 1
6697 @cartouche
6698 Similarly, because the usual mathematical meaning of addition of a
6699 complex operand and a real operand is that the imaginary operand remains
6700 unchanged, an implementation should not perform this operation by first
6701 promoting the real operand to complex type and then performing a full
6702 complex addition.  In implementations in which the @code{Signed_Zeros}
6703 attribute of the component type is @code{True} (and which therefore
6704 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6705 predefined arithmetic operations), the latter technique will not
6706 generate the required result when the imaginary component of the complex
6707 operand is a negatively signed zero.  (Explicit addition of the negative
6708 zero to the zero obtained during promotion yields a positive zero.)
6709 Analogous advice applies in the case of addition of a complex operand
6710 and a pure-imaginary operand, and in the case of subtraction of a
6711 complex operand and a real or pure-imaginary operand.
6712 @end cartouche
6713 Not followed.
6715 @sp 1
6716 @cartouche
6717 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6718 attempt to provide a rational treatment of the signs of zero results and
6719 result components.  As one example, the result of the @code{Argument}
6720 function should have the sign of the imaginary component of the
6721 parameter @code{X} when the point represented by that parameter lies on
6722 the positive real axis; as another, the sign of the imaginary component
6723 of the @code{Compose_From_Polar} function should be the same as
6724 (respectively, the opposite of) that of the @code{Argument} parameter when that
6725 parameter has a value of zero and the @code{Modulus} parameter has a
6726 nonnegative (respectively, negative) value.
6727 @end cartouche
6728 Followed.
6730 @cindex Complex elementary functions
6731 @unnumberedsec G.1.2(49): Complex Elementary Functions
6732 @sp 1
6733 @cartouche
6734 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6735 @code{True} should attempt to provide a rational treatment of the signs
6736 of zero results and result components.  For example, many of the complex
6737 elementary functions have components that are odd functions of one of
6738 the parameter components; in these cases, the result component should
6739 have the sign of the parameter component at the origin.  Other complex
6740 elementary functions have zero components whose sign is opposite that of
6741 a parameter component at the origin, or is always positive or always
6742 negative.
6743 @end cartouche
6744 Followed.
6746 @cindex Accuracy requirements
6747 @unnumberedsec G.2.4(19): Accuracy Requirements
6748 @sp 1
6749 @cartouche
6750 The versions of the forward trigonometric functions without a
6751 @code{Cycle} parameter should not be implemented by calling the
6752 corresponding version with a @code{Cycle} parameter of
6753 @code{2.0*Numerics.Pi}, since this will not provide the required
6754 accuracy in some portions of the domain.  For the same reason, the
6755 version of @code{Log} without a @code{Base} parameter should not be
6756 implemented by calling the corresponding version with a @code{Base}
6757 parameter of @code{Numerics.e}.
6758 @end cartouche
6759 Followed.
6761 @cindex Complex arithmetic accuracy
6762 @cindex Accuracy, complex arithmetic
6763 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6765 @sp 1
6766 @cartouche
6767 The version of the @code{Compose_From_Polar} function without a
6768 @code{Cycle} parameter should not be implemented by calling the
6769 corresponding version with a @code{Cycle} parameter of
6770 @code{2.0*Numerics.Pi}, since this will not provide the required
6771 accuracy in some portions of the domain.
6772 @end cartouche
6773 Followed.
6775 @c -----------------------------------------
6776 @node Implementation Defined Characteristics
6777 @chapter Implementation Defined Characteristics
6779 @noindent
6780 In addition to the implementation dependent pragmas and attributes, and
6781 the implementation advice, there are a number of other features of Ada
6782 95 that are potentially implementation dependent.  These are mentioned
6783 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6785 A requirement for conforming Ada compilers is that they provide
6786 documentation describing how the implementation deals with each of these
6787 issues.  In this chapter, you will find each point in annex M listed
6788 followed by a description in italic font of how GNAT
6789 @c SGI info:
6790 @ignore
6791 in the ProDev Ada
6792 implementation on IRIX 5.3 operating system or greater
6793 @end ignore
6794 handles the implementation dependence.
6796 You can use this chapter as a guide to minimizing implementation
6797 dependent features in your programs if portability to other compilers
6798 and other operating systems is an important consideration.  The numbers
6799 in each section below correspond to the paragraph number in the Ada 95
6800 Reference Manual.
6802 @sp 1
6803 @cartouche
6804 @noindent
6805 @strong{2}.  Whether or not each recommendation given in Implementation
6806 Advice is followed.  See 1.1.2(37).
6807 @end cartouche
6808 @noindent
6809 @xref{Implementation Advice}.
6811 @sp 1
6812 @cartouche
6813 @noindent
6814 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6815 @end cartouche
6816 @noindent
6817 The complexity of programs that can be processed is limited only by the
6818 total amount of available virtual memory, and disk space for the
6819 generated object files.
6821 @sp 1
6822 @cartouche
6823 @noindent
6824 @strong{4}.  Variations from the standard that are impractical to avoid
6825 given the implementation's execution environment.  See 1.1.3(6).
6826 @end cartouche
6827 @noindent
6828 There are no variations from the standard.
6830 @sp 1
6831 @cartouche
6832 @noindent
6833 @strong{5}.  Which @code{code_statement}s cause external
6834 interactions.  See 1.1.3(10).
6835 @end cartouche
6836 @noindent
6837 Any @code{code_statement} can potentially cause external interactions.
6839 @sp 1
6840 @cartouche
6841 @noindent
6842 @strong{6}.  The coded representation for the text of an Ada
6843 program.  See 2.1(4).
6844 @end cartouche
6845 @noindent
6846 See separate section on source representation.
6848 @sp 1
6849 @cartouche
6850 @noindent
6851 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6852 @end cartouche
6853 @noindent
6854 See separate section on source representation.
6856 @sp 1
6857 @cartouche
6858 @noindent
6859 @strong{8}.  The representation for an end of line.  See 2.2(2).
6860 @end cartouche
6861 @noindent
6862 See separate section on source representation.
6864 @sp 1
6865 @cartouche
6866 @noindent
6867 @strong{9}.  Maximum supported line length and lexical element
6868 length.  See 2.2(15).
6869 @end cartouche
6870 @noindent
6871 The maximum line length is 255 characters an the maximum length of a
6872 lexical element is also 255 characters.
6874 @sp 1
6875 @cartouche
6876 @noindent
6877 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6878 @end cartouche
6879 @noindent
6881 @xref{Implementation Defined Pragmas}.
6883 @sp 1
6884 @cartouche
6885 @noindent
6886 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6887 @end cartouche
6888 @noindent
6889 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6890 parameter, checks that the optimization flag is set, and aborts if it is
6891 not.
6893 @sp 1
6894 @cartouche
6895 @noindent
6896 @strong{12}.  The sequence of characters of the value returned by
6897 @code{@var{S}'Image} when some of the graphic characters of
6898 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6899 3.5(37).
6900 @end cartouche
6901 @noindent
6902 The sequence of characters is as defined by the wide character encoding
6903 method used for the source.  See section on source representation for
6904 further details.
6906 @sp 1
6907 @cartouche
6908 @noindent
6909 @strong{13}.  The predefined integer types declared in
6910 @code{Standard}.  See 3.5.4(25).
6911 @end cartouche
6912 @noindent
6913 @table @code
6914 @item Short_Short_Integer
6915 8 bit signed
6916 @item Short_Integer
6917 (Short) 16 bit signed
6918 @item Integer
6919 32 bit signed
6920 @item Long_Integer
6921 64 bit signed (Alpha OpenVMS only)
6922 32 bit signed (all other targets)
6923 @item Long_Long_Integer
6924 64 bit signed
6925 @end table
6927 @sp 1
6928 @cartouche
6929 @noindent
6930 @strong{14}.  Any nonstandard integer types and the operators defined
6931 for them.  See 3.5.4(26).
6932 @end cartouche
6933 @noindent
6934 There are no nonstandard integer types.
6936 @sp 1
6937 @cartouche
6938 @noindent
6939 @strong{15}.  Any nonstandard real types and the operators defined for
6940 them.  See 3.5.6(8).
6941 @end cartouche
6942 @noindent
6943 There are no nonstandard real types.
6945 @sp 1
6946 @cartouche
6947 @noindent
6948 @strong{16}.  What combinations of requested decimal precision and range
6949 are supported for floating point types.  See 3.5.7(7).
6950 @end cartouche
6951 @noindent
6952 The precision and range is as defined by the IEEE standard.
6954 @sp 1
6955 @cartouche
6956 @noindent
6957 @strong{17}.  The predefined floating point types declared in
6958 @code{Standard}.  See 3.5.7(16).
6959 @end cartouche
6960 @noindent
6961 @table @code
6962 @item Short_Float
6963 32 bit IEEE short
6964 @item Float
6965 (Short) 32 bit IEEE short
6966 @item Long_Float
6967 64 bit IEEE long
6968 @item Long_Long_Float
6969 64 bit IEEE long (80 bit IEEE long on x86 processors)
6970 @end table
6972 @sp 1
6973 @cartouche
6974 @noindent
6975 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6976 @end cartouche
6977 @noindent
6978 @code{Fine_Delta} is 2**(@minus{}63)
6980 @sp 1
6981 @cartouche
6982 @noindent
6983 @strong{19}.  What combinations of small, range, and digits are
6984 supported for fixed point types.  See 3.5.9(10).
6985 @end cartouche
6986 @noindent
6987 Any combinations are permitted that do not result in a small less than
6988 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6989 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6990 is 64 bits (true of all architectures except ia32), then the output from
6991 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6992 is because floating-point conversions are used to convert fixed point.
6994 @sp 1
6995 @cartouche
6996 @noindent
6997 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6998 within an unnamed @code{block_statement}.  See 3.9(10).
6999 @end cartouche
7000 @noindent
7001 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7002 decimal integer are allocated.
7004 @sp 1
7005 @cartouche
7006 @noindent
7007 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7008 @end cartouche
7009 @noindent
7010 @xref{Implementation Defined Attributes}.
7012 @sp 1
7013 @cartouche
7014 @noindent
7015 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7016 @end cartouche
7017 @noindent
7018 There are no implementation-defined time types.
7020 @sp 1
7021 @cartouche
7022 @noindent
7023 @strong{23}.  The time base associated with relative delays.
7024 @end cartouche
7025 @noindent
7026 See 9.6(20).  The time base used is that provided by the C library
7027 function @code{gettimeofday}.
7029 @sp 1
7030 @cartouche
7031 @noindent
7032 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7033 9.6(23).
7034 @end cartouche
7035 @noindent
7036 The time base used is that provided by the C library function
7037 @code{gettimeofday}.
7039 @sp 1
7040 @cartouche
7041 @noindent
7042 @strong{25}.  The time zone used for package @code{Calendar}
7043 operations.  See 9.6(24).
7044 @end cartouche
7045 @noindent
7046 The time zone used by package @code{Calendar} is the current system time zone
7047 setting for local time, as accessed by the C library function
7048 @code{localtime}.
7050 @sp 1
7051 @cartouche
7052 @noindent
7053 @strong{26}.  Any limit on @code{delay_until_statements} of
7054 @code{select_statements}.  See 9.6(29).
7055 @end cartouche
7056 @noindent
7057 There are no such limits.
7059 @sp 1
7060 @cartouche
7061 @noindent
7062 @strong{27}.  Whether or not two non overlapping parts of a composite
7063 object are independently addressable, in the case where packing, record
7064 layout, or @code{Component_Size} is specified for the object.  See
7065 9.10(1).
7066 @end cartouche
7067 @noindent
7068 Separate components are independently addressable if they do not share
7069 overlapping storage units.
7071 @sp 1
7072 @cartouche
7073 @noindent
7074 @strong{28}.  The representation for a compilation.  See 10.1(2).
7075 @end cartouche
7076 @noindent
7077 A compilation is represented by a sequence of files presented to the
7078 compiler in a single invocation of the @code{gcc} command.
7080 @sp 1
7081 @cartouche
7082 @noindent
7083 @strong{29}.  Any restrictions on compilations that contain multiple
7084 compilation_units.  See 10.1(4).
7085 @end cartouche
7086 @noindent
7087 No single file can contain more than one compilation unit, but any
7088 sequence of files can be presented to the compiler as a single
7089 compilation.
7091 @sp 1
7092 @cartouche
7093 @noindent
7094 @strong{30}.  The mechanisms for creating an environment and for adding
7095 and replacing compilation units.  See 10.1.4(3).
7096 @end cartouche
7097 @noindent
7098 See separate section on compilation model.
7100 @sp 1
7101 @cartouche
7102 @noindent
7103 @strong{31}.  The manner of explicitly assigning library units to a
7104 partition.  See 10.2(2).
7105 @end cartouche
7106 @noindent
7107 If a unit contains an Ada main program, then the Ada units for the partition
7108 are determined by recursive application of the rules in the Ada Reference
7109 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7110 are needed by the main program, and then this definition of need is applied
7111 recursively to those units, and the partition contains the transitive
7112 closure determined by this relationship.  In short, all the necessary units
7113 are included, with no need to explicitly specify the list.  If additional
7114 units are required, e.g.@: by foreign language units, then all units must be
7115 mentioned in the context clause of one of the needed Ada units.
7117 If the partition contains no main program, or if the main program is in
7118 a language other than Ada, then GNAT
7119 provides the binder options @code{-z} and @code{-n} respectively, and in
7120 this case a list of units can be explicitly supplied to the binder for
7121 inclusion in the partition (all units needed by these units will also
7122 be included automatically).  For full details on the use of these
7123 options, refer to the @cite{GNAT User's Guide} sections on Binding
7124 and Linking.
7126 @sp 1
7127 @cartouche
7128 @noindent
7129 @strong{32}.  The implementation-defined means, if any, of specifying
7130 which compilation units are needed by a given compilation unit.  See
7131 10.2(2).
7132 @end cartouche
7133 @noindent
7134 The units needed by a given compilation unit are as defined in
7135 the Ada Reference Manual section 10.2(2-6).  There are no
7136 implementation-defined pragmas or other implementation-defined
7137 means for specifying needed units.
7139 @sp 1
7140 @cartouche
7141 @noindent
7142 @strong{33}.  The manner of designating the main subprogram of a
7143 partition.  See 10.2(7).
7144 @end cartouche
7145 @noindent
7146 The main program is designated by providing the name of the
7147 corresponding @file{ALI} file as the input parameter to the binder.
7149 @sp 1
7150 @cartouche
7151 @noindent
7152 @strong{34}.  The order of elaboration of @code{library_items}.  See
7153 10.2(18).
7154 @end cartouche
7155 @noindent
7156 The first constraint on ordering is that it meets the requirements of
7157 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
7158 implementation dependent choices, which are resolved by first
7159 elaborating bodies as early as possible (i.e.@: in preference to specs
7160 where there is a choice), and second by evaluating the immediate with
7161 clauses of a unit to determine the probably best choice, and
7162 third by elaborating in alphabetical order of unit names
7163 where a choice still remains.
7165 @sp 1
7166 @cartouche
7167 @noindent
7168 @strong{35}.  Parameter passing and function return for the main
7169 subprogram.  See 10.2(21).
7170 @end cartouche
7171 @noindent
7172 The main program has no parameters.  It may be a procedure, or a function
7173 returning an integer type.  In the latter case, the returned integer
7174 value is the return code of the program (overriding any value that
7175 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7177 @sp 1
7178 @cartouche
7179 @noindent
7180 @strong{36}.  The mechanisms for building and running partitions.  See
7181 10.2(24).
7182 @end cartouche
7183 @noindent
7184 GNAT itself supports programs with only a single partition.  The GNATDIST
7185 tool provided with the GLADE package (which also includes an implementation
7186 of the PCS) provides a completely flexible method for building and running
7187 programs consisting of multiple partitions.  See the separate GLADE manual
7188 for details.
7190 @sp 1
7191 @cartouche
7192 @noindent
7193 @strong{37}.  The details of program execution, including program
7194 termination.  See 10.2(25).
7195 @end cartouche
7196 @noindent
7197 See separate section on compilation model.
7199 @sp 1
7200 @cartouche
7201 @noindent
7202 @strong{38}.  The semantics of any non-active partitions supported by the
7203 implementation.  See 10.2(28).
7204 @end cartouche
7205 @noindent
7206 Passive partitions are supported on targets where shared memory is
7207 provided by the operating system.  See the GLADE reference manual for
7208 further details.
7210 @sp 1
7211 @cartouche
7212 @noindent
7213 @strong{39}.  The information returned by @code{Exception_Message}.  See
7214 11.4.1(10).
7215 @end cartouche
7216 @noindent
7217 Exception message returns the null string unless a specific message has
7218 been passed by the program.
7220 @sp 1
7221 @cartouche
7222 @noindent
7223 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7224 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7225 @end cartouche
7226 @noindent
7227 Blocks have implementation defined names of the form @code{B@var{nnn}}
7228 where @var{nnn} is an integer.
7230 @sp 1
7231 @cartouche
7232 @noindent
7233 @strong{41}.  The information returned by
7234 @code{Exception_Information}.  See 11.4.1(13).
7235 @end cartouche
7236 @noindent
7237 @code{Exception_Information} returns a string in the following format:
7239 @smallexample
7240 @emph{Exception_Name:} nnnnn
7241 @emph{Message:} mmmmm
7242 @emph{PID:} ppp
7243 @emph{Call stack traceback locations:}
7244 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7245 @end smallexample
7247 @noindent
7248 where
7250 @itemize @bullet
7251 @item
7252 @code{nnnn} is the fully qualified name of the exception in all upper
7253 case letters. This line is always present.
7255 @item
7256 @code{mmmm} is the message (this line present only if message is non-null)
7258 @item
7259 @code{ppp} is the Process Id value as a decimal integer (this line is
7260 present only if the Process Id is nonzero). Currently we are
7261 not making use of this field.
7263 @item
7264 The Call stack traceback locations line and the following values
7265 are present only if at least one traceback location was recorded.
7266 The values are given in C style format, with lower case letters
7267 for a-f, and only as many digits present as are necessary.
7268 @end itemize
7270 @noindent
7271 The line terminator sequence at the end of each line, including
7272 the last line is a single @code{LF} character (@code{16#0A#}).
7274 @sp 1
7275 @cartouche
7276 @noindent
7277 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7278 @end cartouche
7279 @noindent
7280 No implementation-defined check names are supported.
7282 @sp 1
7283 @cartouche
7284 @noindent
7285 @strong{43}.  The interpretation of each aspect of representation.  See
7286 13.1(20).
7287 @end cartouche
7288 @noindent
7289 See separate section on data representations.
7291 @sp 1
7292 @cartouche
7293 @noindent
7294 @strong{44}.  Any restrictions placed upon representation items.  See
7295 13.1(20).
7296 @end cartouche
7297 @noindent
7298 See separate section on data representations.
7300 @sp 1
7301 @cartouche
7302 @noindent
7303 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7304 13.3(48).
7305 @end cartouche
7306 @noindent
7307 Size for an indefinite subtype is the maximum possible size, except that
7308 for the case of a subprogram parameter, the size of the parameter object
7309 is the actual size.
7311 @sp 1
7312 @cartouche
7313 @noindent
7314 @strong{46}.  The default external representation for a type tag.  See
7315 13.3(75).
7316 @end cartouche
7317 @noindent
7318 The default external representation for a type tag is the fully expanded
7319 name of the type in upper case letters.
7321 @sp 1
7322 @cartouche
7323 @noindent
7324 @strong{47}.  What determines whether a compilation unit is the same in
7325 two different partitions.  See 13.3(76).
7326 @end cartouche
7327 @noindent
7328 A compilation unit is the same in two different partitions if and only
7329 if it derives from the same source file.
7331 @sp 1
7332 @cartouche
7333 @noindent
7334 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7335 @end cartouche
7336 @noindent
7337 The only implementation defined component is the tag for a tagged type,
7338 which contains a pointer to the dispatching table.
7340 @sp 1
7341 @cartouche
7342 @noindent
7343 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7344 ordering.  See 13.5.3(5).
7345 @end cartouche
7346 @noindent
7347 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7348 implementation, so no non-default bit ordering is supported.  The default
7349 bit ordering corresponds to the natural endianness of the target architecture.
7351 @sp 1
7352 @cartouche
7353 @noindent
7354 @strong{50}.  The contents of the visible part of package @code{System}
7355 and its language-defined children.  See 13.7(2).
7356 @end cartouche
7357 @noindent
7358 See the definition of these packages in files @file{system.ads} and
7359 @file{s-stoele.ads}.
7361 @sp 1
7362 @cartouche
7363 @noindent
7364 @strong{51}.  The contents of the visible part of package
7365 @code{System.Machine_Code}, and the meaning of
7366 @code{code_statements}.  See 13.8(7).
7367 @end cartouche
7368 @noindent
7369 See the definition and documentation in file @file{s-maccod.ads}.
7371 @sp 1
7372 @cartouche
7373 @noindent
7374 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7375 @end cartouche
7376 @noindent
7377 Unchecked conversion between types of the same size
7378 results in an uninterpreted transmission of the bits from one type
7379 to the other.  If the types are of unequal sizes, then in the case of
7380 discrete types, a shorter source is first zero or sign extended as
7381 necessary, and a shorter target is simply truncated on the left.
7382 For all non-discrete types, the source is first copied if necessary
7383 to ensure that the alignment requirements of the target are met, then
7384 a pointer is constructed to the source value, and the result is obtained
7385 by dereferencing this pointer after converting it to be a pointer to the
7386 target type. Unchecked conversions where the target subtype is an
7387 unconstrained array are not permitted. If the target alignment is
7388 greater than the source alignment, then a copy of the result is
7389 made with appropriate alignment
7391 @sp 1
7392 @cartouche
7393 @noindent
7394 @strong{53}.  The manner of choosing a storage pool for an access type
7395 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7396 @end cartouche
7397 @noindent
7398 There are 3 different standard pools used by the compiler when
7399 @code{Storage_Pool} is not specified depending whether the type is local
7400 to a subprogram or defined at the library level and whether
7401 @code{Storage_Size}is specified or not.  See documentation in the runtime
7402 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7403 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7404 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7405 default pools used.
7407 @sp 1
7408 @cartouche
7409 @noindent
7410 @strong{54}.  Whether or not the implementation provides user-accessible
7411 names for the standard pool type(s).  See 13.11(17).
7412 @end cartouche
7413 @noindent
7415 See documentation in the sources of the run time mentioned in paragraph
7416 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7417 these units.
7419 @sp 1
7420 @cartouche
7421 @noindent
7422 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7423 @end cartouche
7424 @noindent
7425 @code{Storage_Size} is measured in storage units, and refers to the
7426 total space available for an access type collection, or to the primary
7427 stack space for a task.
7429 @sp 1
7430 @cartouche
7431 @noindent
7432 @strong{56}.  Implementation-defined aspects of storage pools.  See
7433 13.11(22).
7434 @end cartouche
7435 @noindent
7436 See documentation in the sources of the run time mentioned in paragraph
7437 @strong{53} for details on GNAT-defined aspects of storage pools.
7439 @sp 1
7440 @cartouche
7441 @noindent
7442 @strong{57}.  The set of restrictions allowed in a pragma
7443 @code{Restrictions}.  See 13.12(7).
7444 @end cartouche
7445 @noindent
7446 All RM defined Restriction identifiers are implemented.  The following
7447 additional restriction identifiers are provided.  There are two separate
7448 lists of implementation dependent restriction identifiers.  The first
7449 set requires consistency throughout a partition (in other words, if the
7450 restriction identifier is used for any compilation unit in the partition,
7451 then all compilation units in the partition must obey the restriction.
7453 @table @code
7455 @item Simple_Barriers
7456 @findex Simple_Barriers
7457 This restriction ensures at compile time that barriers in entry declarations
7458 for protected types are restricted to either static boolean expressions or
7459 references to simple boolean variables defined in the private part of the
7460 protected type.  No other form of entry barriers is permitted.  This is one
7461 of the restrictions of the Ravenscar profile for limited tasking (see also
7462 pragma @code{Profile (Ravenscar)}).
7464 @item Max_Entry_Queue_Length => Expr
7465 @findex Max_Entry_Queue_Length
7466 This restriction is a declaration that any protected entry compiled in
7467 the scope of the restriction has at most the specified number of
7468 tasks waiting on the entry
7469 at any one time, and so no queue is required.  This restriction is not
7470 checked at compile time.  A program execution is erroneous if an attempt
7471 is made to queue more than the specified number of tasks on such an entry.
7473 @item No_Calendar
7474 @findex No_Calendar
7475 This restriction ensures at compile time that there is no implicit or
7476 explicit dependence on the package @code{Ada.Calendar}.
7478 @item No_Direct_Boolean_Operators
7479 @findex No_Direct_Boolean_Operators
7480 This restriction ensures that no logical (and/or/xor) or comparison
7481 operators are used on operands of type Boolean (or any type derived
7482 from Boolean). This is intended for use in safety critical programs
7483 where the certification protocol requires the use of short-circuit
7484 (and then, or else) forms for all composite boolean operations.
7486 @item No_Dispatching_Calls
7487 @findex No_Dispatching_Calls
7488 This restriction ensures at compile time that the code generated by the
7489 compiler involves no dispatching calls. The use of this restriction allows the
7490 safe use of record extensions, classwide membership tests and other classwide
7491 features not involving implicit dispatching. This restriction ensures that
7492 the code contains no indirect calls through a dispatching mechanism. Note that
7493 this includes internally-generated calls created by the compiler, for example
7494 in the implementation of class-wide objects assignments. The
7495 membership test is allowed in the presence of this restriction, because its
7496 implementation requires no dispatching.
7497 This restriction is comparable to the official Ada restriction
7498 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7499 all classwide constructs that do not imply dispatching.
7500 The following example indicates constructs that violate this restriction.
7502 @smallexample
7503 package Pkg is
7504   type T is tagged record
7505     Data : Natural;
7506   end record;
7507   procedure P (X : T);
7509   type DT is new T with record
7510     More_Data : Natural;
7511   end record;
7512   procedure Q (X : DT);
7513 end Pkg;
7515 with Pkg; use Pkg;
7516 procedure Example is
7517   procedure Test (O : T'Class) is
7518     N : Natural  := O'Size;--  Error: Dispatching call
7519     C : T'Class := O;      --  Error: implicit Dispatching Call
7520   begin
7521     if O in DT'Class then  --  OK   : Membership test
7522        Q (DT (O));         --  OK   : Type conversion plus direct call
7523     else
7524        P (O);              --  Error: Dispatching call
7525     end if;
7526   end Test;
7528   Obj : DT;
7529 begin
7530   P (Obj);                 --  OK   : Direct call
7531   P (T (Obj));             --  OK   : Type conversion plus direct call
7532   P (T'Class (Obj));       --  Error: Dispatching call
7534   Test (Obj);              --  OK   : Type conversion
7536   if Obj in T'Class then   --  OK   : Membership test
7537      null;
7538   end if;
7539 end Example;
7540 @end smallexample
7542 @item No_Dynamic_Attachment
7543 @findex No_Dynamic_Attachment
7544 This restriction ensures that there is no call to any of the operations
7545 defined in package Ada.Interrupts.
7547 @item No_Enumeration_Maps
7548 @findex No_Enumeration_Maps
7549 This restriction ensures at compile time that no operations requiring
7550 enumeration maps are used (that is Image and Value attributes applied
7551 to enumeration types).
7553 @item No_Entry_Calls_In_Elaboration_Code
7554 @findex No_Entry_Calls_In_Elaboration_Code
7555 This restriction ensures at compile time that no task or protected entry
7556 calls are made during elaboration code.  As a result of the use of this
7557 restriction, the compiler can assume that no code past an accept statement
7558 in a task can be executed at elaboration time.
7560 @item No_Exception_Handlers
7561 @findex No_Exception_Handlers
7562 This restriction ensures at compile time that there are no explicit
7563 exception handlers. It also indicates that no exception propagation will
7564 be provided. In this mode, exceptions may be raised but will result in
7565 an immediate call to the last chance handler, a routine that the user
7566 must define with the following profile:
7568    procedure Last_Chance_Handler
7569      (Source_Location : System.Address; Line : Integer);
7570    pragma Export (C, Last_Chance_Handler,
7571                   "__gnat_last_chance_handler");
7573    The parameter is a C null-terminated string representing a message to be
7574    associated with the exception (typically the source location of the raise
7575    statement generated by the compiler). The Line parameter when nonzero
7576    represents the line number in the source program where the raise occurs.
7578 @item No_Exception_Streams
7579 @findex No_Exception_Streams
7580 This restriction ensures at compile time that no stream operations for
7581 types Exception_Id or Exception_Occurrence are used. This also makes it
7582 impossible to pass exceptions to or from a partition with this restriction
7583 in a distributed environment. If this exception is active, then the generated
7584 code is simplified by omitting the otherwise-required global registration
7585 of exceptions when they are declared.
7587 @item No_Implicit_Conditionals
7588 @findex No_Implicit_Conditionals
7589 This restriction ensures that the generated code does not contain any
7590 implicit conditionals, either by modifying the generated code where possible,
7591 or by rejecting any construct that would otherwise generate an implicit
7592 conditional. Note that this check does not include run time constraint
7593 checks, which on some targets may generate implicit conditionals as
7594 well. To control the latter, constraint checks can be suppressed in the
7595 normal manner. Constructs generating implicit conditionals include comparisons
7596 of composite objects and the Max/Min attributes.
7598 @item No_Implicit_Dynamic_Code
7599 @findex No_Implicit_Dynamic_Code
7600 This restriction prevents the compiler from building ``trampolines''.
7601 This is a structure that is built on the stack and contains dynamic
7602 code to be executed at run time. A trampoline is needed to indirectly
7603 address a nested subprogram (that is a subprogram that is not at the
7604 library level). The restriction prevents the use of any of the
7605 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7606 being applied to a subprogram that is not at the library level.
7608 @item No_Implicit_Loops
7609 @findex No_Implicit_Loops
7610 This restriction ensures that the generated code does not contain any
7611 implicit @code{for} loops, either by modifying
7612 the generated code where possible,
7613 or by rejecting any construct that would otherwise generate an implicit
7614 @code{for} loop.
7616 @item No_Initialize_Scalars
7617 @findex No_Initialize_Scalars
7618 This restriction ensures that no unit in the partition is compiled with
7619 pragma Initialize_Scalars. This allows the generation of more efficient
7620 code, and in particular eliminates dummy null initialization routines that
7621 are otherwise generated for some record and array types.
7623 @item No_Local_Protected_Objects
7624 @findex No_Local_Protected_Objects
7625 This restriction ensures at compile time that protected objects are
7626 only declared at the library level.
7628 @item No_Protected_Type_Allocators
7629 @findex No_Protected_Type_Allocators
7630 This restriction ensures at compile time that there are no allocator
7631 expressions that attempt to allocate protected objects.
7633 @item No_Secondary_Stack
7634 @findex No_Secondary_Stack
7635 This restriction ensures at compile time that the generated code does not
7636 contain any reference to the secondary stack.  The secondary stack is used
7637 to implement functions returning unconstrained objects (arrays or records)
7638 on some targets.
7640 @item No_Select_Statements
7641 @findex No_Select_Statements
7642 This restriction ensures at compile time no select statements of any kind
7643 are permitted, that is the keyword @code{select} may not appear.
7644 This is one of the restrictions of the Ravenscar
7645 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7647 @item No_Standard_Storage_Pools
7648 @findex No_Standard_Storage_Pools
7649 This restriction ensures at compile time that no access types
7650 use the standard default storage pool.  Any access type declared must
7651 have an explicit Storage_Pool attribute defined specifying a
7652 user-defined storage pool.
7654 @item No_Streams
7655 @findex No_Streams
7656 This restriction ensures at compile/bind time that there are no
7657 stream objects created (and therefore no actual stream operations).
7658 This restriction does not forbid dependences on the package
7659 @code{Ada.Streams}. So it is permissible to with
7660 @code{Ada.Streams} (or another package that does so itself)
7661 as long as no actual stream objects are created.
7663 @item No_Task_Attributes_Package
7664 @findex No_Task_Attributes_Package
7665 This restriction ensures at compile time that there are no implicit or
7666 explicit dependencies on the package @code{Ada.Task_Attributes}.
7668 @item No_Task_Termination
7669 @findex No_Task_Termination
7670 This restriction ensures at compile time that no terminate alternatives
7671 appear in any task body.
7673 @item No_Tasking
7674 @findex No_Tasking
7675 This restriction prevents the declaration of tasks or task types throughout
7676 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7677 except that violations are caught at compile time and cause an error message
7678 to be output either by the compiler or binder.
7680 @item Static_Priorities
7681 @findex Static_Priorities
7682 This restriction ensures at compile time that all priority expressions
7683 are static, and that there are no dependencies on the package
7684 @code{Ada.Dynamic_Priorities}.
7686 @item Static_Storage_Size
7687 @findex Static_Storage_Size
7688 This restriction ensures at compile time that any expression appearing
7689 in a Storage_Size pragma or attribute definition clause is static.
7691 @end table
7693 @noindent
7694 The second set of implementation dependent restriction identifiers
7695 does not require partition-wide consistency.
7696 The restriction may be enforced for a single
7697 compilation unit without any effect on any of the
7698 other compilation units in the partition.
7700 @table @code
7702 @item No_Elaboration_Code
7703 @findex No_Elaboration_Code
7704 This restriction ensures at compile time that no elaboration code is
7705 generated.  Note that this is not the same condition as is enforced
7706 by pragma @code{Preelaborate}.  There are cases in which pragma
7707 @code{Preelaborate} still permits code to be generated (e.g.@: code
7708 to initialize a large array to all zeroes), and there are cases of units
7709 which do not meet the requirements for pragma @code{Preelaborate},
7710 but for which no elaboration code is generated.  Generally, it is
7711 the case that preelaborable units will meet the restrictions, with
7712 the exception of large aggregates initialized with an others_clause,
7713 and exception declarations (which generate calls to a run-time
7714 registry procedure).  This restriction is enforced on
7715 a unit by unit basis, it need not be obeyed consistently
7716 throughout a partition.
7718 In the case of aggregates with others, if the aggregate has a dynamic
7719 size, there is no way to eliminate the elaboration code (such dynamic
7720 bounds would be incompatible with @code{Preelaborate} in any case. If
7721 the bounds are static, then use of this restriction actually modifies
7722 the code choice of the compiler to avoid generating a loop, and instead
7723 generate the aggregate statically if possible, no matter how many times
7724 the data for the others clause must be repeatedly generated.
7726 It is not possible to precisely document
7727 the constructs which are compatible with this restriction, since,
7728 unlike most other restrictions, this is not a restriction on the
7729 source code, but a restriction on the generated object code. For
7730 example, if the source contains a declaration:
7732 @smallexample
7733    Val : constant Integer := X;
7734 @end smallexample
7736 @noindent
7737 where X is not a static constant, it may be possible, depending
7738 on complex optimization circuitry, for the compiler to figure
7739 out the value of X at compile time, in which case this initialization
7740 can be done by the loader, and requires no initialization code. It
7741 is not possible to document the precise conditions under which the
7742 optimizer can figure this out.
7744 Note that this the implementation of this restriction requires full
7745 code generation. If it is used in conjunction with "semantics only"
7746 checking, then some cases of violations may be missed.
7748 @item No_Entry_Queue
7749 @findex No_Entry_Queue
7750 This restriction is a declaration that any protected entry compiled in
7751 the scope of the restriction has at most one task waiting on the entry
7752 at any one time, and so no queue is required.  This restriction is not
7753 checked at compile time.  A program execution is erroneous if an attempt
7754 is made to queue a second task on such an entry.
7756 @item No_Implementation_Attributes
7757 @findex No_Implementation_Attributes
7758 This restriction checks at compile time that no GNAT-defined attributes
7759 are present.  With this restriction, the only attributes that can be used
7760 are those defined in the Ada 95 Reference Manual.
7762 @item No_Implementation_Pragmas
7763 @findex No_Implementation_Pragmas
7764 This restriction checks at compile time that no GNAT-defined pragmas
7765 are present.  With this restriction, the only pragmas that can be used
7766 are those defined in the Ada 95 Reference Manual.
7768 @item No_Implementation_Restrictions
7769 @findex No_Implementation_Restrictions
7770 This restriction checks at compile time that no GNAT-defined restriction
7771 identifiers (other than @code{No_Implementation_Restrictions} itself)
7772 are present.  With this restriction, the only other restriction identifiers
7773 that can be used are those defined in the Ada 95 Reference Manual.
7775 @item No_Wide_Characters
7776 @findex No_Wide_Characters
7777 This restriction ensures at compile time that no uses of the types
7778 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7779 wide types
7780 appear, and that no wide or wide wide string or character literals
7781 appear in the program (that is literals representing characters not in
7782 type @code{Character}.
7784 @end table
7786 @sp 1
7787 @cartouche
7788 @noindent
7789 @strong{58}.  The consequences of violating limitations on
7790 @code{Restrictions} pragmas.  See 13.12(9).
7791 @end cartouche
7792 @noindent
7793 Restrictions that can be checked at compile time result in illegalities
7794 if violated.  Currently there are no other consequences of violating
7795 restrictions.
7797 @sp 1
7798 @cartouche
7799 @noindent
7800 @strong{59}.  The representation used by the @code{Read} and
7801 @code{Write} attributes of elementary types in terms of stream
7802 elements.  See 13.13.2(9).
7803 @end cartouche
7804 @noindent
7805 The representation is the in-memory representation of the base type of
7806 the type, using the number of bits corresponding to the
7807 @code{@var{type}'Size} value, and the natural ordering of the machine.
7809 @sp 1
7810 @cartouche
7811 @noindent
7812 @strong{60}.  The names and characteristics of the numeric subtypes
7813 declared in the visible part of package @code{Standard}.  See A.1(3).
7814 @end cartouche
7815 @noindent
7816 See items describing the integer and floating-point types supported.
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{61}.  The accuracy actually achieved by the elementary
7822 functions.  See A.5.1(1).
7823 @end cartouche
7824 @noindent
7825 The elementary functions correspond to the functions available in the C
7826 library.  Only fast math mode is implemented.
7828 @sp 1
7829 @cartouche
7830 @noindent
7831 @strong{62}.  The sign of a zero result from some of the operators or
7832 functions in @code{Numerics.Generic_Elementary_Functions}, when
7833 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7834 @end cartouche
7835 @noindent
7836 The sign of zeroes follows the requirements of the IEEE 754 standard on
7837 floating-point.
7839 @sp 1
7840 @cartouche
7841 @noindent
7842 @strong{63}.  The value of
7843 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7844 @end cartouche
7845 @noindent
7846 Maximum image width is 649, see library file @file{a-numran.ads}.
7848 @sp 1
7849 @cartouche
7850 @noindent
7851 @strong{64}.  The value of
7852 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7853 @end cartouche
7854 @noindent
7855 Maximum image width is 80, see library file @file{a-nudira.ads}.
7857 @sp 1
7858 @cartouche
7859 @noindent
7860 @strong{65}.  The algorithms for random number generation.  See
7861 A.5.2(32).
7862 @end cartouche
7863 @noindent
7864 The algorithm is documented in the source files @file{a-numran.ads} and
7865 @file{a-numran.adb}.
7867 @sp 1
7868 @cartouche
7869 @noindent
7870 @strong{66}.  The string representation of a random number generator's
7871 state.  See A.5.2(38).
7872 @end cartouche
7873 @noindent
7874 See the documentation contained in the file @file{a-numran.adb}.
7876 @sp 1
7877 @cartouche
7878 @noindent
7879 @strong{67}.  The minimum time interval between calls to the
7880 time-dependent Reset procedure that are guaranteed to initiate different
7881 random number sequences.  See A.5.2(45).
7882 @end cartouche
7883 @noindent
7884 The minimum period between reset calls to guarantee distinct series of
7885 random numbers is one microsecond.
7887 @sp 1
7888 @cartouche
7889 @noindent
7890 @strong{68}.  The values of the @code{Model_Mantissa},
7891 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7892 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7893 Annex is not supported.  See A.5.3(72).
7894 @end cartouche
7895 @noindent
7896 See the source file @file{ttypef.ads} for the values of all numeric
7897 attributes.
7899 @sp 1
7900 @cartouche
7901 @noindent
7902 @strong{69}.  Any implementation-defined characteristics of the
7903 input-output packages.  See A.7(14).
7904 @end cartouche
7905 @noindent
7906 There are no special implementation defined characteristics for these
7907 packages.
7909 @sp 1
7910 @cartouche
7911 @noindent
7912 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7913 A.9(10).
7914 @end cartouche
7915 @noindent
7916 All type representations are contiguous, and the @code{Buffer_Size} is
7917 the value of @code{@var{type}'Size} rounded up to the next storage unit
7918 boundary.
7920 @sp 1
7921 @cartouche
7922 @noindent
7923 @strong{71}.  External files for standard input, standard output, and
7924 standard error See A.10(5).
7925 @end cartouche
7926 @noindent
7927 These files are mapped onto the files provided by the C streams
7928 libraries.  See source file @file{i-cstrea.ads} for further details.
7930 @sp 1
7931 @cartouche
7932 @noindent
7933 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7934 A.10.9(36).
7935 @end cartouche
7936 @noindent
7937 If more digits are requested in the output than are represented by the
7938 precision of the value, zeroes are output in the corresponding least
7939 significant digit positions.
7941 @sp 1
7942 @cartouche
7943 @noindent
7944 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7945 @code{Command_Name}.  See A.15(1).
7946 @end cartouche
7947 @noindent
7948 These are mapped onto the @code{argv} and @code{argc} parameters of the
7949 main program in the natural manner.
7951 @sp 1
7952 @cartouche
7953 @noindent
7954 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7955 @end cartouche
7956 @noindent
7957 The following convention names are supported
7959 @table @code
7960 @item  Ada
7962 @item Assembler
7963 Assembly language
7964 @item Asm
7965 Synonym for Assembler
7966 @item Assembly
7967 Synonym for Assembler
7968 @item C
7970 @item C_Pass_By_Copy
7971 Allowed only for record types, like C, but also notes that record
7972 is to be passed by copy rather than reference.
7973 @item COBOL
7974 COBOL
7975 @item CPP
7977 @item Default
7978 Treated the same as C
7979 @item External
7980 Treated the same as C
7981 @item Fortran
7982 Fortran
7983 @item Intrinsic
7984 For support of pragma @code{Import} with convention Intrinsic, see
7985 separate section on Intrinsic Subprograms.
7986 @item Stdcall
7987 Stdcall (used for Windows implementations only).  This convention correspond
7988 to the WINAPI (previously called Pascal convention) C/C++ convention under
7989 Windows.  A function with this convention cleans the stack before exit.
7990 @item DLL
7991 Synonym for Stdcall
7992 @item Win32
7993 Synonym for Stdcall
7994 @item Stubbed
7995 Stubbed is a special convention used to indicate that the body of the
7996 subprogram will be entirely ignored.  Any call to the subprogram
7997 is converted into a raise of the @code{Program_Error} exception.  If a
7998 pragma @code{Import} specifies convention @code{stubbed} then no body need
7999 be present at all.  This convention is useful during development for the
8000 inclusion of subprograms whose body has not yet been written.
8002 @end table
8003 @noindent
8004 In addition, all otherwise unrecognized convention names are also
8005 treated as being synonymous with convention C@.  In all implementations
8006 except for VMS, use of such other names results in a warning.  In VMS
8007 implementations, these names are accepted silently.
8009 @sp 1
8010 @cartouche
8011 @noindent
8012 @strong{75}.  The meaning of link names.  See B.1(36).
8013 @end cartouche
8014 @noindent
8015 Link names are the actual names used by the linker.
8017 @sp 1
8018 @cartouche
8019 @noindent
8020 @strong{76}.  The manner of choosing link names when neither the link
8021 name nor the address of an imported or exported entity is specified.  See
8022 B.1(36).
8023 @end cartouche
8024 @noindent
8025 The default linker name is that which would be assigned by the relevant
8026 external language, interpreting the Ada name as being in all lower case
8027 letters.
8029 @sp 1
8030 @cartouche
8031 @noindent
8032 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8033 @end cartouche
8034 @noindent
8035 The string passed to @code{Linker_Options} is presented uninterpreted as
8036 an argument to the link command, unless it contains Ascii.NUL characters.
8037 NUL characters if they appear act as argument separators, so for example
8039 @smallexample @c ada
8040 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8041 @end smallexample
8043 @noindent
8044 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8045 linker. The order of linker options is preserved for a given unit. The final
8046 list of options passed to the linker is in reverse order of the elaboration
8047 order. For example, linker options fo a body always appear before the options
8048 from the corresponding package spec.
8050 @sp 1
8051 @cartouche
8052 @noindent
8053 @strong{78}.  The contents of the visible part of package
8054 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8055 @end cartouche
8056 @noindent
8057 See files with prefix @file{i-} in the distributed library.
8059 @sp 1
8060 @cartouche
8061 @noindent
8062 @strong{79}.  Implementation-defined children of package
8063 @code{Interfaces}.  The contents of the visible part of package
8064 @code{Interfaces}.  See B.2(11).
8065 @end cartouche
8066 @noindent
8067 See files with prefix @file{i-} in the distributed library.
8069 @sp 1
8070 @cartouche
8071 @noindent
8072 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8073 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8074 @code{COBOL_Character}; and the initialization of the variables
8075 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8076 @code{Interfaces.COBOL}.  See B.4(50).
8077 @end cartouche
8078 @noindent
8079 @table @code
8080 @item Floating
8081 Float
8082 @item Long_Floating
8083 (Floating) Long_Float
8084 @item Binary
8085 Integer
8086 @item Long_Binary
8087 Long_Long_Integer
8088 @item Decimal_Element
8089 Character
8090 @item COBOL_Character
8091 Character
8092 @end table
8094 @noindent
8095 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8097 @sp 1
8098 @cartouche
8099 @noindent
8100 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8101 @end cartouche
8102 @noindent
8103 See documentation in file @file{s-maccod.ads} in the distributed library.
8105 @sp 1
8106 @cartouche
8107 @noindent
8108 @strong{82}.  Implementation-defined aspects of access to machine
8109 operations.  See C.1(9).
8110 @end cartouche
8111 @noindent
8112 See documentation in file @file{s-maccod.ads} in the distributed library.
8114 @sp 1
8115 @cartouche
8116 @noindent
8117 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8118 @end cartouche
8119 @noindent
8120 Interrupts are mapped to signals or conditions as appropriate.  See
8121 definition of unit
8122 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8123 on the interrupts supported on a particular target.
8125 @sp 1
8126 @cartouche
8127 @noindent
8128 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8129 C.4(13).
8130 @end cartouche
8131 @noindent
8132 GNAT does not permit a partition to be restarted without reloading,
8133 except under control of the debugger.
8135 @sp 1
8136 @cartouche
8137 @noindent
8138 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8139 @end cartouche
8140 @noindent
8141 Pragma @code{Discard_Names} causes names of enumeration literals to
8142 be suppressed.  In the presence of this pragma, the Image attribute
8143 provides the image of the Pos of the literal, and Value accepts
8144 Pos values.
8146 @sp 1
8147 @cartouche
8148 @noindent
8149 @strong{86}.  The result of the @code{Task_Identification.Image}
8150 attribute.  See C.7.1(7).
8151 @end cartouche
8152 @noindent
8153 The result of this attribute is an 8-digit hexadecimal string
8154 representing the virtual address of the task control block.
8156 @sp 1
8157 @cartouche
8158 @noindent
8159 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8160 or interrupt handler.  See C.7.1(17).
8161 @end cartouche
8162 @noindent
8163 Protected entries or interrupt handlers can be executed by any
8164 convenient thread, so the value of @code{Current_Task} is undefined.
8166 @sp 1
8167 @cartouche
8168 @noindent
8169 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8170 body or interrupt handler.  See C.7.1(19).
8171 @end cartouche
8172 @noindent
8173 The effect of calling @code{Current_Task} from an entry body or
8174 interrupt handler is to return the identification of the task currently
8175 executing the code.
8177 @sp 1
8178 @cartouche
8179 @noindent
8180 @strong{89}.  Implementation-defined aspects of
8181 @code{Task_Attributes}.  See C.7.2(19).
8182 @end cartouche
8183 @noindent
8184 There are no implementation-defined aspects of @code{Task_Attributes}.
8186 @sp 1
8187 @cartouche
8188 @noindent
8189 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8190 @end cartouche
8191 @noindent
8192 The metrics information for GNAT depends on the performance of the
8193 underlying operating system.  The sources of the run-time for tasking
8194 implementation, together with the output from @code{-gnatG} can be
8195 used to determine the exact sequence of operating systems calls made
8196 to implement various tasking constructs.  Together with appropriate
8197 information on the performance of the underlying operating system,
8198 on the exact target in use, this information can be used to determine
8199 the required metrics.
8201 @sp 1
8202 @cartouche
8203 @noindent
8204 @strong{91}.  The declarations of @code{Any_Priority} and
8205 @code{Priority}.  See D.1(11).
8206 @end cartouche
8207 @noindent
8208 See declarations in file @file{system.ads}.
8210 @sp 1
8211 @cartouche
8212 @noindent
8213 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8214 @end cartouche
8215 @noindent
8216 There are no implementation-defined execution resources.
8218 @sp 1
8219 @cartouche
8220 @noindent
8221 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8222 access to a protected object keeps its processor busy.  See D.2.1(3).
8223 @end cartouche
8224 @noindent
8225 On a multi-processor, a task that is waiting for access to a protected
8226 object does not keep its processor busy.
8228 @sp 1
8229 @cartouche
8230 @noindent
8231 @strong{94}.  The affect of implementation defined execution resources
8232 on task dispatching.  See D.2.1(9).
8233 @end cartouche
8234 @noindent
8235 @c SGI info
8236 @ignore
8237 Tasks map to IRIX threads, and the dispatching policy is as defined by
8238 the IRIX implementation of threads.
8239 @end ignore
8240 Tasks map to threads in the threads package used by GNAT@.  Where possible
8241 and appropriate, these threads correspond to native threads of the
8242 underlying operating system.
8244 @sp 1
8245 @cartouche
8246 @noindent
8247 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8248 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8249 @end cartouche
8250 @noindent
8251 There are no implementation-defined policy-identifiers allowed in this
8252 pragma.
8254 @sp 1
8255 @cartouche
8256 @noindent
8257 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8258 D.2.2(16).
8259 @end cartouche
8260 @noindent
8261 Execution of a task cannot be preempted by the implementation processing
8262 of delay expirations for lower priority tasks.
8264 @sp 1
8265 @cartouche
8266 @noindent
8267 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8268 @end cartouche
8269 @noindent
8270 @c SGI info:
8271 @ignore
8272 Tasks map to IRIX threads, and the dispatching policy is as defined by
8273 the IRIX implementation of threads.
8274 @end ignore
8275 The policy is the same as that of the underlying threads implementation.
8277 @sp 1
8278 @cartouche
8279 @noindent
8280 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8281 in a pragma @code{Locking_Policy}.  See D.3(4).
8282 @end cartouche
8283 @noindent
8284 The only implementation defined policy permitted in GNAT is
8285 @code{Inheritance_Locking}.  On targets that support this policy, locking
8286 is implemented by inheritance, i.e.@: the task owning the lock operates
8287 at a priority equal to the highest priority of any task currently
8288 requesting the lock.
8290 @sp 1
8291 @cartouche
8292 @noindent
8293 @strong{99}.  Default ceiling priorities.  See D.3(10).
8294 @end cartouche
8295 @noindent
8296 The ceiling priority of protected objects of the type
8297 @code{System.Interrupt_Priority'Last} as described in the Ada 95
8298 Reference Manual D.3(10),
8300 @sp 1
8301 @cartouche
8302 @noindent
8303 @strong{100}.  The ceiling of any protected object used internally by
8304 the implementation.  See D.3(16).
8305 @end cartouche
8306 @noindent
8307 The ceiling priority of internal protected objects is
8308 @code{System.Priority'Last}.
8310 @sp 1
8311 @cartouche
8312 @noindent
8313 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8314 @end cartouche
8315 @noindent
8316 There are no implementation-defined queuing policies.
8318 @sp 1
8319 @cartouche
8320 @noindent
8321 @strong{102}.  On a multiprocessor, any conditions that cause the
8322 completion of an aborted construct to be delayed later than what is
8323 specified for a single processor.  See D.6(3).
8324 @end cartouche
8325 @noindent
8326 The semantics for abort on a multi-processor is the same as on a single
8327 processor, there are no further delays.
8329 @sp 1
8330 @cartouche
8331 @noindent
8332 @strong{103}.  Any operations that implicitly require heap storage
8333 allocation.  See D.7(8).
8334 @end cartouche
8335 @noindent
8336 The only operation that implicitly requires heap storage allocation is
8337 task creation.
8339 @sp 1
8340 @cartouche
8341 @noindent
8342 @strong{104}.  Implementation-defined aspects of pragma
8343 @code{Restrictions}.  See D.7(20).
8344 @end cartouche
8345 @noindent
8346 There are no such implementation-defined aspects.
8348 @sp 1
8349 @cartouche
8350 @noindent
8351 @strong{105}.  Implementation-defined aspects of package
8352 @code{Real_Time}.  See D.8(17).
8353 @end cartouche
8354 @noindent
8355 There are no implementation defined aspects of package @code{Real_Time}.
8357 @sp 1
8358 @cartouche
8359 @noindent
8360 @strong{106}.  Implementation-defined aspects of
8361 @code{delay_statements}.  See D.9(8).
8362 @end cartouche
8363 @noindent
8364 Any difference greater than one microsecond will cause the task to be
8365 delayed (see D.9(7)).
8367 @sp 1
8368 @cartouche
8369 @noindent
8370 @strong{107}.  The upper bound on the duration of interrupt blocking
8371 caused by the implementation.  See D.12(5).
8372 @end cartouche
8373 @noindent
8374 The upper bound is determined by the underlying operating system.  In
8375 no cases is it more than 10 milliseconds.
8377 @sp 1
8378 @cartouche
8379 @noindent
8380 @strong{108}.  The means for creating and executing distributed
8381 programs.  See E(5).
8382 @end cartouche
8383 @noindent
8384 The GLADE package provides a utility GNATDIST for creating and executing
8385 distributed programs.  See the GLADE reference manual for further details.
8387 @sp 1
8388 @cartouche
8389 @noindent
8390 @strong{109}.  Any events that can result in a partition becoming
8391 inaccessible.  See E.1(7).
8392 @end cartouche
8393 @noindent
8394 See the GLADE reference manual for full details on such events.
8396 @sp 1
8397 @cartouche
8398 @noindent
8399 @strong{110}.  The scheduling policies, treatment of priorities, and
8400 management of shared resources between partitions in certain cases.  See
8401 E.1(11).
8402 @end cartouche
8403 @noindent
8404 See the GLADE reference manual for full details on these aspects of
8405 multi-partition execution.
8407 @sp 1
8408 @cartouche
8409 @noindent
8410 @strong{111}.  Events that cause the version of a compilation unit to
8411 change.  See E.3(5).
8412 @end cartouche
8413 @noindent
8414 Editing the source file of a compilation unit, or the source files of
8415 any units on which it is dependent in a significant way cause the version
8416 to change.  No other actions cause the version number to change.  All changes
8417 are significant except those which affect only layout, capitalization or
8418 comments.
8420 @sp 1
8421 @cartouche
8422 @noindent
8423 @strong{112}.  Whether the execution of the remote subprogram is
8424 immediately aborted as a result of cancellation.  See E.4(13).
8425 @end cartouche
8426 @noindent
8427 See the GLADE reference manual for details on the effect of abort in
8428 a distributed application.
8430 @sp 1
8431 @cartouche
8432 @noindent
8433 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8434 @end cartouche
8435 @noindent
8436 See the GLADE reference manual for a full description of all implementation
8437 defined aspects of the PCS@.
8439 @sp 1
8440 @cartouche
8441 @noindent
8442 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8443 E.5(26).
8444 @end cartouche
8445 @noindent
8446 See the GLADE reference manual for a full description of all
8447 implementation defined interfaces.
8449 @sp 1
8450 @cartouche
8451 @noindent
8452 @strong{115}.  The values of named numbers in the package
8453 @code{Decimal}.  See F.2(7).
8454 @end cartouche
8455 @noindent
8456 @table @code
8457 @item Max_Scale
8459 @item Min_Scale
8461 @item Min_Delta
8462 1.0E-18
8463 @item Max_Delta
8464 1.0E+18
8465 @item Max_Decimal_Digits
8467 @end table
8469 @sp 1
8470 @cartouche
8471 @noindent
8472 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8473 @code{Text_IO.Editing}.  See F.3.3(16).
8474 @end cartouche
8475 @noindent
8478 @sp 1
8479 @cartouche
8480 @noindent
8481 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8482 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8483 @end cartouche
8484 @noindent
8487 @sp 1
8488 @cartouche
8489 @noindent
8490 @strong{118}.  The accuracy actually achieved by the complex elementary
8491 functions and by other complex arithmetic operations.  See G.1(1).
8492 @end cartouche
8493 @noindent
8494 Standard library functions are used for the complex arithmetic
8495 operations.  Only fast math mode is currently supported.
8497 @sp 1
8498 @cartouche
8499 @noindent
8500 @strong{119}.  The sign of a zero result (or a component thereof) from
8501 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8502 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8503 @end cartouche
8504 @noindent
8505 The signs of zero values are as recommended by the relevant
8506 implementation advice.
8508 @sp 1
8509 @cartouche
8510 @noindent
8511 @strong{120}.  The sign of a zero result (or a component thereof) from
8512 any operator or function in
8513 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8514 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8515 @end cartouche
8516 @noindent
8517 The signs of zero values are as recommended by the relevant
8518 implementation advice.
8520 @sp 1
8521 @cartouche
8522 @noindent
8523 @strong{121}.  Whether the strict mode or the relaxed mode is the
8524 default.  See G.2(2).
8525 @end cartouche
8526 @noindent
8527 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8528 provides a highly efficient implementation of strict mode.
8530 @sp 1
8531 @cartouche
8532 @noindent
8533 @strong{122}.  The result interval in certain cases of fixed-to-float
8534 conversion.  See G.2.1(10).
8535 @end cartouche
8536 @noindent
8537 For cases where the result interval is implementation dependent, the
8538 accuracy is that provided by performing all operations in 64-bit IEEE
8539 floating-point format.
8541 @sp 1
8542 @cartouche
8543 @noindent
8544 @strong{123}.  The result of a floating point arithmetic operation in
8545 overflow situations, when the @code{Machine_Overflows} attribute of the
8546 result type is @code{False}.  See G.2.1(13).
8547 @end cartouche
8548 @noindent
8549 Infinite and NaN values are produced as dictated by the IEEE
8550 floating-point standard.
8552 Note that on machines that are not fully compliant with the IEEE
8553 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8554 must be used for achieving IEEE confirming behavior (although at the cost
8555 of a significant performance penalty), so infinite and NaN values are
8556 properly generated.
8558 @sp 1
8559 @cartouche
8560 @noindent
8561 @strong{124}.  The result interval for division (or exponentiation by a
8562 negative exponent), when the floating point hardware implements division
8563 as multiplication by a reciprocal.  See G.2.1(16).
8564 @end cartouche
8565 @noindent
8566 Not relevant, division is IEEE exact.
8568 @sp 1
8569 @cartouche
8570 @noindent
8571 @strong{125}.  The definition of close result set, which determines the
8572 accuracy of certain fixed point multiplications and divisions.  See
8573 G.2.3(5).
8574 @end cartouche
8575 @noindent
8576 Operations in the close result set are performed using IEEE long format
8577 floating-point arithmetic.  The input operands are converted to
8578 floating-point, the operation is done in floating-point, and the result
8579 is converted to the target type.
8581 @sp 1
8582 @cartouche
8583 @noindent
8584 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8585 point multiplication or division for which the result shall be in the
8586 perfect result set.  See G.2.3(22).
8587 @end cartouche
8588 @noindent
8589 The result is only defined to be in the perfect result set if the result
8590 can be computed by a single scaling operation involving a scale factor
8591 representable in 64-bits.
8593 @sp 1
8594 @cartouche
8595 @noindent
8596 @strong{127}.  The result of a fixed point arithmetic operation in
8597 overflow situations, when the @code{Machine_Overflows} attribute of the
8598 result type is @code{False}.  See G.2.3(27).
8599 @end cartouche
8600 @noindent
8601 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8602 types.
8604 @sp 1
8605 @cartouche
8606 @noindent
8607 @strong{128}.  The result of an elementary function reference in
8608 overflow situations, when the @code{Machine_Overflows} attribute of the
8609 result type is @code{False}.  See G.2.4(4).
8610 @end cartouche
8611 @noindent
8612 IEEE infinite and Nan values are produced as appropriate.
8614 @sp 1
8615 @cartouche
8616 @noindent
8617 @strong{129}.  The value of the angle threshold, within which certain
8618 elementary functions, complex arithmetic operations, and complex
8619 elementary functions yield results conforming to a maximum relative
8620 error bound.  See G.2.4(10).
8621 @end cartouche
8622 @noindent
8623 Information on this subject is not yet available.
8625 @sp 1
8626 @cartouche
8627 @noindent
8628 @strong{130}.  The accuracy of certain elementary functions for
8629 parameters beyond the angle threshold.  See G.2.4(10).
8630 @end cartouche
8631 @noindent
8632 Information on this subject is not yet available.
8634 @sp 1
8635 @cartouche
8636 @noindent
8637 @strong{131}.  The result of a complex arithmetic operation or complex
8638 elementary function reference in overflow situations, when the
8639 @code{Machine_Overflows} attribute of the corresponding real type is
8640 @code{False}.  See G.2.6(5).
8641 @end cartouche
8642 @noindent
8643 IEEE infinite and Nan values are produced as appropriate.
8645 @sp 1
8646 @cartouche
8647 @noindent
8648 @strong{132}.  The accuracy of certain complex arithmetic operations and
8649 certain complex elementary functions for parameters (or components
8650 thereof) beyond the angle threshold.  See G.2.6(8).
8651 @end cartouche
8652 @noindent
8653 Information on those subjects is not yet available.
8655 @sp 1
8656 @cartouche
8657 @noindent
8658 @strong{133}.  Information regarding bounded errors and erroneous
8659 execution.  See H.2(1).
8660 @end cartouche
8661 @noindent
8662 Information on this subject is not yet available.
8664 @sp 1
8665 @cartouche
8666 @noindent
8667 @strong{134}.  Implementation-defined aspects of pragma
8668 @code{Inspection_Point}.  See H.3.2(8).
8669 @end cartouche
8670 @noindent
8671 Pragma @code{Inspection_Point} ensures that the variable is live and can
8672 be examined by the debugger at the inspection point.
8674 @sp 1
8675 @cartouche
8676 @noindent
8677 @strong{135}.  Implementation-defined aspects of pragma
8678 @code{Restrictions}.  See H.4(25).
8679 @end cartouche
8680 @noindent
8681 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8682 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8683 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8685 @sp 1
8686 @cartouche
8687 @noindent
8688 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8689 H.4(27).
8690 @end cartouche
8691 @noindent
8692 There are no restrictions on pragma @code{Restrictions}.
8694 @node Intrinsic Subprograms
8695 @chapter Intrinsic Subprograms
8696 @cindex Intrinsic Subprograms
8698 @menu
8699 * Intrinsic Operators::
8700 * Enclosing_Entity::
8701 * Exception_Information::
8702 * Exception_Message::
8703 * Exception_Name::
8704 * File::
8705 * Line::
8706 * Rotate_Left::
8707 * Rotate_Right::
8708 * Shift_Left::
8709 * Shift_Right::
8710 * Shift_Right_Arithmetic::
8711 * Source_Location::
8712 @end menu
8714 @noindent
8715 GNAT allows a user application program to write the declaration:
8717 @smallexample @c ada
8718    pragma Import (Intrinsic, name);
8719 @end smallexample
8721 @noindent
8722 providing that the name corresponds to one of the implemented intrinsic
8723 subprograms in GNAT, and that the parameter profile of the referenced
8724 subprogram meets the requirements.  This chapter describes the set of
8725 implemented intrinsic subprograms, and the requirements on parameter profiles.
8726 Note that no body is supplied; as with other uses of pragma Import, the
8727 body is supplied elsewhere (in this case by the compiler itself).  Note
8728 that any use of this feature is potentially non-portable, since the
8729 Ada standard does not require Ada compilers to implement this feature.
8731 @node Intrinsic Operators
8732 @section Intrinsic Operators
8733 @cindex Intrinsic operator
8735 @noindent
8736 All the predefined numeric operators in package Standard
8737 in @code{pragma Import (Intrinsic,..)}
8738 declarations.  In the binary operator case, the operands must have the same
8739 size.  The operand or operands must also be appropriate for
8740 the operator.  For example, for addition, the operands must
8741 both be floating-point or both be fixed-point, and the
8742 right operand for @code{"**"} must have a root type of
8743 @code{Standard.Integer'Base}.
8744 You can use an intrinsic operator declaration as in the following example:
8746 @smallexample @c ada
8747    type Int1 is new Integer;
8748    type Int2 is new Integer;
8750    function "+" (X1 : Int1; X2 : Int2) return Int1;
8751    function "+" (X1 : Int1; X2 : Int2) return Int2;
8752    pragma Import (Intrinsic, "+");
8753 @end smallexample
8755 @noindent
8756 This declaration would permit ``mixed mode'' arithmetic on items
8757 of the differing types @code{Int1} and @code{Int2}.
8758 It is also possible to specify such operators for private types, if the
8759 full views are appropriate arithmetic types.
8761 @node Enclosing_Entity
8762 @section Enclosing_Entity
8763 @cindex Enclosing_Entity
8764 @noindent
8765 This intrinsic subprogram is used in the implementation of the
8766 library routine @code{GNAT.Source_Info}.  The only useful use of the
8767 intrinsic import in this case is the one in this unit, so an
8768 application program should simply call the function
8769 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8770 the current subprogram, package, task, entry, or protected subprogram.
8772 @node Exception_Information
8773 @section Exception_Information
8774 @cindex Exception_Information'
8775 @noindent
8776 This intrinsic subprogram is used in the implementation of the
8777 library routine @code{GNAT.Current_Exception}.  The only useful
8778 use of the intrinsic import in this case is the one in this unit,
8779 so an application program should simply call the function
8780 @code{GNAT.Current_Exception.Exception_Information} to obtain
8781 the exception information associated with the current exception.
8783 @node Exception_Message
8784 @section Exception_Message
8785 @cindex Exception_Message
8786 @noindent
8787 This intrinsic subprogram is used in the implementation of the
8788 library routine @code{GNAT.Current_Exception}.  The only useful
8789 use of the intrinsic import in this case is the one in this unit,
8790 so an application program should simply call the function
8791 @code{GNAT.Current_Exception.Exception_Message} to obtain
8792 the message associated with the current exception.
8794 @node Exception_Name
8795 @section Exception_Name
8796 @cindex Exception_Name
8797 @noindent
8798 This intrinsic subprogram is used in the implementation of the
8799 library routine @code{GNAT.Current_Exception}.  The only useful
8800 use of the intrinsic import in this case is the one in this unit,
8801 so an application program should simply call the function
8802 @code{GNAT.Current_Exception.Exception_Name} to obtain
8803 the name of the current exception.
8805 @node File
8806 @section File
8807 @cindex File
8808 @noindent
8809 This intrinsic subprogram is used in the implementation of the
8810 library routine @code{GNAT.Source_Info}.  The only useful use of the
8811 intrinsic import in this case is the one in this unit, so an
8812 application program should simply call the function
8813 @code{GNAT.Source_Info.File} to obtain the name of the current
8814 file.
8816 @node Line
8817 @section Line
8818 @cindex Line
8819 @noindent
8820 This intrinsic subprogram is used in the implementation of the
8821 library routine @code{GNAT.Source_Info}.  The only useful use of the
8822 intrinsic import in this case is the one in this unit, so an
8823 application program should simply call the function
8824 @code{GNAT.Source_Info.Line} to obtain the number of the current
8825 source line.
8827 @node Rotate_Left
8828 @section Rotate_Left
8829 @cindex Rotate_Left
8830 @noindent
8831 In standard Ada 95, the @code{Rotate_Left} function is available only
8832 for the predefined modular types in package @code{Interfaces}.  However, in
8833 GNAT it is possible to define a Rotate_Left function for a user
8834 defined modular type or any signed integer type as in this example:
8836 @smallexample @c ada
8837    function Shift_Left
8838      (Value  : My_Modular_Type;
8839       Amount : Natural)
8840       return   My_Modular_Type;
8841 @end smallexample
8843 @noindent
8844 The requirements are that the profile be exactly as in the example
8845 above.  The only modifications allowed are in the formal parameter
8846 names, and in the type of @code{Value} and the return type, which
8847 must be the same, and must be either a signed integer type, or
8848 a modular integer type with a binary modulus, and the size must
8849 be 8.  16, 32 or 64 bits.
8851 @node Rotate_Right
8852 @section Rotate_Right
8853 @cindex Rotate_Right
8854 @noindent
8855 A @code{Rotate_Right} function can be defined for any user defined
8856 binary modular integer type, or signed integer type, as described
8857 above for @code{Rotate_Left}.
8859 @node Shift_Left
8860 @section Shift_Left
8861 @cindex Shift_Left
8862 @noindent
8863 A @code{Shift_Left} function can be defined for any user defined
8864 binary modular integer type, or signed integer type, as described
8865 above for @code{Rotate_Left}.
8867 @node Shift_Right
8868 @section Shift_Right
8869 @cindex Shift_Right
8870 @noindent
8871 A @code{Shift_Right} function can be defined for any user defined
8872 binary modular integer type, or signed integer type, as described
8873 above for @code{Rotate_Left}.
8875 @node Shift_Right_Arithmetic
8876 @section Shift_Right_Arithmetic
8877 @cindex Shift_Right_Arithmetic
8878 @noindent
8879 A @code{Shift_Right_Arithmetic} function can be defined for any user
8880 defined binary modular integer type, or signed integer type, as described
8881 above for @code{Rotate_Left}.
8883 @node Source_Location
8884 @section Source_Location
8885 @cindex Source_Location
8886 @noindent
8887 This intrinsic subprogram is used in the implementation of the
8888 library routine @code{GNAT.Source_Info}.  The only useful use of the
8889 intrinsic import in this case is the one in this unit, so an
8890 application program should simply call the function
8891 @code{GNAT.Source_Info.Source_Location} to obtain the current
8892 source file location.
8894 @node Representation Clauses and Pragmas
8895 @chapter Representation Clauses and Pragmas
8896 @cindex Representation Clauses
8898 @menu
8899 * Alignment Clauses::
8900 * Size Clauses::
8901 * Storage_Size Clauses::
8902 * Size of Variant Record Objects::
8903 * Biased Representation ::
8904 * Value_Size and Object_Size Clauses::
8905 * Component_Size Clauses::
8906 * Bit_Order Clauses::
8907 * Effect of Bit_Order on Byte Ordering::
8908 * Pragma Pack for Arrays::
8909 * Pragma Pack for Records::
8910 * Record Representation Clauses::
8911 * Enumeration Clauses::
8912 * Address Clauses::
8913 * Effect of Convention on Representation::
8914 * Determining the Representations chosen by GNAT::
8915 @end menu
8917 @noindent
8918 @cindex Representation Clause
8919 @cindex Representation Pragma
8920 @cindex Pragma, representation
8921 This section describes the representation clauses accepted by GNAT, and
8922 their effect on the representation of corresponding data objects.
8924 GNAT fully implements Annex C (Systems Programming).  This means that all
8925 the implementation advice sections in chapter 13 are fully implemented.
8926 However, these sections only require a minimal level of support for
8927 representation clauses.  GNAT provides much more extensive capabilities,
8928 and this section describes the additional capabilities provided.
8930 @node Alignment Clauses
8931 @section Alignment Clauses
8932 @cindex Alignment Clause
8934 @noindent
8935 GNAT requires that all alignment clauses specify a power of 2, and all
8936 default alignments are always a power of 2.  The default alignment
8937 values are as follows:
8939 @itemize @bullet
8940 @item @emph{Primitive Types}.
8941 For primitive types, the alignment is the minimum of the actual size of
8942 objects of the type divided by @code{Storage_Unit},
8943 and the maximum alignment supported by the target.
8944 (This maximum alignment is given by the GNAT-specific attribute
8945 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8946 @cindex @code{Maximum_Alignment} attribute
8947 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8948 default alignment will be 8 on any target that supports alignments
8949 this large, but on some targets, the maximum alignment may be smaller
8950 than 8, in which case objects of type @code{Long_Float} will be maximally
8951 aligned.
8953 @item @emph{Arrays}.
8954 For arrays, the alignment is equal to the alignment of the component type
8955 for the normal case where no packing or component size is given.  If the
8956 array is packed, and the packing is effective (see separate section on
8957 packed arrays), then the alignment will be one for long packed arrays,
8958 or arrays whose length is not known at compile time.  For short packed
8959 arrays, which are handled internally as modular types, the alignment
8960 will be as described for primitive types, e.g.@: a packed array of length
8961 31 bits will have an object size of four bytes, and an alignment of 4.
8963 @item @emph{Records}.
8964 For the normal non-packed case, the alignment of a record is equal to
8965 the maximum alignment of any of its components.  For tagged records, this
8966 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8967 used and all fields are packable (see separate section on pragma @code{Pack}),
8968 then the resulting alignment is 1.
8970 A special case is when:
8971 @itemize @bullet
8972 @item
8973 the size of the record is given explicitly, or a
8974 full record representation clause is given, and
8975 @item
8976 the size of the record is 2, 4, or 8 bytes.
8977 @end itemize
8978 @noindent
8979 In this case, an alignment is chosen to match the
8980 size of the record. For example, if we have:
8982 @smallexample @c ada
8983    type Small is record
8984       A, B : Character;
8985    end record;
8986    for Small'Size use 16;
8987 @end smallexample
8989 @noindent
8990 then the default alignment of the record type @code{Small} is 2, not 1. This
8991 leads to more efficient code when the record is treated as a unit, and also
8992 allows the type to specified as @code{Atomic} on architectures requiring
8993 strict alignment.
8995 @end itemize
8997 @noindent
8998 An alignment clause may
8999 always specify a larger alignment than the default value, up to some
9000 maximum value dependent on the target (obtainable by using the
9001 attribute reference @code{Standard'Maximum_Alignment}).
9002 The only case where
9003 it is permissible to specify a smaller alignment than the default value
9004 is for a record with a record representation clause.
9005 In this case, packable fields for which a component clause is
9006 given still result in a default alignment corresponding to the original
9007 type, but this may be overridden, since these components in fact only
9008 require an alignment of one byte.  For example, given
9010 @smallexample @c ada
9011   type V is record
9012      A : Integer;
9013   end record;
9015   for V use record
9016      A at 0  range 0 .. 31;
9017   end record;
9019   for V'alignment use 1;
9020 @end smallexample
9022 @noindent
9023 @cindex Alignment, default
9024 The default alignment for the type @code{V} is 4, as a result of the
9025 Integer field in the record, but since this field is placed with a
9026 component clause, it is permissible, as shown, to override the default
9027 alignment of the record with a smaller value.
9029 @node Size Clauses
9030 @section Size Clauses
9031 @cindex Size Clause
9033 @noindent
9034 The default size for a type @code{T} is obtainable through the
9035 language-defined attribute @code{T'Size} and also through the
9036 equivalent GNAT-defined attribute @code{T'Value_Size}.
9037 For objects of type @code{T}, GNAT will generally increase the type size
9038 so that the object size (obtainable through the GNAT-defined attribute
9039 @code{T'Object_Size})
9040 is a multiple of @code{T'Alignment * Storage_Unit}.
9041 For example
9043 @smallexample @c ada
9044    type Smallint is range 1 .. 6;
9046    type Rec is record
9047       Y1 : integer;
9048       Y2 : boolean;
9049    end record;
9050 @end smallexample
9052 @noindent
9053 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9054 as specified by the RM rules,
9055 but objects of this type will have a size of 8
9056 (@code{Smallint'Object_Size} = 8),
9057 since objects by default occupy an integral number
9058 of storage units.  On some targets, notably older
9059 versions of the Digital Alpha, the size of stand
9060 alone objects of this type may be 32, reflecting
9061 the inability of the hardware to do byte load/stores.
9063 Similarly, the size of type @code{Rec} is 40 bits
9064 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9065 the alignment is 4, so objects of this type will have
9066 their size increased to 64 bits so that it is a multiple
9067 of the alignment (in bits).  This decision is
9068 in accordance with the specific Implementation Advice in RM 13.3(43):
9070 @quotation
9071 A @code{Size} clause should be supported for an object if the specified
9072 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9073 to a size in storage elements that is a multiple of the object's
9074 @code{Alignment} (if the @code{Alignment} is nonzero).
9075 @end quotation
9077 @noindent
9078 An explicit size clause may be used to override the default size by
9079 increasing it.  For example, if we have:
9081 @smallexample @c ada
9082    type My_Boolean is new Boolean;
9083    for My_Boolean'Size use 32;
9084 @end smallexample
9086 @noindent
9087 then values of this type will always be 32 bits long.  In the case of
9088 discrete types, the size can be increased up to 64 bits, with the effect
9089 that the entire specified field is used to hold the value, sign- or
9090 zero-extended as appropriate.  If more than 64 bits is specified, then
9091 padding space is allocated after the value, and a warning is issued that
9092 there are unused bits.
9094 Similarly the size of records and arrays may be increased, and the effect
9095 is to add padding bits after the value.  This also causes a warning message
9096 to be generated.
9098 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9099 Size in bits, this corresponds to an object of size 256 megabytes (minus
9100 one).  This limitation is true on all targets.  The reason for this
9101 limitation is that it improves the quality of the code in many cases
9102 if it is known that a Size value can be accommodated in an object of
9103 type Integer.
9105 @node Storage_Size Clauses
9106 @section Storage_Size Clauses
9107 @cindex Storage_Size Clause
9109 @noindent
9110 For tasks, the @code{Storage_Size} clause specifies the amount of space
9111 to be allocated for the task stack.  This cannot be extended, and if the
9112 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9113 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9114 or a @code{Storage_Size} pragma in the task definition to set the
9115 appropriate required size.  A useful technique is to include in every
9116 task definition a pragma of the form:
9118 @smallexample @c ada
9119    pragma Storage_Size (Default_Stack_Size);
9120 @end smallexample
9122 @noindent
9123 Then @code{Default_Stack_Size} can be defined in a global package, and
9124 modified as required. Any tasks requiring stack sizes different from the
9125 default can have an appropriate alternative reference in the pragma.
9127 You can also use the @code{-d} binder switch to modify the default stack
9128 size.
9130 For access types, the @code{Storage_Size} clause specifies the maximum
9131 space available for allocation of objects of the type.  If this space is
9132 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9133 In the case where the access type is declared local to a subprogram, the
9134 use of a @code{Storage_Size} clause triggers automatic use of a special
9135 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9136 space for the pool is automatically reclaimed on exit from the scope in
9137 which the type is declared.
9139 A special case recognized by the compiler is the specification of a
9140 @code{Storage_Size} of zero for an access type.  This means that no
9141 items can be allocated from the pool, and this is recognized at compile
9142 time, and all the overhead normally associated with maintaining a fixed
9143 size storage pool is eliminated.  Consider the following example:
9145 @smallexample @c ada
9146    procedure p is
9147       type R is array (Natural) of Character;
9148       type P is access all R;
9149       for P'Storage_Size use 0;
9150       --  Above access type intended only for interfacing purposes
9152       y : P;
9154       procedure g (m : P);
9155       pragma Import (C, g);
9157       --  @dots{}
9159    begin
9160       --  @dots{}
9161       y := new R;
9162    end;
9163 @end smallexample
9165 @noindent
9166 As indicated in this example, these dummy storage pools are often useful in
9167 connection with interfacing where no object will ever be allocated.  If you
9168 compile the above example, you get the warning:
9170 @smallexample
9171    p.adb:16:09: warning: allocation from empty storage pool
9172    p.adb:16:09: warning: Storage_Error will be raised at run time
9173 @end smallexample
9175 @noindent
9176 Of course in practice, there will not be any explicit allocators in the
9177 case of such an access declaration.
9179 @node Size of Variant Record Objects
9180 @section Size of Variant Record Objects
9181 @cindex Size, variant record objects
9182 @cindex Variant record objects, size
9184 @noindent
9185 In the case of variant record objects, there is a question whether Size gives
9186 information about a particular variant, or the maximum size required
9187 for any variant.  Consider the following program
9189 @smallexample @c ada
9190 with Text_IO; use Text_IO;
9191 procedure q is
9192    type R1 (A : Boolean := False) is record
9193      case A is
9194        when True  => X : Character;
9195        when False => null;
9196      end case;
9197    end record;
9199    V1 : R1 (False);
9200    V2 : R1;
9202 begin
9203    Put_Line (Integer'Image (V1'Size));
9204    Put_Line (Integer'Image (V2'Size));
9205 end q;
9206 @end smallexample
9208 @noindent
9209 Here we are dealing with a variant record, where the True variant
9210 requires 16 bits, and the False variant requires 8 bits.
9211 In the above example, both V1 and V2 contain the False variant,
9212 which is only 8 bits long.  However, the result of running the
9213 program is:
9215 @smallexample
9218 @end smallexample
9220 @noindent
9221 The reason for the difference here is that the discriminant value of
9222 V1 is fixed, and will always be False.  It is not possible to assign
9223 a True variant value to V1, therefore 8 bits is sufficient.  On the
9224 other hand, in the case of V2, the initial discriminant value is
9225 False (from the default), but it is possible to assign a True
9226 variant value to V2, therefore 16 bits must be allocated for V2
9227 in the general case, even fewer bits may be needed at any particular
9228 point during the program execution.
9230 As can be seen from the output of this program, the @code{'Size}
9231 attribute applied to such an object in GNAT gives the actual allocated
9232 size of the variable, which is the largest size of any of the variants.
9233 The Ada Reference Manual is not completely clear on what choice should
9234 be made here, but the GNAT behavior seems most consistent with the
9235 language in the RM@.
9237 In some cases, it may be desirable to obtain the size of the current
9238 variant, rather than the size of the largest variant.  This can be
9239 achieved in GNAT by making use of the fact that in the case of a
9240 subprogram parameter, GNAT does indeed return the size of the current
9241 variant (because a subprogram has no way of knowing how much space
9242 is actually allocated for the actual).
9244 Consider the following modified version of the above program:
9246 @smallexample @c ada
9247 with Text_IO; use Text_IO;
9248 procedure q is
9249    type R1 (A : Boolean := False) is record
9250      case A is
9251        when True  => X : Character;
9252        when False => null;
9253      end case;
9254    end record;
9256    V2 : R1;
9258    function Size (V : R1) return Integer is
9259    begin
9260       return V'Size;
9261    end Size;
9263 begin
9264    Put_Line (Integer'Image (V2'Size));
9265    Put_Line (Integer'IMage (Size (V2)));
9266    V2 := (True, 'x');
9267    Put_Line (Integer'Image (V2'Size));
9268    Put_Line (Integer'IMage (Size (V2)));
9269 end q;
9270 @end smallexample
9272 @noindent
9273 The output from this program is
9275 @smallexample
9280 @end smallexample
9282 @noindent
9283 Here we see that while the @code{'Size} attribute always returns
9284 the maximum size, regardless of the current variant value, the
9285 @code{Size} function does indeed return the size of the current
9286 variant value.
9288 @node Biased Representation
9289 @section Biased Representation
9290 @cindex Size for biased representation
9291 @cindex Biased representation
9293 @noindent
9294 In the case of scalars with a range starting at other than zero, it is
9295 possible in some cases to specify a size smaller than the default minimum
9296 value, and in such cases, GNAT uses an unsigned biased representation,
9297 in which zero is used to represent the lower bound, and successive values
9298 represent successive values of the type.
9300 For example, suppose we have the declaration:
9302 @smallexample @c ada
9303    type Small is range -7 .. -4;
9304    for Small'Size use 2;
9305 @end smallexample
9307 @noindent
9308 Although the default size of type @code{Small} is 4, the @code{Size}
9309 clause is accepted by GNAT and results in the following representation
9310 scheme:
9312 @smallexample
9313   -7 is represented as 2#00#
9314   -6 is represented as 2#01#
9315   -5 is represented as 2#10#
9316   -4 is represented as 2#11#
9317 @end smallexample
9319 @noindent
9320 Biased representation is only used if the specified @code{Size} clause
9321 cannot be accepted in any other manner.  These reduced sizes that force
9322 biased representation can be used for all discrete types except for
9323 enumeration types for which a representation clause is given.
9325 @node Value_Size and Object_Size Clauses
9326 @section Value_Size and Object_Size Clauses
9327 @findex Value_Size
9328 @findex Object_Size
9329 @cindex Size, of objects
9331 @noindent
9332 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
9333 required to hold values of type @code{T}.  Although this interpretation was
9334 allowed in Ada 83, it was not required, and this requirement in practice
9335 can cause some significant difficulties.  For example, in most Ada 83
9336 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
9337 @code{Natural'Size} is
9338 typically 31.  This means that code may change in behavior when moving
9339 from Ada 83 to Ada 95.  For example, consider:
9341 @smallexample @c ada
9342    type Rec is record;
9343       A : Natural;
9344       B : Natural;
9345    end record;
9347    for Rec use record
9348       at 0  range 0 .. Natural'Size - 1;
9349       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9350    end record;
9351 @end smallexample
9353 @noindent
9354 In the above code, since the typical size of @code{Natural} objects
9355 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9356 unexpected inefficient packing in Ada 95, and in general there are
9357 cases where the fact that the object size can exceed the
9358 size of the type causes surprises.
9360 To help get around this problem GNAT provides two implementation
9361 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9362 applied to a type, these attributes yield the size of the type
9363 (corresponding to the RM defined size attribute), and the size of
9364 objects of the type respectively.
9366 The @code{Object_Size} is used for determining the default size of
9367 objects and components.  This size value can be referred to using the
9368 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9369 the basis of the determination of the size.  The backend is free to
9370 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9371 character might be stored in 32 bits on a machine with no efficient
9372 byte access instructions such as the Alpha.
9374 The default rules for the value of @code{Object_Size} for
9375 discrete types are as follows:
9377 @itemize @bullet
9378 @item
9379 The @code{Object_Size} for base subtypes reflect the natural hardware
9380 size in bits (run the compiler with @option{-gnatS} to find those values
9381 for numeric types). Enumeration types and fixed-point base subtypes have
9382 8, 16, 32 or 64 bits for this size, depending on the range of values
9383 to be stored.
9385 @item
9386 The @code{Object_Size} of a subtype is the same as the
9387 @code{Object_Size} of
9388 the type from which it is obtained.
9390 @item
9391 The @code{Object_Size} of a derived base type is copied from the parent
9392 base type, and the @code{Object_Size} of a derived first subtype is copied
9393 from the parent first subtype.
9394 @end itemize
9396 @noindent
9397 The @code{Value_Size} attribute
9398 is the (minimum) number of bits required to store a value
9399 of the type.
9400 This value is used to determine how tightly to pack
9401 records or arrays with components of this type, and also affects
9402 the semantics of unchecked conversion (unchecked conversions where
9403 the @code{Value_Size} values differ generate a warning, and are potentially
9404 target dependent).
9406 The default rules for the value of @code{Value_Size} are as follows:
9408 @itemize @bullet
9409 @item
9410 The @code{Value_Size} for a base subtype is the minimum number of bits
9411 required to store all values of the type (including the sign bit
9412 only if negative values are possible).
9414 @item
9415 If a subtype statically matches the first subtype of a given type, then it has
9416 by default the same @code{Value_Size} as the first subtype.  This is a
9417 consequence of RM 13.1(14) (``if two subtypes statically match,
9418 then their subtype-specific aspects are the same''.)
9420 @item
9421 All other subtypes have a @code{Value_Size} corresponding to the minimum
9422 number of bits required to store all values of the subtype.  For
9423 dynamic bounds, it is assumed that the value can range down or up
9424 to the corresponding bound of the ancestor
9425 @end itemize
9427 @noindent
9428 The RM defined attribute @code{Size} corresponds to the
9429 @code{Value_Size} attribute.
9431 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9432 the @code{Value_Size} of
9433 the first-named subtype to the given value, and the
9434 @code{Object_Size} of this first-named subtype to the given value padded up
9435 to an appropriate boundary.  It is a consequence of the default rules
9436 above that this @code{Object_Size} will apply to all further subtypes.  On the
9437 other hand, @code{Value_Size} is affected only for the first subtype, any
9438 dynamic subtypes obtained from it directly, and any statically matching
9439 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9441 @code{Value_Size} and
9442 @code{Object_Size} may be explicitly set for any subtype using
9443 an attribute definition clause.  Note that the use of these attributes
9444 can cause the RM 13.1(14) rule to be violated.  If two access types
9445 reference aliased objects whose subtypes have differing @code{Object_Size}
9446 values as a result of explicit attribute definition clauses, then it
9447 is erroneous to convert from one access subtype to the other.
9449 At the implementation level, Esize stores the Object_Size and the
9450 RM_Size field stores the @code{Value_Size} (and hence the value of the
9451 @code{Size} attribute,
9452 which, as noted above, is equivalent to @code{Value_Size}).
9454 To get a feel for the difference, consider the following examples (note
9455 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9457 @smallexample
9458                                        Object_Size     Value_Size
9460 type x1 is range 0 .. 5;                    8               3
9462 type x2 is range 0 .. 5;
9463 for x2'size use 12;                        16              12
9465 subtype x3 is x2 range 0 .. 3;             16               2
9467 subtype x4 is x2'base range 0 .. 10;        8               4
9469 subtype x5 is x2 range 0 .. dynamic;       16               3*
9471 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9473 @end smallexample
9475 @noindent
9476 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
9477 but it seems in the spirit of the RM rules to allocate the minimum number
9478 of bits (here 3, given the range for @code{x2})
9479 known to be large enough to hold the given range of values.
9481 So far, so good, but GNAT has to obey the RM rules, so the question is
9482 under what conditions must the RM @code{Size} be used.
9483 The following is a list
9484 of the occasions on which the RM @code{Size} must be used:
9486 @itemize @bullet
9487 @item
9488 Component size for packed arrays or records
9490 @item
9491 Value of the attribute @code{Size} for a type
9493 @item
9494 Warning about sizes not matching for unchecked conversion
9495 @end itemize
9497 @noindent
9498 For record types, the @code{Object_Size} is always a multiple of the
9499 alignment of the type (this is true for all types). In some cases the
9500 @code{Value_Size} can be smaller. Consider:
9502 @smallexample
9503    type R is record
9504      X : Integer;
9505      Y : Character;
9506    end record;
9507 @end smallexample
9509 @noindent
9510 On a typical 32-bit architecture, the X component will be four bytes, and
9511 require four-byte alignment, and the Y component will be one byte. In this
9512 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9513 required to store a value of this type, and for example, it is permissible
9514 to have a component of type R in an outer record whose component size is
9515 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9516 since it must be rounded up so that this value is a multiple of the
9517 alignment (4 bytes = 32 bits).
9519 @noindent
9520 For all other types, the @code{Object_Size}
9521 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9522 Only @code{Size} may be specified for such types.
9524 @node Component_Size Clauses
9525 @section Component_Size Clauses
9526 @cindex Component_Size Clause
9528 @noindent
9529 Normally, the value specified in a component size clause must be consistent
9530 with the subtype of the array component with regard to size and alignment.
9531 In other words, the value specified must be at least equal to the size
9532 of this subtype, and must be a multiple of the alignment value.
9534 In addition, component size clauses are allowed which cause the array
9535 to be packed, by specifying a smaller value.  The cases in which this
9536 is allowed are for component size values in the range 1 through 63.  The value
9537 specified must not be smaller than the Size of the subtype.  GNAT will
9538 accurately honor all packing requests in this range.  For example, if
9539 we have:
9541 @smallexample @c ada
9542 type r is array (1 .. 8) of Natural;
9543 for r'Component_Size use 31;
9544 @end smallexample
9546 @noindent
9547 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9548 Of course access to the components of such an array is considerably
9549 less efficient than if the natural component size of 32 is used.
9551 Note that there is no point in giving both a component size clause
9552 and a pragma Pack for the same array type. if such duplicate
9553 clauses are given, the pragma Pack will be ignored.
9555 @node Bit_Order Clauses
9556 @section Bit_Order Clauses
9557 @cindex Bit_Order Clause
9558 @cindex bit ordering
9559 @cindex ordering, of bits
9561 @noindent
9562 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9563 attribute.  The specification may either correspond to the default bit
9564 order for the target, in which case the specification has no effect and
9565 places no additional restrictions, or it may be for the non-standard
9566 setting (that is the opposite of the default).
9568 In the case where the non-standard value is specified, the effect is
9569 to renumber bits within each byte, but the ordering of bytes is not
9570 affected.  There are certain
9571 restrictions placed on component clauses as follows:
9573 @itemize @bullet
9575 @item Components fitting within a single storage unit.
9576 @noindent
9577 These are unrestricted, and the effect is merely to renumber bits.  For
9578 example if we are on a little-endian machine with @code{Low_Order_First}
9579 being the default, then the following two declarations have exactly
9580 the same effect:
9582 @smallexample @c ada
9583    type R1 is record
9584       A : Boolean;
9585       B : Integer range 1 .. 120;
9586    end record;
9588    for R1 use record
9589       A at 0 range 0 .. 0;
9590       B at 0 range 1 .. 7;
9591    end record;
9593    type R2 is record
9594       A : Boolean;
9595       B : Integer range 1 .. 120;
9596    end record;
9598    for R2'Bit_Order use High_Order_First;
9600    for R2 use record
9601       A at 0 range 7 .. 7;
9602       B at 0 range 0 .. 6;
9603    end record;
9604 @end smallexample
9606 @noindent
9607 The useful application here is to write the second declaration with the
9608 @code{Bit_Order} attribute definition clause, and know that it will be treated
9609 the same, regardless of whether the target is little-endian or big-endian.
9611 @item Components occupying an integral number of bytes.
9612 @noindent
9613 These are components that exactly fit in two or more bytes.  Such component
9614 declarations are allowed, but have no effect, since it is important to realize
9615 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9616 In particular, the following attempt at getting an endian-independent integer
9617 does not work:
9619 @smallexample @c ada
9620    type R2 is record
9621       A : Integer;
9622    end record;
9624    for R2'Bit_Order use High_Order_First;
9626    for R2 use record
9627       A at 0 range 0 .. 31;
9628    end record;
9629 @end smallexample
9631 @noindent
9632 This declaration will result in a little-endian integer on a
9633 little-endian machine, and a big-endian integer on a big-endian machine.
9634 If byte flipping is required for interoperability between big- and
9635 little-endian machines, this must be explicitly programmed.  This capability
9636 is not provided by @code{Bit_Order}.
9638 @item Components that are positioned across byte boundaries
9639 @noindent
9640 but do not occupy an integral number of bytes.  Given that bytes are not
9641 reordered, such fields would occupy a non-contiguous sequence of bits
9642 in memory, requiring non-trivial code to reassemble.  They are for this
9643 reason not permitted, and any component clause specifying such a layout
9644 will be flagged as illegal by GNAT@.
9646 @end itemize
9648 @noindent
9649 Since the misconception that Bit_Order automatically deals with all
9650 endian-related incompatibilities is a common one, the specification of
9651 a component field that is an integral number of bytes will always
9652 generate a warning.  This warning may be suppressed using
9653 @code{pragma Suppress} if desired.  The following section contains additional
9654 details regarding the issue of byte ordering.
9656 @node Effect of Bit_Order on Byte Ordering
9657 @section Effect of Bit_Order on Byte Ordering
9658 @cindex byte ordering
9659 @cindex ordering, of bytes
9661 @noindent
9662 In this section we will review the effect of the @code{Bit_Order} attribute
9663 definition clause on byte ordering.  Briefly, it has no effect at all, but
9664 a detailed example will be helpful.  Before giving this
9665 example, let us review the precise
9666 definition of the effect of defining @code{Bit_Order}.  The effect of a
9667 non-standard bit order is described in section 15.5.3 of the Ada
9668 Reference Manual:
9670 @quotation
9671 2   A bit ordering is a method of interpreting the meaning of
9672 the storage place attributes.
9673 @end quotation
9675 @noindent
9676 To understand the precise definition of storage place attributes in
9677 this context, we visit section 13.5.1 of the manual:
9679 @quotation
9680 13   A record_representation_clause (without the mod_clause)
9681 specifies the layout.  The storage place attributes (see 13.5.2)
9682 are taken from the values of the position, first_bit, and last_bit
9683 expressions after normalizing those values so that first_bit is
9684 less than Storage_Unit.
9685 @end quotation
9687 @noindent
9688 The critical point here is that storage places are taken from
9689 the values after normalization, not before.  So the @code{Bit_Order}
9690 interpretation applies to normalized values.  The interpretation
9691 is described in the later part of the 15.5.3 paragraph:
9693 @quotation
9694 2   A bit ordering is a method of interpreting the meaning of
9695 the storage place attributes.  High_Order_First (known in the
9696 vernacular as ``big endian'') means that the first bit of a
9697 storage element (bit 0) is the most significant bit (interpreting
9698 the sequence of bits that represent a component as an unsigned
9699 integer value).  Low_Order_First (known in the vernacular as
9700 ``little endian'') means the opposite: the first bit is the
9701 least significant.
9702 @end quotation
9704 @noindent
9705 Note that the numbering is with respect to the bits of a storage
9706 unit.  In other words, the specification affects only the numbering
9707 of bits within a single storage unit.
9709 We can make the effect clearer by giving an example.
9711 Suppose that we have an external device which presents two bytes, the first
9712 byte presented, which is the first (low addressed byte) of the two byte
9713 record is called Master, and the second byte is called Slave.
9715 The left most (most significant bit is called Control for each byte, and
9716 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9717 (least significant) bit.
9719 On a big-endian machine, we can write the following representation clause
9721 @smallexample @c ada
9722    type Data is record
9723       Master_Control : Bit;
9724       Master_V1      : Bit;
9725       Master_V2      : Bit;
9726       Master_V3      : Bit;
9727       Master_V4      : Bit;
9728       Master_V5      : Bit;
9729       Master_V6      : Bit;
9730       Master_V7      : Bit;
9731       Slave_Control  : Bit;
9732       Slave_V1       : Bit;
9733       Slave_V2       : Bit;
9734       Slave_V3       : Bit;
9735       Slave_V4       : Bit;
9736       Slave_V5       : Bit;
9737       Slave_V6       : Bit;
9738       Slave_V7       : Bit;
9739    end record;
9741    for Data use record
9742       Master_Control at 0 range 0 .. 0;
9743       Master_V1      at 0 range 1 .. 1;
9744       Master_V2      at 0 range 2 .. 2;
9745       Master_V3      at 0 range 3 .. 3;
9746       Master_V4      at 0 range 4 .. 4;
9747       Master_V5      at 0 range 5 .. 5;
9748       Master_V6      at 0 range 6 .. 6;
9749       Master_V7      at 0 range 7 .. 7;
9750       Slave_Control  at 1 range 0 .. 0;
9751       Slave_V1       at 1 range 1 .. 1;
9752       Slave_V2       at 1 range 2 .. 2;
9753       Slave_V3       at 1 range 3 .. 3;
9754       Slave_V4       at 1 range 4 .. 4;
9755       Slave_V5       at 1 range 5 .. 5;
9756       Slave_V6       at 1 range 6 .. 6;
9757       Slave_V7       at 1 range 7 .. 7;
9758    end record;
9759 @end smallexample
9761 @noindent
9762 Now if we move this to a little endian machine, then the bit ordering within
9763 the byte is backwards, so we have to rewrite the record rep clause as:
9765 @smallexample @c ada
9766    for Data use record
9767       Master_Control at 0 range 7 .. 7;
9768       Master_V1      at 0 range 6 .. 6;
9769       Master_V2      at 0 range 5 .. 5;
9770       Master_V3      at 0 range 4 .. 4;
9771       Master_V4      at 0 range 3 .. 3;
9772       Master_V5      at 0 range 2 .. 2;
9773       Master_V6      at 0 range 1 .. 1;
9774       Master_V7      at 0 range 0 .. 0;
9775       Slave_Control  at 1 range 7 .. 7;
9776       Slave_V1       at 1 range 6 .. 6;
9777       Slave_V2       at 1 range 5 .. 5;
9778       Slave_V3       at 1 range 4 .. 4;
9779       Slave_V4       at 1 range 3 .. 3;
9780       Slave_V5       at 1 range 2 .. 2;
9781       Slave_V6       at 1 range 1 .. 1;
9782       Slave_V7       at 1 range 0 .. 0;
9783    end record;
9784 @end smallexample
9786 @noindent
9787 It is a nuisance to have to rewrite the clause, especially if
9788 the code has to be maintained on both machines.  However,
9789 this is a case that we can handle with the
9790 @code{Bit_Order} attribute if it is implemented.
9791 Note that the implementation is not required on byte addressed
9792 machines, but it is indeed implemented in GNAT.
9793 This means that we can simply use the
9794 first record clause, together with the declaration
9796 @smallexample @c ada
9797    for Data'Bit_Order use High_Order_First;
9798 @end smallexample
9800 @noindent
9801 and the effect is what is desired, namely the layout is exactly the same,
9802 independent of whether the code is compiled on a big-endian or little-endian
9803 machine.
9805 The important point to understand is that byte ordering is not affected.
9806 A @code{Bit_Order} attribute definition never affects which byte a field
9807 ends up in, only where it ends up in that byte.
9808 To make this clear, let us rewrite the record rep clause of the previous
9809 example as:
9811 @smallexample @c ada
9812    for Data'Bit_Order use High_Order_First;
9813    for Data use record
9814       Master_Control at 0 range  0 .. 0;
9815       Master_V1      at 0 range  1 .. 1;
9816       Master_V2      at 0 range  2 .. 2;
9817       Master_V3      at 0 range  3 .. 3;
9818       Master_V4      at 0 range  4 .. 4;
9819       Master_V5      at 0 range  5 .. 5;
9820       Master_V6      at 0 range  6 .. 6;
9821       Master_V7      at 0 range  7 .. 7;
9822       Slave_Control  at 0 range  8 .. 8;
9823       Slave_V1       at 0 range  9 .. 9;
9824       Slave_V2       at 0 range 10 .. 10;
9825       Slave_V3       at 0 range 11 .. 11;
9826       Slave_V4       at 0 range 12 .. 12;
9827       Slave_V5       at 0 range 13 .. 13;
9828       Slave_V6       at 0 range 14 .. 14;
9829       Slave_V7       at 0 range 15 .. 15;
9830    end record;
9831 @end smallexample
9833 @noindent
9834 This is exactly equivalent to saying (a repeat of the first example):
9836 @smallexample @c ada
9837    for Data'Bit_Order use High_Order_First;
9838    for Data use record
9839       Master_Control at 0 range 0 .. 0;
9840       Master_V1      at 0 range 1 .. 1;
9841       Master_V2      at 0 range 2 .. 2;
9842       Master_V3      at 0 range 3 .. 3;
9843       Master_V4      at 0 range 4 .. 4;
9844       Master_V5      at 0 range 5 .. 5;
9845       Master_V6      at 0 range 6 .. 6;
9846       Master_V7      at 0 range 7 .. 7;
9847       Slave_Control  at 1 range 0 .. 0;
9848       Slave_V1       at 1 range 1 .. 1;
9849       Slave_V2       at 1 range 2 .. 2;
9850       Slave_V3       at 1 range 3 .. 3;
9851       Slave_V4       at 1 range 4 .. 4;
9852       Slave_V5       at 1 range 5 .. 5;
9853       Slave_V6       at 1 range 6 .. 6;
9854       Slave_V7       at 1 range 7 .. 7;
9855    end record;
9856 @end smallexample
9858 @noindent
9859 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9860 field.  The storage place attributes are obtained by normalizing the
9861 values given so that the @code{First_Bit} value is less than 8.  After
9862 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9863 we specified in the other case.
9865 Now one might expect that the @code{Bit_Order} attribute might affect
9866 bit numbering within the entire record component (two bytes in this
9867 case, thus affecting which byte fields end up in), but that is not
9868 the way this feature is defined, it only affects numbering of bits,
9869 not which byte they end up in.
9871 Consequently it never makes sense to specify a starting bit number
9872 greater than 7 (for a byte addressable field) if an attribute
9873 definition for @code{Bit_Order} has been given, and indeed it
9874 may be actively confusing to specify such a value, so the compiler
9875 generates a warning for such usage.
9877 If you do need to control byte ordering then appropriate conditional
9878 values must be used.  If in our example, the slave byte came first on
9879 some machines we might write:
9881 @smallexample @c ada
9882    Master_Byte_First constant Boolean := @dots{};
9884    Master_Byte : constant Natural :=
9885                    1 - Boolean'Pos (Master_Byte_First);
9886    Slave_Byte  : constant Natural :=
9887                    Boolean'Pos (Master_Byte_First);
9889    for Data'Bit_Order use High_Order_First;
9890    for Data use record
9891       Master_Control at Master_Byte range 0 .. 0;
9892       Master_V1      at Master_Byte range 1 .. 1;
9893       Master_V2      at Master_Byte range 2 .. 2;
9894       Master_V3      at Master_Byte range 3 .. 3;
9895       Master_V4      at Master_Byte range 4 .. 4;
9896       Master_V5      at Master_Byte range 5 .. 5;
9897       Master_V6      at Master_Byte range 6 .. 6;
9898       Master_V7      at Master_Byte range 7 .. 7;
9899       Slave_Control  at Slave_Byte  range 0 .. 0;
9900       Slave_V1       at Slave_Byte  range 1 .. 1;
9901       Slave_V2       at Slave_Byte  range 2 .. 2;
9902       Slave_V3       at Slave_Byte  range 3 .. 3;
9903       Slave_V4       at Slave_Byte  range 4 .. 4;
9904       Slave_V5       at Slave_Byte  range 5 .. 5;
9905       Slave_V6       at Slave_Byte  range 6 .. 6;
9906       Slave_V7       at Slave_Byte  range 7 .. 7;
9907    end record;
9908 @end smallexample
9910 @noindent
9911 Now to switch between machines, all that is necessary is
9912 to set the boolean constant @code{Master_Byte_First} in
9913 an appropriate manner.
9915 @node Pragma Pack for Arrays
9916 @section Pragma Pack for Arrays
9917 @cindex Pragma Pack (for arrays)
9919 @noindent
9920 Pragma @code{Pack} applied to an array has no effect unless the component type
9921 is packable.  For a component type to be packable, it must be one of the
9922 following cases:
9924 @itemize @bullet
9925 @item
9926 Any scalar type
9927 @item
9928 Any type whose size is specified with a size clause
9929 @item
9930 Any packed array type with a static size
9931 @end itemize
9933 @noindent
9934 For all these cases, if the component subtype size is in the range
9935 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9936 component size were specified giving the component subtype size.
9937 For example if we have:
9939 @smallexample @c ada
9940    type r is range 0 .. 17;
9942    type ar is array (1 .. 8) of r;
9943    pragma Pack (ar);
9944 @end smallexample
9946 @noindent
9947 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9948 and the size of the array @code{ar} will be exactly 40 bits.
9950 Note that in some cases this rather fierce approach to packing can produce
9951 unexpected effects.  For example, in Ada 95, type Natural typically has a
9952 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9953 close packing, which saves a few bits, but results in far less efficient
9954 access.  Since many other Ada compilers will ignore such a packing request,
9955 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9956 might not be what is intended.  You can easily remove this warning by
9957 using an explicit @code{Component_Size} setting instead, which never generates
9958 a warning, since the intention of the programmer is clear in this case.
9960 GNAT treats packed arrays in one of two ways.  If the size of the array is
9961 known at compile time and is less than 64 bits, then internally the array
9962 is represented as a single modular type, of exactly the appropriate number
9963 of bits.  If the length is greater than 63 bits, or is not known at compile
9964 time, then the packed array is represented as an array of bytes, and the
9965 length is always a multiple of 8 bits.
9967 Note that to represent a packed array as a modular type, the alignment must
9968 be suitable for the modular type involved. For example, on typical machines
9969 a 32-bit packed array will be represented by a 32-bit modular integer with
9970 an alignment of four bytes. If you explicitly override the default alignment
9971 with an alignment clause that is too small, the modular representation
9972 cannot be used. For example, consider the following set of declarations:
9974 @smallexample @c ada
9975    type R is range 1 .. 3;
9976    type S is array (1 .. 31) of R;
9977    for S'Component_Size use 2;
9978    for S'Size use 62;
9979    for S'Alignment use 1;
9980 @end smallexample
9982 @noindent
9983 If the alignment clause were not present, then a 62-bit modular
9984 representation would be chosen (typically with an alignment of 4 or 8
9985 bytes depending on the target). But the default alignment is overridden
9986 with the explicit alignment clause. This means that the modular
9987 representation cannot be used, and instead the array of bytes
9988 representation must be used, meaning that the length must be a multiple
9989 of 8. Thus the above set of declarations will result in a diagnostic
9990 rejecting the size clause and noting that the minimum size allowed is 64.
9992 @cindex Pragma Pack (for type Natural)
9993 @cindex Pragma Pack warning
9995 One special case that is worth noting occurs when the base type of the
9996 component size is 8/16/32 and the subtype is one bit less. Notably this
9997 occurs with subtype @code{Natural}. Consider:
9999 @smallexample @c ada
10000    type Arr is array (1 .. 32) of Natural;
10001    pragma Pack (Arr);
10002 @end smallexample
10004 @noindent
10005 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10006 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10007 Ada 83 compilers did not attempt 31 bit packing.
10009 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
10010 does pack 31-bit subtype to 31 bits. This may result in a substantial
10011 unintended performance penalty when porting legacy Ada 83 code. To help
10012 prevent this, GNAT generates a warning in such cases. If you really want 31
10013 bit packing in a case like this, you can set the component size explicitly:
10015 @smallexample @c ada
10016    type Arr is array (1 .. 32) of Natural;
10017    for Arr'Component_Size use 31;
10018 @end smallexample
10020 @noindent
10021 Here 31-bit packing is achieved as required, and no warning is generated,
10022 since in this case the programmer intention is clear.
10024 @node Pragma Pack for Records
10025 @section Pragma Pack for Records
10026 @cindex Pragma Pack (for records)
10028 @noindent
10029 Pragma @code{Pack} applied to a record will pack the components to reduce
10030 wasted space from alignment gaps and by reducing the amount of space
10031 taken by components.  We distinguish between @emph{packable} components and
10032 @emph{non-packable} components.
10033 Components of the following types are considered packable:
10034 @itemize @bullet
10035 @item
10036 All primitive types are packable.
10038 @item
10039 Small packed arrays, whose size does not exceed 64 bits, and where the
10040 size is statically known at compile time, are represented internally
10041 as modular integers, and so they are also packable.
10043 @end itemize
10045 @noindent
10046 All packable components occupy the exact number of bits corresponding to
10047 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10048 can start on an arbitrary bit boundary.
10050 All other types are non-packable, they occupy an integral number of
10051 storage units, and
10052 are placed at a boundary corresponding to their alignment requirements.
10054 For example, consider the record
10056 @smallexample @c ada
10057    type Rb1 is array (1 .. 13) of Boolean;
10058    pragma Pack (rb1);
10060    type Rb2 is array (1 .. 65) of Boolean;
10061    pragma Pack (rb2);
10063    type x2 is record
10064       l1 : Boolean;
10065       l2 : Duration;
10066       l3 : Float;
10067       l4 : Boolean;
10068       l5 : Rb1;
10069       l6 : Rb2;
10070    end record;
10071    pragma Pack (x2);
10072 @end smallexample
10074 @noindent
10075 The representation for the record x2 is as follows:
10077 @smallexample @c ada
10078 for x2'Size use 224;
10079 for x2 use record
10080    l1 at  0 range  0 .. 0;
10081    l2 at  0 range  1 .. 64;
10082    l3 at 12 range  0 .. 31;
10083    l4 at 16 range  0 .. 0;
10084    l5 at 16 range  1 .. 13;
10085    l6 at 18 range  0 .. 71;
10086 end record;
10087 @end smallexample
10089 @noindent
10090 Studying this example, we see that the packable fields @code{l1}
10091 and @code{l2} are
10092 of length equal to their sizes, and placed at specific bit boundaries (and
10093 not byte boundaries) to
10094 eliminate padding.  But @code{l3} is of a non-packable float type, so
10095 it is on the next appropriate alignment boundary.
10097 The next two fields are fully packable, so @code{l4} and @code{l5} are
10098 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10099 array that is longer than 64 bits, so it is itself non-packable.  Thus
10100 the @code{l6} field is aligned to the next byte boundary, and takes an
10101 integral number of bytes, i.e.@: 72 bits.
10103 @node Record Representation Clauses
10104 @section Record Representation Clauses
10105 @cindex Record Representation Clause
10107 @noindent
10108 Record representation clauses may be given for all record types, including
10109 types obtained by record extension.  Component clauses are allowed for any
10110 static component.  The restrictions on component clauses depend on the type
10111 of the component.
10113 @cindex Component Clause
10114 For all components of an elementary type, the only restriction on component
10115 clauses is that the size must be at least the 'Size value of the type
10116 (actually the Value_Size).  There are no restrictions due to alignment,
10117 and such components may freely cross storage boundaries.
10119 Packed arrays with a size up to and including 64 bits are represented
10120 internally using a modular type with the appropriate number of bits, and
10121 thus the same lack of restriction applies.  For example, if you declare:
10123 @smallexample @c ada
10124    type R is array (1 .. 49) of Boolean;
10125    pragma Pack (R);
10126    for R'Size use 49;
10127 @end smallexample
10129 @noindent
10130 then a component clause for a component of type R may start on any
10131 specified bit boundary, and may specify a value of 49 bits or greater.
10133 For packed bit arrays that are longer than 64 bits, there are two
10134 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10135 including the important case of single bits or boolean values, then
10136 there are no limitations on placement of such components, and they
10137 may start and end at arbitrary bit boundaries.
10139 If the component size is not a power of 2 (e.g. 3 or 5), then
10140 an array of this type longer than 64 bits must always be placed on
10141 on a storage unit (byte) boundary and occupy an integral number
10142 of storage units (bytes). Any component clause that does not
10143 meet this requirement will be rejected.
10145 Any aliased component, or component of an aliased type, must
10146 have its normal alignment and size. A component clause that
10147 does not meet this requirement will be rejected.
10149 The tag field of a tagged type always occupies an address sized field at
10150 the start of the record.  No component clause may attempt to overlay this
10151 tag. When a tagged type appears as a component, the tag field must have
10152 proper alignment
10154 In the case of a record extension T1, of a type T, no component clause applied
10155 to the type T1 can specify a storage location that would overlap the first
10156 T'Size bytes of the record.
10158 For all other component types, including non-bit-packed arrays,
10159 the component can be placed at an arbitrary bit boundary,
10160 so for example, the following is permitted:
10162 @smallexample @c ada
10163    type R is array (1 .. 10) of Boolean;
10164    for R'Size use 80;
10166    type Q is record
10167       G, H : Boolean;
10168       L, M : R;
10169    end record;
10171    for Q use record
10172       G at 0 range  0 ..   0;
10173       H at 0 range  1 ..   1;
10174       L at 0 range  2 ..  81;
10175       R at 0 range 82 .. 161;
10176    end record;
10177 @end smallexample
10179 @noindent
10180 Note: the above rules apply to recent releases of GNAT 5.
10181 In GNAT 3, there are more severe restrictions on larger components.
10182 For non-primitive types, including packed arrays with a size greater than
10183 64 bits, component clauses must respect the alignment requirement of the
10184 type, in particular, always starting on a byte boundary, and the length
10185 must be a multiple of the storage unit.
10187 @node Enumeration Clauses
10188 @section Enumeration Clauses
10190 The only restriction on enumeration clauses is that the range of values
10191 must be representable.  For the signed case, if one or more of the
10192 representation values are negative, all values must be in the range:
10194 @smallexample @c ada
10195    System.Min_Int .. System.Max_Int
10196 @end smallexample
10198 @noindent
10199 For the unsigned case, where all values are non negative, the values must
10200 be in the range:
10202 @smallexample @c ada
10203    0 .. System.Max_Binary_Modulus;
10204 @end smallexample
10206 @noindent
10207 A @emph{confirming} representation clause is one in which the values range
10208 from 0 in sequence, i.e.@: a clause that confirms the default representation
10209 for an enumeration type.
10210 Such a confirming representation
10211 is permitted by these rules, and is specially recognized by the compiler so
10212 that no extra overhead results from the use of such a clause.
10214 If an array has an index type which is an enumeration type to which an
10215 enumeration clause has been applied, then the array is stored in a compact
10216 manner.  Consider the declarations:
10218 @smallexample @c ada
10219    type r is (A, B, C);
10220    for r use (A => 1, B => 5, C => 10);
10221    type t is array (r) of Character;
10222 @end smallexample
10224 @noindent
10225 The array type t corresponds to a vector with exactly three elements and
10226 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10227 use of space, but means that accesses to elements of the array will incur
10228 the overhead of converting representation values to the corresponding
10229 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10231 @node Address Clauses
10232 @section Address Clauses
10233 @cindex Address Clause
10235 The reference manual allows a general restriction on representation clauses,
10236 as found in RM 13.1(22):
10238 @quotation
10239 An implementation need not support representation
10240 items containing nonstatic expressions, except that
10241 an implementation should support a representation item
10242 for a given entity if each nonstatic expression in the
10243 representation item is a name that statically denotes
10244 a constant declared before the entity.
10245 @end quotation
10247 @noindent
10248 In practice this is applicable only to address clauses, since this is the
10249 only case in which a non-static expression is permitted by the syntax.  As
10250 the AARM notes in sections 13.1 (22.a-22.h):
10252 @display
10253   22.a   Reason: This is to avoid the following sort of thing:
10255   22.b        X : Integer := F(@dots{});
10256               Y : Address := G(@dots{});
10257               for X'Address use Y;
10259   22.c   In the above, we have to evaluate the
10260          initialization expression for X before we
10261          know where to put the result.  This seems
10262          like an unreasonable implementation burden.
10264   22.d   The above code should instead be written
10265          like this:
10267   22.e        Y : constant Address := G(@dots{});
10268               X : Integer := F(@dots{});
10269               for X'Address use Y;
10271   22.f   This allows the expression ``Y'' to be safely
10272          evaluated before X is created.
10274   22.g   The constant could be a formal parameter of mode in.
10276   22.h   An implementation can support other nonstatic
10277          expressions if it wants to.  Expressions of type
10278          Address are hardly ever static, but their value
10279          might be known at compile time anyway in many
10280          cases.
10281 @end display
10283 @noindent
10284 GNAT does indeed permit many additional cases of non-static expressions.  In
10285 particular, if the type involved is elementary there are no restrictions
10286 (since in this case, holding a temporary copy of the initialization value,
10287 if one is present, is inexpensive).  In addition, if there is no implicit or
10288 explicit initialization, then there are no restrictions.  GNAT will reject
10289 only the case where all three of these conditions hold:
10291 @itemize @bullet
10293 @item
10294 The type of the item is non-elementary (e.g.@: a record or array).
10296 @item
10297 There is explicit or implicit initialization required for the object.
10298 Note that access values are always implicitly initialized, and also
10299 in GNAT, certain bit-packed arrays (those having a dynamic length or
10300 a length greater than 64) will also be implicitly initialized to zero.
10302 @item
10303 The address value is non-static.  Here GNAT is more permissive than the
10304 RM, and allows the address value to be the address of a previously declared
10305 stand-alone variable, as long as it does not itself have an address clause.
10307 @smallexample @c ada
10308            Anchor  : Some_Initialized_Type;
10309            Overlay : Some_Initialized_Type;
10310            for Overlay'Address use Anchor'Address;
10311 @end smallexample
10313 @noindent
10314 However, the prefix of the address clause cannot be an array component, or
10315 a component of a discriminated record.
10317 @end itemize
10319 @noindent
10320 As noted above in section 22.h, address values are typically non-static.  In
10321 particular the To_Address function, even if applied to a literal value, is
10322 a non-static function call.  To avoid this minor annoyance, GNAT provides
10323 the implementation defined attribute 'To_Address.  The following two
10324 expressions have identical values:
10326 @findex Attribute
10327 @findex To_Address
10328 @smallexample @c ada
10329    To_Address (16#1234_0000#)
10330    System'To_Address (16#1234_0000#);
10331 @end smallexample
10333 @noindent
10334 except that the second form is considered to be a static expression, and
10335 thus when used as an address clause value is always permitted.
10337 @noindent
10338 Additionally, GNAT treats as static an address clause that is an
10339 unchecked_conversion of a static integer value.  This simplifies the porting
10340 of legacy code, and provides a portable equivalent to the GNAT attribute
10341 @code{To_Address}.
10343 Another issue with address clauses is the interaction with alignment
10344 requirements.  When an address clause is given for an object, the address
10345 value must be consistent with the alignment of the object (which is usually
10346 the same as the alignment of the type of the object).  If an address clause
10347 is given that specifies an inappropriately aligned address value, then the
10348 program execution is erroneous.
10350 Since this source of erroneous behavior can have unfortunate effects, GNAT
10351 checks (at compile time if possible, generating a warning, or at execution
10352 time with a run-time check) that the alignment is appropriate.  If the
10353 run-time check fails, then @code{Program_Error} is raised.  This run-time
10354 check is suppressed if range checks are suppressed, or if the special GNAT
10355 check Alignment_Check is suppressed, or if
10356 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10358 @findex Export
10359 An address clause cannot be given for an exported object.  More
10360 understandably the real restriction is that objects with an address
10361 clause cannot be exported.  This is because such variables are not
10362 defined by the Ada program, so there is no external object to export.
10364 @findex Import
10365 It is permissible to give an address clause and a pragma Import for the
10366 same object.  In this case, the variable is not really defined by the
10367 Ada program, so there is no external symbol to be linked.  The link name
10368 and the external name are ignored in this case.  The reason that we allow this
10369 combination is that it provides a useful idiom to avoid unwanted
10370 initializations on objects with address clauses.
10372 When an address clause is given for an object that has implicit or
10373 explicit initialization, then by default initialization takes place.  This
10374 means that the effect of the object declaration is to overwrite the
10375 memory at the specified address.  This is almost always not what the
10376 programmer wants, so GNAT will output a warning:
10378 @smallexample
10379   with System;
10380   package G is
10381      type R is record
10382         M : Integer := 0;
10383      end record;
10385      Ext : R;
10386      for Ext'Address use System'To_Address (16#1234_1234#);
10387          |
10388   >>> warning: implicit initialization of "Ext" may
10389       modify overlaid storage
10390   >>> warning: use pragma Import for "Ext" to suppress
10391       initialization (RM B(24))
10393   end G;
10394 @end smallexample
10396 @noindent
10397 As indicated by the warning message, the solution is to use a (dummy) pragma
10398 Import to suppress this initialization.  The pragma tell the compiler that the
10399 object is declared and initialized elsewhere.  The following package compiles
10400 without warnings (and the initialization is suppressed):
10402 @smallexample @c ada
10403    with System;
10404    package G is
10405       type R is record
10406          M : Integer := 0;
10407       end record;
10409       Ext : R;
10410       for Ext'Address use System'To_Address (16#1234_1234#);
10411       pragma Import (Ada, Ext);
10412    end G;
10413 @end smallexample
10415 @noindent
10416 A final issue with address clauses involves their use for overlaying
10417 variables, as in the following example:
10418 @cindex Overlaying of objects
10420 @smallexample @c ada
10421   A : Integer;
10422   B : Integer;
10423   for B'Address use A'Address;
10424 @end smallexample
10426 @noindent
10427 or alternatively, using the form recommended by the RM:
10429 @smallexample @c ada
10430   A    : Integer;
10431   Addr : constant Address := A'Address;
10432   B    : Integer;
10433   for B'Address use Addr;
10434 @end smallexample
10436 @noindent
10437 In both of these cases, @code{A}
10438 and @code{B} become aliased to one another via the
10439 address clause. This use of address clauses to overlay
10440 variables, achieving an effect similar to unchecked
10441 conversion was erroneous in Ada 83, but in Ada 95
10442 the effect is implementation defined. Furthermore, the
10443 Ada 95 RM specifically recommends that in a situation
10444 like this, @code{B} should be subject to the following
10445 implementation advice (RM 13.3(19)):
10447 @quotation
10448 19  If the Address of an object is specified, or it is imported
10449     or exported, then the implementation should not perform
10450     optimizations based on assumptions of no aliases.
10451 @end quotation
10453 @noindent
10454 GNAT follows this recommendation, and goes further by also applying
10455 this recommendation to the overlaid variable (@code{A}
10456 in the above example) in this case. This means that the overlay
10457 works "as expected", in that a modification to one of the variables
10458 will affect the value of the other.
10460 @node Effect of Convention on Representation
10461 @section Effect of Convention on Representation
10462 @cindex Convention, effect on representation
10464 @noindent
10465 Normally the specification of a foreign language convention for a type or
10466 an object has no effect on the chosen representation.  In particular, the
10467 representation chosen for data in GNAT generally meets the standard system
10468 conventions, and for example records are laid out in a manner that is
10469 consistent with C@.  This means that specifying convention C (for example)
10470 has no effect.
10472 There are four exceptions to this general rule:
10474 @itemize @bullet
10476 @item Convention Fortran and array subtypes
10477 If pragma Convention Fortran is specified for an array subtype, then in
10478 accordance with the implementation advice in section 3.6.2(11) of the
10479 Ada Reference Manual, the array will be stored in a Fortran-compatible
10480 column-major manner, instead of the normal default row-major order.
10482 @item Convention C and enumeration types
10483 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10484 to accommodate all values of the type.  For example, for the enumeration
10485 type declared by:
10487 @smallexample @c ada
10488    type Color is (Red, Green, Blue);
10489 @end smallexample
10491 @noindent
10492 8 bits is sufficient to store all values of the type, so by default, objects
10493 of type @code{Color} will be represented using 8 bits.  However, normal C
10494 convention is to use 32 bits for all enum values in C, since enum values
10495 are essentially of type int.  If pragma @code{Convention C} is specified for an
10496 Ada enumeration type, then the size is modified as necessary (usually to
10497 32 bits) to be consistent with the C convention for enum values.
10499 @item Convention C/Fortran and Boolean types
10500 In C, the usual convention for boolean values, that is values used for
10501 conditions, is that zero represents false, and nonzero values represent
10502 true.  In Ada, the normal convention is that two specific values, typically
10503 0/1, are used to represent false/true respectively.
10505 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10506 value represents true).
10508 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10509 C or Fortran convention for a derived Boolean, as in the following example:
10511 @smallexample @c ada
10512    type C_Switch is new Boolean;
10513    pragma Convention (C, C_Switch);
10514 @end smallexample
10516 @noindent
10517 then the GNAT generated code will treat any nonzero value as true.  For truth
10518 values generated by GNAT, the conventional value 1 will be used for True, but
10519 when one of these values is read, any nonzero value is treated as True.
10521 @item Access types on OpenVMS
10522 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10523 arrays) are 64-bits long. An exception to this rule is for the case of
10524 C-convention access types where there is no explicit size clause present (or
10525 inherited for derived types). In this case, GNAT chooses to make these
10526 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10527 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10529 @end itemize
10531 @node Determining the Representations chosen by GNAT
10532 @section Determining the Representations chosen by GNAT
10533 @cindex Representation, determination of
10534 @cindex @code{-gnatR} switch
10536 @noindent
10537 Although the descriptions in this section are intended to be complete, it is
10538 often easier to simply experiment to see what GNAT accepts and what the
10539 effect is on the layout of types and objects.
10541 As required by the Ada RM, if a representation clause is not accepted, then
10542 it must be rejected as illegal by the compiler.  However, when a
10543 representation clause or pragma is accepted, there can still be questions
10544 of what the compiler actually does.  For example, if a partial record
10545 representation clause specifies the location of some components and not
10546 others, then where are the non-specified components placed? Or if pragma
10547 @code{Pack} is used on a record, then exactly where are the resulting
10548 fields placed? The section on pragma @code{Pack} in this chapter can be
10549 used to answer the second question, but it is often easier to just see
10550 what the compiler does.
10552 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10553 with this option, then the compiler will output information on the actual
10554 representations chosen, in a format similar to source representation
10555 clauses.  For example, if we compile the package:
10557 @smallexample @c ada
10558 package q is
10559    type r (x : boolean) is tagged record
10560       case x is
10561          when True => S : String (1 .. 100);
10562          when False => null;
10563       end case;
10564    end record;
10566    type r2 is new r (false) with record
10567       y2 : integer;
10568    end record;
10570    for r2 use record
10571       y2 at 16 range 0 .. 31;
10572    end record;
10574    type x is record
10575       y : character;
10576    end record;
10578    type x1 is array (1 .. 10) of x;
10579    for x1'component_size use 11;
10581    type ia is access integer;
10583    type Rb1 is array (1 .. 13) of Boolean;
10584    pragma Pack (rb1);
10586    type Rb2 is array (1 .. 65) of Boolean;
10587    pragma Pack (rb2);
10589    type x2 is record
10590       l1 : Boolean;
10591       l2 : Duration;
10592       l3 : Float;
10593       l4 : Boolean;
10594       l5 : Rb1;
10595       l6 : Rb2;
10596    end record;
10597    pragma Pack (x2);
10598 end q;
10599 @end smallexample
10601 @noindent
10602 using the switch @code{-gnatR} we obtain the following output:
10604 @smallexample
10605 Representation information for unit q
10606 -------------------------------------
10608 for r'Size use ??;
10609 for r'Alignment use 4;
10610 for r use record
10611    x    at 4 range  0 .. 7;
10612    _tag at 0 range  0 .. 31;
10613    s    at 5 range  0 .. 799;
10614 end record;
10616 for r2'Size use 160;
10617 for r2'Alignment use 4;
10618 for r2 use record
10619    x       at  4 range  0 .. 7;
10620    _tag    at  0 range  0 .. 31;
10621    _parent at  0 range  0 .. 63;
10622    y2      at 16 range  0 .. 31;
10623 end record;
10625 for x'Size use 8;
10626 for x'Alignment use 1;
10627 for x use record
10628    y at 0 range  0 .. 7;
10629 end record;
10631 for x1'Size use 112;
10632 for x1'Alignment use 1;
10633 for x1'Component_Size use 11;
10635 for rb1'Size use 13;
10636 for rb1'Alignment use 2;
10637 for rb1'Component_Size use 1;
10639 for rb2'Size use 72;
10640 for rb2'Alignment use 1;
10641 for rb2'Component_Size use 1;
10643 for x2'Size use 224;
10644 for x2'Alignment use 4;
10645 for x2 use record
10646    l1 at  0 range  0 .. 0;
10647    l2 at  0 range  1 .. 64;
10648    l3 at 12 range  0 .. 31;
10649    l4 at 16 range  0 .. 0;
10650    l5 at 16 range  1 .. 13;
10651    l6 at 18 range  0 .. 71;
10652 end record;
10653 @end smallexample
10655 @noindent
10656 The Size values are actually the Object_Size, i.e.@: the default size that
10657 will be allocated for objects of the type.
10658 The ?? size for type r indicates that we have a variant record, and the
10659 actual size of objects will depend on the discriminant value.
10661 The Alignment values show the actual alignment chosen by the compiler
10662 for each record or array type.
10664 The record representation clause for type r shows where all fields
10665 are placed, including the compiler generated tag field (whose location
10666 cannot be controlled by the programmer).
10668 The record representation clause for the type extension r2 shows all the
10669 fields present, including the parent field, which is a copy of the fields
10670 of the parent type of r2, i.e.@: r1.
10672 The component size and size clauses for types rb1 and rb2 show
10673 the exact effect of pragma @code{Pack} on these arrays, and the record
10674 representation clause for type x2 shows how pragma @code{Pack} affects
10675 this record type.
10677 In some cases, it may be useful to cut and paste the representation clauses
10678 generated by the compiler into the original source to fix and guarantee
10679 the actual representation to be used.
10681 @node Standard Library Routines
10682 @chapter Standard Library Routines
10684 @noindent
10685 The Ada 95 Reference Manual contains in Annex A a full description of an
10686 extensive set of standard library routines that can be used in any Ada
10687 program, and which must be provided by all Ada compilers.  They are
10688 analogous to the standard C library used by C programs.
10690 GNAT implements all of the facilities described in annex A, and for most
10691 purposes the description in the Ada 95
10692 reference manual, or appropriate Ada
10693 text book, will be sufficient for making use of these facilities.
10695 In the case of the input-output facilities,
10696 @xref{The Implementation of Standard I/O},
10697 gives details on exactly how GNAT interfaces to the
10698 file system.  For the remaining packages, the Ada 95 reference manual
10699 should be sufficient.  The following is a list of the packages included,
10700 together with a brief description of the functionality that is provided.
10702 For completeness, references are included to other predefined library
10703 routines defined in other sections of the Ada 95 reference manual (these are
10704 cross-indexed from annex A).
10706 @table @code
10707 @item Ada (A.2)
10708 This is a parent package for all the standard library packages.  It is
10709 usually included implicitly in your program, and itself contains no
10710 useful data or routines.
10712 @item Ada.Calendar (9.6)
10713 @code{Calendar} provides time of day access, and routines for
10714 manipulating times and durations.
10716 @item Ada.Characters (A.3.1)
10717 This is a dummy parent package that contains no useful entities
10719 @item Ada.Characters.Handling (A.3.2)
10720 This package provides some basic character handling capabilities,
10721 including classification functions for classes of characters (e.g.@: test
10722 for letters, or digits).
10724 @item Ada.Characters.Latin_1 (A.3.3)
10725 This package includes a complete set of definitions of the characters
10726 that appear in type CHARACTER@.  It is useful for writing programs that
10727 will run in international environments.  For example, if you want an
10728 upper case E with an acute accent in a string, it is often better to use
10729 the definition of @code{UC_E_Acute} in this package.  Then your program
10730 will print in an understandable manner even if your environment does not
10731 support these extended characters.
10733 @item Ada.Command_Line (A.15)
10734 This package provides access to the command line parameters and the name
10735 of the current program (analogous to the use of @code{argc} and @code{argv}
10736 in C), and also allows the exit status for the program to be set in a
10737 system-independent manner.
10739 @item Ada.Decimal (F.2)
10740 This package provides constants describing the range of decimal numbers
10741 implemented, and also a decimal divide routine (analogous to the COBOL
10742 verb DIVIDE .. GIVING .. REMAINDER ..)
10744 @item Ada.Direct_IO (A.8.4)
10745 This package provides input-output using a model of a set of records of
10746 fixed-length, containing an arbitrary definite Ada type, indexed by an
10747 integer record number.
10749 @item Ada.Dynamic_Priorities (D.5)
10750 This package allows the priorities of a task to be adjusted dynamically
10751 as the task is running.
10753 @item Ada.Exceptions (11.4.1)
10754 This package provides additional information on exceptions, and also
10755 contains facilities for treating exceptions as data objects, and raising
10756 exceptions with associated messages.
10758 @item Ada.Finalization (7.6)
10759 This package contains the declarations and subprograms to support the
10760 use of controlled types, providing for automatic initialization and
10761 finalization (analogous to the constructors and destructors of C++)
10763 @item Ada.Interrupts (C.3.2)
10764 This package provides facilities for interfacing to interrupts, which
10765 includes the set of signals or conditions that can be raised and
10766 recognized as interrupts.
10768 @item Ada.Interrupts.Names (C.3.2)
10769 This package provides the set of interrupt names (actually signal
10770 or condition names) that can be handled by GNAT@.
10772 @item Ada.IO_Exceptions (A.13)
10773 This package defines the set of exceptions that can be raised by use of
10774 the standard IO packages.
10776 @item Ada.Numerics
10777 This package contains some standard constants and exceptions used
10778 throughout the numerics packages.  Note that the constants pi and e are
10779 defined here, and it is better to use these definitions than rolling
10780 your own.
10782 @item Ada.Numerics.Complex_Elementary_Functions
10783 Provides the implementation of standard elementary functions (such as
10784 log and trigonometric functions) operating on complex numbers using the
10785 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10786 created by the package @code{Numerics.Complex_Types}.
10788 @item Ada.Numerics.Complex_Types
10789 This is a predefined instantiation of
10790 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10791 build the type @code{Complex} and @code{Imaginary}.
10793 @item Ada.Numerics.Discrete_Random
10794 This package provides a random number generator suitable for generating
10795 random integer values from a specified range.
10797 @item Ada.Numerics.Float_Random
10798 This package provides a random number generator suitable for generating
10799 uniformly distributed floating point values.
10801 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10802 This is a generic version of the package that provides the
10803 implementation of standard elementary functions (such as log and
10804 trigonometric functions) for an arbitrary complex type.
10806 The following predefined instantiations of this package are provided:
10808 @table @code
10809 @item Short_Float
10810 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10811 @item Float
10812 @code{Ada.Numerics.Complex_Elementary_Functions}
10813 @item Long_Float
10814 @code{Ada.Numerics.
10815  Long_Complex_Elementary_Functions}
10816 @end table
10818 @item Ada.Numerics.Generic_Complex_Types
10819 This is a generic package that allows the creation of complex types,
10820 with associated complex arithmetic operations.
10822 The following predefined instantiations of this package exist
10823 @table @code
10824 @item Short_Float
10825 @code{Ada.Numerics.Short_Complex_Complex_Types}
10826 @item Float
10827 @code{Ada.Numerics.Complex_Complex_Types}
10828 @item Long_Float
10829 @code{Ada.Numerics.Long_Complex_Complex_Types}
10830 @end table
10832 @item Ada.Numerics.Generic_Elementary_Functions
10833 This is a generic package that provides the implementation of standard
10834 elementary functions (such as log an trigonometric functions) for an
10835 arbitrary float type.
10837 The following predefined instantiations of this package exist
10839 @table @code
10840 @item Short_Float
10841 @code{Ada.Numerics.Short_Elementary_Functions}
10842 @item Float
10843 @code{Ada.Numerics.Elementary_Functions}
10844 @item Long_Float
10845 @code{Ada.Numerics.Long_Elementary_Functions}
10846 @end table
10848 @item Ada.Real_Time (D.8)
10849 This package provides facilities similar to those of @code{Calendar}, but
10850 operating with a finer clock suitable for real time control. Note that
10851 annex D requires that there be no backward clock jumps, and GNAT generally
10852 guarantees this behavior, but of course if the external clock on which
10853 the GNAT runtime depends is deliberately reset by some external event,
10854 then such a backward jump may occur.
10856 @item Ada.Sequential_IO (A.8.1)
10857 This package provides input-output facilities for sequential files,
10858 which can contain a sequence of values of a single type, which can be
10859 any Ada type, including indefinite (unconstrained) types.
10861 @item Ada.Storage_IO (A.9)
10862 This package provides a facility for mapping arbitrary Ada types to and
10863 from a storage buffer.  It is primarily intended for the creation of new
10864 IO packages.
10866 @item Ada.Streams (13.13.1)
10867 This is a generic package that provides the basic support for the
10868 concept of streams as used by the stream attributes (@code{Input},
10869 @code{Output}, @code{Read} and @code{Write}).
10871 @item Ada.Streams.Stream_IO (A.12.1)
10872 This package is a specialization of the type @code{Streams} defined in
10873 package @code{Streams} together with a set of operations providing
10874 Stream_IO capability.  The Stream_IO model permits both random and
10875 sequential access to a file which can contain an arbitrary set of values
10876 of one or more Ada types.
10878 @item Ada.Strings (A.4.1)
10879 This package provides some basic constants used by the string handling
10880 packages.
10882 @item Ada.Strings.Bounded (A.4.4)
10883 This package provides facilities for handling variable length
10884 strings.  The bounded model requires a maximum length.  It is thus
10885 somewhat more limited than the unbounded model, but avoids the use of
10886 dynamic allocation or finalization.
10888 @item Ada.Strings.Fixed (A.4.3)
10889 This package provides facilities for handling fixed length strings.
10891 @item Ada.Strings.Maps (A.4.2)
10892 This package provides facilities for handling character mappings and
10893 arbitrarily defined subsets of characters.  For instance it is useful in
10894 defining specialized translation tables.
10896 @item Ada.Strings.Maps.Constants (A.4.6)
10897 This package provides a standard set of predefined mappings and
10898 predefined character sets.  For example, the standard upper to lower case
10899 conversion table is found in this package.  Note that upper to lower case
10900 conversion is non-trivial if you want to take the entire set of
10901 characters, including extended characters like E with an acute accent,
10902 into account.  You should use the mappings in this package (rather than
10903 adding 32 yourself) to do case mappings.
10905 @item Ada.Strings.Unbounded (A.4.5)
10906 This package provides facilities for handling variable length
10907 strings.  The unbounded model allows arbitrary length strings, but
10908 requires the use of dynamic allocation and finalization.
10910 @item Ada.Strings.Wide_Bounded (A.4.7)
10911 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10912 @itemx Ada.Strings.Wide_Maps (A.4.7)
10913 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10914 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10915 These packages provide analogous capabilities to the corresponding
10916 packages without @samp{Wide_} in the name, but operate with the types
10917 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10918 and @code{Character}.
10920 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10921 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10922 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10923 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10924 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10925 These packages provide analogous capabilities to the corresponding
10926 packages without @samp{Wide_} in the name, but operate with the types
10927 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10928 of @code{String} and @code{Character}.
10930 @item Ada.Synchronous_Task_Control (D.10)
10931 This package provides some standard facilities for controlling task
10932 communication in a synchronous manner.
10934 @item Ada.Tags
10935 This package contains definitions for manipulation of the tags of tagged
10936 values.
10938 @item Ada.Task_Attributes
10939 This package provides the capability of associating arbitrary
10940 task-specific data with separate tasks.
10942 @item Ada.Text_IO
10943 This package provides basic text input-output capabilities for
10944 character, string and numeric data.  The subpackages of this
10945 package are listed next.
10947 @item Ada.Text_IO.Decimal_IO
10948 Provides input-output facilities for decimal fixed-point types
10950 @item Ada.Text_IO.Enumeration_IO
10951 Provides input-output facilities for enumeration types.
10953 @item Ada.Text_IO.Fixed_IO
10954 Provides input-output facilities for ordinary fixed-point types.
10956 @item Ada.Text_IO.Float_IO
10957 Provides input-output facilities for float types.  The following
10958 predefined instantiations of this generic package are available:
10960 @table @code
10961 @item Short_Float
10962 @code{Short_Float_Text_IO}
10963 @item Float
10964 @code{Float_Text_IO}
10965 @item Long_Float
10966 @code{Long_Float_Text_IO}
10967 @end table
10969 @item Ada.Text_IO.Integer_IO
10970 Provides input-output facilities for integer types.  The following
10971 predefined instantiations of this generic package are available:
10973 @table @code
10974 @item Short_Short_Integer
10975 @code{Ada.Short_Short_Integer_Text_IO}
10976 @item Short_Integer
10977 @code{Ada.Short_Integer_Text_IO}
10978 @item Integer
10979 @code{Ada.Integer_Text_IO}
10980 @item Long_Integer
10981 @code{Ada.Long_Integer_Text_IO}
10982 @item Long_Long_Integer
10983 @code{Ada.Long_Long_Integer_Text_IO}
10984 @end table
10986 @item Ada.Text_IO.Modular_IO
10987 Provides input-output facilities for modular (unsigned) types
10989 @item Ada.Text_IO.Complex_IO (G.1.3)
10990 This package provides basic text input-output capabilities for complex
10991 data.
10993 @item Ada.Text_IO.Editing (F.3.3)
10994 This package contains routines for edited output, analogous to the use
10995 of pictures in COBOL@.  The picture formats used by this package are a
10996 close copy of the facility in COBOL@.
10998 @item Ada.Text_IO.Text_Streams (A.12.2)
10999 This package provides a facility that allows Text_IO files to be treated
11000 as streams, so that the stream attributes can be used for writing
11001 arbitrary data, including binary data, to Text_IO files.
11003 @item Ada.Unchecked_Conversion (13.9)
11004 This generic package allows arbitrary conversion from one type to
11005 another of the same size, providing for breaking the type safety in
11006 special circumstances.
11008 If the types have the same Size (more accurately the same Value_Size),
11009 then the effect is simply to transfer the bits from the source to the
11010 target type without any modification.  This usage is well defined, and
11011 for simple types whose representation is typically the same across
11012 all implementations, gives a portable method of performing such
11013 conversions.
11015 If the types do not have the same size, then the result is implementation
11016 defined, and thus may be non-portable.  The following describes how GNAT
11017 handles such unchecked conversion cases.
11019 If the types are of different sizes, and are both discrete types, then
11020 the effect is of a normal type conversion without any constraint checking.
11021 In particular if the result type has a larger size, the result will be
11022 zero or sign extended.  If the result type has a smaller size, the result
11023 will be truncated by ignoring high order bits.
11025 If the types are of different sizes, and are not both discrete types,
11026 then the conversion works as though pointers were created to the source
11027 and target, and the pointer value is converted.  The effect is that bits
11028 are copied from successive low order storage units and bits of the source
11029 up to the length of the target type.
11031 A warning is issued if the lengths differ, since the effect in this
11032 case is implementation dependent, and the above behavior may not match
11033 that of some other compiler.
11035 A pointer to one type may be converted to a pointer to another type using
11036 unchecked conversion.  The only case in which the effect is undefined is
11037 when one or both pointers are pointers to unconstrained array types.  In
11038 this case, the bounds information may get incorrectly transferred, and in
11039 particular, GNAT uses double size pointers for such types, and it is
11040 meaningless to convert between such pointer types.  GNAT will issue a
11041 warning if the alignment of the target designated type is more strict
11042 than the alignment of the source designated type (since the result may
11043 be unaligned in this case).
11045 A pointer other than a pointer to an unconstrained array type may be
11046 converted to and from System.Address.  Such usage is common in Ada 83
11047 programs, but note that Ada.Address_To_Access_Conversions is the
11048 preferred method of performing such conversions in Ada 95.  Neither
11049 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11050 used in conjunction with pointers to unconstrained objects, since
11051 the bounds information cannot be handled correctly in this case.
11053 @item Ada.Unchecked_Deallocation (13.11.2)
11054 This generic package allows explicit freeing of storage previously
11055 allocated by use of an allocator.
11057 @item Ada.Wide_Text_IO (A.11)
11058 This package is similar to @code{Ada.Text_IO}, except that the external
11059 file supports wide character representations, and the internal types are
11060 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11061 and @code{String}.  It contains generic subpackages listed next.
11063 @item Ada.Wide_Text_IO.Decimal_IO
11064 Provides input-output facilities for decimal fixed-point types
11066 @item Ada.Wide_Text_IO.Enumeration_IO
11067 Provides input-output facilities for enumeration types.
11069 @item Ada.Wide_Text_IO.Fixed_IO
11070 Provides input-output facilities for ordinary fixed-point types.
11072 @item Ada.Wide_Text_IO.Float_IO
11073 Provides input-output facilities for float types.  The following
11074 predefined instantiations of this generic package are available:
11076 @table @code
11077 @item Short_Float
11078 @code{Short_Float_Wide_Text_IO}
11079 @item Float
11080 @code{Float_Wide_Text_IO}
11081 @item Long_Float
11082 @code{Long_Float_Wide_Text_IO}
11083 @end table
11085 @item Ada.Wide_Text_IO.Integer_IO
11086 Provides input-output facilities for integer types.  The following
11087 predefined instantiations of this generic package are available:
11089 @table @code
11090 @item Short_Short_Integer
11091 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11092 @item Short_Integer
11093 @code{Ada.Short_Integer_Wide_Text_IO}
11094 @item Integer
11095 @code{Ada.Integer_Wide_Text_IO}
11096 @item Long_Integer
11097 @code{Ada.Long_Integer_Wide_Text_IO}
11098 @item Long_Long_Integer
11099 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11100 @end table
11102 @item Ada.Wide_Text_IO.Modular_IO
11103 Provides input-output facilities for modular (unsigned) types
11105 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11106 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11107 external file supports wide character representations.
11109 @item Ada.Wide_Text_IO.Editing (F.3.4)
11110 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11111 types are @code{Wide_Character} and @code{Wide_String} instead of
11112 @code{Character} and @code{String}.
11114 @item Ada.Wide_Text_IO.Streams (A.12.3)
11115 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11116 types are @code{Wide_Character} and @code{Wide_String} instead of
11117 @code{Character} and @code{String}.
11119 @item Ada.Wide_Wide_Text_IO (A.11)
11120 This package is similar to @code{Ada.Text_IO}, except that the external
11121 file supports wide character representations, and the internal types are
11122 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11123 and @code{String}.  It contains generic subpackages listed next.
11125 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11126 Provides input-output facilities for decimal fixed-point types
11128 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11129 Provides input-output facilities for enumeration types.
11131 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11132 Provides input-output facilities for ordinary fixed-point types.
11134 @item Ada.Wide_Wide_Text_IO.Float_IO
11135 Provides input-output facilities for float types.  The following
11136 predefined instantiations of this generic package are available:
11138 @table @code
11139 @item Short_Float
11140 @code{Short_Float_Wide_Wide_Text_IO}
11141 @item Float
11142 @code{Float_Wide_Wide_Text_IO}
11143 @item Long_Float
11144 @code{Long_Float_Wide_Wide_Text_IO}
11145 @end table
11147 @item Ada.Wide_Wide_Text_IO.Integer_IO
11148 Provides input-output facilities for integer types.  The following
11149 predefined instantiations of this generic package are available:
11151 @table @code
11152 @item Short_Short_Integer
11153 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11154 @item Short_Integer
11155 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11156 @item Integer
11157 @code{Ada.Integer_Wide_Wide_Text_IO}
11158 @item Long_Integer
11159 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11160 @item Long_Long_Integer
11161 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11162 @end table
11164 @item Ada.Wide_Wide_Text_IO.Modular_IO
11165 Provides input-output facilities for modular (unsigned) types
11167 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11168 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11169 external file supports wide character representations.
11171 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11172 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11173 types are @code{Wide_Character} and @code{Wide_String} instead of
11174 @code{Character} and @code{String}.
11176 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11177 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11178 types are @code{Wide_Character} and @code{Wide_String} instead of
11179 @code{Character} and @code{String}.
11180 @end table
11184 @node The Implementation of Standard I/O
11185 @chapter The Implementation of Standard I/O
11187 @noindent
11188 GNAT implements all the required input-output facilities described in
11189 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
11190 required behavior of these packages from the Ada point of view, and if
11191 you are writing a portable Ada program that does not need to know the
11192 exact manner in which Ada maps to the outside world when it comes to
11193 reading or writing external files, then you do not need to read this
11194 chapter.  As long as your files are all regular files (not pipes or
11195 devices), and as long as you write and read the files only from Ada, the
11196 description in the Ada 95 reference manual is sufficient.
11198 However, if you want to do input-output to pipes or other devices, such
11199 as the keyboard or screen, or if the files you are dealing with are
11200 either generated by some other language, or to be read by some other
11201 language, then you need to know more about the details of how the GNAT
11202 implementation of these input-output facilities behaves.
11204 In this chapter we give a detailed description of exactly how GNAT
11205 interfaces to the file system.  As always, the sources of the system are
11206 available to you for answering questions at an even more detailed level,
11207 but for most purposes the information in this chapter will suffice.
11209 Another reason that you may need to know more about how input-output is
11210 implemented arises when you have a program written in mixed languages
11211 where, for example, files are shared between the C and Ada sections of
11212 the same program.  GNAT provides some additional facilities, in the form
11213 of additional child library packages, that facilitate this sharing, and
11214 these additional facilities are also described in this chapter.
11216 @menu
11217 * Standard I/O Packages::
11218 * FORM Strings::
11219 * Direct_IO::
11220 * Sequential_IO::
11221 * Text_IO::
11222 * Wide_Text_IO::
11223 * Wide_Wide_Text_IO::
11224 * Stream_IO::
11225 * Shared Files::
11226 * Open Modes::
11227 * Operations on C Streams::
11228 * Interfacing to C Streams::
11229 @end menu
11231 @node Standard I/O Packages
11232 @section Standard I/O Packages
11234 @noindent
11235 The Standard I/O packages described in Annex A for
11237 @itemize @bullet
11238 @item
11239 Ada.Text_IO
11240 @item
11241 Ada.Text_IO.Complex_IO
11242 @item
11243 Ada.Text_IO.Text_Streams
11244 @item
11245 Ada.Wide_Text_IO
11246 @item
11247 Ada.Wide_Text_IO.Complex_IO
11248 @item
11249 Ada.Wide_Text_IO.Text_Streams
11250 @item
11251 Ada.Wide_Wide_Text_IO
11252 @item
11253 Ada.Wide_Wide_Text_IO.Complex_IO
11254 @item
11255 Ada.Wide_Wide_Text_IO.Text_Streams
11256 @item
11257 Ada.Stream_IO
11258 @item
11259 Ada.Sequential_IO
11260 @item
11261 Ada.Direct_IO
11262 @end itemize
11264 @noindent
11265 are implemented using the C
11266 library streams facility; where
11268 @itemize @bullet
11269 @item
11270 All files are opened using @code{fopen}.
11271 @item
11272 All input/output operations use @code{fread}/@code{fwrite}.
11273 @end itemize
11275 @noindent
11276 There is no internal buffering of any kind at the Ada library level. The only
11277 buffering is that provided at the system level in the implementation of the
11278 library routines that support streams. This facilitates shared use of these
11279 streams by mixed language programs. Note though that system level buffering is
11280 explicitly enabled at elaboration of the standard I/O packages and that can
11281 have an impact on mixed language programs, in particular those using I/O before
11282 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11283 the Ada elaboration routine before performing any I/O or when impractical,
11284 flush the common I/O streams and in particular Standard_Output before
11285 elaborating the Ada code.
11287 @node FORM Strings
11288 @section FORM Strings
11290 @noindent
11291 The format of a FORM string in GNAT is:
11293 @smallexample
11294 "keyword=value,keyword=value,@dots{},keyword=value"
11295 @end smallexample
11297 @noindent
11298 where letters may be in upper or lower case, and there are no spaces
11299 between values.  The order of the entries is not important.  Currently
11300 there are two keywords defined.
11302 @smallexample
11303 SHARED=[YES|NO]
11304 WCEM=[n|h|u|s\e]
11305 @end smallexample
11307 @noindent
11308 The use of these parameters is described later in this section.
11310 @node Direct_IO
11311 @section Direct_IO
11313 @noindent
11314 Direct_IO can only be instantiated for definite types.  This is a
11315 restriction of the Ada language, which means that the records are fixed
11316 length (the length being determined by @code{@var{type}'Size}, rounded
11317 up to the next storage unit boundary if necessary).
11319 The records of a Direct_IO file are simply written to the file in index
11320 sequence, with the first record starting at offset zero, and subsequent
11321 records following.  There is no control information of any kind.  For
11322 example, if 32-bit integers are being written, each record takes
11323 4-bytes, so the record at index @var{K} starts at offset
11324 (@var{K}@minus{}1)*4.
11326 There is no limit on the size of Direct_IO files, they are expanded as
11327 necessary to accommodate whatever records are written to the file.
11329 @node Sequential_IO
11330 @section Sequential_IO
11332 @noindent
11333 Sequential_IO may be instantiated with either a definite (constrained)
11334 or indefinite (unconstrained) type.
11336 For the definite type case, the elements written to the file are simply
11337 the memory images of the data values with no control information of any
11338 kind.  The resulting file should be read using the same type, no validity
11339 checking is performed on input.
11341 For the indefinite type case, the elements written consist of two
11342 parts.  First is the size of the data item, written as the memory image
11343 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11344 the data value.  The resulting file can only be read using the same
11345 (unconstrained) type.  Normal assignment checks are performed on these
11346 read operations, and if these checks fail, @code{Data_Error} is
11347 raised.  In particular, in the array case, the lengths must match, and in
11348 the variant record case, if the variable for a particular read operation
11349 is constrained, the discriminants must match.
11351 Note that it is not possible to use Sequential_IO to write variable
11352 length array items, and then read the data back into different length
11353 arrays.  For example, the following will raise @code{Data_Error}:
11355 @smallexample @c ada
11356  package IO is new Sequential_IO (String);
11357  F : IO.File_Type;
11358  S : String (1..4);
11359  @dots{}
11360  IO.Create (F)
11361  IO.Write (F, "hello!")
11362  IO.Reset (F, Mode=>In_File);
11363  IO.Read (F, S);
11364  Put_Line (S);
11366 @end smallexample
11368 @noindent
11369 On some Ada implementations, this will print @code{hell}, but the program is
11370 clearly incorrect, since there is only one element in the file, and that
11371 element is the string @code{hello!}.
11373 In Ada 95, this kind of behavior can be legitimately achieved using
11374 Stream_IO, and this is the preferred mechanism.  In particular, the above
11375 program fragment rewritten to use Stream_IO will work correctly.
11377 @node Text_IO
11378 @section Text_IO
11380 @noindent
11381 Text_IO files consist of a stream of characters containing the following
11382 special control characters:
11384 @smallexample
11385 LF (line feed, 16#0A#) Line Mark
11386 FF (form feed, 16#0C#) Page Mark
11387 @end smallexample
11389 @noindent
11390 A canonical Text_IO file is defined as one in which the following
11391 conditions are met:
11393 @itemize @bullet
11394 @item
11395 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11396 of the line.
11398 @item
11399 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11400 end of a page and consequently can appear only immediately following a
11401 @code{LF} (line mark) character.
11403 @item
11404 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11405 (line mark, page mark).  In the former case, the page mark is implicitly
11406 assumed to be present.
11407 @end itemize
11409 @noindent
11410 A file written using Text_IO will be in canonical form provided that no
11411 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11412 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11413 the file unless an explicit @code{New_Page} operation was performed
11414 before closing the file.
11416 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
11417 pipe, can be read using any of the routines in Text_IO@.  The
11418 semantics in this case will be exactly as defined in the Ada 95 reference
11419 manual and all the routines in Text_IO are fully implemented.
11421 A text file that does not meet the requirements for a canonical Text_IO
11422 file has one of the following:
11424 @itemize @bullet
11425 @item
11426 The file contains @code{FF} characters not immediately following a
11427 @code{LF} character.
11429 @item
11430 The file contains @code{LF} or @code{FF} characters written by
11431 @code{Put} or @code{Put_Line}, which are not logically considered to be
11432 line marks or page marks.
11434 @item
11435 The file ends in a character other than @code{LF} or @code{FF},
11436 i.e.@: there is no explicit line mark or page mark at the end of the file.
11437 @end itemize
11439 @noindent
11440 Text_IO can be used to read such non-standard text files but subprograms
11441 to do with line or page numbers do not have defined meanings.  In
11442 particular, a @code{FF} character that does not follow a @code{LF}
11443 character may or may not be treated as a page mark from the point of
11444 view of page and line numbering.  Every @code{LF} character is considered
11445 to end a line, and there is an implied @code{LF} character at the end of
11446 the file.
11448 @menu
11449 * Text_IO Stream Pointer Positioning::
11450 * Text_IO Reading and Writing Non-Regular Files::
11451 * Get_Immediate::
11452 * Treating Text_IO Files as Streams::
11453 * Text_IO Extensions::
11454 * Text_IO Facilities for Unbounded Strings::
11455 @end menu
11457 @node Text_IO Stream Pointer Positioning
11458 @subsection Stream Pointer Positioning
11460 @noindent
11461 @code{Ada.Text_IO} has a definition of current position for a file that
11462 is being read.  No internal buffering occurs in Text_IO, and usually the
11463 physical position in the stream used to implement the file corresponds
11464 to this logical position defined by Text_IO@.  There are two exceptions:
11466 @itemize @bullet
11467 @item
11468 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11469 is positioned past the @code{LF} (line mark) that precedes the page
11470 mark.  Text_IO maintains an internal flag so that subsequent read
11471 operations properly handle the logical position which is unchanged by
11472 the @code{End_Of_Page} call.
11474 @item
11475 After a call to @code{End_Of_File} that returns @code{True}, if the
11476 Text_IO file was positioned before the line mark at the end of file
11477 before the call, then the logical position is unchanged, but the stream
11478 is physically positioned right at the end of file (past the line mark,
11479 and past a possible page mark following the line mark.  Again Text_IO
11480 maintains internal flags so that subsequent read operations properly
11481 handle the logical position.
11482 @end itemize
11484 @noindent
11485 These discrepancies have no effect on the observable behavior of
11486 Text_IO, but if a single Ada stream is shared between a C program and
11487 Ada program, or shared (using @samp{shared=yes} in the form string)
11488 between two Ada files, then the difference may be observable in some
11489 situations.
11491 @node Text_IO Reading and Writing Non-Regular Files
11492 @subsection Reading and Writing Non-Regular Files
11494 @noindent
11495 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11496 can be used for reading and writing.  Writing is not affected and the
11497 sequence of characters output is identical to the normal file case, but
11498 for reading, the behavior of Text_IO is modified to avoid undesirable
11499 look-ahead as follows:
11501 An input file that is not a regular file is considered to have no page
11502 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11503 page mark) appearing in the file are considered to be data
11504 characters.  In particular:
11506 @itemize @bullet
11507 @item
11508 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11509 following a line mark.  If a page mark appears, it will be treated as a
11510 data character.
11512 @item
11513 This avoids the need to wait for an extra character to be typed or
11514 entered from the pipe to complete one of these operations.
11516 @item
11517 @code{End_Of_Page} always returns @code{False}
11519 @item
11520 @code{End_Of_File} will return @code{False} if there is a page mark at
11521 the end of the file.
11522 @end itemize
11524 @noindent
11525 Output to non-regular files is the same as for regular files.  Page marks
11526 may be written to non-regular files using @code{New_Page}, but as noted
11527 above they will not be treated as page marks on input if the output is
11528 piped to another Ada program.
11530 Another important discrepancy when reading non-regular files is that the end
11531 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11532 pressing the @key{EOT} key,
11533 then end of file
11534 is signaled once (i.e.@: the test @code{End_Of_File}
11535 will yield @code{True}, or a read will
11536 raise @code{End_Error}), but then reading can resume
11537 to read data past that end of
11538 file indication, until another end of file indication is entered.
11540 @node Get_Immediate
11541 @subsection Get_Immediate
11542 @cindex Get_Immediate
11544 @noindent
11545 Get_Immediate returns the next character (including control characters)
11546 from the input file.  In particular, Get_Immediate will return LF or FF
11547 characters used as line marks or page marks.  Such operations leave the
11548 file positioned past the control character, and it is thus not treated
11549 as having its normal function.  This means that page, line and column
11550 counts after this kind of Get_Immediate call are set as though the mark
11551 did not occur.  In the case where a Get_Immediate leaves the file
11552 positioned between the line mark and page mark (which is not normally
11553 possible), it is undefined whether the FF character will be treated as a
11554 page mark.
11556 @node Treating Text_IO Files as Streams
11557 @subsection Treating Text_IO Files as Streams
11558 @cindex Stream files
11560 @noindent
11561 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11562 as a stream.  Data written to a Text_IO file in this stream mode is
11563 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11564 16#0C# (@code{FF}), the resulting file may have non-standard
11565 format.  Similarly if read operations are used to read from a Text_IO
11566 file treated as a stream, then @code{LF} and @code{FF} characters may be
11567 skipped and the effect is similar to that described above for
11568 @code{Get_Immediate}.
11570 @node Text_IO Extensions
11571 @subsection Text_IO Extensions
11572 @cindex Text_IO extensions
11574 @noindent
11575 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11576 to the standard @code{Text_IO} package:
11578 @itemize @bullet
11579 @item function File_Exists (Name : String) return Boolean;
11580 Determines if a file of the given name exists.
11582 @item function Get_Line return String;
11583 Reads a string from the standard input file.  The value returned is exactly
11584 the length of the line that was read.
11586 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11587 Similar, except that the parameter File specifies the file from which
11588 the string is to be read.
11590 @end itemize
11592 @node Text_IO Facilities for Unbounded Strings
11593 @subsection Text_IO Facilities for Unbounded Strings
11594 @cindex Text_IO for unbounded strings
11595 @cindex Unbounded_String, Text_IO operations
11597 @noindent
11598 The package @code{Ada.Strings.Unbounded.Text_IO}
11599 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11600 subprograms useful for Text_IO operations on unbounded strings:
11602 @itemize @bullet
11604 @item function Get_Line (File : File_Type) return Unbounded_String;
11605 Reads a line from the specified file
11606 and returns the result as an unbounded string.
11608 @item procedure Put (File : File_Type; U : Unbounded_String);
11609 Writes the value of the given unbounded string to the specified file
11610 Similar to the effect of
11611 @code{Put (To_String (U))} except that an extra copy is avoided.
11613 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11614 Writes the value of the given unbounded string to the specified file,
11615 followed by a @code{New_Line}.
11616 Similar to the effect of @code{Put_Line (To_String (U))} except
11617 that an extra copy is avoided.
11618 @end itemize
11620 @noindent
11621 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11622 and is optional.  If the parameter is omitted, then the standard input or
11623 output file is referenced as appropriate.
11625 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11626 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11627 @code{Wide_Text_IO} functionality for unbounded wide strings.
11629 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11630 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11631 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11633 @node Wide_Text_IO
11634 @section Wide_Text_IO
11636 @noindent
11637 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11638 both input and output files may contain special sequences that represent
11639 wide character values.  The encoding scheme for a given file may be
11640 specified using a FORM parameter:
11642 @smallexample
11643 WCEM=@var{x}
11644 @end smallexample
11646 @noindent
11647 as part of the FORM string (WCEM = wide character encoding method),
11648 where @var{x} is one of the following characters
11650 @table @samp
11651 @item h
11652 Hex ESC encoding
11653 @item u
11654 Upper half encoding
11655 @item s
11656 Shift-JIS encoding
11657 @item e
11658 EUC Encoding
11659 @item 8
11660 UTF-8 encoding
11661 @item b
11662 Brackets encoding
11663 @end table
11665 @noindent
11666 The encoding methods match those that
11667 can be used in a source
11668 program, but there is no requirement that the encoding method used for
11669 the source program be the same as the encoding method used for files,
11670 and different files may use different encoding methods.
11672 The default encoding method for the standard files, and for opened files
11673 for which no WCEM parameter is given in the FORM string matches the
11674 wide character encoding specified for the main program (the default
11675 being brackets encoding if no coding method was specified with -gnatW).
11677 @table @asis
11678 @item Hex Coding
11679 In this encoding, a wide character is represented by a five character
11680 sequence:
11682 @smallexample
11683 ESC a b c d
11684 @end smallexample
11686 @noindent
11687 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11688 characters (using upper case letters) of the wide character code.  For
11689 example, ESC A345 is used to represent the wide character with code
11690 16#A345#.  This scheme is compatible with use of the full
11691 @code{Wide_Character} set.
11693 @item Upper Half Coding
11694 The wide character with encoding 16#abcd#, where the upper bit is on
11695 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11696 16#cd#.  The second byte may never be a format control character, but is
11697 not required to be in the upper half.  This method can be also used for
11698 shift-JIS or EUC where the internal coding matches the external coding.
11700 @item Shift JIS Coding
11701 A wide character is represented by a two character sequence 16#ab# and
11702 16#cd#, with the restrictions described for upper half encoding as
11703 described above.  The internal character code is the corresponding JIS
11704 character according to the standard algorithm for Shift-JIS
11705 conversion.  Only characters defined in the JIS code set table can be
11706 used with this encoding method.
11708 @item EUC Coding
11709 A wide character is represented by a two character sequence 16#ab# and
11710 16#cd#, with both characters being in the upper half.  The internal
11711 character code is the corresponding JIS character according to the EUC
11712 encoding algorithm.  Only characters defined in the JIS code set table
11713 can be used with this encoding method.
11715 @item UTF-8 Coding
11716 A wide character is represented using
11717 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11718 10646-1/Am.2.  Depending on the character value, the representation
11719 is a one, two, or three byte sequence:
11721 @smallexample
11722 16#0000#-16#007f#: 2#0xxxxxxx#
11723 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11724 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11725 @end smallexample
11727 @noindent
11728 where the xxx bits correspond to the left-padded bits of the
11729 16-bit character value.  Note that all lower half ASCII characters
11730 are represented as ASCII bytes and all upper half characters and
11731 other wide characters are represented as sequences of upper-half
11732 (The full UTF-8 scheme allows for encoding 31-bit characters as
11733 6-byte sequences, but in this implementation, all UTF-8 sequences
11734 of four or more bytes length will raise a Constraint_Error, as
11735 will all invalid UTF-8 sequences.)
11737 @item Brackets Coding
11738 In this encoding, a wide character is represented by the following eight
11739 character sequence:
11741 @smallexample
11742 [ " a b c d " ]
11743 @end smallexample
11745 @noindent
11746 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11747 characters (using uppercase letters) of the wide character code.  For
11748 example, @code{["A345"]} is used to represent the wide character with code
11749 @code{16#A345#}.
11750 This scheme is compatible with use of the full Wide_Character set.
11751 On input, brackets coding can also be used for upper half characters,
11752 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11753 is only used for wide characters with a code greater than @code{16#FF#}.
11755 Note that brackets coding is not normally used in the context of
11756 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11757 a portable way of encoding source files. In the context of Wide_Text_IO
11758 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11759 any instance of the left bracket character other than to encode wide
11760 character values using the brackets encoding method. In practice it is
11761 expected that some standard wide character encoding method such
11762 as UTF-8 will be used for text input output.
11764 If brackets notation is used, then any occurrence of a left bracket
11765 in the input file which is not the start of a valid wide character
11766 sequence will cause Constraint_Error to be raised. It is possible to
11767 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11768 input will interpret this as a left bracket.
11770 However, when a left bracket is output, it will be output as a left bracket
11771 and not as ["5B"]. We make this decision because for normal use of
11772 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11773 brackets. For example, if we write:
11775 @smallexample
11776    Put_Line ("Start of output [first run]");
11777 @end smallexample
11779 @noindent
11780 we really do not want to have the left bracket in this message clobbered so
11781 that the output reads:
11783 @smallexample
11784    Start of output ["5B"]first run]
11785 @end smallexample
11787 @noindent
11788 In practice brackets encoding is reasonably useful for normal Put_Line use
11789 since we won't get confused between left brackets and wide character
11790 sequences in the output. But for input, or when files are written out
11791 and read back in, it really makes better sense to use one of the standard
11792 encoding methods such as UTF-8.
11794 @end table
11796 @noindent
11797 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
11798 not all wide character
11799 values can be represented.  An attempt to output a character that cannot
11800 be represented using the encoding scheme for the file causes
11801 Constraint_Error to be raised.  An invalid wide character sequence on
11802 input also causes Constraint_Error to be raised.
11804 @menu
11805 * Wide_Text_IO Stream Pointer Positioning::
11806 * Wide_Text_IO Reading and Writing Non-Regular Files::
11807 @end menu
11809 @node Wide_Text_IO Stream Pointer Positioning
11810 @subsection Stream Pointer Positioning
11812 @noindent
11813 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11814 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11815 case:
11817 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11818 normal lower ASCII set (i.e.@: a character in the range:
11820 @smallexample @c ada
11821 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11822 @end smallexample
11824 @noindent
11825 then although the logical position of the file pointer is unchanged by
11826 the @code{Look_Ahead} call, the stream is physically positioned past the
11827 wide character sequence.  Again this is to avoid the need for buffering
11828 or backup, and all @code{Wide_Text_IO} routines check the internal
11829 indication that this situation has occurred so that this is not visible
11830 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11831 can be observed if the wide text file shares a stream with another file.
11833 @node Wide_Text_IO Reading and Writing Non-Regular Files
11834 @subsection Reading and Writing Non-Regular Files
11836 @noindent
11837 As in the case of Text_IO, when a non-regular file is read, it is
11838 assumed that the file contains no page marks (any form characters are
11839 treated as data characters), and @code{End_Of_Page} always returns
11840 @code{False}.  Similarly, the end of file indication is not sticky, so
11841 it is possible to read beyond an end of file.
11843 @node Wide_Wide_Text_IO
11844 @section Wide_Wide_Text_IO
11846 @noindent
11847 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11848 both input and output files may contain special sequences that represent
11849 wide wide character values.  The encoding scheme for a given file may be
11850 specified using a FORM parameter:
11852 @smallexample
11853 WCEM=@var{x}
11854 @end smallexample
11856 @noindent
11857 as part of the FORM string (WCEM = wide character encoding method),
11858 where @var{x} is one of the following characters
11860 @table @samp
11861 @item h
11862 Hex ESC encoding
11863 @item u
11864 Upper half encoding
11865 @item s
11866 Shift-JIS encoding
11867 @item e
11868 EUC Encoding
11869 @item 8
11870 UTF-8 encoding
11871 @item b
11872 Brackets encoding
11873 @end table
11875 @noindent
11876 The encoding methods match those that
11877 can be used in a source
11878 program, but there is no requirement that the encoding method used for
11879 the source program be the same as the encoding method used for files,
11880 and different files may use different encoding methods.
11882 The default encoding method for the standard files, and for opened files
11883 for which no WCEM parameter is given in the FORM string matches the
11884 wide character encoding specified for the main program (the default
11885 being brackets encoding if no coding method was specified with -gnatW).
11887 @table @asis
11889 @item UTF-8 Coding
11890 A wide character is represented using
11891 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11892 10646-1/Am.2.  Depending on the character value, the representation
11893 is a one, two, three, or four byte sequence:
11895 @smallexample
11896 16#000000#-16#00007f#: 2#0xxxxxxx#
11897 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11898 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11899 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11900 @end smallexample
11902 @noindent
11903 where the xxx bits correspond to the left-padded bits of the
11904 21-bit character value.  Note that all lower half ASCII characters
11905 are represented as ASCII bytes and all upper half characters and
11906 other wide characters are represented as sequences of upper-half
11907 characters.
11909 @item Brackets Coding
11910 In this encoding, a wide wide character is represented by the following eight
11911 character sequence if is in wide character range
11913 @smallexample
11914 [ " a b c d " ]
11915 @end smallexample
11917 and by the following ten character sequence if not
11919 @smallexample
11920 [ " a b c d e f " ]
11921 @end smallexample
11923 @noindent
11924 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11925 are the four or six hexadecimal
11926 characters (using uppercase letters) of the wide wide character code.  For
11927 example, @code{["01A345"]} is used to represent the wide wide character
11928 with code @code{16#01A345#}.
11930 This scheme is compatible with use of the full Wide_Wide_Character set.
11931 On input, brackets coding can also be used for upper half characters,
11932 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11933 is only used for wide characters with a code greater than @code{16#FF#}.
11935 @end table
11937 @noindent
11938 If is also possible to use the other Wide_Character encoding methods,
11939 such as Shift-JIS, but the other schemes cannot support the full range
11940 of wide wide characters.
11941 An attempt to output a character that cannot
11942 be represented using the encoding scheme for the file causes
11943 Constraint_Error to be raised.  An invalid wide character sequence on
11944 input also causes Constraint_Error to be raised.
11946 @menu
11947 * Wide_Wide_Text_IO Stream Pointer Positioning::
11948 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11949 @end menu
11951 @node Wide_Wide_Text_IO Stream Pointer Positioning
11952 @subsection Stream Pointer Positioning
11954 @noindent
11955 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11956 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11957 case:
11959 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11960 normal lower ASCII set (i.e.@: a character in the range:
11962 @smallexample @c ada
11963 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11964 @end smallexample
11966 @noindent
11967 then although the logical position of the file pointer is unchanged by
11968 the @code{Look_Ahead} call, the stream is physically positioned past the
11969 wide character sequence.  Again this is to avoid the need for buffering
11970 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11971 indication that this situation has occurred so that this is not visible
11972 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
11973 can be observed if the wide text file shares a stream with another file.
11975 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11976 @subsection Reading and Writing Non-Regular Files
11978 @noindent
11979 As in the case of Text_IO, when a non-regular file is read, it is
11980 assumed that the file contains no page marks (any form characters are
11981 treated as data characters), and @code{End_Of_Page} always returns
11982 @code{False}.  Similarly, the end of file indication is not sticky, so
11983 it is possible to read beyond an end of file.
11985 @node Stream_IO
11986 @section Stream_IO
11988 @noindent
11989 A stream file is a sequence of bytes, where individual elements are
11990 written to the file as described in the Ada 95 reference manual.  The type
11991 @code{Stream_Element} is simply a byte.  There are two ways to read or
11992 write a stream file.
11994 @itemize @bullet
11995 @item
11996 The operations @code{Read} and @code{Write} directly read or write a
11997 sequence of stream elements with no control information.
11999 @item
12000 The stream attributes applied to a stream file transfer data in the
12001 manner described for stream attributes.
12002 @end itemize
12004 @node Shared Files
12005 @section Shared Files
12007 @noindent
12008 Section A.14 of the Ada 95 Reference Manual allows implementations to
12009 provide a wide variety of behavior if an attempt is made to access the
12010 same external file with two or more internal files.
12012 To provide a full range of functionality, while at the same time
12013 minimizing the problems of portability caused by this implementation
12014 dependence, GNAT handles file sharing as follows:
12016 @itemize @bullet
12017 @item
12018 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12019 to open two or more files with the same full name is considered an error
12020 and is not supported.  The exception @code{Use_Error} will be
12021 raised.  Note that a file that is not explicitly closed by the program
12022 remains open until the program terminates.
12024 @item
12025 If the form parameter @samp{shared=no} appears in the form string, the
12026 file can be opened or created with its own separate stream identifier,
12027 regardless of whether other files sharing the same external file are
12028 opened.  The exact effect depends on how the C stream routines handle
12029 multiple accesses to the same external files using separate streams.
12031 @item
12032 If the form parameter @samp{shared=yes} appears in the form string for
12033 each of two or more files opened using the same full name, the same
12034 stream is shared between these files, and the semantics are as described
12035 in Ada 95 Reference Manual, Section A.14.
12036 @end itemize
12038 @noindent
12039 When a program that opens multiple files with the same name is ported
12040 from another Ada compiler to GNAT, the effect will be that
12041 @code{Use_Error} is raised.
12043 The documentation of the original compiler and the documentation of the
12044 program should then be examined to determine if file sharing was
12045 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12046 and @code{Create} calls as required.
12048 When a program is ported from GNAT to some other Ada compiler, no
12049 special attention is required unless the @samp{shared=@var{xxx}} form
12050 parameter is used in the program.  In this case, you must examine the
12051 documentation of the new compiler to see if it supports the required
12052 file sharing semantics, and form strings modified appropriately.  Of
12053 course it may be the case that the program cannot be ported if the
12054 target compiler does not support the required functionality.  The best
12055 approach in writing portable code is to avoid file sharing (and hence
12056 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12057 completely.
12059 One common use of file sharing in Ada 83 is the use of instantiations of
12060 Sequential_IO on the same file with different types, to achieve
12061 heterogeneous input-output.  Although this approach will work in GNAT if
12062 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
12063 for this purpose (using the stream attributes)
12065 @node Open Modes
12066 @section Open Modes
12068 @noindent
12069 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12070 using the mode shown in the following table:
12072 @sp 2
12073 @center @code{Open} and @code{Create} Call Modes
12074 @smallexample
12075                                @b{OPEN }           @b{CREATE}
12076 Append_File                    "r+"             "w+"
12077 In_File                        "r"              "w+"
12078 Out_File (Direct_IO)           "r+"             "w"
12079 Out_File (all other cases)     "w"              "w"
12080 Inout_File                     "r+"             "w+"
12081 @end smallexample
12083 @noindent
12084 If text file translation is required, then either @samp{b} or @samp{t}
12085 is added to the mode, depending on the setting of Text.  Text file
12086 translation refers to the mapping of CR/LF sequences in an external file
12087 to LF characters internally.  This mapping only occurs in DOS and
12088 DOS-like systems, and is not relevant to other systems.
12090 A special case occurs with Stream_IO@.  As shown in the above table, the
12091 file is initially opened in @samp{r} or @samp{w} mode for the
12092 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12093 subsequently requires switching from reading to writing or vice-versa,
12094 then the file is reopened in @samp{r+} mode to permit the required operation.
12096 @node Operations on C Streams
12097 @section Operations on C Streams
12098 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12099 access to the C library functions for operations on C streams:
12101 @smallexample @c adanocomment
12102 package Interfaces.C_Streams is
12103   -- Note: the reason we do not use the types that are in
12104   -- Interfaces.C is that we want to avoid dragging in the
12105   -- code in this unit if possible.
12106   subtype chars is System.Address;
12107   -- Pointer to null-terminated array of characters
12108   subtype FILEs is System.Address;
12109   -- Corresponds to the C type FILE*
12110   subtype voids is System.Address;
12111   -- Corresponds to the C type void*
12112   subtype int is Integer;
12113   subtype long is Long_Integer;
12114   -- Note: the above types are subtypes deliberately, and it
12115   -- is part of this spec that the above correspondences are
12116   -- guaranteed.  This means that it is legitimate to, for
12117   -- example, use Integer instead of int.  We provide these
12118   -- synonyms for clarity, but in some cases it may be
12119   -- convenient to use the underlying types (for example to
12120   -- avoid an unnecessary dependency of a spec on the spec
12121   -- of this unit).
12122   type size_t is mod 2 ** Standard'Address_Size;
12123   NULL_Stream : constant FILEs;
12124   -- Value returned (NULL in C) to indicate an
12125   -- fdopen/fopen/tmpfile error
12126   ----------------------------------
12127   -- Constants Defined in stdio.h --
12128   ----------------------------------
12129   EOF : constant int;
12130   -- Used by a number of routines to indicate error or
12131   -- end of file
12132   IOFBF : constant int;
12133   IOLBF : constant int;
12134   IONBF : constant int;
12135   -- Used to indicate buffering mode for setvbuf call
12136   SEEK_CUR : constant int;
12137   SEEK_END : constant int;
12138   SEEK_SET : constant int;
12139   -- Used to indicate origin for fseek call
12140   function stdin return FILEs;
12141   function stdout return FILEs;
12142   function stderr return FILEs;
12143   -- Streams associated with standard files
12144   --------------------------
12145   -- Standard C functions --
12146   --------------------------
12147   -- The functions selected below are ones that are
12148   -- available in DOS, OS/2, UNIX and Xenix (but not
12149   -- necessarily in ANSI C).  These are very thin interfaces
12150   -- which copy exactly the C headers.  For more
12151   -- documentation on these functions, see the Microsoft C
12152   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12153   -- ISBN 1-55615-225-6), which includes useful information
12154   -- on system compatibility.
12155   procedure clearerr (stream : FILEs);
12156   function fclose (stream : FILEs) return int;
12157   function fdopen (handle : int; mode : chars) return FILEs;
12158   function feof (stream : FILEs) return int;
12159   function ferror (stream : FILEs) return int;
12160   function fflush (stream : FILEs) return int;
12161   function fgetc (stream : FILEs) return int;
12162   function fgets (strng : chars; n : int; stream : FILEs)
12163       return chars;
12164   function fileno (stream : FILEs) return int;
12165   function fopen (filename : chars; Mode : chars)
12166       return FILEs;
12167   -- Note: to maintain target independence, use
12168   -- text_translation_required, a boolean variable defined in
12169   -- a-sysdep.c to deal with the target dependent text
12170   -- translation requirement.  If this variable is set,
12171   -- then  b/t should be appended to the standard mode
12172   -- argument to set the text translation mode off or on
12173   -- as required.
12174   function fputc (C : int; stream : FILEs) return int;
12175   function fputs (Strng : chars; Stream : FILEs) return int;
12176   function fread
12177      (buffer : voids;
12178       size : size_t;
12179       count : size_t;
12180       stream : FILEs)
12181       return size_t;
12182   function freopen
12183      (filename : chars;
12184       mode : chars;
12185       stream : FILEs)
12186       return FILEs;
12187   function fseek
12188      (stream : FILEs;
12189       offset : long;
12190       origin : int)
12191       return int;
12192   function ftell (stream : FILEs) return long;
12193   function fwrite
12194      (buffer : voids;
12195       size : size_t;
12196       count : size_t;
12197       stream : FILEs)
12198       return size_t;
12199   function isatty (handle : int) return int;
12200   procedure mktemp (template : chars);
12201   -- The return value (which is just a pointer to template)
12202   -- is discarded
12203   procedure rewind (stream : FILEs);
12204   function rmtmp return int;
12205   function setvbuf
12206      (stream : FILEs;
12207       buffer : chars;
12208       mode : int;
12209       size : size_t)
12210       return int;
12212   function tmpfile return FILEs;
12213   function ungetc (c : int; stream : FILEs) return int;
12214   function unlink (filename : chars) return int;
12215   ---------------------
12216   -- Extra functions --
12217   ---------------------
12218   -- These functions supply slightly thicker bindings than
12219   -- those above.  They are derived from functions in the
12220   -- C Run-Time Library, but may do a bit more work than
12221   -- just directly calling one of the Library functions.
12222   function is_regular_file (handle : int) return int;
12223   -- Tests if given handle is for a regular file (result 1)
12224   -- or for a non-regular file (pipe or device, result 0).
12225   ---------------------------------
12226   -- Control of Text/Binary Mode --
12227   ---------------------------------
12228   -- If text_translation_required is true, then the following
12229   -- functions may be used to dynamically switch a file from
12230   -- binary to text mode or vice versa.  These functions have
12231   -- no effect if text_translation_required is false (i.e.  in
12232   -- normal UNIX mode).  Use fileno to get a stream handle.
12233   procedure set_binary_mode (handle : int);
12234   procedure set_text_mode (handle : int);
12235   ----------------------------
12236   -- Full Path Name support --
12237   ----------------------------
12238   procedure full_name (nam : chars; buffer : chars);
12239   -- Given a NUL terminated string representing a file
12240   -- name, returns in buffer a NUL terminated string
12241   -- representing the full path name for the file name.
12242   -- On systems where it is relevant the   drive is also
12243   -- part of the full path name.  It is the responsibility
12244   -- of the caller to pass an actual parameter for buffer
12245   -- that is big enough for any full path name.  Use
12246   -- max_path_len given below as the size of buffer.
12247   max_path_len : integer;
12248   -- Maximum length of an allowable full path name on the
12249   -- system, including a terminating NUL character.
12250 end Interfaces.C_Streams;
12251 @end smallexample
12253 @node Interfacing to C Streams
12254 @section Interfacing to C Streams
12256 @noindent
12257 The packages in this section permit interfacing Ada files to C Stream
12258 operations.
12260 @smallexample @c ada
12261  with Interfaces.C_Streams;
12262  package Ada.Sequential_IO.C_Streams is
12263     function C_Stream (F : File_Type)
12264        return Interfaces.C_Streams.FILEs;
12265     procedure Open
12266       (File : in out File_Type;
12267        Mode : in File_Mode;
12268        C_Stream : in Interfaces.C_Streams.FILEs;
12269        Form : in String := "");
12270  end Ada.Sequential_IO.C_Streams;
12272   with Interfaces.C_Streams;
12273   package Ada.Direct_IO.C_Streams is
12274      function C_Stream (F : File_Type)
12275         return Interfaces.C_Streams.FILEs;
12276      procedure Open
12277        (File : in out File_Type;
12278         Mode : in File_Mode;
12279         C_Stream : in Interfaces.C_Streams.FILEs;
12280         Form : in String := "");
12281   end Ada.Direct_IO.C_Streams;
12283   with Interfaces.C_Streams;
12284   package Ada.Text_IO.C_Streams is
12285      function C_Stream (F : File_Type)
12286         return Interfaces.C_Streams.FILEs;
12287      procedure Open
12288        (File : in out File_Type;
12289         Mode : in File_Mode;
12290         C_Stream : in Interfaces.C_Streams.FILEs;
12291         Form : in String := "");
12292   end Ada.Text_IO.C_Streams;
12294   with Interfaces.C_Streams;
12295   package Ada.Wide_Text_IO.C_Streams is
12296      function C_Stream (F : File_Type)
12297         return Interfaces.C_Streams.FILEs;
12298      procedure Open
12299        (File : in out File_Type;
12300         Mode : in File_Mode;
12301         C_Stream : in Interfaces.C_Streams.FILEs;
12302         Form : in String := "");
12303  end Ada.Wide_Text_IO.C_Streams;
12305   with Interfaces.C_Streams;
12306   package Ada.Wide_Wide_Text_IO.C_Streams is
12307      function C_Stream (F : File_Type)
12308         return Interfaces.C_Streams.FILEs;
12309      procedure Open
12310        (File : in out File_Type;
12311         Mode : in File_Mode;
12312         C_Stream : in Interfaces.C_Streams.FILEs;
12313         Form : in String := "");
12314  end Ada.Wide_Wide_Text_IO.C_Streams;
12316  with Interfaces.C_Streams;
12317  package Ada.Stream_IO.C_Streams is
12318     function C_Stream (F : File_Type)
12319        return Interfaces.C_Streams.FILEs;
12320     procedure Open
12321       (File : in out File_Type;
12322        Mode : in File_Mode;
12323        C_Stream : in Interfaces.C_Streams.FILEs;
12324        Form : in String := "");
12325  end Ada.Stream_IO.C_Streams;
12326 @end smallexample
12328 @noindent
12329 In each of these six packages, the @code{C_Stream} function obtains the
12330 @code{FILE} pointer from a currently opened Ada file.  It is then
12331 possible to use the @code{Interfaces.C_Streams} package to operate on
12332 this stream, or the stream can be passed to a C program which can
12333 operate on it directly.  Of course the program is responsible for
12334 ensuring that only appropriate sequences of operations are executed.
12336 One particular use of relevance to an Ada program is that the
12337 @code{setvbuf} function can be used to control the buffering of the
12338 stream used by an Ada file.  In the absence of such a call the standard
12339 default buffering is used.
12341 The @code{Open} procedures in these packages open a file giving an
12342 existing C Stream instead of a file name.  Typically this stream is
12343 imported from a C program, allowing an Ada file to operate on an
12344 existing C file.
12346 @node The GNAT Library
12347 @chapter The GNAT Library
12349 @noindent
12350 The GNAT library contains a number of general and special purpose packages.
12351 It represents functionality that the GNAT developers have found useful, and
12352 which is made available to GNAT users.  The packages described here are fully
12353 supported, and upwards compatibility will be maintained in future releases,
12354 so you can use these facilities with the confidence that the same functionality
12355 will be available in future releases.
12357 The chapter here simply gives a brief summary of the facilities available.
12358 The full documentation is found in the spec file for the package.  The full
12359 sources of these library packages, including both spec and body, are provided
12360 with all GNAT releases.  For example, to find out the full specifications of
12361 the SPITBOL pattern matching capability, including a full tutorial and
12362 extensive examples, look in the @file{g-spipat.ads} file in the library.
12364 For each entry here, the package name (as it would appear in a @code{with}
12365 clause) is given, followed by the name of the corresponding spec file in
12366 parentheses.  The packages are children in four hierarchies, @code{Ada},
12367 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12368 GNAT-specific hierarchy.
12370 Note that an application program should only use packages in one of these
12371 four hierarchies if the package is defined in the Ada Reference Manual,
12372 or is listed in this section of the GNAT Programmers Reference Manual.
12373 All other units should be considered internal implementation units and
12374 should not be directly @code{with}'ed by application code.  The use of
12375 a @code{with} statement that references one of these internal implementation
12376 units makes an application potentially dependent on changes in versions
12377 of GNAT, and will generate a warning message.
12379 @menu
12380 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12381 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12382 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12383 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12384 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12385 * Ada.Command_Line.Remove (a-colire.ads)::
12386 * Ada.Command_Line.Environment (a-colien.ads)::
12387 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12388 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12389 * Ada.Exceptions.Traceback (a-exctra.ads)::
12390 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12391 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12392 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12393 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12394 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12395 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12396 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12397 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12398 * GNAT.Altivec (g-altive.ads)::
12399 * GNAT.Altivec.Conversions (g-altcon.ads)::
12400 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12401 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12402 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12403 * GNAT.Array_Split (g-arrspl.ads)::
12404 * GNAT.AWK (g-awk.ads)::
12405 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12406 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12407 * GNAT.Bubble_Sort (g-bubsor.ads)::
12408 * GNAT.Bubble_Sort_A (g-busora.ads)::
12409 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12410 * GNAT.Calendar (g-calend.ads)::
12411 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12412 * GNAT.CRC32 (g-crc32.ads)::
12413 * GNAT.Case_Util (g-casuti.ads)::
12414 * GNAT.CGI (g-cgi.ads)::
12415 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12416 * GNAT.CGI.Debug (g-cgideb.ads)::
12417 * GNAT.Command_Line (g-comlin.ads)::
12418 * GNAT.Compiler_Version (g-comver.ads)::
12419 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12420 * GNAT.Current_Exception (g-curexc.ads)::
12421 * GNAT.Debug_Pools (g-debpoo.ads)::
12422 * GNAT.Debug_Utilities (g-debuti.ads)::
12423 * GNAT.Directory_Operations (g-dirope.ads)::
12424 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12425 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12426 * GNAT.Exception_Actions (g-excact.ads)::
12427 * GNAT.Exception_Traces (g-exctra.ads)::
12428 * GNAT.Exceptions (g-except.ads)::
12429 * GNAT.Expect (g-expect.ads)::
12430 * GNAT.Float_Control (g-flocon.ads)::
12431 * GNAT.Heap_Sort (g-heasor.ads)::
12432 * GNAT.Heap_Sort_A (g-hesora.ads)::
12433 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12434 * GNAT.HTable (g-htable.ads)::
12435 * GNAT.IO (g-io.ads)::
12436 * GNAT.IO_Aux (g-io_aux.ads)::
12437 * GNAT.Lock_Files (g-locfil.ads)::
12438 * GNAT.MD5 (g-md5.ads)::
12439 * GNAT.Memory_Dump (g-memdum.ads)::
12440 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12441 * GNAT.OS_Lib (g-os_lib.ads)::
12442 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12443 * GNAT.Regexp (g-regexp.ads)::
12444 * GNAT.Registry (g-regist.ads)::
12445 * GNAT.Regpat (g-regpat.ads)::
12446 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12447 * GNAT.Semaphores (g-semaph.ads)::
12448 * GNAT.Signals (g-signal.ads)::
12449 * GNAT.Sockets (g-socket.ads)::
12450 * GNAT.Source_Info (g-souinf.ads)::
12451 * GNAT.Spell_Checker (g-speche.ads)::
12452 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12453 * GNAT.Spitbol (g-spitbo.ads)::
12454 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12455 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12456 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12457 * GNAT.Strings (g-string.ads)::
12458 * GNAT.String_Split (g-strspl.ads)::
12459 * GNAT.UTF_32 (g-utf_32.ads)::
12460 * GNAT.Table (g-table.ads)::
12461 * GNAT.Task_Lock (g-tasloc.ads)::
12462 * GNAT.Threads (g-thread.ads)::
12463 * GNAT.Traceback (g-traceb.ads)::
12464 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12465 * GNAT.Wide_String_Split (g-wistsp.ads)::
12466 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12467 * Interfaces.C.Extensions (i-cexten.ads)::
12468 * Interfaces.C.Streams (i-cstrea.ads)::
12469 * Interfaces.CPP (i-cpp.ads)::
12470 * Interfaces.Os2lib (i-os2lib.ads)::
12471 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12472 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12473 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12474 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12475 * Interfaces.VxWorks (i-vxwork.ads)::
12476 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12477 * System.Address_Image (s-addima.ads)::
12478 * System.Assertions (s-assert.ads)::
12479 * System.Memory (s-memory.ads)::
12480 * System.Partition_Interface (s-parint.ads)::
12481 * System.Restrictions (s-restri.ads)::
12482 * System.Rident (s-rident.ads)::
12483 * System.Task_Info (s-tasinf.ads)::
12484 * System.Wch_Cnv (s-wchcnv.ads)::
12485 * System.Wch_Con (s-wchcon.ads)::
12486 @end menu
12488 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12489 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12490 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12491 @cindex Latin_9 constants for Character
12493 @noindent
12494 This child of @code{Ada.Characters}
12495 provides a set of definitions corresponding to those in the
12496 RM-defined package @code{Ada.Characters.Latin_1} but with the
12497 few modifications required for @code{Latin-9}
12498 The provision of such a package
12499 is specifically authorized by the Ada Reference Manual
12500 (RM A.3(27)).
12502 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12503 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12504 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12505 @cindex Latin_1 constants for Wide_Character
12507 @noindent
12508 This child of @code{Ada.Characters}
12509 provides a set of definitions corresponding to those in the
12510 RM-defined package @code{Ada.Characters.Latin_1} but with the
12511 types of the constants being @code{Wide_Character}
12512 instead of @code{Character}.  The provision of such a package
12513 is specifically authorized by the Ada Reference Manual
12514 (RM A.3(27)).
12516 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12517 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12518 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12519 @cindex Latin_9 constants for Wide_Character
12521 @noindent
12522 This child of @code{Ada.Characters}
12523 provides a set of definitions corresponding to those in the
12524 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12525 types of the constants being @code{Wide_Character}
12526 instead of @code{Character}.  The provision of such a package
12527 is specifically authorized by the Ada Reference Manual
12528 (RM A.3(27)).
12530 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12531 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12532 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12533 @cindex Latin_1 constants for Wide_Wide_Character
12535 @noindent
12536 This child of @code{Ada.Characters}
12537 provides a set of definitions corresponding to those in the
12538 RM-defined package @code{Ada.Characters.Latin_1} but with the
12539 types of the constants being @code{Wide_Wide_Character}
12540 instead of @code{Character}.  The provision of such a package
12541 is specifically authorized by the Ada Reference Manual
12542 (RM A.3(27)).
12544 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12545 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12546 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12547 @cindex Latin_9 constants for Wide_Wide_Character
12549 @noindent
12550 This child of @code{Ada.Characters}
12551 provides a set of definitions corresponding to those in the
12552 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12553 types of the constants being @code{Wide_Wide_Character}
12554 instead of @code{Character}.  The provision of such a package
12555 is specifically authorized by the Ada Reference Manual
12556 (RM A.3(27)).
12558 @node Ada.Command_Line.Remove (a-colire.ads)
12559 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12560 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12561 @cindex Removing command line arguments
12562 @cindex Command line, argument removal
12564 @noindent
12565 This child of @code{Ada.Command_Line}
12566 provides a mechanism for logically removing
12567 arguments from the argument list.  Once removed, an argument is not visible
12568 to further calls on the subprograms in @code{Ada.Command_Line} will not
12569 see the removed argument.
12571 @node Ada.Command_Line.Environment (a-colien.ads)
12572 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12573 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12574 @cindex Environment entries
12576 @noindent
12577 This child of @code{Ada.Command_Line}
12578 provides a mechanism for obtaining environment values on systems
12579 where this concept makes sense.
12581 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12582 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12583 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12584 @cindex C Streams, Interfacing with Direct_IO
12586 @noindent
12587 This package provides subprograms that allow interfacing between
12588 C streams and @code{Direct_IO}.  The stream identifier can be
12589 extracted from a file opened on the Ada side, and an Ada file
12590 can be constructed from a stream opened on the C side.
12592 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12593 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12594 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12595 @cindex Null_Occurrence, testing for
12597 @noindent
12598 This child subprogram provides a way of testing for the null
12599 exception occurrence (@code{Null_Occurrence}) without raising
12600 an exception.
12602 @node Ada.Exceptions.Traceback (a-exctra.ads)
12603 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12604 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12605 @cindex Traceback for Exception Occurrence
12607 @noindent
12608 This child package provides the subprogram (@code{Tracebacks}) to
12609 give a traceback array of addresses based on an exception
12610 occurrence.
12612 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12613 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12614 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12615 @cindex C Streams, Interfacing with Sequential_IO
12617 @noindent
12618 This package provides subprograms that allow interfacing between
12619 C streams and @code{Sequential_IO}.  The stream identifier can be
12620 extracted from a file opened on the Ada side, and an Ada file
12621 can be constructed from a stream opened on the C side.
12623 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12624 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12625 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12626 @cindex C Streams, Interfacing with Stream_IO
12628 @noindent
12629 This package provides subprograms that allow interfacing between
12630 C streams and @code{Stream_IO}.  The stream identifier can be
12631 extracted from a file opened on the Ada side, and an Ada file
12632 can be constructed from a stream opened on the C side.
12634 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12635 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12636 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12637 @cindex @code{Unbounded_String}, IO support
12638 @cindex @code{Text_IO}, extensions for unbounded strings
12640 @noindent
12641 This package provides subprograms for Text_IO for unbounded
12642 strings, avoiding the necessity for an intermediate operation
12643 with ordinary strings.
12645 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12646 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12647 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12648 @cindex @code{Unbounded_Wide_String}, IO support
12649 @cindex @code{Text_IO}, extensions for unbounded wide strings
12651 @noindent
12652 This package provides subprograms for Text_IO for unbounded
12653 wide strings, avoiding the necessity for an intermediate operation
12654 with ordinary wide strings.
12656 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12657 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12658 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12659 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12660 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12662 @noindent
12663 This package provides subprograms for Text_IO for unbounded
12664 wide wide strings, avoiding the necessity for an intermediate operation
12665 with ordinary wide wide strings.
12667 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12668 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12669 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12670 @cindex C Streams, Interfacing with @code{Text_IO}
12672 @noindent
12673 This package provides subprograms that allow interfacing between
12674 C streams and @code{Text_IO}.  The stream identifier can be
12675 extracted from a file opened on the Ada side, and an Ada file
12676 can be constructed from a stream opened on the C side.
12678 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12679 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12680 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12681 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12683 @noindent
12684 This package provides subprograms that allow interfacing between
12685 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12686 extracted from a file opened on the Ada side, and an Ada file
12687 can be constructed from a stream opened on the C side.
12689 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12690 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12691 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12692 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12694 @noindent
12695 This package provides subprograms that allow interfacing between
12696 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12697 extracted from a file opened on the Ada side, and an Ada file
12698 can be constructed from a stream opened on the C side.
12700 @node GNAT.Altivec (g-altive.ads)
12701 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12702 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12703 @cindex AltiVec
12705 @noindent
12706 This is the root package of the GNAT AltiVec binding. It provides
12707 definitions of constants and types common to all the versions of the
12708 binding.
12710 @node GNAT.Altivec.Conversions (g-altcon.ads)
12711 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12712 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12713 @cindex AltiVec
12715 @noindent
12716 This package provides the Vector/View conversion routines.
12718 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12719 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12720 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12721 @cindex AltiVec
12723 @noindent
12724 This package exposes the Ada interface to the AltiVec operations on
12725 vector objects. A soft emulation is included by default in the GNAT
12726 library. The hard binding is provided as a separate package. This unit
12727 is common to both bindings.
12729 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12730 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12731 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12732 @cindex AltiVec
12734 @noindent
12735 This package exposes the various vector types part of the Ada binding
12736 to AltiVec facilities.
12738 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12739 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12740 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12741 @cindex AltiVec
12743 @noindent
12744 This package provides public 'View' data types from/to which private
12745 vector representations can be converted via
12746 GNAT.Altivec.Conversions. This allows convenient access to individual
12747 vector elements and provides a simple way to initialize vector
12748 objects.
12750 @node GNAT.Array_Split (g-arrspl.ads)
12751 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12752 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12753 @cindex Array splitter
12755 @noindent
12756 Useful array-manipulation routines: given a set of separators, split
12757 an array wherever the separators appear, and provide direct access
12758 to the resulting slices.
12760 @node GNAT.AWK (g-awk.ads)
12761 @section @code{GNAT.AWK} (@file{g-awk.ads})
12762 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12763 @cindex Parsing
12764 @cindex AWK
12766 @noindent
12767 Provides AWK-like parsing functions, with an easy interface for parsing one
12768 or more files containing formatted data.  The file is viewed as a database
12769 where each record is a line and a field is a data element in this line.
12771 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12772 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12773 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12774 @cindex Parsing
12775 @cindex Bounded Buffers
12777 @noindent
12778 Provides a concurrent generic bounded buffer abstraction.  Instances are
12779 useful directly or as parts of the implementations of other abstractions,
12780 such as mailboxes.
12782 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12783 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12784 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12785 @cindex Parsing
12786 @cindex Mailboxes
12788 @noindent
12789 Provides a thread-safe asynchronous intertask mailbox communication facility.
12791 @node GNAT.Bubble_Sort (g-bubsor.ads)
12792 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12793 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12794 @cindex Sorting
12795 @cindex Bubble sort
12797 @noindent
12798 Provides a general implementation of bubble sort usable for sorting arbitrary
12799 data items.  Exchange and comparison procedures are provided by passing
12800 access-to-procedure values.
12802 @node GNAT.Bubble_Sort_A (g-busora.ads)
12803 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12804 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12805 @cindex Sorting
12806 @cindex Bubble sort
12808 @noindent
12809 Provides a general implementation of bubble sort usable for sorting arbitrary
12810 data items.  Move and comparison procedures are provided by passing
12811 access-to-procedure values. This is an older version, retained for
12812 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12814 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12815 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12816 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12817 @cindex Sorting
12818 @cindex Bubble sort
12820 @noindent
12821 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12822 are provided as generic parameters, this improves efficiency, especially
12823 if the procedures can be inlined, at the expense of duplicating code for
12824 multiple instantiations.
12826 @node GNAT.Calendar (g-calend.ads)
12827 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12828 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12829 @cindex @code{Calendar}
12831 @noindent
12832 Extends the facilities provided by @code{Ada.Calendar} to include handling
12833 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12834 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12835 C @code{timeval} format.
12837 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12838 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12839 @cindex @code{Calendar}
12840 @cindex Time
12841 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12843 @node GNAT.CRC32 (g-crc32.ads)
12844 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12845 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12846 @cindex CRC32
12847 @cindex Cyclic Redundancy Check
12849 @noindent
12850 This package implements the CRC-32 algorithm.  For a full description
12851 of this algorithm see
12852 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12853 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12854 Aug.@: 1988.  Sarwate, D.V@.
12856 @noindent
12857 Provides an extended capability for formatted output of time values with
12858 full user control over the format.  Modeled on the GNU Date specification.
12860 @node GNAT.Case_Util (g-casuti.ads)
12861 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12862 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12863 @cindex Casing utilities
12864 @cindex Character handling (@code{GNAT.Case_Util})
12866 @noindent
12867 A set of simple routines for handling upper and lower casing of strings
12868 without the overhead of the full casing tables
12869 in @code{Ada.Characters.Handling}.
12871 @node GNAT.CGI (g-cgi.ads)
12872 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12873 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12874 @cindex CGI (Common Gateway Interface)
12876 @noindent
12877 This is a package for interfacing a GNAT program with a Web server via the
12878 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12879 parameters, which are a set of key/value pairs sent by the Web server.  It
12880 builds a table whose index is the key and provides some services to deal
12881 with this table.
12883 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12884 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12885 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12886 @cindex CGI (Common Gateway Interface) cookie support
12887 @cindex Cookie support in CGI
12889 @noindent
12890 This is a package to interface a GNAT program with a Web server via the
12891 Common Gateway Interface (CGI).  It exports services to deal with Web
12892 cookies (piece of information kept in the Web client software).
12894 @node GNAT.CGI.Debug (g-cgideb.ads)
12895 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12896 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12897 @cindex CGI (Common Gateway Interface) debugging
12899 @noindent
12900 This is a package to help debugging CGI (Common Gateway Interface)
12901 programs written in Ada.
12903 @node GNAT.Command_Line (g-comlin.ads)
12904 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12905 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12906 @cindex Command line
12908 @noindent
12909 Provides a high level interface to @code{Ada.Command_Line} facilities,
12910 including the ability to scan for named switches with optional parameters
12911 and expand file names using wild card notations.
12913 @node GNAT.Compiler_Version (g-comver.ads)
12914 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12915 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12916 @cindex Compiler Version
12917 @cindex Version, of compiler
12919 @noindent
12920 Provides a routine for obtaining the version of the compiler used to
12921 compile the program. More accurately this is the version of the binder
12922 used to bind the program (this will normally be the same as the version
12923 of the compiler if a consistent tool set is used to compile all units
12924 of a partition).
12926 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12927 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12928 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12929 @cindex Interrupt
12931 @noindent
12932 Provides a simple interface to handle Ctrl-C keyboard events.
12934 @node GNAT.Current_Exception (g-curexc.ads)
12935 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12936 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12937 @cindex Current exception
12938 @cindex Exception retrieval
12940 @noindent
12941 Provides access to information on the current exception that has been raised
12942 without the need for using the Ada-95 exception choice parameter specification
12943 syntax.  This is particularly useful in simulating typical facilities for
12944 obtaining information about exceptions provided by Ada 83 compilers.
12946 @node GNAT.Debug_Pools (g-debpoo.ads)
12947 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12948 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12949 @cindex Debugging
12950 @cindex Debug pools
12951 @cindex Memory corruption debugging
12953 @noindent
12954 Provide a debugging storage pools that helps tracking memory corruption
12955 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
12956 the @cite{GNAT User's Guide}.
12958 @node GNAT.Debug_Utilities (g-debuti.ads)
12959 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12960 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12961 @cindex Debugging
12963 @noindent
12964 Provides a few useful utilities for debugging purposes, including conversion
12965 to and from string images of address values. Supports both C and Ada formats
12966 for hexadecimal literals.
12968 @node GNAT.Directory_Operations (g-dirope.ads)
12969 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12970 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12971 @cindex Directory operations
12973 @noindent
12974 Provides a set of routines for manipulating directories, including changing
12975 the current directory, making new directories, and scanning the files in a
12976 directory.
12978 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12979 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12980 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12981 @cindex Hash tables
12983 @noindent
12984 A generic implementation of hash tables that can be used to hash arbitrary
12985 data.  Provided in two forms, a simple form with built in hash functions,
12986 and a more complex form in which the hash function is supplied.
12988 @noindent
12989 This package provides a facility similar to that of @code{GNAT.HTable},
12990 except that this package declares a type that can be used to define
12991 dynamic instances of the hash table, while an instantiation of
12992 @code{GNAT.HTable} creates a single instance of the hash table.
12994 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12995 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12996 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12997 @cindex Table implementation
12998 @cindex Arrays, extendable
13000 @noindent
13001 A generic package providing a single dimension array abstraction where the
13002 length of the array can be dynamically modified.
13004 @noindent
13005 This package provides a facility similar to that of @code{GNAT.Table},
13006 except that this package declares a type that can be used to define
13007 dynamic instances of the table, while an instantiation of
13008 @code{GNAT.Table} creates a single instance of the table type.
13010 @node GNAT.Exception_Actions (g-excact.ads)
13011 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13012 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13013 @cindex Exception actions
13015 @noindent
13016 Provides callbacks when an exception is raised. Callbacks can be registered
13017 for specific exceptions, or when any exception is raised. This
13018 can be used for instance to force a core dump to ease debugging.
13020 @node GNAT.Exception_Traces (g-exctra.ads)
13021 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13022 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13023 @cindex Exception traces
13024 @cindex Debugging
13026 @noindent
13027 Provides an interface allowing to control automatic output upon exception
13028 occurrences.
13030 @node GNAT.Exceptions (g-except.ads)
13031 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13032 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13033 @cindex Exceptions, Pure
13034 @cindex Pure packages, exceptions
13036 @noindent
13037 Normally it is not possible to raise an exception with
13038 a message from a subprogram in a pure package, since the
13039 necessary types and subprograms are in @code{Ada.Exceptions}
13040 which is not a pure unit. @code{GNAT.Exceptions} provides a
13041 facility for getting around this limitation for a few
13042 predefined exceptions, and for example allow raising
13043 @code{Constraint_Error} with a message from a pure subprogram.
13045 @node GNAT.Expect (g-expect.ads)
13046 @section @code{GNAT.Expect} (@file{g-expect.ads})
13047 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13049 @noindent
13050 Provides a set of subprograms similar to what is available
13051 with the standard Tcl Expect tool.
13052 It allows you to easily spawn and communicate with an external process.
13053 You can send commands or inputs to the process, and compare the output
13054 with some expected regular expression. Currently @code{GNAT.Expect}
13055 is implemented on all native GNAT ports except for OpenVMS@.
13056 It is not implemented for cross ports, and in particular is not
13057 implemented for VxWorks or LynxOS@.
13059 @node GNAT.Float_Control (g-flocon.ads)
13060 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13061 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13062 @cindex Floating-Point Processor
13064 @noindent
13065 Provides an interface for resetting the floating-point processor into the
13066 mode required for correct semantic operation in Ada.  Some third party
13067 library calls may cause this mode to be modified, and the Reset procedure
13068 in this package can be used to reestablish the required mode.
13070 @node GNAT.Heap_Sort (g-heasor.ads)
13071 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13072 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13073 @cindex Sorting
13075 @noindent
13076 Provides a general implementation of heap sort usable for sorting arbitrary
13077 data items. Exchange and comparison procedures are provided by passing
13078 access-to-procedure values.  The algorithm used is a modified heap sort
13079 that performs approximately N*log(N) comparisons in the worst case.
13081 @node GNAT.Heap_Sort_A (g-hesora.ads)
13082 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13083 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13084 @cindex Sorting
13086 @noindent
13087 Provides a general implementation of heap sort usable for sorting arbitrary
13088 data items. Move and comparison procedures are provided by passing
13089 access-to-procedure values.  The algorithm used is a modified heap sort
13090 that performs approximately N*log(N) comparisons in the worst case.
13091 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13092 interface, but may be slightly more efficient.
13094 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13095 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13096 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13097 @cindex Sorting
13099 @noindent
13100 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13101 are provided as generic parameters, this improves efficiency, especially
13102 if the procedures can be inlined, at the expense of duplicating code for
13103 multiple instantiations.
13105 @node GNAT.HTable (g-htable.ads)
13106 @section @code{GNAT.HTable} (@file{g-htable.ads})
13107 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13108 @cindex Hash tables
13110 @noindent
13111 A generic implementation of hash tables that can be used to hash arbitrary
13112 data.  Provides two approaches, one a simple static approach, and the other
13113 allowing arbitrary dynamic hash tables.
13115 @node GNAT.IO (g-io.ads)
13116 @section @code{GNAT.IO} (@file{g-io.ads})
13117 @cindex @code{GNAT.IO} (@file{g-io.ads})
13118 @cindex Simple I/O
13119 @cindex Input/Output facilities
13121 @noindent
13122 A simple preelaborable input-output package that provides a subset of
13123 simple Text_IO functions for reading characters and strings from
13124 Standard_Input, and writing characters, strings and integers to either
13125 Standard_Output or Standard_Error.
13127 @node GNAT.IO_Aux (g-io_aux.ads)
13128 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13129 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13130 @cindex Text_IO
13131 @cindex Input/Output facilities
13133 Provides some auxiliary functions for use with Text_IO, including a test
13134 for whether a file exists, and functions for reading a line of text.
13136 @node GNAT.Lock_Files (g-locfil.ads)
13137 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13138 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13139 @cindex File locking
13140 @cindex Locking using files
13142 @noindent
13143 Provides a general interface for using files as locks.  Can be used for
13144 providing program level synchronization.
13146 @node GNAT.MD5 (g-md5.ads)
13147 @section @code{GNAT.MD5} (@file{g-md5.ads})
13148 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13149 @cindex Message Digest MD5
13151 @noindent
13152 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13154 @node GNAT.Memory_Dump (g-memdum.ads)
13155 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13156 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13157 @cindex Dump Memory
13159 @noindent
13160 Provides a convenient routine for dumping raw memory to either the
13161 standard output or standard error files. Uses GNAT.IO for actual
13162 output.
13164 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13165 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13166 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13167 @cindex Exception, obtaining most recent
13169 @noindent
13170 Provides access to the most recently raised exception.  Can be used for
13171 various logging purposes, including duplicating functionality of some
13172 Ada 83 implementation dependent extensions.
13174 @node GNAT.OS_Lib (g-os_lib.ads)
13175 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13176 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13177 @cindex Operating System interface
13178 @cindex Spawn capability
13180 @noindent
13181 Provides a range of target independent operating system interface functions,
13182 including time/date management, file operations, subprocess management,
13183 including a portable spawn procedure, and access to environment variables
13184 and error return codes.
13186 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13187 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13188 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13189 @cindex Hash functions
13191 @noindent
13192 Provides a generator of static minimal perfect hash functions. No
13193 collisions occur and each item can be retrieved from the table in one
13194 probe (perfect property). The hash table size corresponds to the exact
13195 size of the key set and no larger (minimal property). The key set has to
13196 be know in advance (static property). The hash functions are also order
13197 preserving. If w2 is inserted after w1 in the generator, their
13198 hashcode are in the same order. These hashing functions are very
13199 convenient for use with realtime applications.
13201 @node GNAT.Regexp (g-regexp.ads)
13202 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13203 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13204 @cindex Regular expressions
13205 @cindex Pattern matching
13207 @noindent
13208 A simple implementation of regular expressions, using a subset of regular
13209 expression syntax copied from familiar Unix style utilities.  This is the
13210 simples of the three pattern matching packages provided, and is particularly
13211 suitable for ``file globbing'' applications.
13213 @node GNAT.Registry (g-regist.ads)
13214 @section @code{GNAT.Registry} (@file{g-regist.ads})
13215 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13216 @cindex Windows Registry
13218 @noindent
13219 This is a high level binding to the Windows registry.  It is possible to
13220 do simple things like reading a key value, creating a new key.  For full
13221 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13222 package provided with the Win32Ada binding
13224 @node GNAT.Regpat (g-regpat.ads)
13225 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13226 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13227 @cindex Regular expressions
13228 @cindex Pattern matching
13230 @noindent
13231 A complete implementation of Unix-style regular expression matching, copied
13232 from the original V7 style regular expression library written in C by
13233 Henry Spencer (and binary compatible with this C library).
13235 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13236 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13237 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13238 @cindex Secondary Stack Info
13240 @noindent
13241 Provide the capability to query the high water mark of the current task's
13242 secondary stack.
13244 @node GNAT.Semaphores (g-semaph.ads)
13245 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13246 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13247 @cindex Semaphores
13249 @noindent
13250 Provides classic counting and binary semaphores using protected types.
13252 @node GNAT.Signals (g-signal.ads)
13253 @section @code{GNAT.Signals} (@file{g-signal.ads})
13254 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13255 @cindex Signals
13257 @noindent
13258 Provides the ability to manipulate the blocked status of signals on supported
13259 targets.
13261 @node GNAT.Sockets (g-socket.ads)
13262 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13263 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13264 @cindex Sockets
13266 @noindent
13267 A high level and portable interface to develop sockets based applications.
13268 This package is based on the sockets thin binding found in
13269 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13270 on all native GNAT ports except for OpenVMS@.  It is not implemented
13271 for the LynxOS@ cross port.
13273 @node GNAT.Source_Info (g-souinf.ads)
13274 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13275 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13276 @cindex Source Information
13278 @noindent
13279 Provides subprograms that give access to source code information known at
13280 compile time, such as the current file name and line number.
13282 @node GNAT.Spell_Checker (g-speche.ads)
13283 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13284 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13285 @cindex Spell checking
13287 @noindent
13288 Provides a function for determining whether one string is a plausible
13289 near misspelling of another string.
13291 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13292 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13293 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13294 @cindex SPITBOL pattern matching
13295 @cindex Pattern matching
13297 @noindent
13298 A complete implementation of SNOBOL4 style pattern matching.  This is the
13299 most elaborate of the pattern matching packages provided.  It fully duplicates
13300 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13301 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13303 @node GNAT.Spitbol (g-spitbo.ads)
13304 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13305 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13306 @cindex SPITBOL interface
13308 @noindent
13309 The top level package of the collection of SPITBOL-style functionality, this
13310 package provides basic SNOBOL4 string manipulation functions, such as
13311 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13312 useful for constructing arbitrary mappings from strings in the style of
13313 the SNOBOL4 TABLE function.
13315 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13316 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13317 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13318 @cindex Sets of strings
13319 @cindex SPITBOL Tables
13321 @noindent
13322 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13323 for type @code{Standard.Boolean}, giving an implementation of sets of
13324 string values.
13326 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13327 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13328 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13329 @cindex Integer maps
13330 @cindex Maps
13331 @cindex SPITBOL Tables
13333 @noindent
13334 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13335 for type @code{Standard.Integer}, giving an implementation of maps
13336 from string to integer values.
13338 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13339 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13340 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13341 @cindex String maps
13342 @cindex Maps
13343 @cindex SPITBOL Tables
13345 @noindent
13346 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13347 a variable length string type, giving an implementation of general
13348 maps from strings to strings.
13350 @node GNAT.Strings (g-string.ads)
13351 @section @code{GNAT.Strings} (@file{g-string.ads})
13352 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13354 @noindent
13355 Common String access types and related subprograms. Basically it
13356 defines a string access and an array of string access types.
13358 @node GNAT.String_Split (g-strspl.ads)
13359 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13360 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13361 @cindex String splitter
13363 @noindent
13364 Useful string manipulation routines: given a set of separators, split
13365 a string wherever the separators appear, and provide direct access
13366 to the resulting slices. This package is instantiated from
13367 @code{GNAT.Array_Split}.
13369 @node GNAT.UTF_32 (g-utf_32.ads)
13370 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13371 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13372 @cindex Wide character codes
13374 @noindent
13375 This is a package intended to be used in conjunction with the
13376 @code{Wide_Character} type in Ada 95 and the
13377 @code{Wide_Wide_Character} type in Ada 2005 (available
13378 in @code{GNAT} in Ada 2005 mode). This package contains
13379 Unicode categorization routines, as well as lexical
13380 categorization routines corresponding to the Ada 2005
13381 lexical rules for identifiers and strings, and also a
13382 lower case to upper case fold routine corresponding to
13383 the Ada 2005 rules for identifier equivalence.
13385 @node GNAT.Table (g-table.ads)
13386 @section @code{GNAT.Table} (@file{g-table.ads})
13387 @cindex @code{GNAT.Table} (@file{g-table.ads})
13388 @cindex Table implementation
13389 @cindex Arrays, extendable
13391 @noindent
13392 A generic package providing a single dimension array abstraction where the
13393 length of the array can be dynamically modified.
13395 @noindent
13396 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13397 except that this package declares a single instance of the table type,
13398 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13399 used to define dynamic instances of the table.
13401 @node GNAT.Task_Lock (g-tasloc.ads)
13402 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13403 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13404 @cindex Task synchronization
13405 @cindex Task locking
13406 @cindex Locking
13408 @noindent
13409 A very simple facility for locking and unlocking sections of code using a
13410 single global task lock.  Appropriate for use in situations where contention
13411 between tasks is very rarely expected.
13413 @node GNAT.Threads (g-thread.ads)
13414 @section @code{GNAT.Threads} (@file{g-thread.ads})
13415 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13416 @cindex Foreign threads
13417 @cindex Threads, foreign
13419 @noindent
13420 Provides facilities for creating and destroying threads with explicit calls.
13421 These threads are known to the GNAT run-time system.  These subprograms are
13422 exported C-convention procedures intended to be called from foreign code.
13423 By using these primitives rather than directly calling operating systems
13424 routines, compatibility with the Ada tasking run-time is provided.
13426 @node GNAT.Traceback (g-traceb.ads)
13427 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13428 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13429 @cindex Trace back facilities
13431 @noindent
13432 Provides a facility for obtaining non-symbolic traceback information, useful
13433 in various debugging situations.
13435 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13436 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13437 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13438 @cindex Trace back facilities
13440 @noindent
13441 Provides symbolic traceback information that includes the subprogram
13442 name and line number information.
13444 @node GNAT.Wide_String_Split (g-wistsp.ads)
13445 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13446 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13447 @cindex Wide_String splitter
13449 @noindent
13450 Useful wide string manipulation routines: given a set of separators, split
13451 a wide string wherever the separators appear, and provide direct access
13452 to the resulting slices. This package is instantiated from
13453 @code{GNAT.Array_Split}.
13455 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13456 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13457 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13458 @cindex Wide_Wide_String splitter
13460 @noindent
13461 Useful wide wide string manipulation routines: given a set of separators, split
13462 a wide wide string wherever the separators appear, and provide direct access
13463 to the resulting slices. This package is instantiated from
13464 @code{GNAT.Array_Split}.
13466 @node Interfaces.C.Extensions (i-cexten.ads)
13467 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13468 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13470 @noindent
13471 This package contains additional C-related definitions, intended
13472 for use with either manually or automatically generated bindings
13473 to C libraries.
13475 @node Interfaces.C.Streams (i-cstrea.ads)
13476 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13477 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13478 @cindex  C streams, interfacing
13480 @noindent
13481 This package is a binding for the most commonly used operations
13482 on C streams.
13484 @node Interfaces.CPP (i-cpp.ads)
13485 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13486 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13487 @cindex  C++ interfacing
13488 @cindex  Interfacing, to C++
13490 @noindent
13491 This package provides facilities for use in interfacing to C++.  It
13492 is primarily intended to be used in connection with automated tools
13493 for the generation of C++ interfaces.
13495 @node Interfaces.Os2lib (i-os2lib.ads)
13496 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13497 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13498 @cindex Interfacing, to OS/2
13499 @cindex OS/2 interfacing
13501 @noindent
13502 This package provides interface definitions to the OS/2 library.
13503 It is a thin binding which is a direct translation of the
13504 various @file{<bse@.h>} files.
13506 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13507 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13508 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13509 @cindex OS/2 Error codes
13510 @cindex Interfacing, to OS/2
13511 @cindex OS/2 interfacing
13513 @noindent
13514 This package provides definitions of the OS/2 error codes.
13516 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13517 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13518 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13519 @cindex Interfacing, to OS/2
13520 @cindex Synchronization, OS/2
13521 @cindex OS/2 synchronization primitives
13523 @noindent
13524 This is a child package that provides definitions for interfacing
13525 to the @code{OS/2} synchronization primitives.
13527 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13528 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13529 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13530 @cindex Interfacing, to OS/2
13531 @cindex Thread control, OS/2
13532 @cindex OS/2 thread interfacing
13534 @noindent
13535 This is a child package that provides definitions for interfacing
13536 to the @code{OS/2} thread primitives.
13538 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13539 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13540 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13541 @cindex  IBM Packed Format
13542 @cindex  Packed Decimal
13544 @noindent
13545 This package provides a set of routines for conversions to and
13546 from a packed decimal format compatible with that used on IBM
13547 mainframes.
13549 @node Interfaces.VxWorks (i-vxwork.ads)
13550 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13551 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13552 @cindex Interfacing to VxWorks
13553 @cindex VxWorks, interfacing
13555 @noindent
13556 This package provides a limited binding to the VxWorks API.
13557 In particular, it interfaces with the
13558 VxWorks hardware interrupt facilities.
13560 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13561 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13562 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13563 @cindex Interfacing to VxWorks' I/O
13564 @cindex VxWorks, I/O interfacing
13565 @cindex VxWorks, Get_Immediate
13566 @cindex Get_Immediate, VxWorks
13568 @noindent
13569 This package provides a binding to the ioctl (IO/Control)
13570 function of VxWorks, defining a set of option values and
13571 function codes. A particular use of this package is
13572 to enable the use of Get_Immediate under VxWorks.
13574 @node System.Address_Image (s-addima.ads)
13575 @section @code{System.Address_Image} (@file{s-addima.ads})
13576 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13577 @cindex Address image
13578 @cindex Image, of an address
13580 @noindent
13581 This function provides a useful debugging
13582 function that gives an (implementation dependent)
13583 string which identifies an address.
13585 @node System.Assertions (s-assert.ads)
13586 @section @code{System.Assertions} (@file{s-assert.ads})
13587 @cindex @code{System.Assertions} (@file{s-assert.ads})
13588 @cindex Assertions
13589 @cindex Assert_Failure, exception
13591 @noindent
13592 This package provides the declaration of the exception raised
13593 by an run-time assertion failure, as well as the routine that
13594 is used internally to raise this assertion.
13596 @node System.Memory (s-memory.ads)
13597 @section @code{System.Memory} (@file{s-memory.ads})
13598 @cindex @code{System.Memory} (@file{s-memory.ads})
13599 @cindex Memory allocation
13601 @noindent
13602 This package provides the interface to the low level routines used
13603 by the generated code for allocation and freeing storage for the
13604 default storage pool (analogous to the C routines malloc and free.
13605 It also provides a reallocation interface analogous to the C routine
13606 realloc. The body of this unit may be modified to provide alternative
13607 allocation mechanisms for the default pool, and in addition, direct
13608 calls to this unit may be made for low level allocation uses (for
13609 example see the body of @code{GNAT.Tables}).
13611 @node System.Partition_Interface (s-parint.ads)
13612 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13613 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13614 @cindex Partition interfacing functions
13616 @noindent
13617 This package provides facilities for partition interfacing.  It
13618 is used primarily in a distribution context when using Annex E
13619 with @code{GLADE}.
13621 @node System.Restrictions (s-restri.ads)
13622 @section @code{System.Restrictions} (@file{s-restri.ads})
13623 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13624 @cindex Run-time restrictions access
13626 @noindent
13627 This package provides facilities for accessing at run-time
13628 the status of restrictions specified at compile time for
13629 the partition. Information is available both with regard
13630 to actual restrictions specified, and with regard to
13631 compiler determined information on which restrictions
13632 are violated by one or more packages in the partition.
13634 @node System.Rident (s-rident.ads)
13635 @section @code{System.Rident} (@file{s-rident.ads})
13636 @cindex @code{System.Rident} (@file{s-rident.ads})
13637 @cindex Restrictions definitions
13639 @noindent
13640 This package provides definitions of the restrictions
13641 identifiers supported by GNAT, and also the format of
13642 the restrictions provided in package System.Restrictions.
13643 It is not normally necessary to @code{with} this generic package
13644 since the necessary instantiation is included in
13645 package System.Restrictions.
13647 @node System.Task_Info (s-tasinf.ads)
13648 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13649 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13650 @cindex Task_Info pragma
13652 @noindent
13653 This package provides target dependent functionality that is used
13654 to support the @code{Task_Info} pragma
13656 @node System.Wch_Cnv (s-wchcnv.ads)
13657 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13658 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13659 @cindex Wide Character, Representation
13660 @cindex Wide String, Conversion
13661 @cindex Representation of wide characters
13663 @noindent
13664 This package provides routines for converting between
13665 wide and wide wide characters and a representation as a value of type
13666 @code{Standard.String}, using a specified wide character
13667 encoding method.  It uses definitions in
13668 package @code{System.Wch_Con}.
13670 @node System.Wch_Con (s-wchcon.ads)
13671 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13672 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13674 @noindent
13675 This package provides definitions and descriptions of
13676 the various methods used for encoding wide characters
13677 in ordinary strings.  These definitions are used by
13678 the package @code{System.Wch_Cnv}.
13680 @node Interfacing to Other Languages
13681 @chapter Interfacing to Other Languages
13682 @noindent
13683 The facilities in annex B of the Ada 95 Reference Manual are fully
13684 implemented in GNAT, and in addition, a full interface to C++ is
13685 provided.
13687 @menu
13688 * Interfacing to C::
13689 * Interfacing to C++::
13690 * Interfacing to COBOL::
13691 * Interfacing to Fortran::
13692 * Interfacing to non-GNAT Ada code::
13693 @end menu
13695 @node Interfacing to C
13696 @section Interfacing to C
13698 @noindent
13699 Interfacing to C with GNAT can use one of two approaches:
13701 @itemize @bullet
13702 @item
13703 The types in the package @code{Interfaces.C} may be used.
13704 @item
13705 Standard Ada types may be used directly.  This may be less portable to
13706 other compilers, but will work on all GNAT compilers, which guarantee
13707 correspondence between the C and Ada types.
13708 @end itemize
13710 @noindent
13711 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13712 effect, since this is the default.  The following table shows the
13713 correspondence between Ada scalar types and the corresponding C types.
13715 @table @code
13716 @item Integer
13717 @code{int}
13718 @item Short_Integer
13719 @code{short}
13720 @item Short_Short_Integer
13721 @code{signed char}
13722 @item Long_Integer
13723 @code{long}
13724 @item Long_Long_Integer
13725 @code{long long}
13726 @item Short_Float
13727 @code{float}
13728 @item Float
13729 @code{float}
13730 @item Long_Float
13731 @code{double}
13732 @item Long_Long_Float
13733 This is the longest floating-point type supported by the hardware.
13734 @end table
13736 @noindent
13737 Additionally, there are the following general correspondences between Ada
13738 and C types:
13739 @itemize @bullet
13740 @item
13741 Ada enumeration types map to C enumeration types directly if pragma
13742 @code{Convention C} is specified, which causes them to have int
13743 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13744 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13745 @code{int}, respectively) depending on the number of values passed.
13746 This is the only case in which pragma @code{Convention C} affects the
13747 representation of an Ada type.
13749 @item
13750 Ada access types map to C pointers, except for the case of pointers to
13751 unconstrained types in Ada, which have no direct C equivalent.
13753 @item
13754 Ada arrays map directly to C arrays.
13756 @item
13757 Ada records map directly to C structures.
13759 @item
13760 Packed Ada records map to C structures where all members are bit fields
13761 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13762 @end itemize
13764 @node Interfacing to C++
13765 @section Interfacing to C++
13767 @noindent
13768 The interface to C++ makes use of the following pragmas, which are
13769 primarily intended to be constructed automatically using a binding generator
13770 tool, although it is possible to construct them by hand.  No suitable binding
13771 generator tool is supplied with GNAT though.
13773 Using these pragmas it is possible to achieve complete
13774 inter-operability between Ada tagged types and C class definitions.
13775 See @ref{Implementation Defined Pragmas}, for more details.
13777 @table @code
13778 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13779 The argument denotes an entity in the current declarative region that is
13780 declared as a tagged or untagged record type.  It indicates that the type
13781 corresponds to an externally declared C++ class type, and is to be laid
13782 out the same way that C++ would lay out the type.
13784 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13785 This pragma identifies an imported function (imported in the usual way
13786 with pragma @code{Import}) as corresponding to a C++ constructor.
13788 @item pragma CPP_Vtable @dots{}
13789 One @code{CPP_Vtable} pragma can be present for each component of type
13790 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13791 applies.
13792 @end table
13794 @node Interfacing to COBOL
13795 @section Interfacing to COBOL
13797 @noindent
13798 Interfacing to COBOL is achieved as described in section B.4 of
13799 the Ada 95 reference manual.
13801 @node Interfacing to Fortran
13802 @section Interfacing to Fortran
13804 @noindent
13805 Interfacing to Fortran is achieved as described in section B.5 of the
13806 reference manual.  The pragma @code{Convention Fortran}, applied to a
13807 multi-dimensional array causes the array to be stored in column-major
13808 order as required for convenient interface to Fortran.
13810 @node Interfacing to non-GNAT Ada code
13811 @section Interfacing to non-GNAT Ada code
13813 It is possible to specify the convention @code{Ada} in a pragma
13814 @code{Import} or pragma @code{Export}.  However this refers to
13815 the calling conventions used by GNAT, which may or may not be
13816 similar enough to those used by some other Ada 83 or Ada 95
13817 compiler to allow interoperation.
13819 If arguments types are kept simple, and if the foreign compiler generally
13820 follows system calling conventions, then it may be possible to integrate
13821 files compiled by other Ada compilers, provided that the elaboration
13822 issues are adequately addressed (for example by eliminating the
13823 need for any load time elaboration).
13825 In particular, GNAT running on VMS is designed to
13826 be highly compatible with the DEC Ada 83 compiler, so this is one
13827 case in which it is possible to import foreign units of this type,
13828 provided that the data items passed are restricted to simple scalar
13829 values or simple record types without variants, or simple array
13830 types with fixed bounds.
13832 @node Specialized Needs Annexes
13833 @chapter Specialized Needs Annexes
13835 @noindent
13836 Ada 95 defines a number of specialized needs annexes, which are not
13837 required in all implementations.  However, as described in this chapter,
13838 GNAT implements all of these special needs annexes:
13840 @table @asis
13841 @item Systems Programming (Annex C)
13842 The Systems Programming Annex is fully implemented.
13844 @item Real-Time Systems (Annex D)
13845 The Real-Time Systems Annex is fully implemented.
13847 @item Distributed Systems (Annex E)
13848 Stub generation is fully implemented in the GNAT compiler.  In addition,
13849 a complete compatible PCS is available as part of the GLADE system,
13850 a separate product.  When the two
13851 products are used in conjunction, this annex is fully implemented.
13853 @item Information Systems (Annex F)
13854 The Information Systems annex is fully implemented.
13856 @item Numerics (Annex G)
13857 The Numerics Annex is fully implemented.
13859 @item Safety and Security (Annex H)
13860 The Safety and Security annex is fully implemented.
13861 @end table
13863 @node Implementation of Specific Ada Features
13864 @chapter Implementation of Specific Ada Features
13866 @noindent
13867 This chapter describes the GNAT implementation of several Ada language
13868 facilities.
13870 @menu
13871 * Machine Code Insertions::
13872 * GNAT Implementation of Tasking::
13873 * GNAT Implementation of Shared Passive Packages::
13874 * Code Generation for Array Aggregates::
13875 * The Size of Discriminated Records with Default Discriminants::
13876 * Strict Conformance to the Ada 95 Reference Manual::
13877 @end menu
13879 @node Machine Code Insertions
13880 @section Machine Code Insertions
13882 @noindent
13883 Package @code{Machine_Code} provides machine code support as described
13884 in the Ada 95 Reference Manual in two separate forms:
13885 @itemize @bullet
13886 @item
13887 Machine code statements, consisting of qualified expressions that
13888 fit the requirements of RM section 13.8.
13889 @item
13890 An intrinsic callable procedure, providing an alternative mechanism of
13891 including machine instructions in a subprogram.
13892 @end itemize
13894 @noindent
13895 The two features are similar, and both are closely related to the mechanism
13896 provided by the asm instruction in the GNU C compiler.  Full understanding
13897 and use of the facilities in this package requires understanding the asm
13898 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13899 by Richard Stallman. The relevant section is titled ``Extensions to the C
13900 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13902 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13903 semantic restrictions and effects as described below.  Both are provided so
13904 that the procedure call can be used as a statement, and the function call
13905 can be used to form a code_statement.
13907 The first example given in the GCC documentation is the C @code{asm}
13908 instruction:
13909 @smallexample
13910    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13911 @end smallexample
13913 @noindent
13914 The equivalent can be written for GNAT as:
13916 @smallexample @c ada
13917 Asm ("fsinx %1 %0",
13918      My_Float'Asm_Output ("=f", result),
13919      My_Float'Asm_Input  ("f",  angle));
13920 @end smallexample
13922 @noindent
13923 The first argument to @code{Asm} is the assembler template, and is
13924 identical to what is used in GNU C@.  This string must be a static
13925 expression.  The second argument is the output operand list.  It is
13926 either a single @code{Asm_Output} attribute reference, or a list of such
13927 references enclosed in parentheses (technically an array aggregate of
13928 such references).
13930 The @code{Asm_Output} attribute denotes a function that takes two
13931 parameters.  The first is a string, the second is the name of a variable
13932 of the type designated by the attribute prefix.  The first (string)
13933 argument is required to be a static expression and designates the
13934 constraint for the parameter (e.g.@: what kind of register is
13935 required).  The second argument is the variable to be updated with the
13936 result.  The possible values for constraint are the same as those used in
13937 the RTL, and are dependent on the configuration file used to build the
13938 GCC back end.  If there are no output operands, then this argument may
13939 either be omitted, or explicitly given as @code{No_Output_Operands}.
13941 The second argument of @code{@var{my_float}'Asm_Output} functions as
13942 though it were an @code{out} parameter, which is a little curious, but
13943 all names have the form of expressions, so there is no syntactic
13944 irregularity, even though normally functions would not be permitted
13945 @code{out} parameters.  The third argument is the list of input
13946 operands.  It is either a single @code{Asm_Input} attribute reference, or
13947 a list of such references enclosed in parentheses (technically an array
13948 aggregate of such references).
13950 The @code{Asm_Input} attribute denotes a function that takes two
13951 parameters.  The first is a string, the second is an expression of the
13952 type designated by the prefix.  The first (string) argument is required
13953 to be a static expression, and is the constraint for the parameter,
13954 (e.g.@: what kind of register is required).  The second argument is the
13955 value to be used as the input argument.  The possible values for the
13956 constant are the same as those used in the RTL, and are dependent on
13957 the configuration file used to built the GCC back end.
13959 If there are no input operands, this argument may either be omitted, or
13960 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
13961 present in the above example, is a list of register names, called the
13962 @dfn{clobber} argument.  This argument, if given, must be a static string
13963 expression, and is a space or comma separated list of names of registers
13964 that must be considered destroyed as a result of the @code{Asm} call.  If
13965 this argument is the null string (the default value), then the code
13966 generator assumes that no additional registers are destroyed.
13968 The fifth argument, not present in the above example, called the
13969 @dfn{volatile} argument, is by default @code{False}.  It can be set to
13970 the literal value @code{True} to indicate to the code generator that all
13971 optimizations with respect to the instruction specified should be
13972 suppressed, and that in particular, for an instruction that has outputs,
13973 the instruction will still be generated, even if none of the outputs are
13974 used.  See the full description in the GCC manual for further details.
13975 Generally it is strongly advisable to use Volatile for any ASM statement
13976 that is missing either input or output operands, or when two or more ASM
13977 statements appear in sequence, to avoid unwanted optimizations. A warning
13978 is generated if this advice is not followed.
13980 The @code{Asm} subprograms may be used in two ways.  First the procedure
13981 forms can be used anywhere a procedure call would be valid, and
13982 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
13983 be used to intersperse machine instructions with other Ada statements.
13984 Second, the function forms, which return a dummy value of the limited
13985 private type @code{Asm_Insn}, can be used in code statements, and indeed
13986 this is the only context where such calls are allowed.  Code statements
13987 appear as aggregates of the form:
13989 @smallexample @c ada
13990 Asm_Insn'(Asm (@dots{}));
13991 Asm_Insn'(Asm_Volatile (@dots{}));
13992 @end smallexample
13994 @noindent
13995 In accordance with RM rules, such code statements are allowed only
13996 within subprograms whose entire body consists of such statements.  It is
13997 not permissible to intermix such statements with other Ada statements.
13999 Typically the form using intrinsic procedure calls is more convenient
14000 and more flexible.  The code statement form is provided to meet the RM
14001 suggestion that such a facility should be made available.  The following
14002 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14003 is used, the arguments may be given in arbitrary order, following the
14004 normal rules for use of positional and named arguments)
14006 @smallexample
14007 ASM_CALL ::= Asm (
14008                  [Template =>] static_string_EXPRESSION
14009                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14010                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14011                [,[Clobber  =>] static_string_EXPRESSION ]
14012                [,[Volatile =>] static_boolean_EXPRESSION] )
14014 OUTPUT_OPERAND_LIST ::=
14015   [PREFIX.]No_Output_Operands
14016 | OUTPUT_OPERAND_ATTRIBUTE
14017 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14019 OUTPUT_OPERAND_ATTRIBUTE ::=
14020   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14022 INPUT_OPERAND_LIST ::=
14023   [PREFIX.]No_Input_Operands
14024 | INPUT_OPERAND_ATTRIBUTE
14025 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14027 INPUT_OPERAND_ATTRIBUTE ::=
14028   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14029 @end smallexample
14031 @noindent
14032 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14033 are declared in the package @code{Machine_Code} and must be referenced
14034 according to normal visibility rules. In particular if there is no
14035 @code{use} clause for this package, then appropriate package name
14036 qualification is required.
14038 @node GNAT Implementation of Tasking
14039 @section GNAT Implementation of Tasking
14041 @noindent
14042 This chapter outlines the basic GNAT approach to tasking (in particular,
14043 a multi-layered library for portability) and discusses issues related
14044 to compliance with the Real-Time Systems Annex.
14046 @menu
14047 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14048 * Ensuring Compliance with the Real-Time Annex::
14049 @end menu
14051 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14052 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14054 @noindent
14055 GNAT's run-time support comprises two layers:
14057 @itemize @bullet
14058 @item GNARL (GNAT Run-time Layer)
14059 @item GNULL (GNAT Low-level Library)
14060 @end itemize
14062 @noindent
14063 In GNAT, Ada's tasking services rely on a platform and OS independent
14064 layer known as GNARL@.  This code is responsible for implementing the
14065 correct semantics of Ada's task creation, rendezvous, protected
14066 operations etc.
14068 GNARL decomposes Ada's tasking semantics into simpler lower level
14069 operations such as create a thread, set the priority of a thread,
14070 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14071 operations constitutes GNULLI, the GNULL Interface.  This interface is
14072 directly inspired from the POSIX real-time API@.
14074 If the underlying executive or OS implements the POSIX standard
14075 faithfully, the GNULL Interface maps as is to the services offered by
14076 the underlying kernel.  Otherwise, some target dependent glue code maps
14077 the services offered by the underlying kernel to the semantics expected
14078 by GNARL@.
14080 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14081 key point is that each Ada task is mapped on a thread in the underlying
14082 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14084 In addition Ada task priorities map onto the underlying thread priorities.
14085 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14087 @itemize @bullet
14088 @item
14089 The underlying scheduler is used to schedule the Ada tasks.  This
14090 makes Ada tasks as efficient as kernel threads from a scheduling
14091 standpoint.
14093 @item
14094 Interaction with code written in C containing threads is eased
14095 since at the lowest level Ada tasks and C threads map onto the same
14096 underlying kernel concept.
14098 @item
14099 When an Ada task is blocked during I/O the remaining Ada tasks are
14100 able to proceed.
14102 @item
14103 On multiprocessor systems Ada tasks can execute in parallel.
14104 @end itemize
14106 @noindent
14107 Some threads libraries offer a mechanism to fork a new process, with the
14108 child process duplicating the threads from the parent.
14109 GNAT does not
14110 support this functionality when the parent contains more than one task.
14111 @cindex Forking a new process
14113 @node Ensuring Compliance with the Real-Time Annex
14114 @subsection Ensuring Compliance with the Real-Time Annex
14115 @cindex Real-Time Systems Annex compliance
14117 @noindent
14118 Although mapping Ada tasks onto
14119 the underlying threads has significant advantages, it does create some
14120 complications when it comes to respecting the scheduling semantics
14121 specified in the real-time annex (Annex D).
14123 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14124 scheduling policy states:
14126 @quotation
14127 @emph{When the active priority of a ready task that is not running
14128 changes, or the setting of its base priority takes effect, the
14129 task is removed from the ready queue for its old active priority
14130 and is added at the tail of the ready queue for its new active
14131 priority, except in the case where the active priority is lowered
14132 due to the loss of inherited priority, in which case the task is
14133 added at the head of the ready queue for its new active priority.}
14134 @end quotation
14136 @noindent
14137 While most kernels do put tasks at the end of the priority queue when
14138 a task changes its priority, (which respects the main
14139 FIFO_Within_Priorities requirement), almost none keep a thread at the
14140 beginning of its priority queue when its priority drops from the loss
14141 of inherited priority.
14143 As a result most vendors have provided incomplete Annex D implementations.
14145 The GNAT run-time, has a nice cooperative solution to this problem
14146 which ensures that accurate FIFO_Within_Priorities semantics are
14147 respected.
14149 The principle is as follows.  When an Ada task T is about to start
14150 running, it checks whether some other Ada task R with the same
14151 priority as T has been suspended due to the loss of priority
14152 inheritance.  If this is the case, T yields and is placed at the end of
14153 its priority queue.  When R arrives at the front of the queue it
14154 executes.
14156 Note that this simple scheme preserves the relative order of the tasks
14157 that were ready to execute in the priority queue where R has been
14158 placed at the end.
14160 @node GNAT Implementation of Shared Passive Packages
14161 @section GNAT Implementation of Shared Passive Packages
14162 @cindex Shared passive packages
14164 @noindent
14165 GNAT fully implements the pragma @code{Shared_Passive} for
14166 @cindex pragma @code{Shared_Passive}
14167 the purpose of designating shared passive packages.
14168 This allows the use of passive partitions in the
14169 context described in the Ada Reference Manual; i.e. for communication
14170 between separate partitions of a distributed application using the
14171 features in Annex E.
14172 @cindex Annex E
14173 @cindex Distribution Systems Annex
14175 However, the implementation approach used by GNAT provides for more
14176 extensive usage as follows:
14178 @table @emph
14179 @item Communication between separate programs
14181 This allows separate programs to access the data in passive
14182 partitions, using protected objects for synchronization where
14183 needed. The only requirement is that the two programs have a
14184 common shared file system. It is even possible for programs
14185 running on different machines with different architectures
14186 (e.g. different endianness) to communicate via the data in
14187 a passive partition.
14189 @item Persistence between program runs
14191 The data in a passive package can persist from one run of a
14192 program to another, so that a later program sees the final
14193 values stored by a previous run of the same program.
14195 @end table
14197 @noindent
14198 The implementation approach used is to store the data in files. A
14199 separate stream file is created for each object in the package, and
14200 an access to an object causes the corresponding file to be read or
14201 written.
14203 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14204 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14205 set to the directory to be used for these files.
14206 The files in this directory
14207 have names that correspond to their fully qualified names. For
14208 example, if we have the package
14210 @smallexample @c ada
14211 package X is
14212   pragma Shared_Passive (X);
14213   Y : Integer;
14214   Z : Float;
14215 end X;
14216 @end smallexample
14218 @noindent
14219 and the environment variable is set to @code{/stemp/}, then the files created
14220 will have the names:
14222 @smallexample
14223 /stemp/x.y
14224 /stemp/x.z
14225 @end smallexample
14227 @noindent
14228 These files are created when a value is initially written to the object, and
14229 the files are retained until manually deleted. This provides the persistence
14230 semantics. If no file exists, it means that no partition has assigned a value
14231 to the variable; in this case the initial value declared in the package
14232 will be used. This model ensures that there are no issues in synchronizing
14233 the elaboration process, since elaboration of passive packages elaborates the
14234 initial values, but does not create the files.
14236 The files are written using normal @code{Stream_IO} access.
14237 If you want to be able
14238 to communicate between programs or partitions running on different
14239 architectures, then you should use the XDR versions of the stream attribute
14240 routines, since these are architecture independent.
14242 If active synchronization is required for access to the variables in the
14243 shared passive package, then as described in the Ada Reference Manual, the
14244 package may contain protected objects used for this purpose. In this case
14245 a lock file (whose name is @file{___lock} (three underscores)
14246 is created in the shared memory directory.
14247 @cindex @file{___lock} file (for shared passive packages)
14248 This is used to provide the required locking
14249 semantics for proper protected object synchronization.
14251 As of January 2003, GNAT supports shared passive packages on all platforms
14252 except for OpenVMS.
14254 @node Code Generation for Array Aggregates
14255 @section Code Generation for Array Aggregates
14257 @menu
14258 * Static constant aggregates with static bounds::
14259 * Constant aggregates with unconstrained nominal types::
14260 * Aggregates with static bounds::
14261 * Aggregates with non-static bounds::
14262 * Aggregates in assignment statements::
14263 @end menu
14265 @noindent
14266 Aggregates have a rich syntax and allow the user to specify the values of
14267 complex data structures by means of a single construct.  As a result, the
14268 code generated for aggregates can be quite complex and involve loops, case
14269 statements and multiple assignments.  In the simplest cases, however, the
14270 compiler will recognize aggregates whose components and constraints are
14271 fully static, and in those cases the compiler will generate little or no
14272 executable code.  The following is an outline of the code that GNAT generates
14273 for various aggregate constructs.  For further details, you will find it
14274 useful to examine the output produced by the -gnatG flag to see the expanded
14275 source that is input to the code generator.  You may also want to examine
14276 the assembly code generated at various levels of optimization.
14278 The code generated for aggregates depends on the context, the component values,
14279 and the type.  In the context of an object declaration the code generated is
14280 generally simpler than in the case of an assignment.  As a general rule, static
14281 component values and static subtypes also lead to simpler code.
14283 @node Static constant aggregates with static bounds
14284 @subsection Static constant aggregates with static bounds
14286 @noindent
14287 For the declarations:
14288 @smallexample @c ada
14289     type One_Dim is array (1..10) of integer;
14290     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14291 @end smallexample
14293 @noindent
14294 GNAT generates no executable code: the constant ar0 is placed in static memory.
14295 The same is true for constant aggregates with named associations:
14297 @smallexample @c ada
14298     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14299     Cr3 : constant One_Dim := (others => 7777);
14300 @end smallexample
14302 @noindent
14303 The same is true for multidimensional constant arrays such as:
14305 @smallexample @c ada
14306     type two_dim is array (1..3, 1..3) of integer;
14307     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14308 @end smallexample
14310 @noindent
14311 The same is true for arrays of one-dimensional arrays: the following are
14312 static:
14314 @smallexample @c ada
14315 type ar1b  is array (1..3) of boolean;
14316 type ar_ar is array (1..3) of ar1b;
14317 None  : constant ar1b := (others => false);     --  fully static
14318 None2 : constant ar_ar := (1..3 => None);       --  fully static
14319 @end smallexample
14321 @noindent
14322 However, for multidimensional aggregates with named associations, GNAT will
14323 generate assignments and loops, even if all associations are static.  The
14324 following two declarations generate a loop for the first dimension, and
14325 individual component assignments for the second dimension:
14327 @smallexample @c ada
14328 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14329 Zero2: constant two_dim := (others => (others => 0));
14330 @end smallexample
14332 @node Constant aggregates with unconstrained nominal types
14333 @subsection Constant aggregates with unconstrained nominal types
14335 @noindent
14336 In such cases the aggregate itself establishes the subtype, so that
14337 associations with @code{others} cannot be used.  GNAT determines the
14338 bounds for the actual subtype of the aggregate, and allocates the
14339 aggregate statically as well.  No code is generated for the following:
14341 @smallexample @c ada
14342     type One_Unc is array (natural range <>) of integer;
14343     Cr_Unc : constant One_Unc := (12,24,36);
14344 @end smallexample
14346 @node Aggregates with static bounds
14347 @subsection Aggregates with static bounds
14349 @noindent
14350 In all previous examples the aggregate was the initial (and immutable) value
14351 of a constant.  If the aggregate initializes a variable, then code is generated
14352 for it as a combination of individual assignments and loops over the target
14353 object.  The declarations
14355 @smallexample @c ada
14356        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14357        Cr_Var2 : One_Dim := (others > -1);
14358 @end smallexample
14360 @noindent
14361 generate the equivalent of
14363 @smallexample @c ada
14364        Cr_Var1 (1) := 2;
14365        Cr_Var1 (2) := 3;
14366        Cr_Var1 (3) := 5;
14367        Cr_Var1 (4) := 11;
14369        for I in Cr_Var2'range loop
14370           Cr_Var2 (I) := =-1;
14371        end loop;
14372 @end smallexample
14374 @node Aggregates with non-static bounds
14375 @subsection Aggregates with non-static bounds
14377 @noindent
14378 If the bounds of the aggregate are not statically compatible with the bounds
14379 of the nominal subtype  of the target, then constraint checks have to be
14380 generated on the bounds.  For a multidimensional array, constraint checks may
14381 have to be applied to sub-arrays individually, if they do not have statically
14382 compatible subtypes.
14384 @node Aggregates in assignment statements
14385 @subsection Aggregates in assignment statements
14387 @noindent
14388 In general, aggregate assignment requires the construction of a temporary,
14389 and a copy from the temporary to the target of the assignment.  This is because
14390 it is not always possible to convert the assignment into a series of individual
14391 component assignments.  For example, consider the simple case:
14393 @smallexample @c ada
14394         A := (A(2), A(1));
14395 @end smallexample
14397 @noindent
14398 This cannot be converted into:
14400 @smallexample @c ada
14401         A(1) := A(2);
14402         A(2) := A(1);
14403 @end smallexample
14405 @noindent
14406 So the aggregate has to be built first in a separate location, and then
14407 copied into the target.  GNAT recognizes simple cases where this intermediate
14408 step is not required, and the assignments can be performed in place, directly
14409 into the target.  The following sufficient criteria are applied:
14411 @itemize @bullet
14412 @item
14413 The bounds of the aggregate are static, and the associations are static.
14414 @item
14415 The components of the aggregate are static constants, names of
14416 simple variables that are not renamings, or expressions not involving
14417 indexed components whose operands obey these rules.
14418 @end itemize
14420 @noindent
14421 If any of these conditions are violated, the aggregate will be built in
14422 a temporary (created either by the front-end or the code generator) and then
14423 that temporary will be copied onto the target.
14426 @node The Size of Discriminated Records with Default Discriminants
14427 @section The Size of Discriminated Records with Default Discriminants
14429 @noindent
14430 If a discriminated type @code{T} has discriminants with default values, it is
14431 possible to declare an object of this type without providing an explicit
14432 constraint:
14434 @smallexample @c ada
14435 @group
14436 type Size is range 1..100;
14438 type Rec (D : Size := 15) is record
14439    Name : String (1..D);
14440 end T;
14442 Word : Rec;
14443 @end group
14444 @end smallexample
14446 @noindent
14447 Such an object is said to be @emph{unconstrained}.
14448 The discriminant of the object
14449 can be modified by a full assignment to the object, as long as it preserves the
14450 relation between the value of the discriminant, and the value of the components
14451 that depend on it:
14453 @smallexample @c ada
14454 @group
14455 Word := (3, "yes");
14457 Word := (5, "maybe");
14459 Word := (5, "no"); -- raises Constraint_Error
14460 @end group
14461 @end smallexample
14463 @noindent
14464 In order to support this behavior efficiently, an unconstrained object is
14465 given the maximum size that any value of the type requires. In the case
14466 above, @code{Word} has storage for the discriminant and for
14467 a @code{String} of length 100.
14468 It is important to note that unconstrained objects do not require dynamic
14469 allocation. It would be an improper implementation to place on the heap those
14470 components whose size depends on discriminants. (This improper implementation
14471 was used by some Ada83 compilers, where the @code{Name} component above
14472 would have
14473 been stored as a pointer to a dynamic string). Following the principle that
14474 dynamic storage management should never be introduced implicitly,
14475 an Ada95 compiler should reserve the full size for an unconstrained declared
14476 object, and place it on the stack.
14478 This maximum size approach
14479 has been a source of surprise to some users, who expect the default
14480 values of the discriminants to determine the size reserved for an
14481 unconstrained object: ``If the default is 15, why should the object occupy
14482 a larger size?''
14483 The answer, of course, is that the discriminant may be later modified,
14484 and its full range of values must be taken into account. This is why the
14485 declaration:
14487 @smallexample
14488 @group
14489 type Rec (D : Positive := 15) is record
14490    Name : String (1..D);
14491 end record;
14493 Too_Large : Rec;
14494 @end group
14495 @end smallexample
14497 @noindent
14498 is flagged by the compiler with a warning:
14499 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14500 because the required size includes @code{Positive'Last}
14501 bytes. As the first example indicates, the proper approach is to declare an
14502 index type of ``reasonable'' range so that unconstrained objects are not too
14503 large.
14505 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14506 created in the heap by means of an allocator, then it is @emph{not}
14507 unconstrained:
14508 it is constrained by the default values of the discriminants, and those values
14509 cannot be modified by full assignment. This is because in the presence of
14510 aliasing all views of the object (which may be manipulated by different tasks,
14511 say) must be consistent, so it is imperative that the object, once created,
14512 remain invariant.
14514 @node Strict Conformance to the Ada 95 Reference Manual
14515 @section Strict Conformance to the Ada 95 Reference Manual
14517 @noindent
14518 The dynamic semantics defined by the Ada 95 Reference Manual impose a set of
14519 run-time checks to be generated. By default, the GNAT compiler will insert many
14520 run-time checks into the compiled code, including most of those required by the
14521 Ada 95 Reference Manual. However, there are three checks that are not enabled
14522 in the default mode for efficiency reasons: arithmetic overflow checking for
14523 integer operations (including division by zero), checks for access before
14524 elaboration on subprogram calls, and stack overflow checking (most operating
14525 systems do not perform this check by default).
14527 Strict conformance to the Ada 95 Reference Manual can be achieved by adding
14528 three compiler options for overflow checking for integer operations
14529 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14530 calls and generic instantiations (@option{-gnatE}), and stack overflow
14531 checking (@option{-fstack-check}).
14533 Note that the result of a floating point arithmetic operation in overflow and
14534 invalid situations, when the @code{Machine_Overflows} attribute of the result
14535 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14536 case for machines compliant with the IEEE floating-point standard, but on
14537 machines that are not fully compliant with this standard, such as Alpha, the
14538 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14539 behavior (although at the cost of a significant performance penalty), so
14540 infinite and and NaN values are properly generated.
14543 @node Project File Reference
14544 @chapter Project File Reference
14546 @noindent
14547 This chapter describes the syntax and semantics of project files.
14548 Project files specify the options to be used when building a system.
14549 Project files can specify global settings for all tools,
14550 as well as tool-specific settings.
14551 See the chapter on project files in the GNAT Users guide for examples of use.
14553 @menu
14554 * Reserved Words::
14555 * Lexical Elements::
14556 * Declarations::
14557 * Empty declarations::
14558 * Typed string declarations::
14559 * Variables::
14560 * Expressions::
14561 * Attributes::
14562 * Project Attributes::
14563 * Attribute References::
14564 * External Values::
14565 * Case Construction::
14566 * Packages::
14567 * Package Renamings::
14568 * Projects::
14569 * Project Extensions::
14570 * Project File Elaboration::
14571 @end menu
14573 @node Reserved Words
14574 @section Reserved Words
14576 @noindent
14577 All Ada95 reserved words are reserved in project files, and cannot be used
14578 as variable names or project names. In addition, the following are
14579 also reserved in project files:
14581 @itemize
14582 @item @code{extends}
14584 @item @code{external}
14586 @item @code{project}
14588 @end itemize
14590 @node Lexical Elements
14591 @section Lexical Elements
14593 @noindent
14594 Rules for identifiers are the same as in Ada95. Identifiers
14595 are case-insensitive.  Strings are case sensitive, except where noted.
14596 Comments have the same form as in Ada95.
14598 @noindent
14599 Syntax:
14601 @smallexample
14602 simple_name ::=
14603   identifier
14605 name ::=
14606   simple_name @{. simple_name@}
14607 @end smallexample
14609 @node Declarations
14610 @section Declarations
14612 @noindent
14613 Declarations introduce new entities that denote types, variables, attributes,
14614 and packages. Some declarations can only appear immediately within a project
14615 declaration. Others can appear within a project or within a package.
14617 Syntax:
14618 @smallexample
14619 declarative_item ::=
14620   simple_declarative_item |
14621   typed_string_declaration |
14622   package_declaration
14624 simple_declarative_item ::=
14625   variable_declaration |
14626   typed_variable_declaration |
14627   attribute_declaration |
14628   case_construction |
14629   empty_declaration
14630 @end smallexample
14632 @node Empty declarations
14633 @section Empty declarations
14635 @smallexample
14636 empty_declaration ::=
14637   @b{null} ;
14638 @end smallexample
14640 An empty declaration is allowed anywhere a declaration is allowed.
14641 It has no effect.
14643 @node Typed string declarations
14644 @section Typed string declarations
14646 @noindent
14647 Typed strings are sequences of string literals. Typed strings are the only
14648 named types in project files. They are used in case constructions, where they
14649 provide support for conditional attribute definitions.
14651 Syntax:
14652 @smallexample
14653 typed_string_declaration ::=
14654   @b{type} <typed_string_>_simple_name @b{is}
14655    ( string_literal @{, string_literal@} );
14656 @end smallexample
14658 @noindent
14659 A typed string declaration can only appear immediately within a project
14660 declaration.
14662 All the string literals in a typed string declaration must be distinct.
14664 @node Variables
14665 @section Variables
14667 @noindent
14668 Variables denote values, and appear as constituents of expressions.
14670 @smallexample
14671 typed_variable_declaration ::=
14672   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14674 variable_declaration ::=
14675   <variable_>simple_name := expression;
14676 @end smallexample
14678 @noindent
14679 The elaboration of a variable declaration introduces the variable and
14680 assigns to it the value of the expression. The name of the variable is
14681 available after the assignment symbol.
14683 @noindent
14684 A typed_variable can only be declare once.
14686 @noindent
14687 a non typed variable can be declared multiple times.
14689 @noindent
14690 Before the completion of its first declaration, the value of variable
14691 is the null string.
14693 @node Expressions
14694 @section Expressions
14696 @noindent
14697 An expression is a formula that defines a computation or retrieval of a value.
14698 In a project file the value of an expression is either a string or a list
14699 of strings. A string value in an expression is either a literal, the current
14700 value of a variable, an external value, an attribute reference, or a
14701 concatenation operation.
14703 Syntax:
14705 @smallexample
14706 expression ::=
14707   term @{& term@}
14709 term ::=
14710   string_literal |
14711   string_list |
14712   <variable_>name |
14713   external_value |
14714   attribute_reference
14716 string_literal ::=
14717   (same as Ada)
14719 string_list ::=
14720   ( <string_>expression @{ , <string_>expression @} )
14721 @end smallexample
14723 @subsection Concatenation
14724 @noindent
14725 The following concatenation functions are defined:
14727 @smallexample @c ada
14728   function "&" (X : String;      Y : String)      return String;
14729   function "&" (X : String_List; Y : String)      return String_List;
14730   function "&" (X : String_List; Y : String_List) return String_List;
14731 @end smallexample
14733 @node Attributes
14734 @section Attributes
14736 @noindent
14737 An attribute declaration defines a property of a project or package. This
14738 property can later be queried by means of an attribute reference.
14739 Attribute values are strings or string lists.
14741 Some attributes are associative arrays. These attributes are mappings whose
14742 domain is a set of strings. These attributes are declared one association
14743 at a time, by specifying a point in the domain and the corresponding image
14744 of the attribute. They may also be declared as a full associative array,
14745 getting the same associations as the corresponding attribute in an imported
14746 or extended project.
14748 Attributes that are not associative arrays are called simple attributes.
14750 Syntax:
14751 @smallexample
14752 attribute_declaration ::=
14753   full_associative_array_declaration |
14754   @b{for} attribute_designator @b{use} expression ;
14756 full_associative_array_declaration ::=
14757   @b{for} <associative_array_attribute_>simple_name @b{use}
14758   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14760 attribute_designator ::=
14761   <simple_attribute_>simple_name |
14762   <associative_array_attribute_>simple_name ( string_literal )
14763 @end smallexample
14765 @noindent
14766 Some attributes are project-specific, and can only appear immediately within
14767 a project declaration. Others are package-specific, and can only appear within
14768 the proper package.
14770 The expression in an attribute definition must be a string or a string_list.
14771 The string literal appearing in the attribute_designator of an associative
14772 array attribute is case-insensitive.
14774 @node Project Attributes
14775 @section Project Attributes
14777 @noindent
14778 The following attributes apply to a project. All of them are simple
14779 attributes.
14781 @table @code
14782 @item   Object_Dir
14783 Expression must be a path name. The attribute defines the
14784 directory in which the object files created by the build are to be placed. If
14785 not specified, object files are placed in the project directory.
14787 @item   Exec_Dir
14788 Expression must be a path name. The attribute defines the
14789 directory in which the executables created by the build are to be placed.
14790 If not specified, executables are placed in the object directory.
14792 @item  Source_Dirs
14793 Expression must be a list of path names. The attribute
14794 defines the directories in which the source files for the project are to be
14795 found. If not specified, source files are found in the project directory.
14797 @item  Source_Files
14798 Expression must be a list of file names. The attribute
14799 defines the individual files, in the project directory, which are to be used
14800 as sources for the project. File names are path_names that contain no directory
14801 information. If the project has no sources the attribute must be declared
14802 explicitly with an empty list.
14804 @item  Source_List_File
14805 Expression must a single path name. The attribute
14806 defines a text file that contains a list of source file names to be used
14807 as sources for the project
14809 @item  Library_Dir
14810 Expression must be a path name. The attribute defines the
14811 directory in which a  library is to be built.  The directory must exist, must
14812 be distinct from the project's object directory, and must be writable.
14814 @item  Library_Name
14815 Expression must be a string that is a legal file name,
14816 without extension. The attribute defines a string that is used to generate
14817 the name of the library to be built by the project.
14819 @item  Library_Kind
14820 Argument must be a string value that must be one of the
14821 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14822 string is case-insensitive. If this attribute is not specified, the library is
14823 a static library. Otherwise, the library may be dynamic or relocatable. This
14824 distinction is operating-system dependent.
14826 @item  Library_Version
14827 Expression must be a string value whose interpretation
14828 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14829 libraries as the internal name of the library (the @code{"soname"}). If the
14830 library file name (built from the @code{Library_Name}) is different from the
14831 @code{Library_Version}, then the library file will be a symbolic link to the
14832 actual file whose name will be @code{Library_Version}.
14834 @item Library_Interface
14835 Expression must be a string list. Each element of the string list
14836 must designate a unit of the project.
14837 If this attribute is present in a Library Project File, then the project
14838 file is a Stand-alone Library_Project_File.
14840 @item Library_Auto_Init
14841 Expression must be a single string "true" or "false", case-insensitive.
14842 If this attribute is present in a Stand-alone Library Project File,
14843 it indicates if initialization is automatic when the dynamic library
14844 is loaded.
14846 @item Library_Options
14847 Expression must be a string list. Indicates additional switches that
14848 are to be used when building a shared library.
14850 @item Library_GCC
14851 Expression must be a single string. Designates an alternative to "gcc"
14852 for building shared libraries.
14854 @item  Library_Src_Dir
14855 Expression must be a path name. The attribute defines the
14856 directory in which the sources of the interfaces of a Stand-alone Library will
14857 be copied.  The directory must exist, must be distinct from the project's
14858 object directory and source directories of all projects in the project tree,
14859 and must be writable.
14861 @item  Library_Src_Dir
14862 Expression must be a path name. The attribute defines the
14863 directory in which the ALI files of a Library will
14864 be copied.  The directory must exist, must be distinct from the project's
14865 object directory and source directories of all projects in the project tree,
14866 and must be writable.
14868 @item  Library_Symbol_File
14869 Expression must be a single string. Its value is the single file name of a
14870 symbol file to be created when building a stand-alone library when the
14871 symbol policy is either "compliant", "controlled" or "restricted",
14872 on platforms that support symbol control, such as VMS.
14874 @item   Library_Reference_Symbol_File
14875 Expression must be a single string. Its value is the single file name of a
14876 reference symbol file that is read when the symbol policy is either
14877 "compliant" or "controlled", on platforms that support symbol control,
14878 such as VMS, when building a stand-alone library.
14880 @item  Library_Symbol_Policy
14881 Expression must be a single string. Its case-insensitive value can only be
14882 "autonomous", "default", "compliant", "controlled" or "restricted".
14884 This attribute is not taken into account on all platforms. It controls the
14885 policy for exported symbols and, on some platforms (like VMS) that have the
14886 notions of major and minor IDs built in the library files, it controls
14887 the setting of these IDs.
14889 "autonomous" or "default": exported symbols are not controlled.
14891 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
14892 it is equivalent to policy "autonomous". If there are exported symbols in
14893 the reference symbol file that are not in the object files of the interfaces,
14894 the major ID of the library is increased. If there are symbols in the
14895 object files of the interfaces that are not in the reference symbol file,
14896 these symbols are put at the end of the list in the newly created symbol file
14897 and the minor ID is increased.
14899 "controlled": the attribute Library_Reference_Symbol_File must be defined.
14900 The library will fail to build if the exported symbols in the object files of
14901 the interfaces do not match exactly the symbol in the symbol file.
14903 "restricted": The attribute Library_Symbol_File must be defined. The library
14904 will fail to build if there are symbols in the symbol file that are not in
14905 the exported symbols of the object files of the interfaces. Additional symbols
14906 in the object files are not added to the symbol file.
14908 @item  Main
14909 Expression must be a list of strings that are legal file names.
14910 These file names designate existing compilation units in the source directory
14911 that are legal main subprograms.
14913 When a project file is elaborated, as part of the execution of a gnatmake
14914 command, one or several executables are built and placed in the Exec_Dir.
14915 If the gnatmake command does not include explicit file names, the executables
14916 that are built correspond to the files specified by this attribute.
14918 @item  Externally_Built
14919 Expression must be a single string. Its value must be either "true" of "false",
14920 case-insensitive. The default is "false". When the value of this attribute is
14921 "true", no attempt is made to compile the sources or to build the library,
14922 when the project is a library project.
14924 @item Main_Language
14925 This is a simple attribute. Its value is a string that specifies the
14926 language of the main program.
14928 @item  Languages
14929 Expression must be a string list. Each string designates
14930 a programming language that is known to GNAT. The strings are case-insensitive.
14932 @item  Locally_Removed_Files
14933 This attribute is legal only in a project file that extends another.
14934 Expression must be a list of strings that are legal file names.
14935 Each file name must designate a source that would normally be inherited
14936 by the current project file. It cannot designate an immediate source that is
14937 not inherited. Each of the source files in the list are not considered to
14938 be sources of the project file: they are not inherited.
14939 @end table
14941 @node Attribute References
14942 @section Attribute References
14944 @noindent
14945 Attribute references are used to retrieve the value of previously defined
14946 attribute for a package or project.
14947 Syntax:
14948 @smallexample
14949 attribute_reference ::=
14950   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14952 attribute_prefix ::=
14953   @b{project} |
14954   <project_simple_name | package_identifier |
14955   <project_>simple_name . package_identifier
14956 @end smallexample
14958 @noindent
14959 If an attribute has not been specified for a given package or project, its
14960 value is the null string or the empty list.
14962 @node External Values
14963 @section External Values
14965 @noindent
14966 An external value is an expression whose value is obtained from the command
14967 that invoked the processing of the current project file (typically a
14968 gnatmake command).
14970 Syntax:
14971 @smallexample
14972 external_value ::=
14973   @b{external} ( string_literal [, string_literal] )
14974 @end smallexample
14976 @noindent
14977 The first string_literal is the string to be used on the command line or
14978 in the environment to specify the external value. The second string_literal,
14979 if present, is the default to use if there is no specification for this
14980 external value either on the command line or in the environment.
14982 @node Case Construction
14983 @section Case Construction
14985 @noindent
14986 A case construction supports attribute declarations that depend on the value of
14987 a previously declared variable.
14989 Syntax:
14990 @smallexample
14991 case_construction ::=
14992   @b{case} <typed_variable_>name @b{is}
14993     @{case_item@}
14994   @b{end case} ;
14996 case_item ::=
14997   @b{when} discrete_choice_list =>
14998     @{case_construction | attribute_declaration | empty_declaration@}
15000 discrete_choice_list ::=
15001   string_literal @{| string_literal@} |
15002     @b{others}
15003 @end smallexample
15005 @noindent
15006 All choices in a choice list must be distinct. The choice lists of two
15007 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15008 alternatives do not need to include all values of the type. An @code{others}
15009 choice must appear last in the list of alternatives.
15011 @node Packages
15012 @section Packages
15014 @noindent
15015 A package provides a grouping of variable declarations and attribute
15016 declarations to be used when invoking various GNAT tools. The name of
15017 the package indicates the tool(s) to which it applies.
15018 Syntax:
15020 @smallexample
15021 package_declaration ::=
15022   package_specification | package_renaming
15024 package_specification ::=
15025   @b{package} package_identifier @b{is}
15026     @{simple_declarative_item@}
15027   @b{end} package_identifier ;
15029 package_identifier ::=
15030   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15031   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15032   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15033 @end smallexample
15035 @subsection Package Naming
15037 @noindent
15038 The attributes of a @code{Naming} package specifies the naming conventions
15039 that apply to the source files in a project. When invoking other GNAT tools,
15040 they will use the sources in the source directories that satisfy these
15041 naming conventions.
15043 The following attributes apply to a @code{Naming} package:
15045 @table @code
15046 @item Casing
15047 This is a simple attribute whose value is a string. Legal values of this
15048 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15049 These strings are themselves case insensitive.
15051 @noindent
15052 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15054 @item Dot_Replacement
15055 This is a simple attribute whose string value satisfies the following
15056 requirements:
15058 @itemize @bullet
15059 @item It must not be empty
15060 @item It cannot start or end with an alphanumeric character
15061 @item It cannot be a single underscore
15062 @item It cannot start with an underscore followed by an alphanumeric
15063 @item It cannot contain a dot @code{'.'} if longer than one character
15064 @end itemize
15066 @noindent
15067 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15069 @item Spec_Suffix
15070 This is an associative array attribute, defined on language names,
15071 whose image is a string that must satisfy the following
15072 conditions:
15074 @itemize @bullet
15075 @item It must not be empty
15076 @item It cannot start with an alphanumeric character
15077 @item It cannot start with an underscore followed by an alphanumeric character
15078 @end itemize
15080 @noindent
15081 For Ada, the attribute denotes the suffix used in file names that contain
15082 library unit declarations, that is to say units that are package and
15083 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15084 specified, then the default is @code{".ads"}.
15086 For C and C++, the attribute denotes the suffix used in file names that
15087 contain prototypes.
15089 @item Body_Suffix
15090 This is an associative array attribute defined on language names,
15091 whose image is a string that must satisfy the following
15092 conditions:
15094 @itemize @bullet
15095 @item It must not be empty
15096 @item It cannot start with an alphanumeric character
15097 @item It cannot start with an underscore followed by an alphanumeric character
15098 @item It cannot be a suffix of @code{Spec_Suffix}
15099 @end itemize
15101 @noindent
15102 For Ada, the attribute denotes the suffix used in file names that contain
15103 library bodies, that is to say units that are package and subprogram bodies.
15104 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15105 @code{".adb"}.
15107 For C and C++, the attribute denotes the suffix used in file names that contain
15108 source code.
15110 @item Separate_Suffix
15111 This is a simple attribute whose value satisfies the same conditions as
15112 @code{Body_Suffix}.
15114 This attribute is specific to Ada. It denotes the suffix used in file names
15115 that contain separate bodies. If it is not specified, then it defaults to same
15116 value as @code{Body_Suffix ("Ada")}.
15118 @item Spec
15119 This is an associative array attribute, specific to Ada, defined over
15120 compilation unit names. The image is a string that is the name of the file
15121 that contains that library unit. The file name is case sensitive if the
15122 conventions of the host operating system require it.
15124 @item Body
15125 This is an associative array attribute, specific to Ada, defined over
15126 compilation unit names. The image is a string that is the name of the file
15127 that contains the library unit body for the named unit. The file name is case
15128 sensitive if the conventions of the host operating system require it.
15130 @item Specification_Exceptions
15131 This is an associative array attribute defined on language names,
15132 whose value is a list of strings.
15134 This attribute is not significant for Ada.
15136 For C and C++, each string in the list denotes the name of a file that
15137 contains prototypes, but whose suffix is not necessarily the
15138 @code{Spec_Suffix} for the language.
15140 @item Implementation_Exceptions
15141 This is an associative array attribute defined on language names,
15142 whose value is a list of strings.
15144 This attribute is not significant for Ada.
15146 For C and C++, each string in the list denotes the name of a file that
15147 contains source code, but whose suffix is not necessarily the
15148 @code{Body_Suffix} for the language.
15149 @end table
15151 The following attributes of package @code{Naming} are obsolescent. They are
15152 kept as synonyms of other attributes for compatibility with previous versions
15153 of the Project Manager.
15155 @table @code
15156 @item Specification_Suffix
15157 This is a synonym of @code{Spec_Suffix}.
15159 @item Implementation_Suffix
15160 This is a synonym of @code{Body_Suffix}.
15162 @item Specification
15163 This is a synonym of @code{Spec}.
15165 @item Implementation
15166 This is a synonym of @code{Body}.
15167 @end table
15169 @subsection package Compiler
15171 @noindent
15172 The attributes of the @code{Compiler} package specify the compilation options
15173 to be used by the underlying compiler.
15175 @table @code
15176 @item  Default_Switches
15177 This is an associative array attribute. Its
15178 domain is a set of language names. Its range is a string list that
15179 specifies the compilation options to be used when compiling a component
15180 written in that language, for which no file-specific switches have been
15181 specified.
15183 @item  Switches
15184 This is an associative array attribute. Its domain is
15185 a set of file names. Its range is a string list that specifies the
15186 compilation options to be used when compiling the named file. If a file
15187 is not specified in the Switches attribute, it is compiled with the
15188 options specified by Default_Switches of its language, if defined.
15190 @item  Local_Configuration_Pragmas.
15191 This is a simple attribute, whose
15192 value is a path name that designates a file containing configuration pragmas
15193 to be used for all invocations of the compiler for immediate sources of the
15194 project.
15195 @end table
15197 @subsection package Builder
15199 @noindent
15200 The attributes of package @code{Builder} specify the compilation, binding, and
15201 linking options to be used when building an executable for a project. The
15202 following attributes apply to package @code{Builder}:
15204 @table @code
15205 @item Default_Switches
15206 This is an associative array attribute. Its
15207 domain is a set of language names. Its range is a string list that
15208 specifies options to be used when building a main
15209 written in that language, for which no file-specific switches have been
15210 specified.
15212 @item Switches
15213 This is an associative array attribute. Its domain is
15214 a set of file names. Its range is a string list that specifies
15215 options to be used when building the named main file. If a main file
15216 is not specified in the Switches attribute, it is built with the
15217 options specified by Default_Switches of its language, if defined.
15219 @item Global_Configuration_Pragmas
15220 This is a simple attribute, whose
15221 value is a path name that designates a file that contains configuration pragmas
15222 to be used in every build of an executable. If both local and global
15223 configuration pragmas are specified, a compilation makes use of both sets.
15226 @item Executable
15227 This is an associative array attribute. Its domain is
15228 a set of main source file names. Its range is a simple string that specifies
15229 the executable file name to be used when linking the specified main source.
15230 If a main source is not specified in the Executable attribute, the executable
15231 file name is deducted from the main source file name.
15232 This attribute has no effect if its value is the empty string.
15234 @item Executable_Suffix
15235 This is a simple attribute whose value is the suffix to be added to
15236 the executables that don't have an attribute Executable specified.
15237 @end table
15239 @subsection package Gnatls
15241 @noindent
15242 The attributes of package @code{Gnatls} specify the tool options to be used
15243 when invoking the library browser @command{gnatls}.
15244 The following attributes apply to package @code{Gnatls}:
15246 @table @code
15247 @item Switches
15248 This is a single attribute with a string list value. Each non empty string
15249 in the list is an option when invoking @code{gnatls}.
15250 @end table
15252 @subsection package Binder
15254 @noindent
15255 The attributes of package @code{Binder} specify the options to be used
15256 when invoking the binder in the construction of an executable.
15257 The following attributes apply to package @code{Binder}:
15259 @table @code
15260 @item     Default_Switches
15261 This is an associative array attribute. Its
15262 domain is a set of language names. Its range is a string list that
15263 specifies options to be used when binding a main
15264 written in that language, for which no file-specific switches have been
15265 specified.
15267 @item Switches
15268 This is an associative array attribute. Its domain is
15269 a set of file names. Its range is a string list that specifies
15270 options to be used when binding the named main file. If a main file
15271 is not specified in the Switches attribute, it is bound with the
15272 options specified by Default_Switches of its language, if defined.
15273 @end table
15275 @subsection package Linker
15277 @noindent
15278 The attributes of package @code{Linker} specify the options to be used when
15279 invoking the linker in the construction of an executable.
15280 The following attributes apply to package @code{Linker}:
15282 @table @code
15283 @item     Default_Switches
15284 This is an associative array attribute. Its
15285 domain is a set of language names. Its range is a string list that
15286 specifies options to be used when linking a main
15287 written in that language, for which no file-specific switches have been
15288 specified.
15290 @item Switches
15291 This is an associative array attribute. Its domain is
15292 a set of file names. Its range is a string list that specifies
15293 options to be used when linking the named main file. If a main file
15294 is not specified in the Switches attribute, it is linked with the
15295 options specified by Default_Switches of its language, if defined.
15297 @item  Linker_Options
15298 This is a string list attribute. Its value specifies additional options that
15299 be given to the linker when linking an executable. This attribute is not
15300 used in the main project, only in projects imported directly or indirectly.
15302 @end table
15304 @subsection package Cross_Reference
15306 @noindent
15307 The attributes of package @code{Cross_Reference} specify the tool options
15308 to be used
15309 when invoking the library tool @command{gnatxref}.
15310 The following attributes apply to package @code{Cross_Reference}:
15312 @table @code
15313 @item     Default_Switches
15314 This is an associative array attribute. Its
15315 domain is a set of language names. Its range is a string list that
15316 specifies options to be used when calling @command{gnatxref} on a source
15317 written in that language, for which no file-specific switches have been
15318 specified.
15320 @item Switches
15321 This is an associative array attribute. Its domain is
15322 a set of file names. Its range is a string list that specifies
15323 options to be used when calling @command{gnatxref} on the named main source.
15324 If a source is not specified in the Switches attribute, @command{gnatxref} will
15325 be called with the options specified by Default_Switches of its language,
15326 if defined.
15327 @end table
15329 @subsection package   Finder
15331 @noindent
15332 The attributes of package @code{Finder} specify the tool options to be used
15333 when invoking the search tool @command{gnatfind}.
15334 The following attributes apply to package @code{Finder}:
15336 @table @code
15337 @item     Default_Switches
15338 This is an associative array attribute. Its
15339 domain is a set of language names. Its range is a string list that
15340 specifies options to be used when calling @command{gnatfind} on a source
15341 written in that language, for which no file-specific switches have been
15342 specified.
15344 @item Switches
15345 This is an associative array attribute. Its domain is
15346 a set of file names. Its range is a string list that specifies
15347 options to be used when calling @command{gnatfind} on the named main source.
15348 If a source is not specified in the Switches attribute, @command{gnatfind} will
15349 be called with the options specified by Default_Switches of its language,
15350 if defined.
15351 @end table
15353 @subsection package Pretty_Printer
15355 @noindent
15356 The attributes of package @code{Pretty_Printer}
15357 specify the tool options to be used
15358 when invoking the formatting tool @command{gnatpp}.
15359 The following attributes apply to package @code{Pretty_Printer}:
15361 @table @code
15362 @item     Default_switches
15363 This is an associative array attribute. Its
15364 domain is a set of language names. Its range is a string list that
15365 specifies options to be used when calling @command{gnatpp} on a source
15366 written in that language, for which no file-specific switches have been
15367 specified.
15369 @item Switches
15370 This is an associative array attribute. Its domain is
15371 a set of file names. Its range is a string list that specifies
15372 options to be used when calling @command{gnatpp} on the named main source.
15373 If a source is not specified in the Switches attribute, @command{gnatpp} will
15374 be called with the options specified by Default_Switches of its language,
15375 if defined.
15376 @end table
15378 @subsection package gnatstub
15380 @noindent
15381 The attributes of package @code{gnatstub}
15382 specify the tool options to be used
15383 when invoking the tool @command{gnatstub}.
15384 The following attributes apply to package @code{gnatstub}:
15386 @table @code
15387 @item     Default_switches
15388 This is an associative array attribute. Its
15389 domain is a set of language names. Its range is a string list that
15390 specifies options to be used when calling @command{gnatstub} on a source
15391 written in that language, for which no file-specific switches have been
15392 specified.
15394 @item Switches
15395 This is an associative array attribute. Its domain is
15396 a set of file names. Its range is a string list that specifies
15397 options to be used when calling @command{gnatstub} on the named main source.
15398 If a source is not specified in the Switches attribute, @command{gnatpp} will
15399 be called with the options specified by Default_Switches of its language,
15400 if defined.
15401 @end table
15403 @subsection package Eliminate
15405 @noindent
15406 The attributes of package @code{Eliminate}
15407 specify the tool options to be used
15408 when invoking the tool @command{gnatelim}.
15409 The following attributes apply to package @code{Eliminate}:
15411 @table @code
15412 @item     Default_switches
15413 This is an associative array attribute. Its
15414 domain is a set of language names. Its range is a string list that
15415 specifies options to be used when calling @command{gnatelim} on a source
15416 written in that language, for which no file-specific switches have been
15417 specified.
15419 @item Switches
15420 This is an associative array attribute. Its domain is
15421 a set of file names. Its range is a string list that specifies
15422 options to be used when calling @command{gnatelim} on the named main source.
15423 If a source is not specified in the Switches attribute, @command{gnatelim} will
15424 be called with the options specified by Default_Switches of its language,
15425 if defined.
15426 @end table
15428 @subsection package Metrics
15430 @noindent
15431 The attributes of package @code{Metrics}
15432 specify the tool options to be used
15433 when invoking the tool @command{gnatmetric}.
15434 The following attributes apply to package @code{Metrics}:
15436 @table @code
15437 @item     Default_switches
15438 This is an associative array attribute. Its
15439 domain is a set of language names. Its range is a string list that
15440 specifies options to be used when calling @command{gnatmetric} on a source
15441 written in that language, for which no file-specific switches have been
15442 specified.
15444 @item Switches
15445 This is an associative array attribute. Its domain is
15446 a set of file names. Its range is a string list that specifies
15447 options to be used when calling @command{gnatmetric} on the named main source.
15448 If a source is not specified in the Switches attribute, @command{gnatmetric}
15449 will be called with the options specified by Default_Switches of its language,
15450 if defined.
15451 @end table
15453 @subsection  package IDE
15455 @noindent
15456 The attributes of package @code{IDE} specify the options to be used when using
15457 an Integrated Development Environment such as @command{GPS}.
15459 @table @code
15460 @item Remote_Host
15461 This is a simple attribute. Its value is a string that designates the remote
15462 host in a cross-compilation environment, to be used for remote compilation and
15463 debugging. This field should not be specified when running on the local
15464 machine.
15466 @item Program_Host
15467 This is a simple attribute. Its value is a string that specifies the
15468 name of IP address of the embedded target in a cross-compilation environment,
15469 on which the program should execute.
15471 @item Communication_Protocol
15472 This is a simple string attribute. Its value is the name of the protocol
15473 to use to communicate with the target in a cross-compilation environment,
15474 e.g. @code{"wtx"} or @code{"vxworks"}.
15476 @item Compiler_Command
15477 This is an associative array attribute, whose domain is a language name. Its
15478 value is  string that denotes the command to be used to invoke the compiler.
15479 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15480 gnatmake, in particular in the handling of switches.
15482 @item Debugger_Command
15483 This is simple attribute, Its value is a string that specifies the name of
15484 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15486 @item Default_Switches
15487 This is an associative array attribute. Its indexes are the name of the
15488 external tools that the GNAT Programming System (GPS) is supporting. Its
15489 value is a list of switches to use when invoking that tool.
15491 @item  Gnatlist
15492 This is a simple attribute.  Its value is a string that specifies the name
15493 of the @command{gnatls} utility to be used to retrieve information about the
15494 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15496 @item VCS_Kind
15497 This is a simple attribute. Its value is a string used to specify the
15498 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15499 ClearCase or Perforce.
15501 @item VCS_File_Check
15502 This is a simple attribute. Its value is a string that specifies the
15503 command used by the VCS to check the validity of a file, either
15504 when the user explicitly asks for a check, or as a sanity check before
15505 doing the check-in.
15507 @item VCS_Log_Check
15508 This is a simple attribute. Its value is a string that specifies
15509 the command used by the VCS to check the validity of a log file.
15511 @end table
15513 @node Package Renamings
15514 @section Package Renamings
15516 @noindent
15517 A package can be defined by a renaming declaration. The new package renames
15518 a package declared in a different project file, and has the same attributes
15519 as the package it renames.
15520 Syntax:
15521 @smallexample
15522 package_renaming ::==
15523   @b{package} package_identifier @b{renames}
15524        <project_>simple_name.package_identifier ;
15525 @end smallexample
15527 @noindent
15528 The package_identifier of the renamed package must be the same as the
15529 package_identifier. The project whose name is the prefix of the renamed
15530 package must contain a package declaration with this name. This project
15531 must appear in the context_clause of the enclosing project declaration,
15532 or be the parent project of the enclosing child project.
15534 @node Projects
15535 @section Projects
15537 @noindent
15538 A project file specifies a set of rules for constructing a software system.
15539 A project file can be self-contained, or depend on other project files.
15540 Dependencies are expressed through a context clause that names other projects.
15542 Syntax:
15544 @smallexample
15545 project ::=
15546   context_clause project_declaration
15548 project_declaration ::=
15549   simple_project_declaration | project_extension
15551 simple_project_declaration ::=
15552   @b{project} <project_>simple_name @b{is}
15553     @{declarative_item@}
15554   @b{end} <project_>simple_name;
15556 context_clause ::=
15557   @{with_clause@}
15559 with_clause ::=
15560   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15562 path_name ::=
15563    string_literal
15564 @end smallexample
15566 @noindent
15567 A path name denotes a project file. A path name can be absolute or relative.
15568 An absolute path name includes a sequence of directories, in the syntax of
15569 the host operating system, that identifies uniquely the project file in the
15570 file system. A relative path name identifies the project file, relative
15571 to the directory that contains the current project, or relative to a
15572 directory listed in the environment variable ADA_PROJECT_PATH.
15573 Path names are case sensitive if file names in the host operating system
15574 are case sensitive.
15576 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15577 directory names separated by colons (semicolons on Windows).
15579 A given project name can appear only once in a context_clause.
15581 It is illegal for a project imported by a context clause to refer, directly
15582 or indirectly, to the project in which this context clause appears (the
15583 dependency graph cannot contain cycles), except when one of the with_clause
15584 in the cycle is a @code{limited with}.
15586 @node Project Extensions
15587 @section Project Extensions
15589 @noindent
15590 A project extension introduces a new project, which inherits the declarations
15591 of another project.
15592 Syntax:
15593 @smallexample
15595 project_extension ::=
15596   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15597     @{declarative_item@}
15598   @b{end} <project_>simple_name;
15599 @end smallexample
15601 @noindent
15602 The project extension declares a child project. The child project inherits
15603 all the declarations and all the files of the parent project, These inherited
15604 declaration can be overridden in the child project, by means of suitable
15605 declarations.
15607 @node Project File Elaboration
15608 @section Project File Elaboration
15610 @noindent
15611 A project file is processed as part of the invocation of a gnat tool that
15612 uses the project option. Elaboration of the process file consists in the
15613 sequential elaboration of all its declarations. The computed values of
15614 attributes and variables in the project are then used to establish the
15615 environment in which the gnat tool will execute.
15617 @node Obsolescent Features
15618 @chapter Obsolescent Features
15620 @noindent
15621 This chapter describes features that are provided by GNAT, but are
15622 considered obsolescent since there are preferred ways of achieving
15623 the same effect. These features are provided solely for historical
15624 compatibility purposes.
15626 @menu
15627 * pragma No_Run_Time::
15628 * pragma Ravenscar::
15629 * pragma Restricted_Run_Time::
15630 @end menu
15632 @node pragma No_Run_Time
15633 @section pragma No_Run_Time
15635 The pragma @code{No_Run_Time} is used to achieve an affect similar
15636 to the use of the "Zero Foot Print" configurable run time, but without
15637 requiring a specially configured run time. The result of using this
15638 pragma, which must be used for all units in a partition, is to restrict
15639 the use of any language features requiring run-time support code. The
15640 preferred usage is to use an appropriately configured run-time that
15641 includes just those features that are to be made accessible.
15643 @node pragma Ravenscar
15644 @section pragma Ravenscar
15646 The pragma @code{Ravenscar} has exactly the same effect as pragma
15647 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15648 is part of the new Ada 2005 standard.
15650 @node pragma Restricted_Run_Time
15651 @section pragma Restricted_Run_Time
15653 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15654 pragma @code{Profile (Restricted)}. The latter usage is
15655 preferred since the Ada 2005 pragma @code{Profile} is intended for
15656 this kind of implementation dependent addition.
15658 @include fdl.texi
15659 @c GNU Free Documentation License
15661 @node Index,,GNU Free Documentation License, Top
15662 @unnumbered Index
15664 @printindex cp
15666 @contents
15668 @bye