OSDN Git Service

PR 33870
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c              Copyright (C) 1995-2007, 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
17
18 @setfilename gnat_rm.info
19
20 @set EDITION GNAT
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
23
24 @settitle GNAT Reference Manual
25
26 @setchapternewpage odd
27 @syncodeindex fn cp
28
29 @include gcc-common.texi
30
31 @dircategory GNU Ada tools
32 @direntry
33 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
34 @end direntry
35
36 @copying
37 Copyright @copyright{} 1995-2007, Free Software Foundation
38
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
46 @end copying
47
48 @titlepage
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
51 @versionsubtitle
52 @author AdaCore
53 @page
54 @vskip 0pt plus 1filll
55
56 @insertcopying
57
58 @end titlepage
59
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
63
64 @noindent
65 GNAT Reference Manual
66
67 @noindent
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
70
71 @noindent
72 AdaCore
73
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
92
93  --- The Detailed Node Listing ---
94
95 About This Guide
96
97 * What This Reference Manual Contains::
98 * Related Information::
99
100 Implementation Defined Pragmas
101
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Ada_05::
106 * Pragma Ada_2005::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check_Name::
112 * Pragma Comment::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Complete_Representation::
117 * Pragma Complex_Representation::
118 * Pragma Component_Alignment::
119 * Pragma Convention_Identifier::
120 * Pragma CPP_Class::
121 * Pragma CPP_Constructor::
122 * Pragma CPP_Virtual::
123 * Pragma CPP_Vtable::
124 * Pragma Debug::
125 * Pragma Debug_Policy::
126 * Pragma Detect_Blocking::
127 * Pragma Elaboration_Checks::
128 * Pragma Eliminate::
129 * Pragma Export_Exception::
130 * Pragma Export_Function::
131 * Pragma Export_Object::
132 * Pragma Export_Procedure::
133 * Pragma Export_Value::
134 * Pragma Export_Valued_Procedure::
135 * Pragma Extend_System::
136 * Pragma External::
137 * Pragma External_Name_Casing::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
140 * Pragma Ident::
141 * Pragma Implicit_Packing::
142 * Pragma Import_Exception::
143 * Pragma Import_Function::
144 * Pragma Import_Object::
145 * Pragma Import_Procedure::
146 * Pragma Import_Valued_Procedure::
147 * Pragma Initialize_Scalars::
148 * Pragma Inline_Always::
149 * Pragma Inline_Generic::
150 * Pragma Interface::
151 * Pragma Interface_Name::
152 * Pragma Interrupt_Handler::
153 * Pragma Interrupt_State::
154 * Pragma Keep_Names::
155 * Pragma License::
156 * Pragma Link_With::
157 * Pragma Linker_Alias::
158 * Pragma Linker_Constructor::
159 * Pragma Linker_Destructor::
160 * Pragma Linker_Section::
161 * Pragma Long_Float::
162 * Pragma Machine_Attribute::
163 * Pragma Main::
164 * Pragma Main_Storage::
165 * Pragma No_Body::
166 * Pragma No_Return::
167 * Pragma No_Strict_Aliasing ::
168 * Pragma Normalize_Scalars::
169 * Pragma Obsolescent::
170 * Pragma Passive::
171 * Pragma Persistent_BSS::
172 * Pragma Polling::
173 * Pragma Profile (Ravenscar)::
174 * Pragma Profile (Restricted)::
175 * Pragma Psect_Object::
176 * Pragma Pure_Function::
177 * Pragma Restriction_Warnings::
178 * Pragma Source_File_Name::
179 * Pragma Source_File_Name_Project::
180 * Pragma Source_Reference::
181 * Pragma Stream_Convert::
182 * Pragma Style_Checks::
183 * Pragma Subtitle::
184 * Pragma Suppress::
185 * Pragma Suppress_All::
186 * Pragma Suppress_Exception_Locations::
187 * Pragma Suppress_Initialization::
188 * Pragma Task_Info::
189 * Pragma Task_Name::
190 * Pragma Task_Storage::
191 * Pragma Time_Slice::
192 * Pragma Title::
193 * Pragma Unchecked_Union::
194 * Pragma Unimplemented_Unit::
195 * Pragma Universal_Aliasing ::
196 * Pragma Universal_Data::
197 * Pragma Unreferenced::
198 * Pragma Unreferenced_Objects::
199 * Pragma Unreserve_All_Interrupts::
200 * Pragma Unsuppress::
201 * Pragma Use_VADS_Size::
202 * Pragma Validity_Checks::
203 * Pragma Volatile::
204 * Pragma Warnings::
205 * Pragma Weak_External::
206 * Pragma Wide_Character_Encoding::
207
208 Implementation Defined Attributes
209
210 * Abort_Signal::
211 * Address_Size::
212 * Asm_Input::
213 * Asm_Output::
214 * AST_Entry::
215 * Bit::
216 * Bit_Position::
217 * Code_Address::
218 * Default_Bit_Order::
219 * Elaborated::
220 * Elab_Body::
221 * Elab_Spec::
222 * Emax::
223 * Enabled::
224 * Enum_Rep::
225 * Epsilon::
226 * Fixed_Value::
227 * Has_Access_Values::
228 * Has_Discriminants::
229 * Img::
230 * Integer_Value::
231 * Large::
232 * Machine_Size::
233 * Mantissa::
234 * Max_Interrupt_Priority::
235 * Max_Priority::
236 * Maximum_Alignment::
237 * Mechanism_Code::
238 * Null_Parameter::
239 * Object_Size::
240 * Passed_By_Reference::
241 * Range_Length::
242 * Safe_Emax::
243 * Safe_Large::
244 * Small::
245 * Storage_Unit::
246 * Stub_Type::
247 * Target_Name::
248 * Tick::
249 * To_Address::
250 * Type_Class::
251 * UET_Address::
252 * Unconstrained_Array::
253 * Universal_Literal_String::
254 * Unrestricted_Access::
255 * VADS_Size::
256 * Value_Size::
257 * Wchar_T_Size::
258 * Word_Size::
259
260 The Implementation of Standard I/O
261
262 * Standard I/O Packages::
263 * FORM Strings::
264 * Direct_IO::
265 * Sequential_IO::
266 * Text_IO::
267 * Wide_Text_IO::
268 * Wide_Wide_Text_IO::
269 * Stream_IO::
270 * Shared Files::
271 * Filenames encoding::
272 * Open Modes::
273 * Operations on C Streams::
274 * Interfacing to C Streams::
275
276 The GNAT Library
277
278 * Ada.Characters.Latin_9 (a-chlat9.ads)::
279 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
280 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
281 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
282 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
283 * Ada.Command_Line.Remove (a-colire.ads)::
284 * Ada.Command_Line.Environment (a-colien.ads)::
285 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
286 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
287 * Ada.Exceptions.Traceback (a-exctra.ads)::
288 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
289 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
290 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
291 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
292 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
293 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
294 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
295 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
296 * GNAT.Altivec (g-altive.ads)::
297 * GNAT.Altivec.Conversions (g-altcon.ads)::
298 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
299 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
300 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
301 * GNAT.Array_Split (g-arrspl.ads)::
302 * GNAT.AWK (g-awk.ads)::
303 * GNAT.Bounded_Buffers (g-boubuf.ads)::
304 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
305 * GNAT.Bubble_Sort (g-bubsor.ads)::
306 * GNAT.Bubble_Sort_A (g-busora.ads)::
307 * GNAT.Bubble_Sort_G (g-busorg.ads)::
308 * GNAT.Byte_Swapping (g-bytswa.ads)::
309 * GNAT.Calendar (g-calend.ads)::
310 * GNAT.Calendar.Time_IO (g-catiio.ads)::
311 * GNAT.Case_Util (g-casuti.ads)::
312 * GNAT.CGI (g-cgi.ads)::
313 * GNAT.CGI.Cookie (g-cgicoo.ads)::
314 * GNAT.CGI.Debug (g-cgideb.ads)::
315 * GNAT.Command_Line (g-comlin.ads)::
316 * GNAT.Compiler_Version (g-comver.ads)::
317 * GNAT.Ctrl_C (g-ctrl_c.ads)::
318 * GNAT.CRC32 (g-crc32.ads)::
319 * GNAT.Current_Exception (g-curexc.ads)::
320 * GNAT.Debug_Pools (g-debpoo.ads)::
321 * GNAT.Debug_Utilities (g-debuti.ads)::
322 * GNAT.Directory_Operations (g-dirope.ads)::
323 * GNAT.Dynamic_HTables (g-dynhta.ads)::
324 * GNAT.Dynamic_Tables (g-dyntab.ads)::
325 * GNAT.Exception_Actions (g-excact.ads)::
326 * GNAT.Exception_Traces (g-exctra.ads)::
327 * GNAT.Exceptions (g-except.ads)::
328 * GNAT.Expect (g-expect.ads)::
329 * GNAT.Float_Control (g-flocon.ads)::
330 * GNAT.Heap_Sort (g-heasor.ads)::
331 * GNAT.Heap_Sort_A (g-hesora.ads)::
332 * GNAT.Heap_Sort_G (g-hesorg.ads)::
333 * GNAT.HTable (g-htable.ads)::
334 * GNAT.IO (g-io.ads)::
335 * GNAT.IO_Aux (g-io_aux.ads)::
336 * GNAT.Lock_Files (g-locfil.ads)::
337 * GNAT.MD5 (g-md5.ads)::
338 * GNAT.Memory_Dump (g-memdum.ads)::
339 * GNAT.Most_Recent_Exception (g-moreex.ads)::
340 * GNAT.OS_Lib (g-os_lib.ads)::
341 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
342 * GNAT.Regexp (g-regexp.ads)::
343 * GNAT.Registry (g-regist.ads)::
344 * GNAT.Regpat (g-regpat.ads)::
345 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
346 * GNAT.Semaphores (g-semaph.ads)::
347 * GNAT.SHA1 (g-sha1.ads)::
348 * GNAT.Signals (g-signal.ads)::
349 * GNAT.Sockets (g-socket.ads)::
350 * GNAT.Source_Info (g-souinf.ads)::
351 * GNAT.Spell_Checker (g-speche.ads)::
352 * GNAT.Spitbol.Patterns (g-spipat.ads)::
353 * GNAT.Spitbol (g-spitbo.ads)::
354 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
355 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
356 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
357 * GNAT.Strings (g-string.ads)::
358 * GNAT.String_Split (g-strspl.ads)::
359 * GNAT.Table (g-table.ads)::
360 * GNAT.Task_Lock (g-tasloc.ads)::
361 * GNAT.Threads (g-thread.ads)::
362 * GNAT.Traceback (g-traceb.ads)::
363 * GNAT.Traceback.Symbolic (g-trasym.ads)::
364 * GNAT.Wide_String_Split (g-wistsp.ads)::
365 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
366 * Interfaces.C.Extensions (i-cexten.ads)::
367 * Interfaces.C.Streams (i-cstrea.ads)::
368 * Interfaces.CPP (i-cpp.ads)::
369 * Interfaces.Os2lib (i-os2lib.ads)::
370 * Interfaces.Os2lib.Errors (i-os2err.ads)::
371 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
372 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
373 * Interfaces.Packed_Decimal (i-pacdec.ads)::
374 * Interfaces.VxWorks (i-vxwork.ads)::
375 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
376 * System.Address_Image (s-addima.ads)::
377 * System.Assertions (s-assert.ads)::
378 * System.Memory (s-memory.ads)::
379 * System.Partition_Interface (s-parint.ads)::
380 * System.Restrictions (s-restri.ads)::
381 * System.Rident (s-rident.ads)::
382 * System.Task_Info (s-tasinf.ads)::
383 * System.Wch_Cnv (s-wchcnv.ads)::
384 * System.Wch_Con (s-wchcon.ads)::
385
386 Text_IO
387
388 * Text_IO Stream Pointer Positioning::
389 * Text_IO Reading and Writing Non-Regular Files::
390 * Get_Immediate::
391 * Treating Text_IO Files as Streams::
392 * Text_IO Extensions::
393 * Text_IO Facilities for Unbounded Strings::
394
395 Wide_Text_IO
396
397 * Wide_Text_IO Stream Pointer Positioning::
398 * Wide_Text_IO Reading and Writing Non-Regular Files::
399
400 Wide_Wide_Text_IO
401
402 * Wide_Wide_Text_IO Stream Pointer Positioning::
403 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
404
405 Interfacing to Other Languages
406
407 * Interfacing to C::
408 * Interfacing to C++::
409 * Interfacing to COBOL::
410 * Interfacing to Fortran::
411 * Interfacing to non-GNAT Ada code::
412
413 Specialized Needs Annexes
414
415 Implementation of Specific Ada Features
416 * Machine Code Insertions::
417 * GNAT Implementation of Tasking::
418 * GNAT Implementation of Shared Passive Packages::
419 * Code Generation for Array Aggregates::
420 * The Size of Discriminated Records with Default Discriminants::
421 * Strict Conformance to the Ada Reference Manual::
422
423 Project File Reference
424
425 Obsolescent Features
426
427 GNU Free Documentation License
428
429 Index
430 @end menu
431
432 @end ifnottex
433
434 @node About This Guide
435 @unnumbered About This Guide
436
437 @noindent
438 This manual contains useful information in writing programs using the
439 @value{EDITION} compiler.  It includes information on implementation dependent
440 characteristics of @value{EDITION}, including all the information required by
441 Annex M of the Ada language standard.
442
443 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
444 Ada 83 compatibility mode.
445 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
446 but you can override with a compiler switch
447 to explicitly specify the language version.
448 (Please refer to the section ``Compiling Different Versions of Ada'', in
449 @cite{@value{EDITION} User's Guide}, for details on these switches.)
450 Throughout this manual, references to ``Ada'' without a year suffix
451 apply to both the Ada 95 and Ada 2005 versions of the language.
452
453 Ada is designed to be highly portable.
454 In general, a program will have the same effect even when compiled by
455 different compilers on different platforms.
456 However, since Ada is designed to be used in a
457 wide variety of applications, it also contains a number of system
458 dependent features to be used in interfacing to the external world.
459 @cindex Implementation-dependent features
460 @cindex Portability
461
462 Note: Any program that makes use of implementation-dependent features
463 may be non-portable.  You should follow good programming practice and
464 isolate and clearly document any sections of your program that make use
465 of these features in a non-portable manner.
466
467 @ifset PROEDITION
468 For ease of exposition, ``GNAT Pro'' will be referred to simply as
469 ``GNAT'' in the remainder of this document.
470 @end ifset
471
472 @menu
473 * What This Reference Manual Contains::
474 * Conventions::
475 * Related Information::
476 @end menu
477
478 @node What This Reference Manual Contains
479 @unnumberedsec What This Reference Manual Contains
480
481 @noindent
482 This reference manual contains the following chapters:
483
484 @itemize @bullet
485 @item
486 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
487 pragmas, which can be used to extend and enhance the functionality of the
488 compiler.
489
490 @item
491 @ref{Implementation Defined Attributes}, lists GNAT
492 implementation-dependent attributes which can be used to extend and
493 enhance the functionality of the compiler.
494
495 @item
496 @ref{Implementation Advice}, provides information on generally
497 desirable behavior which are not requirements that all compilers must
498 follow since it cannot be provided on all systems, or which may be
499 undesirable on some systems.
500
501 @item
502 @ref{Implementation Defined Characteristics}, provides a guide to
503 minimizing implementation dependent features.
504
505 @item
506 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
507 implemented by GNAT, and how they can be imported into user
508 application programs.
509
510 @item
511 @ref{Representation Clauses and Pragmas}, describes in detail the
512 way that GNAT represents data, and in particular the exact set
513 of representation clauses and pragmas that is accepted.
514
515 @item
516 @ref{Standard Library Routines}, provides a listing of packages and a
517 brief description of the functionality that is provided by Ada's
518 extensive set of standard library routines as implemented by GNAT@.
519
520 @item
521 @ref{The Implementation of Standard I/O}, details how the GNAT
522 implementation of the input-output facilities.
523
524 @item
525 @ref{The GNAT Library}, is a catalog of packages that complement
526 the Ada predefined library.
527
528 @item
529 @ref{Interfacing to Other Languages}, describes how programs
530 written in Ada using GNAT can be interfaced to other programming
531 languages.
532
533 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
534 of the specialized needs annexes.
535
536 @item
537 @ref{Implementation of Specific Ada Features}, discusses issues related
538 to GNAT's implementation of machine code insertions, tasking, and several
539 other features.
540
541 @item
542 @ref{Project File Reference}, presents the syntax and semantics
543 of project files.
544
545 @item
546 @ref{Obsolescent Features} documents implementation dependent features,
547 including pragmas and attributes, which are considered obsolescent, since
548 there are other preferred ways of achieving the same results. These
549 obsolescent forms are retained for backwards compatibility.
550
551 @end itemize
552
553 @cindex Ada 95 Language Reference Manual
554 @cindex Ada 2005 Language Reference Manual
555 @noindent
556 This reference manual assumes a basic familiarity with the Ada 95 language, as
557 described in the International Standard ANSI/ISO/IEC-8652:1995,
558 January 1995.
559 It does not require knowledge of the new features introduced by Ada 2005,
560 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
561 and Amendment 1).
562 Both reference manuals are included in the GNAT documentation
563 package.
564
565 @node Conventions
566 @unnumberedsec Conventions
567 @cindex Conventions, typographical
568 @cindex Typographical conventions
569
570 @noindent
571 Following are examples of the typographical and graphic conventions used
572 in this guide:
573
574 @itemize @bullet
575 @item
576 @code{Functions}, @code{utility program names}, @code{standard names},
577 and @code{classes}.
578
579 @item
580 @code{Option flags}
581
582 @item
583 @file{File Names}, @samp{button names}, and @samp{field names}.
584
585 @item
586 @code{Variables}.
587
588 @item
589 @emph{Emphasis}.
590
591 @item
592 [optional information or parameters]
593
594 @item
595 Examples are described by text
596 @smallexample
597 and then shown this way.
598 @end smallexample
599 @end itemize
600
601 @noindent
602 Commands that are entered by the user are preceded in this manual by the
603 characters @samp{$ } (dollar sign followed by space).  If your system uses this
604 sequence as a prompt, then the commands will appear exactly as you see them
605 in the manual.  If your system uses some other prompt, then the command will
606 appear with the @samp{$} replaced by whatever prompt character you are using.
607
608 @node Related Information
609 @unnumberedsec Related Information
610 @noindent
611 See the following documents for further information on GNAT:
612
613 @itemize @bullet
614 @item
615 @cite{GNAT User's Guide}, which provides information on how to use
616 the GNAT compiler system.
617
618 @item
619 @cite{Ada 95 Reference Manual}, which contains all reference
620 material for the Ada 95 programming language.
621
622 @item
623 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
624 of the Ada 95 standard.  The annotations describe
625 detailed aspects of the design decision, and in particular contain useful
626 sections on Ada 83 compatibility.
627
628 @item
629 @cite{Ada 2005 Reference Manual}, which contains all reference
630 material for the Ada 2005 programming language.
631
632 @item
633 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
634 of the Ada 2005 standard.  The annotations describe
635 detailed aspects of the design decision, and in particular contain useful
636 sections on Ada 83 and Ada 95 compatibility.
637
638 @item
639 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
640 which contains specific information on compatibility between GNAT and
641 DEC Ada 83 systems.
642
643 @item
644 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
645 describes in detail the pragmas and attributes provided by the DEC Ada 83
646 compiler system.
647
648 @end itemize
649
650 @node Implementation Defined Pragmas
651 @chapter Implementation Defined Pragmas
652
653 @noindent
654 Ada defines a set of pragmas that can be used to supply additional
655 information to the compiler.  These language defined pragmas are
656 implemented in GNAT and work as described in the Ada Reference
657 Manual.
658
659 In addition, Ada allows implementations to define additional pragmas
660 whose meaning is defined by the implementation.  GNAT provides a number
661 of these implementation-dependent pragmas which can be used to extend
662 and enhance the functionality of the compiler.  This section of the GNAT
663 Reference Manual describes these additional pragmas.
664
665 Note that any program using these pragmas may not be portable to other
666 compilers (although GNAT implements this set of pragmas on all
667 platforms).  Therefore if portability to other compilers is an important
668 consideration, the use of these pragmas should be minimized.
669
670 @menu
671 * Pragma Abort_Defer::
672 * Pragma Ada_83::
673 * Pragma Ada_95::
674 * Pragma Ada_05::
675 * Pragma Ada_2005::
676 * Pragma Annotate::
677 * Pragma Assert::
678 * Pragma Ast_Entry::
679 * Pragma C_Pass_By_Copy::
680 * Pragma Check_Name::
681 * Pragma Comment::
682 * Pragma Common_Object::
683 * Pragma Compile_Time_Error::
684 * Pragma Compile_Time_Warning::
685 * Pragma Complete_Representation::
686 * Pragma Complex_Representation::
687 * Pragma Component_Alignment::
688 * Pragma Convention_Identifier::
689 * Pragma CPP_Class::
690 * Pragma CPP_Constructor::
691 * Pragma CPP_Virtual::
692 * Pragma CPP_Vtable::
693 * Pragma Debug::
694 * Pragma Debug_Policy::
695 * Pragma Detect_Blocking::
696 * Pragma Elaboration_Checks::
697 * Pragma Eliminate::
698 * Pragma Export_Exception::
699 * Pragma Export_Function::
700 * Pragma Export_Object::
701 * Pragma Export_Procedure::
702 * Pragma Export_Value::
703 * Pragma Export_Valued_Procedure::
704 * Pragma Extend_System::
705 * Pragma External::
706 * Pragma External_Name_Casing::
707 * Pragma Finalize_Storage_Only::
708 * Pragma Float_Representation::
709 * Pragma Ident::
710 * Pragma Implicit_Packing::
711 * Pragma Import_Exception::
712 * Pragma Import_Function::
713 * Pragma Import_Object::
714 * Pragma Import_Procedure::
715 * Pragma Import_Valued_Procedure::
716 * Pragma Initialize_Scalars::
717 * Pragma Inline_Always::
718 * Pragma Inline_Generic::
719 * Pragma Interface::
720 * Pragma Interface_Name::
721 * Pragma Interrupt_Handler::
722 * Pragma Interrupt_State::
723 * Pragma Keep_Names::
724 * Pragma License::
725 * Pragma Link_With::
726 * Pragma Linker_Alias::
727 * Pragma Linker_Constructor::
728 * Pragma Linker_Destructor::
729 * Pragma Linker_Section::
730 * Pragma Long_Float::
731 * Pragma Machine_Attribute::
732 * Pragma Main::
733 * Pragma Main_Storage::
734 * Pragma No_Body::
735 * Pragma No_Return::
736 * Pragma No_Strict_Aliasing::
737 * Pragma Normalize_Scalars::
738 * Pragma Obsolescent::
739 * Pragma Passive::
740 * Pragma Persistent_BSS::
741 * Pragma Polling::
742 * Pragma Profile (Ravenscar)::
743 * Pragma Profile (Restricted)::
744 * Pragma Psect_Object::
745 * Pragma Pure_Function::
746 * Pragma Restriction_Warnings::
747 * Pragma Source_File_Name::
748 * Pragma Source_File_Name_Project::
749 * Pragma Source_Reference::
750 * Pragma Stream_Convert::
751 * Pragma Style_Checks::
752 * Pragma Subtitle::
753 * Pragma Suppress::
754 * Pragma Suppress_All::
755 * Pragma Suppress_Exception_Locations::
756 * Pragma Suppress_Initialization::
757 * Pragma Task_Info::
758 * Pragma Task_Name::
759 * Pragma Task_Storage::
760 * Pragma Time_Slice::
761 * Pragma Title::
762 * Pragma Unchecked_Union::
763 * Pragma Unimplemented_Unit::
764 * Pragma Universal_Aliasing ::
765 * Pragma Universal_Data::
766 * Pragma Unreferenced::
767 * Pragma Unreferenced_Objects::
768 * Pragma Unreserve_All_Interrupts::
769 * Pragma Unsuppress::
770 * Pragma Use_VADS_Size::
771 * Pragma Validity_Checks::
772 * Pragma Volatile::
773 * Pragma Warnings::
774 * Pragma Weak_External::
775 * Pragma Wide_Character_Encoding::
776 @end menu
777
778 @node Pragma Abort_Defer
779 @unnumberedsec Pragma Abort_Defer
780 @findex Abort_Defer
781 @cindex Deferring aborts
782 @noindent
783 Syntax:
784 @smallexample
785 pragma Abort_Defer;
786 @end smallexample
787
788 @noindent
789 This pragma must appear at the start of the statement sequence of a
790 handled sequence of statements (right after the @code{begin}).  It has
791 the effect of deferring aborts for the sequence of statements (but not
792 for the declarations or handlers, if any, associated with this statement
793 sequence).
794
795 @node Pragma Ada_83
796 @unnumberedsec Pragma Ada_83
797 @findex Ada_83
798 @noindent
799 Syntax:
800 @smallexample @c ada
801 pragma Ada_83;
802 @end smallexample
803
804 @noindent
805 A configuration pragma that establishes Ada 83 mode for the unit to
806 which it applies, regardless of the mode set by the command line
807 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
808 the syntax and semantics of Ada 83, as defined in the original Ada
809 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
810 (and Ada 2005) are not recognized, optional package bodies are allowed,
811 and generics may name types with unknown discriminants without using
812 the @code{(<>)} notation.  In addition, some but not all of the additional
813 restrictions of Ada 83 are enforced.
814
815 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
816 Ada 83 code to be compiled and adapted to GNAT with less effort.
817 Secondly, it aids in keeping code backwards compatible with Ada 83.
818 However, there is no guarantee that code that is processed correctly
819 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
820 83 compiler, since GNAT does not enforce all the additional checks
821 required by Ada 83.
822
823 @node Pragma Ada_95
824 @unnumberedsec Pragma Ada_95
825 @findex Ada_95
826 @noindent
827 Syntax:
828 @smallexample @c ada
829 pragma Ada_95;
830 @end smallexample
831
832 @noindent
833 A configuration pragma that establishes Ada 95 mode for the unit to which
834 it applies, regardless of the mode set by the command line switches.
835 This mode is set automatically for the @code{Ada} and @code{System}
836 packages and their children, so you need not specify it in these
837 contexts.  This pragma is useful when writing a reusable component that
838 itself uses Ada 95 features, but which is intended to be usable from
839 either Ada 83 or Ada 95 programs.
840
841 @node Pragma Ada_05
842 @unnumberedsec Pragma Ada_05
843 @findex Ada_05
844 @noindent
845 Syntax:
846 @smallexample @c ada
847 pragma Ada_05;
848 @end smallexample
849
850 @noindent
851 A configuration pragma that establishes Ada 2005 mode for the unit to which
852 it applies, regardless of the mode set by the command line switches.
853 This mode is set automatically for the @code{Ada} and @code{System}
854 packages and their children, so you need not specify it in these
855 contexts.  This pragma is useful when writing a reusable component that
856 itself uses Ada 2005 features, but which is intended to be usable from
857 either Ada 83 or Ada 95 programs.
858
859 @node Pragma Ada_2005
860 @unnumberedsec Pragma Ada_2005
861 @findex Ada_2005
862 @noindent
863 Syntax:
864 @smallexample @c ada
865 pragma Ada_2005;
866 @end smallexample
867
868 @noindent
869 This configuration pragma is a synonym for pragma Ada_05 and has the
870 same syntax and effect.
871
872 @node Pragma Annotate
873 @unnumberedsec Pragma Annotate
874 @findex Annotate
875 @noindent
876 Syntax:
877 @smallexample @c ada
878 pragma Annotate (IDENTIFIER @{, ARG@});
879
880 ARG ::= NAME | EXPRESSION
881 @end smallexample
882
883 @noindent
884 This pragma is used to annotate programs.  @var{identifier} identifies
885 the type of annotation.  GNAT verifies this is an identifier, but does
886 not otherwise analyze it.  The @var{arg} argument
887 can be either a string literal or an
888 expression.  String literals are assumed to be of type
889 @code{Standard.String}.  Names of entities are simply analyzed as entity
890 names.  All other expressions are analyzed as expressions, and must be
891 unambiguous.
892
893 The analyzed pragma is retained in the tree, but not otherwise processed
894 by any part of the GNAT compiler.  This pragma is intended for use by
895 external tools, including ASIS@.
896
897 @node Pragma Assert
898 @unnumberedsec Pragma Assert
899 @findex Assert
900 @noindent
901 Syntax:
902 @smallexample @c ada
903 pragma Assert (
904   boolean_EXPRESSION
905   [, static_string_EXPRESSION]);
906 @end smallexample
907
908 @noindent
909 The effect of this pragma depends on whether the corresponding command
910 line switch is set to activate assertions.  The pragma expands into code
911 equivalent to the following:
912
913 @smallexample @c ada
914 if assertions-enabled then
915    if not boolean_EXPRESSION then
916       System.Assertions.Raise_Assert_Failure
917         (string_EXPRESSION);
918    end if;
919 end if;
920 @end smallexample
921
922 @noindent
923 The string argument, if given, is the message that will be associated
924 with the exception occurrence if the exception is raised.  If no second
925 argument is given, the default message is @samp{@var{file}:@var{nnn}},
926 where @var{file} is the name of the source file containing the assert,
927 and @var{nnn} is the line number of the assert.  A pragma is not a
928 statement, so if a statement sequence contains nothing but a pragma
929 assert, then a null statement is required in addition, as in:
930
931 @smallexample @c ada
932 @dots{}
933 if J > 3 then
934    pragma Assert (K > 3, "Bad value for K");
935    null;
936 end if;
937 @end smallexample
938
939 @noindent
940 Note that, as with the @code{if} statement to which it is equivalent, the
941 type of the expression is either @code{Standard.Boolean}, or any type derived
942 from this standard type.
943
944 If assertions are disabled (switch @code{-gnata} not used), then there
945 is no effect (and in particular, any side effects from the expression
946 are suppressed).  More precisely it is not quite true that the pragma
947 has no effect, since the expression is analyzed, and may cause types
948 to be frozen if they are mentioned here for the first time.
949
950 If assertions are enabled, then the given expression is tested, and if
951 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
952 which results in the raising of @code{Assert_Failure} with the given message.
953
954 If the boolean expression has side effects, these side effects will turn
955 on and off with the setting of the assertions mode, resulting in
956 assertions that have an effect on the program.  You should generally
957 avoid side effects in the expression arguments of this pragma.  However,
958 the expressions are analyzed for semantic correctness whether or not
959 assertions are enabled, so turning assertions on and off cannot affect
960 the legality of a program.
961
962 @node Pragma Ast_Entry
963 @unnumberedsec Pragma Ast_Entry
964 @cindex OpenVMS
965 @findex Ast_Entry
966 @noindent
967 Syntax:
968 @smallexample @c ada
969 pragma AST_Entry (entry_IDENTIFIER);
970 @end smallexample
971
972 @noindent
973 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
974 argument is the simple name of a single entry; at most one @code{AST_Entry}
975 pragma is allowed for any given entry.  This pragma must be used in
976 conjunction with the @code{AST_Entry} attribute, and is only allowed after
977 the entry declaration and in the same task type specification or single task
978 as the entry to which it applies.  This pragma specifies that the given entry
979 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
980 resulting from an OpenVMS system service call.  The pragma does not affect
981 normal use of the entry.  For further details on this pragma, see the
982 DEC Ada Language Reference Manual, section 9.12a.
983
984 @node Pragma C_Pass_By_Copy
985 @unnumberedsec Pragma C_Pass_By_Copy
986 @cindex Passing by copy
987 @findex C_Pass_By_Copy
988 @noindent
989 Syntax:
990 @smallexample @c ada
991 pragma C_Pass_By_Copy
992   ([Max_Size =>] static_integer_EXPRESSION);
993 @end smallexample
994
995 @noindent
996 Normally the default mechanism for passing C convention records to C
997 convention subprograms is to pass them by reference, as suggested by RM
998 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
999 this default, by requiring that record formal parameters be passed by
1000 copy if all of the following conditions are met:
1001
1002 @itemize @bullet
1003 @item
1004 The size of the record type does not exceed@*@var{static_integer_expression}.
1005 @item
1006 The record type has @code{Convention C}.
1007 @item
1008 The formal parameter has this record type, and the subprogram has a
1009 foreign (non-Ada) convention.
1010 @end itemize
1011
1012 @noindent
1013 If these conditions are met the argument is passed by copy, i.e.@: in a
1014 manner consistent with what C expects if the corresponding formal in the
1015 C prototype is a struct (rather than a pointer to a struct).
1016
1017 You can also pass records by copy by specifying the convention
1018 @code{C_Pass_By_Copy} for the record type, or by using the extended
1019 @code{Import} and @code{Export} pragmas, which allow specification of
1020 passing mechanisms on a parameter by parameter basis.
1021
1022 @node Pragma Check_Name
1023 @unnumberedsec Pragma Check_Name
1024 @cindex Defining check names
1025 @cindex Check names, defining
1026 @findex Check_Name
1027 @noindent
1028 Syntax:
1029 @smallexample @c ada
1030 pragma Check_Name (check_name_IDENTIFIER);
1031 @end smallexample
1032
1033 @noindent
1034 This is a configuration pragma which defines a new implementation
1035 defined check name (unless IDENTIFIER matches one of the predefined
1036 check names, in which case the pragma has no effect). Check names
1037 are global to a partition, so if two more more configuration pragmas
1038 are present in a partition mentioning the same name, only one new
1039 check name is introduced.
1040
1041 An implementation defined check name introduced with this pragma may
1042 be used in only three contexts: @code{pragma Suppress},
1043 @code{pragma Unsuppress},
1044 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1045 any of these three cases, the check name must be visible. A check
1046 name is visible if it is in the configuration pragmas applying to
1047 the current unit, or if it appears at the start of any unit that
1048 is part of the dependency set of the current unit (e.g. units that
1049 are mentioned in @code{with} clauses.
1050
1051 Normally the default mechanism for passing C convention records to C
1052 @node Pragma Comment
1053 @unnumberedsec Pragma Comment
1054 @findex Comment
1055 @noindent
1056 Syntax:
1057
1058 @smallexample @c ada
1059 pragma Comment (static_string_EXPRESSION);
1060 @end smallexample
1061
1062 @noindent
1063 This is almost identical in effect to pragma @code{Ident}.  It allows the
1064 placement of a comment into the object file and hence into the
1065 executable file if the operating system permits such usage.  The
1066 difference is that @code{Comment}, unlike @code{Ident}, has
1067 no limitations on placement of the pragma (it can be placed
1068 anywhere in the main source unit), and if more than one pragma
1069 is used, all comments are retained.
1070
1071 @node Pragma Common_Object
1072 @unnumberedsec Pragma Common_Object
1073 @findex Common_Object
1074 @noindent
1075 Syntax:
1076
1077 @smallexample @c ada
1078 pragma Common_Object (
1079      [Internal =>] local_NAME,
1080   [, [External =>] EXTERNAL_SYMBOL]
1081   [, [Size     =>] EXTERNAL_SYMBOL] );
1082
1083 EXTERNAL_SYMBOL ::=
1084   IDENTIFIER
1085 | static_string_EXPRESSION
1086 @end smallexample
1087
1088 @noindent
1089 This pragma enables the shared use of variables stored in overlaid
1090 linker areas corresponding to the use of @code{COMMON}
1091 in Fortran.  The single
1092 object @var{local_NAME} is assigned to the area designated by
1093 the @var{External} argument.
1094 You may define a record to correspond to a series
1095 of fields.  The @var{size} argument
1096 is syntax checked in GNAT, but otherwise ignored.
1097
1098 @code{Common_Object} is not supported on all platforms.  If no
1099 support is available, then the code generator will issue a message
1100 indicating that the necessary attribute for implementation of this
1101 pragma is not available.
1102
1103 @node Pragma Compile_Time_Error
1104 @unnumberedsec Pragma Compile_Time_Error
1105 @findex Compile_Time_Error
1106 @noindent
1107 Syntax:
1108
1109 @smallexample @c ada
1110 pragma Compile_Time_Error
1111          (boolean_EXPRESSION, static_string_EXPRESSION);
1112 @end smallexample
1113
1114 @noindent
1115 This pragma can be used to generate additional compile time
1116 error messages. It
1117 is particularly useful in generics, where errors can be issued for
1118 specific problematic instantiations. The first parameter is a boolean
1119 expression. The pragma is effective only if the value of this expression
1120 is known at compile time, and has the value True. The set of expressions
1121 whose values are known at compile time includes all static boolean
1122 expressions, and also other values which the compiler can determine
1123 at compile time (e.g. the size of a record type set by an explicit
1124 size representation clause, or the value of a variable which was
1125 initialized to a constant and is known not to have been modified).
1126 If these conditions are met, an error message is generated using
1127 the value given as the second argument. This string value may contain
1128 embedded ASCII.LF characters to break the message into multiple lines.
1129
1130 @node Pragma Compile_Time_Warning
1131 @unnumberedsec Pragma Compile_Time_Warning
1132 @findex Compile_Time_Warning
1133 @noindent
1134 Syntax:
1135
1136 @smallexample @c ada
1137 pragma Compile_Time_Warning
1138          (boolean_EXPRESSION, static_string_EXPRESSION);
1139 @end smallexample
1140
1141 @noindent
1142 This pragma can be used to generate additional compile time warnings. It
1143 is particularly useful in generics, where warnings can be issued for
1144 specific problematic instantiations. The first parameter is a boolean
1145 expression. The pragma is effective only if the value of this expression
1146 is known at compile time, and has the value True. The set of expressions
1147 whose values are known at compile time includes all static boolean
1148 expressions, and also other values which the compiler can determine
1149 at compile time (e.g. the size of a record type set by an explicit
1150 size representation clause, or the value of a variable which was
1151 initialized to a constant and is known not to have been modified).
1152 If these conditions are met, a warning message is generated using
1153 the value given as the second argument. This string value may contain
1154 embedded ASCII.LF characters to break the message into multiple lines.
1155
1156 @node Pragma Complete_Representation
1157 @unnumberedsec Pragma Complete_Representation
1158 @findex Complete_Representation
1159 @noindent
1160 Syntax:
1161
1162 @smallexample @c ada
1163 pragma Complete_Representation;
1164 @end smallexample
1165
1166 @noindent
1167 This pragma must appear immediately within a record representation
1168 clause. Typical placements are before the first component clause
1169 or after the last component clause. The effect is to give an error
1170 message if any component is missing a component clause. This pragma
1171 may be used to ensure that a record representation clause is
1172 complete, and that this invariant is maintained if fields are
1173 added to the record in the future.
1174
1175 @node Pragma Complex_Representation
1176 @unnumberedsec Pragma Complex_Representation
1177 @findex Complex_Representation
1178 @noindent
1179 Syntax:
1180
1181 @smallexample @c ada
1182 pragma Complex_Representation
1183         ([Entity =>] local_NAME);
1184 @end smallexample
1185
1186 @noindent
1187 The @var{Entity} argument must be the name of a record type which has
1188 two fields of the same floating-point type.  The effect of this pragma is
1189 to force gcc to use the special internal complex representation form for
1190 this record, which may be more efficient.  Note that this may result in
1191 the code for this type not conforming to standard ABI (application
1192 binary interface) requirements for the handling of record types.  For
1193 example, in some environments, there is a requirement for passing
1194 records by pointer, and the use of this pragma may result in passing
1195 this type in floating-point registers.
1196
1197 @node Pragma Component_Alignment
1198 @unnumberedsec Pragma Component_Alignment
1199 @cindex Alignments of components
1200 @findex Component_Alignment
1201 @noindent
1202 Syntax:
1203
1204 @smallexample @c ada
1205 pragma Component_Alignment (
1206      [Form =>] ALIGNMENT_CHOICE
1207   [, [Name =>] type_local_NAME]);
1208
1209 ALIGNMENT_CHOICE ::=
1210   Component_Size
1211 | Component_Size_4
1212 | Storage_Unit
1213 | Default
1214 @end smallexample
1215
1216 @noindent
1217 Specifies the alignment of components in array or record types.
1218 The meaning of the @var{Form} argument is as follows:
1219
1220 @table @code
1221 @findex Component_Size
1222 @item Component_Size
1223 Aligns scalar components and subcomponents of the array or record type
1224 on boundaries appropriate to their inherent size (naturally
1225 aligned).  For example, 1-byte components are aligned on byte boundaries,
1226 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1227 integer components are aligned on 4-byte boundaries and so on.  These
1228 alignment rules correspond to the normal rules for C compilers on all
1229 machines except the VAX@.
1230
1231 @findex Component_Size_4
1232 @item Component_Size_4
1233 Naturally aligns components with a size of four or fewer
1234 bytes.  Components that are larger than 4 bytes are placed on the next
1235 4-byte boundary.
1236
1237 @findex Storage_Unit
1238 @item Storage_Unit
1239 Specifies that array or record components are byte aligned, i.e.@:
1240 aligned on boundaries determined by the value of the constant
1241 @code{System.Storage_Unit}.
1242
1243 @cindex OpenVMS
1244 @item Default
1245 Specifies that array or record components are aligned on default
1246 boundaries, appropriate to the underlying hardware or operating system or
1247 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1248 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1249 the @code{Default} choice is the same as @code{Component_Size} (natural
1250 alignment).
1251 @end table
1252
1253 @noindent
1254 If the @code{Name} parameter is present, @var{type_local_NAME} must
1255 refer to a local record or array type, and the specified alignment
1256 choice applies to the specified type.  The use of
1257 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1258 @code{Component_Alignment} pragma to be ignored.  The use of
1259 @code{Component_Alignment} together with a record representation clause
1260 is only effective for fields not specified by the representation clause.
1261
1262 If the @code{Name} parameter is absent, the pragma can be used as either
1263 a configuration pragma, in which case it applies to one or more units in
1264 accordance with the normal rules for configuration pragmas, or it can be
1265 used within a declarative part, in which case it applies to types that
1266 are declared within this declarative part, or within any nested scope
1267 within this declarative part.  In either case it specifies the alignment
1268 to be applied to any record or array type which has otherwise standard
1269 representation.
1270
1271 If the alignment for a record or array type is not specified (using
1272 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1273 clause), the GNAT uses the default alignment as described previously.
1274
1275 @node Pragma Convention_Identifier
1276 @unnumberedsec Pragma Convention_Identifier
1277 @findex Convention_Identifier
1278 @cindex Conventions, synonyms
1279 @noindent
1280 Syntax:
1281
1282 @smallexample @c ada
1283 pragma Convention_Identifier (
1284          [Name =>]       IDENTIFIER,
1285          [Convention =>] convention_IDENTIFIER);
1286 @end smallexample
1287
1288 @noindent
1289 This pragma provides a mechanism for supplying synonyms for existing
1290 convention identifiers. The @code{Name} identifier can subsequently
1291 be used as a synonym for the given convention in other pragmas (including
1292 for example pragma @code{Import} or another @code{Convention_Identifier}
1293 pragma). As an example of the use of this, suppose you had legacy code
1294 which used Fortran77 as the identifier for Fortran. Then the pragma:
1295
1296 @smallexample @c ada
1297 pragma Convention_Identifier (Fortran77, Fortran);
1298 @end smallexample
1299
1300 @noindent
1301 would allow the use of the convention identifier @code{Fortran77} in
1302 subsequent code, avoiding the need to modify the sources. As another
1303 example, you could use this to parametrize convention requirements
1304 according to systems. Suppose you needed to use @code{Stdcall} on
1305 windows systems, and @code{C} on some other system, then you could
1306 define a convention identifier @code{Library} and use a single
1307 @code{Convention_Identifier} pragma to specify which convention
1308 would be used system-wide.
1309
1310 @node Pragma CPP_Class
1311 @unnumberedsec Pragma CPP_Class
1312 @findex CPP_Class
1313 @cindex Interfacing with C++
1314 @noindent
1315 Syntax:
1316
1317 @smallexample @c ada
1318 pragma CPP_Class ([Entity =>] local_NAME);
1319 @end smallexample
1320
1321 @noindent
1322 The argument denotes an entity in the current declarative region that is
1323 declared as a tagged record type. It indicates that the type corresponds
1324 to an externally declared C++ class type, and is to be laid out the same
1325 way that C++ would lay out the type.
1326
1327 Types for which @code{CPP_Class} is specified do not have assignment or
1328 equality operators defined (such operations can be imported or declared
1329 as subprograms as required). Initialization is allowed only by constructor
1330 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1331 limited if not explicitly declared as limited or derived from a limited
1332 type, and a warning is issued in that case.
1333
1334 Pragma @code{CPP_Class} is intended primarily for automatic generation
1335 using an automatic binding generator tool.
1336 See @ref{Interfacing to C++} for related information.
1337
1338 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1339 for backward compatibility but its functionality is available
1340 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1341
1342 @node Pragma CPP_Constructor
1343 @unnumberedsec Pragma CPP_Constructor
1344 @cindex Interfacing with C++
1345 @findex CPP_Constructor
1346 @noindent
1347 Syntax:
1348
1349 @smallexample @c ada
1350 pragma CPP_Constructor ([Entity =>] local_NAME
1351   [, [External_Name =>] static_string_EXPRESSION ]
1352   [, [Link_Name     =>] static_string_EXPRESSION ]);
1353 @end smallexample
1354
1355 @noindent
1356 This pragma identifies an imported function (imported in the usual way
1357 with pragma @code{Import}) as corresponding to a C++ constructor. If
1358 @code{External_Name} and @code{Link_Name} are not specified then the
1359 @code{Entity} argument is a name that must have been previously mentioned
1360 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1361 must be of one of the following forms:
1362
1363 @itemize @bullet
1364 @item
1365 @code{function @var{Fname} return @var{T}'Class}
1366
1367 @item
1368 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1369 @end itemize
1370
1371 @noindent
1372 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1373
1374 The first form is the default constructor, used when an object of type
1375 @var{T} is created on the Ada side with no explicit constructor.  Other
1376 constructors (including the copy constructor, which is simply a special
1377 case of the second form in which the one and only argument is of type
1378 @var{T}), can only appear in two contexts:
1379
1380 @itemize @bullet
1381 @item
1382 On the right side of an initialization of an object of type @var{T}.
1383 @item
1384 In an extension aggregate for an object of a type derived from @var{T}.
1385 @end itemize
1386
1387 @noindent
1388 Although the constructor is described as a function that returns a value
1389 on the Ada side, it is typically a procedure with an extra implicit
1390 argument (the object being initialized) at the implementation
1391 level.  GNAT issues the appropriate call, whatever it is, to get the
1392 object properly initialized.
1393
1394 In the case of derived objects, you may use one of two possible forms
1395 for declaring and creating an object:
1396
1397 @itemize @bullet
1398 @item @code{New_Object : Derived_T}
1399 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1400 @end itemize
1401
1402 @noindent
1403 In the first case the default constructor is called and extension fields
1404 if any are initialized according to the default initialization
1405 expressions in the Ada declaration.  In the second case, the given
1406 constructor is called and the extension aggregate indicates the explicit
1407 values of the extension fields.
1408
1409 If no constructors are imported, it is impossible to create any objects
1410 on the Ada side.  If no default constructor is imported, only the
1411 initialization forms using an explicit call to a constructor are
1412 permitted.
1413
1414 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1415 using an automatic binding generator tool.
1416 See @ref{Interfacing to C++} for more related information.
1417
1418 @node Pragma CPP_Virtual
1419 @unnumberedsec Pragma CPP_Virtual
1420 @cindex Interfacing to C++
1421 @findex CPP_Virtual
1422 @noindent
1423 This pragma is now obsolete has has no effect because GNAT generates
1424 the same object layout than the G++ compiler.
1425
1426 See @ref{Interfacing to C++} for related information.
1427
1428 @node Pragma CPP_Vtable
1429 @unnumberedsec Pragma CPP_Vtable
1430 @cindex Interfacing with C++
1431 @findex CPP_Vtable
1432 @noindent
1433 This pragma is now obsolete has has no effect because GNAT generates
1434 the same object layout than the G++ compiler.
1435
1436 See @ref{Interfacing to C++} for related information.
1437
1438 @node Pragma Debug
1439 @unnumberedsec Pragma Debug
1440 @findex Debug
1441 @noindent
1442 Syntax:
1443
1444 @smallexample @c ada
1445 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1446
1447 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1448   PROCEDURE_NAME
1449 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1450 @end smallexample
1451
1452 @noindent
1453 The procedure call argument has the syntactic form of an expression, meeting
1454 the syntactic requirements for pragmas.
1455
1456 If debug pragmas are not enabled or if the condition is present and evaluates
1457 to False, this pragma has no effect. If debug pragmas are enabled, the
1458 semantics of the pragma is exactly equivalent to the procedure call statement
1459 corresponding to the argument with a terminating semicolon. Pragmas are
1460 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1461 intersperse calls to debug procedures in the middle of declarations. Debug
1462 pragmas can be enabled either by use of the command line switch @code{-gnata}
1463 or by use of the configuration pragma @code{Debug_Policy}.
1464
1465 @node Pragma Debug_Policy
1466 @unnumberedsec Pragma Debug_Policy
1467 @findex Debug_Policy
1468 @noindent
1469 Syntax:
1470
1471 @smallexample @c ada
1472 pragma Debug_Policy (CHECK | IGNORE);
1473 @end smallexample
1474
1475 @noindent
1476 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1477 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1478 This pragma overrides the effect of the @code{-gnata} switch on the
1479 command line.
1480
1481 @node Pragma Detect_Blocking
1482 @unnumberedsec Pragma Detect_Blocking
1483 @findex Detect_Blocking
1484 @noindent
1485 Syntax:
1486
1487 @smallexample @c ada
1488 pragma Detect_Blocking;
1489 @end smallexample
1490
1491 @noindent
1492 This is a configuration pragma that forces the detection of potentially
1493 blocking operations within a protected operation, and to raise Program_Error
1494 if that happens.
1495
1496 @node Pragma Elaboration_Checks
1497 @unnumberedsec Pragma Elaboration_Checks
1498 @cindex Elaboration control
1499 @findex Elaboration_Checks
1500 @noindent
1501 Syntax:
1502
1503 @smallexample @c ada
1504 pragma Elaboration_Checks (Dynamic | Static);
1505 @end smallexample
1506
1507 @noindent
1508 This is a configuration pragma that provides control over the
1509 elaboration model used by the compilation affected by the
1510 pragma.  If the parameter is @code{Dynamic},
1511 then the dynamic elaboration
1512 model described in the Ada Reference Manual is used, as though
1513 the @code{-gnatE} switch had been specified on the command
1514 line.  If the parameter is @code{Static}, then the default GNAT static
1515 model is used.  This configuration pragma overrides the setting
1516 of the command line.  For full details on the elaboration models
1517 used by the GNAT compiler, see section ``Elaboration Order
1518 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1519
1520 @node Pragma Eliminate
1521 @unnumberedsec Pragma Eliminate
1522 @cindex Elimination of unused subprograms
1523 @findex Eliminate
1524 @noindent
1525 Syntax:
1526
1527 @smallexample @c ada
1528 pragma Eliminate (
1529     [Unit_Name =>] IDENTIFIER |
1530                    SELECTED_COMPONENT);
1531
1532 pragma Eliminate (
1533     [Unit_Name       =>]  IDENTIFIER |
1534                           SELECTED_COMPONENT,
1535     [Entity          =>]  IDENTIFIER |
1536                           SELECTED_COMPONENT |
1537                           STRING_LITERAL
1538     [,OVERLOADING_RESOLUTION]);
1539
1540 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1541                            SOURCE_LOCATION
1542
1543 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1544                                       FUNCTION_PROFILE
1545
1546 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1547
1548 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1549                       Result_Type => result_SUBTYPE_NAME]
1550
1551 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1552 SUBTYPE_NAME    ::= STRING_VALUE
1553
1554 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1555 SOURCE_TRACE    ::= STRING_VALUE
1556
1557 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1558 @end smallexample
1559
1560 @noindent
1561 This pragma indicates that the given entity is not used outside the
1562 compilation unit it is defined in. The entity must be an explicitly declared
1563 subprogram; this includes  generic subprogram instances and
1564 subprograms declared in generic package instances.
1565
1566 If the entity to be eliminated is a library level subprogram, then
1567 the first form of pragma @code{Eliminate} is used with only a single argument.
1568 In this form, the @code{Unit_Name} argument specifies the name of the
1569 library  level unit to be eliminated.
1570
1571 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1572 are required. If item is an entity of a library package, then the first
1573 argument specifies the unit name, and the second argument specifies
1574 the particular entity.  If the second argument is in string form, it must
1575 correspond to the internal manner in which GNAT stores entity names (see
1576 compilation unit Namet in the compiler sources for details).
1577
1578 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1579 to distinguish between overloaded subprograms. If a pragma does not contain
1580 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1581 subprograms denoted by the first two parameters.
1582
1583 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1584 to be eliminated in a manner similar to that used for the extended
1585 @code{Import} and @code{Export} pragmas, except that the subtype names are
1586 always given as strings. At the moment, this form of distinguishing
1587 overloaded subprograms is implemented only partially, so we do not recommend
1588 using it for practical subprogram elimination.
1589
1590 Note that in case of a parameterless procedure its profile is represented
1591 as @code{Parameter_Types => ("")}
1592
1593 Alternatively, the @code{Source_Location} parameter is used to specify
1594 which overloaded alternative is to be eliminated by pointing to the
1595 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1596 source text. The string literal (or concatenation of string literals)
1597 given as SOURCE_TRACE must have the following format:
1598
1599 @smallexample @c ada
1600 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1601
1602 LBRACKET ::= [
1603 RBRACKET ::= ]
1604
1605 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1606 FILE_NAME       ::= STRING_LITERAL
1607 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1608 @end smallexample
1609
1610 SOURCE_TRACE should be the short name of the source file (with no directory
1611 information), and LINE_NUMBER is supposed to point to the line where the
1612 defining name of the subprogram is located.
1613
1614 For the subprograms that are not a part of generic instantiations, only one
1615 SOURCE_LOCATION is used. If a subprogram is declared in a package
1616 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1617 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1618 second one denotes the declaration of the corresponding subprogram in the
1619 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1620 in case of nested instantiations.
1621
1622 The effect of the pragma is to allow the compiler to eliminate
1623 the code or data associated with the named entity.  Any reference to
1624 an eliminated entity outside the compilation unit it is defined in,
1625 causes a compile time or link time error.
1626
1627 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1628 in a system independent manner, with unused entities eliminated, without
1629 the requirement of modifying the source text.  Normally the required set
1630 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1631 tool. Elimination of unused entities local to a compilation unit is
1632 automatic, without requiring the use of pragma @code{Eliminate}.
1633
1634 Note that the reason this pragma takes string literals where names might
1635 be expected is that a pragma @code{Eliminate} can appear in a context where the
1636 relevant names are not visible.
1637
1638 Note that any change in the source files that includes removing, splitting of
1639 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1640 parameter illegal.
1641
1642 It is legal to use pragma Eliminate where the referenced entity is a
1643 dispatching operation, but it is not clear what this would mean, since
1644 in general the call does not know which entity is actually being called.
1645 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1646
1647 @node Pragma Export_Exception
1648 @unnumberedsec Pragma Export_Exception
1649 @cindex OpenVMS
1650 @findex Export_Exception
1651 @noindent
1652 Syntax:
1653
1654 @smallexample @c ada
1655 pragma Export_Exception (
1656      [Internal =>] local_NAME,
1657   [, [External =>] EXTERNAL_SYMBOL,]
1658   [, [Form     =>] Ada | VMS]
1659   [, [Code     =>] static_integer_EXPRESSION]);
1660
1661 EXTERNAL_SYMBOL ::=
1662   IDENTIFIER
1663 | static_string_EXPRESSION
1664 @end smallexample
1665
1666 @noindent
1667 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1668 causes the specified exception to be propagated outside of the Ada program,
1669 so that it can be handled by programs written in other OpenVMS languages.
1670 This pragma establishes an external name for an Ada exception and makes the
1671 name available to the OpenVMS Linker as a global symbol.  For further details
1672 on this pragma, see the
1673 DEC Ada Language Reference Manual, section 13.9a3.2.
1674
1675 @node Pragma Export_Function
1676 @unnumberedsec Pragma Export_Function
1677 @cindex Argument passing mechanisms
1678 @findex Export_Function
1679
1680 @noindent
1681 Syntax:
1682
1683 @smallexample @c ada
1684 pragma Export_Function (
1685      [Internal         =>] local_NAME,
1686   [, [External         =>] EXTERNAL_SYMBOL]
1687   [, [Parameter_Types  =>] PARAMETER_TYPES]
1688   [, [Result_Type      =>] result_SUBTYPE_MARK]
1689   [, [Mechanism        =>] MECHANISM]
1690   [, [Result_Mechanism =>] MECHANISM_NAME]);
1691
1692 EXTERNAL_SYMBOL ::=
1693   IDENTIFIER
1694 | static_string_EXPRESSION
1695 | ""
1696
1697 PARAMETER_TYPES ::=
1698   null
1699 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1700
1701 TYPE_DESIGNATOR ::=
1702   subtype_NAME
1703 | subtype_Name ' Access
1704
1705 MECHANISM ::=
1706   MECHANISM_NAME
1707 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1708
1709 MECHANISM_ASSOCIATION ::=
1710   [formal_parameter_NAME =>] MECHANISM_NAME
1711
1712 MECHANISM_NAME ::=
1713   Value
1714 | Reference
1715 | Descriptor [([Class =>] CLASS_NAME)]
1716
1717 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1718 @end smallexample
1719
1720 @noindent
1721 Use this pragma to make a function externally callable and optionally
1722 provide information on mechanisms to be used for passing parameter and
1723 result values.  We recommend, for the purposes of improving portability,
1724 this pragma always be used in conjunction with a separate pragma
1725 @code{Export}, which must precede the pragma @code{Export_Function}.
1726 GNAT does not require a separate pragma @code{Export}, but if none is
1727 present, @code{Convention Ada} is assumed, which is usually
1728 not what is wanted, so it is usually appropriate to use this
1729 pragma in conjunction with a @code{Export} or @code{Convention}
1730 pragma that specifies the desired foreign convention.
1731 Pragma @code{Export_Function}
1732 (and @code{Export}, if present) must appear in the same declarative
1733 region as the function to which they apply.
1734
1735 @var{internal_name} must uniquely designate the function to which the
1736 pragma applies.  If more than one function name exists of this name in
1737 the declarative part you must use the @code{Parameter_Types} and
1738 @code{Result_Type} parameters is mandatory to achieve the required
1739 unique designation.  @var{subtype_ mark}s in these parameters must
1740 exactly match the subtypes in the corresponding function specification,
1741 using positional notation to match parameters with subtype marks.
1742 The form with an @code{'Access} attribute can be used to match an
1743 anonymous access parameter.
1744
1745 @cindex OpenVMS
1746 @cindex Passing by descriptor
1747 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1748
1749 @cindex Suppressing external name
1750 Special treatment is given if the EXTERNAL is an explicit null
1751 string or a static string expressions that evaluates to the null
1752 string. In this case, no external name is generated. This form
1753 still allows the specification of parameter mechanisms.
1754
1755 @node Pragma Export_Object
1756 @unnumberedsec Pragma Export_Object
1757 @findex Export_Object
1758 @noindent
1759 Syntax:
1760
1761 @smallexample @c ada
1762 pragma Export_Object
1763       [Internal =>] local_NAME,
1764    [, [External =>] EXTERNAL_SYMBOL]
1765    [, [Size     =>] EXTERNAL_SYMBOL]
1766
1767 EXTERNAL_SYMBOL ::=
1768   IDENTIFIER
1769 | static_string_EXPRESSION
1770 @end smallexample
1771
1772 @noindent
1773 This pragma designates an object as exported, and apart from the
1774 extended rules for external symbols, is identical in effect to the use of
1775 the normal @code{Export} pragma applied to an object.  You may use a
1776 separate Export pragma (and you probably should from the point of view
1777 of portability), but it is not required.  @var{Size} is syntax checked,
1778 but otherwise ignored by GNAT@.
1779
1780 @node Pragma Export_Procedure
1781 @unnumberedsec Pragma Export_Procedure
1782 @findex Export_Procedure
1783 @noindent
1784 Syntax:
1785
1786 @smallexample @c ada
1787 pragma Export_Procedure (
1788      [Internal        =>] local_NAME
1789   [, [External        =>] EXTERNAL_SYMBOL]
1790   [, [Parameter_Types =>] PARAMETER_TYPES]
1791   [, [Mechanism       =>] MECHANISM]);
1792
1793 EXTERNAL_SYMBOL ::=
1794   IDENTIFIER
1795 | static_string_EXPRESSION
1796 | ""
1797
1798 PARAMETER_TYPES ::=
1799   null
1800 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1801
1802 TYPE_DESIGNATOR ::=
1803   subtype_NAME
1804 | subtype_Name ' Access
1805
1806 MECHANISM ::=
1807   MECHANISM_NAME
1808 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1809
1810 MECHANISM_ASSOCIATION ::=
1811   [formal_parameter_NAME =>] MECHANISM_NAME
1812
1813 MECHANISM_NAME ::=
1814   Value
1815 | Reference
1816 | Descriptor [([Class =>] CLASS_NAME)]
1817
1818 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1819 @end smallexample
1820
1821 @noindent
1822 This pragma is identical to @code{Export_Function} except that it
1823 applies to a procedure rather than a function and the parameters
1824 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1825 GNAT does not require a separate pragma @code{Export}, but if none is
1826 present, @code{Convention Ada} is assumed, which is usually
1827 not what is wanted, so it is usually appropriate to use this
1828 pragma in conjunction with a @code{Export} or @code{Convention}
1829 pragma that specifies the desired foreign convention.
1830
1831 @cindex OpenVMS
1832 @cindex Passing by descriptor
1833 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1834
1835 @cindex Suppressing external name
1836 Special treatment is given if the EXTERNAL is an explicit null
1837 string or a static string expressions that evaluates to the null
1838 string. In this case, no external name is generated. This form
1839 still allows the specification of parameter mechanisms.
1840
1841 @node Pragma Export_Value
1842 @unnumberedsec Pragma Export_Value
1843 @findex Export_Value
1844 @noindent
1845 Syntax:
1846
1847 @smallexample @c ada
1848 pragma Export_Value (
1849   [Value     =>] static_integer_EXPRESSION,
1850   [Link_Name =>] static_string_EXPRESSION);
1851 @end smallexample
1852
1853 @noindent
1854 This pragma serves to export a static integer value for external use.
1855 The first argument specifies the value to be exported. The Link_Name
1856 argument specifies the symbolic name to be associated with the integer
1857 value. This pragma is useful for defining a named static value in Ada
1858 that can be referenced in assembly language units to be linked with
1859 the application. This pragma is currently supported only for the
1860 AAMP target and is ignored for other targets.
1861
1862 @node Pragma Export_Valued_Procedure
1863 @unnumberedsec Pragma Export_Valued_Procedure
1864 @findex Export_Valued_Procedure
1865 @noindent
1866 Syntax:
1867
1868 @smallexample @c ada
1869 pragma Export_Valued_Procedure (
1870      [Internal        =>] local_NAME
1871   [, [External        =>] EXTERNAL_SYMBOL]
1872   [, [Parameter_Types =>] PARAMETER_TYPES]
1873   [, [Mechanism       =>] MECHANISM]);
1874
1875 EXTERNAL_SYMBOL ::=
1876   IDENTIFIER
1877 | static_string_EXPRESSION
1878 | ""
1879
1880 PARAMETER_TYPES ::=
1881   null
1882 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1883
1884 TYPE_DESIGNATOR ::=
1885   subtype_NAME
1886 | subtype_Name ' Access
1887
1888 MECHANISM ::=
1889   MECHANISM_NAME
1890 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1891
1892 MECHANISM_ASSOCIATION ::=
1893   [formal_parameter_NAME =>] MECHANISM_NAME
1894
1895 MECHANISM_NAME ::=
1896   Value
1897 | Reference
1898 | Descriptor [([Class =>] CLASS_NAME)]
1899
1900 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1901 @end smallexample
1902
1903 @noindent
1904 This pragma is identical to @code{Export_Procedure} except that the
1905 first parameter of @var{local_NAME}, which must be present, must be of
1906 mode @code{OUT}, and externally the subprogram is treated as a function
1907 with this parameter as the result of the function.  GNAT provides for
1908 this capability to allow the use of @code{OUT} and @code{IN OUT}
1909 parameters in interfacing to external functions (which are not permitted
1910 in Ada functions).
1911 GNAT does not require a separate pragma @code{Export}, but if none is
1912 present, @code{Convention Ada} is assumed, which is almost certainly
1913 not what is wanted since the whole point of this pragma is to interface
1914 with foreign language functions, so it is usually appropriate to use this
1915 pragma in conjunction with a @code{Export} or @code{Convention}
1916 pragma that specifies the desired foreign convention.
1917
1918 @cindex OpenVMS
1919 @cindex Passing by descriptor
1920 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1921
1922 @cindex Suppressing external name
1923 Special treatment is given if the EXTERNAL is an explicit null
1924 string or a static string expressions that evaluates to the null
1925 string. In this case, no external name is generated. This form
1926 still allows the specification of parameter mechanisms.
1927
1928 @node Pragma Extend_System
1929 @unnumberedsec Pragma Extend_System
1930 @cindex @code{system}, extending
1931 @cindex Dec Ada 83
1932 @findex Extend_System
1933 @noindent
1934 Syntax:
1935
1936 @smallexample @c ada
1937 pragma Extend_System ([Name =>] IDENTIFIER);
1938 @end smallexample
1939
1940 @noindent
1941 This pragma is used to provide backwards compatibility with other
1942 implementations that extend the facilities of package @code{System}.  In
1943 GNAT, @code{System} contains only the definitions that are present in
1944 the Ada RM@.  However, other implementations, notably the DEC Ada 83
1945 implementation, provide many extensions to package @code{System}.
1946
1947 For each such implementation accommodated by this pragma, GNAT provides a
1948 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1949 implementation, which provides the required additional definitions.  You
1950 can use this package in two ways.  You can @code{with} it in the normal
1951 way and access entities either by selection or using a @code{use}
1952 clause.  In this case no special processing is required.
1953
1954 However, if existing code contains references such as
1955 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1956 definitions provided in package @code{System}, you may use this pragma
1957 to extend visibility in @code{System} in a non-standard way that
1958 provides greater compatibility with the existing code.  Pragma
1959 @code{Extend_System} is a configuration pragma whose single argument is
1960 the name of the package containing the extended definition
1961 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1962 control of this pragma will be processed using special visibility
1963 processing that looks in package @code{System.Aux_@var{xxx}} where
1964 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1965 package @code{System}, but not found in package @code{System}.
1966
1967 You can use this pragma either to access a predefined @code{System}
1968 extension supplied with the compiler, for example @code{Aux_DEC} or
1969 you can construct your own extension unit following the above
1970 definition.  Note that such a package is a child of @code{System}
1971 and thus is considered part of the implementation.  To compile
1972 it you will have to use the appropriate switch for compiling
1973 system units.  See the GNAT User's Guide for details.
1974
1975 @node Pragma External
1976 @unnumberedsec Pragma External
1977 @findex External
1978 @noindent
1979 Syntax:
1980
1981 @smallexample @c ada
1982 pragma External (
1983   [   Convention    =>] convention_IDENTIFIER,
1984   [   Entity        =>] local_NAME
1985   [, [External_Name =>] static_string_EXPRESSION ]
1986   [, [Link_Name     =>] static_string_EXPRESSION ]);
1987 @end smallexample
1988
1989 @noindent
1990 This pragma is identical in syntax and semantics to pragma
1991 @code{Export} as defined in the Ada Reference Manual.  It is
1992 provided for compatibility with some Ada 83 compilers that
1993 used this pragma for exactly the same purposes as pragma
1994 @code{Export} before the latter was standardized.
1995
1996 @node Pragma External_Name_Casing
1997 @unnumberedsec Pragma External_Name_Casing
1998 @cindex Dec Ada 83 casing compatibility
1999 @cindex External Names, casing
2000 @cindex Casing of External names
2001 @findex External_Name_Casing
2002 @noindent
2003 Syntax:
2004
2005 @smallexample @c ada
2006 pragma External_Name_Casing (
2007   Uppercase | Lowercase
2008   [, Uppercase | Lowercase | As_Is]);
2009 @end smallexample
2010
2011 @noindent
2012 This pragma provides control over the casing of external names associated
2013 with Import and Export pragmas.  There are two cases to consider:
2014
2015 @table @asis
2016 @item Implicit external names
2017 Implicit external names are derived from identifiers.  The most common case
2018 arises when a standard Ada Import or Export pragma is used with only two
2019 arguments, as in:
2020
2021 @smallexample @c ada
2022    pragma Import (C, C_Routine);
2023 @end smallexample
2024
2025 @noindent
2026 Since Ada is a case-insensitive language, the spelling of the identifier in
2027 the Ada source program does not provide any information on the desired
2028 casing of the external name, and so a convention is needed.  In GNAT the
2029 default treatment is that such names are converted to all lower case
2030 letters.  This corresponds to the normal C style in many environments.
2031 The first argument of pragma @code{External_Name_Casing} can be used to
2032 control this treatment.  If @code{Uppercase} is specified, then the name
2033 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2034 then the normal default of all lower case letters will be used.
2035
2036 This same implicit treatment is also used in the case of extended DEC Ada 83
2037 compatible Import and Export pragmas where an external name is explicitly
2038 specified using an identifier rather than a string.
2039
2040 @item Explicit external names
2041 Explicit external names are given as string literals.  The most common case
2042 arises when a standard Ada Import or Export pragma is used with three
2043 arguments, as in:
2044
2045 @smallexample @c ada
2046 pragma Import (C, C_Routine, "C_routine");
2047 @end smallexample
2048
2049 @noindent
2050 In this case, the string literal normally provides the exact casing required
2051 for the external name.  The second argument of pragma
2052 @code{External_Name_Casing} may be used to modify this behavior.
2053 If @code{Uppercase} is specified, then the name
2054 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2055 then the name will be forced to all lowercase letters.  A specification of
2056 @code{As_Is} provides the normal default behavior in which the casing is
2057 taken from the string provided.
2058 @end table
2059
2060 @noindent
2061 This pragma may appear anywhere that a pragma is valid.  In particular, it
2062 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2063 case it applies to all subsequent compilations, or it can be used as a program
2064 unit pragma, in which case it only applies to the current unit, or it can
2065 be used more locally to control individual Import/Export pragmas.
2066
2067 It is primarily intended for use with OpenVMS systems, where many
2068 compilers convert all symbols to upper case by default.  For interfacing to
2069 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2070 the pragma:
2071
2072 @smallexample @c ada
2073 pragma External_Name_Casing (Uppercase, Uppercase);
2074 @end smallexample
2075
2076 @noindent
2077 to enforce the upper casing of all external symbols.
2078
2079 @node Pragma Finalize_Storage_Only
2080 @unnumberedsec Pragma Finalize_Storage_Only
2081 @findex Finalize_Storage_Only
2082 @noindent
2083 Syntax:
2084
2085 @smallexample @c ada
2086 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2087 @end smallexample
2088
2089 @noindent
2090 This pragma allows the compiler not to emit a Finalize call for objects
2091 defined at the library level.  This is mostly useful for types where
2092 finalization is only used to deal with storage reclamation since in most
2093 environments it is not necessary to reclaim memory just before terminating
2094 execution, hence the name.
2095
2096 @node Pragma Float_Representation
2097 @unnumberedsec Pragma Float_Representation
2098 @cindex OpenVMS
2099 @findex Float_Representation
2100 @noindent
2101 Syntax:
2102
2103 @smallexample @c ada
2104 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2105
2106 FLOAT_REP ::= VAX_Float | IEEE_Float
2107 @end smallexample
2108
2109 @noindent
2110 In the one argument form, this pragma is a configuration pragma which
2111 allows control over the internal representation chosen for the predefined
2112 floating point types declared in the packages @code{Standard} and
2113 @code{System}. On all systems other than OpenVMS, the argument must
2114 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2115 argument may be @code{VAX_Float} to specify the use of the VAX float
2116 format for the floating-point types in Standard. This requires that
2117 the standard runtime libraries be recompiled. See the
2118 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2119 of the GNAT Users Guide for details on the use of this command.
2120
2121 The two argument form specifies the representation to be used for
2122 the specified floating-point type. On all systems other than OpenVMS,
2123 the argument must
2124 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2125 argument may be @code{VAX_Float} to specify the use of the VAX float
2126 format, as follows:
2127
2128 @itemize @bullet
2129 @item
2130 For digits values up to 6, F float format will be used.
2131 @item
2132 For digits values from 7 to 9, G float format will be used.
2133 @item
2134 For digits values from 10 to 15, F float format will be used.
2135 @item
2136 Digits values above 15 are not allowed.
2137 @end itemize
2138
2139 @node Pragma Ident
2140 @unnumberedsec Pragma Ident
2141 @findex Ident
2142 @noindent
2143 Syntax:
2144
2145 @smallexample @c ada
2146 pragma Ident (static_string_EXPRESSION);
2147 @end smallexample
2148
2149 @noindent
2150 This pragma provides a string identification in the generated object file,
2151 if the system supports the concept of this kind of identification string.
2152 This pragma is allowed only in the outermost declarative part or
2153 declarative items of a compilation unit. If more than one @code{Ident}
2154 pragma is given, only the last one processed is effective.
2155 @cindex OpenVMS
2156 On OpenVMS systems, the effect of the pragma is identical to the effect of
2157 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2158 maximum allowed length is 31 characters, so if it is important to
2159 maintain compatibility with this compiler, you should obey this length
2160 limit.
2161
2162 @node Pragma Implicit_Packing
2163 @unnumberedsec Pragma Implicit_Packing
2164 @findex Implicit_Packing
2165 @noindent
2166 Syntax:
2167
2168 @smallexample @c ada
2169 pragma Implicit_Packing;
2170 @end smallexample
2171
2172 @noindent
2173 This is a configuration pragma that requests implicit packing for packed
2174 arrays for which a size clause is given but no explicit pragma Pack or
2175 specification of Component_Size is present. Consider this example:
2176
2177 @smallexample @c ada
2178 type R is array (0 .. 7) of Boolean;
2179 for R'Size use 8;
2180 @end smallexample
2181
2182 @noindent
2183 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2184 does not change the layout of a composite object. So the Size clause in the
2185 above example is normally rejected, since the default layout of the array uses
2186 8-bit components, and thus the array requires a minimum of 64 bits.
2187
2188 If this declaration is compiled in a region of code covered by an occurrence
2189 of the configuration pragma Implicit_Packing, then the Size clause in this
2190 and similar examples will cause implicit packing and thus be accepted. For
2191 this implicit packing to occur, the type in question must be an array of small
2192 components whose size is known at compile time, and the Size clause must
2193 specify the exact size that corresponds to the length of the array multiplied
2194 by the size in bits of the component type.
2195 @cindex Array packing
2196
2197 @node Pragma Import_Exception
2198 @unnumberedsec Pragma Import_Exception
2199 @cindex OpenVMS
2200 @findex Import_Exception
2201 @noindent
2202 Syntax:
2203
2204 @smallexample @c ada
2205 pragma Import_Exception (
2206      [Internal =>] local_NAME,
2207   [, [External =>] EXTERNAL_SYMBOL,]
2208   [, [Form     =>] Ada | VMS]
2209   [, [Code     =>] static_integer_EXPRESSION]);
2210
2211 EXTERNAL_SYMBOL ::=
2212   IDENTIFIER
2213 | static_string_EXPRESSION
2214 @end smallexample
2215
2216 @noindent
2217 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2218 It allows OpenVMS conditions (for example, from OpenVMS system services or
2219 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2220 The pragma specifies that the exception associated with an exception
2221 declaration in an Ada program be defined externally (in non-Ada code).
2222 For further details on this pragma, see the
2223 DEC Ada Language Reference Manual, section 13.9a.3.1.
2224
2225 @node Pragma Import_Function
2226 @unnumberedsec Pragma Import_Function
2227 @findex Import_Function
2228 @noindent
2229 Syntax:
2230
2231 @smallexample @c ada
2232 pragma Import_Function (
2233      [Internal                 =>] local_NAME,
2234   [, [External                 =>] EXTERNAL_SYMBOL]
2235   [, [Parameter_Types          =>] PARAMETER_TYPES]
2236   [, [Result_Type              =>] SUBTYPE_MARK]
2237   [, [Mechanism                =>] MECHANISM]
2238   [, [Result_Mechanism         =>] MECHANISM_NAME]
2239   [, [First_Optional_Parameter =>] IDENTIFIER]);
2240
2241 EXTERNAL_SYMBOL ::=
2242   IDENTIFIER
2243 | static_string_EXPRESSION
2244
2245 PARAMETER_TYPES ::=
2246   null
2247 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2248
2249 TYPE_DESIGNATOR ::=
2250   subtype_NAME
2251 | subtype_Name ' Access
2252
2253 MECHANISM ::=
2254   MECHANISM_NAME
2255 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2256
2257 MECHANISM_ASSOCIATION ::=
2258   [formal_parameter_NAME =>] MECHANISM_NAME
2259
2260 MECHANISM_NAME ::=
2261   Value
2262 | Reference
2263 | Descriptor [([Class =>] CLASS_NAME)]
2264
2265 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2266 @end smallexample
2267
2268 @noindent
2269 This pragma is used in conjunction with a pragma @code{Import} to
2270 specify additional information for an imported function.  The pragma
2271 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2272 @code{Import_Function} pragma and both must appear in the same
2273 declarative part as the function specification.
2274
2275 The @var{Internal} argument must uniquely designate
2276 the function to which the
2277 pragma applies.  If more than one function name exists of this name in
2278 the declarative part you must use the @code{Parameter_Types} and
2279 @var{Result_Type} parameters to achieve the required unique
2280 designation.  Subtype marks in these parameters must exactly match the
2281 subtypes in the corresponding function specification, using positional
2282 notation to match parameters with subtype marks.
2283 The form with an @code{'Access} attribute can be used to match an
2284 anonymous access parameter.
2285
2286 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2287 parameters to specify passing mechanisms for the
2288 parameters and result.  If you specify a single mechanism name, it
2289 applies to all parameters.  Otherwise you may specify a mechanism on a
2290 parameter by parameter basis using either positional or named
2291 notation.  If the mechanism is not specified, the default mechanism
2292 is used.
2293
2294 @cindex OpenVMS
2295 @cindex Passing by descriptor
2296 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2297
2298 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2299 It specifies that the designated parameter and all following parameters
2300 are optional, meaning that they are not passed at the generated code
2301 level (this is distinct from the notion of optional parameters in Ada
2302 where the parameters are passed anyway with the designated optional
2303 parameters).  All optional parameters must be of mode @code{IN} and have
2304 default parameter values that are either known at compile time
2305 expressions, or uses of the @code{'Null_Parameter} attribute.
2306
2307 @node Pragma Import_Object
2308 @unnumberedsec Pragma Import_Object
2309 @findex Import_Object
2310 @noindent
2311 Syntax:
2312
2313 @smallexample @c ada
2314 pragma Import_Object
2315      [Internal =>] local_NAME,
2316   [, [External =>] EXTERNAL_SYMBOL],
2317   [, [Size     =>] EXTERNAL_SYMBOL]);
2318
2319 EXTERNAL_SYMBOL ::=
2320   IDENTIFIER
2321 | static_string_EXPRESSION
2322 @end smallexample
2323
2324 @noindent
2325 This pragma designates an object as imported, and apart from the
2326 extended rules for external symbols, is identical in effect to the use of
2327 the normal @code{Import} pragma applied to an object.  Unlike the
2328 subprogram case, you need not use a separate @code{Import} pragma,
2329 although you may do so (and probably should do so from a portability
2330 point of view).  @var{size} is syntax checked, but otherwise ignored by
2331 GNAT@.
2332
2333 @node Pragma Import_Procedure
2334 @unnumberedsec Pragma Import_Procedure
2335 @findex Import_Procedure
2336 @noindent
2337 Syntax:
2338
2339 @smallexample @c ada
2340 pragma Import_Procedure (
2341      [Internal                 =>] local_NAME,
2342   [, [External                 =>] EXTERNAL_SYMBOL]
2343   [, [Parameter_Types          =>] PARAMETER_TYPES]
2344   [, [Mechanism                =>] MECHANISM]
2345   [, [First_Optional_Parameter =>] IDENTIFIER]);
2346
2347 EXTERNAL_SYMBOL ::=
2348   IDENTIFIER
2349 | static_string_EXPRESSION
2350
2351 PARAMETER_TYPES ::=
2352   null
2353 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2354
2355 TYPE_DESIGNATOR ::=
2356   subtype_NAME
2357 | subtype_Name ' Access
2358
2359 MECHANISM ::=
2360   MECHANISM_NAME
2361 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2362
2363 MECHANISM_ASSOCIATION ::=
2364   [formal_parameter_NAME =>] MECHANISM_NAME
2365
2366 MECHANISM_NAME ::=
2367   Value
2368 | Reference
2369 | Descriptor [([Class =>] CLASS_NAME)]
2370
2371 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2372 @end smallexample
2373
2374 @noindent
2375 This pragma is identical to @code{Import_Function} except that it
2376 applies to a procedure rather than a function and the parameters
2377 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2378
2379 @node Pragma Import_Valued_Procedure
2380 @unnumberedsec Pragma Import_Valued_Procedure
2381 @findex Import_Valued_Procedure
2382 @noindent
2383 Syntax:
2384
2385 @smallexample @c ada
2386 pragma Import_Valued_Procedure (
2387      [Internal                 =>] local_NAME,
2388   [, [External                 =>] EXTERNAL_SYMBOL]
2389   [, [Parameter_Types          =>] PARAMETER_TYPES]
2390   [, [Mechanism                =>] MECHANISM]
2391   [, [First_Optional_Parameter =>] IDENTIFIER]);
2392
2393 EXTERNAL_SYMBOL ::=
2394   IDENTIFIER
2395 | static_string_EXPRESSION
2396
2397 PARAMETER_TYPES ::=
2398   null
2399 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2400
2401 TYPE_DESIGNATOR ::=
2402   subtype_NAME
2403 | subtype_Name ' Access
2404
2405 MECHANISM ::=
2406   MECHANISM_NAME
2407 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2408
2409 MECHANISM_ASSOCIATION ::=
2410   [formal_parameter_NAME =>] MECHANISM_NAME
2411
2412 MECHANISM_NAME ::=
2413   Value
2414 | Reference
2415 | Descriptor [([Class =>] CLASS_NAME)]
2416
2417 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2418 @end smallexample
2419
2420 @noindent
2421 This pragma is identical to @code{Import_Procedure} except that the
2422 first parameter of @var{local_NAME}, which must be present, must be of
2423 mode @code{OUT}, and externally the subprogram is treated as a function
2424 with this parameter as the result of the function.  The purpose of this
2425 capability is to allow the use of @code{OUT} and @code{IN OUT}
2426 parameters in interfacing to external functions (which are not permitted
2427 in Ada functions).  You may optionally use the @code{Mechanism}
2428 parameters to specify passing mechanisms for the parameters.
2429 If you specify a single mechanism name, it applies to all parameters.
2430 Otherwise you may specify a mechanism on a parameter by parameter
2431 basis using either positional or named notation.  If the mechanism is not
2432 specified, the default mechanism is used.
2433
2434 Note that it is important to use this pragma in conjunction with a separate
2435 pragma Import that specifies the desired convention, since otherwise the
2436 default convention is Ada, which is almost certainly not what is required.
2437
2438 @node Pragma Initialize_Scalars
2439 @unnumberedsec Pragma Initialize_Scalars
2440 @findex Initialize_Scalars
2441 @cindex debugging with Initialize_Scalars
2442 @noindent
2443 Syntax:
2444
2445 @smallexample @c ada
2446 pragma Initialize_Scalars;
2447 @end smallexample
2448
2449 @noindent
2450 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2451 two important differences.  First, there is no requirement for the pragma
2452 to be used uniformly in all units of a partition, in particular, it is fine
2453 to use this just for some or all of the application units of a partition,
2454 without needing to recompile the run-time library.
2455
2456 In the case where some units are compiled with the pragma, and some without,
2457 then a declaration of a variable where the type is defined in package
2458 Standard or is locally declared will always be subject to initialization,
2459 as will any declaration of a scalar variable.  For composite variables,
2460 whether the variable is initialized may also depend on whether the package
2461 in which the type of the variable is declared is compiled with the pragma.
2462
2463 The other important difference is that you can control the value used
2464 for initializing scalar objects.  At bind time, you can select several
2465 options for initialization. You can
2466 initialize with invalid values (similar to Normalize_Scalars, though for
2467 Initialize_Scalars it is not always possible to determine the invalid
2468 values in complex cases like signed component fields with non-standard
2469 sizes). You can also initialize with high or
2470 low values, or with a specified bit pattern.  See the users guide for binder
2471 options for specifying these cases.
2472
2473 This means that you can compile a program, and then without having to
2474 recompile the program, you can run it with different values being used
2475 for initializing otherwise uninitialized values, to test if your program
2476 behavior depends on the choice.  Of course the behavior should not change,
2477 and if it does, then most likely you have an erroneous reference to an
2478 uninitialized value.
2479
2480 It is even possible to change the value at execution time eliminating even
2481 the need to rebind with a different switch using an environment variable.
2482 See the GNAT users guide for details.
2483
2484 Note that pragma @code{Initialize_Scalars} is particularly useful in
2485 conjunction with the enhanced validity checking that is now provided
2486 in GNAT, which checks for invalid values under more conditions.
2487 Using this feature (see description of the @code{-gnatV} flag in the
2488 users guide) in conjunction with pragma @code{Initialize_Scalars}
2489 provides a powerful new tool to assist in the detection of problems
2490 caused by uninitialized variables.
2491
2492 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2493 effect on the generated code. This may cause your code to be
2494 substantially larger. It may also cause an increase in the amount
2495 of stack required, so it is probably a good idea to turn on stack
2496 checking (see description of stack checking in the GNAT users guide)
2497 when using this pragma.
2498
2499 @node Pragma Inline_Always
2500 @unnumberedsec Pragma Inline_Always
2501 @findex Inline_Always
2502 @noindent
2503 Syntax:
2504
2505 @smallexample @c ada
2506 pragma Inline_Always (NAME [, NAME]);
2507 @end smallexample
2508
2509 @noindent
2510 Similar to pragma @code{Inline} except that inlining is not subject to
2511 the use of option @code{-gnatn} and the inlining happens regardless of
2512 whether this option is used.
2513
2514 @node Pragma Inline_Generic
2515 @unnumberedsec Pragma Inline_Generic
2516 @findex Inline_Generic
2517 @noindent
2518 Syntax:
2519
2520 @smallexample @c ada
2521 pragma Inline_Generic (generic_package_NAME);
2522 @end smallexample
2523
2524 @noindent
2525 This is implemented for compatibility with DEC Ada 83 and is recognized,
2526 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2527 by default when using GNAT@.
2528
2529 @node Pragma Interface
2530 @unnumberedsec Pragma Interface
2531 @findex Interface
2532 @noindent
2533 Syntax:
2534
2535 @smallexample @c ada
2536 pragma Interface (
2537      [Convention    =>] convention_identifier,
2538      [Entity =>] local_NAME
2539   [, [External_Name =>] static_string_expression],
2540   [, [Link_Name     =>] static_string_expression]);
2541 @end smallexample
2542
2543 @noindent
2544 This pragma is identical in syntax and semantics to
2545 the standard Ada pragma @code{Import}.  It is provided for compatibility
2546 with Ada 83.  The definition is upwards compatible both with pragma
2547 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2548 with some extended implementations of this pragma in certain Ada 83
2549 implementations.
2550
2551 @node Pragma Interface_Name
2552 @unnumberedsec Pragma Interface_Name
2553 @findex Interface_Name
2554 @noindent
2555 Syntax:
2556
2557 @smallexample @c ada
2558 pragma Interface_Name (
2559      [Entity        =>] local_NAME
2560   [, [External_Name =>] static_string_EXPRESSION]
2561   [, [Link_Name     =>] static_string_EXPRESSION]);
2562 @end smallexample
2563
2564 @noindent
2565 This pragma provides an alternative way of specifying the interface name
2566 for an interfaced subprogram, and is provided for compatibility with Ada
2567 83 compilers that use the pragma for this purpose.  You must provide at
2568 least one of @var{External_Name} or @var{Link_Name}.
2569
2570 @node Pragma Interrupt_Handler
2571 @unnumberedsec Pragma Interrupt_Handler
2572 @findex Interrupt_Handler
2573 @noindent
2574 Syntax:
2575
2576 @smallexample @c ada
2577 pragma Interrupt_Handler (procedure_local_NAME);
2578 @end smallexample
2579
2580 @noindent
2581 This program unit pragma is supported for parameterless protected procedures
2582 as described in Annex C of the Ada Reference Manual. On the AAMP target
2583 the pragma can also be specified for nonprotected parameterless procedures
2584 that are declared at the library level (which includes procedures
2585 declared at the top level of a library package). In the case of AAMP,
2586 when this pragma is applied to a nonprotected procedure, the instruction
2587 @code{IERET} is generated for returns from the procedure, enabling
2588 maskable interrupts, in place of the normal return instruction.
2589
2590 @node Pragma Interrupt_State
2591 @unnumberedsec Pragma Interrupt_State
2592 @findex Interrupt_State
2593 @noindent
2594 Syntax:
2595
2596 @smallexample @c ada
2597 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2598 @end smallexample
2599
2600 @noindent
2601 Normally certain interrupts are reserved to the implementation.  Any attempt
2602 to attach an interrupt causes Program_Error to be raised, as described in
2603 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2604 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2605 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2606 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2607 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2608 Ada exceptions, or used to implement run-time functions such as the
2609 @code{abort} statement and stack overflow checking.
2610
2611 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2612 such uses of interrupts.  It subsumes the functionality of pragma
2613 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2614 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2615 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2616 and may be used to mark interrupts required by the board support package
2617 as reserved.
2618
2619 Interrupts can be in one of three states:
2620 @itemize @bullet
2621 @item System
2622
2623 The interrupt is reserved (no Ada handler can be installed), and the
2624 Ada run-time may not install a handler. As a result you are guaranteed
2625 standard system default action if this interrupt is raised.
2626
2627 @item Runtime
2628
2629 The interrupt is reserved (no Ada handler can be installed). The run time
2630 is allowed to install a handler for internal control purposes, but is
2631 not required to do so.
2632
2633 @item User
2634
2635 The interrupt is unreserved.  The user may install a handler to provide
2636 some other action.
2637 @end itemize
2638
2639 @noindent
2640 These states are the allowed values of the @code{State} parameter of the
2641 pragma.  The @code{Name} parameter is a value of the type
2642 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2643 @code{Ada.Interrupts.Names}.
2644
2645 This is a configuration pragma, and the binder will check that there
2646 are no inconsistencies between different units in a partition in how a
2647 given interrupt is specified. It may appear anywhere a pragma is legal.
2648
2649 The effect is to move the interrupt to the specified state.
2650
2651 By declaring interrupts to be SYSTEM, you guarantee the standard system
2652 action, such as a core dump.
2653
2654 By declaring interrupts to be USER, you guarantee that you can install
2655 a handler.
2656
2657 Note that certain signals on many operating systems cannot be caught and
2658 handled by applications.  In such cases, the pragma is ignored.  See the
2659 operating system documentation, or the value of the array @code{Reserved}
2660 declared in the specification of package @code{System.OS_Interface}.
2661
2662 Overriding the default state of signals used by the Ada runtime may interfere
2663 with an application's runtime behavior in the cases of the synchronous signals,
2664 and in the case of the signal used to implement the @code{abort} statement.
2665
2666 @node Pragma Keep_Names
2667 @unnumberedsec Pragma Keep_Names
2668 @findex Keep_Names
2669 @noindent
2670 Syntax:
2671
2672 @smallexample @c ada
2673 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2674 @end smallexample
2675
2676 @noindent
2677 The @var{local_NAME} argument
2678 must refer to an enumeration first subtype
2679 in the current declarative part. The effect is to retain the enumeration
2680 literal names for use by @code{Image} and @code{Value} even if a global
2681 @code{Discard_Names} pragma applies. This is useful when you want to
2682 generally suppress enumeration literal names and for example you therefore
2683 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2684 want to retain the names for specific enumeration types.
2685
2686 @node Pragma License
2687 @unnumberedsec Pragma License
2688 @findex License
2689 @cindex License checking
2690 @noindent
2691 Syntax:
2692
2693 @smallexample @c ada
2694 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2695 @end smallexample
2696
2697 @noindent
2698 This pragma is provided to allow automated checking for appropriate license
2699 conditions with respect to the standard and modified GPL@.  A pragma
2700 @code{License}, which is a configuration pragma that typically appears at
2701 the start of a source file or in a separate @file{gnat.adc} file, specifies
2702 the licensing conditions of a unit as follows:
2703
2704 @itemize @bullet
2705 @item Unrestricted
2706 This is used for a unit that can be freely used with no license restrictions.
2707 Examples of such units are public domain units, and units from the Ada
2708 Reference Manual.
2709
2710 @item GPL
2711 This is used for a unit that is licensed under the unmodified GPL, and which
2712 therefore cannot be @code{with}'ed by a restricted unit.
2713
2714 @item Modified_GPL
2715 This is used for a unit licensed under the GNAT modified GPL that includes
2716 a special exception paragraph that specifically permits the inclusion of
2717 the unit in programs without requiring the entire program to be released
2718 under the GPL@.
2719
2720 @item Restricted
2721 This is used for a unit that is restricted in that it is not permitted to
2722 depend on units that are licensed under the GPL@.  Typical examples are
2723 proprietary code that is to be released under more restrictive license
2724 conditions.  Note that restricted units are permitted to @code{with} units
2725 which are licensed under the modified GPL (this is the whole point of the
2726 modified GPL).
2727
2728 @end itemize
2729
2730 @noindent
2731 Normally a unit with no @code{License} pragma is considered to have an
2732 unknown license, and no checking is done.  However, standard GNAT headers
2733 are recognized, and license information is derived from them as follows.
2734
2735 @itemize @bullet
2736
2737 A GNAT license header starts with a line containing 78 hyphens.  The following
2738 comment text is searched for the appearance of any of the following strings.
2739
2740 If the string ``GNU General Public License'' is found, then the unit is assumed
2741 to have GPL license, unless the string ``As a special exception'' follows, in
2742 which case the license is assumed to be modified GPL@.
2743
2744 If one of the strings
2745 ``This specification is adapted from the Ada Semantic Interface'' or
2746 ``This specification is derived from the Ada Reference Manual'' is found
2747 then the unit is assumed to be unrestricted.
2748 @end itemize
2749
2750 @noindent
2751 These default actions means that a program with a restricted license pragma
2752 will automatically get warnings if a GPL unit is inappropriately
2753 @code{with}'ed.  For example, the program:
2754
2755 @smallexample @c ada
2756 with Sem_Ch3;
2757 with GNAT.Sockets;
2758 procedure Secret_Stuff is
2759   @dots{}
2760 end Secret_Stuff
2761 @end smallexample
2762
2763 @noindent
2764 if compiled with pragma @code{License} (@code{Restricted}) in a
2765 @file{gnat.adc} file will generate the warning:
2766
2767 @smallexample
2768 1.  with Sem_Ch3;
2769         |
2770    >>> license of withed unit "Sem_Ch3" is incompatible
2771
2772 2.  with GNAT.Sockets;
2773 3.  procedure Secret_Stuff is
2774 @end smallexample
2775
2776 @noindent
2777 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2778 compiler and is licensed under the
2779 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2780 run time, and is therefore licensed under the modified GPL@.
2781
2782 @node Pragma Link_With
2783 @unnumberedsec Pragma Link_With
2784 @findex Link_With
2785 @noindent
2786 Syntax:
2787
2788 @smallexample @c ada
2789 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2790 @end smallexample
2791
2792 @noindent
2793 This pragma is provided for compatibility with certain Ada 83 compilers.
2794 It has exactly the same effect as pragma @code{Linker_Options} except
2795 that spaces occurring within one of the string expressions are treated
2796 as separators. For example, in the following case:
2797
2798 @smallexample @c ada
2799 pragma Link_With ("-labc -ldef");
2800 @end smallexample
2801
2802 @noindent
2803 results in passing the strings @code{-labc} and @code{-ldef} as two
2804 separate arguments to the linker. In addition pragma Link_With allows
2805 multiple arguments, with the same effect as successive pragmas.
2806
2807 @node Pragma Linker_Alias
2808 @unnumberedsec Pragma Linker_Alias
2809 @findex Linker_Alias
2810 @noindent
2811 Syntax:
2812
2813 @smallexample @c ada
2814 pragma Linker_Alias (
2815   [Entity =>] local_NAME
2816   [Target =>] static_string_EXPRESSION);
2817 @end smallexample
2818
2819 @noindent
2820 @var{local_NAME} must refer to an object that is declared at the library
2821 level. This pragma establishes the given entity as a linker alias for the
2822 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2823 and causes @var{local_NAME} to be emitted as an alias for the symbol
2824 @var{static_string_EXPRESSION} in the object file, that is to say no space
2825 is reserved for @var{local_NAME} by the assembler and it will be resolved
2826 to the same address as @var{static_string_EXPRESSION} by the linker.
2827
2828 The actual linker name for the target must be used (e.g. the fully
2829 encoded name with qualification in Ada, or the mangled name in C++),
2830 or it must be declared using the C convention with @code{pragma Import}
2831 or @code{pragma Export}.
2832
2833 Not all target machines support this pragma. On some of them it is accepted
2834 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2835
2836 @smallexample @c ada
2837 --  Example of the use of pragma Linker_Alias
2838
2839 package p is
2840   i : Integer := 1;
2841   pragma Export (C, i);
2842
2843   new_name_for_i : Integer;
2844   pragma Linker_Alias (new_name_for_i, "i");
2845 end p;
2846 @end smallexample
2847
2848 @node Pragma Linker_Constructor
2849 @unnumberedsec Pragma Linker_Constructor
2850 @findex Linker_Constructor
2851 @noindent
2852 Syntax:
2853
2854 @smallexample @c ada
2855 pragma Linker_Constructor (procedure_LOCAL_NAME);
2856 @end smallexample
2857
2858 @noindent
2859 @var{procedure_local_NAME} must refer to a parameterless procedure that
2860 is declared at the library level. A procedure to which this pragma is
2861 applied will be treated as an initialization routine by the linker.
2862 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2863 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2864 of the executable is called (or immediately after the shared library is
2865 loaded if the procedure is linked in a shared library), in particular
2866 before the Ada run-time environment is set up.
2867
2868 Because of these specific contexts, the set of operations such a procedure
2869 can perform is very limited and the type of objects it can manipulate is
2870 essentially restricted to the elementary types. In particular, it must only
2871 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2872
2873 This pragma is used by GNAT to implement auto-initialization of shared Stand
2874 Alone Libraries, which provides a related capability without the restrictions
2875 listed above. Where possible, the use of Stand Alone Libraries is preferable
2876 to the use of this pragma.
2877
2878 @node Pragma Linker_Destructor
2879 @unnumberedsec Pragma Linker_Destructor
2880 @findex Linker_Destructor
2881 @noindent
2882 Syntax:
2883
2884 @smallexample @c ada
2885 pragma Linker_Destructor (procedure_LOCAL_NAME);
2886 @end smallexample
2887
2888 @noindent
2889 @var{procedure_local_NAME} must refer to a parameterless procedure that
2890 is declared at the library level. A procedure to which this pragma is
2891 applied will be treated as a finalization routine by the linker.
2892 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2893 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2894 of the executable has exited (or immediately before the shared library
2895 is unloaded if the procedure is linked in a shared library), in particular
2896 after the Ada run-time environment is shut down.
2897
2898 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2899 because of these specific contexts.
2900
2901 @node Pragma Linker_Section
2902 @unnumberedsec Pragma Linker_Section
2903 @findex Linker_Section
2904 @noindent
2905 Syntax:
2906
2907 @smallexample @c ada
2908 pragma Linker_Section (
2909   [Entity  =>] local_NAME
2910   [Section =>] static_string_EXPRESSION);
2911 @end smallexample
2912
2913 @noindent
2914 @var{local_NAME} must refer to an object that is declared at the library
2915 level. This pragma specifies the name of the linker section for the given
2916 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2917 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2918 section of the executable (assuming the linker doesn't rename the section).
2919
2920 The compiler normally places library-level objects in standard sections
2921 depending on their type: procedures and functions generally go in the
2922 @code{.text} section, initialized variables in the @code{.data} section
2923 and uninitialized variables in the @code{.bss} section.
2924
2925 Other, special sections may exist on given target machines to map special
2926 hardware, for example I/O ports or flash memory. This pragma is a means to
2927 defer the final layout of the executable to the linker, thus fully working
2928 at the symbolic level with the compiler.
2929
2930 Some file formats do not support arbitrary sections so not all target
2931 machines support this pragma. The use of this pragma may cause a program
2932 execution to be erroneous if it is used to place an entity into an
2933 inappropriate section (e.g. a modified variable into the @code{.text}
2934 section). See also @code{pragma Persistent_BSS}.
2935
2936 @smallexample @c ada
2937 --  Example of the use of pragma Linker_Section
2938
2939 package IO_Card is
2940   Port_A : Integer;
2941   pragma Volatile (Port_A);
2942   pragma Linker_Section (Port_A, ".bss.port_a");
2943
2944   Port_B : Integer;
2945   pragma Volatile (Port_B);
2946   pragma Linker_Section (Port_B, ".bss.port_b");
2947 end IO_Card;
2948 @end smallexample
2949
2950 @node Pragma Long_Float
2951 @unnumberedsec Pragma Long_Float
2952 @cindex OpenVMS
2953 @findex Long_Float
2954 @noindent
2955 Syntax:
2956
2957 @smallexample @c ada
2958 pragma Long_Float (FLOAT_FORMAT);
2959
2960 FLOAT_FORMAT ::= D_Float | G_Float
2961 @end smallexample
2962
2963 @noindent
2964 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2965 It allows control over the internal representation chosen for the predefined
2966 type @code{Long_Float} and for floating point type representations with
2967 @code{digits} specified in the range 7 through 15.
2968 For further details on this pragma, see the
2969 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2970 this pragma, the standard runtime libraries must be recompiled.  See the
2971 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2972 of the GNAT User's Guide for details on the use of this command.
2973
2974 @node Pragma Machine_Attribute
2975 @unnumberedsec Pragma Machine_Attribute
2976 @findex Machine_Attribute
2977 @noindent
2978 Syntax:
2979
2980 @smallexample @c ada
2981 pragma Machine_Attribute (
2982   [Attribute_Name =>] string_EXPRESSION,
2983   [Entity         =>] local_NAME);
2984 @end smallexample
2985
2986 @noindent
2987 Machine-dependent attributes can be specified for types and/or
2988 declarations.  This pragma is semantically equivalent to
2989 @code{__attribute__((@var{string_expression}))} in GNU C,
2990 where @code{@var{string_expression}} is
2991 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2992 defined for each machine.  See the GCC manual for further information.
2993 It is not possible to specify attributes defined by other languages,
2994 only attributes defined by the machine the code is intended to run on.
2995
2996 @node Pragma Main
2997 @unnumberedsec Pragma Main
2998 @cindex OpenVMS
2999 @findex Main
3000 @noindent
3001 Syntax:
3002
3003 @smallexample @c ada
3004 pragma Main
3005  (MAIN_OPTION [, MAIN_OPTION]);
3006
3007 MAIN_OPTION ::=
3008   [STACK_SIZE              =>] static_integer_EXPRESSION
3009 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3010 | [TIME_SLICING_ENABLED    =>] static_boolean_EXPRESSION
3011 @end smallexample
3012
3013 @noindent
3014 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3015 no effect in GNAT, other than being syntax checked.
3016
3017 @node Pragma Main_Storage
3018 @unnumberedsec Pragma Main_Storage
3019 @cindex OpenVMS
3020 @findex Main_Storage
3021 @noindent
3022 Syntax:
3023
3024 @smallexample @c ada
3025 pragma Main_Storage
3026   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3027
3028 MAIN_STORAGE_OPTION ::=
3029   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3030 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3031 @end smallexample
3032
3033 @noindent
3034 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3035 no effect in GNAT, other than being syntax checked.  Note that the pragma
3036 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3037
3038 @node Pragma No_Body
3039 @unnumberedsec Pragma No_Body
3040 @findex No_Body
3041 @noindent
3042 Syntax:
3043
3044 @smallexample @c ada
3045 pragma No_Body;
3046 @end smallexample
3047
3048 @noindent
3049 There are a number of cases in which a package spec does not require a body,
3050 and in fact a body is not permitted. GNAT will not permit the spec to be
3051 compiled if there is a body around. The pragma No_Body allows you to provide
3052 a body file, even in a case where no body is allowed. The body file must
3053 contain only comments and a single No_Body pragma. This is recognized by
3054 the compiler as indicating that no body is logically present.
3055
3056 This is particularly useful during maintenance when a package is modified in
3057 such a way that a body needed before is no longer needed. The provision of a
3058 dummy body with a No_Body pragma ensures that there is no inteference from
3059 earlier versions of the package body.
3060
3061 @node Pragma No_Return
3062 @unnumberedsec Pragma No_Return
3063 @findex No_Return
3064 @noindent
3065 Syntax:
3066
3067 @smallexample @c ada
3068 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
3069 @end smallexample
3070
3071 @noindent
3072 Each @var{procedure_local_NAME} argument must refer to one or more procedure
3073 declarations in the current declarative part.  A procedure to which this
3074 pragma is applied may not contain any explicit @code{return} statements.
3075 In addition, if the procedure contains any implicit returns from falling
3076 off the end of a statement sequence, then execution of that implicit
3077 return will cause Program_Error to be raised.
3078
3079 One use of this pragma is to identify procedures whose only purpose is to raise
3080 an exception. Another use of this pragma is to suppress incorrect warnings
3081 about missing returns in functions, where the last statement of a function
3082 statement sequence is a call to such a procedure.
3083
3084 Note that in Ada 2005 mode, this pragma is part of the language, and is
3085 identical in effect to the pragma as implemented in Ada 95 mode.
3086
3087 @node Pragma No_Strict_Aliasing
3088 @unnumberedsec Pragma No_Strict_Aliasing
3089 @findex No_Strict_Aliasing
3090 @noindent
3091 Syntax:
3092
3093 @smallexample @c ada
3094 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3095 @end smallexample
3096
3097 @noindent
3098 @var{type_LOCAL_NAME} must refer to an access type
3099 declaration in the current declarative part.  The effect is to inhibit
3100 strict aliasing optimization for the given type.  The form with no
3101 arguments is a configuration pragma which applies to all access types
3102 declared in units to which the pragma applies. For a detailed
3103 description of the strict aliasing optimization, and the situations
3104 in which it must be suppressed, see section
3105 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3106
3107 @node Pragma Normalize_Scalars
3108 @unnumberedsec Pragma Normalize_Scalars
3109 @findex Normalize_Scalars
3110 @noindent
3111 Syntax:
3112
3113 @smallexample @c ada
3114 pragma Normalize_Scalars;
3115 @end smallexample
3116
3117 @noindent
3118 This is a language defined pragma which is fully implemented in GNAT@.  The
3119 effect is to cause all scalar objects that are not otherwise initialized
3120 to be initialized.  The initial values are implementation dependent and
3121 are as follows:
3122
3123 @table @code
3124 @item Standard.Character
3125 @noindent
3126 Objects whose root type is Standard.Character are initialized to
3127 Character'Last unless the subtype range excludes NUL (in which case
3128 NUL is used). This choice will always generate an invalid value if
3129 one exists.
3130
3131 @item Standard.Wide_Character
3132 @noindent
3133 Objects whose root type is Standard.Wide_Character are initialized to
3134 Wide_Character'Last unless the subtype range excludes NUL (in which case
3135 NUL is used). This choice will always generate an invalid value if
3136 one exists.
3137
3138 @item Standard.Wide_Wide_Character
3139 @noindent
3140 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3141 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3142 which case NUL is used). This choice will always generate an invalid value if
3143 one exists.
3144
3145 @item Integer types
3146 @noindent
3147 Objects of an integer type are treated differently depending on whether
3148 negative values are present in the subtype. If no negative values are
3149 present, then all one bits is used as the initial value except in the
3150 special case where zero is excluded from the subtype, in which case
3151 all zero bits are used. This choice will always generate an invalid
3152 value if one exists.
3153
3154 For subtypes with negative values present, the largest negative number
3155 is used, except in the unusual case where this largest negative number
3156 is in the subtype, and the largest positive number is not, in which case
3157 the largest positive value is used. This choice will always generate
3158 an invalid value if one exists.
3159
3160 @item Floating-Point Types
3161 Objects of all floating-point types are initialized to all 1-bits. For
3162 standard IEEE format, this corresponds to a NaN (not a number) which is
3163 indeed an invalid value.
3164
3165 @item Fixed-Point Types
3166 Objects of all fixed-point types are treated as described above for integers,
3167 with the rules applying to the underlying integer value used to represent
3168 the fixed-point value.
3169
3170 @item Modular types
3171 Objects of a modular type are initialized to all one bits, except in
3172 the special case where zero is excluded from the subtype, in which
3173 case all zero bits are used. This choice will always generate an
3174 invalid value if one exists.
3175
3176 @item Enumeration types
3177 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3178 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3179 whose Pos value is zero, in which case a code of zero is used. This choice
3180 will always generate an invalid value if one exists.
3181
3182 @end table
3183
3184 @node Pragma Obsolescent
3185 @unnumberedsec Pragma Obsolescent
3186 @findex Obsolescent
3187 @noindent
3188 Syntax:
3189
3190 @smallexample @c ada
3191 pragma Obsolescent
3192   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3193 @end smallexample
3194
3195 @noindent
3196 This pragma can occur immediately following a declaration of an entity,
3197 including the case of a record component, and usually the Entity name
3198 must match the name of the entity declared by this declaration.
3199 Alternatively, the pragma can immediately follow an
3200 enumeration type declaration, where the entity argument names one of the
3201 enumeration literals.
3202
3203 This pragma is used to indicate that the named entity
3204 is considered obsolescent and should not be used. Typically this is
3205 used when an API must be modified by eventually removing or modifying
3206 existing subprograms or other entities. The pragma can be used at an
3207 intermediate stage when the entity is still present, but will be
3208 removed later.
3209
3210 The effect of this pragma is to output a warning message on
3211 a call to a program thus marked that the
3212 subprogram is obsolescent if the appropriate warning option in the
3213 compiler is activated. If the string parameter is present, then a second
3214 warning message is given containing this text.
3215 In addition, a call to such a program is considered a violation of
3216 pragma Restrictions (No_Obsolescent_Features).
3217
3218 This pragma can also be used as a program unit pragma for a package,
3219 in which case the entity name is the name of the package, and the
3220 pragma indicates that the entire package is considered
3221 obsolescent. In this case a client @code{with}'ing such a package
3222 violates the restriction, and the @code{with} statement is
3223 flagged with warnings if the warning option is set.
3224
3225 If the optional third parameter is present (which must be exactly
3226 the identifier Ada_05, no other argument is allowed), then the
3227 indication of obsolescence applies only when compiling in Ada 2005
3228 mode. This is primarily intended for dealing with the situations
3229 in the predefined library where subprograms or packages
3230 have become defined as obsolescent in Ada 2005
3231 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3232
3233 The following examples show typical uses of this pragma:
3234
3235 @smallexample @c ada
3236 package p is
3237    pragma Obsolescent
3238      (Entity => p, "use pp instead of p");
3239 end p;
3240
3241 package q is
3242    procedure q2;
3243    pragma Obsolescent
3244      (Entity => q2, "use q2new instead");
3245
3246    type R is new integer;
3247    pragma Obsolescent
3248      (Entity => R, "use RR in Ada 2005", Ada_05);
3249
3250    type M is record
3251       F1 : Integer;
3252       F2 : Integer;
3253       pragma Obsolescent (Entity => F2);
3254       F3 : Integer;
3255    end record;
3256
3257    type E is (a, bc, 'd', quack);
3258    pragma Obsolescent (Entity => bc)
3259    pragma Obsolescent (Entity => 'd')
3260
3261    function "+"
3262      (a, b : character) return character;
3263    pragma Obsolescent (Entity => "+");
3264 end;
3265 @end smallexample
3266
3267 @noindent
3268 In an earlier version of GNAT, the Entity parameter was not required,
3269 and this form is still accepted for compatibility purposes. If the
3270 Entity parameter is omitted, then the pragma applies to the declaration
3271 immediately preceding the pragma (this form cannot be used for the
3272 enumeration literal case).
3273
3274 @node Pragma Passive
3275 @unnumberedsec Pragma Passive
3276 @findex Passive
3277 @noindent
3278 Syntax:
3279
3280 @smallexample @c ada
3281 pragma Passive [(Semaphore | No)];
3282 @end smallexample
3283
3284 @noindent
3285 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3286 compatibility with DEC Ada 83 implementations, where it is used within a
3287 task definition to request that a task be made passive.  If the argument
3288 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3289 treats the pragma as an assertion that the containing task is passive
3290 and that optimization of context switch with this task is permitted and
3291 desired.  If the argument @code{No} is present, the task must not be
3292 optimized.  GNAT does not attempt to optimize any tasks in this manner
3293 (since protected objects are available in place of passive tasks).
3294
3295 @node Pragma Persistent_BSS
3296 @unnumberedsec Pragma Persistent_BSS
3297 @findex Persistent_BSS
3298 @noindent
3299 Syntax:
3300
3301 @smallexample @c ada
3302 pragma Persistent_BSS [(local_NAME)]
3303 @end smallexample
3304
3305 @noindent
3306 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3307 section. On some targets the linker and loader provide for special
3308 treatment of this section, allowing a program to be reloaded without
3309 affecting the contents of this data (hence the name persistent).
3310
3311 There are two forms of usage. If an argument is given, it must be the
3312 local name of a library level object, with no explicit initialization
3313 and whose type is potentially persistent. If no argument is given, then
3314 the pragma is a configuration pragma, and applies to all library level
3315 objects with no explicit initialization of potentially persistent types.
3316
3317 A potentially persistent type is a scalar type, or a non-tagged,
3318 non-discriminated record, all of whose components have no explicit
3319 initialization and are themselves of a potentially persistent type,
3320 or an array, all of whose constraints are static, and whose component
3321 type is potentially persistent.
3322
3323 If this pragma is used on a target where this feature is not supported,
3324 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3325
3326 @node Pragma Polling
3327 @unnumberedsec Pragma Polling
3328 @findex Polling
3329 @noindent
3330 Syntax:
3331
3332 @smallexample @c ada
3333 pragma Polling (ON | OFF);
3334 @end smallexample
3335
3336 @noindent
3337 This pragma controls the generation of polling code.  This is normally off.
3338 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3339 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3340 runtime library, and can be found in file @file{a-excpol.adb}.
3341
3342 Pragma @code{Polling} can appear as a configuration pragma (for example it
3343 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3344 can be used in the statement or declaration sequence to control polling
3345 more locally.
3346
3347 A call to the polling routine is generated at the start of every loop and
3348 at the start of every subprogram call.  This guarantees that the @code{Poll}
3349 routine is called frequently, and places an upper bound (determined by
3350 the complexity of the code) on the period between two @code{Poll} calls.
3351
3352 The primary purpose of the polling interface is to enable asynchronous
3353 aborts on targets that cannot otherwise support it (for example Windows
3354 NT), but it may be used for any other purpose requiring periodic polling.
3355 The standard version is null, and can be replaced by a user program.  This
3356 will require re-compilation of the @code{Ada.Exceptions} package that can
3357 be found in files @file{a-except.ads} and @file{a-except.adb}.
3358
3359 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3360 distribution) is used to enable the asynchronous abort capability on
3361 targets that do not normally support the capability.  The version of
3362 @code{Poll} in this file makes a call to the appropriate runtime routine
3363 to test for an abort condition.
3364
3365 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
3366 the @cite{GNAT User's Guide} for details.
3367
3368 @node Pragma Profile (Ravenscar)
3369 @unnumberedsec Pragma Profile (Ravenscar)
3370 @findex Ravenscar
3371 @noindent
3372 Syntax:
3373
3374 @smallexample @c ada
3375 pragma Profile (Ravenscar);
3376 @end smallexample
3377
3378 @noindent
3379 A configuration pragma that establishes the following set of configuration
3380 pragmas:
3381
3382 @table @code
3383 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3384 [RM D.2.2] Tasks are dispatched following a preemptive
3385 priority-ordered scheduling policy.
3386
3387 @item Locking_Policy (Ceiling_Locking)
3388 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3389 the ceiling priority of the corresponding protected object.
3390 @c
3391 @c @item Detect_Blocking
3392 @c This pragma forces the detection of potentially blocking operations within a
3393 @c protected operation, and to raise Program_Error if that happens.
3394 @end table
3395 @noindent
3396
3397 plus the following set of restrictions:
3398
3399 @table @code
3400 @item Max_Entry_Queue_Length = 1
3401 Defines the maximum number of calls that are queued on a (protected) entry.
3402 Note that this restrictions is checked at run time. Violation of this
3403 restriction results in the raising of Program_Error exception at the point of
3404 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3405 always 1 and hence no task can be queued on a protected entry.
3406
3407 @item Max_Protected_Entries = 1
3408 [RM D.7] Specifies the maximum number of entries per protected type. The
3409 bounds of every entry family of a protected unit shall be static, or shall be
3410 defined by a discriminant of a subtype whose corresponding bound is static.
3411 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3412
3413 @item Max_Task_Entries = 0
3414 [RM D.7] Specifies the maximum number of entries
3415 per task.  The bounds of every entry family
3416 of a task unit shall be static, or shall be
3417 defined by a discriminant of a subtype whose
3418 corresponding bound is static.  A value of zero
3419 indicates that no rendezvous are possible.  For
3420 the Profile (Ravenscar), the value of Max_Task_Entries is always
3421 0 (zero).
3422
3423 @item No_Abort_Statements
3424 [RM D.7] There are no abort_statements, and there are
3425 no calls to Task_Identification.Abort_Task.
3426
3427 @item No_Asynchronous_Control
3428 [RM D.7] There are no semantic dependences on the package
3429 Asynchronous_Task_Control.
3430
3431 @item No_Calendar
3432 There are no semantic dependencies on the package Ada.Calendar.
3433
3434 @item No_Dynamic_Attachment
3435 There is no call to any of the operations defined in package Ada.Interrupts
3436 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3437 Detach_Handler, and Reference).
3438
3439 @item No_Dynamic_Priorities
3440 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3441
3442 @item No_Implicit_Heap_Allocations
3443 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3444
3445 @item No_Local_Protected_Objects
3446 Protected objects and access types that designate
3447 such objects shall be declared only at library level.
3448
3449 @item No_Protected_Type_Allocators
3450 There are no allocators for protected types or
3451 types containing protected subcomponents.
3452
3453 @item No_Relative_Delay
3454 There are no delay_relative statements.
3455
3456 @item No_Requeue_Statements
3457 Requeue statements are not allowed.
3458
3459 @item No_Select_Statements
3460 There are no select_statements.
3461
3462 @item No_Task_Allocators
3463 [RM D.7] There are no allocators for task types
3464 or types containing task subcomponents.
3465
3466 @item No_Task_Attributes_Package
3467 There are no semantic dependencies on the Ada.Task_Attributes package.
3468
3469 @item No_Task_Hierarchy
3470 [RM D.7] All (non-environment) tasks depend
3471 directly on the environment task of the partition.
3472
3473 @item No_Task_Termination
3474 Tasks which terminate are erroneous.
3475
3476 @item Simple_Barriers
3477 Entry barrier condition expressions shall be either static
3478 boolean expressions or boolean objects which are declared in
3479 the protected type which contains the entry.
3480 @end table
3481
3482 @noindent
3483 This set of configuration pragmas and restrictions correspond to the
3484 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3485 published by the @cite{International Real-Time Ada Workshop}, 1997,
3486 and whose most recent description is available at
3487 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3488
3489 The original definition of the profile was revised at subsequent IRTAW
3490 meetings. It has been included in the ISO
3491 @cite{Guide for the Use of the Ada Programming Language in High
3492 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3493 the next revision of the standard. The formal definition given by
3494 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3495 AI-305) available at
3496 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3497 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3498 respectively.
3499
3500 The above set is a superset of the restrictions provided by pragma
3501 @code{Profile (Restricted)}, it includes six additional restrictions
3502 (@code{Simple_Barriers}, @code{No_Select_Statements},
3503 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3504 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3505 that pragma @code{Profile (Ravenscar)}, like the pragma
3506 @code{Profile (Restricted)},
3507 automatically causes the use of a simplified,
3508 more efficient version of the tasking run-time system.
3509
3510 @node Pragma Profile (Restricted)
3511 @unnumberedsec Pragma Profile (Restricted)
3512 @findex Restricted Run Time
3513 @noindent
3514 Syntax:
3515
3516 @smallexample @c ada
3517 pragma Profile (Restricted);
3518 @end smallexample
3519
3520 @noindent
3521 A configuration pragma that establishes the following set of restrictions:
3522
3523 @itemize @bullet
3524 @item No_Abort_Statements
3525 @item No_Entry_Queue
3526 @item No_Task_Hierarchy
3527 @item No_Task_Allocators
3528 @item No_Dynamic_Priorities
3529 @item No_Terminate_Alternatives
3530 @item No_Dynamic_Attachment
3531 @item No_Protected_Type_Allocators
3532 @item No_Local_Protected_Objects
3533 @item No_Requeue_Statements
3534 @item No_Task_Attributes_Package
3535 @item Max_Asynchronous_Select_Nesting =  0
3536 @item Max_Task_Entries =  0
3537 @item Max_Protected_Entries = 1
3538 @item Max_Select_Alternatives = 0
3539 @end itemize
3540
3541 @noindent
3542 This set of restrictions causes the automatic selection of a simplified
3543 version of the run time that provides improved performance for the
3544 limited set of tasking functionality permitted by this set of restrictions.
3545
3546 @node Pragma Psect_Object
3547 @unnumberedsec Pragma Psect_Object
3548 @findex Psect_Object
3549 @noindent
3550 Syntax:
3551
3552 @smallexample @c ada
3553 pragma Psect_Object (
3554      [Internal =>] local_NAME,
3555   [, [External =>] EXTERNAL_SYMBOL]
3556   [, [Size     =>] EXTERNAL_SYMBOL]);
3557
3558 EXTERNAL_SYMBOL ::=
3559   IDENTIFIER
3560 | static_string_EXPRESSION
3561 @end smallexample
3562
3563 @noindent
3564 This pragma is identical in effect to pragma @code{Common_Object}.
3565
3566 @node Pragma Pure_Function
3567 @unnumberedsec Pragma Pure_Function
3568 @findex Pure_Function
3569 @noindent
3570 Syntax:
3571
3572 @smallexample @c ada
3573 pragma Pure_Function ([Entity =>] function_local_NAME);
3574 @end smallexample
3575
3576 @noindent
3577 This pragma appears in the same declarative part as a function
3578 declaration (or a set of function declarations if more than one
3579 overloaded declaration exists, in which case the pragma applies
3580 to all entities).  It specifies that the function @code{Entity} is
3581 to be considered pure for the purposes of code generation.  This means
3582 that the compiler can assume that there are no side effects, and
3583 in particular that two calls with identical arguments produce the
3584 same result.  It also means that the function can be used in an
3585 address clause.
3586
3587 Note that, quite deliberately, there are no static checks to try
3588 to ensure that this promise is met, so @code{Pure_Function} can be used
3589 with functions that are conceptually pure, even if they do modify
3590 global variables.  For example, a square root function that is
3591 instrumented to count the number of times it is called is still
3592 conceptually pure, and can still be optimized, even though it
3593 modifies a global variable (the count).  Memo functions are another
3594 example (where a table of previous calls is kept and consulted to
3595 avoid re-computation).
3596
3597 @findex Pure
3598 Note: Most functions in a @code{Pure} package are automatically pure, and
3599 there is no need to use pragma @code{Pure_Function} for such functions.  One
3600 exception is any function that has at least one formal of type
3601 @code{System.Address} or a type derived from it.  Such functions are not
3602 considered pure by default, since the compiler assumes that the
3603 @code{Address} parameter may be functioning as a pointer and that the
3604 referenced data may change even if the address value does not.
3605 Similarly, imported functions are not considered to be pure by default,
3606 since there is no way of checking that they are in fact pure.  The use
3607 of pragma @code{Pure_Function} for such a function will override these default
3608 assumption, and cause the compiler to treat a designated subprogram as pure
3609 in these cases.
3610
3611 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3612 applies to the underlying renamed function.  This can be used to
3613 disambiguate cases of overloading where some but not all functions
3614 in a set of overloaded functions are to be designated as pure.
3615
3616 If pragma @code{Pure_Function} is applied to a library level function, the
3617 function is also considered pure from an optimization point of view, but the
3618 unit is not a Pure unit in the categorization sense. So for example, a function
3619 thus marked is free to @code{with} non-pure units.
3620
3621 @node Pragma Restriction_Warnings
3622 @unnumberedsec Pragma Restriction_Warnings
3623 @findex Restriction_Warnings
3624 @noindent
3625 Syntax:
3626
3627 @smallexample @c ada
3628 pragma Restriction_Warnings
3629   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3630 @end smallexample
3631
3632 @noindent
3633 This pragma allows a series of restriction identifiers to be
3634 specified (the list of allowed identifiers is the same as for
3635 pragma @code{Restrictions}). For each of these identifiers
3636 the compiler checks for violations of the restriction, but
3637 generates a warning message rather than an error message
3638 if the restriction is violated.
3639
3640 @node Pragma Source_File_Name
3641 @unnumberedsec Pragma Source_File_Name
3642 @findex Source_File_Name
3643 @noindent
3644 Syntax:
3645
3646 @smallexample @c ada
3647 pragma Source_File_Name (
3648   [Unit_Name   =>] unit_NAME,
3649   Spec_File_Name =>  STRING_LITERAL);
3650
3651 pragma Source_File_Name (
3652   [Unit_Name   =>] unit_NAME,
3653   Body_File_Name =>  STRING_LITERAL);
3654 @end smallexample
3655
3656 @noindent
3657 Use this to override the normal naming convention.  It is a configuration
3658 pragma, and so has the usual applicability of configuration pragmas
3659 (i.e.@: it applies to either an entire partition, or to all units in a
3660 compilation, or to a single unit, depending on how it is used.
3661 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3662 the second argument is required, and indicates whether this is the file
3663 name for the spec or for the body.
3664
3665 Another form of the @code{Source_File_Name} pragma allows
3666 the specification of patterns defining alternative file naming schemes
3667 to apply to all files.
3668
3669 @smallexample @c ada
3670 pragma Source_File_Name
3671   (Spec_File_Name => STRING_LITERAL
3672    [,Casing => CASING_SPEC]
3673    [,Dot_Replacement => STRING_LITERAL]);
3674
3675 pragma Source_File_Name
3676   (Body_File_Name => STRING_LITERAL
3677    [,Casing => CASING_SPEC]
3678    [,Dot_Replacement => STRING_LITERAL]);
3679
3680 pragma Source_File_Name
3681   (Subunit_File_Name => STRING_LITERAL
3682    [,Casing => CASING_SPEC]
3683    [,Dot_Replacement => STRING_LITERAL]);
3684
3685 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3686 @end smallexample
3687
3688 @noindent
3689 The first argument is a pattern that contains a single asterisk indicating
3690 the point at which the unit name is to be inserted in the pattern string
3691 to form the file name.  The second argument is optional.  If present it
3692 specifies the casing of the unit name in the resulting file name string.
3693 The default is lower case.  Finally the third argument allows for systematic
3694 replacement of any dots in the unit name by the specified string literal.
3695
3696 A pragma Source_File_Name cannot appear after a
3697 @ref{Pragma Source_File_Name_Project}.
3698
3699 For more details on the use of the @code{Source_File_Name} pragma,
3700 see the sections ``Using Other File Names'' and
3701 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3702
3703 @node Pragma Source_File_Name_Project
3704 @unnumberedsec Pragma Source_File_Name_Project
3705 @findex Source_File_Name_Project
3706 @noindent
3707
3708 This pragma has the same syntax and semantics as pragma Source_File_Name.
3709 It is only allowed as a stand alone configuration pragma.
3710 It cannot appear after a @ref{Pragma Source_File_Name}, and
3711 most importantly, once pragma Source_File_Name_Project appears,
3712 no further Source_File_Name pragmas are allowed.
3713
3714 The intention is that Source_File_Name_Project pragmas are always
3715 generated by the Project Manager in a manner consistent with the naming
3716 specified in a project file, and when naming is controlled in this manner,
3717 it is not permissible to attempt to modify this naming scheme using
3718 Source_File_Name pragmas (which would not be known to the project manager).
3719
3720 @node Pragma Source_Reference
3721 @unnumberedsec Pragma Source_Reference
3722 @findex Source_Reference
3723 @noindent
3724 Syntax:
3725
3726 @smallexample @c ada
3727 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3728 @end smallexample
3729
3730 @noindent
3731 This pragma must appear as the first line of a source file.
3732 @var{integer_literal} is the logical line number of the line following
3733 the pragma line (for use in error messages and debugging
3734 information).  @var{string_literal} is a static string constant that
3735 specifies the file name to be used in error messages and debugging
3736 information.  This is most notably used for the output of @code{gnatchop}
3737 with the @code{-r} switch, to make sure that the original unchopped
3738 source file is the one referred to.
3739
3740 The second argument must be a string literal, it cannot be a static
3741 string expression other than a string literal.  This is because its value
3742 is needed for error messages issued by all phases of the compiler.
3743
3744 @node Pragma Stream_Convert
3745 @unnumberedsec Pragma Stream_Convert
3746 @findex Stream_Convert
3747 @noindent
3748 Syntax:
3749
3750 @smallexample @c ada
3751 pragma Stream_Convert (
3752   [Entity =>] type_local_NAME,
3753   [Read   =>] function_NAME,
3754   [Write  =>] function_NAME);
3755 @end smallexample
3756
3757 @noindent
3758 This pragma provides an efficient way of providing stream functions for
3759 types defined in packages.  Not only is it simpler to use than declaring
3760 the necessary functions with attribute representation clauses, but more
3761 significantly, it allows the declaration to made in such a way that the
3762 stream packages are not loaded unless they are needed.  The use of
3763 the Stream_Convert pragma adds no overhead at all, unless the stream
3764 attributes are actually used on the designated type.
3765
3766 The first argument specifies the type for which stream functions are
3767 provided.  The second parameter provides a function used to read values
3768 of this type.  It must name a function whose argument type may be any
3769 subtype, and whose returned type must be the type given as the first
3770 argument to the pragma.
3771
3772 The meaning of the @var{Read}
3773 parameter is that if a stream attribute directly
3774 or indirectly specifies reading of the type given as the first parameter,
3775 then a value of the type given as the argument to the Read function is
3776 read from the stream, and then the Read function is used to convert this
3777 to the required target type.
3778
3779 Similarly the @var{Write} parameter specifies how to treat write attributes
3780 that directly or indirectly apply to the type given as the first parameter.
3781 It must have an input parameter of the type specified by the first parameter,
3782 and the return type must be the same as the input type of the Read function.
3783 The effect is to first call the Write function to convert to the given stream
3784 type, and then write the result type to the stream.
3785
3786 The Read and Write functions must not be overloaded subprograms.  If necessary
3787 renamings can be supplied to meet this requirement.
3788 The usage of this attribute is best illustrated by a simple example, taken
3789 from the GNAT implementation of package Ada.Strings.Unbounded:
3790
3791 @smallexample @c ada
3792 function To_Unbounded (S : String)
3793            return Unbounded_String
3794   renames To_Unbounded_String;
3795
3796 pragma Stream_Convert
3797   (Unbounded_String, To_Unbounded, To_String);
3798 @end smallexample
3799
3800 @noindent
3801 The specifications of the referenced functions, as given in the Ada
3802 Reference Manual are:
3803
3804 @smallexample @c ada
3805 function To_Unbounded_String (Source : String)
3806   return Unbounded_String;
3807
3808 function To_String (Source : Unbounded_String)
3809   return String;
3810 @end smallexample
3811
3812 @noindent
3813 The effect is that if the value of an unbounded string is written to a
3814 stream, then the representation of the item in the stream is in the same
3815 format used for @code{Standard.String}, and this same representation is
3816 expected when a value of this type is read from the stream.
3817
3818 @node Pragma Style_Checks
3819 @unnumberedsec Pragma Style_Checks
3820 @findex Style_Checks
3821 @noindent
3822 Syntax:
3823
3824 @smallexample @c ada
3825 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3826                      On | Off [, local_NAME]);
3827 @end smallexample
3828
3829 @noindent
3830 This pragma is used in conjunction with compiler switches to control the
3831 built in style checking provided by GNAT@.  The compiler switches, if set,
3832 provide an initial setting for the switches, and this pragma may be used
3833 to modify these settings, or the settings may be provided entirely by
3834 the use of the pragma.  This pragma can be used anywhere that a pragma
3835 is legal, including use as a configuration pragma (including use in
3836 the @file{gnat.adc} file).
3837
3838 The form with a string literal specifies which style options are to be
3839 activated.  These are additive, so they apply in addition to any previously
3840 set style check options.  The codes for the options are the same as those
3841 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3842 For example the following two methods can be used to enable
3843 layout checking:
3844
3845 @itemize @bullet
3846 @item
3847 @smallexample @c ada
3848 pragma Style_Checks ("l");
3849 @end smallexample
3850
3851 @item
3852 @smallexample
3853 gcc -c -gnatyl @dots{}
3854 @end smallexample
3855 @end itemize
3856
3857 @noindent
3858 The form ALL_CHECKS activates all standard checks (its use is equivalent
3859 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3860 Guide for details.
3861
3862 The forms with @code{Off} and @code{On}
3863 can be used to temporarily disable style checks
3864 as shown in the following example:
3865
3866 @smallexample @c ada
3867 @iftex
3868 @leftskip=0cm
3869 @end iftex
3870 pragma Style_Checks ("k"); -- requires keywords in lower case
3871 pragma Style_Checks (Off); -- turn off style checks
3872 NULL;                      -- this will not generate an error message
3873 pragma Style_Checks (On);  -- turn style checks back on
3874 NULL;                      -- this will generate an error message
3875 @end smallexample
3876
3877 @noindent
3878 Finally the two argument form is allowed only if the first argument is
3879 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3880 for the specified entity, as shown in the following example:
3881
3882 @smallexample @c ada
3883 @iftex
3884 @leftskip=0cm
3885 @end iftex
3886 pragma Style_Checks ("r"); -- require consistency of identifier casing
3887 Arg : Integer;
3888 Rf1 : Integer := ARG;      -- incorrect, wrong case
3889 pragma Style_Checks (Off, Arg);
3890 Rf2 : Integer := ARG;      -- OK, no error
3891 @end smallexample
3892
3893 @node Pragma Subtitle
3894 @unnumberedsec Pragma Subtitle
3895 @findex Subtitle
3896 @noindent
3897 Syntax:
3898
3899 @smallexample @c ada
3900 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3901 @end smallexample
3902
3903 @noindent
3904 This pragma is recognized for compatibility with other Ada compilers
3905 but is ignored by GNAT@.
3906
3907 @node Pragma Suppress
3908 @unnumberedsec Pragma Suppress
3909 @findex Suppress
3910 @noindent
3911 Syntax:
3912
3913 @smallexample @c ada
3914 pragma Suppress (Identifier [, [On =>] Name]);
3915 @end smallexample
3916
3917 @noindent
3918 This is a standard pragma, and supports all the check names required in
3919 the RM. It is included here because GNAT recognizes one additional check
3920 name: @code{Alignment_Check} which can be used to suppress alignment checks
3921 on addresses used in address clauses. Such checks can also be suppressed
3922 by suppressing range checks, but the specific use of @code{Alignment_Check}
3923 allows suppression of alignment checks without suppressing other range checks.
3924
3925 @node Pragma Suppress_All
3926 @unnumberedsec Pragma Suppress_All
3927 @findex Suppress_All
3928 @noindent
3929 Syntax:
3930
3931 @smallexample @c ada
3932 pragma Suppress_All;
3933 @end smallexample
3934
3935 @noindent
3936 This pragma can only appear immediately following a compilation
3937 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3938 which it follows.  This pragma is implemented for compatibility with DEC
3939 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3940 configuration pragma is the preferred usage in GNAT@.
3941
3942 @node Pragma Suppress_Exception_Locations
3943 @unnumberedsec Pragma Suppress_Exception_Locations
3944 @findex Suppress_Exception_Locations
3945 @noindent
3946 Syntax:
3947
3948 @smallexample @c ada
3949 pragma Suppress_Exception_Locations;
3950 @end smallexample
3951
3952 @noindent
3953 In normal mode, a raise statement for an exception by default generates
3954 an exception message giving the file name and line number for the location
3955 of the raise. This is useful for debugging and logging purposes, but this
3956 entails extra space for the strings for the messages. The configuration
3957 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3958 generation of these strings, with the result that space is saved, but the
3959 exception message for such raises is null. This configuration pragma may
3960 appear in a global configuration pragma file, or in a specific unit as
3961 usual. It is not required that this pragma be used consistently within
3962 a partition, so it is fine to have some units within a partition compiled
3963 with this pragma and others compiled in normal mode without it.
3964
3965 @node Pragma Suppress_Initialization
3966 @unnumberedsec Pragma Suppress_Initialization
3967 @findex Suppress_Initialization
3968 @cindex Suppressing initialization
3969 @cindex Initialization, suppression of
3970 @noindent
3971 Syntax:
3972
3973 @smallexample @c ada
3974 pragma Suppress_Initialization ([Entity =>] type_Name);
3975 @end smallexample
3976
3977 @noindent
3978 This pragma suppresses any implicit or explicit initialization
3979 associated with the given type name for all variables of this type.
3980
3981 @node Pragma Task_Info
3982 @unnumberedsec Pragma Task_Info
3983 @findex Task_Info
3984 @noindent
3985 Syntax
3986
3987 @smallexample @c ada
3988 pragma Task_Info (EXPRESSION);
3989 @end smallexample
3990
3991 @noindent
3992 This pragma appears within a task definition (like pragma
3993 @code{Priority}) and applies to the task in which it appears.  The
3994 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3995 The @code{Task_Info} pragma provides system dependent control over
3996 aspects of tasking implementation, for example, the ability to map
3997 tasks to specific processors.  For details on the facilities available
3998 for the version of GNAT that you are using, see the documentation
3999 in the specification of package System.Task_Info in the runtime
4000 library.
4001
4002 @node Pragma Task_Name
4003 @unnumberedsec Pragma Task_Name
4004 @findex Task_Name
4005 @noindent
4006 Syntax
4007
4008 @smallexample @c ada
4009 pragma Task_Name (string_EXPRESSION);
4010 @end smallexample
4011
4012 @noindent
4013 This pragma appears within a task definition (like pragma
4014 @code{Priority}) and applies to the task in which it appears.  The
4015 argument must be of type String, and provides a name to be used for
4016 the task instance when the task is created.  Note that this expression
4017 is not required to be static, and in particular, it can contain
4018 references to task discriminants.  This facility can be used to
4019 provide different names for different tasks as they are created,
4020 as illustrated in the example below.
4021
4022 The task name is recorded internally in the run-time structures
4023 and is accessible to tools like the debugger.  In addition the
4024 routine @code{Ada.Task_Identification.Image} will return this
4025 string, with a unique task address appended.
4026
4027 @smallexample @c ada
4028 --  Example of the use of pragma Task_Name
4029
4030 with Ada.Task_Identification;
4031 use Ada.Task_Identification;
4032 with Text_IO; use Text_IO;
4033 procedure t3 is
4034
4035    type Astring is access String;
4036
4037    task type Task_Typ (Name : access String) is
4038       pragma Task_Name (Name.all);
4039    end Task_Typ;
4040
4041    task body Task_Typ is
4042       Nam : constant String := Image (Current_Task);
4043    begin
4044       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4045    end Task_Typ;
4046
4047    type Ptr_Task is access Task_Typ;
4048    Task_Var : Ptr_Task;
4049
4050 begin
4051    Task_Var :=
4052      new Task_Typ (new String'("This is task 1"));
4053    Task_Var :=
4054      new Task_Typ (new String'("This is task 2"));
4055 end;
4056 @end smallexample
4057
4058 @node Pragma Task_Storage
4059 @unnumberedsec Pragma Task_Storage
4060 @findex Task_Storage
4061 Syntax:
4062
4063 @smallexample @c ada
4064 pragma Task_Storage (
4065   [Task_Type =>] local_NAME,
4066   [Top_Guard =>] static_integer_EXPRESSION);
4067 @end smallexample
4068
4069 @noindent
4070 This pragma specifies the length of the guard area for tasks.  The guard
4071 area is an additional storage area allocated to a task.  A value of zero
4072 means that either no guard area is created or a minimal guard area is
4073 created, depending on the target.  This pragma can appear anywhere a
4074 @code{Storage_Size} attribute definition clause is allowed for a task
4075 type.
4076
4077 @node Pragma Time_Slice
4078 @unnumberedsec Pragma Time_Slice
4079 @findex Time_Slice
4080 @noindent
4081 Syntax:
4082
4083 @smallexample @c ada
4084 pragma Time_Slice (static_duration_EXPRESSION);
4085 @end smallexample
4086
4087 @noindent
4088 For implementations of GNAT on operating systems where it is possible
4089 to supply a time slice value, this pragma may be used for this purpose.
4090 It is ignored if it is used in a system that does not allow this control,
4091 or if it appears in other than the main program unit.
4092 @cindex OpenVMS
4093 Note that the effect of this pragma is identical to the effect of the
4094 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4095
4096 @node Pragma Title
4097 @unnumberedsec Pragma Title
4098 @findex Title
4099 @noindent
4100 Syntax:
4101
4102 @smallexample @c ada
4103 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4104
4105 TITLING_OPTION ::=
4106   [Title    =>] STRING_LITERAL,
4107 | [Subtitle =>] STRING_LITERAL
4108 @end smallexample
4109
4110 @noindent
4111 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4112 pragma used in DEC Ada 83 implementations to provide a title and/or
4113 subtitle for the program listing.  The program listing generated by GNAT
4114 does not have titles or subtitles.
4115
4116 Unlike other pragmas, the full flexibility of named notation is allowed
4117 for this pragma, i.e.@: the parameters may be given in any order if named
4118 notation is used, and named and positional notation can be mixed
4119 following the normal rules for procedure calls in Ada.
4120
4121 @node Pragma Unchecked_Union
4122 @unnumberedsec Pragma Unchecked_Union
4123 @cindex Unions in C
4124 @findex Unchecked_Union
4125 @noindent
4126 Syntax:
4127
4128 @smallexample @c ada
4129 pragma Unchecked_Union (first_subtype_local_NAME);
4130 @end smallexample
4131
4132 @noindent
4133 This pragma is used to specify a representation of a record type that is
4134 equivalent to a C union. It was introduced as a GNAT implementation defined
4135 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4136 pragma, making it language defined, and GNAT fully implements this extended
4137 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4138 details, consult the Ada 2005 Reference Manual, section B.3.3.
4139
4140 @node Pragma Unimplemented_Unit
4141 @unnumberedsec Pragma Unimplemented_Unit
4142 @findex Unimplemented_Unit
4143 @noindent
4144 Syntax:
4145
4146 @smallexample @c ada
4147 pragma Unimplemented_Unit;
4148 @end smallexample
4149
4150 @noindent
4151 If this pragma occurs in a unit that is processed by the compiler, GNAT
4152 aborts with the message @samp{@var{xxx} not implemented}, where
4153 @var{xxx} is the name of the current compilation unit.  This pragma is
4154 intended to allow the compiler to handle unimplemented library units in
4155 a clean manner.
4156
4157 The abort only happens if code is being generated.  Thus you can use
4158 specs of unimplemented packages in syntax or semantic checking mode.
4159
4160 @node Pragma Universal_Aliasing
4161 @unnumberedsec Pragma Universal_Aliasing
4162 @findex Universal_Aliasing
4163 @noindent
4164 Syntax:
4165
4166 @smallexample @c ada
4167 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4168 @end smallexample
4169
4170 @noindent
4171 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4172 declarative part.  The effect is to inhibit strict type-based aliasing
4173 optimization for the given type.  In other words, the effect is as though
4174 access types designating this type were subject to pragma No_Strict_Aliasing.
4175 For a detailed description of the strict aliasing optimization, and the
4176 situations in which it must be suppressed, see section
4177 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4178
4179 @node Pragma Universal_Data
4180 @unnumberedsec Pragma Universal_Data
4181 @findex Universal_Data
4182 @noindent
4183 Syntax:
4184
4185 @smallexample @c ada
4186 pragma Universal_Data [(library_unit_Name)];
4187 @end smallexample
4188
4189 @noindent
4190 This pragma is supported only for the AAMP target and is ignored for
4191 other targets. The pragma specifies that all library-level objects
4192 (Counter 0 data) associated with the library unit are to be accessed
4193 and updated using universal addressing (24-bit addresses for AAMP5)
4194 rather than the default of 16-bit Data Environment (DENV) addressing.
4195 Use of this pragma will generally result in less efficient code for
4196 references to global data associated with the library unit, but
4197 allows such data to be located anywhere in memory. This pragma is
4198 a library unit pragma, but can also be used as a configuration pragma
4199 (including use in the @file{gnat.adc} file). The functionality
4200 of this pragma is also available by applying the -univ switch on the
4201 compilations of units where universal addressing of the data is desired.
4202
4203 @node Pragma Unreferenced
4204 @unnumberedsec Pragma Unreferenced
4205 @findex Unreferenced
4206 @cindex Warnings, unreferenced
4207 @noindent
4208 Syntax:
4209
4210 @smallexample @c ada
4211 pragma Unreferenced (local_NAME @{, local_NAME@});
4212 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4213 @end smallexample
4214
4215 @noindent
4216 This pragma signals that the entities whose names are listed are
4217 deliberately not referenced in the current source unit. This
4218 suppresses warnings about the
4219 entities being unreferenced, and in addition a warning will be
4220 generated if one of these entities is in fact referenced in the
4221 same unit as the pragma (or in the corresponding body, or one
4222 of its subunits).
4223
4224 This is particularly useful for clearly signaling that a particular
4225 parameter is not referenced in some particular subprogram implementation
4226 and that this is deliberate. It can also be useful in the case of
4227 objects declared only for their initialization or finalization side
4228 effects.
4229
4230 If @code{local_NAME} identifies more than one matching homonym in the
4231 current scope, then the entity most recently declared is the one to which
4232 the pragma applies. Note that in the case of accept formals, the pragma
4233 Unreferenced may appear immediately after the keyword @code{do} which
4234 allows the indication of whether or not accept formals are referenced
4235 or not to be given individually for each accept statement.
4236
4237 The left hand side of an assignment does not count as a reference for the
4238 purpose of this pragma. Thus it is fine to assign to an entity for which
4239 pragma Unreferenced is given.
4240
4241 Note that if a warning is desired for all calls to a given subprogram,
4242 regardless of whether they occur in the same unit as the subprogram
4243 declaration, then this pragma should not be used (calls from another
4244 unit would not be flagged); pragma Obsolescent can be used instead
4245 for this purpose, see @xref{Pragma Obsolescent}.
4246
4247 The second form of pragma @code{Unreferenced} is used within a context
4248 clause. In this case the arguments must be unit names of units previously
4249 mentioned in @code{with} clauses (similar to the usage of pragma
4250 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4251 units.
4252
4253 @node Pragma Unreferenced_Objects
4254 @unnumberedsec Pragma Unreferenced_Objects
4255 @findex Unreferenced_Objects
4256 @cindex Warnings, unreferenced
4257 @noindent
4258 Syntax:
4259
4260 @smallexample @c ada
4261 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4262 @end smallexample
4263
4264 @noindent
4265 This pragma signals that for the types or subtypes whose names are
4266 listed, objects which are declared with one of these types or subtypes may
4267 not be referenced, and if no references appear, no warnings are given.
4268
4269 This is particularly useful for objects which are declared solely for their
4270 initialization and finalization effect. Such variables are sometimes referred
4271 to as RAII variables (Resource Acquisition Is Initialization). Using this
4272 pragma on the relevant type (most typically a limited controlled type), the
4273 compiler will automatically suppress unwanted warnings about these variables
4274 not being referenced.
4275
4276 @node Pragma Unreserve_All_Interrupts
4277 @unnumberedsec Pragma Unreserve_All_Interrupts
4278 @findex Unreserve_All_Interrupts
4279 @noindent
4280 Syntax:
4281
4282 @smallexample @c ada
4283 pragma Unreserve_All_Interrupts;
4284 @end smallexample
4285
4286 @noindent
4287 Normally certain interrupts are reserved to the implementation.  Any attempt
4288 to attach an interrupt causes Program_Error to be raised, as described in
4289 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4290 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4291 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4292 interrupt execution.
4293
4294 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4295 a program, then all such interrupts are unreserved.  This allows the
4296 program to handle these interrupts, but disables their standard
4297 functions.  For example, if this pragma is used, then pressing
4298 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4299 a program can then handle the @code{SIGINT} interrupt as it chooses.
4300
4301 For a full list of the interrupts handled in a specific implementation,
4302 see the source code for the specification of @code{Ada.Interrupts.Names} in
4303 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4304 list of interrupts recognized for a given target.  The documentation in
4305 this file also specifies what interrupts are affected by the use of
4306 the @code{Unreserve_All_Interrupts} pragma.
4307
4308 For a more general facility for controlling what interrupts can be
4309 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4310 of the @code{Unreserve_All_Interrupts} pragma.
4311
4312 @node Pragma Unsuppress
4313 @unnumberedsec Pragma Unsuppress
4314 @findex Unsuppress
4315 @noindent
4316 Syntax:
4317
4318 @smallexample @c ada
4319 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4320 @end smallexample
4321
4322 @noindent
4323 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4324 there is no corresponding pragma @code{Suppress} in effect, it has no
4325 effect.  The range of the effect is the same as for pragma
4326 @code{Suppress}.  The meaning of the arguments is identical to that used
4327 in pragma @code{Suppress}.
4328
4329 One important application is to ensure that checks are on in cases where
4330 code depends on the checks for its correct functioning, so that the code
4331 will compile correctly even if the compiler switches are set to suppress
4332 checks.
4333
4334 @node Pragma Use_VADS_Size
4335 @unnumberedsec Pragma Use_VADS_Size
4336 @cindex @code{Size}, VADS compatibility
4337 @findex Use_VADS_Size
4338 @noindent
4339 Syntax:
4340
4341 @smallexample @c ada
4342 pragma Use_VADS_Size;
4343 @end smallexample
4344
4345 @noindent
4346 This is a configuration pragma.  In a unit to which it applies, any use
4347 of the 'Size attribute is automatically interpreted as a use of the
4348 'VADS_Size attribute.  Note that this may result in incorrect semantic
4349 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4350 the handling of existing code which depends on the interpretation of Size
4351 as implemented in the VADS compiler.  See description of the VADS_Size
4352 attribute for further details.
4353
4354 @node Pragma Validity_Checks
4355 @unnumberedsec Pragma Validity_Checks
4356 @findex Validity_Checks
4357 @noindent
4358 Syntax:
4359
4360 @smallexample @c ada
4361 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4362 @end smallexample
4363
4364 @noindent
4365 This pragma is used in conjunction with compiler switches to control the
4366 built-in validity checking provided by GNAT@.  The compiler switches, if set
4367 provide an initial setting for the switches, and this pragma may be used
4368 to modify these settings, or the settings may be provided entirely by
4369 the use of the pragma.  This pragma can be used anywhere that a pragma
4370 is legal, including use as a configuration pragma (including use in
4371 the @file{gnat.adc} file).
4372
4373 The form with a string literal specifies which validity options are to be
4374 activated.  The validity checks are first set to include only the default
4375 reference manual settings, and then a string of letters in the string
4376 specifies the exact set of options required.  The form of this string
4377 is exactly as described for the @code{-gnatVx} compiler switch (see the
4378 GNAT users guide for details).  For example the following two methods
4379 can be used to enable validity checking for mode @code{in} and
4380 @code{in out} subprogram parameters:
4381
4382 @itemize @bullet
4383 @item
4384 @smallexample @c ada
4385 pragma Validity_Checks ("im");
4386 @end smallexample
4387
4388 @item
4389 @smallexample
4390 gcc -c -gnatVim @dots{}
4391 @end smallexample
4392 @end itemize
4393
4394 @noindent
4395 The form ALL_CHECKS activates all standard checks (its use is equivalent
4396 to the use of the @code{gnatva} switch.
4397
4398 The forms with @code{Off} and @code{On}
4399 can be used to temporarily disable validity checks
4400 as shown in the following example:
4401
4402 @smallexample @c ada
4403 @iftex
4404 @leftskip=0cm
4405 @end iftex
4406 pragma Validity_Checks ("c"); -- validity checks for copies
4407 pragma Validity_Checks (Off); -- turn off validity checks
4408 A := B;                       -- B will not be validity checked
4409 pragma Validity_Checks (On);  -- turn validity checks back on
4410 A := C;                       -- C will be validity checked
4411 @end smallexample
4412
4413 @node Pragma Volatile
4414 @unnumberedsec Pragma Volatile
4415 @findex Volatile
4416 @noindent
4417 Syntax:
4418
4419 @smallexample @c ada
4420 pragma Volatile (local_NAME);
4421 @end smallexample
4422
4423 @noindent
4424 This pragma is defined by the Ada Reference Manual, and the GNAT
4425 implementation is fully conformant with this definition.  The reason it
4426 is mentioned in this section is that a pragma of the same name was supplied
4427 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4428 implementation of pragma Volatile is upwards compatible with the
4429 implementation in DEC Ada 83.
4430
4431 @node Pragma Warnings
4432 @unnumberedsec Pragma Warnings
4433 @findex Warnings
4434 @noindent
4435 Syntax:
4436
4437 @smallexample @c ada
4438 pragma Warnings (On | Off);
4439 pragma Warnings (On | Off, local_NAME);
4440 pragma Warnings (static_string_EXPRESSION);
4441 pragma Warnings (On | Off, static_string_EXPRESSION);
4442 @end smallexample
4443
4444 @noindent
4445 Normally warnings are enabled, with the output being controlled by
4446 the command line switch.  Warnings (@code{Off}) turns off generation of
4447 warnings until a Warnings (@code{On}) is encountered or the end of the
4448 current unit.  If generation of warnings is turned off using this
4449 pragma, then no warning messages are output, regardless of the
4450 setting of the command line switches.
4451
4452 The form with a single argument may be used as a configuration pragma.
4453
4454 If the @var{local_NAME} parameter is present, warnings are suppressed for
4455 the specified entity.  This suppression is effective from the point where
4456 it occurs till the end of the extended scope of the variable (similar to
4457 the scope of @code{Suppress}).
4458
4459 The form with a single static_string_EXPRESSION argument provides more precise
4460 control over which warnings are active. The string is a list of letters
4461 specifying which warnings are to be activated and which deactivated. The
4462 code for these letters is the same as the string used in the command
4463 line switch controlling warnings. The following is a brief summary. For
4464 full details see the GNAT Users Guide:
4465
4466 @smallexample
4467 a   turn on all optional warnings (except d,h,l)
4468 A   turn off all optional warnings
4469 b   turn on warnings for bad fixed value (not multiple of small)
4470 B   turn off warnings for bad fixed value (not multiple of small)
4471 c   turn on warnings for constant conditional
4472 C   turn off warnings for constant conditional
4473 d   turn on warnings for implicit dereference
4474 D   turn off warnings for implicit dereference
4475 e   treat all warnings as errors
4476 f   turn on warnings for unreferenced formal
4477 F   turn off warnings for unreferenced formal
4478 g   turn on warnings for unrecognized pragma
4479 G   turn off warnings for unrecognized pragma
4480 h   turn on warnings for hiding variable
4481 H   turn off warnings for hiding variable
4482 i   turn on warnings for implementation unit
4483 I   turn off warnings for implementation unit
4484 j   turn on warnings for obsolescent (annex J) feature
4485 J   turn off warnings for obsolescent (annex J) feature
4486 k   turn on warnings on constant variable
4487 K   turn off warnings on constant variable
4488 l   turn on warnings for missing elaboration pragma
4489 L   turn off warnings for missing elaboration pragma
4490 m   turn on warnings for variable assigned but not read
4491 M   turn off warnings for variable assigned but not read
4492 n   normal warning mode (cancels -gnatws/-gnatwe)
4493 o   turn on warnings for address clause overlay
4494 O   turn off warnings for address clause overlay
4495 p   turn on warnings for ineffective pragma Inline
4496 P   turn off warnings for ineffective pragma Inline
4497 q   turn on warnings for questionable missing parentheses
4498 Q   turn off warnings for questionable missing parentheses
4499 r   turn on warnings for redundant construct
4500 R   turn off warnings for redundant construct
4501 s   suppress all warnings
4502 t   turn on warnings for tracking deleted code
4503 T   turn off warnings for tracking deleted code
4504 u   turn on warnings for unused entity
4505 U   turn off warnings for unused entity
4506 v   turn on warnings for unassigned variable
4507 V   turn off warnings for unassigned variable
4508 w   turn on warnings for wrong low bound assumption
4509 W   turn off warnings for wrong low bound assumption
4510 x   turn on warnings for export/import
4511 X   turn off warnings for export/import
4512 y   turn on warnings for Ada 2005 incompatibility
4513 Y   turn off warnings for Ada 2005 incompatibility
4514 z   turn on size/align warnings for unchecked conversion
4515 Z   turn off size/align warnings for unchecked conversion
4516 @end smallexample
4517
4518 @noindent
4519 The specified warnings will be in effect until the end of the program
4520 or another pragma Warnings is encountered. The effect of the pragma is
4521 cumulative. Initially the set of warnings is the standard default set
4522 as possibly modified by compiler switches. Then each pragma Warning
4523 modifies this set of warnings as specified. This form of the pragma may
4524 also be used as a configuration pragma.
4525
4526 The fourth form, with an On|Off parameter and a string, is used to
4527 control individual messages, based on their text. The string argument
4528 is a pattern that is used to match against the text of individual
4529 warning messages (not including the initial "warnings: " tag).
4530
4531 The pattern may start with an asterisk, which matches otherwise unmatched
4532 characters at the start of the message, and it may also end with an asterisk
4533 which matches otherwise unmatched characters at the end of the message. For
4534 example, the string "*alignment*" could be used to match any warnings about
4535 alignment problems. Within the string, the sequence "*" can be used to match
4536 any sequence of characters enclosed in quotation marks. No other regular
4537 expression notations are permitted. All characters other than asterisk in
4538 these three specific cases are treated as literal characters in the match.
4539
4540 There are two ways to use this pragma. The OFF form can be used as a
4541 configuration pragma. The effect is to suppress all warnings (if any)
4542 that match the pattern string throughout the compilation.
4543
4544 The second usage is to suppress a warning locally, and in this case, two
4545 pragmas must appear in sequence:
4546
4547 @smallexample @c ada
4548 pragma Warnings (Off, Pattern);
4549 .. code where given warning is to be suppressed
4550 pragma Warnings (On, Pattern);
4551 @end smallexample
4552
4553 @noindent
4554 In this usage, the pattern string must match in the Off and On pragmas,
4555 and at least one matching warning must be suppressed.
4556
4557 @node Pragma Weak_External
4558 @unnumberedsec Pragma Weak_External
4559 @findex Weak_External
4560 @noindent
4561 Syntax:
4562
4563 @smallexample @c ada
4564 pragma Weak_External ([Entity =>] local_NAME);
4565 @end smallexample
4566
4567 @noindent
4568 @var{local_NAME} must refer to an object that is declared at the library
4569 level. This pragma specifies that the given entity should be marked as a
4570 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4571 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4572 of a regular symbol, that is to say a symbol that does not have to be
4573 resolved by the linker if used in conjunction with a pragma Import.
4574
4575 When a weak symbol is not resolved by the linker, its address is set to
4576 zero. This is useful in writing interfaces to external modules that may
4577 or may not be linked in the final executable, for example depending on
4578 configuration settings.
4579
4580 If a program references at run time an entity to which this pragma has been
4581 applied, and the corresponding symbol was not resolved at link time, then
4582 the execution of the program is erroneous. It is not erroneous to take the
4583 Address of such an entity, for example to guard potential references,
4584 as shown in the example below.
4585
4586 Some file formats do not support weak symbols so not all target machines
4587 support this pragma.
4588
4589 @smallexample @c ada
4590 --  Example of the use of pragma Weak_External
4591
4592 package External_Module is
4593   key : Integer;
4594   pragma Import (C, key);
4595   pragma Weak_External (key);
4596   function Present return boolean;
4597 end External_Module;
4598
4599 with System; use System;
4600 package body External_Module is
4601   function Present return boolean is
4602   begin
4603     return key'Address /= System.Null_Address;
4604   end Present;
4605 end External_Module;
4606 @end smallexample
4607
4608 @node Pragma Wide_Character_Encoding
4609 @unnumberedsec Pragma Wide_Character_Encoding
4610 @findex Wide_Character_Encoding
4611 @noindent
4612 Syntax:
4613
4614 @smallexample @c ada
4615 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4616 @end smallexample
4617
4618 @noindent
4619 This pragma specifies the wide character encoding to be used in program
4620 source text appearing subsequently. It is a configuration pragma, but may
4621 also be used at any point that a pragma is allowed, and it is permissible
4622 to have more than one such pragma in a file, allowing multiple encodings
4623 to appear within the same file.
4624
4625 The argument can be an identifier or a character literal. In the identifier
4626 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4627 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4628 case it is correspondingly one of the characters h,u,s,e,8,b.
4629
4630 Note that when the pragma is used within a file, it affects only the
4631 encoding within that file, and does not affect withed units, specs,
4632 or subunits.
4633
4634 @node Implementation Defined Attributes
4635 @chapter Implementation Defined Attributes
4636 Ada defines (throughout the Ada reference manual,
4637 summarized in Annex K),
4638 a set of attributes that provide useful additional functionality in all
4639 areas of the language.  These language defined attributes are implemented
4640 in GNAT and work as described in the Ada Reference Manual.
4641
4642 In addition, Ada allows implementations to define additional
4643 attributes whose meaning is defined by the implementation.  GNAT provides
4644 a number of these implementation-dependent attributes which can be used
4645 to extend and enhance the functionality of the compiler.  This section of
4646 the GNAT reference manual describes these additional attributes.
4647
4648 Note that any program using these attributes may not be portable to
4649 other compilers (although GNAT implements this set of attributes on all
4650 platforms).  Therefore if portability to other compilers is an important
4651 consideration, you should minimize the use of these attributes.
4652
4653 @menu
4654 * Abort_Signal::
4655 * Address_Size::
4656 * Asm_Input::
4657 * Asm_Output::
4658 * AST_Entry::
4659 * Bit::
4660 * Bit_Position::
4661 * Code_Address::
4662 * Default_Bit_Order::
4663 * Elaborated::
4664 * Elab_Body::
4665 * Elab_Spec::
4666 * Emax::
4667 * Enabled::
4668 * Enum_Rep::
4669 * Epsilon::
4670 * Fixed_Value::
4671 * Has_Access_Values::
4672 * Has_Discriminants::
4673 * Img::
4674 * Integer_Value::
4675 * Large::
4676 * Machine_Size::
4677 * Mantissa::
4678 * Max_Interrupt_Priority::
4679 * Max_Priority::
4680 * Maximum_Alignment::
4681 * Mechanism_Code::
4682 * Null_Parameter::
4683 * Object_Size::
4684 * Passed_By_Reference::
4685 * Range_Length::
4686 * Safe_Emax::
4687 * Safe_Large::
4688 * Small::
4689 * Storage_Unit::
4690 * Stub_Type::
4691 * Target_Name::
4692 * Tick::
4693 * To_Address::
4694 * Type_Class::
4695 * UET_Address::
4696 * Unconstrained_Array::
4697 * Universal_Literal_String::
4698 * Unrestricted_Access::
4699 * VADS_Size::
4700 * Value_Size::
4701 * Wchar_T_Size::
4702 * Word_Size::
4703 @end menu
4704
4705 @node Abort_Signal
4706 @unnumberedsec Abort_Signal
4707 @findex Abort_Signal
4708 @noindent
4709 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4710 prefix) provides the entity for the special exception used to signal
4711 task abort or asynchronous transfer of control.  Normally this attribute
4712 should only be used in the tasking runtime (it is highly peculiar, and
4713 completely outside the normal semantics of Ada, for a user program to
4714 intercept the abort exception).
4715
4716 @node Address_Size
4717 @unnumberedsec Address_Size
4718 @cindex Size of @code{Address}
4719 @findex Address_Size
4720 @noindent
4721 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4722 prefix) is a static constant giving the number of bits in an
4723 @code{Address}. It is the same value as System.Address'Size,
4724 but has the advantage of being static, while a direct
4725 reference to System.Address'Size is non-static because Address
4726 is a private type.
4727
4728 @node Asm_Input
4729 @unnumberedsec Asm_Input
4730 @findex Asm_Input
4731 @noindent
4732 The @code{Asm_Input} attribute denotes a function that takes two
4733 parameters.  The first is a string, the second is an expression of the
4734 type designated by the prefix.  The first (string) argument is required
4735 to be a static expression, and is the constraint for the parameter,
4736 (e.g.@: what kind of register is required).  The second argument is the
4737 value to be used as the input argument.  The possible values for the
4738 constant are the same as those used in the RTL, and are dependent on
4739 the configuration file used to built the GCC back end.
4740 @ref{Machine Code Insertions}
4741
4742 @node Asm_Output
4743 @unnumberedsec Asm_Output
4744 @findex Asm_Output
4745 @noindent
4746 The @code{Asm_Output} attribute denotes a function that takes two
4747 parameters.  The first is a string, the second is the name of a variable
4748 of the type designated by the attribute prefix.  The first (string)
4749 argument is required to be a static expression and designates the
4750 constraint for the parameter (e.g.@: what kind of register is
4751 required).  The second argument is the variable to be updated with the
4752 result.  The possible values for constraint are the same as those used in
4753 the RTL, and are dependent on the configuration file used to build the
4754 GCC back end.  If there are no output operands, then this argument may
4755 either be omitted, or explicitly given as @code{No_Output_Operands}.
4756 @ref{Machine Code Insertions}
4757
4758 @node AST_Entry
4759 @unnumberedsec AST_Entry
4760 @cindex OpenVMS
4761 @findex AST_Entry
4762 @noindent
4763 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4764 the name of an entry, it yields a value of the predefined type AST_Handler
4765 (declared in the predefined package System, as extended by the use of
4766 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4767 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4768 Language Reference Manual}, section 9.12a.
4769
4770 @node Bit
4771 @unnumberedsec Bit
4772 @findex Bit
4773 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4774 offset within the storage unit (byte) that contains the first bit of
4775 storage allocated for the object.  The value of this attribute is of the
4776 type @code{Universal_Integer}, and is always a non-negative number not
4777 exceeding the value of @code{System.Storage_Unit}.
4778
4779 For an object that is a variable or a constant allocated in a register,
4780 the value is zero.  (The use of this attribute does not force the
4781 allocation of a variable to memory).
4782
4783 For an object that is a formal parameter, this attribute applies
4784 to either the matching actual parameter or to a copy of the
4785 matching actual parameter.
4786
4787 For an access object the value is zero.  Note that
4788 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4789 designated object.  Similarly for a record component
4790 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4791 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4792 are subject to index checks.
4793
4794 This attribute is designed to be compatible with the DEC Ada 83 definition
4795 and implementation of the @code{Bit} attribute.
4796
4797 @node Bit_Position
4798 @unnumberedsec Bit_Position
4799 @findex Bit_Position
4800 @noindent
4801 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4802 of the fields of the record type, yields the bit
4803 offset within the record contains the first bit of
4804 storage allocated for the object.  The value of this attribute is of the
4805 type @code{Universal_Integer}.  The value depends only on the field
4806 @var{C} and is independent of the alignment of
4807 the containing record @var{R}.
4808
4809 @node Code_Address
4810 @unnumberedsec Code_Address
4811 @findex Code_Address
4812 @cindex Subprogram address
4813 @cindex Address of subprogram code
4814 @noindent
4815 The @code{'Address}
4816 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4817 intended effect seems to be to provide
4818 an address value which can be used to call the subprogram by means of
4819 an address clause as in the following example:
4820
4821 @smallexample @c ada
4822 procedure K is @dots{}
4823
4824 procedure L;
4825 for L'Address use K'Address;
4826 pragma Import (Ada, L);
4827 @end smallexample
4828
4829 @noindent
4830 A call to @code{L} is then expected to result in a call to @code{K}@.
4831 In Ada 83, where there were no access-to-subprogram values, this was
4832 a common work-around for getting the effect of an indirect call.
4833 GNAT implements the above use of @code{Address} and the technique
4834 illustrated by the example code works correctly.
4835
4836 However, for some purposes, it is useful to have the address of the start
4837 of the generated code for the subprogram.  On some architectures, this is
4838 not necessarily the same as the @code{Address} value described above.
4839 For example, the @code{Address} value may reference a subprogram
4840 descriptor rather than the subprogram itself.
4841
4842 The @code{'Code_Address} attribute, which can only be applied to
4843 subprogram entities, always returns the address of the start of the
4844 generated code of the specified subprogram, which may or may not be
4845 the same value as is returned by the corresponding @code{'Address}
4846 attribute.
4847
4848 @node Default_Bit_Order
4849 @unnumberedsec Default_Bit_Order
4850 @cindex Big endian
4851 @cindex Little endian
4852 @findex Default_Bit_Order
4853 @noindent
4854 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4855 permissible prefix), provides the value @code{System.Default_Bit_Order}
4856 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4857 @code{Low_Order_First}).  This is used to construct the definition of
4858 @code{Default_Bit_Order} in package @code{System}.
4859
4860 @node Elaborated
4861 @unnumberedsec Elaborated
4862 @findex Elaborated
4863 @noindent
4864 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4865 value is a Boolean which indicates whether or not the given unit has been
4866 elaborated.  This attribute is primarily intended for internal use by the
4867 generated code for dynamic elaboration checking, but it can also be used
4868 in user programs.  The value will always be True once elaboration of all
4869 units has been completed.  An exception is for units which need no
4870 elaboration, the value is always False for such units.
4871
4872 @node Elab_Body
4873 @unnumberedsec Elab_Body
4874 @findex Elab_Body
4875 @noindent
4876 This attribute can only be applied to a program unit name.  It returns
4877 the entity for the corresponding elaboration procedure for elaborating
4878 the body of the referenced unit.  This is used in the main generated
4879 elaboration procedure by the binder and is not normally used in any
4880 other context.  However, there may be specialized situations in which it
4881 is useful to be able to call this elaboration procedure from Ada code,
4882 e.g.@: if it is necessary to do selective re-elaboration to fix some
4883 error.
4884
4885 @node Elab_Spec
4886 @unnumberedsec Elab_Spec
4887 @findex Elab_Spec
4888 @noindent
4889 This attribute can only be applied to a program unit name.  It returns
4890 the entity for the corresponding elaboration procedure for elaborating
4891 the specification of the referenced unit.  This is used in the main
4892 generated elaboration procedure by the binder and is not normally used
4893 in any other context.  However, there may be specialized situations in
4894 which it is useful to be able to call this elaboration procedure from
4895 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4896 some error.
4897
4898 @node Emax
4899 @unnumberedsec Emax
4900 @cindex Ada 83 attributes
4901 @findex Emax
4902 @noindent
4903 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4904 the Ada 83 reference manual for an exact description of the semantics of
4905 this attribute.
4906
4907 @node Enabled
4908 @unnumberedsec Enabled
4909 @findex Enabled
4910 @noindent
4911 The @code{Enabled} attribute allows an application program to check at compile
4912 time to see if the designated check is currently enabled. The prefix is a
4913 simple identifier, referencing any predefined check name (other than
4914 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
4915 no argument is given for the attribute, the check is for the general state
4916 of the check, if an argument is given, then it is an entity name, and the
4917 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
4918 given naming the entity (if not, then the argument is ignored).
4919
4920 Note that instantiations inherit the check status at the point of the
4921 instantiation, so a useful idiom is to have a library package that
4922 introduces a check name with @code{pragma Check_Name}, and then contains
4923 generic packages or subprograms which use the @code{Enabled} attribute
4924 to see if the check is enabled. A user of this package can then issue
4925 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
4926 the package or subprogram, controlling whether the check will be present.
4927
4928 @node Enum_Rep
4929 @unnumberedsec Enum_Rep
4930 @cindex Representation of enums
4931 @findex Enum_Rep
4932 @noindent
4933 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4934 function with the following spec:
4935
4936 @smallexample @c ada
4937 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4938   return @i{Universal_Integer};
4939 @end smallexample
4940
4941 @noindent
4942 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4943 enumeration type or to a non-overloaded enumeration
4944 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4945 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4946 enumeration literal or object.
4947
4948 The function returns the representation value for the given enumeration
4949 value.  This will be equal to value of the @code{Pos} attribute in the
4950 absence of an enumeration representation clause.  This is a static
4951 attribute (i.e.@: the result is static if the argument is static).
4952
4953 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4954 in which case it simply returns the integer value.  The reason for this
4955 is to allow it to be used for @code{(<>)} discrete formal arguments in
4956 a generic unit that can be instantiated with either enumeration types
4957 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4958 type whose upper bound exceeds the upper bound of the largest signed
4959 integer type, and the argument is a variable, so that the universal
4960 integer calculation is done at run time, then the call to @code{Enum_Rep}
4961 may raise @code{Constraint_Error}.
4962
4963 @node Epsilon
4964 @unnumberedsec Epsilon
4965 @cindex Ada 83 attributes
4966 @findex Epsilon
4967 @noindent
4968 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4969 the Ada 83 reference manual for an exact description of the semantics of
4970 this attribute.
4971
4972 @node Fixed_Value
4973 @unnumberedsec Fixed_Value
4974 @findex Fixed_Value
4975 @noindent
4976 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4977 function with the following specification:
4978
4979 @smallexample @c ada
4980 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4981   return @var{S};
4982 @end smallexample
4983
4984 @noindent
4985 The value returned is the fixed-point value @var{V} such that
4986
4987 @smallexample @c ada
4988 @var{V} = Arg * @var{S}'Small
4989 @end smallexample
4990
4991 @noindent
4992 The effect is thus similar to first converting the argument to the
4993 integer type used to represent @var{S}, and then doing an unchecked
4994 conversion to the fixed-point type.  The difference is
4995 that there are full range checks, to ensure that the result is in range.
4996 This attribute is primarily intended for use in implementation of the
4997 input-output functions for fixed-point values.
4998
4999 @node Has_Access_Values
5000 @unnumberedsec Has_Access_Values
5001 @cindex Access values, testing for
5002 @findex Has_Access_Values
5003 @noindent
5004 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5005 is a Boolean value which is True if the is an access type, or is a composite
5006 type with a component (at any nesting depth) that is an access type, and is
5007 False otherwise.
5008 The intended use of this attribute is in conjunction with generic
5009 definitions.  If the attribute is applied to a generic private type, it
5010 indicates whether or not the corresponding actual type has access values.
5011
5012 @node Has_Discriminants
5013 @unnumberedsec Has_Discriminants
5014 @cindex Discriminants, testing for
5015 @findex Has_Discriminants
5016 @noindent
5017 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5018 is a Boolean value which is True if the type has discriminants, and False
5019 otherwise.  The intended use of this attribute is in conjunction with generic
5020 definitions.  If the attribute is applied to a generic private type, it
5021 indicates whether or not the corresponding actual type has discriminants.
5022
5023 @node Img
5024 @unnumberedsec Img
5025 @findex Img
5026 @noindent
5027 The @code{Img} attribute differs from @code{Image} in that it may be
5028 applied to objects as well as types, in which case it gives the
5029 @code{Image} for the subtype of the object.  This is convenient for
5030 debugging:
5031
5032 @smallexample @c ada
5033 Put_Line ("X = " & X'Img);
5034 @end smallexample
5035
5036 @noindent
5037 has the same meaning as the more verbose:
5038
5039 @smallexample @c ada
5040 Put_Line ("X = " & @var{T}'Image (X));
5041 @end smallexample
5042
5043 @noindent
5044 where @var{T} is the (sub)type of the object @code{X}.
5045
5046 @node Integer_Value
5047 @unnumberedsec Integer_Value
5048 @findex Integer_Value
5049 @noindent
5050 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5051 function with the following spec:
5052
5053 @smallexample @c ada
5054 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5055   return @var{S};
5056 @end smallexample
5057
5058 @noindent
5059 The value returned is the integer value @var{V}, such that
5060
5061 @smallexample @c ada
5062 Arg = @var{V} * @var{T}'Small
5063 @end smallexample
5064
5065 @noindent
5066 where @var{T} is the type of @code{Arg}.
5067 The effect is thus similar to first doing an unchecked conversion from
5068 the fixed-point type to its corresponding implementation type, and then
5069 converting the result to the target integer type.  The difference is
5070 that there are full range checks, to ensure that the result is in range.
5071 This attribute is primarily intended for use in implementation of the
5072 standard input-output functions for fixed-point values.
5073
5074 @node Large
5075 @unnumberedsec Large
5076 @cindex Ada 83 attributes
5077 @findex Large
5078 @noindent
5079 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5080 the Ada 83 reference manual for an exact description of the semantics of
5081 this attribute.
5082
5083 @node Machine_Size
5084 @unnumberedsec Machine_Size
5085 @findex Machine_Size
5086 @noindent
5087 This attribute is identical to the @code{Object_Size} attribute.  It is
5088 provided for compatibility with the DEC Ada 83 attribute of this name.
5089
5090 @node Mantissa
5091 @unnumberedsec Mantissa
5092 @cindex Ada 83 attributes
5093 @findex Mantissa
5094 @noindent
5095 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5096 the Ada 83 reference manual for an exact description of the semantics of
5097 this attribute.
5098
5099 @node Max_Interrupt_Priority
5100 @unnumberedsec Max_Interrupt_Priority
5101 @cindex Interrupt priority, maximum
5102 @findex Max_Interrupt_Priority
5103 @noindent
5104 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5105 permissible prefix), provides the same value as
5106 @code{System.Max_Interrupt_Priority}.
5107
5108 @node Max_Priority
5109 @unnumberedsec Max_Priority
5110 @cindex Priority, maximum
5111 @findex Max_Priority
5112 @noindent
5113 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5114 prefix) provides the same value as @code{System.Max_Priority}.
5115
5116 @node Maximum_Alignment
5117 @unnumberedsec Maximum_Alignment
5118 @cindex Alignment, maximum
5119 @findex Maximum_Alignment
5120 @noindent
5121 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5122 permissible prefix) provides the maximum useful alignment value for the
5123 target.  This is a static value that can be used to specify the alignment
5124 for an object, guaranteeing that it is properly aligned in all
5125 cases.
5126
5127 @node Mechanism_Code
5128 @unnumberedsec Mechanism_Code
5129 @cindex Return values, passing mechanism
5130 @cindex Parameters, passing mechanism
5131 @findex Mechanism_Code
5132 @noindent
5133 @code{@var{function}'Mechanism_Code} yields an integer code for the
5134 mechanism used for the result of function, and
5135 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5136 used for formal parameter number @var{n} (a static integer value with 1
5137 meaning the first parameter) of @var{subprogram}.  The code returned is:
5138
5139 @table @asis
5140 @item 1
5141 by copy (value)
5142 @item 2
5143 by reference
5144 @item 3
5145 by descriptor (default descriptor class)
5146 @item 4
5147 by descriptor (UBS: unaligned bit string)
5148 @item 5
5149 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5150 @item 6
5151 by descriptor (UBA: unaligned bit array)
5152 @item 7
5153 by descriptor (S: string, also scalar access type parameter)
5154 @item 8
5155 by descriptor (SB: string with arbitrary bounds)
5156 @item 9
5157 by descriptor (A: contiguous array)
5158 @item 10
5159 by descriptor (NCA: non-contiguous array)
5160 @end table
5161
5162 @noindent
5163 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5164 @cindex OpenVMS
5165
5166 @node Null_Parameter
5167 @unnumberedsec Null_Parameter
5168 @cindex Zero address, passing
5169 @findex Null_Parameter
5170 @noindent
5171 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5172 type or subtype @var{T} allocated at machine address zero.  The attribute
5173 is allowed only as the default expression of a formal parameter, or as
5174 an actual expression of a subprogram call.  In either case, the
5175 subprogram must be imported.
5176
5177 The identity of the object is represented by the address zero in the
5178 argument list, independent of the passing mechanism (explicit or
5179 default).
5180
5181 This capability is needed to specify that a zero address should be
5182 passed for a record or other composite object passed by reference.
5183 There is no way of indicating this without the @code{Null_Parameter}
5184 attribute.
5185
5186 @node Object_Size
5187 @unnumberedsec Object_Size
5188 @cindex Size, used for objects
5189 @findex Object_Size
5190 @noindent
5191 The size of an object is not necessarily the same as the size of the type
5192 of an object.  This is because by default object sizes are increased to be
5193 a multiple of the alignment of the object.  For example,
5194 @code{Natural'Size} is
5195 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5196 Similarly, a record containing an integer and a character:
5197
5198 @smallexample @c ada
5199 type Rec is record
5200    I : Integer;
5201    C : Character;
5202 end record;
5203 @end smallexample
5204
5205 @noindent
5206 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5207 alignment will be 4, because of the
5208 integer field, and so the default size of record objects for this type
5209 will be 64 (8 bytes).
5210
5211 The @code{@var{type}'Object_Size} attribute
5212 has been added to GNAT to allow the
5213 default object size of a type to be easily determined.  For example,
5214 @code{Natural'Object_Size} is 32, and
5215 @code{Rec'Object_Size} (for the record type in the above example) will be
5216 64.  Note also that, unlike the situation with the
5217 @code{Size} attribute as defined in the Ada RM, the
5218 @code{Object_Size} attribute can be specified individually
5219 for different subtypes.  For example:
5220
5221 @smallexample @c ada
5222 type R is new Integer;
5223 subtype R1 is R range 1 .. 10;
5224 subtype R2 is R range 1 .. 10;
5225 for R2'Object_Size use 8;
5226 @end smallexample
5227
5228 @noindent
5229 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5230 32 since the default object size for a subtype is the same as the object size
5231 for the parent subtype.  This means that objects of type @code{R}
5232 or @code{R1} will
5233 by default be 32 bits (four bytes).  But objects of type
5234 @code{R2} will be only
5235 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5236
5237 Although @code{Object_Size} does properly reflect the default object size
5238 value, it is not necessarily the case that all objects will be of this size
5239 in a case where it is not specified explicitly. The compiler is free to
5240 increase the size and alignment of stand alone objects to improve efficiency
5241 of the generated code and sometimes does so in the case of large composite
5242 objects. If the size of a stand alone object is critical to the
5243 application, it should be specified explicitly.
5244
5245 @node Passed_By_Reference
5246 @unnumberedsec Passed_By_Reference
5247 @cindex Parameters, when passed by reference
5248 @findex Passed_By_Reference
5249 @noindent
5250 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5251 a value of type @code{Boolean} value that is @code{True} if the type is
5252 normally passed by reference and @code{False} if the type is normally
5253 passed by copy in calls.  For scalar types, the result is always @code{False}
5254 and is static.  For non-scalar types, the result is non-static.
5255
5256 @node Range_Length
5257 @unnumberedsec Range_Length
5258 @findex Range_Length
5259 @noindent
5260 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5261 the number of values represented by the subtype (zero for a null
5262 range).  The result is static for static subtypes.  @code{Range_Length}
5263 applied to the index subtype of a one dimensional array always gives the
5264 same result as @code{Range} applied to the array itself.
5265
5266 @node Safe_Emax
5267 @unnumberedsec Safe_Emax
5268 @cindex Ada 83 attributes
5269 @findex Safe_Emax
5270 @noindent
5271 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5272 the Ada 83 reference manual for an exact description of the semantics of
5273 this attribute.
5274
5275 @node Safe_Large
5276 @unnumberedsec Safe_Large
5277 @cindex Ada 83 attributes
5278 @findex Safe_Large
5279 @noindent
5280 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5281 the Ada 83 reference manual for an exact description of the semantics of
5282 this attribute.
5283
5284 @node Small
5285 @unnumberedsec Small
5286 @cindex Ada 83 attributes
5287 @findex Small
5288 @noindent
5289 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5290 fixed-point types.
5291 GNAT also allows this attribute to be applied to floating-point types
5292 for compatibility with Ada 83.  See
5293 the Ada 83 reference manual for an exact description of the semantics of
5294 this attribute when applied to floating-point types.
5295
5296 @node Storage_Unit
5297 @unnumberedsec Storage_Unit
5298 @findex Storage_Unit
5299 @noindent
5300 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5301 prefix) provides the same value as @code{System.Storage_Unit}.
5302
5303 @node Stub_Type
5304 @unnumberedsec Stub_Type
5305 @findex Stub_Type
5306 @noindent
5307 The GNAT implementation of remote access-to-classwide types is
5308 organized as described in AARM section E.4 (20.t): a value of an RACW type
5309 (designating a remote object) is represented as a normal access
5310 value, pointing to a "stub" object which in turn contains the
5311 necessary information to contact the designated remote object. A
5312 call on any dispatching operation of such a stub object does the
5313 remote call, if necessary, using the information in the stub object
5314 to locate the target partition, etc.
5315
5316 For a prefix @code{T} that denotes a remote access-to-classwide type,
5317 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5318
5319 By construction, the layout of @code{T'Stub_Type} is identical to that of
5320 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5321 unit @code{System.Partition_Interface}. Use of this attribute will create
5322 an implicit dependency on this unit.
5323
5324 @node Target_Name
5325 @unnumberedsec Target_Name
5326 @findex Target_Name
5327 @noindent
5328 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5329 prefix) provides a static string value that identifies the target
5330 for the current compilation. For GCC implementations, this is the
5331 standard gcc target name without the terminating slash (for
5332 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5333
5334 @node Tick
5335 @unnumberedsec Tick
5336 @findex Tick
5337 @noindent
5338 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5339 provides the same value as @code{System.Tick},
5340
5341 @node To_Address
5342 @unnumberedsec To_Address
5343 @findex To_Address
5344 @noindent
5345 The @code{System'To_Address}
5346 (@code{System} is the only permissible prefix)
5347 denotes a function identical to
5348 @code{System.Storage_Elements.To_Address} except that
5349 it is a static attribute.  This means that if its argument is
5350 a static expression, then the result of the attribute is a
5351 static expression.  The result is that such an expression can be
5352 used in contexts (e.g.@: preelaborable packages) which require a
5353 static expression and where the function call could not be used
5354 (since the function call is always non-static, even if its
5355 argument is static).
5356
5357 @node Type_Class
5358 @unnumberedsec Type_Class
5359 @findex Type_Class
5360 @noindent
5361 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5362 the value of the type class for the full type of @var{type}.  If
5363 @var{type} is a generic formal type, the value is the value for the
5364 corresponding actual subtype.  The value of this attribute is of type
5365 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5366
5367 @smallexample @c ada
5368   type Type_Class is
5369     (Type_Class_Enumeration,
5370      Type_Class_Integer,
5371      Type_Class_Fixed_Point,
5372      Type_Class_Floating_Point,
5373      Type_Class_Array,
5374      Type_Class_Record,
5375      Type_Class_Access,
5376      Type_Class_Task,
5377      Type_Class_Address);
5378 @end smallexample
5379
5380 @noindent
5381 Protected types yield the value @code{Type_Class_Task}, which thus
5382 applies to all concurrent types.  This attribute is designed to
5383 be compatible with the DEC Ada 83 attribute of the same name.
5384
5385 @node UET_Address
5386 @unnumberedsec UET_Address
5387 @findex UET_Address
5388 @noindent
5389 The @code{UET_Address} attribute can only be used for a prefix which
5390 denotes a library package.  It yields the address of the unit exception
5391 table when zero cost exception handling is used.  This attribute is
5392 intended only for use within the GNAT implementation.  See the unit
5393 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5394 for details on how this attribute is used in the implementation.
5395
5396 @node Unconstrained_Array
5397 @unnumberedsec Unconstrained_Array
5398 @findex Unconstrained_Array
5399 @noindent
5400 The @code{Unconstrained_Array} attribute can be used with a prefix that
5401 denotes any type or subtype. It is a static attribute that yields
5402 @code{True} if the prefix designates an unconstrained array,
5403 and @code{False} otherwise. In a generic instance, the result is
5404 still static, and yields the result of applying this test to the
5405 generic actual.
5406
5407 @node Universal_Literal_String
5408 @unnumberedsec Universal_Literal_String
5409 @cindex Named numbers, representation of
5410 @findex Universal_Literal_String
5411 @noindent
5412 The prefix of @code{Universal_Literal_String} must be a named
5413 number.  The static result is the string consisting of the characters of
5414 the number as defined in the original source.  This allows the user
5415 program to access the actual text of named numbers without intermediate
5416 conversions and without the need to enclose the strings in quotes (which
5417 would preclude their use as numbers).  This is used internally for the
5418 construction of values of the floating-point attributes from the file
5419 @file{ttypef.ads}, but may also be used by user programs.
5420
5421 For example, the following program prints the first 50 digits of pi:
5422
5423 @smallexample @c ada
5424 with Text_IO; use Text_IO;
5425 with Ada.Numerics;
5426 procedure Pi is
5427 begin
5428    Put (Ada.Numerics.Pi'Universal_Literal_String);
5429 end;
5430 @end smallexample
5431
5432 @node Unrestricted_Access
5433 @unnumberedsec Unrestricted_Access
5434 @cindex @code{Access}, unrestricted
5435 @findex Unrestricted_Access
5436 @noindent
5437 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5438 except that all accessibility and aliased view checks are omitted.  This
5439 is a user-beware attribute.  It is similar to
5440 @code{Address}, for which it is a desirable replacement where the value
5441 desired is an access type.  In other words, its effect is identical to
5442 first applying the @code{Address} attribute and then doing an unchecked
5443 conversion to a desired access type.  In GNAT, but not necessarily in
5444 other implementations, the use of static chains for inner level
5445 subprograms means that @code{Unrestricted_Access} applied to a
5446 subprogram yields a value that can be called as long as the subprogram
5447 is in scope (normal Ada accessibility rules restrict this usage).
5448
5449 It is possible to use @code{Unrestricted_Access} for any type, but care
5450 must be exercised if it is used to create pointers to unconstrained
5451 objects. In this case, the resulting pointer has the same scope as the
5452 context of the attribute, and may not be returned to some enclosing
5453 scope. For instance, a function cannot use @code{Unrestricted_Access}
5454 to create a unconstrained pointer and then return that value to the
5455 caller.
5456
5457 @node VADS_Size
5458 @unnumberedsec VADS_Size
5459 @cindex @code{Size}, VADS compatibility
5460 @findex VADS_Size
5461 @noindent
5462 The @code{'VADS_Size} attribute is intended to make it easier to port
5463 legacy code which relies on the semantics of @code{'Size} as implemented
5464 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5465 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5466 to a predefined or other primitive type with no Size clause yields the
5467 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5468 typical machines).  In addition @code{'VADS_Size} applied to an object
5469 gives the result that would be obtained by applying the attribute to
5470 the corresponding type.
5471
5472 @node Value_Size
5473 @unnumberedsec Value_Size
5474 @cindex @code{Size}, setting for not-first subtype
5475 @findex Value_Size
5476 @code{@var{type}'Value_Size} is the number of bits required to represent
5477 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5478 but, unlike @code{Size}, may be set for non-first subtypes.
5479
5480 @node Wchar_T_Size
5481 @unnumberedsec Wchar_T_Size
5482 @findex Wchar_T_Size
5483 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5484 prefix) provides the size in bits of the C @code{wchar_t} type
5485 primarily for constructing the definition of this type in
5486 package @code{Interfaces.C}.
5487
5488 @node Word_Size
5489 @unnumberedsec Word_Size
5490 @findex Word_Size
5491 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5492 prefix) provides the value @code{System.Word_Size}.
5493
5494 @c ------------------------
5495 @node Implementation Advice
5496 @chapter Implementation Advice
5497 @noindent
5498 The main text of the Ada Reference Manual describes the required
5499 behavior of all Ada compilers, and the GNAT compiler conforms to
5500 these requirements.
5501
5502 In addition, there are sections throughout the Ada Reference Manual headed
5503 by the phrase ``Implementation advice''.  These sections are not normative,
5504 i.e., they do not specify requirements that all compilers must
5505 follow.  Rather they provide advice on generally desirable behavior.  You
5506 may wonder why they are not requirements.  The most typical answer is
5507 that they describe behavior that seems generally desirable, but cannot
5508 be provided on all systems, or which may be undesirable on some systems.
5509
5510 As far as practical, GNAT follows the implementation advice sections in
5511 the Ada Reference Manual.  This chapter contains a table giving the
5512 reference manual section number, paragraph number and several keywords
5513 for each advice.  Each entry consists of the text of the advice followed
5514 by the GNAT interpretation of this advice.  Most often, this simply says
5515 ``followed'', which means that GNAT follows the advice.  However, in a
5516 number of cases, GNAT deliberately deviates from this advice, in which
5517 case the text describes what GNAT does and why.
5518
5519 @cindex Error detection
5520 @unnumberedsec 1.1.3(20): Error Detection
5521 @sp 1
5522 @cartouche
5523 If an implementation detects the use of an unsupported Specialized Needs
5524 Annex feature at run time, it should raise @code{Program_Error} if
5525 feasible.
5526 @end cartouche
5527 Not relevant.  All specialized needs annex features are either supported,
5528 or diagnosed at compile time.
5529
5530 @cindex Child Units
5531 @unnumberedsec 1.1.3(31): Child Units
5532 @sp 1
5533 @cartouche
5534 If an implementation wishes to provide implementation-defined
5535 extensions to the functionality of a language-defined library unit, it
5536 should normally do so by adding children to the library unit.
5537 @end cartouche
5538 Followed.
5539
5540 @cindex Bounded errors
5541 @unnumberedsec 1.1.5(12): Bounded Errors
5542 @sp 1
5543 @cartouche
5544 If an implementation detects a bounded error or erroneous
5545 execution, it should raise @code{Program_Error}.
5546 @end cartouche
5547 Followed in all cases in which the implementation detects a bounded
5548 error or erroneous execution.  Not all such situations are detected at
5549 runtime.
5550
5551 @cindex Pragmas
5552 @unnumberedsec 2.8(16): Pragmas
5553 @sp 1
5554 @cartouche
5555 Normally, implementation-defined pragmas should have no semantic effect
5556 for error-free programs; that is, if the implementation-defined pragmas
5557 are removed from a working program, the program should still be legal,
5558 and should still have the same semantics.
5559 @end cartouche
5560 The following implementation defined pragmas are exceptions to this
5561 rule:
5562
5563 @table @code
5564 @item Abort_Defer
5565 Affects semantics
5566 @item Ada_83
5567 Affects legality
5568 @item Assert
5569 Affects semantics
5570 @item CPP_Class
5571 Affects semantics
5572 @item CPP_Constructor
5573 Affects semantics
5574 @item Debug
5575 Affects semantics
5576 @item Interface_Name
5577 Affects semantics
5578 @item Machine_Attribute
5579 Affects semantics
5580 @item Unimplemented_Unit
5581 Affects legality
5582 @item Unchecked_Union
5583 Affects semantics
5584 @end table
5585
5586 @noindent
5587 In each of the above cases, it is essential to the purpose of the pragma
5588 that this advice not be followed.  For details see the separate section
5589 on implementation defined pragmas.
5590
5591 @unnumberedsec 2.8(17-19): Pragmas
5592 @sp 1
5593 @cartouche
5594 Normally, an implementation should not define pragmas that can
5595 make an illegal program legal, except as follows:
5596 @end cartouche
5597 @sp 1
5598 @cartouche
5599 A pragma used to complete a declaration, such as a pragma @code{Import};
5600 @end cartouche
5601 @sp 1
5602 @cartouche
5603 A pragma used to configure the environment by adding, removing, or
5604 replacing @code{library_items}.
5605 @end cartouche
5606 See response to paragraph 16 of this same section.
5607
5608 @cindex Character Sets
5609 @cindex Alternative Character Sets
5610 @unnumberedsec 3.5.2(5): Alternative Character Sets
5611 @sp 1
5612 @cartouche
5613 If an implementation supports a mode with alternative interpretations
5614 for @code{Character} and @code{Wide_Character}, the set of graphic
5615 characters of @code{Character} should nevertheless remain a proper
5616 subset of the set of graphic characters of @code{Wide_Character}.  Any
5617 character set ``localizations'' should be reflected in the results of
5618 the subprograms defined in the language-defined package
5619 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5620 an alternative interpretation of @code{Character}, the implementation should
5621 also support a corresponding change in what is a legal
5622 @code{identifier_letter}.
5623 @end cartouche
5624 Not all wide character modes follow this advice, in particular the JIS
5625 and IEC modes reflect standard usage in Japan, and in these encoding,
5626 the upper half of the Latin-1 set is not part of the wide-character
5627 subset, since the most significant bit is used for wide character
5628 encoding.  However, this only applies to the external forms.  Internally
5629 there is no such restriction.
5630
5631 @cindex Integer types
5632 @unnumberedsec 3.5.4(28): Integer Types
5633
5634 @sp 1
5635 @cartouche
5636 An implementation should support @code{Long_Integer} in addition to
5637 @code{Integer} if the target machine supports 32-bit (or longer)
5638 arithmetic.  No other named integer subtypes are recommended for package
5639 @code{Standard}.  Instead, appropriate named integer subtypes should be
5640 provided in the library package @code{Interfaces} (see B.2).
5641 @end cartouche
5642 @code{Long_Integer} is supported.  Other standard integer types are supported
5643 so this advice is not fully followed.  These types
5644 are supported for convenient interface to C, and so that all hardware
5645 types of the machine are easily available.
5646 @unnumberedsec 3.5.4(29): Integer Types
5647
5648 @sp 1
5649 @cartouche
5650 An implementation for a two's complement machine should support
5651 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5652 implementation should support a non-binary modules up to @code{Integer'Last}.
5653 @end cartouche
5654 Followed.
5655
5656 @cindex Enumeration values
5657 @unnumberedsec 3.5.5(8): Enumeration Values
5658 @sp 1
5659 @cartouche
5660 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5661 subtype, if the value of the operand does not correspond to the internal
5662 code for any enumeration literal of its type (perhaps due to an
5663 un-initialized variable), then the implementation should raise
5664 @code{Program_Error}.  This is particularly important for enumeration
5665 types with noncontiguous internal codes specified by an
5666 enumeration_representation_clause.
5667 @end cartouche
5668 Followed.
5669
5670 @cindex Float types
5671 @unnumberedsec 3.5.7(17): Float Types
5672 @sp 1
5673 @cartouche
5674 An implementation should support @code{Long_Float} in addition to
5675 @code{Float} if the target machine supports 11 or more digits of
5676 precision.  No other named floating point subtypes are recommended for
5677 package @code{Standard}.  Instead, appropriate named floating point subtypes
5678 should be provided in the library package @code{Interfaces} (see B.2).
5679 @end cartouche
5680 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5681 former provides improved compatibility with other implementations
5682 supporting this type.  The latter corresponds to the highest precision
5683 floating-point type supported by the hardware.  On most machines, this
5684 will be the same as @code{Long_Float}, but on some machines, it will
5685 correspond to the IEEE extended form.  The notable case is all ia32
5686 (x86) implementations, where @code{Long_Long_Float} corresponds to
5687 the 80-bit extended precision format supported in hardware on this
5688 processor.  Note that the 128-bit format on SPARC is not supported,
5689 since this is a software rather than a hardware format.
5690
5691 @cindex Multidimensional arrays
5692 @cindex Arrays, multidimensional
5693 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5694 @sp 1
5695 @cartouche
5696 An implementation should normally represent multidimensional arrays in
5697 row-major order, consistent with the notation used for multidimensional
5698 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5699 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5700 column-major order should be used instead (see B.5, ``Interfacing with
5701 Fortran'').
5702 @end cartouche
5703 Followed.
5704
5705 @findex Duration'Small
5706 @unnumberedsec 9.6(30-31): Duration'Small
5707 @sp 1
5708 @cartouche
5709 Whenever possible in an implementation, the value of @code{Duration'Small}
5710 should be no greater than 100 microseconds.
5711 @end cartouche
5712 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5713
5714 @sp 1
5715 @cartouche
5716 The time base for @code{delay_relative_statements} should be monotonic;
5717 it need not be the same time base as used for @code{Calendar.Clock}.
5718 @end cartouche
5719 Followed.
5720
5721 @unnumberedsec 10.2.1(12): Consistent Representation
5722 @sp 1
5723 @cartouche
5724 In an implementation, a type declared in a pre-elaborated package should
5725 have the same representation in every elaboration of a given version of
5726 the package, whether the elaborations occur in distinct executions of
5727 the same program, or in executions of distinct programs or partitions
5728 that include the given version.
5729 @end cartouche
5730 Followed, except in the case of tagged types.  Tagged types involve
5731 implicit pointers to a local copy of a dispatch table, and these pointers
5732 have representations which thus depend on a particular elaboration of the
5733 package.  It is not easy to see how it would be possible to follow this
5734 advice without severely impacting efficiency of execution.
5735
5736 @cindex Exception information
5737 @unnumberedsec 11.4.1(19): Exception Information
5738 @sp 1
5739 @cartouche
5740 @code{Exception_Message} by default and @code{Exception_Information}
5741 should produce information useful for
5742 debugging.  @code{Exception_Message} should be short, about one
5743 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5744 should not include the
5745 @code{Exception_Name}.  @code{Exception_Information} should include both
5746 the @code{Exception_Name} and the @code{Exception_Message}.
5747 @end cartouche
5748 Followed.  For each exception that doesn't have a specified
5749 @code{Exception_Message}, the compiler generates one containing the location
5750 of the raise statement.  This location has the form ``file:line'', where
5751 file is the short file name (without path information) and line is the line
5752 number in the file.  Note that in the case of the Zero Cost Exception
5753 mechanism, these messages become redundant with the Exception_Information that
5754 contains a full backtrace of the calling sequence, so they are disabled.
5755 To disable explicitly the generation of the source location message, use the
5756 Pragma @code{Discard_Names}.
5757
5758 @cindex Suppression of checks
5759 @cindex Checks, suppression of
5760 @unnumberedsec 11.5(28): Suppression of Checks
5761 @sp 1
5762 @cartouche
5763 The implementation should minimize the code executed for checks that
5764 have been suppressed.
5765 @end cartouche
5766 Followed.
5767
5768 @cindex Representation clauses
5769 @unnumberedsec 13.1 (21-24): Representation Clauses
5770 @sp 1
5771 @cartouche
5772 The recommended level of support for all representation items is
5773 qualified as follows:
5774 @end cartouche
5775 @sp 1
5776 @cartouche
5777 An implementation need not support representation items containing
5778 non-static expressions, except that an implementation should support a
5779 representation item for a given entity if each non-static expression in
5780 the representation item is a name that statically denotes a constant
5781 declared before the entity.
5782 @end cartouche
5783 Followed.  In fact, GNAT goes beyond the recommended level of support
5784 by allowing nonstatic expressions in some representation clauses even
5785 without the need to declare constants initialized with the values of
5786 such expressions.
5787 For example:
5788
5789 @smallexample @c ada
5790   X : Integer;
5791   Y : Float;
5792   for Y'Address use X'Address;>>
5793 @end smallexample
5794
5795
5796 @sp 1
5797 @cartouche
5798 An implementation need not support a specification for the @code{Size}
5799 for a given composite subtype, nor the size or storage place for an
5800 object (including a component) of a given composite subtype, unless the
5801 constraints on the subtype and its composite subcomponents (if any) are
5802 all static constraints.
5803 @end cartouche
5804 Followed.  Size Clauses are not permitted on non-static components, as
5805 described above.
5806
5807 @sp 1
5808 @cartouche
5809 An aliased component, or a component whose type is by-reference, should
5810 always be allocated at an addressable location.
5811 @end cartouche
5812 Followed.
5813
5814 @cindex Packed types
5815 @unnumberedsec 13.2(6-8): Packed Types
5816 @sp 1
5817 @cartouche
5818 If a type is packed, then the implementation should try to minimize
5819 storage allocated to objects of the type, possibly at the expense of
5820 speed of accessing components, subject to reasonable complexity in
5821 addressing calculations.
5822 @end cartouche
5823 @sp 1
5824 @cartouche
5825 The recommended level of support pragma @code{Pack} is:
5826
5827 For a packed record type, the components should be packed as tightly as
5828 possible subject to the Sizes of the component subtypes, and subject to
5829 any @code{record_representation_clause} that applies to the type; the
5830 implementation may, but need not, reorder components or cross aligned
5831 word boundaries to improve the packing.  A component whose @code{Size} is
5832 greater than the word size may be allocated an integral number of words.
5833 @end cartouche
5834 Followed.  Tight packing of arrays is supported for all component sizes
5835 up to 64-bits. If the array component size is 1 (that is to say, if
5836 the component is a boolean type or an enumeration type with two values)
5837 then values of the type are implicitly initialized to zero. This
5838 happens both for objects of the packed type, and for objects that have a
5839 subcomponent of the packed type.
5840
5841 @sp 1
5842 @cartouche
5843 An implementation should support Address clauses for imported
5844 subprograms.
5845 @end cartouche
5846 Followed.
5847 @cindex @code{Address} clauses
5848 @unnumberedsec 13.3(14-19): Address Clauses
5849
5850 @sp 1
5851 @cartouche
5852 For an array @var{X}, @code{@var{X}'Address} should point at the first
5853 component of the array, and not at the array bounds.
5854 @end cartouche
5855 Followed.
5856
5857 @sp 1
5858 @cartouche
5859 The recommended level of support for the @code{Address} attribute is:
5860
5861 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5862 object that is aliased or of a by-reference type, or is an entity whose
5863 @code{Address} has been specified.
5864 @end cartouche
5865 Followed.  A valid address will be produced even if none of those
5866 conditions have been met.  If necessary, the object is forced into
5867 memory to ensure the address is valid.
5868
5869 @sp 1
5870 @cartouche
5871 An implementation should support @code{Address} clauses for imported
5872 subprograms.
5873 @end cartouche
5874 Followed.
5875
5876 @sp 1
5877 @cartouche
5878 Objects (including subcomponents) that are aliased or of a by-reference
5879 type should be allocated on storage element boundaries.
5880 @end cartouche
5881 Followed.
5882
5883 @sp 1
5884 @cartouche
5885 If the @code{Address} of an object is specified, or it is imported or exported,
5886 then the implementation should not perform optimizations based on
5887 assumptions of no aliases.
5888 @end cartouche
5889 Followed.
5890
5891 @cindex @code{Alignment} clauses
5892 @unnumberedsec 13.3(29-35): Alignment Clauses
5893 @sp 1
5894 @cartouche
5895 The recommended level of support for the @code{Alignment} attribute for
5896 subtypes is:
5897
5898 An implementation should support specified Alignments that are factors
5899 and multiples of the number of storage elements per word, subject to the
5900 following:
5901 @end cartouche
5902 Followed.
5903
5904 @sp 1
5905 @cartouche
5906 An implementation need not support specified @code{Alignment}s for
5907 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5908 loaded and stored by available machine instructions.
5909 @end cartouche
5910 Followed.
5911
5912 @sp 1
5913 @cartouche
5914 An implementation need not support specified @code{Alignment}s that are
5915 greater than the maximum @code{Alignment} the implementation ever returns by
5916 default.
5917 @end cartouche
5918 Followed.
5919
5920 @sp 1
5921 @cartouche
5922 The recommended level of support for the @code{Alignment} attribute for
5923 objects is:
5924
5925 Same as above, for subtypes, but in addition:
5926 @end cartouche
5927 Followed.
5928
5929 @sp 1
5930 @cartouche
5931 For stand-alone library-level objects of statically constrained
5932 subtypes, the implementation should support all @code{Alignment}s
5933 supported by the target linker.  For example, page alignment is likely to
5934 be supported for such objects, but not for subtypes.
5935 @end cartouche
5936 Followed.
5937
5938 @cindex @code{Size} clauses
5939 @unnumberedsec 13.3(42-43): Size Clauses
5940 @sp 1
5941 @cartouche
5942 The recommended level of support for the @code{Size} attribute of
5943 objects is:
5944
5945 A @code{Size} clause should be supported for an object if the specified
5946 @code{Size} is at least as large as its subtype's @code{Size}, and
5947 corresponds to a size in storage elements that is a multiple of the
5948 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5949 @end cartouche
5950 Followed.
5951
5952 @unnumberedsec 13.3(50-56): Size Clauses
5953 @sp 1
5954 @cartouche
5955 If the @code{Size} of a subtype is specified, and allows for efficient
5956 independent addressability (see 9.10) on the target architecture, then
5957 the @code{Size} of the following objects of the subtype should equal the
5958 @code{Size} of the subtype:
5959
5960 Aliased objects (including components).
5961 @end cartouche
5962 Followed.
5963
5964 @sp 1
5965 @cartouche
5966 @code{Size} clause on a composite subtype should not affect the
5967 internal layout of components.
5968 @end cartouche
5969 Followed. But note that this can be overridden by use of the implementation
5970 pragma Implicit_Packing in the case of packed arrays.
5971
5972 @sp 1
5973 @cartouche
5974 The recommended level of support for the @code{Size} attribute of subtypes is:
5975 @end cartouche
5976 @sp 1
5977 @cartouche
5978 The @code{Size} (if not specified) of a static discrete or fixed point
5979 subtype should be the number of bits needed to represent each value
5980 belonging to the subtype using an unbiased representation, leaving space
5981 for a sign bit only if the subtype contains negative values.  If such a
5982 subtype is a first subtype, then an implementation should support a
5983 specified @code{Size} for it that reflects this representation.
5984 @end cartouche
5985 Followed.
5986
5987 @sp 1
5988 @cartouche
5989 For a subtype implemented with levels of indirection, the @code{Size}
5990 should include the size of the pointers, but not the size of what they
5991 point at.
5992 @end cartouche
5993 Followed.
5994
5995 @cindex @code{Component_Size} clauses
5996 @unnumberedsec 13.3(71-73): Component Size Clauses
5997 @sp 1
5998 @cartouche
5999 The recommended level of support for the @code{Component_Size}
6000 attribute is:
6001 @end cartouche
6002 @sp 1
6003 @cartouche
6004 An implementation need not support specified @code{Component_Sizes} that are
6005 less than the @code{Size} of the component subtype.
6006 @end cartouche
6007 Followed.
6008
6009 @sp 1
6010 @cartouche
6011 An implementation should support specified @code{Component_Size}s that
6012 are factors and multiples of the word size.  For such
6013 @code{Component_Size}s, the array should contain no gaps between
6014 components.  For other @code{Component_Size}s (if supported), the array
6015 should contain no gaps between components when packing is also
6016 specified; the implementation should forbid this combination in cases
6017 where it cannot support a no-gaps representation.
6018 @end cartouche
6019 Followed.
6020
6021 @cindex Enumeration representation clauses
6022 @cindex Representation clauses, enumeration
6023 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6024 @sp 1
6025 @cartouche
6026 The recommended level of support for enumeration representation clauses
6027 is:
6028
6029 An implementation need not support enumeration representation clauses
6030 for boolean types, but should at minimum support the internal codes in
6031 the range @code{System.Min_Int.System.Max_Int}.
6032 @end cartouche
6033 Followed.
6034
6035 @cindex Record representation clauses
6036 @cindex Representation clauses, records
6037 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6038 @sp 1
6039 @cartouche
6040 The recommended level of support for
6041 @*@code{record_representation_clauses} is:
6042
6043 An implementation should support storage places that can be extracted
6044 with a load, mask, shift sequence of machine code, and set with a load,
6045 shift, mask, store sequence, given the available machine instructions
6046 and run-time model.
6047 @end cartouche
6048 Followed.
6049
6050 @sp 1
6051 @cartouche
6052 A storage place should be supported if its size is equal to the
6053 @code{Size} of the component subtype, and it starts and ends on a
6054 boundary that obeys the @code{Alignment} of the component subtype.
6055 @end cartouche
6056 Followed.
6057
6058 @sp 1
6059 @cartouche
6060 If the default bit ordering applies to the declaration of a given type,
6061 then for a component whose subtype's @code{Size} is less than the word
6062 size, any storage place that does not cross an aligned word boundary
6063 should be supported.
6064 @end cartouche
6065 Followed.
6066
6067 @sp 1
6068 @cartouche
6069 An implementation may reserve a storage place for the tag field of a
6070 tagged type, and disallow other components from overlapping that place.
6071 @end cartouche
6072 Followed.  The storage place for the tag field is the beginning of the tagged
6073 record, and its size is Address'Size.  GNAT will reject an explicit component
6074 clause for the tag field.
6075
6076 @sp 1
6077 @cartouche
6078 An implementation need not support a @code{component_clause} for a
6079 component of an extension part if the storage place is not after the
6080 storage places of all components of the parent type, whether or not
6081 those storage places had been specified.
6082 @end cartouche
6083 Followed.  The above advice on record representation clauses is followed,
6084 and all mentioned features are implemented.
6085
6086 @cindex Storage place attributes
6087 @unnumberedsec 13.5.2(5): Storage Place Attributes
6088 @sp 1
6089 @cartouche
6090 If a component is represented using some form of pointer (such as an
6091 offset) to the actual data of the component, and this data is contiguous
6092 with the rest of the object, then the storage place attributes should
6093 reflect the place of the actual data, not the pointer.  If a component is
6094 allocated discontinuously from the rest of the object, then a warning
6095 should be generated upon reference to one of its storage place
6096 attributes.
6097 @end cartouche
6098 Followed.  There are no such components in GNAT@.
6099
6100 @cindex Bit ordering
6101 @unnumberedsec 13.5.3(7-8): Bit Ordering
6102 @sp 1
6103 @cartouche
6104 The recommended level of support for the non-default bit ordering is:
6105 @end cartouche
6106 @sp 1
6107 @cartouche
6108 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6109 should support the non-default bit ordering in addition to the default
6110 bit ordering.
6111 @end cartouche
6112 Followed.  Word size does not equal storage size in this implementation.
6113 Thus non-default bit ordering is not supported.
6114
6115 @cindex @code{Address}, as private type
6116 @unnumberedsec 13.7(37): Address as Private
6117 @sp 1
6118 @cartouche
6119 @code{Address} should be of a private type.
6120 @end cartouche
6121 Followed.
6122
6123 @cindex Operations, on @code{Address}
6124 @cindex @code{Address}, operations of
6125 @unnumberedsec 13.7.1(16): Address Operations
6126 @sp 1
6127 @cartouche
6128 Operations in @code{System} and its children should reflect the target
6129 environment semantics as closely as is reasonable.  For example, on most
6130 machines, it makes sense for address arithmetic to ``wrap around''.
6131 Operations that do not make sense should raise @code{Program_Error}.
6132 @end cartouche
6133 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6134 operation raises @code{Program_Error}, since all operations make sense.
6135
6136 @cindex Unchecked conversion
6137 @unnumberedsec 13.9(14-17): Unchecked Conversion
6138 @sp 1
6139 @cartouche
6140 The @code{Size} of an array object should not include its bounds; hence,
6141 the bounds should not be part of the converted data.
6142 @end cartouche
6143 Followed.
6144
6145 @sp 1
6146 @cartouche
6147 The implementation should not generate unnecessary run-time checks to
6148 ensure that the representation of @var{S} is a representation of the
6149 target type.  It should take advantage of the permission to return by
6150 reference when possible.  Restrictions on unchecked conversions should be
6151 avoided unless required by the target environment.
6152 @end cartouche
6153 Followed.  There are no restrictions on unchecked conversion.  A warning is
6154 generated if the source and target types do not have the same size since
6155 the semantics in this case may be target dependent.
6156
6157 @sp 1
6158 @cartouche
6159 The recommended level of support for unchecked conversions is:
6160 @end cartouche
6161 @sp 1
6162 @cartouche
6163 Unchecked conversions should be supported and should be reversible in
6164 the cases where this clause defines the result.  To enable meaningful use
6165 of unchecked conversion, a contiguous representation should be used for
6166 elementary subtypes, for statically constrained array subtypes whose
6167 component subtype is one of the subtypes described in this paragraph,
6168 and for record subtypes without discriminants whose component subtypes
6169 are described in this paragraph.
6170 @end cartouche
6171 Followed.
6172
6173 @cindex Heap usage, implicit
6174 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6175 @sp 1
6176 @cartouche
6177 An implementation should document any cases in which it dynamically
6178 allocates heap storage for a purpose other than the evaluation of an
6179 allocator.
6180 @end cartouche
6181 Followed, the only other points at which heap storage is dynamically
6182 allocated are as follows:
6183
6184 @itemize @bullet
6185 @item
6186 At initial elaboration time, to allocate dynamically sized global
6187 objects.
6188
6189 @item
6190 To allocate space for a task when a task is created.
6191
6192 @item
6193 To extend the secondary stack dynamically when needed.  The secondary
6194 stack is used for returning variable length results.
6195 @end itemize
6196
6197 @sp 1
6198 @cartouche
6199 A default (implementation-provided) storage pool for an
6200 access-to-constant type should not have overhead to support deallocation of
6201 individual objects.
6202 @end cartouche
6203 Followed.
6204
6205 @sp 1
6206 @cartouche
6207 A storage pool for an anonymous access type should be created at the
6208 point of an allocator for the type, and be reclaimed when the designated
6209 object becomes inaccessible.
6210 @end cartouche
6211 Followed.
6212
6213 @cindex Unchecked deallocation
6214 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6215 @sp 1
6216 @cartouche
6217 For a standard storage pool, @code{Free} should actually reclaim the
6218 storage.
6219 @end cartouche
6220 Followed.
6221
6222 @cindex Stream oriented attributes
6223 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6224 @sp 1
6225 @cartouche
6226 If a stream element is the same size as a storage element, then the
6227 normal in-memory representation should be used by @code{Read} and
6228 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6229 should use the smallest number of stream elements needed to represent
6230 all values in the base range of the scalar type.
6231 @end cartouche
6232
6233 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6234 which specifies using the size of the first subtype.
6235 However, such an implementation is based on direct binary
6236 representations and is therefore target- and endianness-dependent.
6237 To address this issue, GNAT also supplies an alternate implementation
6238 of the stream attributes @code{Read} and @code{Write},
6239 which uses the target-independent XDR standard representation
6240 for scalar types.
6241 @cindex XDR representation
6242 @cindex @code{Read} attribute
6243 @cindex @code{Write} attribute
6244 @cindex Stream oriented attributes
6245 The XDR implementation is provided as an alternative body of the
6246 @code{System.Stream_Attributes} package, in the file
6247 @file{s-strxdr.adb} in the GNAT library.
6248 There is no @file{s-strxdr.ads} file.
6249 In order to install the XDR implementation, do the following:
6250 @enumerate
6251 @item Replace the default implementation of the
6252 @code{System.Stream_Attributes} package with the XDR implementation.
6253 For example on a Unix platform issue the commands:
6254 @smallexample
6255 $ mv s-stratt.adb s-strold.adb
6256 $ mv s-strxdr.adb s-stratt.adb
6257 @end smallexample
6258
6259 @item
6260 Rebuild the GNAT run-time library as documented in the
6261 @cite{GNAT User's Guide}
6262 @end enumerate
6263
6264 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6265 @sp 1
6266 @cartouche
6267 If an implementation provides additional named predefined integer types,
6268 then the names should end with @samp{Integer} as in
6269 @samp{Long_Integer}.  If an implementation provides additional named
6270 predefined floating point types, then the names should end with
6271 @samp{Float} as in @samp{Long_Float}.
6272 @end cartouche
6273 Followed.
6274
6275 @findex Ada.Characters.Handling
6276 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6277 @sp 1
6278 @cartouche
6279 If an implementation provides a localized definition of @code{Character}
6280 or @code{Wide_Character}, then the effects of the subprograms in
6281 @code{Characters.Handling} should reflect the localizations.  See also
6282 3.5.2.
6283 @end cartouche
6284 Followed.  GNAT provides no such localized definitions.
6285
6286 @cindex Bounded-length strings
6287 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6288 @sp 1
6289 @cartouche
6290 Bounded string objects should not be implemented by implicit pointers
6291 and dynamic allocation.
6292 @end cartouche
6293 Followed.  No implicit pointers or dynamic allocation are used.
6294
6295 @cindex Random number generation
6296 @unnumberedsec A.5.2(46-47): Random Number Generation
6297 @sp 1
6298 @cartouche
6299 Any storage associated with an object of type @code{Generator} should be
6300 reclaimed on exit from the scope of the object.
6301 @end cartouche
6302 Followed.
6303
6304 @sp 1
6305 @cartouche
6306 If the generator period is sufficiently long in relation to the number
6307 of distinct initiator values, then each possible value of
6308 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6309 random numbers that does not, in a practical sense, overlap the sequence
6310 initiated by any other value.  If this is not possible, then the mapping
6311 between initiator values and generator states should be a rapidly
6312 varying function of the initiator value.
6313 @end cartouche
6314 Followed.  The generator period is sufficiently long for the first
6315 condition here to hold true.
6316
6317 @findex Get_Immediate
6318 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6319 @sp 1
6320 @cartouche
6321 The @code{Get_Immediate} procedures should be implemented with
6322 unbuffered input.  For a device such as a keyboard, input should be
6323 @dfn{available} if a key has already been typed, whereas for a disk
6324 file, input should always be available except at end of file.  For a file
6325 associated with a keyboard-like device, any line-editing features of the
6326 underlying operating system should be disabled during the execution of
6327 @code{Get_Immediate}.
6328 @end cartouche
6329 Followed on all targets except VxWorks. For VxWorks, there is no way to
6330 provide this functionality that does not result in the input buffer being
6331 flushed before the @code{Get_Immediate} call. A special unit
6332 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6333 this functionality.
6334
6335 @findex Export
6336 @unnumberedsec B.1(39-41): Pragma @code{Export}
6337 @sp 1
6338 @cartouche
6339 If an implementation supports pragma @code{Export} to a given language,
6340 then it should also allow the main subprogram to be written in that
6341 language.  It should support some mechanism for invoking the elaboration
6342 of the Ada library units included in the system, and for invoking the
6343 finalization of the environment task.  On typical systems, the
6344 recommended mechanism is to provide two subprograms whose link names are
6345 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6346 elaboration code for library units.  @code{adafinal} should contain the
6347 finalization code.  These subprograms should have no effect the second
6348 and subsequent time they are called.
6349 @end cartouche
6350 Followed.
6351
6352 @sp 1
6353 @cartouche
6354 Automatic elaboration of pre-elaborated packages should be
6355 provided when pragma @code{Export} is supported.
6356 @end cartouche
6357 Followed when the main program is in Ada.  If the main program is in a
6358 foreign language, then
6359 @code{adainit} must be called to elaborate pre-elaborated
6360 packages.
6361
6362 @sp 1
6363 @cartouche
6364 For each supported convention @var{L} other than @code{Intrinsic}, an
6365 implementation should support @code{Import} and @code{Export} pragmas
6366 for objects of @var{L}-compatible types and for subprograms, and pragma
6367 @code{Convention} for @var{L}-eligible types and for subprograms,
6368 presuming the other language has corresponding features.  Pragma
6369 @code{Convention} need not be supported for scalar types.
6370 @end cartouche
6371 Followed.
6372
6373 @cindex Package @code{Interfaces}
6374 @findex Interfaces
6375 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6376 @sp 1
6377 @cartouche
6378 For each implementation-defined convention identifier, there should be a
6379 child package of package Interfaces with the corresponding name.  This
6380 package should contain any declarations that would be useful for
6381 interfacing to the language (implementation) represented by the
6382 convention.  Any declarations useful for interfacing to any language on
6383 the given hardware architecture should be provided directly in
6384 @code{Interfaces}.
6385 @end cartouche
6386 Followed. An additional package not defined
6387 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6388 for interfacing to C++.
6389
6390 @sp 1
6391 @cartouche
6392 An implementation supporting an interface to C, COBOL, or Fortran should
6393 provide the corresponding package or packages described in the following
6394 clauses.
6395 @end cartouche
6396 Followed.  GNAT provides all the packages described in this section.
6397
6398 @cindex C, interfacing with
6399 @unnumberedsec B.3(63-71): Interfacing with C
6400 @sp 1
6401 @cartouche
6402 An implementation should support the following interface correspondences
6403 between Ada and C@.
6404 @end cartouche
6405 Followed.
6406
6407 @sp 1
6408 @cartouche
6409 An Ada procedure corresponds to a void-returning C function.
6410 @end cartouche
6411 Followed.
6412
6413 @sp 1
6414 @cartouche
6415 An Ada function corresponds to a non-void C function.
6416 @end cartouche
6417 Followed.
6418
6419 @sp 1
6420 @cartouche
6421 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6422 function.
6423 @end cartouche
6424 Followed.
6425
6426 @sp 1
6427 @cartouche
6428 An Ada @code{in} parameter of an access-to-object type with designated
6429 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6430 where @var{t} is the C type corresponding to the Ada type @var{T}.
6431 @end cartouche
6432 Followed.
6433
6434 @sp 1
6435 @cartouche
6436 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6437 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6438 argument to a C function, where @var{t} is the C type corresponding to
6439 the Ada type @var{T}.  In the case of an elementary @code{out} or
6440 @code{in out} parameter, a pointer to a temporary copy is used to
6441 preserve by-copy semantics.
6442 @end cartouche
6443 Followed.
6444
6445 @sp 1
6446 @cartouche
6447 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6448 @code{@var{t}*} argument to a C function, where @var{t} is the C
6449 structure corresponding to the Ada type @var{T}.
6450 @end cartouche
6451 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6452 pragma, or Convention, or by explicitly specifying the mechanism for a given
6453 call using an extended import or export pragma.
6454
6455 @sp 1
6456 @cartouche
6457 An Ada parameter of an array type with component type @var{T}, of any
6458 mode, is passed as a @code{@var{t}*} argument to a C function, where
6459 @var{t} is the C type corresponding to the Ada type @var{T}.
6460 @end cartouche
6461 Followed.
6462
6463 @sp 1
6464 @cartouche
6465 An Ada parameter of an access-to-subprogram type is passed as a pointer
6466 to a C function whose prototype corresponds to the designated
6467 subprogram's specification.
6468 @end cartouche
6469 Followed.
6470
6471 @cindex COBOL, interfacing with
6472 @unnumberedsec B.4(95-98): Interfacing with COBOL
6473 @sp 1
6474 @cartouche
6475 An Ada implementation should support the following interface
6476 correspondences between Ada and COBOL@.
6477 @end cartouche
6478 Followed.
6479
6480 @sp 1
6481 @cartouche
6482 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6483 the COBOL type corresponding to @var{T}.
6484 @end cartouche
6485 Followed.
6486
6487 @sp 1
6488 @cartouche
6489 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6490 the corresponding COBOL type.
6491 @end cartouche
6492 Followed.
6493
6494 @sp 1
6495 @cartouche
6496 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6497 COBOL type corresponding to the Ada parameter type; for scalars, a local
6498 copy is used if necessary to ensure by-copy semantics.
6499 @end cartouche
6500 Followed.
6501
6502 @cindex Fortran, interfacing with
6503 @unnumberedsec B.5(22-26): Interfacing with Fortran
6504 @sp 1
6505 @cartouche
6506 An Ada implementation should support the following interface
6507 correspondences between Ada and Fortran:
6508 @end cartouche
6509 Followed.
6510
6511 @sp 1
6512 @cartouche
6513 An Ada procedure corresponds to a Fortran subroutine.
6514 @end cartouche
6515 Followed.
6516
6517 @sp 1
6518 @cartouche
6519 An Ada function corresponds to a Fortran function.
6520 @end cartouche
6521 Followed.
6522
6523 @sp 1
6524 @cartouche
6525 An Ada parameter of an elementary, array, or record type @var{T} is
6526 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6527 the Fortran type corresponding to the Ada type @var{T}, and where the
6528 INTENT attribute of the corresponding dummy argument matches the Ada
6529 formal parameter mode; the Fortran implementation's parameter passing
6530 conventions are used.  For elementary types, a local copy is used if
6531 necessary to ensure by-copy semantics.
6532 @end cartouche
6533 Followed.
6534
6535 @sp 1
6536 @cartouche
6537 An Ada parameter of an access-to-subprogram type is passed as a
6538 reference to a Fortran procedure whose interface corresponds to the
6539 designated subprogram's specification.
6540 @end cartouche
6541 Followed.
6542
6543 @cindex Machine operations
6544 @unnumberedsec C.1(3-5): Access to Machine Operations
6545 @sp 1
6546 @cartouche
6547 The machine code or intrinsic support should allow access to all
6548 operations normally available to assembly language programmers for the
6549 target environment, including privileged instructions, if any.
6550 @end cartouche
6551 Followed.
6552
6553 @sp 1
6554 @cartouche
6555 The interfacing pragmas (see Annex B) should support interface to
6556 assembler; the default assembler should be associated with the
6557 convention identifier @code{Assembler}.
6558 @end cartouche
6559 Followed.
6560
6561 @sp 1
6562 @cartouche
6563 If an entity is exported to assembly language, then the implementation
6564 should allocate it at an addressable location, and should ensure that it
6565 is retained by the linking process, even if not otherwise referenced
6566 from the Ada code.  The implementation should assume that any call to a
6567 machine code or assembler subprogram is allowed to read or update every
6568 object that is specified as exported.
6569 @end cartouche
6570 Followed.
6571
6572 @unnumberedsec C.1(10-16): Access to Machine Operations
6573 @sp 1
6574 @cartouche
6575 The implementation should ensure that little or no overhead is
6576 associated with calling intrinsic and machine-code subprograms.
6577 @end cartouche
6578 Followed for both intrinsics and machine-code subprograms.
6579
6580 @sp 1
6581 @cartouche
6582 It is recommended that intrinsic subprograms be provided for convenient
6583 access to any machine operations that provide special capabilities or
6584 efficiency and that are not otherwise available through the language
6585 constructs.
6586 @end cartouche
6587 Followed.  A full set of machine operation intrinsic subprograms is provided.
6588
6589 @sp 1
6590 @cartouche
6591 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6592 swap, decrement and test, enqueue/dequeue.
6593 @end cartouche
6594 Followed on any target supporting such operations.
6595
6596 @sp 1
6597 @cartouche
6598 Standard numeric functions---e.g.@:, sin, log.
6599 @end cartouche
6600 Followed on any target supporting such operations.
6601
6602 @sp 1
6603 @cartouche
6604 String manipulation operations---e.g.@:, translate and test.
6605 @end cartouche
6606 Followed on any target supporting such operations.
6607
6608 @sp 1
6609 @cartouche
6610 Vector operations---e.g.@:, compare vector against thresholds.
6611 @end cartouche
6612 Followed on any target supporting such operations.
6613
6614 @sp 1
6615 @cartouche
6616 Direct operations on I/O ports.
6617 @end cartouche
6618 Followed on any target supporting such operations.
6619
6620 @cindex Interrupt support
6621 @unnumberedsec C.3(28): Interrupt Support
6622 @sp 1
6623 @cartouche
6624 If the @code{Ceiling_Locking} policy is not in effect, the
6625 implementation should provide means for the application to specify which
6626 interrupts are to be blocked during protected actions, if the underlying
6627 system allows for a finer-grain control of interrupt blocking.
6628 @end cartouche
6629 Followed.  The underlying system does not allow for finer-grain control
6630 of interrupt blocking.
6631
6632 @cindex Protected procedure handlers
6633 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6634 @sp 1
6635 @cartouche
6636 Whenever possible, the implementation should allow interrupt handlers to
6637 be called directly by the hardware.
6638 @end cartouche
6639 @c SGI info:
6640 @ignore
6641 This is never possible under IRIX, so this is followed by default.
6642 @end ignore
6643 Followed on any target where the underlying operating system permits
6644 such direct calls.
6645
6646 @sp 1
6647 @cartouche
6648 Whenever practical, violations of any
6649 implementation-defined restrictions should be detected before run time.
6650 @end cartouche
6651 Followed.  Compile time warnings are given when possible.
6652
6653 @cindex Package @code{Interrupts}
6654 @findex Interrupts
6655 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6656
6657 @sp 1
6658 @cartouche
6659 If implementation-defined forms of interrupt handler procedures are
6660 supported, such as protected procedures with parameters, then for each
6661 such form of a handler, a type analogous to @code{Parameterless_Handler}
6662 should be specified in a child package of @code{Interrupts}, with the
6663 same operations as in the predefined package Interrupts.
6664 @end cartouche
6665 Followed.
6666
6667 @cindex Pre-elaboration requirements
6668 @unnumberedsec C.4(14): Pre-elaboration Requirements
6669 @sp 1
6670 @cartouche
6671 It is recommended that pre-elaborated packages be implemented in such a
6672 way that there should be little or no code executed at run time for the
6673 elaboration of entities not already covered by the Implementation
6674 Requirements.
6675 @end cartouche
6676 Followed.  Executable code is generated in some cases, e.g.@: loops
6677 to initialize large arrays.
6678
6679 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6680
6681 @sp 1
6682 @cartouche
6683 If the pragma applies to an entity, then the implementation should
6684 reduce the amount of storage used for storing names associated with that
6685 entity.
6686 @end cartouche
6687 Followed.
6688
6689 @cindex Package @code{Task_Attributes}
6690 @findex Task_Attributes
6691 @unnumberedsec C.7.2(30): The Package Task_Attributes
6692 @sp 1
6693 @cartouche
6694 Some implementations are targeted to domains in which memory use at run
6695 time must be completely deterministic.  For such implementations, it is
6696 recommended that the storage for task attributes will be pre-allocated
6697 statically and not from the heap.  This can be accomplished by either
6698 placing restrictions on the number and the size of the task's
6699 attributes, or by using the pre-allocated storage for the first @var{N}
6700 attribute objects, and the heap for the others.  In the latter case,
6701 @var{N} should be documented.
6702 @end cartouche
6703 Not followed.  This implementation is not targeted to such a domain.
6704
6705 @cindex Locking Policies
6706 @unnumberedsec D.3(17): Locking Policies
6707
6708 @sp 1
6709 @cartouche
6710 The implementation should use names that end with @samp{_Locking} for
6711 locking policies defined by the implementation.
6712 @end cartouche
6713 Followed.  A single implementation-defined locking policy is defined,
6714 whose name (@code{Inheritance_Locking}) follows this suggestion.
6715
6716 @cindex Entry queuing policies
6717 @unnumberedsec D.4(16): Entry Queuing Policies
6718 @sp 1
6719 @cartouche
6720 Names that end with @samp{_Queuing} should be used
6721 for all implementation-defined queuing policies.
6722 @end cartouche
6723 Followed.  No such implementation-defined queuing policies exist.
6724
6725 @cindex Preemptive abort
6726 @unnumberedsec D.6(9-10): Preemptive Abort
6727 @sp 1
6728 @cartouche
6729 Even though the @code{abort_statement} is included in the list of
6730 potentially blocking operations (see 9.5.1), it is recommended that this
6731 statement be implemented in a way that never requires the task executing
6732 the @code{abort_statement} to block.
6733 @end cartouche
6734 Followed.
6735
6736 @sp 1
6737 @cartouche
6738 On a multi-processor, the delay associated with aborting a task on
6739 another processor should be bounded; the implementation should use
6740 periodic polling, if necessary, to achieve this.
6741 @end cartouche
6742 Followed.
6743
6744 @cindex Tasking restrictions
6745 @unnumberedsec D.7(21): Tasking Restrictions
6746 @sp 1
6747 @cartouche
6748 When feasible, the implementation should take advantage of the specified
6749 restrictions to produce a more efficient implementation.
6750 @end cartouche
6751 GNAT currently takes advantage of these restrictions by providing an optimized
6752 run time when the Ravenscar profile and the GNAT restricted run time set
6753 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6754 pragma @code{Profile (Restricted)} for more details.
6755
6756 @cindex Time, monotonic
6757 @unnumberedsec D.8(47-49): Monotonic Time
6758 @sp 1
6759 @cartouche
6760 When appropriate, implementations should provide configuration
6761 mechanisms to change the value of @code{Tick}.
6762 @end cartouche
6763 Such configuration mechanisms are not appropriate to this implementation
6764 and are thus not supported.
6765
6766 @sp 1
6767 @cartouche
6768 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6769 be implemented as transformations of the same time base.
6770 @end cartouche
6771 Followed.
6772
6773 @sp 1
6774 @cartouche
6775 It is recommended that the @dfn{best} time base which exists in
6776 the underlying system be available to the application through
6777 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6778 @end cartouche
6779 Followed.
6780
6781 @cindex Partition communication subsystem
6782 @cindex PCS
6783 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6784 @sp 1
6785 @cartouche
6786 Whenever possible, the PCS on the called partition should allow for
6787 multiple tasks to call the RPC-receiver with different messages and
6788 should allow them to block until the corresponding subprogram body
6789 returns.
6790 @end cartouche
6791 Followed by GLADE, a separately supplied PCS that can be used with
6792 GNAT.
6793
6794 @sp 1
6795 @cartouche
6796 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6797 should raise @code{Storage_Error} if it runs out of space trying to
6798 write the @code{Item} into the stream.
6799 @end cartouche
6800 Followed by GLADE, a separately supplied PCS that can be used with
6801 GNAT@.
6802
6803 @cindex COBOL support
6804 @unnumberedsec F(7): COBOL Support
6805 @sp 1
6806 @cartouche
6807 If COBOL (respectively, C) is widely supported in the target
6808 environment, implementations supporting the Information Systems Annex
6809 should provide the child package @code{Interfaces.COBOL} (respectively,
6810 @code{Interfaces.C}) specified in Annex B and should support a
6811 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6812 pragmas (see Annex B), thus allowing Ada programs to interface with
6813 programs written in that language.
6814 @end cartouche
6815 Followed.
6816
6817 @cindex Decimal radix support
6818 @unnumberedsec F.1(2): Decimal Radix Support
6819 @sp 1
6820 @cartouche
6821 Packed decimal should be used as the internal representation for objects
6822 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6823 @end cartouche
6824 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6825 representations.
6826
6827 @cindex Numerics
6828 @unnumberedsec G: Numerics
6829 @sp 2
6830 @cartouche
6831 If Fortran (respectively, C) is widely supported in the target
6832 environment, implementations supporting the Numerics Annex
6833 should provide the child package @code{Interfaces.Fortran} (respectively,
6834 @code{Interfaces.C}) specified in Annex B and should support a
6835 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6836 pragmas (see Annex B), thus allowing Ada programs to interface with
6837 programs written in that language.
6838 @end cartouche
6839 Followed.
6840
6841 @cindex Complex types
6842 @unnumberedsec G.1.1(56-58): Complex Types
6843 @sp 2
6844 @cartouche
6845 Because the usual mathematical meaning of multiplication of a complex
6846 operand and a real operand is that of the scaling of both components of
6847 the former by the latter, an implementation should not perform this
6848 operation by first promoting the real operand to complex type and then
6849 performing a full complex multiplication.  In systems that, in the
6850 future, support an Ada binding to IEC 559:1989, the latter technique
6851 will not generate the required result when one of the components of the
6852 complex operand is infinite.  (Explicit multiplication of the infinite
6853 component by the zero component obtained during promotion yields a NaN
6854 that propagates into the final result.) Analogous advice applies in the
6855 case of multiplication of a complex operand and a pure-imaginary
6856 operand, and in the case of division of a complex operand by a real or
6857 pure-imaginary operand.
6858 @end cartouche
6859 Not followed.
6860
6861 @sp 1
6862 @cartouche
6863 Similarly, because the usual mathematical meaning of addition of a
6864 complex operand and a real operand is that the imaginary operand remains
6865 unchanged, an implementation should not perform this operation by first
6866 promoting the real operand to complex type and then performing a full
6867 complex addition.  In implementations in which the @code{Signed_Zeros}
6868 attribute of the component type is @code{True} (and which therefore
6869 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6870 predefined arithmetic operations), the latter technique will not
6871 generate the required result when the imaginary component of the complex
6872 operand is a negatively signed zero.  (Explicit addition of the negative
6873 zero to the zero obtained during promotion yields a positive zero.)
6874 Analogous advice applies in the case of addition of a complex operand
6875 and a pure-imaginary operand, and in the case of subtraction of a
6876 complex operand and a real or pure-imaginary operand.
6877 @end cartouche
6878 Not followed.
6879
6880 @sp 1
6881 @cartouche
6882 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6883 attempt to provide a rational treatment of the signs of zero results and
6884 result components.  As one example, the result of the @code{Argument}
6885 function should have the sign of the imaginary component of the
6886 parameter @code{X} when the point represented by that parameter lies on
6887 the positive real axis; as another, the sign of the imaginary component
6888 of the @code{Compose_From_Polar} function should be the same as
6889 (respectively, the opposite of) that of the @code{Argument} parameter when that
6890 parameter has a value of zero and the @code{Modulus} parameter has a
6891 nonnegative (respectively, negative) value.
6892 @end cartouche
6893 Followed.
6894
6895 @cindex Complex elementary functions
6896 @unnumberedsec G.1.2(49): Complex Elementary Functions
6897 @sp 1
6898 @cartouche
6899 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6900 @code{True} should attempt to provide a rational treatment of the signs
6901 of zero results and result components.  For example, many of the complex
6902 elementary functions have components that are odd functions of one of
6903 the parameter components; in these cases, the result component should
6904 have the sign of the parameter component at the origin.  Other complex
6905 elementary functions have zero components whose sign is opposite that of
6906 a parameter component at the origin, or is always positive or always
6907 negative.
6908 @end cartouche
6909 Followed.
6910
6911 @cindex Accuracy requirements
6912 @unnumberedsec G.2.4(19): Accuracy Requirements
6913 @sp 1
6914 @cartouche
6915 The versions of the forward trigonometric functions without a
6916 @code{Cycle} parameter should not be implemented by calling the
6917 corresponding version with a @code{Cycle} parameter of
6918 @code{2.0*Numerics.Pi}, since this will not provide the required
6919 accuracy in some portions of the domain.  For the same reason, the
6920 version of @code{Log} without a @code{Base} parameter should not be
6921 implemented by calling the corresponding version with a @code{Base}
6922 parameter of @code{Numerics.e}.
6923 @end cartouche
6924 Followed.
6925
6926 @cindex Complex arithmetic accuracy
6927 @cindex Accuracy, complex arithmetic
6928 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6929
6930 @sp 1
6931 @cartouche
6932 The version of the @code{Compose_From_Polar} function without a
6933 @code{Cycle} parameter should not be implemented by calling the
6934 corresponding version with a @code{Cycle} parameter of
6935 @code{2.0*Numerics.Pi}, since this will not provide the required
6936 accuracy in some portions of the domain.
6937 @end cartouche
6938 Followed.
6939
6940 @c -----------------------------------------
6941 @node Implementation Defined Characteristics
6942 @chapter Implementation Defined Characteristics
6943
6944 @noindent
6945 In addition to the implementation dependent pragmas and attributes, and
6946 the implementation advice, there are a number of other Ada features
6947 that are potentially implementation dependent.  These are mentioned
6948 throughout the Ada Reference Manual, and are summarized in annex M@.
6949
6950 A requirement for conforming Ada compilers is that they provide
6951 documentation describing how the implementation deals with each of these
6952 issues.  In this chapter, you will find each point in annex M listed
6953 followed by a description in italic font of how GNAT
6954 @c SGI info:
6955 @ignore
6956 in the ProDev Ada
6957 implementation on IRIX 5.3 operating system or greater
6958 @end ignore
6959 handles the implementation dependence.
6960
6961 You can use this chapter as a guide to minimizing implementation
6962 dependent features in your programs if portability to other compilers
6963 and other operating systems is an important consideration.  The numbers
6964 in each section below correspond to the paragraph number in the Ada
6965 Reference Manual.
6966
6967 @sp 1
6968 @cartouche
6969 @noindent
6970 @strong{2}.  Whether or not each recommendation given in Implementation
6971 Advice is followed.  See 1.1.2(37).
6972 @end cartouche
6973 @noindent
6974 @xref{Implementation Advice}.
6975
6976 @sp 1
6977 @cartouche
6978 @noindent
6979 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6980 @end cartouche
6981 @noindent
6982 The complexity of programs that can be processed is limited only by the
6983 total amount of available virtual memory, and disk space for the
6984 generated object files.
6985
6986 @sp 1
6987 @cartouche
6988 @noindent
6989 @strong{4}.  Variations from the standard that are impractical to avoid
6990 given the implementation's execution environment.  See 1.1.3(6).
6991 @end cartouche
6992 @noindent
6993 There are no variations from the standard.
6994
6995 @sp 1
6996 @cartouche
6997 @noindent
6998 @strong{5}.  Which @code{code_statement}s cause external
6999 interactions.  See 1.1.3(10).
7000 @end cartouche
7001 @noindent
7002 Any @code{code_statement} can potentially cause external interactions.
7003
7004 @sp 1
7005 @cartouche
7006 @noindent
7007 @strong{6}.  The coded representation for the text of an Ada
7008 program.  See 2.1(4).
7009 @end cartouche
7010 @noindent
7011 See separate section on source representation.
7012
7013 @sp 1
7014 @cartouche
7015 @noindent
7016 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7017 @end cartouche
7018 @noindent
7019 See separate section on source representation.
7020
7021 @sp 1
7022 @cartouche
7023 @noindent
7024 @strong{8}.  The representation for an end of line.  See 2.2(2).
7025 @end cartouche
7026 @noindent
7027 See separate section on source representation.
7028
7029 @sp 1
7030 @cartouche
7031 @noindent
7032 @strong{9}.  Maximum supported line length and lexical element
7033 length.  See 2.2(15).
7034 @end cartouche
7035 @noindent
7036 The maximum line length is 255 characters an the maximum length of a
7037 lexical element is also 255 characters.
7038
7039 @sp 1
7040 @cartouche
7041 @noindent
7042 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7043 @end cartouche
7044 @noindent
7045
7046 @xref{Implementation Defined Pragmas}.
7047
7048 @sp 1
7049 @cartouche
7050 @noindent
7051 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7052 @end cartouche
7053 @noindent
7054 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7055 parameter, checks that the optimization flag is set, and aborts if it is
7056 not.
7057
7058 @sp 1
7059 @cartouche
7060 @noindent
7061 @strong{12}.  The sequence of characters of the value returned by
7062 @code{@var{S}'Image} when some of the graphic characters of
7063 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7064 3.5(37).
7065 @end cartouche
7066 @noindent
7067 The sequence of characters is as defined by the wide character encoding
7068 method used for the source.  See section on source representation for
7069 further details.
7070
7071 @sp 1
7072 @cartouche
7073 @noindent
7074 @strong{13}.  The predefined integer types declared in
7075 @code{Standard}.  See 3.5.4(25).
7076 @end cartouche
7077 @noindent
7078 @table @code
7079 @item Short_Short_Integer
7080 8 bit signed
7081 @item Short_Integer
7082 (Short) 16 bit signed
7083 @item Integer
7084 32 bit signed
7085 @item Long_Integer
7086 64 bit signed (Alpha OpenVMS only)
7087 32 bit signed (all other targets)
7088 @item Long_Long_Integer
7089 64 bit signed
7090 @end table
7091
7092 @sp 1
7093 @cartouche
7094 @noindent
7095 @strong{14}.  Any nonstandard integer types and the operators defined
7096 for them.  See 3.5.4(26).
7097 @end cartouche
7098 @noindent
7099 There are no nonstandard integer types.
7100
7101 @sp 1
7102 @cartouche
7103 @noindent
7104 @strong{15}.  Any nonstandard real types and the operators defined for
7105 them.  See 3.5.6(8).
7106 @end cartouche
7107 @noindent
7108 There are no nonstandard real types.
7109
7110 @sp 1
7111 @cartouche
7112 @noindent
7113 @strong{16}.  What combinations of requested decimal precision and range
7114 are supported for floating point types.  See 3.5.7(7).
7115 @end cartouche
7116 @noindent
7117 The precision and range is as defined by the IEEE standard.
7118
7119 @sp 1
7120 @cartouche
7121 @noindent
7122 @strong{17}.  The predefined floating point types declared in
7123 @code{Standard}.  See 3.5.7(16).
7124 @end cartouche
7125 @noindent
7126 @table @code
7127 @item Short_Float
7128 32 bit IEEE short
7129 @item Float
7130 (Short) 32 bit IEEE short
7131 @item Long_Float
7132 64 bit IEEE long
7133 @item Long_Long_Float
7134 64 bit IEEE long (80 bit IEEE long on x86 processors)
7135 @end table
7136
7137 @sp 1
7138 @cartouche
7139 @noindent
7140 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7141 @end cartouche
7142 @noindent
7143 @code{Fine_Delta} is 2**(@minus{}63)
7144
7145 @sp 1
7146 @cartouche
7147 @noindent
7148 @strong{19}.  What combinations of small, range, and digits are
7149 supported for fixed point types.  See 3.5.9(10).
7150 @end cartouche
7151 @noindent
7152 Any combinations are permitted that do not result in a small less than
7153 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7154 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7155 is 64 bits (true of all architectures except ia32), then the output from
7156 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7157 is because floating-point conversions are used to convert fixed point.
7158
7159 @sp 1
7160 @cartouche
7161 @noindent
7162 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7163 within an unnamed @code{block_statement}.  See 3.9(10).
7164 @end cartouche
7165 @noindent
7166 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7167 decimal integer are allocated.
7168
7169 @sp 1
7170 @cartouche
7171 @noindent
7172 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7173 @end cartouche
7174 @noindent
7175 @xref{Implementation Defined Attributes}.
7176
7177 @sp 1
7178 @cartouche
7179 @noindent
7180 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7181 @end cartouche
7182 @noindent
7183 There are no implementation-defined time types.
7184
7185 @sp 1
7186 @cartouche
7187 @noindent
7188 @strong{23}.  The time base associated with relative delays.
7189 @end cartouche
7190 @noindent
7191 See 9.6(20).  The time base used is that provided by the C library
7192 function @code{gettimeofday}.
7193
7194 @sp 1
7195 @cartouche
7196 @noindent
7197 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7198 9.6(23).
7199 @end cartouche
7200 @noindent
7201 The time base used is that provided by the C library function
7202 @code{gettimeofday}.
7203
7204 @sp 1
7205 @cartouche
7206 @noindent
7207 @strong{25}.  The time zone used for package @code{Calendar}
7208 operations.  See 9.6(24).
7209 @end cartouche
7210 @noindent
7211 The time zone used by package @code{Calendar} is the current system time zone
7212 setting for local time, as accessed by the C library function
7213 @code{localtime}.
7214
7215 @sp 1
7216 @cartouche
7217 @noindent
7218 @strong{26}.  Any limit on @code{delay_until_statements} of
7219 @code{select_statements}.  See 9.6(29).
7220 @end cartouche
7221 @noindent
7222 There are no such limits.
7223
7224 @sp 1
7225 @cartouche
7226 @noindent
7227 @strong{27}.  Whether or not two non overlapping parts of a composite
7228 object are independently addressable, in the case where packing, record
7229 layout, or @code{Component_Size} is specified for the object.  See
7230 9.10(1).
7231 @end cartouche
7232 @noindent
7233 Separate components are independently addressable if they do not share
7234 overlapping storage units.
7235
7236 @sp 1
7237 @cartouche
7238 @noindent
7239 @strong{28}.  The representation for a compilation.  See 10.1(2).
7240 @end cartouche
7241 @noindent
7242 A compilation is represented by a sequence of files presented to the
7243 compiler in a single invocation of the @code{gcc} command.
7244
7245 @sp 1
7246 @cartouche
7247 @noindent
7248 @strong{29}.  Any restrictions on compilations that contain multiple
7249 compilation_units.  See 10.1(4).
7250 @end cartouche
7251 @noindent
7252 No single file can contain more than one compilation unit, but any
7253 sequence of files can be presented to the compiler as a single
7254 compilation.
7255
7256 @sp 1
7257 @cartouche
7258 @noindent
7259 @strong{30}.  The mechanisms for creating an environment and for adding
7260 and replacing compilation units.  See 10.1.4(3).
7261 @end cartouche
7262 @noindent
7263 See separate section on compilation model.
7264
7265 @sp 1
7266 @cartouche
7267 @noindent
7268 @strong{31}.  The manner of explicitly assigning library units to a
7269 partition.  See 10.2(2).
7270 @end cartouche
7271 @noindent
7272 If a unit contains an Ada main program, then the Ada units for the partition
7273 are determined by recursive application of the rules in the Ada Reference
7274 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7275 are needed by the main program, and then this definition of need is applied
7276 recursively to those units, and the partition contains the transitive
7277 closure determined by this relationship.  In short, all the necessary units
7278 are included, with no need to explicitly specify the list.  If additional
7279 units are required, e.g.@: by foreign language units, then all units must be
7280 mentioned in the context clause of one of the needed Ada units.
7281
7282 If the partition contains no main program, or if the main program is in
7283 a language other than Ada, then GNAT
7284 provides the binder options @code{-z} and @code{-n} respectively, and in
7285 this case a list of units can be explicitly supplied to the binder for
7286 inclusion in the partition (all units needed by these units will also
7287 be included automatically).  For full details on the use of these
7288 options, refer to the @cite{GNAT User's Guide} sections on Binding
7289 and Linking.
7290
7291 @sp 1
7292 @cartouche
7293 @noindent
7294 @strong{32}.  The implementation-defined means, if any, of specifying
7295 which compilation units are needed by a given compilation unit.  See
7296 10.2(2).
7297 @end cartouche
7298 @noindent
7299 The units needed by a given compilation unit are as defined in
7300 the Ada Reference Manual section 10.2(2-6).  There are no
7301 implementation-defined pragmas or other implementation-defined
7302 means for specifying needed units.
7303
7304 @sp 1
7305 @cartouche
7306 @noindent
7307 @strong{33}.  The manner of designating the main subprogram of a
7308 partition.  See 10.2(7).
7309 @end cartouche
7310 @noindent
7311 The main program is designated by providing the name of the
7312 corresponding @file{ALI} file as the input parameter to the binder.
7313
7314 @sp 1
7315 @cartouche
7316 @noindent
7317 @strong{34}.  The order of elaboration of @code{library_items}.  See
7318 10.2(18).
7319 @end cartouche
7320 @noindent
7321 The first constraint on ordering is that it meets the requirements of
7322 Chapter 10 of the Ada Reference Manual.  This still leaves some
7323 implementation dependent choices, which are resolved by first
7324 elaborating bodies as early as possible (i.e., in preference to specs
7325 where there is a choice), and second by evaluating the immediate with
7326 clauses of a unit to determine the probably best choice, and
7327 third by elaborating in alphabetical order of unit names
7328 where a choice still remains.
7329
7330 @sp 1
7331 @cartouche
7332 @noindent
7333 @strong{35}.  Parameter passing and function return for the main
7334 subprogram.  See 10.2(21).
7335 @end cartouche
7336 @noindent
7337 The main program has no parameters.  It may be a procedure, or a function
7338 returning an integer type.  In the latter case, the returned integer
7339 value is the return code of the program (overriding any value that
7340 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7341
7342 @sp 1
7343 @cartouche
7344 @noindent
7345 @strong{36}.  The mechanisms for building and running partitions.  See
7346 10.2(24).
7347 @end cartouche
7348 @noindent
7349 GNAT itself supports programs with only a single partition.  The GNATDIST
7350 tool provided with the GLADE package (which also includes an implementation
7351 of the PCS) provides a completely flexible method for building and running
7352 programs consisting of multiple partitions.  See the separate GLADE manual
7353 for details.
7354
7355 @sp 1
7356 @cartouche
7357 @noindent
7358 @strong{37}.  The details of program execution, including program
7359 termination.  See 10.2(25).
7360 @end cartouche
7361 @noindent
7362 See separate section on compilation model.
7363
7364 @sp 1
7365 @cartouche
7366 @noindent
7367 @strong{38}.  The semantics of any non-active partitions supported by the
7368 implementation.  See 10.2(28).
7369 @end cartouche
7370 @noindent
7371 Passive partitions are supported on targets where shared memory is
7372 provided by the operating system.  See the GLADE reference manual for
7373 further details.
7374
7375 @sp 1
7376 @cartouche
7377 @noindent
7378 @strong{39}.  The information returned by @code{Exception_Message}.  See
7379 11.4.1(10).
7380 @end cartouche
7381 @noindent
7382 Exception message returns the null string unless a specific message has
7383 been passed by the program.
7384
7385 @sp 1
7386 @cartouche
7387 @noindent
7388 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7389 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7390 @end cartouche
7391 @noindent
7392 Blocks have implementation defined names of the form @code{B@var{nnn}}
7393 where @var{nnn} is an integer.
7394
7395 @sp 1
7396 @cartouche
7397 @noindent
7398 @strong{41}.  The information returned by
7399 @code{Exception_Information}.  See 11.4.1(13).
7400 @end cartouche
7401 @noindent
7402 @code{Exception_Information} returns a string in the following format:
7403
7404 @smallexample
7405 @emph{Exception_Name:} nnnnn
7406 @emph{Message:} mmmmm
7407 @emph{PID:} ppp
7408 @emph{Call stack traceback locations:}
7409 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7410 @end smallexample
7411
7412 @noindent
7413 where
7414
7415 @itemize @bullet
7416 @item
7417 @code{nnnn} is the fully qualified name of the exception in all upper
7418 case letters. This line is always present.
7419
7420 @item
7421 @code{mmmm} is the message (this line present only if message is non-null)
7422
7423 @item
7424 @code{ppp} is the Process Id value as a decimal integer (this line is
7425 present only if the Process Id is nonzero). Currently we are
7426 not making use of this field.
7427
7428 @item
7429 The Call stack traceback locations line and the following values
7430 are present only if at least one traceback location was recorded.
7431 The values are given in C style format, with lower case letters
7432 for a-f, and only as many digits present as are necessary.
7433 @end itemize
7434
7435 @noindent
7436 The line terminator sequence at the end of each line, including
7437 the last line is a single @code{LF} character (@code{16#0A#}).
7438
7439 @sp 1
7440 @cartouche
7441 @noindent
7442 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7443 @end cartouche
7444 @noindent
7445 The implementation defined check name Alignment_Check controls checking of
7446 address clause values for proper alignment (that is, the address supplied
7447 must be consistent with the alignment of the type).
7448
7449 In addition, a user program can add implementation-defined check names
7450 by means of the pragma Check_Name.
7451
7452 @sp 1
7453 @cartouche
7454 @noindent
7455 @strong{43}.  The interpretation of each aspect of representation.  See
7456 13.1(20).
7457 @end cartouche
7458 @noindent
7459 See separate section on data representations.
7460
7461 @sp 1
7462 @cartouche
7463 @noindent
7464 @strong{44}.  Any restrictions placed upon representation items.  See
7465 13.1(20).
7466 @end cartouche
7467 @noindent
7468 See separate section on data representations.
7469
7470 @sp 1
7471 @cartouche
7472 @noindent
7473 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7474 13.3(48).
7475 @end cartouche
7476 @noindent
7477 Size for an indefinite subtype is the maximum possible size, except that
7478 for the case of a subprogram parameter, the size of the parameter object
7479 is the actual size.
7480
7481 @sp 1
7482 @cartouche
7483 @noindent
7484 @strong{46}.  The default external representation for a type tag.  See
7485 13.3(75).
7486 @end cartouche
7487 @noindent
7488 The default external representation for a type tag is the fully expanded
7489 name of the type in upper case letters.
7490
7491 @sp 1
7492 @cartouche
7493 @noindent
7494 @strong{47}.  What determines whether a compilation unit is the same in
7495 two different partitions.  See 13.3(76).
7496 @end cartouche
7497 @noindent
7498 A compilation unit is the same in two different partitions if and only
7499 if it derives from the same source file.
7500
7501 @sp 1
7502 @cartouche
7503 @noindent
7504 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7505 @end cartouche
7506 @noindent
7507 The only implementation defined component is the tag for a tagged type,
7508 which contains a pointer to the dispatching table.
7509
7510 @sp 1
7511 @cartouche
7512 @noindent
7513 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7514 ordering.  See 13.5.3(5).
7515 @end cartouche
7516 @noindent
7517 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7518 implementation, so no non-default bit ordering is supported.  The default
7519 bit ordering corresponds to the natural endianness of the target architecture.
7520
7521 @sp 1
7522 @cartouche
7523 @noindent
7524 @strong{50}.  The contents of the visible part of package @code{System}
7525 and its language-defined children.  See 13.7(2).
7526 @end cartouche
7527 @noindent
7528 See the definition of these packages in files @file{system.ads} and
7529 @file{s-stoele.ads}.
7530
7531 @sp 1
7532 @cartouche
7533 @noindent
7534 @strong{51}.  The contents of the visible part of package
7535 @code{System.Machine_Code}, and the meaning of
7536 @code{code_statements}.  See 13.8(7).
7537 @end cartouche
7538 @noindent
7539 See the definition and documentation in file @file{s-maccod.ads}.
7540
7541 @sp 1
7542 @cartouche
7543 @noindent
7544 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7545 @end cartouche
7546 @noindent
7547 Unchecked conversion between types of the same size
7548 results in an uninterpreted transmission of the bits from one type
7549 to the other.  If the types are of unequal sizes, then in the case of
7550 discrete types, a shorter source is first zero or sign extended as
7551 necessary, and a shorter target is simply truncated on the left.
7552 For all non-discrete types, the source is first copied if necessary
7553 to ensure that the alignment requirements of the target are met, then
7554 a pointer is constructed to the source value, and the result is obtained
7555 by dereferencing this pointer after converting it to be a pointer to the
7556 target type. Unchecked conversions where the target subtype is an
7557 unconstrained array are not permitted. If the target alignment is
7558 greater than the source alignment, then a copy of the result is
7559 made with appropriate alignment
7560
7561 @sp 1
7562 @cartouche
7563 @noindent
7564 @strong{53}.  The manner of choosing a storage pool for an access type
7565 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7566 @end cartouche
7567 @noindent
7568 There are 3 different standard pools used by the compiler when
7569 @code{Storage_Pool} is not specified depending whether the type is local
7570 to a subprogram or defined at the library level and whether
7571 @code{Storage_Size}is specified or not.  See documentation in the runtime
7572 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7573 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7574 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7575 default pools used.
7576
7577 @sp 1
7578 @cartouche
7579 @noindent
7580 @strong{54}.  Whether or not the implementation provides user-accessible
7581 names for the standard pool type(s).  See 13.11(17).
7582 @end cartouche
7583 @noindent
7584
7585 See documentation in the sources of the run time mentioned in paragraph
7586 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7587 these units.
7588
7589 @sp 1
7590 @cartouche
7591 @noindent
7592 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7593 @end cartouche
7594 @noindent
7595 @code{Storage_Size} is measured in storage units, and refers to the
7596 total space available for an access type collection, or to the primary
7597 stack space for a task.
7598
7599 @sp 1
7600 @cartouche
7601 @noindent
7602 @strong{56}.  Implementation-defined aspects of storage pools.  See
7603 13.11(22).
7604 @end cartouche
7605 @noindent
7606 See documentation in the sources of the run time mentioned in paragraph
7607 @strong{53} for details on GNAT-defined aspects of storage pools.
7608
7609 @sp 1
7610 @cartouche
7611 @noindent
7612 @strong{57}.  The set of restrictions allowed in a pragma
7613 @code{Restrictions}.  See 13.12(7).
7614 @end cartouche
7615 @noindent
7616 All RM defined Restriction identifiers are implemented.  The following
7617 additional restriction identifiers are provided.  There are two separate
7618 lists of implementation dependent restriction identifiers.  The first
7619 set requires consistency throughout a partition (in other words, if the
7620 restriction identifier is used for any compilation unit in the partition,
7621 then all compilation units in the partition must obey the restriction.
7622
7623 @table @code
7624
7625 @item Simple_Barriers
7626 @findex Simple_Barriers
7627 This restriction ensures at compile time that barriers in entry declarations
7628 for protected types are restricted to either static boolean expressions or
7629 references to simple boolean variables defined in the private part of the
7630 protected type.  No other form of entry barriers is permitted.  This is one
7631 of the restrictions of the Ravenscar profile for limited tasking (see also
7632 pragma @code{Profile (Ravenscar)}).
7633
7634 @item Max_Entry_Queue_Length => Expr
7635 @findex Max_Entry_Queue_Length
7636 This restriction is a declaration that any protected entry compiled in
7637 the scope of the restriction has at most the specified number of
7638 tasks waiting on the entry
7639 at any one time, and so no queue is required.  This restriction is not
7640 checked at compile time.  A program execution is erroneous if an attempt
7641 is made to queue more than the specified number of tasks on such an entry.
7642
7643 @item No_Calendar
7644 @findex No_Calendar
7645 This restriction ensures at compile time that there is no implicit or
7646 explicit dependence on the package @code{Ada.Calendar}.
7647
7648 @item No_Direct_Boolean_Operators
7649 @findex No_Direct_Boolean_Operators
7650 This restriction ensures that no logical (and/or/xor) or comparison
7651 operators are used on operands of type Boolean (or any type derived
7652 from Boolean). This is intended for use in safety critical programs
7653 where the certification protocol requires the use of short-circuit
7654 (and then, or else) forms for all composite boolean operations.
7655
7656 @item No_Dispatching_Calls
7657 @findex No_Dispatching_Calls
7658 This restriction ensures at compile time that the code generated by the
7659 compiler involves no dispatching calls. The use of this restriction allows the
7660 safe use of record extensions, classwide membership tests and other classwide
7661 features not involving implicit dispatching. This restriction ensures that
7662 the code contains no indirect calls through a dispatching mechanism. Note that
7663 this includes internally-generated calls created by the compiler, for example
7664 in the implementation of class-wide objects assignments. The
7665 membership test is allowed in the presence of this restriction, because its
7666 implementation requires no dispatching.
7667 This restriction is comparable to the official Ada restriction
7668 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7669 all classwide constructs that do not imply dispatching.
7670 The following example indicates constructs that violate this restriction.
7671
7672 @smallexample
7673 package Pkg is
7674   type T is tagged record
7675     Data : Natural;
7676   end record;
7677   procedure P (X : T);
7678
7679   type DT is new T with record
7680     More_Data : Natural;
7681   end record;
7682   procedure Q (X : DT);
7683 end Pkg;
7684
7685 with Pkg; use Pkg;
7686 procedure Example is
7687   procedure Test (O : T'Class) is
7688     N : Natural  := O'Size;--  Error: Dispatching call
7689     C : T'Class := O;      --  Error: implicit Dispatching Call
7690   begin
7691     if O in DT'Class then  --  OK   : Membership test
7692        Q (DT (O));         --  OK   : Type conversion plus direct call
7693     else
7694        P (O);              --  Error: Dispatching call
7695     end if;
7696   end Test;
7697
7698   Obj : DT;
7699 begin
7700   P (Obj);                 --  OK   : Direct call
7701   P (T (Obj));             --  OK   : Type conversion plus direct call
7702   P (T'Class (Obj));       --  Error: Dispatching call
7703
7704   Test (Obj);              --  OK   : Type conversion
7705
7706   if Obj in T'Class then   --  OK   : Membership test
7707      null;
7708   end if;
7709 end Example;
7710 @end smallexample
7711
7712 @item No_Dynamic_Attachment
7713 @findex No_Dynamic_Attachment
7714 This restriction ensures that there is no call to any of the operations
7715 defined in package Ada.Interrupts.
7716
7717 @item No_Enumeration_Maps
7718 @findex No_Enumeration_Maps
7719 This restriction ensures at compile time that no operations requiring
7720 enumeration maps are used (that is Image and Value attributes applied
7721 to enumeration types).
7722
7723 @item No_Entry_Calls_In_Elaboration_Code
7724 @findex No_Entry_Calls_In_Elaboration_Code
7725 This restriction ensures at compile time that no task or protected entry
7726 calls are made during elaboration code.  As a result of the use of this
7727 restriction, the compiler can assume that no code past an accept statement
7728 in a task can be executed at elaboration time.
7729
7730 @item No_Exception_Handlers
7731 @findex No_Exception_Handlers
7732 This restriction ensures at compile time that there are no explicit
7733 exception handlers. It also indicates that no exception propagation will
7734 be provided. In this mode, exceptions may be raised but will result in
7735 an immediate call to the last chance handler, a routine that the user
7736 must define with the following profile:
7737
7738    procedure Last_Chance_Handler
7739      (Source_Location : System.Address; Line : Integer);
7740    pragma Export (C, Last_Chance_Handler,
7741                   "__gnat_last_chance_handler");
7742
7743    The parameter is a C null-terminated string representing a message to be
7744    associated with the exception (typically the source location of the raise
7745    statement generated by the compiler). The Line parameter when nonzero
7746    represents the line number in the source program where the raise occurs.
7747
7748 @item No_Exception_Propagation
7749 @findex No_Exception_Propagation
7750 This restriction guarantees that exceptions are never propagated to an outer
7751 subprogram scope). The only case in which an exception may be raised is when
7752 the handler is statically in the same subprogram, so that the effect of a raise
7753 is essentially like a goto statement. Any other raise statement (implicit or
7754 explicit) will be considered unhandled. Exception handlers are allowed, but may
7755 not contain an exception occurrence identifier (exception choice). In addition
7756 use of the package GNAT.Current_Exception is not permitted, and reraise
7757 statements (raise with no operand) are not permitted.
7758
7759 @item No_Exception_Registration
7760 @findex No_Exception_Registration
7761 This restriction ensures at compile time that no stream operations for
7762 types Exception_Id or Exception_Occurrence are used. This also makes it
7763 impossible to pass exceptions to or from a partition with this restriction
7764 in a distributed environment. If this exception is active, then the generated
7765 code is simplified by omitting the otherwise-required global registration
7766 of exceptions when they are declared.
7767
7768 @item No_Implicit_Conditionals
7769 @findex No_Implicit_Conditionals
7770 This restriction ensures that the generated code does not contain any
7771 implicit conditionals, either by modifying the generated code where possible,
7772 or by rejecting any construct that would otherwise generate an implicit
7773 conditional. Note that this check does not include run time constraint
7774 checks, which on some targets may generate implicit conditionals as
7775 well. To control the latter, constraint checks can be suppressed in the
7776 normal manner. Constructs generating implicit conditionals include comparisons
7777 of composite objects and the Max/Min attributes.
7778
7779 @item No_Implicit_Dynamic_Code
7780 @findex No_Implicit_Dynamic_Code
7781 This restriction prevents the compiler from building ``trampolines''.
7782 This is a structure that is built on the stack and contains dynamic
7783 code to be executed at run time. On some targets, a trampoline is
7784 built for the following features: @code{Access},
7785 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7786 nested task bodies; primitive operations of nested tagged types.
7787 Trampolines do not work on machines that prevent execution of stack
7788 data. For example, on windows systems, enabling DEP (data execution
7789 protection) will cause trampolines to raise an exception.
7790
7791 @item No_Implicit_Loops
7792 @findex No_Implicit_Loops
7793 This restriction ensures that the generated code does not contain any
7794 implicit @code{for} loops, either by modifying
7795 the generated code where possible,
7796 or by rejecting any construct that would otherwise generate an implicit
7797 @code{for} loop. If this restriction is active, it is possible to build
7798 large array aggregates with all static components without generating an
7799 intermediate temporary, and without generating a loop to initialize individual
7800 components..Otherwise, a loop is created for arrays larger than about 5000
7801 scalar components.
7802
7803 @item No_Initialize_Scalars
7804 @findex No_Initialize_Scalars
7805 This restriction ensures that no unit in the partition is compiled with
7806 pragma Initialize_Scalars. This allows the generation of more efficient
7807 code, and in particular eliminates dummy null initialization routines that
7808 are otherwise generated for some record and array types.
7809
7810 @item No_Local_Protected_Objects
7811 @findex No_Local_Protected_Objects
7812 This restriction ensures at compile time that protected objects are
7813 only declared at the library level.
7814
7815 @item No_Protected_Type_Allocators
7816 @findex No_Protected_Type_Allocators
7817 This restriction ensures at compile time that there are no allocator
7818 expressions that attempt to allocate protected objects.
7819
7820 @item No_Secondary_Stack
7821 @findex No_Secondary_Stack
7822 This restriction ensures at compile time that the generated code does not
7823 contain any reference to the secondary stack.  The secondary stack is used
7824 to implement functions returning unconstrained objects (arrays or records)
7825 on some targets.
7826
7827 @item No_Select_Statements
7828 @findex No_Select_Statements
7829 This restriction ensures at compile time no select statements of any kind
7830 are permitted, that is the keyword @code{select} may not appear.
7831 This is one of the restrictions of the Ravenscar
7832 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7833
7834 @item No_Standard_Storage_Pools
7835 @findex No_Standard_Storage_Pools
7836 This restriction ensures at compile time that no access types
7837 use the standard default storage pool.  Any access type declared must
7838 have an explicit Storage_Pool attribute defined specifying a
7839 user-defined storage pool.
7840
7841 @item No_Streams
7842 @findex No_Streams
7843 This restriction ensures at compile/bind time that there are no
7844 stream objects created (and therefore no actual stream operations).
7845 This restriction does not forbid dependences on the package
7846 @code{Ada.Streams}. So it is permissible to with
7847 @code{Ada.Streams} (or another package that does so itself)
7848 as long as no actual stream objects are created.
7849
7850 @item No_Task_Attributes_Package
7851 @findex No_Task_Attributes_Package
7852 This restriction ensures at compile time that there are no implicit or
7853 explicit dependencies on the package @code{Ada.Task_Attributes}.
7854
7855 @item No_Task_Termination
7856 @findex No_Task_Termination
7857 This restriction ensures at compile time that no terminate alternatives
7858 appear in any task body.
7859
7860 @item No_Tasking
7861 @findex No_Tasking
7862 This restriction prevents the declaration of tasks or task types throughout
7863 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7864 except that violations are caught at compile time and cause an error message
7865 to be output either by the compiler or binder.
7866
7867 @item Static_Priorities
7868 @findex Static_Priorities
7869 This restriction ensures at compile time that all priority expressions
7870 are static, and that there are no dependencies on the package
7871 @code{Ada.Dynamic_Priorities}.
7872
7873 @item Static_Storage_Size
7874 @findex Static_Storage_Size
7875 This restriction ensures at compile time that any expression appearing
7876 in a Storage_Size pragma or attribute definition clause is static.
7877
7878 @end table
7879
7880 @noindent
7881 The second set of implementation dependent restriction identifiers
7882 does not require partition-wide consistency.
7883 The restriction may be enforced for a single
7884 compilation unit without any effect on any of the
7885 other compilation units in the partition.
7886
7887 @table @code
7888
7889 @item No_Elaboration_Code
7890 @findex No_Elaboration_Code
7891 This restriction ensures at compile time that no elaboration code is
7892 generated.  Note that this is not the same condition as is enforced
7893 by pragma @code{Preelaborate}.  There are cases in which pragma
7894 @code{Preelaborate} still permits code to be generated (e.g.@: code
7895 to initialize a large array to all zeroes), and there are cases of units
7896 which do not meet the requirements for pragma @code{Preelaborate},
7897 but for which no elaboration code is generated.  Generally, it is
7898 the case that preelaborable units will meet the restrictions, with
7899 the exception of large aggregates initialized with an others_clause,
7900 and exception declarations (which generate calls to a run-time
7901 registry procedure).  This restriction is enforced on
7902 a unit by unit basis, it need not be obeyed consistently
7903 throughout a partition.
7904
7905 In the case of aggregates with others, if the aggregate has a dynamic
7906 size, there is no way to eliminate the elaboration code (such dynamic
7907 bounds would be incompatible with @code{Preelaborate} in any case). If
7908 the bounds are static, then use of this restriction actually modifies
7909 the code choice of the compiler to avoid generating a loop, and instead
7910 generate the aggregate statically if possible, no matter how many times
7911 the data for the others clause must be repeatedly generated.
7912
7913 It is not possible to precisely document
7914 the constructs which are compatible with this restriction, since,
7915 unlike most other restrictions, this is not a restriction on the
7916 source code, but a restriction on the generated object code. For
7917 example, if the source contains a declaration:
7918
7919 @smallexample
7920    Val : constant Integer := X;
7921 @end smallexample
7922
7923 @noindent
7924 where X is not a static constant, it may be possible, depending
7925 on complex optimization circuitry, for the compiler to figure
7926 out the value of X at compile time, in which case this initialization
7927 can be done by the loader, and requires no initialization code. It
7928 is not possible to document the precise conditions under which the
7929 optimizer can figure this out.
7930
7931 Note that this the implementation of this restriction requires full
7932 code generation. If it is used in conjunction with "semantics only"
7933 checking, then some cases of violations may be missed.
7934
7935 @item No_Entry_Queue
7936 @findex No_Entry_Queue
7937 This restriction is a declaration that any protected entry compiled in
7938 the scope of the restriction has at most one task waiting on the entry
7939 at any one time, and so no queue is required.  This restriction is not
7940 checked at compile time.  A program execution is erroneous if an attempt
7941 is made to queue a second task on such an entry.
7942
7943 @item No_Implementation_Attributes
7944 @findex No_Implementation_Attributes
7945 This restriction checks at compile time that no GNAT-defined attributes
7946 are present.  With this restriction, the only attributes that can be used
7947 are those defined in the Ada Reference Manual.
7948
7949 @item No_Implementation_Pragmas
7950 @findex No_Implementation_Pragmas
7951 This restriction checks at compile time that no GNAT-defined pragmas
7952 are present.  With this restriction, the only pragmas that can be used
7953 are those defined in the Ada Reference Manual.
7954
7955 @item No_Implementation_Restrictions
7956 @findex No_Implementation_Restrictions
7957 This restriction checks at compile time that no GNAT-defined restriction
7958 identifiers (other than @code{No_Implementation_Restrictions} itself)
7959 are present.  With this restriction, the only other restriction identifiers
7960 that can be used are those defined in the Ada Reference Manual.
7961
7962 @item No_Wide_Characters
7963 @findex No_Wide_Characters
7964 This restriction ensures at compile time that no uses of the types
7965 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7966 wide types
7967 appear, and that no wide or wide wide string or character literals
7968 appear in the program (that is literals representing characters not in
7969 type @code{Character}.
7970
7971 @end table
7972
7973 @sp 1
7974 @cartouche
7975 @noindent
7976 @strong{58}.  The consequences of violating limitations on
7977 @code{Restrictions} pragmas.  See 13.12(9).
7978 @end cartouche
7979 @noindent
7980 Restrictions that can be checked at compile time result in illegalities
7981 if violated.  Currently there are no other consequences of violating
7982 restrictions.
7983
7984 @sp 1
7985 @cartouche
7986 @noindent
7987 @strong{59}.  The representation used by the @code{Read} and
7988 @code{Write} attributes of elementary types in terms of stream
7989 elements.  See 13.13.2(9).
7990 @end cartouche
7991 @noindent
7992 The representation is the in-memory representation of the base type of
7993 the type, using the number of bits corresponding to the
7994 @code{@var{type}'Size} value, and the natural ordering of the machine.
7995
7996 @sp 1
7997 @cartouche
7998 @noindent
7999 @strong{60}.  The names and characteristics of the numeric subtypes
8000 declared in the visible part of package @code{Standard}.  See A.1(3).
8001 @end cartouche
8002 @noindent
8003 See items describing the integer and floating-point types supported.
8004
8005 @sp 1
8006 @cartouche
8007 @noindent
8008 @strong{61}.  The accuracy actually achieved by the elementary
8009 functions.  See A.5.1(1).
8010 @end cartouche
8011 @noindent
8012 The elementary functions correspond to the functions available in the C
8013 library.  Only fast math mode is implemented.
8014
8015 @sp 1
8016 @cartouche
8017 @noindent
8018 @strong{62}.  The sign of a zero result from some of the operators or
8019 functions in @code{Numerics.Generic_Elementary_Functions}, when
8020 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8021 @end cartouche
8022 @noindent
8023 The sign of zeroes follows the requirements of the IEEE 754 standard on
8024 floating-point.
8025
8026 @sp 1
8027 @cartouche
8028 @noindent
8029 @strong{63}.  The value of
8030 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8031 @end cartouche
8032 @noindent
8033 Maximum image width is 649, see library file @file{a-numran.ads}.
8034
8035 @sp 1
8036 @cartouche
8037 @noindent
8038 @strong{64}.  The value of
8039 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8040 @end cartouche
8041 @noindent
8042 Maximum image width is 80, see library file @file{a-nudira.ads}.
8043
8044 @sp 1
8045 @cartouche
8046 @noindent
8047 @strong{65}.  The algorithms for random number generation.  See
8048 A.5.2(32).
8049 @end cartouche
8050 @noindent
8051 The algorithm is documented in the source files @file{a-numran.ads} and
8052 @file{a-numran.adb}.
8053
8054 @sp 1
8055 @cartouche
8056 @noindent
8057 @strong{66}.  The string representation of a random number generator's
8058 state.  See A.5.2(38).
8059 @end cartouche
8060 @noindent
8061 See the documentation contained in the file @file{a-numran.adb}.
8062
8063 @sp 1
8064 @cartouche
8065 @noindent
8066 @strong{67}.  The minimum time interval between calls to the
8067 time-dependent Reset procedure that are guaranteed to initiate different
8068 random number sequences.  See A.5.2(45).
8069 @end cartouche
8070 @noindent
8071 The minimum period between reset calls to guarantee distinct series of
8072 random numbers is one microsecond.
8073
8074 @sp 1
8075 @cartouche
8076 @noindent
8077 @strong{68}.  The values of the @code{Model_Mantissa},
8078 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8079 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8080 Annex is not supported.  See A.5.3(72).
8081 @end cartouche
8082 @noindent
8083 See the source file @file{ttypef.ads} for the values of all numeric
8084 attributes.
8085
8086 @sp 1
8087 @cartouche
8088 @noindent
8089 @strong{69}.  Any implementation-defined characteristics of the
8090 input-output packages.  See A.7(14).
8091 @end cartouche
8092 @noindent
8093 There are no special implementation defined characteristics for these
8094 packages.
8095
8096 @sp 1
8097 @cartouche
8098 @noindent
8099 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8100 A.9(10).
8101 @end cartouche
8102 @noindent
8103 All type representations are contiguous, and the @code{Buffer_Size} is
8104 the value of @code{@var{type}'Size} rounded up to the next storage unit
8105 boundary.
8106
8107 @sp 1
8108 @cartouche
8109 @noindent
8110 @strong{71}.  External files for standard input, standard output, and
8111 standard error See A.10(5).
8112 @end cartouche
8113 @noindent
8114 These files are mapped onto the files provided by the C streams
8115 libraries.  See source file @file{i-cstrea.ads} for further details.
8116
8117 @sp 1
8118 @cartouche
8119 @noindent
8120 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8121 A.10.9(36).
8122 @end cartouche
8123 @noindent
8124 If more digits are requested in the output than are represented by the
8125 precision of the value, zeroes are output in the corresponding least
8126 significant digit positions.
8127
8128 @sp 1
8129 @cartouche
8130 @noindent
8131 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8132 @code{Command_Name}.  See A.15(1).
8133 @end cartouche
8134 @noindent
8135 These are mapped onto the @code{argv} and @code{argc} parameters of the
8136 main program in the natural manner.
8137
8138 @sp 1
8139 @cartouche
8140 @noindent
8141 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8142 @end cartouche
8143 @noindent
8144 The following convention names are supported
8145
8146 @table @code
8147 @item  Ada
8148 Ada
8149 @item Assembler
8150 Assembly language
8151 @item Asm
8152 Synonym for Assembler
8153 @item Assembly
8154 Synonym for Assembler
8155 @item C
8156 C
8157 @item C_Pass_By_Copy
8158 Allowed only for record types, like C, but also notes that record
8159 is to be passed by copy rather than reference.
8160 @item COBOL
8161 COBOL
8162 @item C_Plus_Plus (or CPP)
8163 C++
8164 @item Default
8165 Treated the same as C
8166 @item External
8167 Treated the same as C
8168 @item Fortran
8169 Fortran
8170 @item Intrinsic
8171 For support of pragma @code{Import} with convention Intrinsic, see
8172 separate section on Intrinsic Subprograms.
8173 @item Stdcall
8174 Stdcall (used for Windows implementations only).  This convention correspond
8175 to the WINAPI (previously called Pascal convention) C/C++ convention under
8176 Windows.  A function with this convention cleans the stack before exit.
8177 @item DLL
8178 Synonym for Stdcall
8179 @item Win32
8180 Synonym for Stdcall
8181 @item Stubbed
8182 Stubbed is a special convention used to indicate that the body of the
8183 subprogram will be entirely ignored.  Any call to the subprogram
8184 is converted into a raise of the @code{Program_Error} exception.  If a
8185 pragma @code{Import} specifies convention @code{stubbed} then no body need
8186 be present at all.  This convention is useful during development for the
8187 inclusion of subprograms whose body has not yet been written.
8188
8189 @end table
8190 @noindent
8191 In addition, all otherwise unrecognized convention names are also
8192 treated as being synonymous with convention C@.  In all implementations
8193 except for VMS, use of such other names results in a warning.  In VMS
8194 implementations, these names are accepted silently.
8195
8196 @sp 1
8197 @cartouche
8198 @noindent
8199 @strong{75}.  The meaning of link names.  See B.1(36).
8200 @end cartouche
8201 @noindent
8202 Link names are the actual names used by the linker.
8203
8204 @sp 1
8205 @cartouche
8206 @noindent
8207 @strong{76}.  The manner of choosing link names when neither the link
8208 name nor the address of an imported or exported entity is specified.  See
8209 B.1(36).
8210 @end cartouche
8211 @noindent
8212 The default linker name is that which would be assigned by the relevant
8213 external language, interpreting the Ada name as being in all lower case
8214 letters.
8215
8216 @sp 1
8217 @cartouche
8218 @noindent
8219 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8220 @end cartouche
8221 @noindent
8222 The string passed to @code{Linker_Options} is presented uninterpreted as
8223 an argument to the link command, unless it contains Ascii.NUL characters.
8224 NUL characters if they appear act as argument separators, so for example
8225
8226 @smallexample @c ada
8227 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8228 @end smallexample
8229
8230 @noindent
8231 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8232 linker. The order of linker options is preserved for a given unit. The final
8233 list of options passed to the linker is in reverse order of the elaboration
8234 order. For example, linker options fo a body always appear before the options
8235 from the corresponding package spec.
8236
8237 @sp 1
8238 @cartouche
8239 @noindent
8240 @strong{78}.  The contents of the visible part of package
8241 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8242 @end cartouche
8243 @noindent
8244 See files with prefix @file{i-} in the distributed library.
8245
8246 @sp 1
8247 @cartouche
8248 @noindent
8249 @strong{79}.  Implementation-defined children of package
8250 @code{Interfaces}.  The contents of the visible part of package
8251 @code{Interfaces}.  See B.2(11).
8252 @end cartouche
8253 @noindent
8254 See files with prefix @file{i-} in the distributed library.
8255
8256 @sp 1
8257 @cartouche
8258 @noindent
8259 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8260 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8261 @code{COBOL_Character}; and the initialization of the variables
8262 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8263 @code{Interfaces.COBOL}.  See B.4(50).
8264 @end cartouche
8265 @noindent
8266 @table @code
8267 @item Floating
8268 Float
8269 @item Long_Floating
8270 (Floating) Long_Float
8271 @item Binary
8272 Integer
8273 @item Long_Binary
8274 Long_Long_Integer
8275 @item Decimal_Element
8276 Character
8277 @item COBOL_Character
8278 Character
8279 @end table
8280
8281 @noindent
8282 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8283
8284 @sp 1
8285 @cartouche
8286 @noindent
8287 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8288 @end cartouche
8289 @noindent
8290 See documentation in file @file{s-maccod.ads} in the distributed library.
8291
8292 @sp 1
8293 @cartouche
8294 @noindent
8295 @strong{82}.  Implementation-defined aspects of access to machine
8296 operations.  See C.1(9).
8297 @end cartouche
8298 @noindent
8299 See documentation in file @file{s-maccod.ads} in the distributed library.
8300
8301 @sp 1
8302 @cartouche
8303 @noindent
8304 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8305 @end cartouche
8306 @noindent
8307 Interrupts are mapped to signals or conditions as appropriate.  See
8308 definition of unit
8309 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8310 on the interrupts supported on a particular target.
8311
8312 @sp 1
8313 @cartouche
8314 @noindent
8315 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8316 C.4(13).
8317 @end cartouche
8318 @noindent
8319 GNAT does not permit a partition to be restarted without reloading,
8320 except under control of the debugger.
8321
8322 @sp 1
8323 @cartouche
8324 @noindent
8325 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8326 @end cartouche
8327 @noindent
8328 Pragma @code{Discard_Names} causes names of enumeration literals to
8329 be suppressed.  In the presence of this pragma, the Image attribute
8330 provides the image of the Pos of the literal, and Value accepts
8331 Pos values.
8332
8333 @sp 1
8334 @cartouche
8335 @noindent
8336 @strong{86}.  The result of the @code{Task_Identification.Image}
8337 attribute.  See C.7.1(7).
8338 @end cartouche
8339 @noindent
8340 The result of this attribute is a string that identifies
8341 the object or component that denotes a given task. If a variable Var has a task
8342 type, the image for this task will have the form Var_XXXXXXXX, where the
8343 suffix
8344 is the hexadecimal representation of the virtual address of the corresponding
8345 task control block. If the variable is an array of tasks, the image of each
8346 task will have the form of an indexed component indicating the position of a
8347 given task in the array, eg.  Group(5)_XXXXXXX. If the task is a
8348 component of a record, the image of the task will have the form of a selected
8349 component. These rules are fully recursive, so that the image of a task that
8350 is a subcomponent of a composite object corresponds to the expression that
8351 designates this task.
8352 @noindent
8353 If a task is created by an allocator, its image depends on the context. If the
8354 allocator is part of an object declaration, the rules described above are used
8355 to construct its image, and this image is not affected by subsequent
8356 assignments. If the allocator appears within an expression, the image
8357 includes only the name of the task type.
8358 @noindent
8359 If the configuration pragma Discard_Names is present, or if the restriction
8360 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8361 the numeric suffix, that is to say the hexadecimal representation of the
8362 virtual address of the control block of the task.
8363 @sp 1
8364 @cartouche
8365 @noindent
8366 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8367 or interrupt handler.  See C.7.1(17).
8368 @end cartouche
8369 @noindent
8370 Protected entries or interrupt handlers can be executed by any
8371 convenient thread, so the value of @code{Current_Task} is undefined.
8372
8373 @sp 1
8374 @cartouche
8375 @noindent
8376 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8377 body or interrupt handler.  See C.7.1(19).
8378 @end cartouche
8379 @noindent
8380 The effect of calling @code{Current_Task} from an entry body or
8381 interrupt handler is to return the identification of the task currently
8382 executing the code.
8383
8384 @sp 1
8385 @cartouche
8386 @noindent
8387 @strong{89}.  Implementation-defined aspects of
8388 @code{Task_Attributes}.  See C.7.2(19).
8389 @end cartouche
8390 @noindent
8391 There are no implementation-defined aspects of @code{Task_Attributes}.
8392
8393 @sp 1
8394 @cartouche
8395 @noindent
8396 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8397 @end cartouche
8398 @noindent
8399 The metrics information for GNAT depends on the performance of the
8400 underlying operating system.  The sources of the run-time for tasking
8401 implementation, together with the output from @code{-gnatG} can be
8402 used to determine the exact sequence of operating systems calls made
8403 to implement various tasking constructs.  Together with appropriate
8404 information on the performance of the underlying operating system,
8405 on the exact target in use, this information can be used to determine
8406 the required metrics.
8407
8408 @sp 1
8409 @cartouche
8410 @noindent
8411 @strong{91}.  The declarations of @code{Any_Priority} and
8412 @code{Priority}.  See D.1(11).
8413 @end cartouche
8414 @noindent
8415 See declarations in file @file{system.ads}.
8416
8417 @sp 1
8418 @cartouche
8419 @noindent
8420 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8421 @end cartouche
8422 @noindent
8423 There are no implementation-defined execution resources.
8424
8425 @sp 1
8426 @cartouche
8427 @noindent
8428 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8429 access to a protected object keeps its processor busy.  See D.2.1(3).
8430 @end cartouche
8431 @noindent
8432 On a multi-processor, a task that is waiting for access to a protected
8433 object does not keep its processor busy.
8434
8435 @sp 1
8436 @cartouche
8437 @noindent
8438 @strong{94}.  The affect of implementation defined execution resources
8439 on task dispatching.  See D.2.1(9).
8440 @end cartouche
8441 @noindent
8442 @c SGI info
8443 @ignore
8444 Tasks map to IRIX threads, and the dispatching policy is as defined by
8445 the IRIX implementation of threads.
8446 @end ignore
8447 Tasks map to threads in the threads package used by GNAT@.  Where possible
8448 and appropriate, these threads correspond to native threads of the
8449 underlying operating system.
8450
8451 @sp 1
8452 @cartouche
8453 @noindent
8454 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8455 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8456 @end cartouche
8457 @noindent
8458 There are no implementation-defined policy-identifiers allowed in this
8459 pragma.
8460
8461 @sp 1
8462 @cartouche
8463 @noindent
8464 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8465 D.2.2(16).
8466 @end cartouche
8467 @noindent
8468 Execution of a task cannot be preempted by the implementation processing
8469 of delay expirations for lower priority tasks.
8470
8471 @sp 1
8472 @cartouche
8473 @noindent
8474 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8475 @end cartouche
8476 @noindent
8477 @c SGI info:
8478 @ignore
8479 Tasks map to IRIX threads, and the dispatching policy is as defined by
8480 the IRIX implementation of threads.
8481 @end ignore
8482 The policy is the same as that of the underlying threads implementation.
8483
8484 @sp 1
8485 @cartouche
8486 @noindent
8487 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8488 in a pragma @code{Locking_Policy}.  See D.3(4).
8489 @end cartouche
8490 @noindent
8491 The only implementation defined policy permitted in GNAT is
8492 @code{Inheritance_Locking}.  On targets that support this policy, locking
8493 is implemented by inheritance, i.e.@: the task owning the lock operates
8494 at a priority equal to the highest priority of any task currently
8495 requesting the lock.
8496
8497 @sp 1
8498 @cartouche
8499 @noindent
8500 @strong{99}.  Default ceiling priorities.  See D.3(10).
8501 @end cartouche
8502 @noindent
8503 The ceiling priority of protected objects of the type
8504 @code{System.Interrupt_Priority'Last} as described in the Ada
8505 Reference Manual D.3(10),
8506
8507 @sp 1
8508 @cartouche
8509 @noindent
8510 @strong{100}.  The ceiling of any protected object used internally by
8511 the implementation.  See D.3(16).
8512 @end cartouche
8513 @noindent
8514 The ceiling priority of internal protected objects is
8515 @code{System.Priority'Last}.
8516
8517 @sp 1
8518 @cartouche
8519 @noindent
8520 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8521 @end cartouche
8522 @noindent
8523 There are no implementation-defined queuing policies.
8524
8525 @sp 1
8526 @cartouche
8527 @noindent
8528 @strong{102}.  On a multiprocessor, any conditions that cause the
8529 completion of an aborted construct to be delayed later than what is
8530 specified for a single processor.  See D.6(3).
8531 @end cartouche
8532 @noindent
8533 The semantics for abort on a multi-processor is the same as on a single
8534 processor, there are no further delays.
8535
8536 @sp 1
8537 @cartouche
8538 @noindent
8539 @strong{103}.  Any operations that implicitly require heap storage
8540 allocation.  See D.7(8).
8541 @end cartouche
8542 @noindent
8543 The only operation that implicitly requires heap storage allocation is
8544 task creation.
8545
8546 @sp 1
8547 @cartouche
8548 @noindent
8549 @strong{104}.  Implementation-defined aspects of pragma
8550 @code{Restrictions}.  See D.7(20).
8551 @end cartouche
8552 @noindent
8553 There are no such implementation-defined aspects.
8554
8555 @sp 1
8556 @cartouche
8557 @noindent
8558 @strong{105}.  Implementation-defined aspects of package
8559 @code{Real_Time}.  See D.8(17).
8560 @end cartouche
8561 @noindent
8562 There are no implementation defined aspects of package @code{Real_Time}.
8563
8564 @sp 1
8565 @cartouche
8566 @noindent
8567 @strong{106}.  Implementation-defined aspects of
8568 @code{delay_statements}.  See D.9(8).
8569 @end cartouche
8570 @noindent
8571 Any difference greater than one microsecond will cause the task to be
8572 delayed (see D.9(7)).
8573
8574 @sp 1
8575 @cartouche
8576 @noindent
8577 @strong{107}.  The upper bound on the duration of interrupt blocking
8578 caused by the implementation.  See D.12(5).
8579 @end cartouche
8580 @noindent
8581 The upper bound is determined by the underlying operating system.  In
8582 no cases is it more than 10 milliseconds.
8583
8584 @sp 1
8585 @cartouche
8586 @noindent
8587 @strong{108}.  The means for creating and executing distributed
8588 programs.  See E(5).
8589 @end cartouche
8590 @noindent
8591 The GLADE package provides a utility GNATDIST for creating and executing
8592 distributed programs.  See the GLADE reference manual for further details.
8593
8594 @sp 1
8595 @cartouche
8596 @noindent
8597 @strong{109}.  Any events that can result in a partition becoming
8598 inaccessible.  See E.1(7).
8599 @end cartouche
8600 @noindent
8601 See the GLADE reference manual for full details on such events.
8602
8603 @sp 1
8604 @cartouche
8605 @noindent
8606 @strong{110}.  The scheduling policies, treatment of priorities, and
8607 management of shared resources between partitions in certain cases.  See
8608 E.1(11).
8609 @end cartouche
8610 @noindent
8611 See the GLADE reference manual for full details on these aspects of
8612 multi-partition execution.
8613
8614 @sp 1
8615 @cartouche
8616 @noindent
8617 @strong{111}.  Events that cause the version of a compilation unit to
8618 change.  See E.3(5).
8619 @end cartouche
8620 @noindent
8621 Editing the source file of a compilation unit, or the source files of
8622 any units on which it is dependent in a significant way cause the version
8623 to change.  No other actions cause the version number to change.  All changes
8624 are significant except those which affect only layout, capitalization or
8625 comments.
8626
8627 @sp 1
8628 @cartouche
8629 @noindent
8630 @strong{112}.  Whether the execution of the remote subprogram is
8631 immediately aborted as a result of cancellation.  See E.4(13).
8632 @end cartouche
8633 @noindent
8634 See the GLADE reference manual for details on the effect of abort in
8635 a distributed application.
8636
8637 @sp 1
8638 @cartouche
8639 @noindent
8640 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8641 @end cartouche
8642 @noindent
8643 See the GLADE reference manual for a full description of all implementation
8644 defined aspects of the PCS@.
8645
8646 @sp 1
8647 @cartouche
8648 @noindent
8649 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8650 E.5(26).
8651 @end cartouche
8652 @noindent
8653 See the GLADE reference manual for a full description of all
8654 implementation defined interfaces.
8655
8656 @sp 1
8657 @cartouche
8658 @noindent
8659 @strong{115}.  The values of named numbers in the package
8660 @code{Decimal}.  See F.2(7).
8661 @end cartouche
8662 @noindent
8663 @table @code
8664 @item Max_Scale
8665 +18
8666 @item Min_Scale
8667 -18
8668 @item Min_Delta
8669 1.0E-18
8670 @item Max_Delta
8671 1.0E+18
8672 @item Max_Decimal_Digits
8673 18
8674 @end table
8675
8676 @sp 1
8677 @cartouche
8678 @noindent
8679 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8680 @code{Text_IO.Editing}.  See F.3.3(16).
8681 @end cartouche
8682 @noindent
8683 64
8684
8685 @sp 1
8686 @cartouche
8687 @noindent
8688 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8689 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8690 @end cartouche
8691 @noindent
8692 64
8693
8694 @sp 1
8695 @cartouche
8696 @noindent
8697 @strong{118}.  The accuracy actually achieved by the complex elementary
8698 functions and by other complex arithmetic operations.  See G.1(1).
8699 @end cartouche
8700 @noindent
8701 Standard library functions are used for the complex arithmetic
8702 operations.  Only fast math mode is currently supported.
8703
8704 @sp 1
8705 @cartouche
8706 @noindent
8707 @strong{119}.  The sign of a zero result (or a component thereof) from
8708 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8709 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8710 @end cartouche
8711 @noindent
8712 The signs of zero values are as recommended by the relevant
8713 implementation advice.
8714
8715 @sp 1
8716 @cartouche
8717 @noindent
8718 @strong{120}.  The sign of a zero result (or a component thereof) from
8719 any operator or function in
8720 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8721 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8722 @end cartouche
8723 @noindent
8724 The signs of zero values are as recommended by the relevant
8725 implementation advice.
8726
8727 @sp 1
8728 @cartouche
8729 @noindent
8730 @strong{121}.  Whether the strict mode or the relaxed mode is the
8731 default.  See G.2(2).
8732 @end cartouche
8733 @noindent
8734 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8735 provides a highly efficient implementation of strict mode.
8736
8737 @sp 1
8738 @cartouche
8739 @noindent
8740 @strong{122}.  The result interval in certain cases of fixed-to-float
8741 conversion.  See G.2.1(10).
8742 @end cartouche
8743 @noindent
8744 For cases where the result interval is implementation dependent, the
8745 accuracy is that provided by performing all operations in 64-bit IEEE
8746 floating-point format.
8747
8748 @sp 1
8749 @cartouche
8750 @noindent
8751 @strong{123}.  The result of a floating point arithmetic operation in
8752 overflow situations, when the @code{Machine_Overflows} attribute of the
8753 result type is @code{False}.  See G.2.1(13).
8754 @end cartouche
8755 @noindent
8756 Infinite and NaN values are produced as dictated by the IEEE
8757 floating-point standard.
8758
8759 Note that on machines that are not fully compliant with the IEEE
8760 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8761 must be used for achieving IEEE confirming behavior (although at the cost
8762 of a significant performance penalty), so infinite and NaN values are
8763 properly generated.
8764
8765 @sp 1
8766 @cartouche
8767 @noindent
8768 @strong{124}.  The result interval for division (or exponentiation by a
8769 negative exponent), when the floating point hardware implements division
8770 as multiplication by a reciprocal.  See G.2.1(16).
8771 @end cartouche
8772 @noindent
8773 Not relevant, division is IEEE exact.
8774
8775 @sp 1
8776 @cartouche
8777 @noindent
8778 @strong{125}.  The definition of close result set, which determines the
8779 accuracy of certain fixed point multiplications and divisions.  See
8780 G.2.3(5).
8781 @end cartouche
8782 @noindent
8783 Operations in the close result set are performed using IEEE long format
8784 floating-point arithmetic.  The input operands are converted to
8785 floating-point, the operation is done in floating-point, and the result
8786 is converted to the target type.
8787
8788 @sp 1
8789 @cartouche
8790 @noindent
8791 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8792 point multiplication or division for which the result shall be in the
8793 perfect result set.  See G.2.3(22).
8794 @end cartouche
8795 @noindent
8796 The result is only defined to be in the perfect result set if the result
8797 can be computed by a single scaling operation involving a scale factor
8798 representable in 64-bits.
8799
8800 @sp 1
8801 @cartouche
8802 @noindent
8803 @strong{127}.  The result of a fixed point arithmetic operation in
8804 overflow situations, when the @code{Machine_Overflows} attribute of the
8805 result type is @code{False}.  See G.2.3(27).
8806 @end cartouche
8807 @noindent
8808 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8809 types.
8810
8811 @sp 1
8812 @cartouche
8813 @noindent
8814 @strong{128}.  The result of an elementary function reference in
8815 overflow situations, when the @code{Machine_Overflows} attribute of the
8816 result type is @code{False}.  See G.2.4(4).
8817 @end cartouche
8818 @noindent
8819 IEEE infinite and Nan values are produced as appropriate.
8820
8821 @sp 1
8822 @cartouche
8823 @noindent
8824 @strong{129}.  The value of the angle threshold, within which certain
8825 elementary functions, complex arithmetic operations, and complex
8826 elementary functions yield results conforming to a maximum relative
8827 error bound.  See G.2.4(10).
8828 @end cartouche
8829 @noindent
8830 Information on this subject is not yet available.
8831
8832 @sp 1
8833 @cartouche
8834 @noindent
8835 @strong{130}.  The accuracy of certain elementary functions for
8836 parameters beyond the angle threshold.  See G.2.4(10).
8837 @end cartouche
8838 @noindent
8839 Information on this subject is not yet available.
8840
8841 @sp 1
8842 @cartouche
8843 @noindent
8844 @strong{131}.  The result of a complex arithmetic operation or complex
8845 elementary function reference in overflow situations, when the
8846 @code{Machine_Overflows} attribute of the corresponding real type is
8847 @code{False}.  See G.2.6(5).
8848 @end cartouche
8849 @noindent
8850 IEEE infinite and Nan values are produced as appropriate.
8851
8852 @sp 1
8853 @cartouche
8854 @noindent
8855 @strong{132}.  The accuracy of certain complex arithmetic operations and
8856 certain complex elementary functions for parameters (or components
8857 thereof) beyond the angle threshold.  See G.2.6(8).
8858 @end cartouche
8859 @noindent
8860 Information on those subjects is not yet available.
8861
8862 @sp 1
8863 @cartouche
8864 @noindent
8865 @strong{133}.  Information regarding bounded errors and erroneous
8866 execution.  See H.2(1).
8867 @end cartouche
8868 @noindent
8869 Information on this subject is not yet available.
8870
8871 @sp 1
8872 @cartouche
8873 @noindent
8874 @strong{134}.  Implementation-defined aspects of pragma
8875 @code{Inspection_Point}.  See H.3.2(8).
8876 @end cartouche
8877 @noindent
8878 Pragma @code{Inspection_Point} ensures that the variable is live and can
8879 be examined by the debugger at the inspection point.
8880
8881 @sp 1
8882 @cartouche
8883 @noindent
8884 @strong{135}.  Implementation-defined aspects of pragma
8885 @code{Restrictions}.  See H.4(25).
8886 @end cartouche
8887 @noindent
8888 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8889 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8890 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8891
8892 @sp 1
8893 @cartouche
8894 @noindent
8895 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8896 H.4(27).
8897 @end cartouche
8898 @noindent
8899 There are no restrictions on pragma @code{Restrictions}.
8900
8901 @node Intrinsic Subprograms
8902 @chapter Intrinsic Subprograms
8903 @cindex Intrinsic Subprograms
8904
8905 @menu
8906 * Intrinsic Operators::
8907 * Enclosing_Entity::
8908 * Exception_Information::
8909 * Exception_Message::
8910 * Exception_Name::
8911 * File::
8912 * Line::
8913 * Rotate_Left::
8914 * Rotate_Right::
8915 * Shift_Left::
8916 * Shift_Right::
8917 * Shift_Right_Arithmetic::
8918 * Source_Location::
8919 @end menu
8920
8921 @noindent
8922 GNAT allows a user application program to write the declaration:
8923
8924 @smallexample @c ada
8925    pragma Import (Intrinsic, name);
8926 @end smallexample
8927
8928 @noindent
8929 providing that the name corresponds to one of the implemented intrinsic
8930 subprograms in GNAT, and that the parameter profile of the referenced
8931 subprogram meets the requirements.  This chapter describes the set of
8932 implemented intrinsic subprograms, and the requirements on parameter profiles.
8933 Note that no body is supplied; as with other uses of pragma Import, the
8934 body is supplied elsewhere (in this case by the compiler itself).  Note
8935 that any use of this feature is potentially non-portable, since the
8936 Ada standard does not require Ada compilers to implement this feature.
8937
8938 @node Intrinsic Operators
8939 @section Intrinsic Operators
8940 @cindex Intrinsic operator
8941
8942 @noindent
8943 All the predefined numeric operators in package Standard
8944 in @code{pragma Import (Intrinsic,..)}
8945 declarations.  In the binary operator case, the operands must have the same
8946 size.  The operand or operands must also be appropriate for
8947 the operator.  For example, for addition, the operands must
8948 both be floating-point or both be fixed-point, and the
8949 right operand for @code{"**"} must have a root type of
8950 @code{Standard.Integer'Base}.
8951 You can use an intrinsic operator declaration as in the following example:
8952
8953 @smallexample @c ada
8954    type Int1 is new Integer;
8955    type Int2 is new Integer;
8956
8957    function "+" (X1 : Int1; X2 : Int2) return Int1;
8958    function "+" (X1 : Int1; X2 : Int2) return Int2;
8959    pragma Import (Intrinsic, "+");
8960 @end smallexample
8961
8962 @noindent
8963 This declaration would permit ``mixed mode'' arithmetic on items
8964 of the differing types @code{Int1} and @code{Int2}.
8965 It is also possible to specify such operators for private types, if the
8966 full views are appropriate arithmetic types.
8967
8968 @node Enclosing_Entity
8969 @section Enclosing_Entity
8970 @cindex Enclosing_Entity
8971 @noindent
8972 This intrinsic subprogram is used in the implementation of the
8973 library routine @code{GNAT.Source_Info}.  The only useful use of the
8974 intrinsic import in this case is the one in this unit, so an
8975 application program should simply call the function
8976 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8977 the current subprogram, package, task, entry, or protected subprogram.
8978
8979 @node Exception_Information
8980 @section Exception_Information
8981 @cindex Exception_Information'
8982 @noindent
8983 This intrinsic subprogram is used in the implementation of the
8984 library routine @code{GNAT.Current_Exception}.  The only useful
8985 use of the intrinsic import in this case is the one in this unit,
8986 so an application program should simply call the function
8987 @code{GNAT.Current_Exception.Exception_Information} to obtain
8988 the exception information associated with the current exception.
8989
8990 @node Exception_Message
8991 @section Exception_Message
8992 @cindex Exception_Message
8993 @noindent
8994 This intrinsic subprogram is used in the implementation of the
8995 library routine @code{GNAT.Current_Exception}.  The only useful
8996 use of the intrinsic import in this case is the one in this unit,
8997 so an application program should simply call the function
8998 @code{GNAT.Current_Exception.Exception_Message} to obtain
8999 the message associated with the current exception.
9000
9001 @node Exception_Name
9002 @section Exception_Name
9003 @cindex Exception_Name
9004 @noindent
9005 This intrinsic subprogram is used in the implementation of the
9006 library routine @code{GNAT.Current_Exception}.  The only useful
9007 use of the intrinsic import in this case is the one in this unit,
9008 so an application program should simply call the function
9009 @code{GNAT.Current_Exception.Exception_Name} to obtain
9010 the name of the current exception.
9011
9012 @node File
9013 @section File
9014 @cindex File
9015 @noindent
9016 This intrinsic subprogram is used in the implementation of the
9017 library routine @code{GNAT.Source_Info}.  The only useful use of the
9018 intrinsic import in this case is the one in this unit, so an
9019 application program should simply call the function
9020 @code{GNAT.Source_Info.File} to obtain the name of the current
9021 file.
9022
9023 @node Line
9024 @section Line
9025 @cindex Line
9026 @noindent
9027 This intrinsic subprogram is used in the implementation of the
9028 library routine @code{GNAT.Source_Info}.  The only useful use of the
9029 intrinsic import in this case is the one in this unit, so an
9030 application program should simply call the function
9031 @code{GNAT.Source_Info.Line} to obtain the number of the current
9032 source line.
9033
9034 @node Rotate_Left
9035 @section Rotate_Left
9036 @cindex Rotate_Left
9037 @noindent
9038 In standard Ada, the @code{Rotate_Left} function is available only
9039 for the predefined modular types in package @code{Interfaces}.  However, in
9040 GNAT it is possible to define a Rotate_Left function for a user
9041 defined modular type or any signed integer type as in this example:
9042
9043 @smallexample @c ada
9044    function Shift_Left
9045      (Value  : My_Modular_Type;
9046       Amount : Natural)
9047       return   My_Modular_Type;
9048 @end smallexample
9049
9050 @noindent
9051 The requirements are that the profile be exactly as in the example
9052 above.  The only modifications allowed are in the formal parameter
9053 names, and in the type of @code{Value} and the return type, which
9054 must be the same, and must be either a signed integer type, or
9055 a modular integer type with a binary modulus, and the size must
9056 be 8.  16, 32 or 64 bits.
9057
9058 @node Rotate_Right
9059 @section Rotate_Right
9060 @cindex Rotate_Right
9061 @noindent
9062 A @code{Rotate_Right} function can be defined for any user defined
9063 binary modular integer type, or signed integer type, as described
9064 above for @code{Rotate_Left}.
9065
9066 @node Shift_Left
9067 @section Shift_Left
9068 @cindex Shift_Left
9069 @noindent
9070 A @code{Shift_Left} function can be defined for any user defined
9071 binary modular integer type, or signed integer type, as described
9072 above for @code{Rotate_Left}.
9073
9074 @node Shift_Right
9075 @section Shift_Right
9076 @cindex Shift_Right
9077 @noindent
9078 A @code{Shift_Right} function can be defined for any user defined
9079 binary modular integer type, or signed integer type, as described
9080 above for @code{Rotate_Left}.
9081
9082 @node Shift_Right_Arithmetic
9083 @section Shift_Right_Arithmetic
9084 @cindex Shift_Right_Arithmetic
9085 @noindent
9086 A @code{Shift_Right_Arithmetic} function can be defined for any user
9087 defined binary modular integer type, or signed integer type, as described
9088 above for @code{Rotate_Left}.
9089
9090 @node Source_Location
9091 @section Source_Location
9092 @cindex Source_Location
9093 @noindent
9094 This intrinsic subprogram is used in the implementation of the
9095 library routine @code{GNAT.Source_Info}.  The only useful use of the
9096 intrinsic import in this case is the one in this unit, so an
9097 application program should simply call the function
9098 @code{GNAT.Source_Info.Source_Location} to obtain the current
9099 source file location.
9100
9101 @node Representation Clauses and Pragmas
9102 @chapter Representation Clauses and Pragmas
9103 @cindex Representation Clauses
9104
9105 @menu
9106 * Alignment Clauses::
9107 * Size Clauses::
9108 * Storage_Size Clauses::
9109 * Size of Variant Record Objects::
9110 * Biased Representation ::
9111 * Value_Size and Object_Size Clauses::
9112 * Component_Size Clauses::
9113 * Bit_Order Clauses::
9114 * Effect of Bit_Order on Byte Ordering::
9115 * Pragma Pack for Arrays::
9116 * Pragma Pack for Records::
9117 * Record Representation Clauses::
9118 * Enumeration Clauses::
9119 * Address Clauses::
9120 * Effect of Convention on Representation::
9121 * Determining the Representations chosen by GNAT::
9122 @end menu
9123
9124 @noindent
9125 @cindex Representation Clause
9126 @cindex Representation Pragma
9127 @cindex Pragma, representation
9128 This section describes the representation clauses accepted by GNAT, and
9129 their effect on the representation of corresponding data objects.
9130
9131 GNAT fully implements Annex C (Systems Programming).  This means that all
9132 the implementation advice sections in chapter 13 are fully implemented.
9133 However, these sections only require a minimal level of support for
9134 representation clauses.  GNAT provides much more extensive capabilities,
9135 and this section describes the additional capabilities provided.
9136
9137 @node Alignment Clauses
9138 @section Alignment Clauses
9139 @cindex Alignment Clause
9140
9141 @noindent
9142 GNAT requires that all alignment clauses specify a power of 2, and all
9143 default alignments are always a power of 2.  The default alignment
9144 values are as follows:
9145
9146 @itemize @bullet
9147 @item @emph{Primitive Types}.
9148 For primitive types, the alignment is the minimum of the actual size of
9149 objects of the type divided by @code{Storage_Unit},
9150 and the maximum alignment supported by the target.
9151 (This maximum alignment is given by the GNAT-specific attribute
9152 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9153 @cindex @code{Maximum_Alignment} attribute
9154 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9155 default alignment will be 8 on any target that supports alignments
9156 this large, but on some targets, the maximum alignment may be smaller
9157 than 8, in which case objects of type @code{Long_Float} will be maximally
9158 aligned.
9159
9160 @item @emph{Arrays}.
9161 For arrays, the alignment is equal to the alignment of the component type
9162 for the normal case where no packing or component size is given.  If the
9163 array is packed, and the packing is effective (see separate section on
9164 packed arrays), then the alignment will be one for long packed arrays,
9165 or arrays whose length is not known at compile time.  For short packed
9166 arrays, which are handled internally as modular types, the alignment
9167 will be as described for primitive types, e.g.@: a packed array of length
9168 31 bits will have an object size of four bytes, and an alignment of 4.
9169
9170 @item @emph{Records}.
9171 For the normal non-packed case, the alignment of a record is equal to
9172 the maximum alignment of any of its components.  For tagged records, this
9173 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
9174 used and all fields are packable (see separate section on pragma @code{Pack}),
9175 then the resulting alignment is 1.
9176
9177 A special case is when:
9178 @itemize @bullet
9179 @item
9180 the size of the record is given explicitly, or a
9181 full record representation clause is given, and
9182 @item
9183 the size of the record is 2, 4, or 8 bytes.
9184 @end itemize
9185 @noindent
9186 In this case, an alignment is chosen to match the
9187 size of the record. For example, if we have:
9188
9189 @smallexample @c ada
9190    type Small is record
9191       A, B : Character;
9192    end record;
9193    for Small'Size use 16;
9194 @end smallexample
9195
9196 @noindent
9197 then the default alignment of the record type @code{Small} is 2, not 1. This
9198 leads to more efficient code when the record is treated as a unit, and also
9199 allows the type to specified as @code{Atomic} on architectures requiring
9200 strict alignment.
9201
9202 @end itemize
9203
9204 @noindent
9205 An alignment clause may specify a larger alignment than the default value
9206 up to some maximum value dependent on the target (obtainable by using the
9207 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9208 a smaller alignment than the default value, for example
9209
9210 @smallexample @c ada
9211   type V is record
9212      A : Integer;
9213   end record;
9214
9215   for V'alignment use 1;
9216 @end smallexample
9217
9218 @noindent
9219 @cindex Alignment, default
9220 The default alignment for the type @code{V} is 4, as a result of the
9221 Integer field in the record, but it is permissible, as shown, to
9222 override the default alignment of the record with a smaller value.
9223
9224 @node Size Clauses
9225 @section Size Clauses
9226 @cindex Size Clause
9227
9228 @noindent
9229 The default size for a type @code{T} is obtainable through the
9230 language-defined attribute @code{T'Size} and also through the
9231 equivalent GNAT-defined attribute @code{T'Value_Size}.
9232 For objects of type @code{T}, GNAT will generally increase the type size
9233 so that the object size (obtainable through the GNAT-defined attribute
9234 @code{T'Object_Size})
9235 is a multiple of @code{T'Alignment * Storage_Unit}.
9236 For example
9237
9238 @smallexample @c ada
9239    type Smallint is range 1 .. 6;
9240
9241    type Rec is record
9242       Y1 : integer;
9243       Y2 : boolean;
9244    end record;
9245 @end smallexample
9246
9247 @noindent
9248 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9249 as specified by the RM rules,
9250 but objects of this type will have a size of 8
9251 (@code{Smallint'Object_Size} = 8),
9252 since objects by default occupy an integral number
9253 of storage units.  On some targets, notably older
9254 versions of the Digital Alpha, the size of stand
9255 alone objects of this type may be 32, reflecting
9256 the inability of the hardware to do byte load/stores.
9257
9258 Similarly, the size of type @code{Rec} is 40 bits
9259 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9260 the alignment is 4, so objects of this type will have
9261 their size increased to 64 bits so that it is a multiple
9262 of the alignment (in bits).  This decision is
9263 in accordance with the specific Implementation Advice in RM 13.3(43):
9264
9265 @quotation
9266 A @code{Size} clause should be supported for an object if the specified
9267 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9268 to a size in storage elements that is a multiple of the object's
9269 @code{Alignment} (if the @code{Alignment} is nonzero).
9270 @end quotation
9271
9272 @noindent
9273 An explicit size clause may be used to override the default size by
9274 increasing it.  For example, if we have:
9275
9276 @smallexample @c ada
9277    type My_Boolean is new Boolean;
9278    for My_Boolean'Size use 32;
9279 @end smallexample
9280
9281 @noindent
9282 then values of this type will always be 32 bits long.  In the case of
9283 discrete types, the size can be increased up to 64 bits, with the effect
9284 that the entire specified field is used to hold the value, sign- or
9285 zero-extended as appropriate.  If more than 64 bits is specified, then
9286 padding space is allocated after the value, and a warning is issued that
9287 there are unused bits.
9288
9289 Similarly the size of records and arrays may be increased, and the effect
9290 is to add padding bits after the value.  This also causes a warning message
9291 to be generated.
9292
9293 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9294 Size in bits, this corresponds to an object of size 256 megabytes (minus
9295 one).  This limitation is true on all targets.  The reason for this
9296 limitation is that it improves the quality of the code in many cases
9297 if it is known that a Size value can be accommodated in an object of
9298 type Integer.
9299
9300 @node Storage_Size Clauses
9301 @section Storage_Size Clauses
9302 @cindex Storage_Size Clause
9303
9304 @noindent
9305 For tasks, the @code{Storage_Size} clause specifies the amount of space
9306 to be allocated for the task stack.  This cannot be extended, and if the
9307 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9308 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9309 or a @code{Storage_Size} pragma in the task definition to set the
9310 appropriate required size.  A useful technique is to include in every
9311 task definition a pragma of the form:
9312
9313 @smallexample @c ada
9314    pragma Storage_Size (Default_Stack_Size);
9315 @end smallexample
9316
9317 @noindent
9318 Then @code{Default_Stack_Size} can be defined in a global package, and
9319 modified as required. Any tasks requiring stack sizes different from the
9320 default can have an appropriate alternative reference in the pragma.
9321
9322 You can also use the @code{-d} binder switch to modify the default stack
9323 size.
9324
9325 For access types, the @code{Storage_Size} clause specifies the maximum
9326 space available for allocation of objects of the type.  If this space is
9327 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9328 In the case where the access type is declared local to a subprogram, the
9329 use of a @code{Storage_Size} clause triggers automatic use of a special
9330 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9331 space for the pool is automatically reclaimed on exit from the scope in
9332 which the type is declared.
9333
9334 A special case recognized by the compiler is the specification of a
9335 @code{Storage_Size} of zero for an access type.  This means that no
9336 items can be allocated from the pool, and this is recognized at compile
9337 time, and all the overhead normally associated with maintaining a fixed
9338 size storage pool is eliminated.  Consider the following example:
9339
9340 @smallexample @c ada
9341    procedure p is
9342       type R is array (Natural) of Character;
9343       type P is access all R;
9344       for P'Storage_Size use 0;
9345       --  Above access type intended only for interfacing purposes
9346
9347       y : P;
9348
9349       procedure g (m : P);
9350       pragma Import (C, g);
9351
9352       --  @dots{}
9353
9354    begin
9355       --  @dots{}
9356       y := new R;
9357    end;
9358 @end smallexample
9359
9360 @noindent
9361 As indicated in this example, these dummy storage pools are often useful in
9362 connection with interfacing where no object will ever be allocated.  If you
9363 compile the above example, you get the warning:
9364
9365 @smallexample
9366    p.adb:16:09: warning: allocation from empty storage pool
9367    p.adb:16:09: warning: Storage_Error will be raised at run time
9368 @end smallexample
9369
9370 @noindent
9371 Of course in practice, there will not be any explicit allocators in the
9372 case of such an access declaration.
9373
9374 @node Size of Variant Record Objects
9375 @section Size of Variant Record Objects
9376 @cindex Size, variant record objects
9377 @cindex Variant record objects, size
9378
9379 @noindent
9380 In the case of variant record objects, there is a question whether Size gives
9381 information about a particular variant, or the maximum size required
9382 for any variant.  Consider the following program
9383
9384 @smallexample @c ada
9385 with Text_IO; use Text_IO;
9386 procedure q is
9387    type R1 (A : Boolean := False) is record
9388      case A is
9389        when True  => X : Character;
9390        when False => null;
9391      end case;
9392    end record;
9393
9394    V1 : R1 (False);
9395    V2 : R1;
9396
9397 begin
9398    Put_Line (Integer'Image (V1'Size));
9399    Put_Line (Integer'Image (V2'Size));
9400 end q;
9401 @end smallexample
9402
9403 @noindent
9404 Here we are dealing with a variant record, where the True variant
9405 requires 16 bits, and the False variant requires 8 bits.
9406 In the above example, both V1 and V2 contain the False variant,
9407 which is only 8 bits long.  However, the result of running the
9408 program is:
9409
9410 @smallexample
9411 8
9412 16
9413 @end smallexample
9414
9415 @noindent
9416 The reason for the difference here is that the discriminant value of
9417 V1 is fixed, and will always be False.  It is not possible to assign
9418 a True variant value to V1, therefore 8 bits is sufficient.  On the
9419 other hand, in the case of V2, the initial discriminant value is
9420 False (from the default), but it is possible to assign a True
9421 variant value to V2, therefore 16 bits must be allocated for V2
9422 in the general case, even fewer bits may be needed at any particular
9423 point during the program execution.
9424
9425 As can be seen from the output of this program, the @code{'Size}
9426 attribute applied to such an object in GNAT gives the actual allocated
9427 size of the variable, which is the largest size of any of the variants.
9428 The Ada Reference Manual is not completely clear on what choice should
9429 be made here, but the GNAT behavior seems most consistent with the
9430 language in the RM@.
9431
9432 In some cases, it may be desirable to obtain the size of the current
9433 variant, rather than the size of the largest variant.  This can be
9434 achieved in GNAT by making use of the fact that in the case of a
9435 subprogram parameter, GNAT does indeed return the size of the current
9436 variant (because a subprogram has no way of knowing how much space
9437 is actually allocated for the actual).
9438
9439 Consider the following modified version of the above program:
9440
9441 @smallexample @c ada
9442 with Text_IO; use Text_IO;
9443 procedure q is
9444    type R1 (A : Boolean := False) is record
9445      case A is
9446        when True  => X : Character;
9447        when False => null;
9448      end case;
9449    end record;
9450
9451    V2 : R1;
9452
9453    function Size (V : R1) return Integer is
9454    begin
9455       return V'Size;
9456    end Size;
9457
9458 begin
9459    Put_Line (Integer'Image (V2'Size));
9460    Put_Line (Integer'IMage (Size (V2)));
9461    V2 := (True, 'x');
9462    Put_Line (Integer'Image (V2'Size));
9463    Put_Line (Integer'IMage (Size (V2)));
9464 end q;
9465 @end smallexample
9466
9467 @noindent
9468 The output from this program is
9469
9470 @smallexample
9471 16
9472 8
9473 16
9474 16
9475 @end smallexample
9476
9477 @noindent
9478 Here we see that while the @code{'Size} attribute always returns
9479 the maximum size, regardless of the current variant value, the
9480 @code{Size} function does indeed return the size of the current
9481 variant value.
9482
9483 @node Biased Representation
9484 @section Biased Representation
9485 @cindex Size for biased representation
9486 @cindex Biased representation
9487
9488 @noindent
9489 In the case of scalars with a range starting at other than zero, it is
9490 possible in some cases to specify a size smaller than the default minimum
9491 value, and in such cases, GNAT uses an unsigned biased representation,
9492 in which zero is used to represent the lower bound, and successive values
9493 represent successive values of the type.
9494
9495 For example, suppose we have the declaration:
9496
9497 @smallexample @c ada
9498    type Small is range -7 .. -4;
9499    for Small'Size use 2;
9500 @end smallexample
9501
9502 @noindent
9503 Although the default size of type @code{Small} is 4, the @code{Size}
9504 clause is accepted by GNAT and results in the following representation
9505 scheme:
9506
9507 @smallexample
9508   -7 is represented as 2#00#
9509   -6 is represented as 2#01#
9510   -5 is represented as 2#10#
9511   -4 is represented as 2#11#
9512 @end smallexample
9513
9514 @noindent
9515 Biased representation is only used if the specified @code{Size} clause
9516 cannot be accepted in any other manner.  These reduced sizes that force
9517 biased representation can be used for all discrete types except for
9518 enumeration types for which a representation clause is given.
9519
9520 @node Value_Size and Object_Size Clauses
9521 @section Value_Size and Object_Size Clauses
9522 @findex Value_Size
9523 @findex Object_Size
9524 @cindex Size, of objects
9525
9526 @noindent
9527 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9528 number of bits required to hold values of type @code{T}.
9529 Although this interpretation was allowed in Ada 83, it was not required,
9530 and this requirement in practice can cause some significant difficulties.
9531 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9532 However, in Ada 95 and Ada 2005,
9533 @code{Natural'Size} is
9534 typically 31.  This means that code may change in behavior when moving
9535 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
9536
9537 @smallexample @c ada
9538    type Rec is record;
9539       A : Natural;
9540       B : Natural;
9541    end record;
9542
9543    for Rec use record
9544       at 0  range 0 .. Natural'Size - 1;
9545       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9546    end record;
9547 @end smallexample
9548
9549 @noindent
9550 In the above code, since the typical size of @code{Natural} objects
9551 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9552 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9553 there are cases where the fact that the object size can exceed the
9554 size of the type causes surprises.
9555
9556 To help get around this problem GNAT provides two implementation
9557 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9558 applied to a type, these attributes yield the size of the type
9559 (corresponding to the RM defined size attribute), and the size of
9560 objects of the type respectively.
9561
9562 The @code{Object_Size} is used for determining the default size of
9563 objects and components.  This size value can be referred to using the
9564 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9565 the basis of the determination of the size.  The backend is free to
9566 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9567 character might be stored in 32 bits on a machine with no efficient
9568 byte access instructions such as the Alpha.
9569
9570 The default rules for the value of @code{Object_Size} for
9571 discrete types are as follows:
9572
9573 @itemize @bullet
9574 @item
9575 The @code{Object_Size} for base subtypes reflect the natural hardware
9576 size in bits (run the compiler with @option{-gnatS} to find those values
9577 for numeric types). Enumeration types and fixed-point base subtypes have
9578 8, 16, 32 or 64 bits for this size, depending on the range of values
9579 to be stored.
9580
9581 @item
9582 The @code{Object_Size} of a subtype is the same as the
9583 @code{Object_Size} of
9584 the type from which it is obtained.
9585
9586 @item
9587 The @code{Object_Size} of a derived base type is copied from the parent
9588 base type, and the @code{Object_Size} of a derived first subtype is copied
9589 from the parent first subtype.
9590 @end itemize
9591
9592 @noindent
9593 The @code{Value_Size} attribute
9594 is the (minimum) number of bits required to store a value
9595 of the type.
9596 This value is used to determine how tightly to pack
9597 records or arrays with components of this type, and also affects
9598 the semantics of unchecked conversion (unchecked conversions where
9599 the @code{Value_Size} values differ generate a warning, and are potentially
9600 target dependent).
9601
9602 The default rules for the value of @code{Value_Size} are as follows:
9603
9604 @itemize @bullet
9605 @item
9606 The @code{Value_Size} for a base subtype is the minimum number of bits
9607 required to store all values of the type (including the sign bit
9608 only if negative values are possible).
9609
9610 @item
9611 If a subtype statically matches the first subtype of a given type, then it has
9612 by default the same @code{Value_Size} as the first subtype.  This is a
9613 consequence of RM 13.1(14) (``if two subtypes statically match,
9614 then their subtype-specific aspects are the same''.)
9615
9616 @item
9617 All other subtypes have a @code{Value_Size} corresponding to the minimum
9618 number of bits required to store all values of the subtype.  For
9619 dynamic bounds, it is assumed that the value can range down or up
9620 to the corresponding bound of the ancestor
9621 @end itemize
9622
9623 @noindent
9624 The RM defined attribute @code{Size} corresponds to the
9625 @code{Value_Size} attribute.
9626
9627 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9628 the @code{Value_Size} of
9629 the first-named subtype to the given value, and the
9630 @code{Object_Size} of this first-named subtype to the given value padded up
9631 to an appropriate boundary.  It is a consequence of the default rules
9632 above that this @code{Object_Size} will apply to all further subtypes.  On the
9633 other hand, @code{Value_Size} is affected only for the first subtype, any
9634 dynamic subtypes obtained from it directly, and any statically matching
9635 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9636
9637 @code{Value_Size} and
9638 @code{Object_Size} may be explicitly set for any subtype using
9639 an attribute definition clause.  Note that the use of these attributes
9640 can cause the RM 13.1(14) rule to be violated.  If two access types
9641 reference aliased objects whose subtypes have differing @code{Object_Size}
9642 values as a result of explicit attribute definition clauses, then it
9643 is erroneous to convert from one access subtype to the other.
9644
9645 At the implementation level, Esize stores the Object_Size and the
9646 RM_Size field stores the @code{Value_Size} (and hence the value of the
9647 @code{Size} attribute,
9648 which, as noted above, is equivalent to @code{Value_Size}).
9649
9650 To get a feel for the difference, consider the following examples (note
9651 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9652
9653 @smallexample
9654                                        Object_Size     Value_Size
9655
9656 type x1 is range 0 .. 5;                    8               3
9657
9658 type x2 is range 0 .. 5;
9659 for x2'size use 12;                        16              12
9660
9661 subtype x3 is x2 range 0 .. 3;             16               2
9662
9663 subtype x4 is x2'base range 0 .. 10;        8               4
9664
9665 subtype x5 is x2 range 0 .. dynamic;       16               3*
9666
9667 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9668
9669 @end smallexample
9670
9671 @noindent
9672 Note: the entries marked ``3*'' are not actually specified by the Ada
9673 Reference Manual, but it seems in the spirit of the RM rules to allocate
9674 the minimum number of bits (here 3, given the range for @code{x2})
9675 known to be large enough to hold the given range of values.
9676
9677 So far, so good, but GNAT has to obey the RM rules, so the question is
9678 under what conditions must the RM @code{Size} be used.
9679 The following is a list
9680 of the occasions on which the RM @code{Size} must be used:
9681
9682 @itemize @bullet
9683 @item
9684 Component size for packed arrays or records
9685
9686 @item
9687 Value of the attribute @code{Size} for a type
9688
9689 @item
9690 Warning about sizes not matching for unchecked conversion
9691 @end itemize
9692
9693 @noindent
9694 For record types, the @code{Object_Size} is always a multiple of the
9695 alignment of the type (this is true for all types). In some cases the
9696 @code{Value_Size} can be smaller. Consider:
9697
9698 @smallexample
9699    type R is record
9700      X : Integer;
9701      Y : Character;
9702    end record;
9703 @end smallexample
9704
9705 @noindent
9706 On a typical 32-bit architecture, the X component will be four bytes, and
9707 require four-byte alignment, and the Y component will be one byte. In this
9708 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9709 required to store a value of this type, and for example, it is permissible
9710 to have a component of type R in an outer record whose component size is
9711 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9712 since it must be rounded up so that this value is a multiple of the
9713 alignment (4 bytes = 32 bits).
9714
9715 @noindent
9716 For all other types, the @code{Object_Size}
9717 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9718 Only @code{Size} may be specified for such types.
9719
9720 @node Component_Size Clauses
9721 @section Component_Size Clauses
9722 @cindex Component_Size Clause
9723
9724 @noindent
9725 Normally, the value specified in a component size clause must be consistent
9726 with the subtype of the array component with regard to size and alignment.
9727 In other words, the value specified must be at least equal to the size
9728 of this subtype, and must be a multiple of the alignment value.
9729
9730 In addition, component size clauses are allowed which cause the array
9731 to be packed, by specifying a smaller value.  The cases in which this
9732 is allowed are for component size values in the range 1 through 63.  The value
9733 specified must not be smaller than the Size of the subtype.  GNAT will
9734 accurately honor all packing requests in this range.  For example, if
9735 we have:
9736
9737 @smallexample @c ada
9738 type r is array (1 .. 8) of Natural;
9739 for r'Component_Size use 31;
9740 @end smallexample
9741
9742 @noindent
9743 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9744 Of course access to the components of such an array is considerably
9745 less efficient than if the natural component size of 32 is used.
9746
9747 Note that there is no point in giving both a component size clause
9748 and a pragma Pack for the same array type. if such duplicate
9749 clauses are given, the pragma Pack will be ignored.
9750
9751 @node Bit_Order Clauses
9752 @section Bit_Order Clauses
9753 @cindex Bit_Order Clause
9754 @cindex bit ordering
9755 @cindex ordering, of bits
9756
9757 @noindent
9758 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9759 attribute.  The specification may either correspond to the default bit
9760 order for the target, in which case the specification has no effect and
9761 places no additional restrictions, or it may be for the non-standard
9762 setting (that is the opposite of the default).
9763
9764 In the case where the non-standard value is specified, the effect is
9765 to renumber bits within each byte, but the ordering of bytes is not
9766 affected.  There are certain
9767 restrictions placed on component clauses as follows:
9768
9769 @itemize @bullet
9770
9771 @item Components fitting within a single storage unit.
9772 @noindent
9773 These are unrestricted, and the effect is merely to renumber bits.  For
9774 example if we are on a little-endian machine with @code{Low_Order_First}
9775 being the default, then the following two declarations have exactly
9776 the same effect:
9777
9778 @smallexample @c ada
9779    type R1 is record
9780       A : Boolean;
9781       B : Integer range 1 .. 120;
9782    end record;
9783
9784    for R1 use record
9785       A at 0 range 0 .. 0;
9786       B at 0 range 1 .. 7;
9787    end record;
9788
9789    type R2 is record
9790       A : Boolean;
9791       B : Integer range 1 .. 120;
9792    end record;
9793
9794    for R2'Bit_Order use High_Order_First;
9795
9796    for R2 use record
9797       A at 0 range 7 .. 7;
9798       B at 0 range 0 .. 6;
9799    end record;
9800 @end smallexample
9801
9802 @noindent
9803 The useful application here is to write the second declaration with the
9804 @code{Bit_Order} attribute definition clause, and know that it will be treated
9805 the same, regardless of whether the target is little-endian or big-endian.
9806
9807 @item Components occupying an integral number of bytes.
9808 @noindent
9809 These are components that exactly fit in two or more bytes.  Such component
9810 declarations are allowed, but have no effect, since it is important to realize
9811 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9812 In particular, the following attempt at getting an endian-independent integer
9813 does not work:
9814
9815 @smallexample @c ada
9816    type R2 is record
9817       A : Integer;
9818    end record;
9819
9820    for R2'Bit_Order use High_Order_First;
9821
9822    for R2 use record
9823       A at 0 range 0 .. 31;
9824    end record;
9825 @end smallexample
9826
9827 @noindent
9828 This declaration will result in a little-endian integer on a
9829 little-endian machine, and a big-endian integer on a big-endian machine.
9830 If byte flipping is required for interoperability between big- and
9831 little-endian machines, this must be explicitly programmed.  This capability
9832 is not provided by @code{Bit_Order}.
9833
9834 @item Components that are positioned across byte boundaries
9835 @noindent
9836 but do not occupy an integral number of bytes.  Given that bytes are not
9837 reordered, such fields would occupy a non-contiguous sequence of bits
9838 in memory, requiring non-trivial code to reassemble.  They are for this
9839 reason not permitted, and any component clause specifying such a layout
9840 will be flagged as illegal by GNAT@.
9841
9842 @end itemize
9843
9844 @noindent
9845 Since the misconception that Bit_Order automatically deals with all
9846 endian-related incompatibilities is a common one, the specification of
9847 a component field that is an integral number of bytes will always
9848 generate a warning.  This warning may be suppressed using
9849 @code{pragma Suppress} if desired.  The following section contains additional
9850 details regarding the issue of byte ordering.
9851
9852 @node Effect of Bit_Order on Byte Ordering
9853 @section Effect of Bit_Order on Byte Ordering
9854 @cindex byte ordering
9855 @cindex ordering, of bytes
9856
9857 @noindent
9858 In this section we will review the effect of the @code{Bit_Order} attribute
9859 definition clause on byte ordering.  Briefly, it has no effect at all, but
9860 a detailed example will be helpful.  Before giving this
9861 example, let us review the precise
9862 definition of the effect of defining @code{Bit_Order}.  The effect of a
9863 non-standard bit order is described in section 15.5.3 of the Ada
9864 Reference Manual:
9865
9866 @quotation
9867 2   A bit ordering is a method of interpreting the meaning of
9868 the storage place attributes.
9869 @end quotation
9870
9871 @noindent
9872 To understand the precise definition of storage place attributes in
9873 this context, we visit section 13.5.1 of the manual:
9874
9875 @quotation
9876 13   A record_representation_clause (without the mod_clause)
9877 specifies the layout.  The storage place attributes (see 13.5.2)
9878 are taken from the values of the position, first_bit, and last_bit
9879 expressions after normalizing those values so that first_bit is
9880 less than Storage_Unit.
9881 @end quotation
9882
9883 @noindent
9884 The critical point here is that storage places are taken from
9885 the values after normalization, not before.  So the @code{Bit_Order}
9886 interpretation applies to normalized values.  The interpretation
9887 is described in the later part of the 15.5.3 paragraph:
9888
9889 @quotation
9890 2   A bit ordering is a method of interpreting the meaning of
9891 the storage place attributes.  High_Order_First (known in the
9892 vernacular as ``big endian'') means that the first bit of a
9893 storage element (bit 0) is the most significant bit (interpreting
9894 the sequence of bits that represent a component as an unsigned
9895 integer value).  Low_Order_First (known in the vernacular as
9896 ``little endian'') means the opposite: the first bit is the
9897 least significant.
9898 @end quotation
9899
9900 @noindent
9901 Note that the numbering is with respect to the bits of a storage
9902 unit.  In other words, the specification affects only the numbering
9903 of bits within a single storage unit.
9904
9905 We can make the effect clearer by giving an example.
9906
9907 Suppose that we have an external device which presents two bytes, the first
9908 byte presented, which is the first (low addressed byte) of the two byte
9909 record is called Master, and the second byte is called Slave.
9910
9911 The left most (most significant bit is called Control for each byte, and
9912 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9913 (least significant) bit.
9914
9915 On a big-endian machine, we can write the following representation clause
9916
9917 @smallexample @c ada
9918    type Data is record
9919       Master_Control : Bit;
9920       Master_V1      : Bit;
9921       Master_V2      : Bit;
9922       Master_V3      : Bit;
9923       Master_V4      : Bit;
9924       Master_V5      : Bit;
9925       Master_V6      : Bit;
9926       Master_V7      : Bit;
9927       Slave_Control  : Bit;
9928       Slave_V1       : Bit;
9929       Slave_V2       : Bit;
9930       Slave_V3       : Bit;
9931       Slave_V4       : Bit;
9932       Slave_V5       : Bit;
9933       Slave_V6       : Bit;
9934       Slave_V7       : Bit;
9935    end record;
9936
9937    for Data use record
9938       Master_Control at 0 range 0 .. 0;
9939       Master_V1      at 0 range 1 .. 1;
9940       Master_V2      at 0 range 2 .. 2;
9941       Master_V3      at 0 range 3 .. 3;
9942       Master_V4      at 0 range 4 .. 4;
9943       Master_V5      at 0 range 5 .. 5;
9944       Master_V6      at 0 range 6 .. 6;
9945       Master_V7      at 0 range 7 .. 7;
9946       Slave_Control  at 1 range 0 .. 0;
9947       Slave_V1       at 1 range 1 .. 1;
9948       Slave_V2       at 1 range 2 .. 2;
9949       Slave_V3       at 1 range 3 .. 3;
9950       Slave_V4       at 1 range 4 .. 4;
9951       Slave_V5       at 1 range 5 .. 5;
9952       Slave_V6       at 1 range 6 .. 6;
9953       Slave_V7       at 1 range 7 .. 7;
9954    end record;
9955 @end smallexample
9956
9957 @noindent
9958 Now if we move this to a little endian machine, then the bit ordering within
9959 the byte is backwards, so we have to rewrite the record rep clause as:
9960
9961 @smallexample @c ada
9962    for Data use record
9963       Master_Control at 0 range 7 .. 7;
9964       Master_V1      at 0 range 6 .. 6;
9965       Master_V2      at 0 range 5 .. 5;
9966       Master_V3      at 0 range 4 .. 4;
9967       Master_V4      at 0 range 3 .. 3;
9968       Master_V5      at 0 range 2 .. 2;
9969       Master_V6      at 0 range 1 .. 1;
9970       Master_V7      at 0 range 0 .. 0;
9971       Slave_Control  at 1 range 7 .. 7;
9972       Slave_V1       at 1 range 6 .. 6;
9973       Slave_V2       at 1 range 5 .. 5;
9974       Slave_V3       at 1 range 4 .. 4;
9975       Slave_V4       at 1 range 3 .. 3;
9976       Slave_V5       at 1 range 2 .. 2;
9977       Slave_V6       at 1 range 1 .. 1;
9978       Slave_V7       at 1 range 0 .. 0;
9979    end record;
9980 @end smallexample
9981
9982 @noindent
9983 It is a nuisance to have to rewrite the clause, especially if
9984 the code has to be maintained on both machines.  However,
9985 this is a case that we can handle with the
9986 @code{Bit_Order} attribute if it is implemented.
9987 Note that the implementation is not required on byte addressed
9988 machines, but it is indeed implemented in GNAT.
9989 This means that we can simply use the
9990 first record clause, together with the declaration
9991
9992 @smallexample @c ada
9993    for Data'Bit_Order use High_Order_First;
9994 @end smallexample
9995
9996 @noindent
9997 and the effect is what is desired, namely the layout is exactly the same,
9998 independent of whether the code is compiled on a big-endian or little-endian
9999 machine.
10000
10001 The important point to understand is that byte ordering is not affected.
10002 A @code{Bit_Order} attribute definition never affects which byte a field
10003 ends up in, only where it ends up in that byte.
10004 To make this clear, let us rewrite the record rep clause of the previous
10005 example as:
10006
10007 @smallexample @c ada
10008    for Data'Bit_Order use High_Order_First;
10009    for Data use record
10010       Master_Control at 0 range  0 .. 0;
10011       Master_V1      at 0 range  1 .. 1;
10012       Master_V2      at 0 range  2 .. 2;
10013       Master_V3      at 0 range  3 .. 3;
10014       Master_V4      at 0 range  4 .. 4;
10015       Master_V5      at 0 range  5 .. 5;
10016       Master_V6      at 0 range  6 .. 6;
10017       Master_V7      at 0 range  7 .. 7;
10018       Slave_Control  at 0 range  8 .. 8;
10019       Slave_V1       at 0 range  9 .. 9;
10020       Slave_V2       at 0 range 10 .. 10;
10021       Slave_V3       at 0 range 11 .. 11;
10022       Slave_V4       at 0 range 12 .. 12;
10023       Slave_V5       at 0 range 13 .. 13;
10024       Slave_V6       at 0 range 14 .. 14;
10025       Slave_V7       at 0 range 15 .. 15;
10026    end record;
10027 @end smallexample
10028
10029 @noindent
10030 This is exactly equivalent to saying (a repeat of the first example):
10031
10032 @smallexample @c ada
10033    for Data'Bit_Order use High_Order_First;
10034    for Data use record
10035       Master_Control at 0 range 0 .. 0;
10036       Master_V1      at 0 range 1 .. 1;
10037       Master_V2      at 0 range 2 .. 2;
10038       Master_V3      at 0 range 3 .. 3;
10039       Master_V4      at 0 range 4 .. 4;
10040       Master_V5      at 0 range 5 .. 5;
10041       Master_V6      at 0 range 6 .. 6;
10042       Master_V7      at 0 range 7 .. 7;
10043       Slave_Control  at 1 range 0 .. 0;
10044       Slave_V1       at 1 range 1 .. 1;
10045       Slave_V2       at 1 range 2 .. 2;
10046       Slave_V3       at 1 range 3 .. 3;
10047       Slave_V4       at 1 range 4 .. 4;
10048       Slave_V5       at 1 range 5 .. 5;
10049       Slave_V6       at 1 range 6 .. 6;
10050       Slave_V7       at 1 range 7 .. 7;
10051    end record;
10052 @end smallexample
10053
10054 @noindent
10055 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10056 field.  The storage place attributes are obtained by normalizing the
10057 values given so that the @code{First_Bit} value is less than 8.  After
10058 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10059 we specified in the other case.
10060
10061 Now one might expect that the @code{Bit_Order} attribute might affect
10062 bit numbering within the entire record component (two bytes in this
10063 case, thus affecting which byte fields end up in), but that is not
10064 the way this feature is defined, it only affects numbering of bits,
10065 not which byte they end up in.
10066
10067 Consequently it never makes sense to specify a starting bit number
10068 greater than 7 (for a byte addressable field) if an attribute
10069 definition for @code{Bit_Order} has been given, and indeed it
10070 may be actively confusing to specify such a value, so the compiler
10071 generates a warning for such usage.
10072
10073 If you do need to control byte ordering then appropriate conditional
10074 values must be used.  If in our example, the slave byte came first on
10075 some machines we might write:
10076
10077 @smallexample @c ada
10078    Master_Byte_First constant Boolean := @dots{};
10079
10080    Master_Byte : constant Natural :=
10081                    1 - Boolean'Pos (Master_Byte_First);
10082    Slave_Byte  : constant Natural :=
10083                    Boolean'Pos (Master_Byte_First);
10084
10085    for Data'Bit_Order use High_Order_First;
10086    for Data use record
10087       Master_Control at Master_Byte range 0 .. 0;
10088       Master_V1      at Master_Byte range 1 .. 1;
10089       Master_V2      at Master_Byte range 2 .. 2;
10090       Master_V3      at Master_Byte range 3 .. 3;
10091       Master_V4      at Master_Byte range 4 .. 4;
10092       Master_V5      at Master_Byte range 5 .. 5;
10093       Master_V6      at Master_Byte range 6 .. 6;
10094       Master_V7      at Master_Byte range 7 .. 7;
10095       Slave_Control  at Slave_Byte  range 0 .. 0;
10096       Slave_V1       at Slave_Byte  range 1 .. 1;
10097       Slave_V2       at Slave_Byte  range 2 .. 2;
10098       Slave_V3       at Slave_Byte  range 3 .. 3;
10099       Slave_V4       at Slave_Byte  range 4 .. 4;
10100       Slave_V5       at Slave_Byte  range 5 .. 5;
10101       Slave_V6       at Slave_Byte  range 6 .. 6;
10102       Slave_V7       at Slave_Byte  range 7 .. 7;
10103    end record;
10104 @end smallexample
10105
10106 @noindent
10107 Now to switch between machines, all that is necessary is
10108 to set the boolean constant @code{Master_Byte_First} in
10109 an appropriate manner.
10110
10111 @node Pragma Pack for Arrays
10112 @section Pragma Pack for Arrays
10113 @cindex Pragma Pack (for arrays)
10114
10115 @noindent
10116 Pragma @code{Pack} applied to an array has no effect unless the component type
10117 is packable.  For a component type to be packable, it must be one of the
10118 following cases:
10119
10120 @itemize @bullet
10121 @item
10122 Any scalar type
10123 @item
10124 Any type whose size is specified with a size clause
10125 @item
10126 Any packed array type with a static size
10127 @end itemize
10128
10129 @noindent
10130 For all these cases, if the component subtype size is in the range
10131 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10132 component size were specified giving the component subtype size.
10133 For example if we have:
10134
10135 @smallexample @c ada
10136    type r is range 0 .. 17;
10137
10138    type ar is array (1 .. 8) of r;
10139    pragma Pack (ar);
10140 @end smallexample
10141
10142 @noindent
10143 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10144 and the size of the array @code{ar} will be exactly 40 bits.
10145
10146 Note that in some cases this rather fierce approach to packing can produce
10147 unexpected effects.  For example, in Ada 95 and Ada 2005,
10148 subtype @code{Natural} typically has a size of 31, meaning that if you
10149 pack an array of @code{Natural}, you get 31-bit
10150 close packing, which saves a few bits, but results in far less efficient
10151 access.  Since many other Ada compilers will ignore such a packing request,
10152 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10153 might not be what is intended.  You can easily remove this warning by
10154 using an explicit @code{Component_Size} setting instead, which never generates
10155 a warning, since the intention of the programmer is clear in this case.
10156
10157 GNAT treats packed arrays in one of two ways.  If the size of the array is
10158 known at compile time and is less than 64 bits, then internally the array
10159 is represented as a single modular type, of exactly the appropriate number
10160 of bits.  If the length is greater than 63 bits, or is not known at compile
10161 time, then the packed array is represented as an array of bytes, and the
10162 length is always a multiple of 8 bits.
10163
10164 Note that to represent a packed array as a modular type, the alignment must
10165 be suitable for the modular type involved. For example, on typical machines
10166 a 32-bit packed array will be represented by a 32-bit modular integer with
10167 an alignment of four bytes. If you explicitly override the default alignment
10168 with an alignment clause that is too small, the modular representation
10169 cannot be used. For example, consider the following set of declarations:
10170
10171 @smallexample @c ada
10172    type R is range 1 .. 3;
10173    type S is array (1 .. 31) of R;
10174    for S'Component_Size use 2;
10175    for S'Size use 62;
10176    for S'Alignment use 1;
10177 @end smallexample
10178
10179 @noindent
10180 If the alignment clause were not present, then a 62-bit modular
10181 representation would be chosen (typically with an alignment of 4 or 8
10182 bytes depending on the target). But the default alignment is overridden
10183 with the explicit alignment clause. This means that the modular
10184 representation cannot be used, and instead the array of bytes
10185 representation must be used, meaning that the length must be a multiple
10186 of 8. Thus the above set of declarations will result in a diagnostic
10187 rejecting the size clause and noting that the minimum size allowed is 64.
10188
10189 @cindex Pragma Pack (for type Natural)
10190 @cindex Pragma Pack warning
10191
10192 One special case that is worth noting occurs when the base type of the
10193 component size is 8/16/32 and the subtype is one bit less. Notably this
10194 occurs with subtype @code{Natural}. Consider:
10195
10196 @smallexample @c ada
10197    type Arr is array (1 .. 32) of Natural;
10198    pragma Pack (Arr);
10199 @end smallexample
10200
10201 @noindent
10202 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10203 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10204 Ada 83 compilers did not attempt 31 bit packing.
10205
10206 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10207 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10208 substantial unintended performance penalty when porting legacy Ada 83 code.
10209 To help prevent this, GNAT generates a warning in such cases. If you really
10210 want 31 bit packing in a case like this, you can set the component size
10211 explicitly:
10212
10213 @smallexample @c ada
10214    type Arr is array (1 .. 32) of Natural;
10215    for Arr'Component_Size use 31;
10216 @end smallexample
10217
10218 @noindent
10219 Here 31-bit packing is achieved as required, and no warning is generated,
10220 since in this case the programmer intention is clear.
10221
10222 @node Pragma Pack for Records
10223 @section Pragma Pack for Records
10224 @cindex Pragma Pack (for records)
10225
10226 @noindent
10227 Pragma @code{Pack} applied to a record will pack the components to reduce
10228 wasted space from alignment gaps and by reducing the amount of space
10229 taken by components.  We distinguish between @emph{packable} components and
10230 @emph{non-packable} components.
10231 Components of the following types are considered packable:
10232 @itemize @bullet
10233 @item
10234 All primitive types are packable.
10235
10236 @item
10237 Small packed arrays, whose size does not exceed 64 bits, and where the
10238 size is statically known at compile time, are represented internally
10239 as modular integers, and so they are also packable.
10240
10241 @end itemize
10242
10243 @noindent
10244 All packable components occupy the exact number of bits corresponding to
10245 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10246 can start on an arbitrary bit boundary.
10247
10248 All other types are non-packable, they occupy an integral number of
10249 storage units, and
10250 are placed at a boundary corresponding to their alignment requirements.
10251
10252 For example, consider the record
10253
10254 @smallexample @c ada
10255    type Rb1 is array (1 .. 13) of Boolean;
10256    pragma Pack (rb1);
10257
10258    type Rb2 is array (1 .. 65) of Boolean;
10259    pragma Pack (rb2);
10260
10261    type x2 is record
10262       l1 : Boolean;
10263       l2 : Duration;
10264       l3 : Float;
10265       l4 : Boolean;
10266       l5 : Rb1;
10267       l6 : Rb2;
10268    end record;
10269    pragma Pack (x2);
10270 @end smallexample
10271
10272 @noindent
10273 The representation for the record x2 is as follows:
10274
10275 @smallexample @c ada
10276 for x2'Size use 224;
10277 for x2 use record
10278    l1 at  0 range  0 .. 0;
10279    l2 at  0 range  1 .. 64;
10280    l3 at 12 range  0 .. 31;
10281    l4 at 16 range  0 .. 0;
10282    l5 at 16 range  1 .. 13;
10283    l6 at 18 range  0 .. 71;
10284 end record;
10285 @end smallexample
10286
10287 @noindent
10288 Studying this example, we see that the packable fields @code{l1}
10289 and @code{l2} are
10290 of length equal to their sizes, and placed at specific bit boundaries (and
10291 not byte boundaries) to
10292 eliminate padding.  But @code{l3} is of a non-packable float type, so
10293 it is on the next appropriate alignment boundary.
10294
10295 The next two fields are fully packable, so @code{l4} and @code{l5} are
10296 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10297 array that is longer than 64 bits, so it is itself non-packable.  Thus
10298 the @code{l6} field is aligned to the next byte boundary, and takes an
10299 integral number of bytes, i.e.@: 72 bits.
10300
10301 @node Record Representation Clauses
10302 @section Record Representation Clauses
10303 @cindex Record Representation Clause
10304
10305 @noindent
10306 Record representation clauses may be given for all record types, including
10307 types obtained by record extension.  Component clauses are allowed for any
10308 static component.  The restrictions on component clauses depend on the type
10309 of the component.
10310
10311 @cindex Component Clause
10312 For all components of an elementary type, the only restriction on component
10313 clauses is that the size must be at least the 'Size value of the type
10314 (actually the Value_Size).  There are no restrictions due to alignment,
10315 and such components may freely cross storage boundaries.
10316
10317 Packed arrays with a size up to and including 64 bits are represented
10318 internally using a modular type with the appropriate number of bits, and
10319 thus the same lack of restriction applies.  For example, if you declare:
10320
10321 @smallexample @c ada
10322    type R is array (1 .. 49) of Boolean;
10323    pragma Pack (R);
10324    for R'Size use 49;
10325 @end smallexample
10326
10327 @noindent
10328 then a component clause for a component of type R may start on any
10329 specified bit boundary, and may specify a value of 49 bits or greater.
10330
10331 For packed bit arrays that are longer than 64 bits, there are two
10332 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10333 including the important case of single bits or boolean values, then
10334 there are no limitations on placement of such components, and they
10335 may start and end at arbitrary bit boundaries.
10336
10337 If the component size is not a power of 2 (e.g. 3 or 5), then
10338 an array of this type longer than 64 bits must always be placed on
10339 on a storage unit (byte) boundary and occupy an integral number
10340 of storage units (bytes). Any component clause that does not
10341 meet this requirement will be rejected.
10342
10343 Any aliased component, or component of an aliased type, must
10344 have its normal alignment and size. A component clause that
10345 does not meet this requirement will be rejected.
10346
10347 The tag field of a tagged type always occupies an address sized field at
10348 the start of the record.  No component clause may attempt to overlay this
10349 tag. When a tagged type appears as a component, the tag field must have
10350 proper alignment
10351
10352 In the case of a record extension T1, of a type T, no component clause applied
10353 to the type T1 can specify a storage location that would overlap the first
10354 T'Size bytes of the record.
10355
10356 For all other component types, including non-bit-packed arrays,
10357 the component can be placed at an arbitrary bit boundary,
10358 so for example, the following is permitted:
10359
10360 @smallexample @c ada
10361    type R is array (1 .. 10) of Boolean;
10362    for R'Size use 80;
10363
10364    type Q is record
10365       G, H : Boolean;
10366       L, M : R;
10367    end record;
10368
10369    for Q use record
10370       G at 0 range  0 ..   0;
10371       H at 0 range  1 ..   1;
10372       L at 0 range  2 ..  81;
10373       R at 0 range 82 .. 161;
10374    end record;
10375 @end smallexample
10376
10377 @noindent
10378 Note: the above rules apply to recent releases of GNAT 5.
10379 In GNAT 3, there are more severe restrictions on larger components.
10380 For non-primitive types, including packed arrays with a size greater than
10381 64 bits, component clauses must respect the alignment requirement of the
10382 type, in particular, always starting on a byte boundary, and the length
10383 must be a multiple of the storage unit.
10384
10385 @node Enumeration Clauses
10386 @section Enumeration Clauses
10387
10388 The only restriction on enumeration clauses is that the range of values
10389 must be representable.  For the signed case, if one or more of the
10390 representation values are negative, all values must be in the range:
10391
10392 @smallexample @c ada
10393    System.Min_Int .. System.Max_Int
10394 @end smallexample
10395
10396 @noindent
10397 For the unsigned case, where all values are non negative, the values must
10398 be in the range:
10399
10400 @smallexample @c ada
10401    0 .. System.Max_Binary_Modulus;
10402 @end smallexample
10403
10404 @noindent
10405 A @emph{confirming} representation clause is one in which the values range
10406 from 0 in sequence, i.e.@: a clause that confirms the default representation
10407 for an enumeration type.
10408 Such a confirming representation
10409 is permitted by these rules, and is specially recognized by the compiler so
10410 that no extra overhead results from the use of such a clause.
10411
10412 If an array has an index type which is an enumeration type to which an
10413 enumeration clause has been applied, then the array is stored in a compact
10414 manner.  Consider the declarations:
10415
10416 @smallexample @c ada
10417    type r is (A, B, C);
10418    for r use (A => 1, B => 5, C => 10);
10419    type t is array (r) of Character;
10420 @end smallexample
10421
10422 @noindent
10423 The array type t corresponds to a vector with exactly three elements and
10424 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10425 use of space, but means that accesses to elements of the array will incur
10426 the overhead of converting representation values to the corresponding
10427 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10428
10429 @node Address Clauses
10430 @section Address Clauses
10431 @cindex Address Clause
10432
10433 The reference manual allows a general restriction on representation clauses,
10434 as found in RM 13.1(22):
10435
10436 @quotation
10437 An implementation need not support representation
10438 items containing nonstatic expressions, except that
10439 an implementation should support a representation item
10440 for a given entity if each nonstatic expression in the
10441 representation item is a name that statically denotes
10442 a constant declared before the entity.
10443 @end quotation
10444
10445 @noindent
10446 In practice this is applicable only to address clauses, since this is the
10447 only case in which a non-static expression is permitted by the syntax.  As
10448 the AARM notes in sections 13.1 (22.a-22.h):
10449
10450 @display
10451   22.a   Reason: This is to avoid the following sort of thing:
10452
10453   22.b        X : Integer := F(@dots{});
10454               Y : Address := G(@dots{});
10455               for X'Address use Y;
10456
10457   22.c   In the above, we have to evaluate the
10458          initialization expression for X before we
10459          know where to put the result.  This seems
10460          like an unreasonable implementation burden.
10461
10462   22.d   The above code should instead be written
10463          like this:
10464
10465   22.e        Y : constant Address := G(@dots{});
10466               X : Integer := F(@dots{});
10467               for X'Address use Y;
10468
10469   22.f   This allows the expression ``Y'' to be safely
10470          evaluated before X is created.
10471
10472   22.g   The constant could be a formal parameter of mode in.
10473
10474   22.h   An implementation can support other nonstatic
10475          expressions if it wants to.  Expressions of type
10476          Address are hardly ever static, but their value
10477          might be known at compile time anyway in many
10478          cases.
10479 @end display
10480
10481 @noindent
10482 GNAT does indeed permit many additional cases of non-static expressions.  In
10483 particular, if the type involved is elementary there are no restrictions
10484 (since in this case, holding a temporary copy of the initialization value,
10485 if one is present, is inexpensive).  In addition, if there is no implicit or
10486 explicit initialization, then there are no restrictions.  GNAT will reject
10487 only the case where all three of these conditions hold:
10488
10489 @itemize @bullet
10490
10491 @item
10492 The type of the item is non-elementary (e.g.@: a record or array).
10493
10494 @item
10495 There is explicit or implicit initialization required for the object.
10496 Note that access values are always implicitly initialized, and also
10497 in GNAT, certain bit-packed arrays (those having a dynamic length or
10498 a length greater than 64) will also be implicitly initialized to zero.
10499
10500 @item
10501 The address value is non-static.  Here GNAT is more permissive than the
10502 RM, and allows the address value to be the address of a previously declared
10503 stand-alone variable, as long as it does not itself have an address clause.
10504
10505 @smallexample @c ada
10506            Anchor  : Some_Initialized_Type;
10507            Overlay : Some_Initialized_Type;
10508            for Overlay'Address use Anchor'Address;
10509 @end smallexample
10510
10511 @noindent
10512 However, the prefix of the address clause cannot be an array component, or
10513 a component of a discriminated record.
10514
10515 @end itemize
10516
10517 @noindent
10518 As noted above in section 22.h, address values are typically non-static.  In
10519 particular the To_Address function, even if applied to a literal value, is
10520 a non-static function call.  To avoid this minor annoyance, GNAT provides
10521 the implementation defined attribute 'To_Address.  The following two
10522 expressions have identical values:
10523
10524 @findex Attribute
10525 @findex To_Address
10526 @smallexample @c ada
10527    To_Address (16#1234_0000#)
10528    System'To_Address (16#1234_0000#);
10529 @end smallexample
10530
10531 @noindent
10532 except that the second form is considered to be a static expression, and
10533 thus when used as an address clause value is always permitted.
10534
10535 @noindent
10536 Additionally, GNAT treats as static an address clause that is an
10537 unchecked_conversion of a static integer value.  This simplifies the porting
10538 of legacy code, and provides a portable equivalent to the GNAT attribute
10539 @code{To_Address}.
10540
10541 Another issue with address clauses is the interaction with alignment
10542 requirements.  When an address clause is given for an object, the address
10543 value must be consistent with the alignment of the object (which is usually
10544 the same as the alignment of the type of the object).  If an address clause
10545 is given that specifies an inappropriately aligned address value, then the
10546 program execution is erroneous.
10547
10548 Since this source of erroneous behavior can have unfortunate effects, GNAT
10549 checks (at compile time if possible, generating a warning, or at execution
10550 time with a run-time check) that the alignment is appropriate.  If the
10551 run-time check fails, then @code{Program_Error} is raised.  This run-time
10552 check is suppressed if range checks are suppressed, or if the special GNAT
10553 check Alignment_Check is suppressed, or if
10554 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10555
10556 Finally, GNAT does not permit overlaying of objects of controlled types or
10557 composite types containing a controlled component. In most cases, the compiler
10558 can detect an attempt at such overlays and will generate a warning at compile
10559 time and a Program_Error exception at run time.
10560
10561 @findex Export
10562 An address clause cannot be given for an exported object.  More
10563 understandably the real restriction is that objects with an address
10564 clause cannot be exported.  This is because such variables are not
10565 defined by the Ada program, so there is no external object to export.
10566
10567 @findex Import
10568 It is permissible to give an address clause and a pragma Import for the
10569 same object.  In this case, the variable is not really defined by the
10570 Ada program, so there is no external symbol to be linked.  The link name
10571 and the external name are ignored in this case.  The reason that we allow this
10572 combination is that it provides a useful idiom to avoid unwanted
10573 initializations on objects with address clauses.
10574
10575 When an address clause is given for an object that has implicit or
10576 explicit initialization, then by default initialization takes place.  This
10577 means that the effect of the object declaration is to overwrite the
10578 memory at the specified address.  This is almost always not what the
10579 programmer wants, so GNAT will output a warning:
10580
10581 @smallexample
10582   with System;
10583   package G is
10584      type R is record
10585         M : Integer := 0;
10586      end record;
10587
10588      Ext : R;
10589      for Ext'Address use System'To_Address (16#1234_1234#);
10590          |
10591   >>> warning: implicit initialization of "Ext" may
10592       modify overlaid storage
10593   >>> warning: use pragma Import for "Ext" to suppress
10594       initialization (RM B(24))
10595
10596   end G;
10597 @end smallexample
10598
10599 @noindent
10600 As indicated by the warning message, the solution is to use a (dummy) pragma
10601 Import to suppress this initialization.  The pragma tell the compiler that the
10602 object is declared and initialized elsewhere.  The following package compiles
10603 without warnings (and the initialization is suppressed):
10604
10605 @smallexample @c ada
10606    with System;
10607    package G is
10608       type R is record
10609          M : Integer := 0;
10610       end record;
10611
10612       Ext : R;
10613       for Ext'Address use System'To_Address (16#1234_1234#);
10614       pragma Import (Ada, Ext);
10615    end G;
10616 @end smallexample
10617
10618 @noindent
10619 A final issue with address clauses involves their use for overlaying
10620 variables, as in the following example:
10621 @cindex Overlaying of objects
10622
10623 @smallexample @c ada
10624   A : Integer;
10625   B : Integer;
10626   for B'Address use A'Address;
10627 @end smallexample
10628
10629 @noindent
10630 or alternatively, using the form recommended by the RM:
10631
10632 @smallexample @c ada
10633   A    : Integer;
10634   Addr : constant Address := A'Address;
10635   B    : Integer;
10636   for B'Address use Addr;
10637 @end smallexample
10638
10639 @noindent
10640 In both of these cases, @code{A}
10641 and @code{B} become aliased to one another via the
10642 address clause. This use of address clauses to overlay
10643 variables, achieving an effect similar to unchecked
10644 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10645 the effect is implementation defined. Furthermore, the
10646 Ada RM specifically recommends that in a situation
10647 like this, @code{B} should be subject to the following
10648 implementation advice (RM 13.3(19)):
10649
10650 @quotation
10651 19  If the Address of an object is specified, or it is imported
10652     or exported, then the implementation should not perform
10653     optimizations based on assumptions of no aliases.
10654 @end quotation
10655
10656 @noindent
10657 GNAT follows this recommendation, and goes further by also applying
10658 this recommendation to the overlaid variable (@code{A}
10659 in the above example) in this case. This means that the overlay
10660 works "as expected", in that a modification to one of the variables
10661 will affect the value of the other.
10662
10663 @node Effect of Convention on Representation
10664 @section Effect of Convention on Representation
10665 @cindex Convention, effect on representation
10666
10667 @noindent
10668 Normally the specification of a foreign language convention for a type or
10669 an object has no effect on the chosen representation.  In particular, the
10670 representation chosen for data in GNAT generally meets the standard system
10671 conventions, and for example records are laid out in a manner that is
10672 consistent with C@.  This means that specifying convention C (for example)
10673 has no effect.
10674
10675 There are four exceptions to this general rule:
10676
10677 @itemize @bullet
10678
10679 @item Convention Fortran and array subtypes
10680 If pragma Convention Fortran is specified for an array subtype, then in
10681 accordance with the implementation advice in section 3.6.2(11) of the
10682 Ada Reference Manual, the array will be stored in a Fortran-compatible
10683 column-major manner, instead of the normal default row-major order.
10684
10685 @item Convention C and enumeration types
10686 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10687 to accommodate all values of the type.  For example, for the enumeration
10688 type declared by:
10689
10690 @smallexample @c ada
10691    type Color is (Red, Green, Blue);
10692 @end smallexample
10693
10694 @noindent
10695 8 bits is sufficient to store all values of the type, so by default, objects
10696 of type @code{Color} will be represented using 8 bits.  However, normal C
10697 convention is to use 32 bits for all enum values in C, since enum values
10698 are essentially of type int.  If pragma @code{Convention C} is specified for an
10699 Ada enumeration type, then the size is modified as necessary (usually to
10700 32 bits) to be consistent with the C convention for enum values.
10701
10702 Note that this treatment applies only to types. If Convention C is given for
10703 an enumeration object, where the enumeration type is not Convention C, then
10704 Object_Size bits are allocated. For example, for a normal enumeration type,
10705 with less than 256 elements, only 8 bits will be allocated for the object.
10706 Since this may be a surprise in terms of what C expects, GNAT will issue a
10707 warning in this situation. The warning can be suppressed by giving an explicit
10708 size clause specifying the desired size.
10709
10710 @item Convention C/Fortran and Boolean types
10711 In C, the usual convention for boolean values, that is values used for
10712 conditions, is that zero represents false, and nonzero values represent
10713 true.  In Ada, the normal convention is that two specific values, typically
10714 0/1, are used to represent false/true respectively.
10715
10716 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10717 value represents true).
10718
10719 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10720 C or Fortran convention for a derived Boolean, as in the following example:
10721
10722 @smallexample @c ada
10723    type C_Switch is new Boolean;
10724    pragma Convention (C, C_Switch);
10725 @end smallexample
10726
10727 @noindent
10728 then the GNAT generated code will treat any nonzero value as true.  For truth
10729 values generated by GNAT, the conventional value 1 will be used for True, but
10730 when one of these values is read, any nonzero value is treated as True.
10731
10732 @item Access types on OpenVMS
10733 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10734 arrays) are 64-bits long. An exception to this rule is for the case of
10735 C-convention access types where there is no explicit size clause present (or
10736 inherited for derived types). In this case, GNAT chooses to make these
10737 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10738 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10739
10740 @end itemize
10741
10742 @node Determining the Representations chosen by GNAT
10743 @section Determining the Representations chosen by GNAT
10744 @cindex Representation, determination of
10745 @cindex @code{-gnatR} switch
10746
10747 @noindent
10748 Although the descriptions in this section are intended to be complete, it is
10749 often easier to simply experiment to see what GNAT accepts and what the
10750 effect is on the layout of types and objects.
10751
10752 As required by the Ada RM, if a representation clause is not accepted, then
10753 it must be rejected as illegal by the compiler.  However, when a
10754 representation clause or pragma is accepted, there can still be questions
10755 of what the compiler actually does.  For example, if a partial record
10756 representation clause specifies the location of some components and not
10757 others, then where are the non-specified components placed? Or if pragma
10758 @code{Pack} is used on a record, then exactly where are the resulting
10759 fields placed? The section on pragma @code{Pack} in this chapter can be
10760 used to answer the second question, but it is often easier to just see
10761 what the compiler does.
10762
10763 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10764 with this option, then the compiler will output information on the actual
10765 representations chosen, in a format similar to source representation
10766 clauses.  For example, if we compile the package:
10767
10768 @smallexample @c ada
10769 package q is
10770    type r (x : boolean) is tagged record
10771       case x is
10772          when True => S : String (1 .. 100);
10773          when False => null;
10774       end case;
10775    end record;
10776
10777    type r2 is new r (false) with record
10778       y2 : integer;
10779    end record;
10780
10781    for r2 use record
10782       y2 at 16 range 0 .. 31;
10783    end record;
10784
10785    type x is record
10786       y : character;
10787    end record;
10788
10789    type x1 is array (1 .. 10) of x;
10790    for x1'component_size use 11;
10791
10792    type ia is access integer;
10793
10794    type Rb1 is array (1 .. 13) of Boolean;
10795    pragma Pack (rb1);
10796
10797    type Rb2 is array (1 .. 65) of Boolean;
10798    pragma Pack (rb2);
10799
10800    type x2 is record
10801       l1 : Boolean;
10802       l2 : Duration;
10803       l3 : Float;
10804       l4 : Boolean;
10805       l5 : Rb1;
10806       l6 : Rb2;
10807    end record;
10808    pragma Pack (x2);
10809 end q;
10810 @end smallexample
10811
10812 @noindent
10813 using the switch @code{-gnatR} we obtain the following output:
10814
10815 @smallexample
10816 Representation information for unit q
10817 -------------------------------------
10818
10819 for r'Size use ??;
10820 for r'Alignment use 4;
10821 for r use record
10822    x    at 4 range  0 .. 7;
10823    _tag at 0 range  0 .. 31;
10824    s    at 5 range  0 .. 799;
10825 end record;
10826
10827 for r2'Size use 160;
10828 for r2'Alignment use 4;
10829 for r2 use record
10830    x       at  4 range  0 .. 7;
10831    _tag    at  0 range  0 .. 31;
10832    _parent at  0 range  0 .. 63;
10833    y2      at 16 range  0 .. 31;
10834 end record;
10835
10836 for x'Size use 8;
10837 for x'Alignment use 1;
10838 for x use record
10839    y at 0 range  0 .. 7;
10840 end record;
10841
10842 for x1'Size use 112;
10843 for x1'Alignment use 1;
10844 for x1'Component_Size use 11;
10845
10846 for rb1'Size use 13;
10847 for rb1'Alignment use 2;
10848 for rb1'Component_Size use 1;
10849
10850 for rb2'Size use 72;
10851 for rb2'Alignment use 1;
10852 for rb2'Component_Size use 1;
10853
10854 for x2'Size use 224;
10855 for x2'Alignment use 4;
10856 for x2 use record
10857    l1 at  0 range  0 .. 0;
10858    l2 at  0 range  1 .. 64;
10859    l3 at 12 range  0 .. 31;
10860    l4 at 16 range  0 .. 0;
10861    l5 at 16 range  1 .. 13;
10862    l6 at 18 range  0 .. 71;
10863 end record;
10864 @end smallexample
10865
10866 @noindent
10867 The Size values are actually the Object_Size, i.e.@: the default size that
10868 will be allocated for objects of the type.
10869 The ?? size for type r indicates that we have a variant record, and the
10870 actual size of objects will depend on the discriminant value.
10871
10872 The Alignment values show the actual alignment chosen by the compiler
10873 for each record or array type.
10874
10875 The record representation clause for type r shows where all fields
10876 are placed, including the compiler generated tag field (whose location
10877 cannot be controlled by the programmer).
10878
10879 The record representation clause for the type extension r2 shows all the
10880 fields present, including the parent field, which is a copy of the fields
10881 of the parent type of r2, i.e.@: r1.
10882
10883 The component size and size clauses for types rb1 and rb2 show
10884 the exact effect of pragma @code{Pack} on these arrays, and the record
10885 representation clause for type x2 shows how pragma @code{Pack} affects
10886 this record type.
10887
10888 In some cases, it may be useful to cut and paste the representation clauses
10889 generated by the compiler into the original source to fix and guarantee
10890 the actual representation to be used.
10891
10892 @node Standard Library Routines
10893 @chapter Standard Library Routines
10894
10895 @noindent
10896 The Ada Reference Manual contains in Annex A a full description of an
10897 extensive set of standard library routines that can be used in any Ada
10898 program, and which must be provided by all Ada compilers.  They are
10899 analogous to the standard C library used by C programs.
10900
10901 GNAT implements all of the facilities described in annex A, and for most
10902 purposes the description in the Ada Reference Manual, or appropriate Ada
10903 text book, will be sufficient for making use of these facilities.
10904
10905 In the case of the input-output facilities,
10906 @xref{The Implementation of Standard I/O},
10907 gives details on exactly how GNAT interfaces to the
10908 file system.  For the remaining packages, the Ada Reference Manual
10909 should be sufficient.  The following is a list of the packages included,
10910 together with a brief description of the functionality that is provided.
10911
10912 For completeness, references are included to other predefined library
10913 routines defined in other sections of the Ada Reference Manual (these are
10914 cross-indexed from Annex A).
10915
10916 @table @code
10917 @item Ada (A.2)
10918 This is a parent package for all the standard library packages.  It is
10919 usually included implicitly in your program, and itself contains no
10920 useful data or routines.
10921
10922 @item Ada.Calendar (9.6)
10923 @code{Calendar} provides time of day access, and routines for
10924 manipulating times and durations.
10925
10926 @item Ada.Characters (A.3.1)
10927 This is a dummy parent package that contains no useful entities
10928
10929 @item Ada.Characters.Handling (A.3.2)
10930 This package provides some basic character handling capabilities,
10931 including classification functions for classes of characters (e.g.@: test
10932 for letters, or digits).
10933
10934 @item Ada.Characters.Latin_1 (A.3.3)
10935 This package includes a complete set of definitions of the characters
10936 that appear in type CHARACTER@.  It is useful for writing programs that
10937 will run in international environments.  For example, if you want an
10938 upper case E with an acute accent in a string, it is often better to use
10939 the definition of @code{UC_E_Acute} in this package.  Then your program
10940 will print in an understandable manner even if your environment does not
10941 support these extended characters.
10942
10943 @item Ada.Command_Line (A.15)
10944 This package provides access to the command line parameters and the name
10945 of the current program (analogous to the use of @code{argc} and @code{argv}
10946 in C), and also allows the exit status for the program to be set in a
10947 system-independent manner.
10948
10949 @item Ada.Decimal (F.2)
10950 This package provides constants describing the range of decimal numbers
10951 implemented, and also a decimal divide routine (analogous to the COBOL
10952 verb DIVIDE .. GIVING .. REMAINDER ..)
10953
10954 @item Ada.Direct_IO (A.8.4)
10955 This package provides input-output using a model of a set of records of
10956 fixed-length, containing an arbitrary definite Ada type, indexed by an
10957 integer record number.
10958
10959 @item Ada.Dynamic_Priorities (D.5)
10960 This package allows the priorities of a task to be adjusted dynamically
10961 as the task is running.
10962
10963 @item Ada.Exceptions (11.4.1)
10964 This package provides additional information on exceptions, and also
10965 contains facilities for treating exceptions as data objects, and raising
10966 exceptions with associated messages.
10967
10968 @item Ada.Finalization (7.6)
10969 This package contains the declarations and subprograms to support the
10970 use of controlled types, providing for automatic initialization and
10971 finalization (analogous to the constructors and destructors of C++)
10972
10973 @item Ada.Interrupts (C.3.2)
10974 This package provides facilities for interfacing to interrupts, which
10975 includes the set of signals or conditions that can be raised and
10976 recognized as interrupts.
10977
10978 @item Ada.Interrupts.Names (C.3.2)
10979 This package provides the set of interrupt names (actually signal
10980 or condition names) that can be handled by GNAT@.
10981
10982 @item Ada.IO_Exceptions (A.13)
10983 This package defines the set of exceptions that can be raised by use of
10984 the standard IO packages.
10985
10986 @item Ada.Numerics
10987 This package contains some standard constants and exceptions used
10988 throughout the numerics packages.  Note that the constants pi and e are
10989 defined here, and it is better to use these definitions than rolling
10990 your own.
10991
10992 @item Ada.Numerics.Complex_Elementary_Functions
10993 Provides the implementation of standard elementary functions (such as
10994 log and trigonometric functions) operating on complex numbers using the
10995 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10996 created by the package @code{Numerics.Complex_Types}.
10997
10998 @item Ada.Numerics.Complex_Types
10999 This is a predefined instantiation of
11000 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11001 build the type @code{Complex} and @code{Imaginary}.
11002
11003 @item Ada.Numerics.Discrete_Random
11004 This package provides a random number generator suitable for generating
11005 random integer values from a specified range.
11006
11007 @item Ada.Numerics.Float_Random
11008 This package provides a random number generator suitable for generating
11009 uniformly distributed floating point values.
11010
11011 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11012 This is a generic version of the package that provides the
11013 implementation of standard elementary functions (such as log and
11014 trigonometric functions) for an arbitrary complex type.
11015
11016 The following predefined instantiations of this package are provided:
11017
11018 @table @code
11019 @item Short_Float
11020 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11021 @item Float
11022 @code{Ada.Numerics.Complex_Elementary_Functions}
11023 @item Long_Float
11024 @code{Ada.Numerics.
11025  Long_Complex_Elementary_Functions}
11026 @end table
11027
11028 @item Ada.Numerics.Generic_Complex_Types
11029 This is a generic package that allows the creation of complex types,
11030 with associated complex arithmetic operations.
11031
11032 The following predefined instantiations of this package exist
11033 @table @code
11034 @item Short_Float
11035 @code{Ada.Numerics.Short_Complex_Complex_Types}
11036 @item Float
11037 @code{Ada.Numerics.Complex_Complex_Types}
11038 @item Long_Float
11039 @code{Ada.Numerics.Long_Complex_Complex_Types}
11040 @end table
11041
11042 @item Ada.Numerics.Generic_Elementary_Functions
11043 This is a generic package that provides the implementation of standard
11044 elementary functions (such as log an trigonometric functions) for an
11045 arbitrary float type.
11046
11047 The following predefined instantiations of this package exist
11048
11049 @table @code
11050 @item Short_Float
11051 @code{Ada.Numerics.Short_Elementary_Functions}
11052 @item Float
11053 @code{Ada.Numerics.Elementary_Functions}
11054 @item Long_Float
11055 @code{Ada.Numerics.Long_Elementary_Functions}
11056 @end table
11057
11058 @item Ada.Real_Time (D.8)
11059 This package provides facilities similar to those of @code{Calendar}, but
11060 operating with a finer clock suitable for real time control. Note that
11061 annex D requires that there be no backward clock jumps, and GNAT generally
11062 guarantees this behavior, but of course if the external clock on which
11063 the GNAT runtime depends is deliberately reset by some external event,
11064 then such a backward jump may occur.
11065
11066 @item Ada.Sequential_IO (A.8.1)
11067 This package provides input-output facilities for sequential files,
11068 which can contain a sequence of values of a single type, which can be
11069 any Ada type, including indefinite (unconstrained) types.
11070
11071 @item Ada.Storage_IO (A.9)
11072 This package provides a facility for mapping arbitrary Ada types to and
11073 from a storage buffer.  It is primarily intended for the creation of new
11074 IO packages.
11075
11076 @item Ada.Streams (13.13.1)
11077 This is a generic package that provides the basic support for the
11078 concept of streams as used by the stream attributes (@code{Input},
11079 @code{Output}, @code{Read} and @code{Write}).
11080
11081 @item Ada.Streams.Stream_IO (A.12.1)
11082 This package is a specialization of the type @code{Streams} defined in
11083 package @code{Streams} together with a set of operations providing
11084 Stream_IO capability.  The Stream_IO model permits both random and
11085 sequential access to a file which can contain an arbitrary set of values
11086 of one or more Ada types.
11087
11088 @item Ada.Strings (A.4.1)
11089 This package provides some basic constants used by the string handling
11090 packages.
11091
11092 @item Ada.Strings.Bounded (A.4.4)
11093 This package provides facilities for handling variable length
11094 strings.  The bounded model requires a maximum length.  It is thus
11095 somewhat more limited than the unbounded model, but avoids the use of
11096 dynamic allocation or finalization.
11097
11098 @item Ada.Strings.Fixed (A.4.3)
11099 This package provides facilities for handling fixed length strings.
11100
11101 @item Ada.Strings.Maps (A.4.2)
11102 This package provides facilities for handling character mappings and
11103 arbitrarily defined subsets of characters.  For instance it is useful in
11104 defining specialized translation tables.
11105
11106 @item Ada.Strings.Maps.Constants (A.4.6)
11107 This package provides a standard set of predefined mappings and
11108 predefined character sets.  For example, the standard upper to lower case
11109 conversion table is found in this package.  Note that upper to lower case
11110 conversion is non-trivial if you want to take the entire set of
11111 characters, including extended characters like E with an acute accent,
11112 into account.  You should use the mappings in this package (rather than
11113 adding 32 yourself) to do case mappings.
11114
11115 @item Ada.Strings.Unbounded (A.4.5)
11116 This package provides facilities for handling variable length
11117 strings.  The unbounded model allows arbitrary length strings, but
11118 requires the use of dynamic allocation and finalization.
11119
11120 @item Ada.Strings.Wide_Bounded (A.4.7)
11121 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11122 @itemx Ada.Strings.Wide_Maps (A.4.7)
11123 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11124 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11125 These packages provide analogous capabilities to the corresponding
11126 packages without @samp{Wide_} in the name, but operate with the types
11127 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11128 and @code{Character}.
11129
11130 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11131 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11132 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11133 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11134 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11135 These packages provide analogous capabilities to the corresponding
11136 packages without @samp{Wide_} in the name, but operate with the types
11137 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11138 of @code{String} and @code{Character}.
11139
11140 @item Ada.Synchronous_Task_Control (D.10)
11141 This package provides some standard facilities for controlling task
11142 communication in a synchronous manner.
11143
11144 @item Ada.Tags
11145 This package contains definitions for manipulation of the tags of tagged
11146 values.
11147
11148 @item Ada.Task_Attributes
11149 This package provides the capability of associating arbitrary
11150 task-specific data with separate tasks.
11151
11152 @item Ada.Text_IO
11153 This package provides basic text input-output capabilities for
11154 character, string and numeric data.  The subpackages of this
11155 package are listed next.
11156
11157 @item Ada.Text_IO.Decimal_IO
11158 Provides input-output facilities for decimal fixed-point types
11159
11160 @item Ada.Text_IO.Enumeration_IO
11161 Provides input-output facilities for enumeration types.
11162
11163 @item Ada.Text_IO.Fixed_IO
11164 Provides input-output facilities for ordinary fixed-point types.
11165
11166 @item Ada.Text_IO.Float_IO
11167 Provides input-output facilities for float types.  The following
11168 predefined instantiations of this generic package are available:
11169
11170 @table @code
11171 @item Short_Float
11172 @code{Short_Float_Text_IO}
11173 @item Float
11174 @code{Float_Text_IO}
11175 @item Long_Float
11176 @code{Long_Float_Text_IO}
11177 @end table
11178
11179 @item Ada.Text_IO.Integer_IO
11180 Provides input-output facilities for integer types.  The following
11181 predefined instantiations of this generic package are available:
11182
11183 @table @code
11184 @item Short_Short_Integer
11185 @code{Ada.Short_Short_Integer_Text_IO}
11186 @item Short_Integer
11187 @code{Ada.Short_Integer_Text_IO}
11188 @item Integer
11189 @code{Ada.Integer_Text_IO}
11190 @item Long_Integer
11191 @code{Ada.Long_Integer_Text_IO}
11192 @item Long_Long_Integer
11193 @code{Ada.Long_Long_Integer_Text_IO}
11194 @end table
11195
11196 @item Ada.Text_IO.Modular_IO
11197 Provides input-output facilities for modular (unsigned) types
11198
11199 @item Ada.Text_IO.Complex_IO (G.1.3)
11200 This package provides basic text input-output capabilities for complex
11201 data.
11202
11203 @item Ada.Text_IO.Editing (F.3.3)
11204 This package contains routines for edited output, analogous to the use
11205 of pictures in COBOL@.  The picture formats used by this package are a
11206 close copy of the facility in COBOL@.
11207
11208 @item Ada.Text_IO.Text_Streams (A.12.2)
11209 This package provides a facility that allows Text_IO files to be treated
11210 as streams, so that the stream attributes can be used for writing
11211 arbitrary data, including binary data, to Text_IO files.
11212
11213 @item Ada.Unchecked_Conversion (13.9)
11214 This generic package allows arbitrary conversion from one type to
11215 another of the same size, providing for breaking the type safety in
11216 special circumstances.
11217
11218 If the types have the same Size (more accurately the same Value_Size),
11219 then the effect is simply to transfer the bits from the source to the
11220 target type without any modification.  This usage is well defined, and
11221 for simple types whose representation is typically the same across
11222 all implementations, gives a portable method of performing such
11223 conversions.
11224
11225 If the types do not have the same size, then the result is implementation
11226 defined, and thus may be non-portable.  The following describes how GNAT
11227 handles such unchecked conversion cases.
11228
11229 If the types are of different sizes, and are both discrete types, then
11230 the effect is of a normal type conversion without any constraint checking.
11231 In particular if the result type has a larger size, the result will be
11232 zero or sign extended.  If the result type has a smaller size, the result
11233 will be truncated by ignoring high order bits.
11234
11235 If the types are of different sizes, and are not both discrete types,
11236 then the conversion works as though pointers were created to the source
11237 and target, and the pointer value is converted.  The effect is that bits
11238 are copied from successive low order storage units and bits of the source
11239 up to the length of the target type.
11240
11241 A warning is issued if the lengths differ, since the effect in this
11242 case is implementation dependent, and the above behavior may not match
11243 that of some other compiler.
11244
11245 A pointer to one type may be converted to a pointer to another type using
11246 unchecked conversion.  The only case in which the effect is undefined is
11247 when one or both pointers are pointers to unconstrained array types.  In
11248 this case, the bounds information may get incorrectly transferred, and in
11249 particular, GNAT uses double size pointers for such types, and it is
11250 meaningless to convert between such pointer types.  GNAT will issue a
11251 warning if the alignment of the target designated type is more strict
11252 than the alignment of the source designated type (since the result may
11253 be unaligned in this case).
11254
11255 A pointer other than a pointer to an unconstrained array type may be
11256 converted to and from System.Address.  Such usage is common in Ada 83
11257 programs, but note that Ada.Address_To_Access_Conversions is the
11258 preferred method of performing such conversions in Ada 95 and Ada 2005.
11259 Neither
11260 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11261 used in conjunction with pointers to unconstrained objects, since
11262 the bounds information cannot be handled correctly in this case.
11263
11264 @item Ada.Unchecked_Deallocation (13.11.2)
11265 This generic package allows explicit freeing of storage previously
11266 allocated by use of an allocator.
11267
11268 @item Ada.Wide_Text_IO (A.11)
11269 This package is similar to @code{Ada.Text_IO}, except that the external
11270 file supports wide character representations, and the internal types are
11271 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11272 and @code{String}.  It contains generic subpackages listed next.
11273
11274 @item Ada.Wide_Text_IO.Decimal_IO
11275 Provides input-output facilities for decimal fixed-point types
11276
11277 @item Ada.Wide_Text_IO.Enumeration_IO
11278 Provides input-output facilities for enumeration types.
11279
11280 @item Ada.Wide_Text_IO.Fixed_IO
11281 Provides input-output facilities for ordinary fixed-point types.
11282
11283 @item Ada.Wide_Text_IO.Float_IO
11284 Provides input-output facilities for float types.  The following
11285 predefined instantiations of this generic package are available:
11286
11287 @table @code
11288 @item Short_Float
11289 @code{Short_Float_Wide_Text_IO}
11290 @item Float
11291 @code{Float_Wide_Text_IO}
11292 @item Long_Float
11293 @code{Long_Float_Wide_Text_IO}
11294 @end table
11295
11296 @item Ada.Wide_Text_IO.Integer_IO
11297 Provides input-output facilities for integer types.  The following
11298 predefined instantiations of this generic package are available:
11299
11300 @table @code
11301 @item Short_Short_Integer
11302 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11303 @item Short_Integer
11304 @code{Ada.Short_Integer_Wide_Text_IO}
11305 @item Integer
11306 @code{Ada.Integer_Wide_Text_IO}
11307 @item Long_Integer
11308 @code{Ada.Long_Integer_Wide_Text_IO}
11309 @item Long_Long_Integer
11310 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11311 @end table
11312
11313 @item Ada.Wide_Text_IO.Modular_IO
11314 Provides input-output facilities for modular (unsigned) types
11315
11316 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11317 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11318 external file supports wide character representations.
11319
11320 @item Ada.Wide_Text_IO.Editing (F.3.4)
11321 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11322 types are @code{Wide_Character} and @code{Wide_String} instead of
11323 @code{Character} and @code{String}.
11324
11325 @item Ada.Wide_Text_IO.Streams (A.12.3)
11326 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11327 types are @code{Wide_Character} and @code{Wide_String} instead of
11328 @code{Character} and @code{String}.
11329
11330 @item Ada.Wide_Wide_Text_IO (A.11)
11331 This package is similar to @code{Ada.Text_IO}, except that the external
11332 file supports wide character representations, and the internal types are
11333 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11334 and @code{String}.  It contains generic subpackages listed next.
11335
11336 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11337 Provides input-output facilities for decimal fixed-point types
11338
11339 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11340 Provides input-output facilities for enumeration types.
11341
11342 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11343 Provides input-output facilities for ordinary fixed-point types.
11344
11345 @item Ada.Wide_Wide_Text_IO.Float_IO
11346 Provides input-output facilities for float types.  The following
11347 predefined instantiations of this generic package are available:
11348
11349 @table @code
11350 @item Short_Float
11351 @code{Short_Float_Wide_Wide_Text_IO}
11352 @item Float
11353 @code{Float_Wide_Wide_Text_IO}
11354 @item Long_Float
11355 @code{Long_Float_Wide_Wide_Text_IO}
11356 @end table
11357
11358 @item Ada.Wide_Wide_Text_IO.Integer_IO
11359 Provides input-output facilities for integer types.  The following
11360 predefined instantiations of this generic package are available:
11361
11362 @table @code
11363 @item Short_Short_Integer
11364 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11365 @item Short_Integer
11366 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11367 @item Integer
11368 @code{Ada.Integer_Wide_Wide_Text_IO}
11369 @item Long_Integer
11370 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11371 @item Long_Long_Integer
11372 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11373 @end table
11374
11375 @item Ada.Wide_Wide_Text_IO.Modular_IO
11376 Provides input-output facilities for modular (unsigned) types
11377
11378 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11379 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11380 external file supports wide character representations.
11381
11382 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11383 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11384 types are @code{Wide_Character} and @code{Wide_String} instead of
11385 @code{Character} and @code{String}.
11386
11387 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11388 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11389 types are @code{Wide_Character} and @code{Wide_String} instead of
11390 @code{Character} and @code{String}.
11391 @end table
11392
11393
11394
11395 @node The Implementation of Standard I/O
11396 @chapter The Implementation of Standard I/O
11397
11398 @noindent
11399 GNAT implements all the required input-output facilities described in
11400 A.6 through A.14.  These sections of the Ada Reference Manual describe the
11401 required behavior of these packages from the Ada point of view, and if
11402 you are writing a portable Ada program that does not need to know the
11403 exact manner in which Ada maps to the outside world when it comes to
11404 reading or writing external files, then you do not need to read this
11405 chapter.  As long as your files are all regular files (not pipes or
11406 devices), and as long as you write and read the files only from Ada, the
11407 description in the Ada Reference Manual is sufficient.
11408
11409 However, if you want to do input-output to pipes or other devices, such
11410 as the keyboard or screen, or if the files you are dealing with are
11411 either generated by some other language, or to be read by some other
11412 language, then you need to know more about the details of how the GNAT
11413 implementation of these input-output facilities behaves.
11414
11415 In this chapter we give a detailed description of exactly how GNAT
11416 interfaces to the file system.  As always, the sources of the system are
11417 available to you for answering questions at an even more detailed level,
11418 but for most purposes the information in this chapter will suffice.
11419
11420 Another reason that you may need to know more about how input-output is
11421 implemented arises when you have a program written in mixed languages
11422 where, for example, files are shared between the C and Ada sections of
11423 the same program.  GNAT provides some additional facilities, in the form
11424 of additional child library packages, that facilitate this sharing, and
11425 these additional facilities are also described in this chapter.
11426
11427 @menu
11428 * Standard I/O Packages::
11429 * FORM Strings::
11430 * Direct_IO::
11431 * Sequential_IO::
11432 * Text_IO::
11433 * Wide_Text_IO::
11434 * Wide_Wide_Text_IO::
11435 * Stream_IO::
11436 * Shared Files::
11437 * Filenames encoding::
11438 * Open Modes::
11439 * Operations on C Streams::
11440 * Interfacing to C Streams::
11441 @end menu
11442
11443 @node Standard I/O Packages
11444 @section Standard I/O Packages
11445
11446 @noindent
11447 The Standard I/O packages described in Annex A for
11448
11449 @itemize @bullet
11450 @item
11451 Ada.Text_IO
11452 @item
11453 Ada.Text_IO.Complex_IO
11454 @item
11455 Ada.Text_IO.Text_Streams
11456 @item
11457 Ada.Wide_Text_IO
11458 @item
11459 Ada.Wide_Text_IO.Complex_IO
11460 @item
11461 Ada.Wide_Text_IO.Text_Streams
11462 @item
11463 Ada.Wide_Wide_Text_IO
11464 @item
11465 Ada.Wide_Wide_Text_IO.Complex_IO
11466 @item
11467 Ada.Wide_Wide_Text_IO.Text_Streams
11468 @item
11469 Ada.Stream_IO
11470 @item
11471 Ada.Sequential_IO
11472 @item
11473 Ada.Direct_IO
11474 @end itemize
11475
11476 @noindent
11477 are implemented using the C
11478 library streams facility; where
11479
11480 @itemize @bullet
11481 @item
11482 All files are opened using @code{fopen}.
11483 @item
11484 All input/output operations use @code{fread}/@code{fwrite}.
11485 @end itemize
11486
11487 @noindent
11488 There is no internal buffering of any kind at the Ada library level. The only
11489 buffering is that provided at the system level in the implementation of the
11490 library routines that support streams. This facilitates shared use of these
11491 streams by mixed language programs. Note though that system level buffering is
11492 explicitly enabled at elaboration of the standard I/O packages and that can
11493 have an impact on mixed language programs, in particular those using I/O before
11494 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11495 the Ada elaboration routine before performing any I/O or when impractical,
11496 flush the common I/O streams and in particular Standard_Output before
11497 elaborating the Ada code.
11498
11499 @node FORM Strings
11500 @section FORM Strings
11501
11502 @noindent
11503 The format of a FORM string in GNAT is:
11504
11505 @smallexample
11506 "keyword=value,keyword=value,@dots{},keyword=value"
11507 @end smallexample
11508
11509 @noindent
11510 where letters may be in upper or lower case, and there are no spaces
11511 between values.  The order of the entries is not important.  Currently
11512 there are two keywords defined.
11513
11514 @smallexample
11515 SHARED=[YES|NO]
11516 WCEM=[n|h|u|s|e|8|b]
11517 @end smallexample
11518
11519 @noindent
11520 The use of these parameters is described later in this section.
11521
11522 @node Direct_IO
11523 @section Direct_IO
11524
11525 @noindent
11526 Direct_IO can only be instantiated for definite types.  This is a
11527 restriction of the Ada language, which means that the records are fixed
11528 length (the length being determined by @code{@var{type}'Size}, rounded
11529 up to the next storage unit boundary if necessary).
11530
11531 The records of a Direct_IO file are simply written to the file in index
11532 sequence, with the first record starting at offset zero, and subsequent
11533 records following.  There is no control information of any kind.  For
11534 example, if 32-bit integers are being written, each record takes
11535 4-bytes, so the record at index @var{K} starts at offset
11536 (@var{K}@minus{}1)*4.
11537
11538 There is no limit on the size of Direct_IO files, they are expanded as
11539 necessary to accommodate whatever records are written to the file.
11540
11541 @node Sequential_IO
11542 @section Sequential_IO
11543
11544 @noindent
11545 Sequential_IO may be instantiated with either a definite (constrained)
11546 or indefinite (unconstrained) type.
11547
11548 For the definite type case, the elements written to the file are simply
11549 the memory images of the data values with no control information of any
11550 kind.  The resulting file should be read using the same type, no validity
11551 checking is performed on input.
11552
11553 For the indefinite type case, the elements written consist of two
11554 parts.  First is the size of the data item, written as the memory image
11555 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11556 the data value.  The resulting file can only be read using the same
11557 (unconstrained) type.  Normal assignment checks are performed on these
11558 read operations, and if these checks fail, @code{Data_Error} is
11559 raised.  In particular, in the array case, the lengths must match, and in
11560 the variant record case, if the variable for a particular read operation
11561 is constrained, the discriminants must match.
11562
11563 Note that it is not possible to use Sequential_IO to write variable
11564 length array items, and then read the data back into different length
11565 arrays.  For example, the following will raise @code{Data_Error}:
11566
11567 @smallexample @c ada
11568  package IO is new Sequential_IO (String);
11569  F : IO.File_Type;
11570  S : String (1..4);
11571  @dots{}
11572  IO.Create (F)
11573  IO.Write (F, "hello!")
11574  IO.Reset (F, Mode=>In_File);
11575  IO.Read (F, S);
11576  Put_Line (S);
11577
11578 @end smallexample
11579
11580 @noindent
11581 On some Ada implementations, this will print @code{hell}, but the program is
11582 clearly incorrect, since there is only one element in the file, and that
11583 element is the string @code{hello!}.
11584
11585 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11586 using Stream_IO, and this is the preferred mechanism.  In particular, the
11587 above program fragment rewritten to use Stream_IO will work correctly.
11588
11589 @node Text_IO
11590 @section Text_IO
11591
11592 @noindent
11593 Text_IO files consist of a stream of characters containing the following
11594 special control characters:
11595
11596 @smallexample
11597 LF (line feed, 16#0A#) Line Mark
11598 FF (form feed, 16#0C#) Page Mark
11599 @end smallexample
11600
11601 @noindent
11602 A canonical Text_IO file is defined as one in which the following
11603 conditions are met:
11604
11605 @itemize @bullet
11606 @item
11607 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11608 of the line.
11609
11610 @item
11611 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11612 end of a page and consequently can appear only immediately following a
11613 @code{LF} (line mark) character.
11614
11615 @item
11616 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11617 (line mark, page mark).  In the former case, the page mark is implicitly
11618 assumed to be present.
11619 @end itemize
11620
11621 @noindent
11622 A file written using Text_IO will be in canonical form provided that no
11623 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11624 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11625 the file unless an explicit @code{New_Page} operation was performed
11626 before closing the file.
11627
11628 A canonical Text_IO file that is a regular file (i.e., not a device or a
11629 pipe) can be read using any of the routines in Text_IO@.  The
11630 semantics in this case will be exactly as defined in the Ada Reference
11631 Manual, and all the routines in Text_IO are fully implemented.
11632
11633 A text file that does not meet the requirements for a canonical Text_IO
11634 file has one of the following:
11635
11636 @itemize @bullet
11637 @item
11638 The file contains @code{FF} characters not immediately following a
11639 @code{LF} character.
11640
11641 @item
11642 The file contains @code{LF} or @code{FF} characters written by
11643 @code{Put} or @code{Put_Line}, which are not logically considered to be
11644 line marks or page marks.
11645
11646 @item
11647 The file ends in a character other than @code{LF} or @code{FF},
11648 i.e.@: there is no explicit line mark or page mark at the end of the file.
11649 @end itemize
11650
11651 @noindent
11652 Text_IO can be used to read such non-standard text files but subprograms
11653 to do with line or page numbers do not have defined meanings.  In
11654 particular, a @code{FF} character that does not follow a @code{LF}
11655 character may or may not be treated as a page mark from the point of
11656 view of page and line numbering.  Every @code{LF} character is considered
11657 to end a line, and there is an implied @code{LF} character at the end of
11658 the file.
11659
11660 @menu
11661 * Text_IO Stream Pointer Positioning::
11662 * Text_IO Reading and Writing Non-Regular Files::
11663 * Get_Immediate::
11664 * Treating Text_IO Files as Streams::
11665 * Text_IO Extensions::
11666 * Text_IO Facilities for Unbounded Strings::
11667 @end menu
11668
11669 @node Text_IO Stream Pointer Positioning
11670 @subsection Stream Pointer Positioning
11671
11672 @noindent
11673 @code{Ada.Text_IO} has a definition of current position for a file that
11674 is being read.  No internal buffering occurs in Text_IO, and usually the
11675 physical position in the stream used to implement the file corresponds
11676 to this logical position defined by Text_IO@.  There are two exceptions:
11677
11678 @itemize @bullet
11679 @item
11680 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11681 is positioned past the @code{LF} (line mark) that precedes the page
11682 mark.  Text_IO maintains an internal flag so that subsequent read
11683 operations properly handle the logical position which is unchanged by
11684 the @code{End_Of_Page} call.
11685
11686 @item
11687 After a call to @code{End_Of_File} that returns @code{True}, if the
11688 Text_IO file was positioned before the line mark at the end of file
11689 before the call, then the logical position is unchanged, but the stream
11690 is physically positioned right at the end of file (past the line mark,
11691 and past a possible page mark following the line mark.  Again Text_IO
11692 maintains internal flags so that subsequent read operations properly
11693 handle the logical position.
11694 @end itemize
11695
11696 @noindent
11697 These discrepancies have no effect on the observable behavior of
11698 Text_IO, but if a single Ada stream is shared between a C program and
11699 Ada program, or shared (using @samp{shared=yes} in the form string)
11700 between two Ada files, then the difference may be observable in some
11701 situations.
11702
11703 @node Text_IO Reading and Writing Non-Regular Files
11704 @subsection Reading and Writing Non-Regular Files
11705
11706 @noindent
11707 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11708 can be used for reading and writing.  Writing is not affected and the
11709 sequence of characters output is identical to the normal file case, but
11710 for reading, the behavior of Text_IO is modified to avoid undesirable
11711 look-ahead as follows:
11712
11713 An input file that is not a regular file is considered to have no page
11714 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11715 page mark) appearing in the file are considered to be data
11716 characters.  In particular:
11717
11718 @itemize @bullet
11719 @item
11720 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11721 following a line mark.  If a page mark appears, it will be treated as a
11722 data character.
11723
11724 @item
11725 This avoids the need to wait for an extra character to be typed or
11726 entered from the pipe to complete one of these operations.
11727
11728 @item
11729 @code{End_Of_Page} always returns @code{False}
11730
11731 @item
11732 @code{End_Of_File} will return @code{False} if there is a page mark at
11733 the end of the file.
11734 @end itemize
11735
11736 @noindent
11737 Output to non-regular files is the same as for regular files.  Page marks
11738 may be written to non-regular files using @code{New_Page}, but as noted
11739 above they will not be treated as page marks on input if the output is
11740 piped to another Ada program.
11741
11742 Another important discrepancy when reading non-regular files is that the end
11743 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11744 pressing the @key{EOT} key,
11745 then end of file
11746 is signaled once (i.e.@: the test @code{End_Of_File}
11747 will yield @code{True}, or a read will
11748 raise @code{End_Error}), but then reading can resume
11749 to read data past that end of
11750 file indication, until another end of file indication is entered.
11751
11752 @node Get_Immediate
11753 @subsection Get_Immediate
11754 @cindex Get_Immediate
11755
11756 @noindent
11757 Get_Immediate returns the next character (including control characters)
11758 from the input file.  In particular, Get_Immediate will return LF or FF
11759 characters used as line marks or page marks.  Such operations leave the
11760 file positioned past the control character, and it is thus not treated
11761 as having its normal function.  This means that page, line and column
11762 counts after this kind of Get_Immediate call are set as though the mark
11763 did not occur.  In the case where a Get_Immediate leaves the file
11764 positioned between the line mark and page mark (which is not normally
11765 possible), it is undefined whether the FF character will be treated as a
11766 page mark.
11767
11768 @node Treating Text_IO Files as Streams
11769 @subsection Treating Text_IO Files as Streams
11770 @cindex Stream files
11771
11772 @noindent
11773 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11774 as a stream.  Data written to a Text_IO file in this stream mode is
11775 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11776 16#0C# (@code{FF}), the resulting file may have non-standard
11777 format.  Similarly if read operations are used to read from a Text_IO
11778 file treated as a stream, then @code{LF} and @code{FF} characters may be
11779 skipped and the effect is similar to that described above for
11780 @code{Get_Immediate}.
11781
11782 @node Text_IO Extensions
11783 @subsection Text_IO Extensions
11784 @cindex Text_IO extensions
11785
11786 @noindent
11787 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11788 to the standard @code{Text_IO} package:
11789
11790 @itemize @bullet
11791 @item function File_Exists (Name : String) return Boolean;
11792 Determines if a file of the given name exists.
11793
11794 @item function Get_Line return String;
11795 Reads a string from the standard input file.  The value returned is exactly
11796 the length of the line that was read.
11797
11798 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11799 Similar, except that the parameter File specifies the file from which
11800 the string is to be read.
11801
11802 @end itemize
11803
11804 @node Text_IO Facilities for Unbounded Strings
11805 @subsection Text_IO Facilities for Unbounded Strings
11806 @cindex Text_IO for unbounded strings
11807 @cindex Unbounded_String, Text_IO operations
11808
11809 @noindent
11810 The package @code{Ada.Strings.Unbounded.Text_IO}
11811 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11812 subprograms useful for Text_IO operations on unbounded strings:
11813
11814 @itemize @bullet
11815
11816 @item function Get_Line (File : File_Type) return Unbounded_String;
11817 Reads a line from the specified file
11818 and returns the result as an unbounded string.
11819
11820 @item procedure Put (File : File_Type; U : Unbounded_String);
11821 Writes the value of the given unbounded string to the specified file
11822 Similar to the effect of
11823 @code{Put (To_String (U))} except that an extra copy is avoided.
11824
11825 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11826 Writes the value of the given unbounded string to the specified file,
11827 followed by a @code{New_Line}.
11828 Similar to the effect of @code{Put_Line (To_String (U))} except
11829 that an extra copy is avoided.
11830 @end itemize
11831
11832 @noindent
11833 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11834 and is optional.  If the parameter is omitted, then the standard input or
11835 output file is referenced as appropriate.
11836
11837 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11838 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11839 @code{Wide_Text_IO} functionality for unbounded wide strings.
11840
11841 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11842 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11843 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11844
11845 @node Wide_Text_IO
11846 @section Wide_Text_IO
11847
11848 @noindent
11849 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11850 both input and output files may contain special sequences that represent
11851 wide character values.  The encoding scheme for a given file may be
11852 specified using a FORM parameter:
11853
11854 @smallexample
11855 WCEM=@var{x}
11856 @end smallexample
11857
11858 @noindent
11859 as part of the FORM string (WCEM = wide character encoding method),
11860 where @var{x} is one of the following characters
11861
11862 @table @samp
11863 @item h
11864 Hex ESC encoding
11865 @item u
11866 Upper half encoding
11867 @item s
11868 Shift-JIS encoding
11869 @item e
11870 EUC Encoding
11871 @item 8
11872 UTF-8 encoding
11873 @item b
11874 Brackets encoding
11875 @end table
11876
11877 @noindent
11878 The encoding methods match those that
11879 can be used in a source
11880 program, but there is no requirement that the encoding method used for
11881 the source program be the same as the encoding method used for files,
11882 and different files may use different encoding methods.
11883
11884 The default encoding method for the standard files, and for opened files
11885 for which no WCEM parameter is given in the FORM string matches the
11886 wide character encoding specified for the main program (the default
11887 being brackets encoding if no coding method was specified with -gnatW).
11888
11889 @table @asis
11890 @item Hex Coding
11891 In this encoding, a wide character is represented by a five character
11892 sequence:
11893
11894 @smallexample
11895 ESC a b c d
11896 @end smallexample
11897
11898 @noindent
11899 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11900 characters (using upper case letters) of the wide character code.  For
11901 example, ESC A345 is used to represent the wide character with code
11902 16#A345#.  This scheme is compatible with use of the full
11903 @code{Wide_Character} set.
11904
11905 @item Upper Half Coding
11906 The wide character with encoding 16#abcd#, where the upper bit is on
11907 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11908 16#cd#.  The second byte may never be a format control character, but is
11909 not required to be in the upper half.  This method can be also used for
11910 shift-JIS or EUC where the internal coding matches the external coding.
11911
11912 @item Shift JIS Coding
11913 A wide character is represented by a two character sequence 16#ab# and
11914 16#cd#, with the restrictions described for upper half encoding as
11915 described above.  The internal character code is the corresponding JIS
11916 character according to the standard algorithm for Shift-JIS
11917 conversion.  Only characters defined in the JIS code set table can be
11918 used with this encoding method.
11919
11920 @item EUC Coding
11921 A wide character is represented by a two character sequence 16#ab# and
11922 16#cd#, with both characters being in the upper half.  The internal
11923 character code is the corresponding JIS character according to the EUC
11924 encoding algorithm.  Only characters defined in the JIS code set table
11925 can be used with this encoding method.
11926
11927 @item UTF-8 Coding
11928 A wide character is represented using
11929 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11930 10646-1/Am.2.  Depending on the character value, the representation
11931 is a one, two, or three byte sequence:
11932
11933 @smallexample
11934 16#0000#-16#007f#: 2#0xxxxxxx#
11935 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11936 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11937 @end smallexample
11938
11939 @noindent
11940 where the xxx bits correspond to the left-padded bits of the
11941 16-bit character value.  Note that all lower half ASCII characters
11942 are represented as ASCII bytes and all upper half characters and
11943 other wide characters are represented as sequences of upper-half
11944 (The full UTF-8 scheme allows for encoding 31-bit characters as
11945 6-byte sequences, but in this implementation, all UTF-8 sequences
11946 of four or more bytes length will raise a Constraint_Error, as
11947 will all invalid UTF-8 sequences.)
11948
11949 @item Brackets Coding
11950 In this encoding, a wide character is represented by the following eight
11951 character sequence:
11952
11953 @smallexample
11954 [ " a b c d " ]
11955 @end smallexample
11956
11957 @noindent
11958 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11959 characters (using uppercase letters) of the wide character code.  For
11960 example, @code{["A345"]} is used to represent the wide character with code
11961 @code{16#A345#}.
11962 This scheme is compatible with use of the full Wide_Character set.
11963 On input, brackets coding can also be used for upper half characters,
11964 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11965 is only used for wide characters with a code greater than @code{16#FF#}.
11966
11967 Note that brackets coding is not normally used in the context of
11968 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11969 a portable way of encoding source files. In the context of Wide_Text_IO
11970 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11971 any instance of the left bracket character other than to encode wide
11972 character values using the brackets encoding method. In practice it is
11973 expected that some standard wide character encoding method such
11974 as UTF-8 will be used for text input output.
11975
11976 If brackets notation is used, then any occurrence of a left bracket
11977 in the input file which is not the start of a valid wide character
11978 sequence will cause Constraint_Error to be raised. It is possible to
11979 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11980 input will interpret this as a left bracket.
11981
11982 However, when a left bracket is output, it will be output as a left bracket
11983 and not as ["5B"]. We make this decision because for normal use of
11984 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11985 brackets. For example, if we write:
11986
11987 @smallexample
11988    Put_Line ("Start of output [first run]");
11989 @end smallexample
11990
11991 @noindent
11992 we really do not want to have the left bracket in this message clobbered so
11993 that the output reads:
11994
11995 @smallexample
11996    Start of output ["5B"]first run]
11997 @end smallexample
11998
11999 @noindent
12000 In practice brackets encoding is reasonably useful for normal Put_Line use
12001 since we won't get confused between left brackets and wide character
12002 sequences in the output. But for input, or when files are written out
12003 and read back in, it really makes better sense to use one of the standard
12004 encoding methods such as UTF-8.
12005
12006 @end table
12007
12008 @noindent
12009 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12010 not all wide character
12011 values can be represented.  An attempt to output a character that cannot
12012 be represented using the encoding scheme for the file causes
12013 Constraint_Error to be raised.  An invalid wide character sequence on
12014 input also causes Constraint_Error to be raised.
12015
12016 @menu
12017 * Wide_Text_IO Stream Pointer Positioning::
12018 * Wide_Text_IO Reading and Writing Non-Regular Files::
12019 @end menu
12020
12021 @node Wide_Text_IO Stream Pointer Positioning
12022 @subsection Stream Pointer Positioning
12023
12024 @noindent
12025 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12026 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12027 case:
12028
12029 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12030 normal lower ASCII set (i.e.@: a character in the range:
12031
12032 @smallexample @c ada
12033 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12034 @end smallexample
12035
12036 @noindent
12037 then although the logical position of the file pointer is unchanged by
12038 the @code{Look_Ahead} call, the stream is physically positioned past the
12039 wide character sequence.  Again this is to avoid the need for buffering
12040 or backup, and all @code{Wide_Text_IO} routines check the internal
12041 indication that this situation has occurred so that this is not visible
12042 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12043 can be observed if the wide text file shares a stream with another file.
12044
12045 @node Wide_Text_IO Reading and Writing Non-Regular Files
12046 @subsection Reading and Writing Non-Regular Files
12047
12048 @noindent
12049 As in the case of Text_IO, when a non-regular file is read, it is
12050 assumed that the file contains no page marks (any form characters are
12051 treated as data characters), and @code{End_Of_Page} always returns
12052 @code{False}.  Similarly, the end of file indication is not sticky, so
12053 it is possible to read beyond an end of file.
12054
12055 @node Wide_Wide_Text_IO
12056 @section Wide_Wide_Text_IO
12057
12058 @noindent
12059 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12060 both input and output files may contain special sequences that represent
12061 wide wide character values.  The encoding scheme for a given file may be
12062 specified using a FORM parameter:
12063
12064 @smallexample
12065 WCEM=@var{x}
12066 @end smallexample
12067
12068 @noindent
12069 as part of the FORM string (WCEM = wide character encoding method),
12070 where @var{x} is one of the following characters
12071
12072 @table @samp
12073 @item h
12074 Hex ESC encoding
12075 @item u
12076 Upper half encoding
12077 @item s
12078 Shift-JIS encoding
12079 @item e
12080 EUC Encoding
12081 @item 8
12082 UTF-8 encoding
12083 @item b
12084 Brackets encoding
12085 @end table
12086
12087 @noindent
12088 The encoding methods match those that
12089 can be used in a source
12090 program, but there is no requirement that the encoding method used for
12091 the source program be the same as the encoding method used for files,
12092 and different files may use different encoding methods.
12093
12094 The default encoding method for the standard files, and for opened files
12095 for which no WCEM parameter is given in the FORM string matches the
12096 wide character encoding specified for the main program (the default
12097 being brackets encoding if no coding method was specified with -gnatW).
12098
12099 @table @asis
12100
12101 @item UTF-8 Coding
12102 A wide character is represented using
12103 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12104 10646-1/Am.2.  Depending on the character value, the representation
12105 is a one, two, three, or four byte sequence:
12106
12107 @smallexample
12108 16#000000#-16#00007f#: 2#0xxxxxxx#
12109 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12110 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12111 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12112 @end smallexample
12113
12114 @noindent
12115 where the xxx bits correspond to the left-padded bits of the
12116 21-bit character value.  Note that all lower half ASCII characters
12117 are represented as ASCII bytes and all upper half characters and
12118 other wide characters are represented as sequences of upper-half
12119 characters.
12120
12121 @item Brackets Coding
12122 In this encoding, a wide wide character is represented by the following eight
12123 character sequence if is in wide character range
12124
12125 @smallexample
12126 [ " a b c d " ]
12127 @end smallexample
12128
12129 and by the following ten character sequence if not
12130
12131 @smallexample
12132 [ " a b c d e f " ]
12133 @end smallexample
12134
12135 @noindent
12136 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12137 are the four or six hexadecimal
12138 characters (using uppercase letters) of the wide wide character code.  For
12139 example, @code{["01A345"]} is used to represent the wide wide character
12140 with code @code{16#01A345#}.
12141
12142 This scheme is compatible with use of the full Wide_Wide_Character set.
12143 On input, brackets coding can also be used for upper half characters,
12144 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12145 is only used for wide characters with a code greater than @code{16#FF#}.
12146
12147 @end table
12148
12149 @noindent
12150 If is also possible to use the other Wide_Character encoding methods,
12151 such as Shift-JIS, but the other schemes cannot support the full range
12152 of wide wide characters.
12153 An attempt to output a character that cannot
12154 be represented using the encoding scheme for the file causes
12155 Constraint_Error to be raised.  An invalid wide character sequence on
12156 input also causes Constraint_Error to be raised.
12157
12158 @menu
12159 * Wide_Wide_Text_IO Stream Pointer Positioning::
12160 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12161 @end menu
12162
12163 @node Wide_Wide_Text_IO Stream Pointer Positioning
12164 @subsection Stream Pointer Positioning
12165
12166 @noindent
12167 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12168 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12169 case:
12170
12171 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12172 normal lower ASCII set (i.e.@: a character in the range:
12173
12174 @smallexample @c ada
12175 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12176 @end smallexample
12177
12178 @noindent
12179 then although the logical position of the file pointer is unchanged by
12180 the @code{Look_Ahead} call, the stream is physically positioned past the
12181 wide character sequence.  Again this is to avoid the need for buffering
12182 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12183 indication that this situation has occurred so that this is not visible
12184 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12185 can be observed if the wide text file shares a stream with another file.
12186
12187 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12188 @subsection Reading and Writing Non-Regular Files
12189
12190 @noindent
12191 As in the case of Text_IO, when a non-regular file is read, it is
12192 assumed that the file contains no page marks (any form characters are
12193 treated as data characters), and @code{End_Of_Page} always returns
12194 @code{False}.  Similarly, the end of file indication is not sticky, so
12195 it is possible to read beyond an end of file.
12196
12197 @node Stream_IO
12198 @section Stream_IO
12199
12200 @noindent
12201 A stream file is a sequence of bytes, where individual elements are
12202 written to the file as described in the Ada Reference Manual.  The type
12203 @code{Stream_Element} is simply a byte.  There are two ways to read or
12204 write a stream file.
12205
12206 @itemize @bullet
12207 @item
12208 The operations @code{Read} and @code{Write} directly read or write a
12209 sequence of stream elements with no control information.
12210
12211 @item
12212 The stream attributes applied to a stream file transfer data in the
12213 manner described for stream attributes.
12214 @end itemize
12215
12216 @node Shared Files
12217 @section Shared Files
12218
12219 @noindent
12220 Section A.14 of the Ada Reference Manual allows implementations to
12221 provide a wide variety of behavior if an attempt is made to access the
12222 same external file with two or more internal files.
12223
12224 To provide a full range of functionality, while at the same time
12225 minimizing the problems of portability caused by this implementation
12226 dependence, GNAT handles file sharing as follows:
12227
12228 @itemize @bullet
12229 @item
12230 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12231 to open two or more files with the same full name is considered an error
12232 and is not supported.  The exception @code{Use_Error} will be
12233 raised.  Note that a file that is not explicitly closed by the program
12234 remains open until the program terminates.
12235
12236 @item
12237 If the form parameter @samp{shared=no} appears in the form string, the
12238 file can be opened or created with its own separate stream identifier,
12239 regardless of whether other files sharing the same external file are
12240 opened.  The exact effect depends on how the C stream routines handle
12241 multiple accesses to the same external files using separate streams.
12242
12243 @item
12244 If the form parameter @samp{shared=yes} appears in the form string for
12245 each of two or more files opened using the same full name, the same
12246 stream is shared between these files, and the semantics are as described
12247 in Ada Reference Manual, Section A.14.
12248 @end itemize
12249
12250 @noindent
12251 When a program that opens multiple files with the same name is ported
12252 from another Ada compiler to GNAT, the effect will be that
12253 @code{Use_Error} is raised.
12254
12255 The documentation of the original compiler and the documentation of the
12256 program should then be examined to determine if file sharing was
12257 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12258 and @code{Create} calls as required.
12259
12260 When a program is ported from GNAT to some other Ada compiler, no
12261 special attention is required unless the @samp{shared=@var{xxx}} form
12262 parameter is used in the program.  In this case, you must examine the
12263 documentation of the new compiler to see if it supports the required
12264 file sharing semantics, and form strings modified appropriately.  Of
12265 course it may be the case that the program cannot be ported if the
12266 target compiler does not support the required functionality.  The best
12267 approach in writing portable code is to avoid file sharing (and hence
12268 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12269 completely.
12270
12271 One common use of file sharing in Ada 83 is the use of instantiations of
12272 Sequential_IO on the same file with different types, to achieve
12273 heterogeneous input-output.  Although this approach will work in GNAT if
12274 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12275 for this purpose (using the stream attributes)
12276
12277 @node Filenames encoding
12278 @section Filenames encoding
12279
12280 @noindent
12281 An encoding form parameter can be used to specify the filename
12282 encoding @samp{encoding=@var{xxx}}.
12283
12284 @itemize @bullet
12285 @item
12286 If the form parameter @samp{encoding=utf8} appears in the form string, the
12287 filename must be encoded in UTF-8.
12288
12289 @item
12290 If the form parameter @samp{encoding=8bits} appears in the form
12291 string, the filename must be a standard 8bits string.
12292 @end itemize
12293
12294 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12295 value UTF-8 is used. This encoding form parameter is only supported on
12296 the Windows platform. On the other Operating Systems the runtime is
12297 supporting UTF-8 natively.
12298
12299 @node Open Modes
12300 @section Open Modes
12301
12302 @noindent
12303 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12304 using the mode shown in the following table:
12305
12306 @sp 2
12307 @center @code{Open} and @code{Create} Call Modes
12308 @smallexample
12309                                @b{OPEN }           @b{CREATE}
12310 Append_File                    "r+"             "w+"
12311 In_File                        "r"              "w+"
12312 Out_File (Direct_IO)           "r+"             "w"
12313 Out_File (all other cases)     "w"              "w"
12314 Inout_File                     "r+"             "w+"
12315 @end smallexample
12316
12317 @noindent
12318 If text file translation is required, then either @samp{b} or @samp{t}
12319 is added to the mode, depending on the setting of Text.  Text file
12320 translation refers to the mapping of CR/LF sequences in an external file
12321 to LF characters internally.  This mapping only occurs in DOS and
12322 DOS-like systems, and is not relevant to other systems.
12323
12324 A special case occurs with Stream_IO@.  As shown in the above table, the
12325 file is initially opened in @samp{r} or @samp{w} mode for the
12326 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12327 subsequently requires switching from reading to writing or vice-versa,
12328 then the file is reopened in @samp{r+} mode to permit the required operation.
12329
12330 @node Operations on C Streams
12331 @section Operations on C Streams
12332 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12333 access to the C library functions for operations on C streams:
12334
12335 @smallexample @c adanocomment
12336 package Interfaces.C_Streams is
12337   -- Note: the reason we do not use the types that are in
12338   -- Interfaces.C is that we want to avoid dragging in the
12339   -- code in this unit if possible.
12340   subtype chars is System.Address;
12341   -- Pointer to null-terminated array of characters
12342   subtype FILEs is System.Address;
12343   -- Corresponds to the C type FILE*
12344   subtype voids is System.Address;
12345   -- Corresponds to the C type void*
12346   subtype int is Integer;
12347   subtype long is Long_Integer;
12348   -- Note: the above types are subtypes deliberately, and it
12349   -- is part of this spec that the above correspondences are
12350   -- guaranteed.  This means that it is legitimate to, for
12351   -- example, use Integer instead of int.  We provide these
12352   -- synonyms for clarity, but in some cases it may be
12353   -- convenient to use the underlying types (for example to
12354   -- avoid an unnecessary dependency of a spec on the spec
12355   -- of this unit).
12356   type size_t is mod 2 ** Standard'Address_Size;
12357   NULL_Stream : constant FILEs;
12358   -- Value returned (NULL in C) to indicate an
12359   -- fdopen/fopen/tmpfile error
12360   ----------------------------------
12361   -- Constants Defined in stdio.h --
12362   ----------------------------------
12363   EOF : constant int;
12364   -- Used by a number of routines to indicate error or
12365   -- end of file
12366   IOFBF : constant int;
12367   IOLBF : constant int;
12368   IONBF : constant int;
12369   -- Used to indicate buffering mode for setvbuf call
12370   SEEK_CUR : constant int;
12371   SEEK_END : constant int;
12372   SEEK_SET : constant int;
12373   -- Used to indicate origin for fseek call
12374   function stdin return FILEs;
12375   function stdout return FILEs;
12376   function stderr return FILEs;
12377   -- Streams associated with standard files
12378   --------------------------
12379   -- Standard C functions --
12380   --------------------------
12381   -- The functions selected below are ones that are
12382   -- available in DOS, OS/2, UNIX and Xenix (but not
12383   -- necessarily in ANSI C).  These are very thin interfaces
12384   -- which copy exactly the C headers.  For more
12385   -- documentation on these functions, see the Microsoft C
12386   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12387   -- ISBN 1-55615-225-6), which includes useful information
12388   -- on system compatibility.
12389   procedure clearerr (stream : FILEs);
12390   function fclose (stream : FILEs) return int;
12391   function fdopen (handle : int; mode : chars) return FILEs;
12392   function feof (stream : FILEs) return int;
12393   function ferror (stream : FILEs) return int;
12394   function fflush (stream : FILEs) return int;
12395   function fgetc (stream : FILEs) return int;
12396   function fgets (strng : chars; n : int; stream : FILEs)
12397       return chars;
12398   function fileno (stream : FILEs) return int;
12399   function fopen (filename : chars; Mode : chars)
12400       return FILEs;
12401   -- Note: to maintain target independence, use
12402   -- text_translation_required, a boolean variable defined in
12403   -- a-sysdep.c to deal with the target dependent text
12404   -- translation requirement.  If this variable is set,
12405   -- then  b/t should be appended to the standard mode
12406   -- argument to set the text translation mode off or on
12407   -- as required.
12408   function fputc (C : int; stream : FILEs) return int;
12409   function fputs (Strng : chars; Stream : FILEs) return int;
12410   function fread
12411      (buffer : voids;
12412       size : size_t;
12413       count : size_t;
12414       stream : FILEs)
12415       return size_t;
12416   function freopen
12417      (filename : chars;
12418       mode : chars;
12419       stream : FILEs)
12420       return FILEs;
12421   function fseek
12422      (stream : FILEs;
12423       offset : long;
12424       origin : int)
12425       return int;
12426   function ftell (stream : FILEs) return long;
12427   function fwrite
12428      (buffer : voids;
12429       size : size_t;
12430       count : size_t;
12431       stream : FILEs)
12432       return size_t;
12433   function isatty (handle : int) return int;
12434   procedure mktemp (template : chars);
12435   -- The return value (which is just a pointer to template)
12436   -- is discarded
12437   procedure rewind (stream : FILEs);
12438   function rmtmp return int;
12439   function setvbuf
12440      (stream : FILEs;
12441       buffer : chars;
12442       mode : int;
12443       size : size_t)
12444       return int;
12445
12446   function tmpfile return FILEs;
12447   function ungetc (c : int; stream : FILEs) return int;
12448   function unlink (filename : chars) return int;
12449   ---------------------
12450   -- Extra functions --
12451   ---------------------
12452   -- These functions supply slightly thicker bindings than
12453   -- those above.  They are derived from functions in the
12454   -- C Run-Time Library, but may do a bit more work than
12455   -- just directly calling one of the Library functions.
12456   function is_regular_file (handle : int) return int;
12457   -- Tests if given handle is for a regular file (result 1)
12458   -- or for a non-regular file (pipe or device, result 0).
12459   ---------------------------------
12460   -- Control of Text/Binary Mode --
12461   ---------------------------------
12462   -- If text_translation_required is true, then the following
12463   -- functions may be used to dynamically switch a file from
12464   -- binary to text mode or vice versa.  These functions have
12465   -- no effect if text_translation_required is false (i.e.  in
12466   -- normal UNIX mode).  Use fileno to get a stream handle.
12467   procedure set_binary_mode (handle : int);
12468   procedure set_text_mode (handle : int);
12469   ----------------------------
12470   -- Full Path Name support --
12471   ----------------------------
12472   procedure full_name (nam : chars; buffer : chars);
12473   -- Given a NUL terminated string representing a file
12474   -- name, returns in buffer a NUL terminated string
12475   -- representing the full path name for the file name.
12476   -- On systems where it is relevant the   drive is also
12477   -- part of the full path name.  It is the responsibility
12478   -- of the caller to pass an actual parameter for buffer
12479   -- that is big enough for any full path name.  Use
12480   -- max_path_len given below as the size of buffer.
12481   max_path_len : integer;
12482   -- Maximum length of an allowable full path name on the
12483   -- system, including a terminating NUL character.
12484 end Interfaces.C_Streams;
12485 @end smallexample
12486
12487 @node Interfacing to C Streams
12488 @section Interfacing to C Streams
12489
12490 @noindent
12491 The packages in this section permit interfacing Ada files to C Stream
12492 operations.
12493
12494 @smallexample @c ada
12495  with Interfaces.C_Streams;
12496  package Ada.Sequential_IO.C_Streams is
12497     function C_Stream (F : File_Type)
12498        return Interfaces.C_Streams.FILEs;
12499     procedure Open
12500       (File : in out File_Type;
12501        Mode : in File_Mode;
12502        C_Stream : in Interfaces.C_Streams.FILEs;
12503        Form : in String := "");
12504  end Ada.Sequential_IO.C_Streams;
12505
12506   with Interfaces.C_Streams;
12507   package Ada.Direct_IO.C_Streams is
12508      function C_Stream (F : File_Type)
12509         return Interfaces.C_Streams.FILEs;
12510      procedure Open
12511        (File : in out File_Type;
12512         Mode : in File_Mode;
12513         C_Stream : in Interfaces.C_Streams.FILEs;
12514         Form : in String := "");
12515   end Ada.Direct_IO.C_Streams;
12516
12517   with Interfaces.C_Streams;
12518   package Ada.Text_IO.C_Streams is
12519      function C_Stream (F : File_Type)
12520         return Interfaces.C_Streams.FILEs;
12521      procedure Open
12522        (File : in out File_Type;
12523         Mode : in File_Mode;
12524         C_Stream : in Interfaces.C_Streams.FILEs;
12525         Form : in String := "");
12526   end Ada.Text_IO.C_Streams;
12527
12528   with Interfaces.C_Streams;
12529   package Ada.Wide_Text_IO.C_Streams is
12530      function C_Stream (F : File_Type)
12531         return Interfaces.C_Streams.FILEs;
12532      procedure Open
12533        (File : in out File_Type;
12534         Mode : in File_Mode;
12535         C_Stream : in Interfaces.C_Streams.FILEs;
12536         Form : in String := "");
12537  end Ada.Wide_Text_IO.C_Streams;
12538
12539   with Interfaces.C_Streams;
12540   package Ada.Wide_Wide_Text_IO.C_Streams is
12541      function C_Stream (F : File_Type)
12542         return Interfaces.C_Streams.FILEs;
12543      procedure Open
12544        (File : in out File_Type;
12545         Mode : in File_Mode;
12546         C_Stream : in Interfaces.C_Streams.FILEs;
12547         Form : in String := "");
12548  end Ada.Wide_Wide_Text_IO.C_Streams;
12549
12550  with Interfaces.C_Streams;
12551  package Ada.Stream_IO.C_Streams is
12552     function C_Stream (F : File_Type)
12553        return Interfaces.C_Streams.FILEs;
12554     procedure Open
12555       (File : in out File_Type;
12556        Mode : in File_Mode;
12557        C_Stream : in Interfaces.C_Streams.FILEs;
12558        Form : in String := "");
12559  end Ada.Stream_IO.C_Streams;
12560 @end smallexample
12561
12562 @noindent
12563 In each of these six packages, the @code{C_Stream} function obtains the
12564 @code{FILE} pointer from a currently opened Ada file.  It is then
12565 possible to use the @code{Interfaces.C_Streams} package to operate on
12566 this stream, or the stream can be passed to a C program which can
12567 operate on it directly.  Of course the program is responsible for
12568 ensuring that only appropriate sequences of operations are executed.
12569
12570 One particular use of relevance to an Ada program is that the
12571 @code{setvbuf} function can be used to control the buffering of the
12572 stream used by an Ada file.  In the absence of such a call the standard
12573 default buffering is used.
12574
12575 The @code{Open} procedures in these packages open a file giving an
12576 existing C Stream instead of a file name.  Typically this stream is
12577 imported from a C program, allowing an Ada file to operate on an
12578 existing C file.
12579
12580 @node The GNAT Library
12581 @chapter The GNAT Library
12582
12583 @noindent
12584 The GNAT library contains a number of general and special purpose packages.
12585 It represents functionality that the GNAT developers have found useful, and
12586 which is made available to GNAT users.  The packages described here are fully
12587 supported, and upwards compatibility will be maintained in future releases,
12588 so you can use these facilities with the confidence that the same functionality
12589 will be available in future releases.
12590
12591 The chapter here simply gives a brief summary of the facilities available.
12592 The full documentation is found in the spec file for the package.  The full
12593 sources of these library packages, including both spec and body, are provided
12594 with all GNAT releases.  For example, to find out the full specifications of
12595 the SPITBOL pattern matching capability, including a full tutorial and
12596 extensive examples, look in the @file{g-spipat.ads} file in the library.
12597
12598 For each entry here, the package name (as it would appear in a @code{with}
12599 clause) is given, followed by the name of the corresponding spec file in
12600 parentheses.  The packages are children in four hierarchies, @code{Ada},
12601 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12602 GNAT-specific hierarchy.
12603
12604 Note that an application program should only use packages in one of these
12605 four hierarchies if the package is defined in the Ada Reference Manual,
12606 or is listed in this section of the GNAT Programmers Reference Manual.
12607 All other units should be considered internal implementation units and
12608 should not be directly @code{with}'ed by application code.  The use of
12609 a @code{with} statement that references one of these internal implementation
12610 units makes an application potentially dependent on changes in versions
12611 of GNAT, and will generate a warning message.
12612
12613 @menu
12614 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12615 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12616 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12617 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12618 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12619 * Ada.Command_Line.Remove (a-colire.ads)::
12620 * Ada.Command_Line.Environment (a-colien.ads)::
12621 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12622 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12623 * Ada.Exceptions.Traceback (a-exctra.ads)::
12624 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12625 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12626 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12627 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12628 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12629 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12630 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12631 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12632 * GNAT.Altivec (g-altive.ads)::
12633 * GNAT.Altivec.Conversions (g-altcon.ads)::
12634 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12635 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12636 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12637 * GNAT.Array_Split (g-arrspl.ads)::
12638 * GNAT.AWK (g-awk.ads)::
12639 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12640 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12641 * GNAT.Bubble_Sort (g-bubsor.ads)::
12642 * GNAT.Bubble_Sort_A (g-busora.ads)::
12643 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12644 * GNAT.Byte_Swapping (g-bytswa.ads)::
12645 * GNAT.Calendar (g-calend.ads)::
12646 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12647 * GNAT.CRC32 (g-crc32.ads)::
12648 * GNAT.Case_Util (g-casuti.ads)::
12649 * GNAT.CGI (g-cgi.ads)::
12650 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12651 * GNAT.CGI.Debug (g-cgideb.ads)::
12652 * GNAT.Command_Line (g-comlin.ads)::
12653 * GNAT.Compiler_Version (g-comver.ads)::
12654 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12655 * GNAT.Current_Exception (g-curexc.ads)::
12656 * GNAT.Debug_Pools (g-debpoo.ads)::
12657 * GNAT.Debug_Utilities (g-debuti.ads)::
12658 * GNAT.Directory_Operations (g-dirope.ads)::
12659 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12660 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12661 * GNAT.Exception_Actions (g-excact.ads)::
12662 * GNAT.Exception_Traces (g-exctra.ads)::
12663 * GNAT.Exceptions (g-except.ads)::
12664 * GNAT.Expect (g-expect.ads)::
12665 * GNAT.Float_Control (g-flocon.ads)::
12666 * GNAT.Heap_Sort (g-heasor.ads)::
12667 * GNAT.Heap_Sort_A (g-hesora.ads)::
12668 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12669 * GNAT.HTable (g-htable.ads)::
12670 * GNAT.IO (g-io.ads)::
12671 * GNAT.IO_Aux (g-io_aux.ads)::
12672 * GNAT.Lock_Files (g-locfil.ads)::
12673 * GNAT.MD5 (g-md5.ads)::
12674 * GNAT.Memory_Dump (g-memdum.ads)::
12675 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12676 * GNAT.OS_Lib (g-os_lib.ads)::
12677 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12678 * GNAT.Regexp (g-regexp.ads)::
12679 * GNAT.Registry (g-regist.ads)::
12680 * GNAT.Regpat (g-regpat.ads)::
12681 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12682 * GNAT.Semaphores (g-semaph.ads)::
12683 * GNAT.SHA1 (g-sha1.ads)::
12684 * GNAT.Signals (g-signal.ads)::
12685 * GNAT.Sockets (g-socket.ads)::
12686 * GNAT.Source_Info (g-souinf.ads)::
12687 * GNAT.Spell_Checker (g-speche.ads)::
12688 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12689 * GNAT.Spitbol (g-spitbo.ads)::
12690 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12691 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12692 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12693 * GNAT.Strings (g-string.ads)::
12694 * GNAT.String_Split (g-strspl.ads)::
12695 * GNAT.UTF_32 (g-utf_32.ads)::
12696 * GNAT.Table (g-table.ads)::
12697 * GNAT.Task_Lock (g-tasloc.ads)::
12698 * GNAT.Threads (g-thread.ads)::
12699 * GNAT.Traceback (g-traceb.ads)::
12700 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12701 * GNAT.Wide_String_Split (g-wistsp.ads)::
12702 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12703 * Interfaces.C.Extensions (i-cexten.ads)::
12704 * Interfaces.C.Streams (i-cstrea.ads)::
12705 * Interfaces.CPP (i-cpp.ads)::
12706 * Interfaces.Os2lib (i-os2lib.ads)::
12707 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12708 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12709 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12710 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12711 * Interfaces.VxWorks (i-vxwork.ads)::
12712 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12713 * System.Address_Image (s-addima.ads)::
12714 * System.Assertions (s-assert.ads)::
12715 * System.Memory (s-memory.ads)::
12716 * System.Partition_Interface (s-parint.ads)::
12717 * System.Restrictions (s-restri.ads)::
12718 * System.Rident (s-rident.ads)::
12719 * System.Task_Info (s-tasinf.ads)::
12720 * System.Wch_Cnv (s-wchcnv.ads)::
12721 * System.Wch_Con (s-wchcon.ads)::
12722 @end menu
12723
12724 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12725 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12726 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12727 @cindex Latin_9 constants for Character
12728
12729 @noindent
12730 This child of @code{Ada.Characters}
12731 provides a set of definitions corresponding to those in the
12732 RM-defined package @code{Ada.Characters.Latin_1} but with the
12733 few modifications required for @code{Latin-9}
12734 The provision of such a package
12735 is specifically authorized by the Ada Reference Manual
12736 (RM A.3.3(27)).
12737
12738 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12739 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12740 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12741 @cindex Latin_1 constants for Wide_Character
12742
12743 @noindent
12744 This child of @code{Ada.Characters}
12745 provides a set of definitions corresponding to those in the
12746 RM-defined package @code{Ada.Characters.Latin_1} but with the
12747 types of the constants being @code{Wide_Character}
12748 instead of @code{Character}.  The provision of such a package
12749 is specifically authorized by the Ada Reference Manual
12750 (RM A.3.3(27)).
12751
12752 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12753 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12754 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12755 @cindex Latin_9 constants for Wide_Character
12756
12757 @noindent
12758 This child of @code{Ada.Characters}
12759 provides a set of definitions corresponding to those in the
12760 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12761 types of the constants being @code{Wide_Character}
12762 instead of @code{Character}.  The provision of such a package
12763 is specifically authorized by the Ada Reference Manual
12764 (RM A.3.3(27)).
12765
12766 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12767 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12768 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12769 @cindex Latin_1 constants for Wide_Wide_Character
12770
12771 @noindent
12772 This child of @code{Ada.Characters}
12773 provides a set of definitions corresponding to those in the
12774 RM-defined package @code{Ada.Characters.Latin_1} but with the
12775 types of the constants being @code{Wide_Wide_Character}
12776 instead of @code{Character}.  The provision of such a package
12777 is specifically authorized by the Ada Reference Manual
12778 (RM A.3.3(27)).
12779
12780 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12781 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12782 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12783 @cindex Latin_9 constants for Wide_Wide_Character
12784
12785 @noindent
12786 This child of @code{Ada.Characters}
12787 provides a set of definitions corresponding to those in the
12788 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12789 types of the constants being @code{Wide_Wide_Character}
12790 instead of @code{Character}.  The provision of such a package
12791 is specifically authorized by the Ada Reference Manual
12792 (RM A.3.3(27)).
12793
12794 @node Ada.Command_Line.Remove (a-colire.ads)
12795 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12796 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12797 @cindex Removing command line arguments
12798 @cindex Command line, argument removal
12799
12800 @noindent
12801 This child of @code{Ada.Command_Line}
12802 provides a mechanism for logically removing
12803 arguments from the argument list.  Once removed, an argument is not visible
12804 to further calls on the subprograms in @code{Ada.Command_Line} will not
12805 see the removed argument.
12806
12807 @node Ada.Command_Line.Environment (a-colien.ads)
12808 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12809 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12810 @cindex Environment entries
12811
12812 @noindent
12813 This child of @code{Ada.Command_Line}
12814 provides a mechanism for obtaining environment values on systems
12815 where this concept makes sense.
12816
12817 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12818 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12819 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12820 @cindex C Streams, Interfacing with Direct_IO
12821
12822 @noindent
12823 This package provides subprograms that allow interfacing between
12824 C streams and @code{Direct_IO}.  The stream identifier can be
12825 extracted from a file opened on the Ada side, and an Ada file
12826 can be constructed from a stream opened on the C side.
12827
12828 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12829 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12830 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12831 @cindex Null_Occurrence, testing for
12832
12833 @noindent
12834 This child subprogram provides a way of testing for the null
12835 exception occurrence (@code{Null_Occurrence}) without raising
12836 an exception.
12837
12838 @node Ada.Exceptions.Traceback (a-exctra.ads)
12839 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12840 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12841 @cindex Traceback for Exception Occurrence
12842
12843 @noindent
12844 This child package provides the subprogram (@code{Tracebacks}) to
12845 give a traceback array of addresses based on an exception
12846 occurrence.
12847
12848 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12849 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12850 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12851 @cindex C Streams, Interfacing with Sequential_IO
12852
12853 @noindent
12854 This package provides subprograms that allow interfacing between
12855 C streams and @code{Sequential_IO}.  The stream identifier can be
12856 extracted from a file opened on the Ada side, and an Ada file
12857 can be constructed from a stream opened on the C side.
12858
12859 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12860 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12861 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12862 @cindex C Streams, Interfacing with Stream_IO
12863
12864 @noindent
12865 This package provides subprograms that allow interfacing between
12866 C streams and @code{Stream_IO}.  The stream identifier can be
12867 extracted from a file opened on the Ada side, and an Ada file
12868 can be constructed from a stream opened on the C side.
12869
12870 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12871 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12872 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12873 @cindex @code{Unbounded_String}, IO support
12874 @cindex @code{Text_IO}, extensions for unbounded strings
12875
12876 @noindent
12877 This package provides subprograms for Text_IO for unbounded
12878 strings, avoiding the necessity for an intermediate operation
12879 with ordinary strings.
12880
12881 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12882 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12883 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12884 @cindex @code{Unbounded_Wide_String}, IO support
12885 @cindex @code{Text_IO}, extensions for unbounded wide strings
12886
12887 @noindent
12888 This package provides subprograms for Text_IO for unbounded
12889 wide strings, avoiding the necessity for an intermediate operation
12890 with ordinary wide strings.
12891
12892 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12893 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12894 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12895 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12896 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12897
12898 @noindent
12899 This package provides subprograms for Text_IO for unbounded
12900 wide wide strings, avoiding the necessity for an intermediate operation
12901 with ordinary wide wide strings.
12902
12903 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12904 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12905 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12906 @cindex C Streams, Interfacing with @code{Text_IO}
12907
12908 @noindent
12909 This package provides subprograms that allow interfacing between
12910 C streams and @code{Text_IO}.  The stream identifier can be
12911 extracted from a file opened on the Ada side, and an Ada file
12912 can be constructed from a stream opened on the C side.
12913
12914 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12915 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12916 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12917 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12918
12919 @noindent
12920 This package provides subprograms that allow interfacing between
12921 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12922 extracted from a file opened on the Ada side, and an Ada file
12923 can be constructed from a stream opened on the C side.
12924
12925 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12926 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12927 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12928 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12929
12930 @noindent
12931 This package provides subprograms that allow interfacing between
12932 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12933 extracted from a file opened on the Ada side, and an Ada file
12934 can be constructed from a stream opened on the C side.
12935
12936 @node GNAT.Altivec (g-altive.ads)
12937 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12938 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12939 @cindex AltiVec
12940
12941 @noindent
12942 This is the root package of the GNAT AltiVec binding. It provides
12943 definitions of constants and types common to all the versions of the
12944 binding.
12945
12946 @node GNAT.Altivec.Conversions (g-altcon.ads)
12947 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12948 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12949 @cindex AltiVec
12950
12951 @noindent
12952 This package provides the Vector/View conversion routines.
12953
12954 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12955 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12956 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12957 @cindex AltiVec
12958
12959 @noindent
12960 This package exposes the Ada interface to the AltiVec operations on
12961 vector objects. A soft emulation is included by default in the GNAT
12962 library. The hard binding is provided as a separate package. This unit
12963 is common to both bindings.
12964
12965 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12966 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12967 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12968 @cindex AltiVec
12969
12970 @noindent
12971 This package exposes the various vector types part of the Ada binding
12972 to AltiVec facilities.
12973
12974 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12975 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12976 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12977 @cindex AltiVec
12978
12979 @noindent
12980 This package provides public 'View' data types from/to which private
12981 vector representations can be converted via
12982 GNAT.Altivec.Conversions. This allows convenient access to individual
12983 vector elements and provides a simple way to initialize vector
12984 objects.
12985
12986 @node GNAT.Array_Split (g-arrspl.ads)
12987 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12988 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12989 @cindex Array splitter
12990
12991 @noindent
12992 Useful array-manipulation routines: given a set of separators, split
12993 an array wherever the separators appear, and provide direct access
12994 to the resulting slices.
12995
12996 @node GNAT.AWK (g-awk.ads)
12997 @section @code{GNAT.AWK} (@file{g-awk.ads})
12998 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12999 @cindex Parsing
13000 @cindex AWK
13001
13002 @noindent
13003 Provides AWK-like parsing functions, with an easy interface for parsing one
13004 or more files containing formatted data.  The file is viewed as a database
13005 where each record is a line and a field is a data element in this line.
13006
13007 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13008 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13009 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13010 @cindex Parsing
13011 @cindex Bounded Buffers
13012
13013 @noindent
13014 Provides a concurrent generic bounded buffer abstraction.  Instances are
13015 useful directly or as parts of the implementations of other abstractions,
13016 such as mailboxes.
13017
13018 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13019 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13020 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13021 @cindex Parsing
13022 @cindex Mailboxes
13023
13024 @noindent
13025 Provides a thread-safe asynchronous intertask mailbox communication facility.
13026
13027 @node GNAT.Bubble_Sort (g-bubsor.ads)
13028 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13029 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13030 @cindex Sorting
13031 @cindex Bubble sort
13032
13033 @noindent
13034 Provides a general implementation of bubble sort usable for sorting arbitrary
13035 data items.  Exchange and comparison procedures are provided by passing
13036 access-to-procedure values.
13037
13038 @node GNAT.Bubble_Sort_A (g-busora.ads)
13039 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13040 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13041 @cindex Sorting
13042 @cindex Bubble sort
13043
13044 @noindent
13045 Provides a general implementation of bubble sort usable for sorting arbitrary
13046 data items.  Move and comparison procedures are provided by passing
13047 access-to-procedure values. This is an older version, retained for
13048 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13049
13050 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13051 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13052 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13053 @cindex Sorting
13054 @cindex Bubble sort
13055
13056 @noindent
13057 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13058 are provided as generic parameters, this improves efficiency, especially
13059 if the procedures can be inlined, at the expense of duplicating code for
13060 multiple instantiations.
13061
13062 @node GNAT.Byte_Swapping (g-bytswa.ads)
13063 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13064 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13065 @cindex Byte swapping
13066 @cindex Endian
13067
13068 @noindent
13069 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13070 Machine-specific implementations are available in some cases.
13071
13072 @node GNAT.Calendar (g-calend.ads)
13073 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13074 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13075 @cindex @code{Calendar}
13076
13077 @noindent
13078 Extends the facilities provided by @code{Ada.Calendar} to include handling
13079 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13080 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13081 C @code{timeval} format.
13082
13083 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13084 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13085 @cindex @code{Calendar}
13086 @cindex Time
13087 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13088
13089 @node GNAT.CRC32 (g-crc32.ads)
13090 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13091 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13092 @cindex CRC32
13093 @cindex Cyclic Redundancy Check
13094
13095 @noindent
13096 This package implements the CRC-32 algorithm.  For a full description
13097 of this algorithm see
13098 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13099 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13100 Aug.@: 1988.  Sarwate, D.V@.
13101
13102 @node GNAT.Case_Util (g-casuti.ads)
13103 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13104 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13105 @cindex Casing utilities
13106 @cindex Character handling (@code{GNAT.Case_Util})
13107
13108 @noindent
13109 A set of simple routines for handling upper and lower casing of strings
13110 without the overhead of the full casing tables
13111 in @code{Ada.Characters.Handling}.
13112
13113 @node GNAT.CGI (g-cgi.ads)
13114 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13115 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13116 @cindex CGI (Common Gateway Interface)
13117
13118 @noindent
13119 This is a package for interfacing a GNAT program with a Web server via the
13120 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13121 parameters, which are a set of key/value pairs sent by the Web server.  It
13122 builds a table whose index is the key and provides some services to deal
13123 with this table.
13124
13125 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13126 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13127 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13128 @cindex CGI (Common Gateway Interface) cookie support
13129 @cindex Cookie support in CGI
13130
13131 @noindent
13132 This is a package to interface a GNAT program with a Web server via the
13133 Common Gateway Interface (CGI).  It exports services to deal with Web
13134 cookies (piece of information kept in the Web client software).
13135
13136 @node GNAT.CGI.Debug (g-cgideb.ads)
13137 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13138 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13139 @cindex CGI (Common Gateway Interface) debugging
13140
13141 @noindent
13142 This is a package to help debugging CGI (Common Gateway Interface)
13143 programs written in Ada.
13144
13145 @node GNAT.Command_Line (g-comlin.ads)
13146 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13147 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13148 @cindex Command line
13149
13150 @noindent
13151 Provides a high level interface to @code{Ada.Command_Line} facilities,
13152 including the ability to scan for named switches with optional parameters
13153 and expand file names using wild card notations.
13154
13155 @node GNAT.Compiler_Version (g-comver.ads)
13156 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13157 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13158 @cindex Compiler Version
13159 @cindex Version, of compiler
13160
13161 @noindent
13162 Provides a routine for obtaining the version of the compiler used to
13163 compile the program. More accurately this is the version of the binder
13164 used to bind the program (this will normally be the same as the version
13165 of the compiler if a consistent tool set is used to compile all units
13166 of a partition).
13167
13168 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13169 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13170 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13171 @cindex Interrupt
13172
13173 @noindent
13174 Provides a simple interface to handle Ctrl-C keyboard events.
13175
13176 @node GNAT.Current_Exception (g-curexc.ads)
13177 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13178 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13179 @cindex Current exception
13180 @cindex Exception retrieval
13181
13182 @noindent
13183 Provides access to information on the current exception that has been raised
13184 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13185 specification syntax.
13186 This is particularly useful in simulating typical facilities for
13187 obtaining information about exceptions provided by Ada 83 compilers.
13188
13189 @node GNAT.Debug_Pools (g-debpoo.ads)
13190 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13191 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13192 @cindex Debugging
13193 @cindex Debug pools
13194 @cindex Memory corruption debugging
13195
13196 @noindent
13197 Provide a debugging storage pools that helps tracking memory corruption
13198 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
13199 the @cite{GNAT User's Guide}.
13200
13201 @node GNAT.Debug_Utilities (g-debuti.ads)
13202 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13203 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13204 @cindex Debugging
13205
13206 @noindent
13207 Provides a few useful utilities for debugging purposes, including conversion
13208 to and from string images of address values. Supports both C and Ada formats
13209 for hexadecimal literals.
13210
13211 @node GNAT.Directory_Operations (g-dirope.ads)
13212 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13213 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13214 @cindex Directory operations
13215
13216 @noindent
13217 Provides a set of routines for manipulating directories, including changing
13218 the current directory, making new directories, and scanning the files in a
13219 directory.
13220
13221 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13222 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13223 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13224 @cindex Hash tables
13225
13226 @noindent
13227 A generic implementation of hash tables that can be used to hash arbitrary
13228 data.  Provided in two forms, a simple form with built in hash functions,
13229 and a more complex form in which the hash function is supplied.
13230
13231 @noindent
13232 This package provides a facility similar to that of @code{GNAT.HTable},
13233 except that this package declares a type that can be used to define
13234 dynamic instances of the hash table, while an instantiation of
13235 @code{GNAT.HTable} creates a single instance of the hash table.
13236
13237 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13238 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13239 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13240 @cindex Table implementation
13241 @cindex Arrays, extendable
13242
13243 @noindent
13244 A generic package providing a single dimension array abstraction where the
13245 length of the array can be dynamically modified.
13246
13247 @noindent
13248 This package provides a facility similar to that of @code{GNAT.Table},
13249 except that this package declares a type that can be used to define
13250 dynamic instances of the table, while an instantiation of
13251 @code{GNAT.Table} creates a single instance of the table type.
13252
13253 @node GNAT.Exception_Actions (g-excact.ads)
13254 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13255 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13256 @cindex Exception actions
13257
13258 @noindent
13259 Provides callbacks when an exception is raised. Callbacks can be registered
13260 for specific exceptions, or when any exception is raised. This
13261 can be used for instance to force a core dump to ease debugging.
13262
13263 @node GNAT.Exception_Traces (g-exctra.ads)
13264 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13265 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13266 @cindex Exception traces
13267 @cindex Debugging
13268
13269 @noindent
13270 Provides an interface allowing to control automatic output upon exception
13271 occurrences.
13272
13273 @node GNAT.Exceptions (g-except.ads)
13274 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13275 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13276 @cindex Exceptions, Pure
13277 @cindex Pure packages, exceptions
13278
13279 @noindent
13280 Normally it is not possible to raise an exception with
13281 a message from a subprogram in a pure package, since the
13282 necessary types and subprograms are in @code{Ada.Exceptions}
13283 which is not a pure unit. @code{GNAT.Exceptions} provides a
13284 facility for getting around this limitation for a few
13285 predefined exceptions, and for example allow raising
13286 @code{Constraint_Error} with a message from a pure subprogram.
13287
13288 @node GNAT.Expect (g-expect.ads)
13289 @section @code{GNAT.Expect} (@file{g-expect.ads})
13290 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13291
13292 @noindent
13293 Provides a set of subprograms similar to what is available
13294 with the standard Tcl Expect tool.
13295 It allows you to easily spawn and communicate with an external process.
13296 You can send commands or inputs to the process, and compare the output
13297 with some expected regular expression. Currently @code{GNAT.Expect}
13298 is implemented on all native GNAT ports except for OpenVMS@.
13299 It is not implemented for cross ports, and in particular is not
13300 implemented for VxWorks or LynxOS@.
13301
13302 @node GNAT.Float_Control (g-flocon.ads)
13303 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13304 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13305 @cindex Floating-Point Processor
13306
13307 @noindent
13308 Provides an interface for resetting the floating-point processor into the
13309 mode required for correct semantic operation in Ada.  Some third party
13310 library calls may cause this mode to be modified, and the Reset procedure
13311 in this package can be used to reestablish the required mode.
13312
13313 @node GNAT.Heap_Sort (g-heasor.ads)
13314 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13315 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13316 @cindex Sorting
13317
13318 @noindent
13319 Provides a general implementation of heap sort usable for sorting arbitrary
13320 data items. Exchange and comparison procedures are provided by passing
13321 access-to-procedure values.  The algorithm used is a modified heap sort
13322 that performs approximately N*log(N) comparisons in the worst case.
13323
13324 @node GNAT.Heap_Sort_A (g-hesora.ads)
13325 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13326 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13327 @cindex Sorting
13328
13329 @noindent
13330 Provides a general implementation of heap sort usable for sorting arbitrary
13331 data items. Move and comparison procedures are provided by passing
13332 access-to-procedure values.  The algorithm used is a modified heap sort
13333 that performs approximately N*log(N) comparisons in the worst case.
13334 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13335 interface, but may be slightly more efficient.
13336
13337 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13338 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13339 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13340 @cindex Sorting
13341
13342 @noindent
13343 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13344 are provided as generic parameters, this improves efficiency, especially
13345 if the procedures can be inlined, at the expense of duplicating code for
13346 multiple instantiations.
13347
13348 @node GNAT.HTable (g-htable.ads)
13349 @section @code{GNAT.HTable} (@file{g-htable.ads})
13350 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13351 @cindex Hash tables
13352
13353 @noindent
13354 A generic implementation of hash tables that can be used to hash arbitrary
13355 data.  Provides two approaches, one a simple static approach, and the other
13356 allowing arbitrary dynamic hash tables.
13357
13358 @node GNAT.IO (g-io.ads)
13359 @section @code{GNAT.IO} (@file{g-io.ads})
13360 @cindex @code{GNAT.IO} (@file{g-io.ads})
13361 @cindex Simple I/O
13362 @cindex Input/Output facilities
13363
13364 @noindent
13365 A simple preelaborable input-output package that provides a subset of
13366 simple Text_IO functions for reading characters and strings from
13367 Standard_Input, and writing characters, strings and integers to either
13368 Standard_Output or Standard_Error.
13369
13370 @node GNAT.IO_Aux (g-io_aux.ads)
13371 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13372 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13373 @cindex Text_IO
13374 @cindex Input/Output facilities
13375
13376 Provides some auxiliary functions for use with Text_IO, including a test
13377 for whether a file exists, and functions for reading a line of text.
13378
13379 @node GNAT.Lock_Files (g-locfil.ads)
13380 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13381 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13382 @cindex File locking
13383 @cindex Locking using files
13384
13385 @noindent
13386 Provides a general interface for using files as locks.  Can be used for
13387 providing program level synchronization.
13388
13389 @node GNAT.MD5 (g-md5.ads)
13390 @section @code{GNAT.MD5} (@file{g-md5.ads})
13391 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13392 @cindex Message Digest MD5
13393
13394 @noindent
13395 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13396
13397 @node GNAT.Memory_Dump (g-memdum.ads)
13398 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13399 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13400 @cindex Dump Memory
13401
13402 @noindent
13403 Provides a convenient routine for dumping raw memory to either the
13404 standard output or standard error files. Uses GNAT.IO for actual
13405 output.
13406
13407 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13408 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13409 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13410 @cindex Exception, obtaining most recent
13411
13412 @noindent
13413 Provides access to the most recently raised exception.  Can be used for
13414 various logging purposes, including duplicating functionality of some
13415 Ada 83 implementation dependent extensions.
13416
13417 @node GNAT.OS_Lib (g-os_lib.ads)
13418 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13419 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13420 @cindex Operating System interface
13421 @cindex Spawn capability
13422
13423 @noindent
13424 Provides a range of target independent operating system interface functions,
13425 including time/date management, file operations, subprocess management,
13426 including a portable spawn procedure, and access to environment variables
13427 and error return codes.
13428
13429 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13430 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13431 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13432 @cindex Hash functions
13433
13434 @noindent
13435 Provides a generator of static minimal perfect hash functions. No
13436 collisions occur and each item can be retrieved from the table in one
13437 probe (perfect property). The hash table size corresponds to the exact
13438 size of the key set and no larger (minimal property). The key set has to
13439 be know in advance (static property). The hash functions are also order
13440 preserving. If w2 is inserted after w1 in the generator, their
13441 hashcode are in the same order. These hashing functions are very
13442 convenient for use with realtime applications.
13443
13444 @node GNAT.Regexp (g-regexp.ads)
13445 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13446 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13447 @cindex Regular expressions
13448 @cindex Pattern matching
13449
13450 @noindent
13451 A simple implementation of regular expressions, using a subset of regular
13452 expression syntax copied from familiar Unix style utilities.  This is the
13453 simples of the three pattern matching packages provided, and is particularly
13454 suitable for ``file globbing'' applications.
13455
13456 @node GNAT.Registry (g-regist.ads)
13457 @section @code{GNAT.Registry} (@file{g-regist.ads})
13458 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13459 @cindex Windows Registry
13460
13461 @noindent
13462 This is a high level binding to the Windows registry.  It is possible to
13463 do simple things like reading a key value, creating a new key.  For full
13464 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13465 package provided with the Win32Ada binding
13466
13467 @node GNAT.Regpat (g-regpat.ads)
13468 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13469 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13470 @cindex Regular expressions
13471 @cindex Pattern matching
13472
13473 @noindent
13474 A complete implementation of Unix-style regular expression matching, copied
13475 from the original V7 style regular expression library written in C by
13476 Henry Spencer (and binary compatible with this C library).
13477
13478 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13479 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13480 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13481 @cindex Secondary Stack Info
13482
13483 @noindent
13484 Provide the capability to query the high water mark of the current task's
13485 secondary stack.
13486
13487 @node GNAT.Semaphores (g-semaph.ads)
13488 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13489 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13490 @cindex Semaphores
13491
13492 @noindent
13493 Provides classic counting and binary semaphores using protected types.
13494
13495 @node GNAT.SHA1 (g-sha1.ads)
13496 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13497 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13498 @cindex Secure Hash Algorithm SHA-1
13499
13500 @noindent
13501 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13502
13503 @node GNAT.Signals (g-signal.ads)
13504 @section @code{GNAT.Signals} (@file{g-signal.ads})
13505 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13506 @cindex Signals
13507
13508 @noindent
13509 Provides the ability to manipulate the blocked status of signals on supported
13510 targets.
13511
13512 @node GNAT.Sockets (g-socket.ads)
13513 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13514 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13515 @cindex Sockets
13516
13517 @noindent
13518 A high level and portable interface to develop sockets based applications.
13519 This package is based on the sockets thin binding found in
13520 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13521 on all native GNAT ports except for OpenVMS@.  It is not implemented
13522 for the LynxOS@ cross port.
13523
13524 @node GNAT.Source_Info (g-souinf.ads)
13525 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13526 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13527 @cindex Source Information
13528
13529 @noindent
13530 Provides subprograms that give access to source code information known at
13531 compile time, such as the current file name and line number.
13532
13533 @node GNAT.Spell_Checker (g-speche.ads)
13534 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13535 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13536 @cindex Spell checking
13537
13538 @noindent
13539 Provides a function for determining whether one string is a plausible
13540 near misspelling of another string.
13541
13542 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13543 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13544 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13545 @cindex SPITBOL pattern matching
13546 @cindex Pattern matching
13547
13548 @noindent
13549 A complete implementation of SNOBOL4 style pattern matching.  This is the
13550 most elaborate of the pattern matching packages provided.  It fully duplicates
13551 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13552 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13553
13554 @node GNAT.Spitbol (g-spitbo.ads)
13555 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13556 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13557 @cindex SPITBOL interface
13558
13559 @noindent
13560 The top level package of the collection of SPITBOL-style functionality, this
13561 package provides basic SNOBOL4 string manipulation functions, such as
13562 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13563 useful for constructing arbitrary mappings from strings in the style of
13564 the SNOBOL4 TABLE function.
13565
13566 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13567 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13568 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13569 @cindex Sets of strings
13570 @cindex SPITBOL Tables
13571
13572 @noindent
13573 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13574 for type @code{Standard.Boolean}, giving an implementation of sets of
13575 string values.
13576
13577 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13578 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13579 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13580 @cindex Integer maps
13581 @cindex Maps
13582 @cindex SPITBOL Tables
13583
13584 @noindent
13585 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13586 for type @code{Standard.Integer}, giving an implementation of maps
13587 from string to integer values.
13588
13589 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13590 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13591 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13592 @cindex String maps
13593 @cindex Maps
13594 @cindex SPITBOL Tables
13595
13596 @noindent
13597 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13598 a variable length string type, giving an implementation of general
13599 maps from strings to strings.
13600
13601 @node GNAT.Strings (g-string.ads)
13602 @section @code{GNAT.Strings} (@file{g-string.ads})
13603 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13604
13605 @noindent
13606 Common String access types and related subprograms. Basically it
13607 defines a string access and an array of string access types.
13608
13609 @node GNAT.String_Split (g-strspl.ads)
13610 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13611 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13612 @cindex String splitter
13613
13614 @noindent
13615 Useful string manipulation routines: given a set of separators, split
13616 a string wherever the separators appear, and provide direct access
13617 to the resulting slices. This package is instantiated from
13618 @code{GNAT.Array_Split}.
13619
13620 @node GNAT.UTF_32 (g-utf_32.ads)
13621 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13622 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13623 @cindex Wide character codes
13624
13625 @noindent
13626 This is a package intended to be used in conjunction with the
13627 @code{Wide_Character} type in Ada 95 and the
13628 @code{Wide_Wide_Character} type in Ada 2005 (available
13629 in @code{GNAT} in Ada 2005 mode). This package contains
13630 Unicode categorization routines, as well as lexical
13631 categorization routines corresponding to the Ada 2005
13632 lexical rules for identifiers and strings, and also a
13633 lower case to upper case fold routine corresponding to
13634 the Ada 2005 rules for identifier equivalence.
13635
13636 @node GNAT.Table (g-table.ads)
13637 @section @code{GNAT.Table} (@file{g-table.ads})
13638 @cindex @code{GNAT.Table} (@file{g-table.ads})
13639 @cindex Table implementation
13640 @cindex Arrays, extendable
13641
13642 @noindent
13643 A generic package providing a single dimension array abstraction where the
13644 length of the array can be dynamically modified.
13645
13646 @noindent
13647 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13648 except that this package declares a single instance of the table type,
13649 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13650 used to define dynamic instances of the table.
13651
13652 @node GNAT.Task_Lock (g-tasloc.ads)
13653 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13654 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13655 @cindex Task synchronization
13656 @cindex Task locking
13657 @cindex Locking
13658
13659 @noindent
13660 A very simple facility for locking and unlocking sections of code using a
13661 single global task lock.  Appropriate for use in situations where contention
13662 between tasks is very rarely expected.
13663
13664 @node GNAT.Threads (g-thread.ads)
13665 @section @code{GNAT.Threads} (@file{g-thread.ads})
13666 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13667 @cindex Foreign threads
13668 @cindex Threads, foreign
13669
13670 @noindent
13671 Provides facilities for dealing with foreign threads which need to be known
13672 by the GNAT run-time system. Consult the documentation of this package for
13673 further details if your program has threads that are created by a non-Ada
13674 environment which then accesses Ada code.
13675
13676 @node GNAT.Traceback (g-traceb.ads)
13677 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13678 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13679 @cindex Trace back facilities
13680
13681 @noindent
13682 Provides a facility for obtaining non-symbolic traceback information, useful
13683 in various debugging situations.
13684
13685 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13686 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13687 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13688 @cindex Trace back facilities
13689
13690 @noindent
13691 Provides symbolic traceback information that includes the subprogram
13692 name and line number information. Note that this capability is not available
13693 on all targets, see g-trasym.ads for list of supported targets.
13694
13695 @node GNAT.Wide_String_Split (g-wistsp.ads)
13696 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13697 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13698 @cindex Wide_String splitter
13699
13700 @noindent
13701 Useful wide string manipulation routines: given a set of separators, split
13702 a wide string wherever the separators appear, and provide direct access
13703 to the resulting slices. This package is instantiated from
13704 @code{GNAT.Array_Split}.
13705
13706 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13707 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13708 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13709 @cindex Wide_Wide_String splitter
13710
13711 @noindent
13712 Useful wide wide string manipulation routines: given a set of separators, split
13713 a wide wide string wherever the separators appear, and provide direct access
13714 to the resulting slices. This package is instantiated from
13715 @code{GNAT.Array_Split}.
13716
13717 @node Interfaces.C.Extensions (i-cexten.ads)
13718 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13719 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13720
13721 @noindent
13722 This package contains additional C-related definitions, intended
13723 for use with either manually or automatically generated bindings
13724 to C libraries.
13725
13726 @node Interfaces.C.Streams (i-cstrea.ads)
13727 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13728 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13729 @cindex  C streams, interfacing
13730
13731 @noindent
13732 This package is a binding for the most commonly used operations
13733 on C streams.
13734
13735 @node Interfaces.CPP (i-cpp.ads)
13736 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13737 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13738 @cindex  C++ interfacing
13739 @cindex  Interfacing, to C++
13740
13741 @noindent
13742 This package provides facilities for use in interfacing to C++.  It
13743 is primarily intended to be used in connection with automated tools
13744 for the generation of C++ interfaces.
13745
13746 @node Interfaces.Os2lib (i-os2lib.ads)
13747 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13748 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13749 @cindex Interfacing, to OS/2
13750 @cindex OS/2 interfacing
13751
13752 @noindent
13753 This package provides interface definitions to the OS/2 library.
13754 It is a thin binding which is a direct translation of the
13755 various @file{<bse@.h>} files.
13756
13757 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13758 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13759 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13760 @cindex OS/2 Error codes
13761 @cindex Interfacing, to OS/2
13762 @cindex OS/2 interfacing
13763
13764 @noindent
13765 This package provides definitions of the OS/2 error codes.
13766
13767 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13768 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13769 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13770 @cindex Interfacing, to OS/2
13771 @cindex Synchronization, OS/2
13772 @cindex OS/2 synchronization primitives
13773
13774 @noindent
13775 This is a child package that provides definitions for interfacing
13776 to the @code{OS/2} synchronization primitives.
13777
13778 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13779 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13780 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13781 @cindex Interfacing, to OS/2
13782 @cindex Thread control, OS/2
13783 @cindex OS/2 thread interfacing
13784
13785 @noindent
13786 This is a child package that provides definitions for interfacing
13787 to the @code{OS/2} thread primitives.
13788
13789 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13790 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13791 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13792 @cindex  IBM Packed Format
13793 @cindex  Packed Decimal
13794
13795 @noindent
13796 This package provides a set of routines for conversions to and
13797 from a packed decimal format compatible with that used on IBM
13798 mainframes.
13799
13800 @node Interfaces.VxWorks (i-vxwork.ads)
13801 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13802 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13803 @cindex Interfacing to VxWorks
13804 @cindex VxWorks, interfacing
13805
13806 @noindent
13807 This package provides a limited binding to the VxWorks API.
13808 In particular, it interfaces with the
13809 VxWorks hardware interrupt facilities.
13810
13811 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13812 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13813 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13814 @cindex Interfacing to VxWorks' I/O
13815 @cindex VxWorks, I/O interfacing
13816 @cindex VxWorks, Get_Immediate
13817 @cindex Get_Immediate, VxWorks
13818
13819 @noindent
13820 This package provides a binding to the ioctl (IO/Control)
13821 function of VxWorks, defining a set of option values and
13822 function codes. A particular use of this package is
13823 to enable the use of Get_Immediate under VxWorks.
13824
13825 @node System.Address_Image (s-addima.ads)
13826 @section @code{System.Address_Image} (@file{s-addima.ads})
13827 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13828 @cindex Address image
13829 @cindex Image, of an address
13830
13831 @noindent
13832 This function provides a useful debugging
13833 function that gives an (implementation dependent)
13834 string which identifies an address.
13835
13836 @node System.Assertions (s-assert.ads)
13837 @section @code{System.Assertions} (@file{s-assert.ads})
13838 @cindex @code{System.Assertions} (@file{s-assert.ads})
13839 @cindex Assertions
13840 @cindex Assert_Failure, exception
13841
13842 @noindent
13843 This package provides the declaration of the exception raised
13844 by an run-time assertion failure, as well as the routine that
13845 is used internally to raise this assertion.
13846
13847 @node System.Memory (s-memory.ads)
13848 @section @code{System.Memory} (@file{s-memory.ads})
13849 @cindex @code{System.Memory} (@file{s-memory.ads})
13850 @cindex Memory allocation
13851
13852 @noindent
13853 This package provides the interface to the low level routines used
13854 by the generated code for allocation and freeing storage for the
13855 default storage pool (analogous to the C routines malloc and free.
13856 It also provides a reallocation interface analogous to the C routine
13857 realloc. The body of this unit may be modified to provide alternative
13858 allocation mechanisms for the default pool, and in addition, direct
13859 calls to this unit may be made for low level allocation uses (for
13860 example see the body of @code{GNAT.Tables}).
13861
13862 @node System.Partition_Interface (s-parint.ads)
13863 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13864 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13865 @cindex Partition interfacing functions
13866
13867 @noindent
13868 This package provides facilities for partition interfacing.  It
13869 is used primarily in a distribution context when using Annex E
13870 with @code{GLADE}.
13871
13872 @node System.Restrictions (s-restri.ads)
13873 @section @code{System.Restrictions} (@file{s-restri.ads})
13874 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13875 @cindex Run-time restrictions access
13876
13877 @noindent
13878 This package provides facilities for accessing at run time
13879 the status of restrictions specified at compile time for
13880 the partition. Information is available both with regard
13881 to actual restrictions specified, and with regard to
13882 compiler determined information on which restrictions
13883 are violated by one or more packages in the partition.
13884
13885 @node System.Rident (s-rident.ads)
13886 @section @code{System.Rident} (@file{s-rident.ads})
13887 @cindex @code{System.Rident} (@file{s-rident.ads})
13888 @cindex Restrictions definitions
13889
13890 @noindent
13891 This package provides definitions of the restrictions
13892 identifiers supported by GNAT, and also the format of
13893 the restrictions provided in package System.Restrictions.
13894 It is not normally necessary to @code{with} this generic package
13895 since the necessary instantiation is included in
13896 package System.Restrictions.
13897
13898 @node System.Task_Info (s-tasinf.ads)
13899 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13900 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13901 @cindex Task_Info pragma
13902
13903 @noindent
13904 This package provides target dependent functionality that is used
13905 to support the @code{Task_Info} pragma
13906
13907 @node System.Wch_Cnv (s-wchcnv.ads)
13908 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13909 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13910 @cindex Wide Character, Representation
13911 @cindex Wide String, Conversion
13912 @cindex Representation of wide characters
13913
13914 @noindent
13915 This package provides routines for converting between
13916 wide and wide wide characters and a representation as a value of type
13917 @code{Standard.String}, using a specified wide character
13918 encoding method.  It uses definitions in
13919 package @code{System.Wch_Con}.
13920
13921 @node System.Wch_Con (s-wchcon.ads)
13922 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13923 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13924
13925 @noindent
13926 This package provides definitions and descriptions of
13927 the various methods used for encoding wide characters
13928 in ordinary strings.  These definitions are used by
13929 the package @code{System.Wch_Cnv}.
13930
13931 @node Interfacing to Other Languages
13932 @chapter Interfacing to Other Languages
13933 @noindent
13934 The facilities in annex B of the Ada Reference Manual are fully
13935 implemented in GNAT, and in addition, a full interface to C++ is
13936 provided.
13937
13938 @menu
13939 * Interfacing to C::
13940 * Interfacing to C++::
13941 * Interfacing to COBOL::
13942 * Interfacing to Fortran::
13943 * Interfacing to non-GNAT Ada code::
13944 @end menu
13945
13946 @node Interfacing to C
13947 @section Interfacing to C
13948
13949 @noindent
13950 Interfacing to C with GNAT can use one of two approaches:
13951
13952 @itemize @bullet
13953 @item
13954 The types in the package @code{Interfaces.C} may be used.
13955 @item
13956 Standard Ada types may be used directly.  This may be less portable to
13957 other compilers, but will work on all GNAT compilers, which guarantee
13958 correspondence between the C and Ada types.
13959 @end itemize
13960
13961 @noindent
13962 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13963 effect, since this is the default.  The following table shows the
13964 correspondence between Ada scalar types and the corresponding C types.
13965
13966 @table @code
13967 @item Integer
13968 @code{int}
13969 @item Short_Integer
13970 @code{short}
13971 @item Short_Short_Integer
13972 @code{signed char}
13973 @item Long_Integer
13974 @code{long}
13975 @item Long_Long_Integer
13976 @code{long long}
13977 @item Short_Float
13978 @code{float}
13979 @item Float
13980 @code{float}
13981 @item Long_Float
13982 @code{double}
13983 @item Long_Long_Float
13984 This is the longest floating-point type supported by the hardware.
13985 @end table
13986
13987 @noindent
13988 Additionally, there are the following general correspondences between Ada
13989 and C types:
13990 @itemize @bullet
13991 @item
13992 Ada enumeration types map to C enumeration types directly if pragma
13993 @code{Convention C} is specified, which causes them to have int
13994 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13995 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13996 @code{int}, respectively) depending on the number of values passed.
13997 This is the only case in which pragma @code{Convention C} affects the
13998 representation of an Ada type.
13999
14000 @item
14001 Ada access types map to C pointers, except for the case of pointers to
14002 unconstrained types in Ada, which have no direct C equivalent.
14003
14004 @item
14005 Ada arrays map directly to C arrays.
14006
14007 @item
14008 Ada records map directly to C structures.
14009
14010 @item
14011 Packed Ada records map to C structures where all members are bit fields
14012 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14013 @end itemize
14014
14015 @node Interfacing to C++
14016 @section Interfacing to C++
14017
14018 @noindent
14019 The interface to C++ makes use of the following pragmas, which are
14020 primarily intended to be constructed automatically using a binding generator
14021 tool, although it is possible to construct them by hand.  No suitable binding
14022 generator tool is supplied with GNAT though.
14023
14024 Using these pragmas it is possible to achieve complete
14025 inter-operability between Ada tagged types and C++ class definitions.
14026 See @ref{Implementation Defined Pragmas}, for more details.
14027
14028 @table @code
14029 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
14030 The argument denotes an entity in the current declarative region that is
14031 declared as a tagged or untagged record type. It indicates that the type
14032 corresponds to an externally declared C++ class type, and is to be laid
14033 out the same way that C++ would lay out the type.
14034
14035 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14036 for backward compatibility but its functionality is available
14037 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14038
14039 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
14040 This pragma identifies an imported function (imported in the usual way
14041 with pragma @code{Import}) as corresponding to a C++ constructor.
14042 @end table
14043
14044 @node Interfacing to COBOL
14045 @section Interfacing to COBOL
14046
14047 @noindent
14048 Interfacing to COBOL is achieved as described in section B.4 of
14049 the Ada Reference Manual.
14050
14051 @node Interfacing to Fortran
14052 @section Interfacing to Fortran
14053
14054 @noindent
14055 Interfacing to Fortran is achieved as described in section B.5 of the
14056 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14057 multi-dimensional array causes the array to be stored in column-major
14058 order as required for convenient interface to Fortran.
14059
14060 @node Interfacing to non-GNAT Ada code
14061 @section Interfacing to non-GNAT Ada code
14062
14063 It is possible to specify the convention @code{Ada} in a pragma
14064 @code{Import} or pragma @code{Export}.  However this refers to
14065 the calling conventions used by GNAT, which may or may not be
14066 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14067 compiler to allow interoperation.
14068
14069 If arguments types are kept simple, and if the foreign compiler generally
14070 follows system calling conventions, then it may be possible to integrate
14071 files compiled by other Ada compilers, provided that the elaboration
14072 issues are adequately addressed (for example by eliminating the
14073 need for any load time elaboration).
14074
14075 In particular, GNAT running on VMS is designed to
14076 be highly compatible with the DEC Ada 83 compiler, so this is one
14077 case in which it is possible to import foreign units of this type,
14078 provided that the data items passed are restricted to simple scalar
14079 values or simple record types without variants, or simple array
14080 types with fixed bounds.
14081
14082 @node Specialized Needs Annexes
14083 @chapter Specialized Needs Annexes
14084
14085 @noindent
14086 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14087 required in all implementations.  However, as described in this chapter,
14088 GNAT implements all of these annexes:
14089
14090 @table @asis
14091 @item Systems Programming (Annex C)
14092 The Systems Programming Annex is fully implemented.
14093
14094 @item Real-Time Systems (Annex D)
14095 The Real-Time Systems Annex is fully implemented.
14096
14097 @item Distributed Systems (Annex E)
14098 Stub generation is fully implemented in the GNAT compiler.  In addition,
14099 a complete compatible PCS is available as part of the GLADE system,
14100 a separate product.  When the two
14101 products are used in conjunction, this annex is fully implemented.
14102
14103 @item Information Systems (Annex F)
14104 The Information Systems annex is fully implemented.
14105
14106 @item Numerics (Annex G)
14107 The Numerics Annex is fully implemented.
14108
14109 @item Safety and Security / High-Integrity Systems (Annex H)
14110 The Safety and Security Annex (termed the High-Integrity Systems Annex
14111 in Ada 2005) is fully implemented.
14112 @end table
14113
14114 @node Implementation of Specific Ada Features
14115 @chapter Implementation of Specific Ada Features
14116
14117 @noindent
14118 This chapter describes the GNAT implementation of several Ada language
14119 facilities.
14120
14121 @menu
14122 * Machine Code Insertions::
14123 * GNAT Implementation of Tasking::
14124 * GNAT Implementation of Shared Passive Packages::
14125 * Code Generation for Array Aggregates::
14126 * The Size of Discriminated Records with Default Discriminants::
14127 * Strict Conformance to the Ada Reference Manual::
14128 @end menu
14129
14130 @node Machine Code Insertions
14131 @section Machine Code Insertions
14132 @cindex Machine Code insertions
14133
14134 @noindent
14135 Package @code{Machine_Code} provides machine code support as described
14136 in the Ada Reference Manual in two separate forms:
14137 @itemize @bullet
14138 @item
14139 Machine code statements, consisting of qualified expressions that
14140 fit the requirements of RM section 13.8.
14141 @item
14142 An intrinsic callable procedure, providing an alternative mechanism of
14143 including machine instructions in a subprogram.
14144 @end itemize
14145
14146 @noindent
14147 The two features are similar, and both are closely related to the mechanism
14148 provided by the asm instruction in the GNU C compiler.  Full understanding
14149 and use of the facilities in this package requires understanding the asm
14150 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14151 by Richard Stallman. The relevant section is titled ``Extensions to the C
14152 Language Family'' @result{} ``Assembler Instructions with C Expression
14153 Operands''.
14154
14155 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14156 semantic restrictions and effects as described below.  Both are provided so
14157 that the procedure call can be used as a statement, and the function call
14158 can be used to form a code_statement.
14159
14160 The first example given in the GCC documentation is the C @code{asm}
14161 instruction:
14162 @smallexample
14163    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14164 @end smallexample
14165
14166 @noindent
14167 The equivalent can be written for GNAT as:
14168
14169 @smallexample @c ada
14170 Asm ("fsinx %1 %0",
14171      My_Float'Asm_Output ("=f", result),
14172      My_Float'Asm_Input  ("f",  angle));
14173 @end smallexample
14174
14175 @noindent
14176 The first argument to @code{Asm} is the assembler template, and is
14177 identical to what is used in GNU C@.  This string must be a static
14178 expression.  The second argument is the output operand list.  It is
14179 either a single @code{Asm_Output} attribute reference, or a list of such
14180 references enclosed in parentheses (technically an array aggregate of
14181 such references).
14182
14183 The @code{Asm_Output} attribute denotes a function that takes two
14184 parameters.  The first is a string, the second is the name of a variable
14185 of the type designated by the attribute prefix.  The first (string)
14186 argument is required to be a static expression and designates the
14187 constraint for the parameter (e.g.@: what kind of register is
14188 required).  The second argument is the variable to be updated with the
14189 result.  The possible values for constraint are the same as those used in
14190 the RTL, and are dependent on the configuration file used to build the
14191 GCC back end.  If there are no output operands, then this argument may
14192 either be omitted, or explicitly given as @code{No_Output_Operands}.
14193
14194 The second argument of @code{@var{my_float}'Asm_Output} functions as
14195 though it were an @code{out} parameter, which is a little curious, but
14196 all names have the form of expressions, so there is no syntactic
14197 irregularity, even though normally functions would not be permitted
14198 @code{out} parameters.  The third argument is the list of input
14199 operands.  It is either a single @code{Asm_Input} attribute reference, or
14200 a list of such references enclosed in parentheses (technically an array
14201 aggregate of such references).
14202
14203 The @code{Asm_Input} attribute denotes a function that takes two
14204 parameters.  The first is a string, the second is an expression of the
14205 type designated by the prefix.  The first (string) argument is required
14206 to be a static expression, and is the constraint for the parameter,
14207 (e.g.@: what kind of register is required).  The second argument is the
14208 value to be used as the input argument.  The possible values for the
14209 constant are the same as those used in the RTL, and are dependent on
14210 the configuration file used to built the GCC back end.
14211
14212 If there are no input operands, this argument may either be omitted, or
14213 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
14214 present in the above example, is a list of register names, called the
14215 @dfn{clobber} argument.  This argument, if given, must be a static string
14216 expression, and is a space or comma separated list of names of registers
14217 that must be considered destroyed as a result of the @code{Asm} call.  If
14218 this argument is the null string (the default value), then the code
14219 generator assumes that no additional registers are destroyed.
14220
14221 The fifth argument, not present in the above example, called the
14222 @dfn{volatile} argument, is by default @code{False}.  It can be set to
14223 the literal value @code{True} to indicate to the code generator that all
14224 optimizations with respect to the instruction specified should be
14225 suppressed, and that in particular, for an instruction that has outputs,
14226 the instruction will still be generated, even if none of the outputs are
14227 used.  See the full description in the GCC manual for further details.
14228 Generally it is strongly advisable to use Volatile for any ASM statement
14229 that is missing either input or output operands, or when two or more ASM
14230 statements appear in sequence, to avoid unwanted optimizations. A warning
14231 is generated if this advice is not followed.
14232
14233 The @code{Asm} subprograms may be used in two ways.  First the procedure
14234 forms can be used anywhere a procedure call would be valid, and
14235 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
14236 be used to intersperse machine instructions with other Ada statements.
14237 Second, the function forms, which return a dummy value of the limited
14238 private type @code{Asm_Insn}, can be used in code statements, and indeed
14239 this is the only context where such calls are allowed.  Code statements
14240 appear as aggregates of the form:
14241
14242 @smallexample @c ada
14243 Asm_Insn'(Asm (@dots{}));
14244 Asm_Insn'(Asm_Volatile (@dots{}));
14245 @end smallexample
14246
14247 @noindent
14248 In accordance with RM rules, such code statements are allowed only
14249 within subprograms whose entire body consists of such statements.  It is
14250 not permissible to intermix such statements with other Ada statements.
14251
14252 Typically the form using intrinsic procedure calls is more convenient
14253 and more flexible.  The code statement form is provided to meet the RM
14254 suggestion that such a facility should be made available.  The following
14255 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14256 is used, the arguments may be given in arbitrary order, following the
14257 normal rules for use of positional and named arguments)
14258
14259 @smallexample
14260 ASM_CALL ::= Asm (
14261                  [Template =>] static_string_EXPRESSION
14262                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14263                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14264                [,[Clobber  =>] static_string_EXPRESSION ]
14265                [,[Volatile =>] static_boolean_EXPRESSION] )
14266
14267 OUTPUT_OPERAND_LIST ::=
14268   [PREFIX.]No_Output_Operands
14269 | OUTPUT_OPERAND_ATTRIBUTE
14270 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14271
14272 OUTPUT_OPERAND_ATTRIBUTE ::=
14273   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14274
14275 INPUT_OPERAND_LIST ::=
14276   [PREFIX.]No_Input_Operands
14277 | INPUT_OPERAND_ATTRIBUTE
14278 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14279
14280 INPUT_OPERAND_ATTRIBUTE ::=
14281   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14282 @end smallexample
14283
14284 @noindent
14285 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14286 are declared in the package @code{Machine_Code} and must be referenced
14287 according to normal visibility rules. In particular if there is no
14288 @code{use} clause for this package, then appropriate package name
14289 qualification is required.
14290
14291 @node GNAT Implementation of Tasking
14292 @section GNAT Implementation of Tasking
14293
14294 @noindent
14295 This chapter outlines the basic GNAT approach to tasking (in particular,
14296 a multi-layered library for portability) and discusses issues related
14297 to compliance with the Real-Time Systems Annex.
14298
14299 @menu
14300 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14301 * Ensuring Compliance with the Real-Time Annex::
14302 @end menu
14303
14304 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14305 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14306
14307 @noindent
14308 GNAT's run-time support comprises two layers:
14309
14310 @itemize @bullet
14311 @item GNARL (GNAT Run-time Layer)
14312 @item GNULL (GNAT Low-level Library)
14313 @end itemize
14314
14315 @noindent
14316 In GNAT, Ada's tasking services rely on a platform and OS independent
14317 layer known as GNARL@.  This code is responsible for implementing the
14318 correct semantics of Ada's task creation, rendezvous, protected
14319 operations etc.
14320
14321 GNARL decomposes Ada's tasking semantics into simpler lower level
14322 operations such as create a thread, set the priority of a thread,
14323 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14324 operations constitutes GNULLI, the GNULL Interface.  This interface is
14325 directly inspired from the POSIX real-time API@.
14326
14327 If the underlying executive or OS implements the POSIX standard
14328 faithfully, the GNULL Interface maps as is to the services offered by
14329 the underlying kernel.  Otherwise, some target dependent glue code maps
14330 the services offered by the underlying kernel to the semantics expected
14331 by GNARL@.
14332
14333 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14334 key point is that each Ada task is mapped on a thread in the underlying
14335 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14336
14337 In addition Ada task priorities map onto the underlying thread priorities.
14338 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14339
14340 @itemize @bullet
14341 @item
14342 The underlying scheduler is used to schedule the Ada tasks.  This
14343 makes Ada tasks as efficient as kernel threads from a scheduling
14344 standpoint.
14345
14346 @item
14347 Interaction with code written in C containing threads is eased
14348 since at the lowest level Ada tasks and C threads map onto the same
14349 underlying kernel concept.
14350
14351 @item
14352 When an Ada task is blocked during I/O the remaining Ada tasks are
14353 able to proceed.
14354
14355 @item
14356 On multiprocessor systems Ada tasks can execute in parallel.
14357 @end itemize
14358
14359 @noindent
14360 Some threads libraries offer a mechanism to fork a new process, with the
14361 child process duplicating the threads from the parent.
14362 GNAT does not
14363 support this functionality when the parent contains more than one task.
14364 @cindex Forking a new process
14365
14366 @node Ensuring Compliance with the Real-Time Annex
14367 @subsection Ensuring Compliance with the Real-Time Annex
14368 @cindex Real-Time Systems Annex compliance
14369
14370 @noindent
14371 Although mapping Ada tasks onto
14372 the underlying threads has significant advantages, it does create some
14373 complications when it comes to respecting the scheduling semantics
14374 specified in the real-time annex (Annex D).
14375
14376 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14377 scheduling policy states:
14378
14379 @quotation
14380 @emph{When the active priority of a ready task that is not running
14381 changes, or the setting of its base priority takes effect, the
14382 task is removed from the ready queue for its old active priority
14383 and is added at the tail of the ready queue for its new active
14384 priority, except in the case where the active priority is lowered
14385 due to the loss of inherited priority, in which case the task is
14386 added at the head of the ready queue for its new active priority.}
14387 @end quotation
14388
14389 @noindent
14390 While most kernels do put tasks at the end of the priority queue when
14391 a task changes its priority, (which respects the main
14392 FIFO_Within_Priorities requirement), almost none keep a thread at the
14393 beginning of its priority queue when its priority drops from the loss
14394 of inherited priority.
14395
14396 As a result most vendors have provided incomplete Annex D implementations.
14397
14398 The GNAT run-time, has a nice cooperative solution to this problem
14399 which ensures that accurate FIFO_Within_Priorities semantics are
14400 respected.
14401
14402 The principle is as follows.  When an Ada task T is about to start
14403 running, it checks whether some other Ada task R with the same
14404 priority as T has been suspended due to the loss of priority
14405 inheritance.  If this is the case, T yields and is placed at the end of
14406 its priority queue.  When R arrives at the front of the queue it
14407 executes.
14408
14409 Note that this simple scheme preserves the relative order of the tasks
14410 that were ready to execute in the priority queue where R has been
14411 placed at the end.
14412
14413 @node GNAT Implementation of Shared Passive Packages
14414 @section GNAT Implementation of Shared Passive Packages
14415 @cindex Shared passive packages
14416
14417 @noindent
14418 GNAT fully implements the pragma @code{Shared_Passive} for
14419 @cindex pragma @code{Shared_Passive}
14420 the purpose of designating shared passive packages.
14421 This allows the use of passive partitions in the
14422 context described in the Ada Reference Manual; i.e. for communication
14423 between separate partitions of a distributed application using the
14424 features in Annex E.
14425 @cindex Annex E
14426 @cindex Distribution Systems Annex
14427
14428 However, the implementation approach used by GNAT provides for more
14429 extensive usage as follows:
14430
14431 @table @emph
14432 @item Communication between separate programs
14433
14434 This allows separate programs to access the data in passive
14435 partitions, using protected objects for synchronization where
14436 needed. The only requirement is that the two programs have a
14437 common shared file system. It is even possible for programs
14438 running on different machines with different architectures
14439 (e.g. different endianness) to communicate via the data in
14440 a passive partition.
14441
14442 @item Persistence between program runs
14443
14444 The data in a passive package can persist from one run of a
14445 program to another, so that a later program sees the final
14446 values stored by a previous run of the same program.
14447
14448 @end table
14449
14450 @noindent
14451 The implementation approach used is to store the data in files. A
14452 separate stream file is created for each object in the package, and
14453 an access to an object causes the corresponding file to be read or
14454 written.
14455
14456 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14457 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14458 set to the directory to be used for these files.
14459 The files in this directory
14460 have names that correspond to their fully qualified names. For
14461 example, if we have the package
14462
14463 @smallexample @c ada
14464 package X is
14465   pragma Shared_Passive (X);
14466   Y : Integer;
14467   Z : Float;
14468 end X;
14469 @end smallexample
14470
14471 @noindent
14472 and the environment variable is set to @code{/stemp/}, then the files created
14473 will have the names:
14474
14475 @smallexample
14476 /stemp/x.y
14477 /stemp/x.z
14478 @end smallexample
14479
14480 @noindent
14481 These files are created when a value is initially written to the object, and
14482 the files are retained until manually deleted. This provides the persistence
14483 semantics. If no file exists, it means that no partition has assigned a value
14484 to the variable; in this case the initial value declared in the package
14485 will be used. This model ensures that there are no issues in synchronizing
14486 the elaboration process, since elaboration of passive packages elaborates the
14487 initial values, but does not create the files.
14488
14489 The files are written using normal @code{Stream_IO} access.
14490 If you want to be able
14491 to communicate between programs or partitions running on different
14492 architectures, then you should use the XDR versions of the stream attribute
14493 routines, since these are architecture independent.
14494
14495 If active synchronization is required for access to the variables in the
14496 shared passive package, then as described in the Ada Reference Manual, the
14497 package may contain protected objects used for this purpose. In this case
14498 a lock file (whose name is @file{___lock} (three underscores)
14499 is created in the shared memory directory.
14500 @cindex @file{___lock} file (for shared passive packages)
14501 This is used to provide the required locking
14502 semantics for proper protected object synchronization.
14503
14504 As of January 2003, GNAT supports shared passive packages on all platforms
14505 except for OpenVMS.
14506
14507 @node Code Generation for Array Aggregates
14508 @section Code Generation for Array Aggregates
14509
14510 @menu
14511 * Static constant aggregates with static bounds::
14512 * Constant aggregates with unconstrained nominal types::
14513 * Aggregates with static bounds::
14514 * Aggregates with non-static bounds::
14515 * Aggregates in assignment statements::
14516 @end menu
14517
14518 @noindent
14519 Aggregates have a rich syntax and allow the user to specify the values of
14520 complex data structures by means of a single construct.  As a result, the
14521 code generated for aggregates can be quite complex and involve loops, case
14522 statements and multiple assignments.  In the simplest cases, however, the
14523 compiler will recognize aggregates whose components and constraints are
14524 fully static, and in those cases the compiler will generate little or no
14525 executable code.  The following is an outline of the code that GNAT generates
14526 for various aggregate constructs.  For further details, you will find it
14527 useful to examine the output produced by the -gnatG flag to see the expanded
14528 source that is input to the code generator.  You may also want to examine
14529 the assembly code generated at various levels of optimization.
14530
14531 The code generated for aggregates depends on the context, the component values,
14532 and the type.  In the context of an object declaration the code generated is
14533 generally simpler than in the case of an assignment.  As a general rule, static
14534 component values and static subtypes also lead to simpler code.
14535
14536 @node Static constant aggregates with static bounds
14537 @subsection Static constant aggregates with static bounds
14538
14539 @noindent
14540 For the declarations:
14541 @smallexample @c ada
14542     type One_Dim is array (1..10) of integer;
14543     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14544 @end smallexample
14545
14546 @noindent
14547 GNAT generates no executable code: the constant ar0 is placed in static memory.
14548 The same is true for constant aggregates with named associations:
14549
14550 @smallexample @c ada
14551     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14552     Cr3 : constant One_Dim := (others => 7777);
14553 @end smallexample
14554
14555 @noindent
14556 The same is true for multidimensional constant arrays such as:
14557
14558 @smallexample @c ada
14559     type two_dim is array (1..3, 1..3) of integer;
14560     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14561 @end smallexample
14562
14563 @noindent
14564 The same is true for arrays of one-dimensional arrays: the following are
14565 static:
14566
14567 @smallexample @c ada
14568 type ar1b  is array (1..3) of boolean;
14569 type ar_ar is array (1..3) of ar1b;
14570 None  : constant ar1b := (others => false);     --  fully static
14571 None2 : constant ar_ar := (1..3 => None);       --  fully static
14572 @end smallexample
14573
14574 @noindent
14575 However, for multidimensional aggregates with named associations, GNAT will
14576 generate assignments and loops, even if all associations are static.  The
14577 following two declarations generate a loop for the first dimension, and
14578 individual component assignments for the second dimension:
14579
14580 @smallexample @c ada
14581 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14582 Zero2: constant two_dim := (others => (others => 0));
14583 @end smallexample
14584
14585 @node Constant aggregates with unconstrained nominal types
14586 @subsection Constant aggregates with unconstrained nominal types
14587
14588 @noindent
14589 In such cases the aggregate itself establishes the subtype, so that
14590 associations with @code{others} cannot be used.  GNAT determines the
14591 bounds for the actual subtype of the aggregate, and allocates the
14592 aggregate statically as well.  No code is generated for the following:
14593
14594 @smallexample @c ada
14595     type One_Unc is array (natural range <>) of integer;
14596     Cr_Unc : constant One_Unc := (12,24,36);
14597 @end smallexample
14598
14599 @node Aggregates with static bounds
14600 @subsection Aggregates with static bounds
14601
14602 @noindent
14603 In all previous examples the aggregate was the initial (and immutable) value
14604 of a constant.  If the aggregate initializes a variable, then code is generated
14605 for it as a combination of individual assignments and loops over the target
14606 object.  The declarations
14607
14608 @smallexample @c ada
14609        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14610        Cr_Var2 : One_Dim := (others > -1);
14611 @end smallexample
14612
14613 @noindent
14614 generate the equivalent of
14615
14616 @smallexample @c ada
14617        Cr_Var1 (1) := 2;
14618        Cr_Var1 (2) := 3;
14619        Cr_Var1 (3) := 5;
14620        Cr_Var1 (4) := 11;
14621
14622        for I in Cr_Var2'range loop
14623           Cr_Var2 (I) := =-1;
14624        end loop;
14625 @end smallexample
14626
14627 @node Aggregates with non-static bounds
14628 @subsection Aggregates with non-static bounds
14629
14630 @noindent
14631 If the bounds of the aggregate are not statically compatible with the bounds
14632 of the nominal subtype  of the target, then constraint checks have to be
14633 generated on the bounds.  For a multidimensional array, constraint checks may
14634 have to be applied to sub-arrays individually, if they do not have statically
14635 compatible subtypes.
14636
14637 @node Aggregates in assignment statements
14638 @subsection Aggregates in assignment statements
14639
14640 @noindent
14641 In general, aggregate assignment requires the construction of a temporary,
14642 and a copy from the temporary to the target of the assignment.  This is because
14643 it is not always possible to convert the assignment into a series of individual
14644 component assignments.  For example, consider the simple case:
14645
14646 @smallexample @c ada
14647         A := (A(2), A(1));
14648 @end smallexample
14649
14650 @noindent
14651 This cannot be converted into:
14652
14653 @smallexample @c ada
14654         A(1) := A(2);
14655         A(2) := A(1);
14656 @end smallexample
14657
14658 @noindent
14659 So the aggregate has to be built first in a separate location, and then
14660 copied into the target.  GNAT recognizes simple cases where this intermediate
14661 step is not required, and the assignments can be performed in place, directly
14662 into the target.  The following sufficient criteria are applied:
14663
14664 @itemize @bullet
14665 @item
14666 The bounds of the aggregate are static, and the associations are static.
14667 @item
14668 The components of the aggregate are static constants, names of
14669 simple variables that are not renamings, or expressions not involving
14670 indexed components whose operands obey these rules.
14671 @end itemize
14672
14673 @noindent
14674 If any of these conditions are violated, the aggregate will be built in
14675 a temporary (created either by the front-end or the code generator) and then
14676 that temporary will be copied onto the target.
14677
14678
14679 @node The Size of Discriminated Records with Default Discriminants
14680 @section The Size of Discriminated Records with Default Discriminants
14681
14682 @noindent
14683 If a discriminated type @code{T} has discriminants with default values, it is
14684 possible to declare an object of this type without providing an explicit
14685 constraint:
14686
14687 @smallexample @c ada
14688 @group
14689 type Size is range 1..100;
14690
14691 type Rec (D : Size := 15) is record
14692    Name : String (1..D);
14693 end T;
14694
14695 Word : Rec;
14696 @end group
14697 @end smallexample
14698
14699 @noindent
14700 Such an object is said to be @emph{unconstrained}.
14701 The discriminant of the object
14702 can be modified by a full assignment to the object, as long as it preserves the
14703 relation between the value of the discriminant, and the value of the components
14704 that depend on it:
14705
14706 @smallexample @c ada
14707 @group
14708 Word := (3, "yes");
14709
14710 Word := (5, "maybe");
14711
14712 Word := (5, "no"); -- raises Constraint_Error
14713 @end group
14714 @end smallexample
14715
14716 @noindent
14717 In order to support this behavior efficiently, an unconstrained object is
14718 given the maximum size that any value of the type requires. In the case
14719 above, @code{Word} has storage for the discriminant and for
14720 a @code{String} of length 100.
14721 It is important to note that unconstrained objects do not require dynamic
14722 allocation. It would be an improper implementation to place on the heap those
14723 components whose size depends on discriminants. (This improper implementation
14724 was used by some Ada83 compilers, where the @code{Name} component above
14725 would have
14726 been stored as a pointer to a dynamic string). Following the principle that
14727 dynamic storage management should never be introduced implicitly,
14728 an Ada compiler should reserve the full size for an unconstrained declared
14729 object, and place it on the stack.
14730
14731 This maximum size approach
14732 has been a source of surprise to some users, who expect the default
14733 values of the discriminants to determine the size reserved for an
14734 unconstrained object: ``If the default is 15, why should the object occupy
14735 a larger size?''
14736 The answer, of course, is that the discriminant may be later modified,
14737 and its full range of values must be taken into account. This is why the
14738 declaration:
14739
14740 @smallexample
14741 @group
14742 type Rec (D : Positive := 15) is record
14743    Name : String (1..D);
14744 end record;
14745
14746 Too_Large : Rec;
14747 @end group
14748 @end smallexample
14749
14750 @noindent
14751 is flagged by the compiler with a warning:
14752 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14753 because the required size includes @code{Positive'Last}
14754 bytes. As the first example indicates, the proper approach is to declare an
14755 index type of ``reasonable'' range so that unconstrained objects are not too
14756 large.
14757
14758 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14759 created in the heap by means of an allocator, then it is @emph{not}
14760 unconstrained:
14761 it is constrained by the default values of the discriminants, and those values
14762 cannot be modified by full assignment. This is because in the presence of
14763 aliasing all views of the object (which may be manipulated by different tasks,
14764 say) must be consistent, so it is imperative that the object, once created,
14765 remain invariant.
14766
14767 @node Strict Conformance to the Ada Reference Manual
14768 @section Strict Conformance to the Ada Reference Manual
14769
14770 @noindent
14771 The dynamic semantics defined by the Ada Reference Manual impose a set of
14772 run-time checks to be generated. By default, the GNAT compiler will insert many
14773 run-time checks into the compiled code, including most of those required by the
14774 Ada Reference Manual. However, there are three checks that are not enabled
14775 in the default mode for efficiency reasons: arithmetic overflow checking for
14776 integer operations (including division by zero), checks for access before
14777 elaboration on subprogram calls, and stack overflow checking (most operating
14778 systems do not perform this check by default).
14779
14780 Strict conformance to the Ada Reference Manual can be achieved by adding
14781 three compiler options for overflow checking for integer operations
14782 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14783 calls and generic instantiations (@option{-gnatE}), and stack overflow
14784 checking (@option{-fstack-check}).
14785
14786 Note that the result of a floating point arithmetic operation in overflow and
14787 invalid situations, when the @code{Machine_Overflows} attribute of the result
14788 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14789 case for machines compliant with the IEEE floating-point standard, but on
14790 machines that are not fully compliant with this standard, such as Alpha, the
14791 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14792 behavior (although at the cost of a significant performance penalty), so
14793 infinite and and NaN values are properly generated.
14794
14795
14796 @node Project File Reference
14797 @chapter Project File Reference
14798
14799 @noindent
14800 This chapter describes the syntax and semantics of project files.
14801 Project files specify the options to be used when building a system.
14802 Project files can specify global settings for all tools,
14803 as well as tool-specific settings.
14804 See the chapter on project files in the GNAT Users guide for examples of use.
14805
14806 @menu
14807 * Reserved Words::
14808 * Lexical Elements::
14809 * Declarations::
14810 * Empty declarations::
14811 * Typed string declarations::
14812 * Variables::
14813 * Expressions::
14814 * Attributes::
14815 * Project Attributes::
14816 * Attribute References::
14817 * External Values::
14818 * Case Construction::
14819 * Packages::
14820 * Package Renamings::
14821 * Projects::
14822 * Project Extensions::
14823 * Project File Elaboration::
14824 @end menu
14825
14826 @node Reserved Words
14827 @section Reserved Words
14828
14829 @noindent
14830 All Ada reserved words are reserved in project files, and cannot be used
14831 as variable names or project names. In addition, the following are
14832 also reserved in project files:
14833
14834 @itemize
14835 @item @code{extends}
14836
14837 @item @code{external}
14838
14839 @item @code{project}
14840
14841 @end itemize
14842
14843 @node Lexical Elements
14844 @section Lexical Elements
14845
14846 @noindent
14847 Rules for identifiers are the same as in Ada. Identifiers
14848 are case-insensitive.  Strings are case sensitive, except where noted.
14849 Comments have the same form as in Ada.
14850
14851 @noindent
14852 Syntax:
14853
14854 @smallexample
14855 simple_name ::=
14856   identifier
14857
14858 name ::=
14859   simple_name @{. simple_name@}
14860 @end smallexample
14861
14862 @node Declarations
14863 @section Declarations
14864
14865 @noindent
14866 Declarations introduce new entities that denote types, variables, attributes,
14867 and packages. Some declarations can only appear immediately within a project
14868 declaration. Others can appear within a project or within a package.
14869
14870 Syntax:
14871 @smallexample
14872 declarative_item ::=
14873   simple_declarative_item |
14874   typed_string_declaration |
14875   package_declaration
14876
14877 simple_declarative_item ::=
14878   variable_declaration |
14879   typed_variable_declaration |
14880   attribute_declaration |
14881   case_construction |
14882   empty_declaration
14883 @end smallexample
14884
14885 @node Empty declarations
14886 @section Empty declarations
14887
14888 @smallexample
14889 empty_declaration ::=
14890   @b{null} ;
14891 @end smallexample
14892
14893 An empty declaration is allowed anywhere a declaration is allowed.
14894 It has no effect.
14895
14896 @node Typed string declarations
14897 @section Typed string declarations
14898
14899 @noindent
14900 Typed strings are sequences of string literals. Typed strings are the only
14901 named types in project files. They are used in case constructions, where they
14902 provide support for conditional attribute definitions.
14903
14904 Syntax:
14905 @smallexample
14906 typed_string_declaration ::=
14907   @b{type} <typed_string_>_simple_name @b{is}
14908    ( string_literal @{, string_literal@} );
14909 @end smallexample
14910
14911 @noindent
14912 A typed string declaration can only appear immediately within a project
14913 declaration.
14914
14915 All the string literals in a typed string declaration must be distinct.
14916
14917 @node Variables
14918 @section Variables
14919
14920 @noindent
14921 Variables denote values, and appear as constituents of expressions.
14922
14923 @smallexample
14924 typed_variable_declaration ::=
14925   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14926
14927 variable_declaration ::=
14928   <variable_>simple_name := expression;
14929 @end smallexample
14930
14931 @noindent
14932 The elaboration of a variable declaration introduces the variable and
14933 assigns to it the value of the expression. The name of the variable is
14934 available after the assignment symbol.
14935
14936 @noindent
14937 A typed_variable can only be declare once.
14938
14939 @noindent
14940 a non typed variable can be declared multiple times.
14941
14942 @noindent
14943 Before the completion of its first declaration, the value of variable
14944 is the null string.
14945
14946 @node Expressions
14947 @section Expressions
14948
14949 @noindent
14950 An expression is a formula that defines a computation or retrieval of a value.
14951 In a project file the value of an expression is either a string or a list
14952 of strings. A string value in an expression is either a literal, the current
14953 value of a variable, an external value, an attribute reference, or a
14954 concatenation operation.
14955
14956 Syntax:
14957
14958 @smallexample
14959 expression ::=
14960   term @{& term@}
14961
14962 term ::=
14963   string_literal |
14964   string_list |
14965   <variable_>name |
14966   external_value |
14967   attribute_reference
14968
14969 string_literal ::=
14970   (same as Ada)
14971
14972 string_list ::=
14973   ( <string_>expression @{ , <string_>expression @} )
14974 @end smallexample
14975
14976 @subsection Concatenation
14977 @noindent
14978 The following concatenation functions are defined:
14979
14980 @smallexample @c ada
14981   function "&" (X : String;      Y : String)      return String;
14982   function "&" (X : String_List; Y : String)      return String_List;
14983   function "&" (X : String_List; Y : String_List) return String_List;
14984 @end smallexample
14985
14986 @node Attributes
14987 @section Attributes
14988
14989 @noindent
14990 An attribute declaration defines a property of a project or package. This
14991 property can later be queried by means of an attribute reference.
14992 Attribute values are strings or string lists.
14993
14994 Some attributes are associative arrays. These attributes are mappings whose
14995 domain is a set of strings. These attributes are declared one association
14996 at a time, by specifying a point in the domain and the corresponding image
14997 of the attribute. They may also be declared as a full associative array,
14998 getting the same associations as the corresponding attribute in an imported
14999 or extended project.
15000
15001 Attributes that are not associative arrays are called simple attributes.
15002
15003 Syntax:
15004 @smallexample
15005 attribute_declaration ::=
15006   full_associative_array_declaration |
15007   @b{for} attribute_designator @b{use} expression ;
15008
15009 full_associative_array_declaration ::=
15010   @b{for} <associative_array_attribute_>simple_name @b{use}
15011   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15012
15013 attribute_designator ::=
15014   <simple_attribute_>simple_name |
15015   <associative_array_attribute_>simple_name ( string_literal )
15016 @end smallexample
15017
15018 @noindent
15019 Some attributes are project-specific, and can only appear immediately within
15020 a project declaration. Others are package-specific, and can only appear within
15021 the proper package.
15022
15023 The expression in an attribute definition must be a string or a string_list.
15024 The string literal appearing in the attribute_designator of an associative
15025 array attribute is case-insensitive.
15026
15027 @node Project Attributes
15028 @section Project Attributes
15029
15030 @noindent
15031 The following attributes apply to a project. All of them are simple
15032 attributes.
15033
15034 @table @code
15035 @item   Object_Dir
15036 Expression must be a path name. The attribute defines the
15037 directory in which the object files created by the build are to be placed. If
15038 not specified, object files are placed in the project directory.
15039
15040 @item   Exec_Dir
15041 Expression must be a path name. The attribute defines the
15042 directory in which the executables created by the build are to be placed.
15043 If not specified, executables are placed in the object directory.
15044
15045 @item  Source_Dirs
15046 Expression must be a list of path names. The attribute
15047 defines the directories in which the source files for the project are to be
15048 found. If not specified, source files are found in the project directory.
15049 If a string in the list ends with "/**", then the directory that precedes
15050 "/**" and all of its subdirectories (recursively) are included in the list
15051 of source directories.
15052
15053 @item  Excluded_Source_Dirs
15054 Expression must be a list of strings. Each entry designates a directory that
15055 is not to be included in the list of source directories of the project.
15056 This is normally used when there are strings ending with "/**" in the value
15057 of attribute Source_Dirs.
15058
15059 @item  Source_Files
15060 Expression must be a list of file names. The attribute
15061 defines the individual files, in the project directory, which are to be used
15062 as sources for the project. File names are path_names that contain no directory
15063 information. If the project has no sources the attribute must be declared
15064 explicitly with an empty list.
15065
15066 @item  Excluded_Source_Files (Locally_Removed_Files)
15067 Expression must be a list of strings that are legal file names.
15068 Each file name must designate a source that would normally be a source file
15069 in the source directories of the project or, if the project file is an
15070 extending project file, inherited by the current project file. It cannot
15071 designate an immediate source that is not inherited. Each of the source files
15072 in the list are not considered to be sources of the project file: they are not
15073 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15074 Excluded_Source_Files is preferred.
15075
15076 @item  Source_List_File
15077 Expression must a single path name. The attribute
15078 defines a text file that contains a list of source file names to be used
15079 as sources for the project
15080
15081 @item  Library_Dir
15082 Expression must be a path name. The attribute defines the
15083 directory in which a  library is to be built.  The directory must exist, must
15084 be distinct from the project's object directory, and must be writable.
15085
15086 @item  Library_Name
15087 Expression must be a string that is a legal file name,
15088 without extension. The attribute defines a string that is used to generate
15089 the name of the library to be built by the project.
15090
15091 @item  Library_Kind
15092 Argument must be a string value that must be one of the
15093 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15094 string is case-insensitive. If this attribute is not specified, the library is
15095 a static library. Otherwise, the library may be dynamic or relocatable. This
15096 distinction is operating-system dependent.
15097
15098 @item  Library_Version
15099 Expression must be a string value whose interpretation
15100 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15101 libraries as the internal name of the library (the @code{"soname"}). If the
15102 library file name (built from the @code{Library_Name}) is different from the
15103 @code{Library_Version}, then the library file will be a symbolic link to the
15104 actual file whose name will be @code{Library_Version}.
15105
15106 @item Library_Interface
15107 Expression must be a string list. Each element of the string list
15108 must designate a unit of the project.
15109 If this attribute is present in a Library Project File, then the project
15110 file is a Stand-alone Library_Project_File.
15111
15112 @item Library_Auto_Init
15113 Expression must be a single string "true" or "false", case-insensitive.
15114 If this attribute is present in a Stand-alone Library Project File,
15115 it indicates if initialization is automatic when the dynamic library
15116 is loaded.
15117
15118 @item Library_Options
15119 Expression must be a string list. Indicates additional switches that
15120 are to be used when building a shared library.
15121
15122 @item Library_GCC
15123 Expression must be a single string. Designates an alternative to "gcc"
15124 for building shared libraries.
15125
15126 @item  Library_Src_Dir
15127 Expression must be a path name. The attribute defines the
15128 directory in which the sources of the interfaces of a Stand-alone Library will
15129 be copied.  The directory must exist, must be distinct from the project's
15130 object directory and source directories of all projects in the project tree,
15131 and must be writable.
15132
15133 @item  Library_Src_Dir
15134 Expression must be a path name. The attribute defines the
15135 directory in which the ALI files of a Library will
15136 be copied.  The directory must exist, must be distinct from the project's
15137 object directory and source directories of all projects in the project tree,
15138 and must be writable.
15139
15140 @item  Library_Symbol_File
15141 Expression must be a single string. Its value is the single file name of a
15142 symbol file to be created when building a stand-alone library when the
15143 symbol policy is either "compliant", "controlled" or "restricted",
15144 on platforms that support symbol control, such as VMS. When symbol policy
15145 is "direct", then a file with this name must exist in the object directory.
15146
15147 @item   Library_Reference_Symbol_File
15148 Expression must be a single string. Its value is the path name of a
15149 reference symbol file that is read when the symbol policy is either
15150 "compliant" or "controlled", on platforms that support symbol control,
15151 such as VMS, when building a stand-alone library. The path may be an absolute
15152 path or a path relative to the project directory.
15153
15154 @item  Library_Symbol_Policy
15155 Expression must be a single string. Its case-insensitive value can only be
15156 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15157
15158 This attribute is not taken into account on all platforms. It controls the
15159 policy for exported symbols and, on some platforms (like VMS) that have the
15160 notions of major and minor IDs built in the library files, it controls
15161 the setting of these IDs.
15162
15163 "autonomous" or "default": exported symbols are not controlled.
15164
15165 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15166 it is equivalent to policy "autonomous". If there are exported symbols in
15167 the reference symbol file that are not in the object files of the interfaces,
15168 the major ID of the library is increased. If there are symbols in the
15169 object files of the interfaces that are not in the reference symbol file,
15170 these symbols are put at the end of the list in the newly created symbol file
15171 and the minor ID is increased.
15172
15173 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15174 The library will fail to build if the exported symbols in the object files of
15175 the interfaces do not match exactly the symbol in the symbol file.
15176
15177 "restricted": The attribute Library_Symbol_File must be defined. The library
15178 will fail to build if there are symbols in the symbol file that are not in
15179 the exported symbols of the object files of the interfaces. Additional symbols
15180 in the object files are not added to the symbol file.
15181
15182 "direct": The attribute Library_Symbol_File must be defined and must designate
15183 an existing file in the object directory. This symbol file is passed directly
15184 to the underlying linker without any symbol processing.
15185
15186 @item  Main
15187 Expression must be a list of strings that are legal file names.
15188 These file names designate existing compilation units in the source directory
15189 that are legal main subprograms.
15190
15191 When a project file is elaborated, as part of the execution of a gnatmake
15192 command, one or several executables are built and placed in the Exec_Dir.
15193 If the gnatmake command does not include explicit file names, the executables
15194 that are built correspond to the files specified by this attribute.
15195
15196 @item  Externally_Built
15197 Expression must be a single string. Its value must be either "true" of "false",
15198 case-insensitive. The default is "false". When the value of this attribute is
15199 "true", no attempt is made to compile the sources or to build the library,
15200 when the project is a library project.
15201
15202 @item Main_Language
15203 This is a simple attribute. Its value is a string that specifies the
15204 language of the main program.
15205
15206 @item  Languages
15207 Expression must be a string list. Each string designates
15208 a programming language that is known to GNAT. The strings are case-insensitive.
15209
15210 @end table
15211
15212 @node Attribute References
15213 @section Attribute References
15214
15215 @noindent
15216 Attribute references are used to retrieve the value of previously defined
15217 attribute for a package or project.
15218 Syntax:
15219 @smallexample
15220 attribute_reference ::=
15221   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15222
15223 attribute_prefix ::=
15224   @b{project} |
15225   <project_simple_name | package_identifier |
15226   <project_>simple_name . package_identifier
15227 @end smallexample
15228
15229 @noindent
15230 If an attribute has not been specified for a given package or project, its
15231 value is the null string or the empty list.
15232
15233 @node External Values
15234 @section External Values
15235
15236 @noindent
15237 An external value is an expression whose value is obtained from the command
15238 that invoked the processing of the current project file (typically a
15239 gnatmake command).
15240
15241 Syntax:
15242 @smallexample
15243 external_value ::=
15244   @b{external} ( string_literal [, string_literal] )
15245 @end smallexample
15246
15247 @noindent
15248 The first string_literal is the string to be used on the command line or
15249 in the environment to specify the external value. The second string_literal,
15250 if present, is the default to use if there is no specification for this
15251 external value either on the command line or in the environment.
15252
15253 @node Case Construction
15254 @section Case Construction
15255
15256 @noindent
15257 A case construction supports attribute and variable declarations that depend
15258 on the value of a previously declared variable.
15259
15260 Syntax:
15261 @smallexample
15262 case_construction ::=
15263   @b{case} <typed_variable_>name @b{is}
15264     @{case_item@}
15265   @b{end case} ;
15266
15267 case_item ::=
15268   @b{when} discrete_choice_list =>
15269     @{case_construction |
15270       attribute_declaration |
15271       variable_declaration |
15272       empty_declaration@}
15273
15274 discrete_choice_list ::=
15275   string_literal @{| string_literal@} |
15276     @b{others}
15277 @end smallexample
15278
15279 @noindent
15280 Inside a case construction, variable declarations must be for variables that
15281 have already been declared before the case construction.
15282
15283 All choices in a choice list must be distinct. The choice lists of two
15284 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15285 alternatives do not need to include all values of the type. An @code{others}
15286 choice must appear last in the list of alternatives.
15287
15288 @node Packages
15289 @section Packages
15290
15291 @noindent
15292 A package provides a grouping of variable declarations and attribute
15293 declarations to be used when invoking various GNAT tools. The name of
15294 the package indicates the tool(s) to which it applies.
15295 Syntax:
15296
15297 @smallexample
15298 package_declaration ::=
15299   package_specification | package_renaming
15300
15301 package_specification ::=
15302   @b{package} package_identifier @b{is}
15303     @{simple_declarative_item@}
15304   @b{end} package_identifier ;
15305
15306 package_identifier ::=
15307   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15308   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15309   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15310 @end smallexample
15311
15312 @subsection Package Naming
15313
15314 @noindent
15315 The attributes of a @code{Naming} package specifies the naming conventions
15316 that apply to the source files in a project. When invoking other GNAT tools,
15317 they will use the sources in the source directories that satisfy these
15318 naming conventions.
15319
15320 The following attributes apply to a @code{Naming} package:
15321
15322 @table @code
15323 @item Casing
15324 This is a simple attribute whose value is a string. Legal values of this
15325 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15326 These strings are themselves case insensitive.
15327
15328 @noindent
15329 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15330
15331 @item Dot_Replacement
15332 This is a simple attribute whose string value satisfies the following
15333 requirements:
15334
15335 @itemize @bullet
15336 @item It must not be empty
15337 @item It cannot start or end with an alphanumeric character
15338 @item It cannot be a single underscore
15339 @item It cannot start with an underscore followed by an alphanumeric
15340 @item It cannot contain a dot @code{'.'} if longer than one character
15341 @end itemize
15342
15343 @noindent
15344 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15345
15346 @item Spec_Suffix
15347 This is an associative array attribute, defined on language names,
15348 whose image is a string that must satisfy the following
15349 conditions:
15350
15351 @itemize @bullet
15352 @item It must not be empty
15353 @item It cannot start with an alphanumeric character
15354 @item It cannot start with an underscore followed by an alphanumeric character
15355 @end itemize
15356
15357 @noindent
15358 For Ada, the attribute denotes the suffix used in file names that contain
15359 library unit declarations, that is to say units that are package and
15360 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15361 specified, then the default is @code{".ads"}.
15362
15363 For C and C++, the attribute denotes the suffix used in file names that
15364 contain prototypes.
15365
15366 @item Body_Suffix
15367 This is an associative array attribute defined on language names,
15368 whose image is a string that must satisfy the following
15369 conditions:
15370
15371 @itemize @bullet
15372 @item It must not be empty
15373 @item It cannot start with an alphanumeric character
15374 @item It cannot start with an underscore followed by an alphanumeric character
15375 @item It cannot be a suffix of @code{Spec_Suffix}
15376 @end itemize
15377
15378 @noindent
15379 For Ada, the attribute denotes the suffix used in file names that contain
15380 library bodies, that is to say units that are package and subprogram bodies.
15381 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15382 @code{".adb"}.
15383
15384 For C and C++, the attribute denotes the suffix used in file names that contain
15385 source code.
15386
15387 @item Separate_Suffix
15388 This is a simple attribute whose value satisfies the same conditions as
15389 @code{Body_Suffix}.
15390
15391 This attribute is specific to Ada. It denotes the suffix used in file names
15392 that contain separate bodies. If it is not specified, then it defaults to same
15393 value as @code{Body_Suffix ("Ada")}.
15394
15395 @item Spec
15396 This is an associative array attribute, specific to Ada, defined over
15397 compilation unit names. The image is a string that is the name of the file
15398 that contains that library unit. The file name is case sensitive if the
15399 conventions of the host operating system require it.
15400
15401 @item Body
15402 This is an associative array attribute, specific to Ada, defined over
15403 compilation unit names. The image is a string that is the name of the file
15404 that contains the library unit body for the named unit. The file name is case
15405 sensitive if the conventions of the host operating system require it.
15406
15407 @item Specification_Exceptions
15408 This is an associative array attribute defined on language names,
15409 whose value is a list of strings.
15410
15411 This attribute is not significant for Ada.
15412
15413 For C and C++, each string in the list denotes the name of a file that
15414 contains prototypes, but whose suffix is not necessarily the
15415 @code{Spec_Suffix} for the language.
15416
15417 @item Implementation_Exceptions
15418 This is an associative array attribute defined on language names,
15419 whose value is a list of strings.
15420
15421 This attribute is not significant for Ada.
15422
15423 For C and C++, each string in the list denotes the name of a file that
15424 contains source code, but whose suffix is not necessarily the
15425 @code{Body_Suffix} for the language.
15426 @end table
15427
15428 The following attributes of package @code{Naming} are obsolescent. They are
15429 kept as synonyms of other attributes for compatibility with previous versions
15430 of the Project Manager.
15431
15432 @table @code
15433 @item Specification_Suffix
15434 This is a synonym of @code{Spec_Suffix}.
15435
15436 @item Implementation_Suffix
15437 This is a synonym of @code{Body_Suffix}.
15438
15439 @item Specification
15440 This is a synonym of @code{Spec}.
15441
15442 @item Implementation
15443 This is a synonym of @code{Body}.
15444 @end table
15445
15446 @subsection package Compiler
15447
15448 @noindent
15449 The attributes of the @code{Compiler} package specify the compilation options
15450 to be used by the underlying compiler.
15451
15452 @table @code
15453 @item  Default_Switches
15454 This is an associative array attribute. Its
15455 domain is a set of language names. Its range is a string list that
15456 specifies the compilation options to be used when compiling a component
15457 written in that language, for which no file-specific switches have been
15458 specified.
15459
15460 @item  Switches
15461 This is an associative array attribute. Its domain is
15462 a set of file names. Its range is a string list that specifies the
15463 compilation options to be used when compiling the named file. If a file
15464 is not specified in the Switches attribute, it is compiled with the
15465 options specified by Default_Switches of its language, if defined.
15466
15467 @item  Local_Configuration_Pragmas.
15468 This is a simple attribute, whose
15469 value is a path name that designates a file containing configuration pragmas
15470 to be used for all invocations of the compiler for immediate sources of the
15471 project.
15472 @end table
15473
15474 @subsection package Builder
15475
15476 @noindent
15477 The attributes of package @code{Builder} specify the compilation, binding, and
15478 linking options to be used when building an executable for a project. The
15479 following attributes apply to package @code{Builder}:
15480
15481 @table @code
15482 @item Default_Switches
15483 This is an associative array attribute. Its
15484 domain is a set of language names. Its range is a string list that
15485 specifies options to be used when building a main
15486 written in that language, for which no file-specific switches have been
15487 specified.
15488
15489 @item Switches
15490 This is an associative array attribute. Its domain is
15491 a set of file names. Its range is a string list that specifies
15492 options to be used when building the named main file. If a main file
15493 is not specified in the Switches attribute, it is built with the
15494 options specified by Default_Switches of its language, if defined.
15495
15496 @item Global_Configuration_Pragmas
15497 This is a simple attribute, whose
15498 value is a path name that designates a file that contains configuration pragmas
15499 to be used in every build of an executable. If both local and global
15500 configuration pragmas are specified, a compilation makes use of both sets.
15501
15502
15503 @item Executable
15504 This is an associative array attribute. Its domain is
15505 a set of main source file names. Its range is a simple string that specifies
15506 the executable file name to be used when linking the specified main source.
15507 If a main source is not specified in the Executable attribute, the executable
15508 file name is deducted from the main source file name.
15509 This attribute has no effect if its value is the empty string.
15510
15511 @item Executable_Suffix
15512 This is a simple attribute whose value is the suffix to be added to
15513 the executables that don't have an attribute Executable specified.
15514 @end table
15515
15516 @subsection package Gnatls
15517
15518 @noindent
15519 The attributes of package @code{Gnatls} specify the tool options to be used
15520 when invoking the library browser @command{gnatls}.
15521 The following attributes apply to package @code{Gnatls}:
15522
15523 @table @code
15524 @item Switches
15525 This is a single attribute with a string list value. Each non empty string
15526 in the list is an option when invoking @code{gnatls}.
15527 @end table
15528
15529 @subsection package Binder
15530
15531 @noindent
15532 The attributes of package @code{Binder} specify the options to be used
15533 when invoking the binder in the construction of an executable.
15534 The following attributes apply to package @code{Binder}:
15535
15536 @table @code
15537 @item     Default_Switches
15538 This is an associative array attribute. Its
15539 domain is a set of language names. Its range is a string list that
15540 specifies options to be used when binding a main
15541 written in that language, for which no file-specific switches have been
15542 specified.
15543
15544 @item Switches
15545 This is an associative array attribute. Its domain is
15546 a set of file names. Its range is a string list that specifies
15547 options to be used when binding the named main file. If a main file
15548 is not specified in the Switches attribute, it is bound with the
15549 options specified by Default_Switches of its language, if defined.
15550 @end table
15551
15552 @subsection package Linker
15553
15554 @noindent
15555 The attributes of package @code{Linker} specify the options to be used when
15556 invoking the linker in the construction of an executable.
15557 The following attributes apply to package @code{Linker}:
15558
15559 @table @code
15560 @item     Default_Switches
15561 This is an associative array attribute. Its
15562 domain is a set of language names. Its range is a string list that
15563 specifies options to be used when linking a main
15564 written in that language, for which no file-specific switches have been
15565 specified.
15566
15567 @item Switches
15568 This is an associative array attribute. Its domain is
15569 a set of file names. Its range is a string list that specifies
15570 options to be used when linking the named main file. If a main file
15571 is not specified in the Switches attribute, it is linked with the
15572 options specified by Default_Switches of its language, if defined.
15573
15574 @item  Linker_Options
15575 This is a string list attribute. Its value specifies additional options that
15576 be given to the linker when linking an executable. This attribute is not
15577 used in the main project, only in projects imported directly or indirectly.
15578
15579 @end table
15580
15581 @subsection package Cross_Reference
15582
15583 @noindent
15584 The attributes of package @code{Cross_Reference} specify the tool options
15585 to be used
15586 when invoking the library tool @command{gnatxref}.
15587 The following attributes apply to package @code{Cross_Reference}:
15588
15589 @table @code
15590 @item     Default_Switches
15591 This is an associative array attribute. Its
15592 domain is a set of language names. Its range is a string list that
15593 specifies options to be used when calling @command{gnatxref} on a source
15594 written in that language, for which no file-specific switches have been
15595 specified.
15596
15597 @item Switches
15598 This is an associative array attribute. Its domain is
15599 a set of file names. Its range is a string list that specifies
15600 options to be used when calling @command{gnatxref} on the named main source.
15601 If a source is not specified in the Switches attribute, @command{gnatxref} will
15602 be called with the options specified by Default_Switches of its language,
15603 if defined.
15604 @end table
15605
15606 @subsection package   Finder
15607
15608 @noindent
15609 The attributes of package @code{Finder} specify the tool options to be used
15610 when invoking the search tool @command{gnatfind}.
15611 The following attributes apply to package @code{Finder}:
15612
15613 @table @code
15614 @item     Default_Switches
15615 This is an associative array attribute. Its
15616 domain is a set of language names. Its range is a string list that
15617 specifies options to be used when calling @command{gnatfind} on a source
15618 written in that language, for which no file-specific switches have been
15619 specified.
15620
15621 @item Switches
15622 This is an associative array attribute. Its domain is
15623 a set of file names. Its range is a string list that specifies
15624 options to be used when calling @command{gnatfind} on the named main source.
15625 If a source is not specified in the Switches attribute, @command{gnatfind} will
15626 be called with the options specified by Default_Switches of its language,
15627 if defined.
15628 @end table
15629
15630 @subsection package Pretty_Printer
15631
15632 @noindent
15633 The attributes of package @code{Pretty_Printer}
15634 specify the tool options to be used
15635 when invoking the formatting tool @command{gnatpp}.
15636 The following attributes apply to package @code{Pretty_Printer}:
15637
15638 @table @code
15639 @item     Default_switches
15640 This is an associative array attribute. Its
15641 domain is a set of language names. Its range is a string list that
15642 specifies options to be used when calling @command{gnatpp} on a source
15643 written in that language, for which no file-specific switches have been
15644 specified.
15645
15646 @item Switches
15647 This is an associative array attribute. Its domain is
15648 a set of file names. Its range is a string list that specifies
15649 options to be used when calling @command{gnatpp} on the named main source.
15650 If a source is not specified in the Switches attribute, @command{gnatpp} will
15651 be called with the options specified by Default_Switches of its language,
15652 if defined.
15653 @end table
15654
15655 @subsection package gnatstub
15656
15657 @noindent
15658 The attributes of package @code{gnatstub}
15659 specify the tool options to be used
15660 when invoking the tool @command{gnatstub}.
15661 The following attributes apply to package @code{gnatstub}:
15662
15663 @table @code
15664 @item     Default_switches
15665 This is an associative array attribute. Its
15666 domain is a set of language names. Its range is a string list that
15667 specifies options to be used when calling @command{gnatstub} on a source
15668 written in that language, for which no file-specific switches have been
15669 specified.
15670
15671 @item Switches
15672 This is an associative array attribute. Its domain is
15673 a set of file names. Its range is a string list that specifies
15674 options to be used when calling @command{gnatstub} on the named main source.
15675 If a source is not specified in the Switches attribute, @command{gnatpp} will
15676 be called with the options specified by Default_Switches of its language,
15677 if defined.
15678 @end table
15679
15680 @subsection package Eliminate
15681
15682 @noindent
15683 The attributes of package @code{Eliminate}
15684 specify the tool options to be used
15685 when invoking the tool @command{gnatelim}.
15686 The following attributes apply to package @code{Eliminate}:
15687
15688 @table @code
15689 @item     Default_switches
15690 This is an associative array attribute. Its
15691 domain is a set of language names. Its range is a string list that
15692 specifies options to be used when calling @command{gnatelim} on a source
15693 written in that language, for which no file-specific switches have been
15694 specified.
15695
15696 @item Switches
15697 This is an associative array attribute. Its domain is
15698 a set of file names. Its range is a string list that specifies
15699 options to be used when calling @command{gnatelim} on the named main source.
15700 If a source is not specified in the Switches attribute, @command{gnatelim} will
15701 be called with the options specified by Default_Switches of its language,
15702 if defined.
15703 @end table
15704
15705 @subsection package Metrics
15706
15707 @noindent
15708 The attributes of package @code{Metrics}
15709 specify the tool options to be used
15710 when invoking the tool @command{gnatmetric}.
15711 The following attributes apply to package @code{Metrics}:
15712
15713 @table @code
15714 @item     Default_switches
15715 This is an associative array attribute. Its
15716 domain is a set of language names. Its range is a string list that
15717 specifies options to be used when calling @command{gnatmetric} on a source
15718 written in that language, for which no file-specific switches have been
15719 specified.
15720
15721 @item Switches
15722 This is an associative array attribute. Its domain is
15723 a set of file names. Its range is a string list that specifies
15724 options to be used when calling @command{gnatmetric} on the named main source.
15725 If a source is not specified in the Switches attribute, @command{gnatmetric}
15726 will be called with the options specified by Default_Switches of its language,
15727 if defined.
15728 @end table
15729
15730 @subsection  package IDE
15731
15732 @noindent
15733 The attributes of package @code{IDE} specify the options to be used when using
15734 an Integrated Development Environment such as @command{GPS}.
15735
15736 @table @code
15737 @item Remote_Host
15738 This is a simple attribute. Its value is a string that designates the remote
15739 host in a cross-compilation environment, to be used for remote compilation and
15740 debugging. This field should not be specified when running on the local
15741 machine.
15742
15743 @item Program_Host
15744 This is a simple attribute. Its value is a string that specifies the
15745 name of IP address of the embedded target in a cross-compilation environment,
15746 on which the program should execute.
15747
15748 @item Communication_Protocol
15749 This is a simple string attribute. Its value is the name of the protocol
15750 to use to communicate with the target in a cross-compilation environment,
15751 e.g. @code{"wtx"} or @code{"vxworks"}.
15752
15753 @item Compiler_Command
15754 This is an associative array attribute, whose domain is a language name. Its
15755 value is  string that denotes the command to be used to invoke the compiler.
15756 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15757 gnatmake, in particular in the handling of switches.
15758
15759 @item Debugger_Command
15760 This is simple attribute, Its value is a string that specifies the name of
15761 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15762
15763 @item Default_Switches
15764 This is an associative array attribute. Its indexes are the name of the
15765 external tools that the GNAT Programming System (GPS) is supporting. Its
15766 value is a list of switches to use when invoking that tool.
15767
15768 @item  Gnatlist
15769 This is a simple attribute.  Its value is a string that specifies the name
15770 of the @command{gnatls} utility to be used to retrieve information about the
15771 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15772
15773 @item VCS_Kind
15774 This is a simple attribute. Its value is a string used to specify the
15775 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15776 ClearCase or Perforce.
15777
15778 @item VCS_File_Check
15779 This is a simple attribute. Its value is a string that specifies the
15780 command used by the VCS to check the validity of a file, either
15781 when the user explicitly asks for a check, or as a sanity check before
15782 doing the check-in.
15783
15784 @item VCS_Log_Check
15785 This is a simple attribute. Its value is a string that specifies
15786 the command used by the VCS to check the validity of a log file.
15787
15788 @item VCS_Repository_Root
15789 The VCS repository root path. This is used to create tags or branches
15790 of the repository. For subversion the value should be the @code{URL}
15791 as specified to check-out the working copy of the repository.
15792
15793 @item VCS_Patch_Root
15794 The local root directory to use for building patch file. All patch chunks
15795 will be relative to this path. The root project directory is used if
15796 this value is not defined.
15797
15798 @end table
15799
15800 @node Package Renamings
15801 @section Package Renamings
15802
15803 @noindent
15804 A package can be defined by a renaming declaration. The new package renames
15805 a package declared in a different project file, and has the same attributes
15806 as the package it renames.
15807 Syntax:
15808 @smallexample
15809 package_renaming ::==
15810   @b{package} package_identifier @b{renames}
15811        <project_>simple_name.package_identifier ;
15812 @end smallexample
15813
15814 @noindent
15815 The package_identifier of the renamed package must be the same as the
15816 package_identifier. The project whose name is the prefix of the renamed
15817 package must contain a package declaration with this name. This project
15818 must appear in the context_clause of the enclosing project declaration,
15819 or be the parent project of the enclosing child project.
15820
15821 @node Projects
15822 @section Projects
15823
15824 @noindent
15825 A project file specifies a set of rules for constructing a software system.
15826 A project file can be self-contained, or depend on other project files.
15827 Dependencies are expressed through a context clause that names other projects.
15828
15829 Syntax:
15830
15831 @smallexample
15832 project ::=
15833   context_clause project_declaration
15834
15835 project_declaration ::=
15836   simple_project_declaration | project_extension
15837
15838 simple_project_declaration ::=
15839   @b{project} <project_>simple_name @b{is}
15840     @{declarative_item@}
15841   @b{end} <project_>simple_name;
15842
15843 context_clause ::=
15844   @{with_clause@}
15845
15846 with_clause ::=
15847   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15848
15849 path_name ::=
15850    string_literal
15851 @end smallexample
15852
15853 @noindent
15854 A path name denotes a project file. A path name can be absolute or relative.
15855 An absolute path name includes a sequence of directories, in the syntax of
15856 the host operating system, that identifies uniquely the project file in the
15857 file system. A relative path name identifies the project file, relative
15858 to the directory that contains the current project, or relative to a
15859 directory listed in the environment variable ADA_PROJECT_PATH.
15860 Path names are case sensitive if file names in the host operating system
15861 are case sensitive.
15862
15863 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15864 directory names separated by colons (semicolons on Windows).
15865
15866 A given project name can appear only once in a context_clause.
15867
15868 It is illegal for a project imported by a context clause to refer, directly
15869 or indirectly, to the project in which this context clause appears (the
15870 dependency graph cannot contain cycles), except when one of the with_clause
15871 in the cycle is a @code{limited with}.
15872
15873 @node Project Extensions
15874 @section Project Extensions
15875
15876 @noindent
15877 A project extension introduces a new project, which inherits the declarations
15878 of another project.
15879 Syntax:
15880 @smallexample
15881
15882 project_extension ::=
15883   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15884     @{declarative_item@}
15885   @b{end} <project_>simple_name;
15886 @end smallexample
15887
15888 @noindent
15889 The project extension declares a child project. The child project inherits
15890 all the declarations and all the files of the parent project, These inherited
15891 declaration can be overridden in the child project, by means of suitable
15892 declarations.
15893
15894 @node Project File Elaboration
15895 @section Project File Elaboration
15896
15897 @noindent
15898 A project file is processed as part of the invocation of a gnat tool that
15899 uses the project option. Elaboration of the process file consists in the
15900 sequential elaboration of all its declarations. The computed values of
15901 attributes and variables in the project are then used to establish the
15902 environment in which the gnat tool will execute.
15903
15904 @node Obsolescent Features
15905 @chapter Obsolescent Features
15906
15907 @noindent
15908 This chapter describes features that are provided by GNAT, but are
15909 considered obsolescent since there are preferred ways of achieving
15910 the same effect. These features are provided solely for historical
15911 compatibility purposes.
15912
15913 @menu
15914 * pragma No_Run_Time::
15915 * pragma Ravenscar::
15916 * pragma Restricted_Run_Time::
15917 @end menu
15918
15919 @node pragma No_Run_Time
15920 @section pragma No_Run_Time
15921
15922 The pragma @code{No_Run_Time} is used to achieve an affect similar
15923 to the use of the "Zero Foot Print" configurable run time, but without
15924 requiring a specially configured run time. The result of using this
15925 pragma, which must be used for all units in a partition, is to restrict
15926 the use of any language features requiring run-time support code. The
15927 preferred usage is to use an appropriately configured run-time that
15928 includes just those features that are to be made accessible.
15929
15930 @node pragma Ravenscar
15931 @section pragma Ravenscar
15932
15933 The pragma @code{Ravenscar} has exactly the same effect as pragma
15934 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15935 is part of the new Ada 2005 standard.
15936
15937 @node pragma Restricted_Run_Time
15938 @section pragma Restricted_Run_Time
15939
15940 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15941 pragma @code{Profile (Restricted)}. The latter usage is
15942 preferred since the Ada 2005 pragma @code{Profile} is intended for
15943 this kind of implementation dependent addition.
15944
15945 @include fdl.texi
15946 @c GNU Free Documentation License
15947
15948 @node Index,,GNU Free Documentation License, Top
15949 @unnumbered Index
15950
15951 @printindex cp
15952
15953 @contents
15954
15955 @bye