OSDN Git Service

Remove s-crtl-vms64.ads, no longer used.
[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. A trampoline is needed to indirectly
7784 address a nested subprogram (that is a subprogram that is not at the
7785 library level). The restriction prevents the use of any of the
7786 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7787 being applied to a subprogram that is not at the library level.
7788
7789 @item No_Implicit_Loops
7790 @findex No_Implicit_Loops
7791 This restriction ensures that the generated code does not contain any
7792 implicit @code{for} loops, either by modifying
7793 the generated code where possible,
7794 or by rejecting any construct that would otherwise generate an implicit
7795 @code{for} loop. If this restriction is active, it is possible to build
7796 large array aggregates with all static components without generating an
7797 intermediate temporary, and without generating a loop to initialize individual
7798 components..Otherwise, a loop is created for arrays larger than about 5000
7799 scalar components.
7800
7801 @item No_Initialize_Scalars
7802 @findex No_Initialize_Scalars
7803 This restriction ensures that no unit in the partition is compiled with
7804 pragma Initialize_Scalars. This allows the generation of more efficient
7805 code, and in particular eliminates dummy null initialization routines that
7806 are otherwise generated for some record and array types.
7807
7808 @item No_Local_Protected_Objects
7809 @findex No_Local_Protected_Objects
7810 This restriction ensures at compile time that protected objects are
7811 only declared at the library level.
7812
7813 @item No_Protected_Type_Allocators
7814 @findex No_Protected_Type_Allocators
7815 This restriction ensures at compile time that there are no allocator
7816 expressions that attempt to allocate protected objects.
7817
7818 @item No_Secondary_Stack
7819 @findex No_Secondary_Stack
7820 This restriction ensures at compile time that the generated code does not
7821 contain any reference to the secondary stack.  The secondary stack is used
7822 to implement functions returning unconstrained objects (arrays or records)
7823 on some targets.
7824
7825 @item No_Select_Statements
7826 @findex No_Select_Statements
7827 This restriction ensures at compile time no select statements of any kind
7828 are permitted, that is the keyword @code{select} may not appear.
7829 This is one of the restrictions of the Ravenscar
7830 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7831
7832 @item No_Standard_Storage_Pools
7833 @findex No_Standard_Storage_Pools
7834 This restriction ensures at compile time that no access types
7835 use the standard default storage pool.  Any access type declared must
7836 have an explicit Storage_Pool attribute defined specifying a
7837 user-defined storage pool.
7838
7839 @item No_Streams
7840 @findex No_Streams
7841 This restriction ensures at compile/bind time that there are no
7842 stream objects created (and therefore no actual stream operations).
7843 This restriction does not forbid dependences on the package
7844 @code{Ada.Streams}. So it is permissible to with
7845 @code{Ada.Streams} (or another package that does so itself)
7846 as long as no actual stream objects are created.
7847
7848 @item No_Task_Attributes_Package
7849 @findex No_Task_Attributes_Package
7850 This restriction ensures at compile time that there are no implicit or
7851 explicit dependencies on the package @code{Ada.Task_Attributes}.
7852
7853 @item No_Task_Termination
7854 @findex No_Task_Termination
7855 This restriction ensures at compile time that no terminate alternatives
7856 appear in any task body.
7857
7858 @item No_Tasking
7859 @findex No_Tasking
7860 This restriction prevents the declaration of tasks or task types throughout
7861 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7862 except that violations are caught at compile time and cause an error message
7863 to be output either by the compiler or binder.
7864
7865 @item Static_Priorities
7866 @findex Static_Priorities
7867 This restriction ensures at compile time that all priority expressions
7868 are static, and that there are no dependencies on the package
7869 @code{Ada.Dynamic_Priorities}.
7870
7871 @item Static_Storage_Size
7872 @findex Static_Storage_Size
7873 This restriction ensures at compile time that any expression appearing
7874 in a Storage_Size pragma or attribute definition clause is static.
7875
7876 @end table
7877
7878 @noindent
7879 The second set of implementation dependent restriction identifiers
7880 does not require partition-wide consistency.
7881 The restriction may be enforced for a single
7882 compilation unit without any effect on any of the
7883 other compilation units in the partition.
7884
7885 @table @code
7886
7887 @item No_Elaboration_Code
7888 @findex No_Elaboration_Code
7889 This restriction ensures at compile time that no elaboration code is
7890 generated.  Note that this is not the same condition as is enforced
7891 by pragma @code{Preelaborate}.  There are cases in which pragma
7892 @code{Preelaborate} still permits code to be generated (e.g.@: code
7893 to initialize a large array to all zeroes), and there are cases of units
7894 which do not meet the requirements for pragma @code{Preelaborate},
7895 but for which no elaboration code is generated.  Generally, it is
7896 the case that preelaborable units will meet the restrictions, with
7897 the exception of large aggregates initialized with an others_clause,
7898 and exception declarations (which generate calls to a run-time
7899 registry procedure).  This restriction is enforced on
7900 a unit by unit basis, it need not be obeyed consistently
7901 throughout a partition.
7902
7903 In the case of aggregates with others, if the aggregate has a dynamic
7904 size, there is no way to eliminate the elaboration code (such dynamic
7905 bounds would be incompatible with @code{Preelaborate} in any case). If
7906 the bounds are static, then use of this restriction actually modifies
7907 the code choice of the compiler to avoid generating a loop, and instead
7908 generate the aggregate statically if possible, no matter how many times
7909 the data for the others clause must be repeatedly generated.
7910
7911 It is not possible to precisely document
7912 the constructs which are compatible with this restriction, since,
7913 unlike most other restrictions, this is not a restriction on the
7914 source code, but a restriction on the generated object code. For
7915 example, if the source contains a declaration:
7916
7917 @smallexample
7918    Val : constant Integer := X;
7919 @end smallexample
7920
7921 @noindent
7922 where X is not a static constant, it may be possible, depending
7923 on complex optimization circuitry, for the compiler to figure
7924 out the value of X at compile time, in which case this initialization
7925 can be done by the loader, and requires no initialization code. It
7926 is not possible to document the precise conditions under which the
7927 optimizer can figure this out.
7928
7929 Note that this the implementation of this restriction requires full
7930 code generation. If it is used in conjunction with "semantics only"
7931 checking, then some cases of violations may be missed.
7932
7933 @item No_Entry_Queue
7934 @findex No_Entry_Queue
7935 This restriction is a declaration that any protected entry compiled in
7936 the scope of the restriction has at most one task waiting on the entry
7937 at any one time, and so no queue is required.  This restriction is not
7938 checked at compile time.  A program execution is erroneous if an attempt
7939 is made to queue a second task on such an entry.
7940
7941 @item No_Implementation_Attributes
7942 @findex No_Implementation_Attributes
7943 This restriction checks at compile time that no GNAT-defined attributes
7944 are present.  With this restriction, the only attributes that can be used
7945 are those defined in the Ada Reference Manual.
7946
7947 @item No_Implementation_Pragmas
7948 @findex No_Implementation_Pragmas
7949 This restriction checks at compile time that no GNAT-defined pragmas
7950 are present.  With this restriction, the only pragmas that can be used
7951 are those defined in the Ada Reference Manual.
7952
7953 @item No_Implementation_Restrictions
7954 @findex No_Implementation_Restrictions
7955 This restriction checks at compile time that no GNAT-defined restriction
7956 identifiers (other than @code{No_Implementation_Restrictions} itself)
7957 are present.  With this restriction, the only other restriction identifiers
7958 that can be used are those defined in the Ada Reference Manual.
7959
7960 @item No_Wide_Characters
7961 @findex No_Wide_Characters
7962 This restriction ensures at compile time that no uses of the types
7963 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7964 wide types
7965 appear, and that no wide or wide wide string or character literals
7966 appear in the program (that is literals representing characters not in
7967 type @code{Character}.
7968
7969 @end table
7970
7971 @sp 1
7972 @cartouche
7973 @noindent
7974 @strong{58}.  The consequences of violating limitations on
7975 @code{Restrictions} pragmas.  See 13.12(9).
7976 @end cartouche
7977 @noindent
7978 Restrictions that can be checked at compile time result in illegalities
7979 if violated.  Currently there are no other consequences of violating
7980 restrictions.
7981
7982 @sp 1
7983 @cartouche
7984 @noindent
7985 @strong{59}.  The representation used by the @code{Read} and
7986 @code{Write} attributes of elementary types in terms of stream
7987 elements.  See 13.13.2(9).
7988 @end cartouche
7989 @noindent
7990 The representation is the in-memory representation of the base type of
7991 the type, using the number of bits corresponding to the
7992 @code{@var{type}'Size} value, and the natural ordering of the machine.
7993
7994 @sp 1
7995 @cartouche
7996 @noindent
7997 @strong{60}.  The names and characteristics of the numeric subtypes
7998 declared in the visible part of package @code{Standard}.  See A.1(3).
7999 @end cartouche
8000 @noindent
8001 See items describing the integer and floating-point types supported.
8002
8003 @sp 1
8004 @cartouche
8005 @noindent
8006 @strong{61}.  The accuracy actually achieved by the elementary
8007 functions.  See A.5.1(1).
8008 @end cartouche
8009 @noindent
8010 The elementary functions correspond to the functions available in the C
8011 library.  Only fast math mode is implemented.
8012
8013 @sp 1
8014 @cartouche
8015 @noindent
8016 @strong{62}.  The sign of a zero result from some of the operators or
8017 functions in @code{Numerics.Generic_Elementary_Functions}, when
8018 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8019 @end cartouche
8020 @noindent
8021 The sign of zeroes follows the requirements of the IEEE 754 standard on
8022 floating-point.
8023
8024 @sp 1
8025 @cartouche
8026 @noindent
8027 @strong{63}.  The value of
8028 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8029 @end cartouche
8030 @noindent
8031 Maximum image width is 649, see library file @file{a-numran.ads}.
8032
8033 @sp 1
8034 @cartouche
8035 @noindent
8036 @strong{64}.  The value of
8037 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8038 @end cartouche
8039 @noindent
8040 Maximum image width is 80, see library file @file{a-nudira.ads}.
8041
8042 @sp 1
8043 @cartouche
8044 @noindent
8045 @strong{65}.  The algorithms for random number generation.  See
8046 A.5.2(32).
8047 @end cartouche
8048 @noindent
8049 The algorithm is documented in the source files @file{a-numran.ads} and
8050 @file{a-numran.adb}.
8051
8052 @sp 1
8053 @cartouche
8054 @noindent
8055 @strong{66}.  The string representation of a random number generator's
8056 state.  See A.5.2(38).
8057 @end cartouche
8058 @noindent
8059 See the documentation contained in the file @file{a-numran.adb}.
8060
8061 @sp 1
8062 @cartouche
8063 @noindent
8064 @strong{67}.  The minimum time interval between calls to the
8065 time-dependent Reset procedure that are guaranteed to initiate different
8066 random number sequences.  See A.5.2(45).
8067 @end cartouche
8068 @noindent
8069 The minimum period between reset calls to guarantee distinct series of
8070 random numbers is one microsecond.
8071
8072 @sp 1
8073 @cartouche
8074 @noindent
8075 @strong{68}.  The values of the @code{Model_Mantissa},
8076 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8077 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8078 Annex is not supported.  See A.5.3(72).
8079 @end cartouche
8080 @noindent
8081 See the source file @file{ttypef.ads} for the values of all numeric
8082 attributes.
8083
8084 @sp 1
8085 @cartouche
8086 @noindent
8087 @strong{69}.  Any implementation-defined characteristics of the
8088 input-output packages.  See A.7(14).
8089 @end cartouche
8090 @noindent
8091 There are no special implementation defined characteristics for these
8092 packages.
8093
8094 @sp 1
8095 @cartouche
8096 @noindent
8097 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8098 A.9(10).
8099 @end cartouche
8100 @noindent
8101 All type representations are contiguous, and the @code{Buffer_Size} is
8102 the value of @code{@var{type}'Size} rounded up to the next storage unit
8103 boundary.
8104
8105 @sp 1
8106 @cartouche
8107 @noindent
8108 @strong{71}.  External files for standard input, standard output, and
8109 standard error See A.10(5).
8110 @end cartouche
8111 @noindent
8112 These files are mapped onto the files provided by the C streams
8113 libraries.  See source file @file{i-cstrea.ads} for further details.
8114
8115 @sp 1
8116 @cartouche
8117 @noindent
8118 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8119 A.10.9(36).
8120 @end cartouche
8121 @noindent
8122 If more digits are requested in the output than are represented by the
8123 precision of the value, zeroes are output in the corresponding least
8124 significant digit positions.
8125
8126 @sp 1
8127 @cartouche
8128 @noindent
8129 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8130 @code{Command_Name}.  See A.15(1).
8131 @end cartouche
8132 @noindent
8133 These are mapped onto the @code{argv} and @code{argc} parameters of the
8134 main program in the natural manner.
8135
8136 @sp 1
8137 @cartouche
8138 @noindent
8139 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8140 @end cartouche
8141 @noindent
8142 The following convention names are supported
8143
8144 @table @code
8145 @item  Ada
8146 Ada
8147 @item Assembler
8148 Assembly language
8149 @item Asm
8150 Synonym for Assembler
8151 @item Assembly
8152 Synonym for Assembler
8153 @item C
8154 C
8155 @item C_Pass_By_Copy
8156 Allowed only for record types, like C, but also notes that record
8157 is to be passed by copy rather than reference.
8158 @item COBOL
8159 COBOL
8160 @item C_Plus_Plus (or CPP)
8161 C++
8162 @item Default
8163 Treated the same as C
8164 @item External
8165 Treated the same as C
8166 @item Fortran
8167 Fortran
8168 @item Intrinsic
8169 For support of pragma @code{Import} with convention Intrinsic, see
8170 separate section on Intrinsic Subprograms.
8171 @item Stdcall
8172 Stdcall (used for Windows implementations only).  This convention correspond
8173 to the WINAPI (previously called Pascal convention) C/C++ convention under
8174 Windows.  A function with this convention cleans the stack before exit.
8175 @item DLL
8176 Synonym for Stdcall
8177 @item Win32
8178 Synonym for Stdcall
8179 @item Stubbed
8180 Stubbed is a special convention used to indicate that the body of the
8181 subprogram will be entirely ignored.  Any call to the subprogram
8182 is converted into a raise of the @code{Program_Error} exception.  If a
8183 pragma @code{Import} specifies convention @code{stubbed} then no body need
8184 be present at all.  This convention is useful during development for the
8185 inclusion of subprograms whose body has not yet been written.
8186
8187 @end table
8188 @noindent
8189 In addition, all otherwise unrecognized convention names are also
8190 treated as being synonymous with convention C@.  In all implementations
8191 except for VMS, use of such other names results in a warning.  In VMS
8192 implementations, these names are accepted silently.
8193
8194 @sp 1
8195 @cartouche
8196 @noindent
8197 @strong{75}.  The meaning of link names.  See B.1(36).
8198 @end cartouche
8199 @noindent
8200 Link names are the actual names used by the linker.
8201
8202 @sp 1
8203 @cartouche
8204 @noindent
8205 @strong{76}.  The manner of choosing link names when neither the link
8206 name nor the address of an imported or exported entity is specified.  See
8207 B.1(36).
8208 @end cartouche
8209 @noindent
8210 The default linker name is that which would be assigned by the relevant
8211 external language, interpreting the Ada name as being in all lower case
8212 letters.
8213
8214 @sp 1
8215 @cartouche
8216 @noindent
8217 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8218 @end cartouche
8219 @noindent
8220 The string passed to @code{Linker_Options} is presented uninterpreted as
8221 an argument to the link command, unless it contains Ascii.NUL characters.
8222 NUL characters if they appear act as argument separators, so for example
8223
8224 @smallexample @c ada
8225 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8226 @end smallexample
8227
8228 @noindent
8229 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8230 linker. The order of linker options is preserved for a given unit. The final
8231 list of options passed to the linker is in reverse order of the elaboration
8232 order. For example, linker options fo a body always appear before the options
8233 from the corresponding package spec.
8234
8235 @sp 1
8236 @cartouche
8237 @noindent
8238 @strong{78}.  The contents of the visible part of package
8239 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8240 @end cartouche
8241 @noindent
8242 See files with prefix @file{i-} in the distributed library.
8243
8244 @sp 1
8245 @cartouche
8246 @noindent
8247 @strong{79}.  Implementation-defined children of package
8248 @code{Interfaces}.  The contents of the visible part of package
8249 @code{Interfaces}.  See B.2(11).
8250 @end cartouche
8251 @noindent
8252 See files with prefix @file{i-} in the distributed library.
8253
8254 @sp 1
8255 @cartouche
8256 @noindent
8257 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8258 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8259 @code{COBOL_Character}; and the initialization of the variables
8260 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8261 @code{Interfaces.COBOL}.  See B.4(50).
8262 @end cartouche
8263 @noindent
8264 @table @code
8265 @item Floating
8266 Float
8267 @item Long_Floating
8268 (Floating) Long_Float
8269 @item Binary
8270 Integer
8271 @item Long_Binary
8272 Long_Long_Integer
8273 @item Decimal_Element
8274 Character
8275 @item COBOL_Character
8276 Character
8277 @end table
8278
8279 @noindent
8280 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8281
8282 @sp 1
8283 @cartouche
8284 @noindent
8285 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8286 @end cartouche
8287 @noindent
8288 See documentation in file @file{s-maccod.ads} in the distributed library.
8289
8290 @sp 1
8291 @cartouche
8292 @noindent
8293 @strong{82}.  Implementation-defined aspects of access to machine
8294 operations.  See C.1(9).
8295 @end cartouche
8296 @noindent
8297 See documentation in file @file{s-maccod.ads} in the distributed library.
8298
8299 @sp 1
8300 @cartouche
8301 @noindent
8302 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8303 @end cartouche
8304 @noindent
8305 Interrupts are mapped to signals or conditions as appropriate.  See
8306 definition of unit
8307 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8308 on the interrupts supported on a particular target.
8309
8310 @sp 1
8311 @cartouche
8312 @noindent
8313 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8314 C.4(13).
8315 @end cartouche
8316 @noindent
8317 GNAT does not permit a partition to be restarted without reloading,
8318 except under control of the debugger.
8319
8320 @sp 1
8321 @cartouche
8322 @noindent
8323 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8324 @end cartouche
8325 @noindent
8326 Pragma @code{Discard_Names} causes names of enumeration literals to
8327 be suppressed.  In the presence of this pragma, the Image attribute
8328 provides the image of the Pos of the literal, and Value accepts
8329 Pos values.
8330
8331 @sp 1
8332 @cartouche
8333 @noindent
8334 @strong{86}.  The result of the @code{Task_Identification.Image}
8335 attribute.  See C.7.1(7).
8336 @end cartouche
8337 @noindent
8338 The result of this attribute is a string that identifies
8339 the object or component that denotes a given task. If a variable Var has a task
8340 type, the image for this task will have the form Var_XXXXXXXX, where the
8341 suffix
8342 is the hexadecimal representation of the virtual address of the corresponding
8343 task control block. If the variable is an array of tasks, the image of each
8344 task will have the form of an indexed component indicating the position of a
8345 given task in the array, eg.  Group(5)_XXXXXXX. If the task is a
8346 component of a record, the image of the task will have the form of a selected
8347 component. These rules are fully recursive, so that the image of a task that
8348 is a subcomponent of a composite object corresponds to the expression that
8349 designates this task.
8350 @noindent
8351 If a task is created by an allocator, its image depends on the context. If the
8352 allocator is part of an object declaration, the rules described above are used
8353 to construct its image, and this image is not affected by subsequent
8354 assignments. If the allocator appears within an expression, the image
8355 includes only the name of the task type.
8356 @noindent
8357 If the configuration pragma Discard_Names is present, or if the restriction
8358 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8359 the numeric suffix, that is to say the hexadecimal representation of the
8360 virtual address of the control block of the task.
8361 @sp 1
8362 @cartouche
8363 @noindent
8364 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8365 or interrupt handler.  See C.7.1(17).
8366 @end cartouche
8367 @noindent
8368 Protected entries or interrupt handlers can be executed by any
8369 convenient thread, so the value of @code{Current_Task} is undefined.
8370
8371 @sp 1
8372 @cartouche
8373 @noindent
8374 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8375 body or interrupt handler.  See C.7.1(19).
8376 @end cartouche
8377 @noindent
8378 The effect of calling @code{Current_Task} from an entry body or
8379 interrupt handler is to return the identification of the task currently
8380 executing the code.
8381
8382 @sp 1
8383 @cartouche
8384 @noindent
8385 @strong{89}.  Implementation-defined aspects of
8386 @code{Task_Attributes}.  See C.7.2(19).
8387 @end cartouche
8388 @noindent
8389 There are no implementation-defined aspects of @code{Task_Attributes}.
8390
8391 @sp 1
8392 @cartouche
8393 @noindent
8394 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8395 @end cartouche
8396 @noindent
8397 The metrics information for GNAT depends on the performance of the
8398 underlying operating system.  The sources of the run-time for tasking
8399 implementation, together with the output from @code{-gnatG} can be
8400 used to determine the exact sequence of operating systems calls made
8401 to implement various tasking constructs.  Together with appropriate
8402 information on the performance of the underlying operating system,
8403 on the exact target in use, this information can be used to determine
8404 the required metrics.
8405
8406 @sp 1
8407 @cartouche
8408 @noindent
8409 @strong{91}.  The declarations of @code{Any_Priority} and
8410 @code{Priority}.  See D.1(11).
8411 @end cartouche
8412 @noindent
8413 See declarations in file @file{system.ads}.
8414
8415 @sp 1
8416 @cartouche
8417 @noindent
8418 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8419 @end cartouche
8420 @noindent
8421 There are no implementation-defined execution resources.
8422
8423 @sp 1
8424 @cartouche
8425 @noindent
8426 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8427 access to a protected object keeps its processor busy.  See D.2.1(3).
8428 @end cartouche
8429 @noindent
8430 On a multi-processor, a task that is waiting for access to a protected
8431 object does not keep its processor busy.
8432
8433 @sp 1
8434 @cartouche
8435 @noindent
8436 @strong{94}.  The affect of implementation defined execution resources
8437 on task dispatching.  See D.2.1(9).
8438 @end cartouche
8439 @noindent
8440 @c SGI info
8441 @ignore
8442 Tasks map to IRIX threads, and the dispatching policy is as defined by
8443 the IRIX implementation of threads.
8444 @end ignore
8445 Tasks map to threads in the threads package used by GNAT@.  Where possible
8446 and appropriate, these threads correspond to native threads of the
8447 underlying operating system.
8448
8449 @sp 1
8450 @cartouche
8451 @noindent
8452 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8453 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8454 @end cartouche
8455 @noindent
8456 There are no implementation-defined policy-identifiers allowed in this
8457 pragma.
8458
8459 @sp 1
8460 @cartouche
8461 @noindent
8462 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8463 D.2.2(16).
8464 @end cartouche
8465 @noindent
8466 Execution of a task cannot be preempted by the implementation processing
8467 of delay expirations for lower priority tasks.
8468
8469 @sp 1
8470 @cartouche
8471 @noindent
8472 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8473 @end cartouche
8474 @noindent
8475 @c SGI info:
8476 @ignore
8477 Tasks map to IRIX threads, and the dispatching policy is as defined by
8478 the IRIX implementation of threads.
8479 @end ignore
8480 The policy is the same as that of the underlying threads implementation.
8481
8482 @sp 1
8483 @cartouche
8484 @noindent
8485 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8486 in a pragma @code{Locking_Policy}.  See D.3(4).
8487 @end cartouche
8488 @noindent
8489 The only implementation defined policy permitted in GNAT is
8490 @code{Inheritance_Locking}.  On targets that support this policy, locking
8491 is implemented by inheritance, i.e.@: the task owning the lock operates
8492 at a priority equal to the highest priority of any task currently
8493 requesting the lock.
8494
8495 @sp 1
8496 @cartouche
8497 @noindent
8498 @strong{99}.  Default ceiling priorities.  See D.3(10).
8499 @end cartouche
8500 @noindent
8501 The ceiling priority of protected objects of the type
8502 @code{System.Interrupt_Priority'Last} as described in the Ada
8503 Reference Manual D.3(10),
8504
8505 @sp 1
8506 @cartouche
8507 @noindent
8508 @strong{100}.  The ceiling of any protected object used internally by
8509 the implementation.  See D.3(16).
8510 @end cartouche
8511 @noindent
8512 The ceiling priority of internal protected objects is
8513 @code{System.Priority'Last}.
8514
8515 @sp 1
8516 @cartouche
8517 @noindent
8518 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8519 @end cartouche
8520 @noindent
8521 There are no implementation-defined queuing policies.
8522
8523 @sp 1
8524 @cartouche
8525 @noindent
8526 @strong{102}.  On a multiprocessor, any conditions that cause the
8527 completion of an aborted construct to be delayed later than what is
8528 specified for a single processor.  See D.6(3).
8529 @end cartouche
8530 @noindent
8531 The semantics for abort on a multi-processor is the same as on a single
8532 processor, there are no further delays.
8533
8534 @sp 1
8535 @cartouche
8536 @noindent
8537 @strong{103}.  Any operations that implicitly require heap storage
8538 allocation.  See D.7(8).
8539 @end cartouche
8540 @noindent
8541 The only operation that implicitly requires heap storage allocation is
8542 task creation.
8543
8544 @sp 1
8545 @cartouche
8546 @noindent
8547 @strong{104}.  Implementation-defined aspects of pragma
8548 @code{Restrictions}.  See D.7(20).
8549 @end cartouche
8550 @noindent
8551 There are no such implementation-defined aspects.
8552
8553 @sp 1
8554 @cartouche
8555 @noindent
8556 @strong{105}.  Implementation-defined aspects of package
8557 @code{Real_Time}.  See D.8(17).
8558 @end cartouche
8559 @noindent
8560 There are no implementation defined aspects of package @code{Real_Time}.
8561
8562 @sp 1
8563 @cartouche
8564 @noindent
8565 @strong{106}.  Implementation-defined aspects of
8566 @code{delay_statements}.  See D.9(8).
8567 @end cartouche
8568 @noindent
8569 Any difference greater than one microsecond will cause the task to be
8570 delayed (see D.9(7)).
8571
8572 @sp 1
8573 @cartouche
8574 @noindent
8575 @strong{107}.  The upper bound on the duration of interrupt blocking
8576 caused by the implementation.  See D.12(5).
8577 @end cartouche
8578 @noindent
8579 The upper bound is determined by the underlying operating system.  In
8580 no cases is it more than 10 milliseconds.
8581
8582 @sp 1
8583 @cartouche
8584 @noindent
8585 @strong{108}.  The means for creating and executing distributed
8586 programs.  See E(5).
8587 @end cartouche
8588 @noindent
8589 The GLADE package provides a utility GNATDIST for creating and executing
8590 distributed programs.  See the GLADE reference manual for further details.
8591
8592 @sp 1
8593 @cartouche
8594 @noindent
8595 @strong{109}.  Any events that can result in a partition becoming
8596 inaccessible.  See E.1(7).
8597 @end cartouche
8598 @noindent
8599 See the GLADE reference manual for full details on such events.
8600
8601 @sp 1
8602 @cartouche
8603 @noindent
8604 @strong{110}.  The scheduling policies, treatment of priorities, and
8605 management of shared resources between partitions in certain cases.  See
8606 E.1(11).
8607 @end cartouche
8608 @noindent
8609 See the GLADE reference manual for full details on these aspects of
8610 multi-partition execution.
8611
8612 @sp 1
8613 @cartouche
8614 @noindent
8615 @strong{111}.  Events that cause the version of a compilation unit to
8616 change.  See E.3(5).
8617 @end cartouche
8618 @noindent
8619 Editing the source file of a compilation unit, or the source files of
8620 any units on which it is dependent in a significant way cause the version
8621 to change.  No other actions cause the version number to change.  All changes
8622 are significant except those which affect only layout, capitalization or
8623 comments.
8624
8625 @sp 1
8626 @cartouche
8627 @noindent
8628 @strong{112}.  Whether the execution of the remote subprogram is
8629 immediately aborted as a result of cancellation.  See E.4(13).
8630 @end cartouche
8631 @noindent
8632 See the GLADE reference manual for details on the effect of abort in
8633 a distributed application.
8634
8635 @sp 1
8636 @cartouche
8637 @noindent
8638 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8639 @end cartouche
8640 @noindent
8641 See the GLADE reference manual for a full description of all implementation
8642 defined aspects of the PCS@.
8643
8644 @sp 1
8645 @cartouche
8646 @noindent
8647 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8648 E.5(26).
8649 @end cartouche
8650 @noindent
8651 See the GLADE reference manual for a full description of all
8652 implementation defined interfaces.
8653
8654 @sp 1
8655 @cartouche
8656 @noindent
8657 @strong{115}.  The values of named numbers in the package
8658 @code{Decimal}.  See F.2(7).
8659 @end cartouche
8660 @noindent
8661 @table @code
8662 @item Max_Scale
8663 +18
8664 @item Min_Scale
8665 -18
8666 @item Min_Delta
8667 1.0E-18
8668 @item Max_Delta
8669 1.0E+18
8670 @item Max_Decimal_Digits
8671 18
8672 @end table
8673
8674 @sp 1
8675 @cartouche
8676 @noindent
8677 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8678 @code{Text_IO.Editing}.  See F.3.3(16).
8679 @end cartouche
8680 @noindent
8681 64
8682
8683 @sp 1
8684 @cartouche
8685 @noindent
8686 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8687 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8688 @end cartouche
8689 @noindent
8690 64
8691
8692 @sp 1
8693 @cartouche
8694 @noindent
8695 @strong{118}.  The accuracy actually achieved by the complex elementary
8696 functions and by other complex arithmetic operations.  See G.1(1).
8697 @end cartouche
8698 @noindent
8699 Standard library functions are used for the complex arithmetic
8700 operations.  Only fast math mode is currently supported.
8701
8702 @sp 1
8703 @cartouche
8704 @noindent
8705 @strong{119}.  The sign of a zero result (or a component thereof) from
8706 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8707 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8708 @end cartouche
8709 @noindent
8710 The signs of zero values are as recommended by the relevant
8711 implementation advice.
8712
8713 @sp 1
8714 @cartouche
8715 @noindent
8716 @strong{120}.  The sign of a zero result (or a component thereof) from
8717 any operator or function in
8718 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8719 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8720 @end cartouche
8721 @noindent
8722 The signs of zero values are as recommended by the relevant
8723 implementation advice.
8724
8725 @sp 1
8726 @cartouche
8727 @noindent
8728 @strong{121}.  Whether the strict mode or the relaxed mode is the
8729 default.  See G.2(2).
8730 @end cartouche
8731 @noindent
8732 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8733 provides a highly efficient implementation of strict mode.
8734
8735 @sp 1
8736 @cartouche
8737 @noindent
8738 @strong{122}.  The result interval in certain cases of fixed-to-float
8739 conversion.  See G.2.1(10).
8740 @end cartouche
8741 @noindent
8742 For cases where the result interval is implementation dependent, the
8743 accuracy is that provided by performing all operations in 64-bit IEEE
8744 floating-point format.
8745
8746 @sp 1
8747 @cartouche
8748 @noindent
8749 @strong{123}.  The result of a floating point arithmetic operation in
8750 overflow situations, when the @code{Machine_Overflows} attribute of the
8751 result type is @code{False}.  See G.2.1(13).
8752 @end cartouche
8753 @noindent
8754 Infinite and NaN values are produced as dictated by the IEEE
8755 floating-point standard.
8756
8757 Note that on machines that are not fully compliant with the IEEE
8758 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8759 must be used for achieving IEEE confirming behavior (although at the cost
8760 of a significant performance penalty), so infinite and NaN values are
8761 properly generated.
8762
8763 @sp 1
8764 @cartouche
8765 @noindent
8766 @strong{124}.  The result interval for division (or exponentiation by a
8767 negative exponent), when the floating point hardware implements division
8768 as multiplication by a reciprocal.  See G.2.1(16).
8769 @end cartouche
8770 @noindent
8771 Not relevant, division is IEEE exact.
8772
8773 @sp 1
8774 @cartouche
8775 @noindent
8776 @strong{125}.  The definition of close result set, which determines the
8777 accuracy of certain fixed point multiplications and divisions.  See
8778 G.2.3(5).
8779 @end cartouche
8780 @noindent
8781 Operations in the close result set are performed using IEEE long format
8782 floating-point arithmetic.  The input operands are converted to
8783 floating-point, the operation is done in floating-point, and the result
8784 is converted to the target type.
8785
8786 @sp 1
8787 @cartouche
8788 @noindent
8789 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8790 point multiplication or division for which the result shall be in the
8791 perfect result set.  See G.2.3(22).
8792 @end cartouche
8793 @noindent
8794 The result is only defined to be in the perfect result set if the result
8795 can be computed by a single scaling operation involving a scale factor
8796 representable in 64-bits.
8797
8798 @sp 1
8799 @cartouche
8800 @noindent
8801 @strong{127}.  The result of a fixed point arithmetic operation in
8802 overflow situations, when the @code{Machine_Overflows} attribute of the
8803 result type is @code{False}.  See G.2.3(27).
8804 @end cartouche
8805 @noindent
8806 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8807 types.
8808
8809 @sp 1
8810 @cartouche
8811 @noindent
8812 @strong{128}.  The result of an elementary function reference in
8813 overflow situations, when the @code{Machine_Overflows} attribute of the
8814 result type is @code{False}.  See G.2.4(4).
8815 @end cartouche
8816 @noindent
8817 IEEE infinite and Nan values are produced as appropriate.
8818
8819 @sp 1
8820 @cartouche
8821 @noindent
8822 @strong{129}.  The value of the angle threshold, within which certain
8823 elementary functions, complex arithmetic operations, and complex
8824 elementary functions yield results conforming to a maximum relative
8825 error bound.  See G.2.4(10).
8826 @end cartouche
8827 @noindent
8828 Information on this subject is not yet available.
8829
8830 @sp 1
8831 @cartouche
8832 @noindent
8833 @strong{130}.  The accuracy of certain elementary functions for
8834 parameters beyond the angle threshold.  See G.2.4(10).
8835 @end cartouche
8836 @noindent
8837 Information on this subject is not yet available.
8838
8839 @sp 1
8840 @cartouche
8841 @noindent
8842 @strong{131}.  The result of a complex arithmetic operation or complex
8843 elementary function reference in overflow situations, when the
8844 @code{Machine_Overflows} attribute of the corresponding real type is
8845 @code{False}.  See G.2.6(5).
8846 @end cartouche
8847 @noindent
8848 IEEE infinite and Nan values are produced as appropriate.
8849
8850 @sp 1
8851 @cartouche
8852 @noindent
8853 @strong{132}.  The accuracy of certain complex arithmetic operations and
8854 certain complex elementary functions for parameters (or components
8855 thereof) beyond the angle threshold.  See G.2.6(8).
8856 @end cartouche
8857 @noindent
8858 Information on those subjects is not yet available.
8859
8860 @sp 1
8861 @cartouche
8862 @noindent
8863 @strong{133}.  Information regarding bounded errors and erroneous
8864 execution.  See H.2(1).
8865 @end cartouche
8866 @noindent
8867 Information on this subject is not yet available.
8868
8869 @sp 1
8870 @cartouche
8871 @noindent
8872 @strong{134}.  Implementation-defined aspects of pragma
8873 @code{Inspection_Point}.  See H.3.2(8).
8874 @end cartouche
8875 @noindent
8876 Pragma @code{Inspection_Point} ensures that the variable is live and can
8877 be examined by the debugger at the inspection point.
8878
8879 @sp 1
8880 @cartouche
8881 @noindent
8882 @strong{135}.  Implementation-defined aspects of pragma
8883 @code{Restrictions}.  See H.4(25).
8884 @end cartouche
8885 @noindent
8886 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8887 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8888 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8889
8890 @sp 1
8891 @cartouche
8892 @noindent
8893 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8894 H.4(27).
8895 @end cartouche
8896 @noindent
8897 There are no restrictions on pragma @code{Restrictions}.
8898
8899 @node Intrinsic Subprograms
8900 @chapter Intrinsic Subprograms
8901 @cindex Intrinsic Subprograms
8902
8903 @menu
8904 * Intrinsic Operators::
8905 * Enclosing_Entity::
8906 * Exception_Information::
8907 * Exception_Message::
8908 * Exception_Name::
8909 * File::
8910 * Line::
8911 * Rotate_Left::
8912 * Rotate_Right::
8913 * Shift_Left::
8914 * Shift_Right::
8915 * Shift_Right_Arithmetic::
8916 * Source_Location::
8917 @end menu
8918
8919 @noindent
8920 GNAT allows a user application program to write the declaration:
8921
8922 @smallexample @c ada
8923    pragma Import (Intrinsic, name);
8924 @end smallexample
8925
8926 @noindent
8927 providing that the name corresponds to one of the implemented intrinsic
8928 subprograms in GNAT, and that the parameter profile of the referenced
8929 subprogram meets the requirements.  This chapter describes the set of
8930 implemented intrinsic subprograms, and the requirements on parameter profiles.
8931 Note that no body is supplied; as with other uses of pragma Import, the
8932 body is supplied elsewhere (in this case by the compiler itself).  Note
8933 that any use of this feature is potentially non-portable, since the
8934 Ada standard does not require Ada compilers to implement this feature.
8935
8936 @node Intrinsic Operators
8937 @section Intrinsic Operators
8938 @cindex Intrinsic operator
8939
8940 @noindent
8941 All the predefined numeric operators in package Standard
8942 in @code{pragma Import (Intrinsic,..)}
8943 declarations.  In the binary operator case, the operands must have the same
8944 size.  The operand or operands must also be appropriate for
8945 the operator.  For example, for addition, the operands must
8946 both be floating-point or both be fixed-point, and the
8947 right operand for @code{"**"} must have a root type of
8948 @code{Standard.Integer'Base}.
8949 You can use an intrinsic operator declaration as in the following example:
8950
8951 @smallexample @c ada
8952    type Int1 is new Integer;
8953    type Int2 is new Integer;
8954
8955    function "+" (X1 : Int1; X2 : Int2) return Int1;
8956    function "+" (X1 : Int1; X2 : Int2) return Int2;
8957    pragma Import (Intrinsic, "+");
8958 @end smallexample
8959
8960 @noindent
8961 This declaration would permit ``mixed mode'' arithmetic on items
8962 of the differing types @code{Int1} and @code{Int2}.
8963 It is also possible to specify such operators for private types, if the
8964 full views are appropriate arithmetic types.
8965
8966 @node Enclosing_Entity
8967 @section Enclosing_Entity
8968 @cindex Enclosing_Entity
8969 @noindent
8970 This intrinsic subprogram is used in the implementation of the
8971 library routine @code{GNAT.Source_Info}.  The only useful use of the
8972 intrinsic import in this case is the one in this unit, so an
8973 application program should simply call the function
8974 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8975 the current subprogram, package, task, entry, or protected subprogram.
8976
8977 @node Exception_Information
8978 @section Exception_Information
8979 @cindex Exception_Information'
8980 @noindent
8981 This intrinsic subprogram is used in the implementation of the
8982 library routine @code{GNAT.Current_Exception}.  The only useful
8983 use of the intrinsic import in this case is the one in this unit,
8984 so an application program should simply call the function
8985 @code{GNAT.Current_Exception.Exception_Information} to obtain
8986 the exception information associated with the current exception.
8987
8988 @node Exception_Message
8989 @section Exception_Message
8990 @cindex Exception_Message
8991 @noindent
8992 This intrinsic subprogram is used in the implementation of the
8993 library routine @code{GNAT.Current_Exception}.  The only useful
8994 use of the intrinsic import in this case is the one in this unit,
8995 so an application program should simply call the function
8996 @code{GNAT.Current_Exception.Exception_Message} to obtain
8997 the message associated with the current exception.
8998
8999 @node Exception_Name
9000 @section Exception_Name
9001 @cindex Exception_Name
9002 @noindent
9003 This intrinsic subprogram is used in the implementation of the
9004 library routine @code{GNAT.Current_Exception}.  The only useful
9005 use of the intrinsic import in this case is the one in this unit,
9006 so an application program should simply call the function
9007 @code{GNAT.Current_Exception.Exception_Name} to obtain
9008 the name of the current exception.
9009
9010 @node File
9011 @section File
9012 @cindex File
9013 @noindent
9014 This intrinsic subprogram is used in the implementation of the
9015 library routine @code{GNAT.Source_Info}.  The only useful use of the
9016 intrinsic import in this case is the one in this unit, so an
9017 application program should simply call the function
9018 @code{GNAT.Source_Info.File} to obtain the name of the current
9019 file.
9020
9021 @node Line
9022 @section Line
9023 @cindex Line
9024 @noindent
9025 This intrinsic subprogram is used in the implementation of the
9026 library routine @code{GNAT.Source_Info}.  The only useful use of the
9027 intrinsic import in this case is the one in this unit, so an
9028 application program should simply call the function
9029 @code{GNAT.Source_Info.Line} to obtain the number of the current
9030 source line.
9031
9032 @node Rotate_Left
9033 @section Rotate_Left
9034 @cindex Rotate_Left
9035 @noindent
9036 In standard Ada, the @code{Rotate_Left} function is available only
9037 for the predefined modular types in package @code{Interfaces}.  However, in
9038 GNAT it is possible to define a Rotate_Left function for a user
9039 defined modular type or any signed integer type as in this example:
9040
9041 @smallexample @c ada
9042    function Shift_Left
9043      (Value  : My_Modular_Type;
9044       Amount : Natural)
9045       return   My_Modular_Type;
9046 @end smallexample
9047
9048 @noindent
9049 The requirements are that the profile be exactly as in the example
9050 above.  The only modifications allowed are in the formal parameter
9051 names, and in the type of @code{Value} and the return type, which
9052 must be the same, and must be either a signed integer type, or
9053 a modular integer type with a binary modulus, and the size must
9054 be 8.  16, 32 or 64 bits.
9055
9056 @node Rotate_Right
9057 @section Rotate_Right
9058 @cindex Rotate_Right
9059 @noindent
9060 A @code{Rotate_Right} function can be defined for any user defined
9061 binary modular integer type, or signed integer type, as described
9062 above for @code{Rotate_Left}.
9063
9064 @node Shift_Left
9065 @section Shift_Left
9066 @cindex Shift_Left
9067 @noindent
9068 A @code{Shift_Left} function can be defined for any user defined
9069 binary modular integer type, or signed integer type, as described
9070 above for @code{Rotate_Left}.
9071
9072 @node Shift_Right
9073 @section Shift_Right
9074 @cindex Shift_Right
9075 @noindent
9076 A @code{Shift_Right} function can be defined for any user defined
9077 binary modular integer type, or signed integer type, as described
9078 above for @code{Rotate_Left}.
9079
9080 @node Shift_Right_Arithmetic
9081 @section Shift_Right_Arithmetic
9082 @cindex Shift_Right_Arithmetic
9083 @noindent
9084 A @code{Shift_Right_Arithmetic} function can be defined for any user
9085 defined binary modular integer type, or signed integer type, as described
9086 above for @code{Rotate_Left}.
9087
9088 @node Source_Location
9089 @section Source_Location
9090 @cindex Source_Location
9091 @noindent
9092 This intrinsic subprogram is used in the implementation of the
9093 library routine @code{GNAT.Source_Info}.  The only useful use of the
9094 intrinsic import in this case is the one in this unit, so an
9095 application program should simply call the function
9096 @code{GNAT.Source_Info.Source_Location} to obtain the current
9097 source file location.
9098
9099 @node Representation Clauses and Pragmas
9100 @chapter Representation Clauses and Pragmas
9101 @cindex Representation Clauses
9102
9103 @menu
9104 * Alignment Clauses::
9105 * Size Clauses::
9106 * Storage_Size Clauses::
9107 * Size of Variant Record Objects::
9108 * Biased Representation ::
9109 * Value_Size and Object_Size Clauses::
9110 * Component_Size Clauses::
9111 * Bit_Order Clauses::
9112 * Effect of Bit_Order on Byte Ordering::
9113 * Pragma Pack for Arrays::
9114 * Pragma Pack for Records::
9115 * Record Representation Clauses::
9116 * Enumeration Clauses::
9117 * Address Clauses::
9118 * Effect of Convention on Representation::
9119 * Determining the Representations chosen by GNAT::
9120 @end menu
9121
9122 @noindent
9123 @cindex Representation Clause
9124 @cindex Representation Pragma
9125 @cindex Pragma, representation
9126 This section describes the representation clauses accepted by GNAT, and
9127 their effect on the representation of corresponding data objects.
9128
9129 GNAT fully implements Annex C (Systems Programming).  This means that all
9130 the implementation advice sections in chapter 13 are fully implemented.
9131 However, these sections only require a minimal level of support for
9132 representation clauses.  GNAT provides much more extensive capabilities,
9133 and this section describes the additional capabilities provided.
9134
9135 @node Alignment Clauses
9136 @section Alignment Clauses
9137 @cindex Alignment Clause
9138
9139 @noindent
9140 GNAT requires that all alignment clauses specify a power of 2, and all
9141 default alignments are always a power of 2.  The default alignment
9142 values are as follows:
9143
9144 @itemize @bullet
9145 @item @emph{Primitive Types}.
9146 For primitive types, the alignment is the minimum of the actual size of
9147 objects of the type divided by @code{Storage_Unit},
9148 and the maximum alignment supported by the target.
9149 (This maximum alignment is given by the GNAT-specific attribute
9150 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9151 @cindex @code{Maximum_Alignment} attribute
9152 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9153 default alignment will be 8 on any target that supports alignments
9154 this large, but on some targets, the maximum alignment may be smaller
9155 than 8, in which case objects of type @code{Long_Float} will be maximally
9156 aligned.
9157
9158 @item @emph{Arrays}.
9159 For arrays, the alignment is equal to the alignment of the component type
9160 for the normal case where no packing or component size is given.  If the
9161 array is packed, and the packing is effective (see separate section on
9162 packed arrays), then the alignment will be one for long packed arrays,
9163 or arrays whose length is not known at compile time.  For short packed
9164 arrays, which are handled internally as modular types, the alignment
9165 will be as described for primitive types, e.g.@: a packed array of length
9166 31 bits will have an object size of four bytes, and an alignment of 4.
9167
9168 @item @emph{Records}.
9169 For the normal non-packed case, the alignment of a record is equal to
9170 the maximum alignment of any of its components.  For tagged records, this
9171 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
9172 used and all fields are packable (see separate section on pragma @code{Pack}),
9173 then the resulting alignment is 1.
9174
9175 A special case is when:
9176 @itemize @bullet
9177 @item
9178 the size of the record is given explicitly, or a
9179 full record representation clause is given, and
9180 @item
9181 the size of the record is 2, 4, or 8 bytes.
9182 @end itemize
9183 @noindent
9184 In this case, an alignment is chosen to match the
9185 size of the record. For example, if we have:
9186
9187 @smallexample @c ada
9188    type Small is record
9189       A, B : Character;
9190    end record;
9191    for Small'Size use 16;
9192 @end smallexample
9193
9194 @noindent
9195 then the default alignment of the record type @code{Small} is 2, not 1. This
9196 leads to more efficient code when the record is treated as a unit, and also
9197 allows the type to specified as @code{Atomic} on architectures requiring
9198 strict alignment.
9199
9200 @end itemize
9201
9202 @noindent
9203 An alignment clause may specify a larger alignment than the default value
9204 up to some maximum value dependent on the target (obtainable by using the
9205 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9206 a smaller alignment than the default value, for example
9207
9208 @smallexample @c ada
9209   type V is record
9210      A : Integer;
9211   end record;
9212
9213   for V'alignment use 1;
9214 @end smallexample
9215
9216 @noindent
9217 @cindex Alignment, default
9218 The default alignment for the type @code{V} is 4, as a result of the
9219 Integer field in the record, but it is permissible, as shown, to
9220 override the default alignment of the record with a smaller value.
9221
9222 @node Size Clauses
9223 @section Size Clauses
9224 @cindex Size Clause
9225
9226 @noindent
9227 The default size for a type @code{T} is obtainable through the
9228 language-defined attribute @code{T'Size} and also through the
9229 equivalent GNAT-defined attribute @code{T'Value_Size}.
9230 For objects of type @code{T}, GNAT will generally increase the type size
9231 so that the object size (obtainable through the GNAT-defined attribute
9232 @code{T'Object_Size})
9233 is a multiple of @code{T'Alignment * Storage_Unit}.
9234 For example
9235
9236 @smallexample @c ada
9237    type Smallint is range 1 .. 6;
9238
9239    type Rec is record
9240       Y1 : integer;
9241       Y2 : boolean;
9242    end record;
9243 @end smallexample
9244
9245 @noindent
9246 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9247 as specified by the RM rules,
9248 but objects of this type will have a size of 8
9249 (@code{Smallint'Object_Size} = 8),
9250 since objects by default occupy an integral number
9251 of storage units.  On some targets, notably older
9252 versions of the Digital Alpha, the size of stand
9253 alone objects of this type may be 32, reflecting
9254 the inability of the hardware to do byte load/stores.
9255
9256 Similarly, the size of type @code{Rec} is 40 bits
9257 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9258 the alignment is 4, so objects of this type will have
9259 their size increased to 64 bits so that it is a multiple
9260 of the alignment (in bits).  This decision is
9261 in accordance with the specific Implementation Advice in RM 13.3(43):
9262
9263 @quotation
9264 A @code{Size} clause should be supported for an object if the specified
9265 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9266 to a size in storage elements that is a multiple of the object's
9267 @code{Alignment} (if the @code{Alignment} is nonzero).
9268 @end quotation
9269
9270 @noindent
9271 An explicit size clause may be used to override the default size by
9272 increasing it.  For example, if we have:
9273
9274 @smallexample @c ada
9275    type My_Boolean is new Boolean;
9276    for My_Boolean'Size use 32;
9277 @end smallexample
9278
9279 @noindent
9280 then values of this type will always be 32 bits long.  In the case of
9281 discrete types, the size can be increased up to 64 bits, with the effect
9282 that the entire specified field is used to hold the value, sign- or
9283 zero-extended as appropriate.  If more than 64 bits is specified, then
9284 padding space is allocated after the value, and a warning is issued that
9285 there are unused bits.
9286
9287 Similarly the size of records and arrays may be increased, and the effect
9288 is to add padding bits after the value.  This also causes a warning message
9289 to be generated.
9290
9291 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9292 Size in bits, this corresponds to an object of size 256 megabytes (minus
9293 one).  This limitation is true on all targets.  The reason for this
9294 limitation is that it improves the quality of the code in many cases
9295 if it is known that a Size value can be accommodated in an object of
9296 type Integer.
9297
9298 @node Storage_Size Clauses
9299 @section Storage_Size Clauses
9300 @cindex Storage_Size Clause
9301
9302 @noindent
9303 For tasks, the @code{Storage_Size} clause specifies the amount of space
9304 to be allocated for the task stack.  This cannot be extended, and if the
9305 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9306 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9307 or a @code{Storage_Size} pragma in the task definition to set the
9308 appropriate required size.  A useful technique is to include in every
9309 task definition a pragma of the form:
9310
9311 @smallexample @c ada
9312    pragma Storage_Size (Default_Stack_Size);
9313 @end smallexample
9314
9315 @noindent
9316 Then @code{Default_Stack_Size} can be defined in a global package, and
9317 modified as required. Any tasks requiring stack sizes different from the
9318 default can have an appropriate alternative reference in the pragma.
9319
9320 You can also use the @code{-d} binder switch to modify the default stack
9321 size.
9322
9323 For access types, the @code{Storage_Size} clause specifies the maximum
9324 space available for allocation of objects of the type.  If this space is
9325 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9326 In the case where the access type is declared local to a subprogram, the
9327 use of a @code{Storage_Size} clause triggers automatic use of a special
9328 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9329 space for the pool is automatically reclaimed on exit from the scope in
9330 which the type is declared.
9331
9332 A special case recognized by the compiler is the specification of a
9333 @code{Storage_Size} of zero for an access type.  This means that no
9334 items can be allocated from the pool, and this is recognized at compile
9335 time, and all the overhead normally associated with maintaining a fixed
9336 size storage pool is eliminated.  Consider the following example:
9337
9338 @smallexample @c ada
9339    procedure p is
9340       type R is array (Natural) of Character;
9341       type P is access all R;
9342       for P'Storage_Size use 0;
9343       --  Above access type intended only for interfacing purposes
9344
9345       y : P;
9346
9347       procedure g (m : P);
9348       pragma Import (C, g);
9349
9350       --  @dots{}
9351
9352    begin
9353       --  @dots{}
9354       y := new R;
9355    end;
9356 @end smallexample
9357
9358 @noindent
9359 As indicated in this example, these dummy storage pools are often useful in
9360 connection with interfacing where no object will ever be allocated.  If you
9361 compile the above example, you get the warning:
9362
9363 @smallexample
9364    p.adb:16:09: warning: allocation from empty storage pool
9365    p.adb:16:09: warning: Storage_Error will be raised at run time
9366 @end smallexample
9367
9368 @noindent
9369 Of course in practice, there will not be any explicit allocators in the
9370 case of such an access declaration.
9371
9372 @node Size of Variant Record Objects
9373 @section Size of Variant Record Objects
9374 @cindex Size, variant record objects
9375 @cindex Variant record objects, size
9376
9377 @noindent
9378 In the case of variant record objects, there is a question whether Size gives
9379 information about a particular variant, or the maximum size required
9380 for any variant.  Consider the following program
9381
9382 @smallexample @c ada
9383 with Text_IO; use Text_IO;
9384 procedure q is
9385    type R1 (A : Boolean := False) is record
9386      case A is
9387        when True  => X : Character;
9388        when False => null;
9389      end case;
9390    end record;
9391
9392    V1 : R1 (False);
9393    V2 : R1;
9394
9395 begin
9396    Put_Line (Integer'Image (V1'Size));
9397    Put_Line (Integer'Image (V2'Size));
9398 end q;
9399 @end smallexample
9400
9401 @noindent
9402 Here we are dealing with a variant record, where the True variant
9403 requires 16 bits, and the False variant requires 8 bits.
9404 In the above example, both V1 and V2 contain the False variant,
9405 which is only 8 bits long.  However, the result of running the
9406 program is:
9407
9408 @smallexample
9409 8
9410 16
9411 @end smallexample
9412
9413 @noindent
9414 The reason for the difference here is that the discriminant value of
9415 V1 is fixed, and will always be False.  It is not possible to assign
9416 a True variant value to V1, therefore 8 bits is sufficient.  On the
9417 other hand, in the case of V2, the initial discriminant value is
9418 False (from the default), but it is possible to assign a True
9419 variant value to V2, therefore 16 bits must be allocated for V2
9420 in the general case, even fewer bits may be needed at any particular
9421 point during the program execution.
9422
9423 As can be seen from the output of this program, the @code{'Size}
9424 attribute applied to such an object in GNAT gives the actual allocated
9425 size of the variable, which is the largest size of any of the variants.
9426 The Ada Reference Manual is not completely clear on what choice should
9427 be made here, but the GNAT behavior seems most consistent with the
9428 language in the RM@.
9429
9430 In some cases, it may be desirable to obtain the size of the current
9431 variant, rather than the size of the largest variant.  This can be
9432 achieved in GNAT by making use of the fact that in the case of a
9433 subprogram parameter, GNAT does indeed return the size of the current
9434 variant (because a subprogram has no way of knowing how much space
9435 is actually allocated for the actual).
9436
9437 Consider the following modified version of the above program:
9438
9439 @smallexample @c ada
9440 with Text_IO; use Text_IO;
9441 procedure q is
9442    type R1 (A : Boolean := False) is record
9443      case A is
9444        when True  => X : Character;
9445        when False => null;
9446      end case;
9447    end record;
9448
9449    V2 : R1;
9450
9451    function Size (V : R1) return Integer is
9452    begin
9453       return V'Size;
9454    end Size;
9455
9456 begin
9457    Put_Line (Integer'Image (V2'Size));
9458    Put_Line (Integer'IMage (Size (V2)));
9459    V2 := (True, 'x');
9460    Put_Line (Integer'Image (V2'Size));
9461    Put_Line (Integer'IMage (Size (V2)));
9462 end q;
9463 @end smallexample
9464
9465 @noindent
9466 The output from this program is
9467
9468 @smallexample
9469 16
9470 8
9471 16
9472 16
9473 @end smallexample
9474
9475 @noindent
9476 Here we see that while the @code{'Size} attribute always returns
9477 the maximum size, regardless of the current variant value, the
9478 @code{Size} function does indeed return the size of the current
9479 variant value.
9480
9481 @node Biased Representation
9482 @section Biased Representation
9483 @cindex Size for biased representation
9484 @cindex Biased representation
9485
9486 @noindent
9487 In the case of scalars with a range starting at other than zero, it is
9488 possible in some cases to specify a size smaller than the default minimum
9489 value, and in such cases, GNAT uses an unsigned biased representation,
9490 in which zero is used to represent the lower bound, and successive values
9491 represent successive values of the type.
9492
9493 For example, suppose we have the declaration:
9494
9495 @smallexample @c ada
9496    type Small is range -7 .. -4;
9497    for Small'Size use 2;
9498 @end smallexample
9499
9500 @noindent
9501 Although the default size of type @code{Small} is 4, the @code{Size}
9502 clause is accepted by GNAT and results in the following representation
9503 scheme:
9504
9505 @smallexample
9506   -7 is represented as 2#00#
9507   -6 is represented as 2#01#
9508   -5 is represented as 2#10#
9509   -4 is represented as 2#11#
9510 @end smallexample
9511
9512 @noindent
9513 Biased representation is only used if the specified @code{Size} clause
9514 cannot be accepted in any other manner.  These reduced sizes that force
9515 biased representation can be used for all discrete types except for
9516 enumeration types for which a representation clause is given.
9517
9518 @node Value_Size and Object_Size Clauses
9519 @section Value_Size and Object_Size Clauses
9520 @findex Value_Size
9521 @findex Object_Size
9522 @cindex Size, of objects
9523
9524 @noindent
9525 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9526 number of bits required to hold values of type @code{T}.
9527 Although this interpretation was allowed in Ada 83, it was not required,
9528 and this requirement in practice can cause some significant difficulties.
9529 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9530 However, in Ada 95 and Ada 2005,
9531 @code{Natural'Size} is
9532 typically 31.  This means that code may change in behavior when moving
9533 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
9534
9535 @smallexample @c ada
9536    type Rec is record;
9537       A : Natural;
9538       B : Natural;
9539    end record;
9540
9541    for Rec use record
9542       at 0  range 0 .. Natural'Size - 1;
9543       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9544    end record;
9545 @end smallexample
9546
9547 @noindent
9548 In the above code, since the typical size of @code{Natural} objects
9549 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9550 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9551 there are cases where the fact that the object size can exceed the
9552 size of the type causes surprises.
9553
9554 To help get around this problem GNAT provides two implementation
9555 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9556 applied to a type, these attributes yield the size of the type
9557 (corresponding to the RM defined size attribute), and the size of
9558 objects of the type respectively.
9559
9560 The @code{Object_Size} is used for determining the default size of
9561 objects and components.  This size value can be referred to using the
9562 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9563 the basis of the determination of the size.  The backend is free to
9564 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9565 character might be stored in 32 bits on a machine with no efficient
9566 byte access instructions such as the Alpha.
9567
9568 The default rules for the value of @code{Object_Size} for
9569 discrete types are as follows:
9570
9571 @itemize @bullet
9572 @item
9573 The @code{Object_Size} for base subtypes reflect the natural hardware
9574 size in bits (run the compiler with @option{-gnatS} to find those values
9575 for numeric types). Enumeration types and fixed-point base subtypes have
9576 8, 16, 32 or 64 bits for this size, depending on the range of values
9577 to be stored.
9578
9579 @item
9580 The @code{Object_Size} of a subtype is the same as the
9581 @code{Object_Size} of
9582 the type from which it is obtained.
9583
9584 @item
9585 The @code{Object_Size} of a derived base type is copied from the parent
9586 base type, and the @code{Object_Size} of a derived first subtype is copied
9587 from the parent first subtype.
9588 @end itemize
9589
9590 @noindent
9591 The @code{Value_Size} attribute
9592 is the (minimum) number of bits required to store a value
9593 of the type.
9594 This value is used to determine how tightly to pack
9595 records or arrays with components of this type, and also affects
9596 the semantics of unchecked conversion (unchecked conversions where
9597 the @code{Value_Size} values differ generate a warning, and are potentially
9598 target dependent).
9599
9600 The default rules for the value of @code{Value_Size} are as follows:
9601
9602 @itemize @bullet
9603 @item
9604 The @code{Value_Size} for a base subtype is the minimum number of bits
9605 required to store all values of the type (including the sign bit
9606 only if negative values are possible).
9607
9608 @item
9609 If a subtype statically matches the first subtype of a given type, then it has
9610 by default the same @code{Value_Size} as the first subtype.  This is a
9611 consequence of RM 13.1(14) (``if two subtypes statically match,
9612 then their subtype-specific aspects are the same''.)
9613
9614 @item
9615 All other subtypes have a @code{Value_Size} corresponding to the minimum
9616 number of bits required to store all values of the subtype.  For
9617 dynamic bounds, it is assumed that the value can range down or up
9618 to the corresponding bound of the ancestor
9619 @end itemize
9620
9621 @noindent
9622 The RM defined attribute @code{Size} corresponds to the
9623 @code{Value_Size} attribute.
9624
9625 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9626 the @code{Value_Size} of
9627 the first-named subtype to the given value, and the
9628 @code{Object_Size} of this first-named subtype to the given value padded up
9629 to an appropriate boundary.  It is a consequence of the default rules
9630 above that this @code{Object_Size} will apply to all further subtypes.  On the
9631 other hand, @code{Value_Size} is affected only for the first subtype, any
9632 dynamic subtypes obtained from it directly, and any statically matching
9633 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9634
9635 @code{Value_Size} and
9636 @code{Object_Size} may be explicitly set for any subtype using
9637 an attribute definition clause.  Note that the use of these attributes
9638 can cause the RM 13.1(14) rule to be violated.  If two access types
9639 reference aliased objects whose subtypes have differing @code{Object_Size}
9640 values as a result of explicit attribute definition clauses, then it
9641 is erroneous to convert from one access subtype to the other.
9642
9643 At the implementation level, Esize stores the Object_Size and the
9644 RM_Size field stores the @code{Value_Size} (and hence the value of the
9645 @code{Size} attribute,
9646 which, as noted above, is equivalent to @code{Value_Size}).
9647
9648 To get a feel for the difference, consider the following examples (note
9649 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9650
9651 @smallexample
9652                                        Object_Size     Value_Size
9653
9654 type x1 is range 0 .. 5;                    8               3
9655
9656 type x2 is range 0 .. 5;
9657 for x2'size use 12;                        16              12
9658
9659 subtype x3 is x2 range 0 .. 3;             16               2
9660
9661 subtype x4 is x2'base range 0 .. 10;        8               4
9662
9663 subtype x5 is x2 range 0 .. dynamic;       16               3*
9664
9665 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9666
9667 @end smallexample
9668
9669 @noindent
9670 Note: the entries marked ``3*'' are not actually specified by the Ada
9671 Reference Manual, but it seems in the spirit of the RM rules to allocate
9672 the minimum number of bits (here 3, given the range for @code{x2})
9673 known to be large enough to hold the given range of values.
9674
9675 So far, so good, but GNAT has to obey the RM rules, so the question is
9676 under what conditions must the RM @code{Size} be used.
9677 The following is a list
9678 of the occasions on which the RM @code{Size} must be used:
9679
9680 @itemize @bullet
9681 @item
9682 Component size for packed arrays or records
9683
9684 @item
9685 Value of the attribute @code{Size} for a type
9686
9687 @item
9688 Warning about sizes not matching for unchecked conversion
9689 @end itemize
9690
9691 @noindent
9692 For record types, the @code{Object_Size} is always a multiple of the
9693 alignment of the type (this is true for all types). In some cases the
9694 @code{Value_Size} can be smaller. Consider:
9695
9696 @smallexample
9697    type R is record
9698      X : Integer;
9699      Y : Character;
9700    end record;
9701 @end smallexample
9702
9703 @noindent
9704 On a typical 32-bit architecture, the X component will be four bytes, and
9705 require four-byte alignment, and the Y component will be one byte. In this
9706 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9707 required to store a value of this type, and for example, it is permissible
9708 to have a component of type R in an outer record whose component size is
9709 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9710 since it must be rounded up so that this value is a multiple of the
9711 alignment (4 bytes = 32 bits).
9712
9713 @noindent
9714 For all other types, the @code{Object_Size}
9715 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9716 Only @code{Size} may be specified for such types.
9717
9718 @node Component_Size Clauses
9719 @section Component_Size Clauses
9720 @cindex Component_Size Clause
9721
9722 @noindent
9723 Normally, the value specified in a component size clause must be consistent
9724 with the subtype of the array component with regard to size and alignment.
9725 In other words, the value specified must be at least equal to the size
9726 of this subtype, and must be a multiple of the alignment value.
9727
9728 In addition, component size clauses are allowed which cause the array
9729 to be packed, by specifying a smaller value.  The cases in which this
9730 is allowed are for component size values in the range 1 through 63.  The value
9731 specified must not be smaller than the Size of the subtype.  GNAT will
9732 accurately honor all packing requests in this range.  For example, if
9733 we have:
9734
9735 @smallexample @c ada
9736 type r is array (1 .. 8) of Natural;
9737 for r'Component_Size use 31;
9738 @end smallexample
9739
9740 @noindent
9741 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9742 Of course access to the components of such an array is considerably
9743 less efficient than if the natural component size of 32 is used.
9744
9745 Note that there is no point in giving both a component size clause
9746 and a pragma Pack for the same array type. if such duplicate
9747 clauses are given, the pragma Pack will be ignored.
9748
9749 @node Bit_Order Clauses
9750 @section Bit_Order Clauses
9751 @cindex Bit_Order Clause
9752 @cindex bit ordering
9753 @cindex ordering, of bits
9754
9755 @noindent
9756 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9757 attribute.  The specification may either correspond to the default bit
9758 order for the target, in which case the specification has no effect and
9759 places no additional restrictions, or it may be for the non-standard
9760 setting (that is the opposite of the default).
9761
9762 In the case where the non-standard value is specified, the effect is
9763 to renumber bits within each byte, but the ordering of bytes is not
9764 affected.  There are certain
9765 restrictions placed on component clauses as follows:
9766
9767 @itemize @bullet
9768
9769 @item Components fitting within a single storage unit.
9770 @noindent
9771 These are unrestricted, and the effect is merely to renumber bits.  For
9772 example if we are on a little-endian machine with @code{Low_Order_First}
9773 being the default, then the following two declarations have exactly
9774 the same effect:
9775
9776 @smallexample @c ada
9777    type R1 is record
9778       A : Boolean;
9779       B : Integer range 1 .. 120;
9780    end record;
9781
9782    for R1 use record
9783       A at 0 range 0 .. 0;
9784       B at 0 range 1 .. 7;
9785    end record;
9786
9787    type R2 is record
9788       A : Boolean;
9789       B : Integer range 1 .. 120;
9790    end record;
9791
9792    for R2'Bit_Order use High_Order_First;
9793
9794    for R2 use record
9795       A at 0 range 7 .. 7;
9796       B at 0 range 0 .. 6;
9797    end record;
9798 @end smallexample
9799
9800 @noindent
9801 The useful application here is to write the second declaration with the
9802 @code{Bit_Order} attribute definition clause, and know that it will be treated
9803 the same, regardless of whether the target is little-endian or big-endian.
9804
9805 @item Components occupying an integral number of bytes.
9806 @noindent
9807 These are components that exactly fit in two or more bytes.  Such component
9808 declarations are allowed, but have no effect, since it is important to realize
9809 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9810 In particular, the following attempt at getting an endian-independent integer
9811 does not work:
9812
9813 @smallexample @c ada
9814    type R2 is record
9815       A : Integer;
9816    end record;
9817
9818    for R2'Bit_Order use High_Order_First;
9819
9820    for R2 use record
9821       A at 0 range 0 .. 31;
9822    end record;
9823 @end smallexample
9824
9825 @noindent
9826 This declaration will result in a little-endian integer on a
9827 little-endian machine, and a big-endian integer on a big-endian machine.
9828 If byte flipping is required for interoperability between big- and
9829 little-endian machines, this must be explicitly programmed.  This capability
9830 is not provided by @code{Bit_Order}.
9831
9832 @item Components that are positioned across byte boundaries
9833 @noindent
9834 but do not occupy an integral number of bytes.  Given that bytes are not
9835 reordered, such fields would occupy a non-contiguous sequence of bits
9836 in memory, requiring non-trivial code to reassemble.  They are for this
9837 reason not permitted, and any component clause specifying such a layout
9838 will be flagged as illegal by GNAT@.
9839
9840 @end itemize
9841
9842 @noindent
9843 Since the misconception that Bit_Order automatically deals with all
9844 endian-related incompatibilities is a common one, the specification of
9845 a component field that is an integral number of bytes will always
9846 generate a warning.  This warning may be suppressed using
9847 @code{pragma Suppress} if desired.  The following section contains additional
9848 details regarding the issue of byte ordering.
9849
9850 @node Effect of Bit_Order on Byte Ordering
9851 @section Effect of Bit_Order on Byte Ordering
9852 @cindex byte ordering
9853 @cindex ordering, of bytes
9854
9855 @noindent
9856 In this section we will review the effect of the @code{Bit_Order} attribute
9857 definition clause on byte ordering.  Briefly, it has no effect at all, but
9858 a detailed example will be helpful.  Before giving this
9859 example, let us review the precise
9860 definition of the effect of defining @code{Bit_Order}.  The effect of a
9861 non-standard bit order is described in section 15.5.3 of the Ada
9862 Reference Manual:
9863
9864 @quotation
9865 2   A bit ordering is a method of interpreting the meaning of
9866 the storage place attributes.
9867 @end quotation
9868
9869 @noindent
9870 To understand the precise definition of storage place attributes in
9871 this context, we visit section 13.5.1 of the manual:
9872
9873 @quotation
9874 13   A record_representation_clause (without the mod_clause)
9875 specifies the layout.  The storage place attributes (see 13.5.2)
9876 are taken from the values of the position, first_bit, and last_bit
9877 expressions after normalizing those values so that first_bit is
9878 less than Storage_Unit.
9879 @end quotation
9880
9881 @noindent
9882 The critical point here is that storage places are taken from
9883 the values after normalization, not before.  So the @code{Bit_Order}
9884 interpretation applies to normalized values.  The interpretation
9885 is described in the later part of the 15.5.3 paragraph:
9886
9887 @quotation
9888 2   A bit ordering is a method of interpreting the meaning of
9889 the storage place attributes.  High_Order_First (known in the
9890 vernacular as ``big endian'') means that the first bit of a
9891 storage element (bit 0) is the most significant bit (interpreting
9892 the sequence of bits that represent a component as an unsigned
9893 integer value).  Low_Order_First (known in the vernacular as
9894 ``little endian'') means the opposite: the first bit is the
9895 least significant.
9896 @end quotation
9897
9898 @noindent
9899 Note that the numbering is with respect to the bits of a storage
9900 unit.  In other words, the specification affects only the numbering
9901 of bits within a single storage unit.
9902
9903 We can make the effect clearer by giving an example.
9904
9905 Suppose that we have an external device which presents two bytes, the first
9906 byte presented, which is the first (low addressed byte) of the two byte
9907 record is called Master, and the second byte is called Slave.
9908
9909 The left most (most significant bit is called Control for each byte, and
9910 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9911 (least significant) bit.
9912
9913 On a big-endian machine, we can write the following representation clause
9914
9915 @smallexample @c ada
9916    type Data is record
9917       Master_Control : Bit;
9918       Master_V1      : Bit;
9919       Master_V2      : Bit;
9920       Master_V3      : Bit;
9921       Master_V4      : Bit;
9922       Master_V5      : Bit;
9923       Master_V6      : Bit;
9924       Master_V7      : Bit;
9925       Slave_Control  : Bit;
9926       Slave_V1       : Bit;
9927       Slave_V2       : Bit;
9928       Slave_V3       : Bit;
9929       Slave_V4       : Bit;
9930       Slave_V5       : Bit;
9931       Slave_V6       : Bit;
9932       Slave_V7       : Bit;
9933    end record;
9934
9935    for Data use record
9936       Master_Control at 0 range 0 .. 0;
9937       Master_V1      at 0 range 1 .. 1;
9938       Master_V2      at 0 range 2 .. 2;
9939       Master_V3      at 0 range 3 .. 3;
9940       Master_V4      at 0 range 4 .. 4;
9941       Master_V5      at 0 range 5 .. 5;
9942       Master_V6      at 0 range 6 .. 6;
9943       Master_V7      at 0 range 7 .. 7;
9944       Slave_Control  at 1 range 0 .. 0;
9945       Slave_V1       at 1 range 1 .. 1;
9946       Slave_V2       at 1 range 2 .. 2;
9947       Slave_V3       at 1 range 3 .. 3;
9948       Slave_V4       at 1 range 4 .. 4;
9949       Slave_V5       at 1 range 5 .. 5;
9950       Slave_V6       at 1 range 6 .. 6;
9951       Slave_V7       at 1 range 7 .. 7;
9952    end record;
9953 @end smallexample
9954
9955 @noindent
9956 Now if we move this to a little endian machine, then the bit ordering within
9957 the byte is backwards, so we have to rewrite the record rep clause as:
9958
9959 @smallexample @c ada
9960    for Data use record
9961       Master_Control at 0 range 7 .. 7;
9962       Master_V1      at 0 range 6 .. 6;
9963       Master_V2      at 0 range 5 .. 5;
9964       Master_V3      at 0 range 4 .. 4;
9965       Master_V4      at 0 range 3 .. 3;
9966       Master_V5      at 0 range 2 .. 2;
9967       Master_V6      at 0 range 1 .. 1;
9968       Master_V7      at 0 range 0 .. 0;
9969       Slave_Control  at 1 range 7 .. 7;
9970       Slave_V1       at 1 range 6 .. 6;
9971       Slave_V2       at 1 range 5 .. 5;
9972       Slave_V3       at 1 range 4 .. 4;
9973       Slave_V4       at 1 range 3 .. 3;
9974       Slave_V5       at 1 range 2 .. 2;
9975       Slave_V6       at 1 range 1 .. 1;
9976       Slave_V7       at 1 range 0 .. 0;
9977    end record;
9978 @end smallexample
9979
9980 @noindent
9981 It is a nuisance to have to rewrite the clause, especially if
9982 the code has to be maintained on both machines.  However,
9983 this is a case that we can handle with the
9984 @code{Bit_Order} attribute if it is implemented.
9985 Note that the implementation is not required on byte addressed
9986 machines, but it is indeed implemented in GNAT.
9987 This means that we can simply use the
9988 first record clause, together with the declaration
9989
9990 @smallexample @c ada
9991    for Data'Bit_Order use High_Order_First;
9992 @end smallexample
9993
9994 @noindent
9995 and the effect is what is desired, namely the layout is exactly the same,
9996 independent of whether the code is compiled on a big-endian or little-endian
9997 machine.
9998
9999 The important point to understand is that byte ordering is not affected.
10000 A @code{Bit_Order} attribute definition never affects which byte a field
10001 ends up in, only where it ends up in that byte.
10002 To make this clear, let us rewrite the record rep clause of the previous
10003 example as:
10004
10005 @smallexample @c ada
10006    for Data'Bit_Order use High_Order_First;
10007    for Data use record
10008       Master_Control at 0 range  0 .. 0;
10009       Master_V1      at 0 range  1 .. 1;
10010       Master_V2      at 0 range  2 .. 2;
10011       Master_V3      at 0 range  3 .. 3;
10012       Master_V4      at 0 range  4 .. 4;
10013       Master_V5      at 0 range  5 .. 5;
10014       Master_V6      at 0 range  6 .. 6;
10015       Master_V7      at 0 range  7 .. 7;
10016       Slave_Control  at 0 range  8 .. 8;
10017       Slave_V1       at 0 range  9 .. 9;
10018       Slave_V2       at 0 range 10 .. 10;
10019       Slave_V3       at 0 range 11 .. 11;
10020       Slave_V4       at 0 range 12 .. 12;
10021       Slave_V5       at 0 range 13 .. 13;
10022       Slave_V6       at 0 range 14 .. 14;
10023       Slave_V7       at 0 range 15 .. 15;
10024    end record;
10025 @end smallexample
10026
10027 @noindent
10028 This is exactly equivalent to saying (a repeat of the first example):
10029
10030 @smallexample @c ada
10031    for Data'Bit_Order use High_Order_First;
10032    for Data use record
10033       Master_Control at 0 range 0 .. 0;
10034       Master_V1      at 0 range 1 .. 1;
10035       Master_V2      at 0 range 2 .. 2;
10036       Master_V3      at 0 range 3 .. 3;
10037       Master_V4      at 0 range 4 .. 4;
10038       Master_V5      at 0 range 5 .. 5;
10039       Master_V6      at 0 range 6 .. 6;
10040       Master_V7      at 0 range 7 .. 7;
10041       Slave_Control  at 1 range 0 .. 0;
10042       Slave_V1       at 1 range 1 .. 1;
10043       Slave_V2       at 1 range 2 .. 2;
10044       Slave_V3       at 1 range 3 .. 3;
10045       Slave_V4       at 1 range 4 .. 4;
10046       Slave_V5       at 1 range 5 .. 5;
10047       Slave_V6       at 1 range 6 .. 6;
10048       Slave_V7       at 1 range 7 .. 7;
10049    end record;
10050 @end smallexample
10051
10052 @noindent
10053 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10054 field.  The storage place attributes are obtained by normalizing the
10055 values given so that the @code{First_Bit} value is less than 8.  After
10056 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10057 we specified in the other case.
10058
10059 Now one might expect that the @code{Bit_Order} attribute might affect
10060 bit numbering within the entire record component (two bytes in this
10061 case, thus affecting which byte fields end up in), but that is not
10062 the way this feature is defined, it only affects numbering of bits,
10063 not which byte they end up in.
10064
10065 Consequently it never makes sense to specify a starting bit number
10066 greater than 7 (for a byte addressable field) if an attribute
10067 definition for @code{Bit_Order} has been given, and indeed it
10068 may be actively confusing to specify such a value, so the compiler
10069 generates a warning for such usage.
10070
10071 If you do need to control byte ordering then appropriate conditional
10072 values must be used.  If in our example, the slave byte came first on
10073 some machines we might write:
10074
10075 @smallexample @c ada
10076    Master_Byte_First constant Boolean := @dots{};
10077
10078    Master_Byte : constant Natural :=
10079                    1 - Boolean'Pos (Master_Byte_First);
10080    Slave_Byte  : constant Natural :=
10081                    Boolean'Pos (Master_Byte_First);
10082
10083    for Data'Bit_Order use High_Order_First;
10084    for Data use record
10085       Master_Control at Master_Byte range 0 .. 0;
10086       Master_V1      at Master_Byte range 1 .. 1;
10087       Master_V2      at Master_Byte range 2 .. 2;
10088       Master_V3      at Master_Byte range 3 .. 3;
10089       Master_V4      at Master_Byte range 4 .. 4;
10090       Master_V5      at Master_Byte range 5 .. 5;
10091       Master_V6      at Master_Byte range 6 .. 6;
10092       Master_V7      at Master_Byte range 7 .. 7;
10093       Slave_Control  at Slave_Byte  range 0 .. 0;
10094       Slave_V1       at Slave_Byte  range 1 .. 1;
10095       Slave_V2       at Slave_Byte  range 2 .. 2;
10096       Slave_V3       at Slave_Byte  range 3 .. 3;
10097       Slave_V4       at Slave_Byte  range 4 .. 4;
10098       Slave_V5       at Slave_Byte  range 5 .. 5;
10099       Slave_V6       at Slave_Byte  range 6 .. 6;
10100       Slave_V7       at Slave_Byte  range 7 .. 7;
10101    end record;
10102 @end smallexample
10103
10104 @noindent
10105 Now to switch between machines, all that is necessary is
10106 to set the boolean constant @code{Master_Byte_First} in
10107 an appropriate manner.
10108
10109 @node Pragma Pack for Arrays
10110 @section Pragma Pack for Arrays
10111 @cindex Pragma Pack (for arrays)
10112
10113 @noindent
10114 Pragma @code{Pack} applied to an array has no effect unless the component type
10115 is packable.  For a component type to be packable, it must be one of the
10116 following cases:
10117
10118 @itemize @bullet
10119 @item
10120 Any scalar type
10121 @item
10122 Any type whose size is specified with a size clause
10123 @item
10124 Any packed array type with a static size
10125 @end itemize
10126
10127 @noindent
10128 For all these cases, if the component subtype size is in the range
10129 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10130 component size were specified giving the component subtype size.
10131 For example if we have:
10132
10133 @smallexample @c ada
10134    type r is range 0 .. 17;
10135
10136    type ar is array (1 .. 8) of r;
10137    pragma Pack (ar);
10138 @end smallexample
10139
10140 @noindent
10141 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10142 and the size of the array @code{ar} will be exactly 40 bits.
10143
10144 Note that in some cases this rather fierce approach to packing can produce
10145 unexpected effects.  For example, in Ada 95 and Ada 2005,
10146 subtype @code{Natural} typically has a size of 31, meaning that if you
10147 pack an array of @code{Natural}, you get 31-bit
10148 close packing, which saves a few bits, but results in far less efficient
10149 access.  Since many other Ada compilers will ignore such a packing request,
10150 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10151 might not be what is intended.  You can easily remove this warning by
10152 using an explicit @code{Component_Size} setting instead, which never generates
10153 a warning, since the intention of the programmer is clear in this case.
10154
10155 GNAT treats packed arrays in one of two ways.  If the size of the array is
10156 known at compile time and is less than 64 bits, then internally the array
10157 is represented as a single modular type, of exactly the appropriate number
10158 of bits.  If the length is greater than 63 bits, or is not known at compile
10159 time, then the packed array is represented as an array of bytes, and the
10160 length is always a multiple of 8 bits.
10161
10162 Note that to represent a packed array as a modular type, the alignment must
10163 be suitable for the modular type involved. For example, on typical machines
10164 a 32-bit packed array will be represented by a 32-bit modular integer with
10165 an alignment of four bytes. If you explicitly override the default alignment
10166 with an alignment clause that is too small, the modular representation
10167 cannot be used. For example, consider the following set of declarations:
10168
10169 @smallexample @c ada
10170    type R is range 1 .. 3;
10171    type S is array (1 .. 31) of R;
10172    for S'Component_Size use 2;
10173    for S'Size use 62;
10174    for S'Alignment use 1;
10175 @end smallexample
10176
10177 @noindent
10178 If the alignment clause were not present, then a 62-bit modular
10179 representation would be chosen (typically with an alignment of 4 or 8
10180 bytes depending on the target). But the default alignment is overridden
10181 with the explicit alignment clause. This means that the modular
10182 representation cannot be used, and instead the array of bytes
10183 representation must be used, meaning that the length must be a multiple
10184 of 8. Thus the above set of declarations will result in a diagnostic
10185 rejecting the size clause and noting that the minimum size allowed is 64.
10186
10187 @cindex Pragma Pack (for type Natural)
10188 @cindex Pragma Pack warning
10189
10190 One special case that is worth noting occurs when the base type of the
10191 component size is 8/16/32 and the subtype is one bit less. Notably this
10192 occurs with subtype @code{Natural}. Consider:
10193
10194 @smallexample @c ada
10195    type Arr is array (1 .. 32) of Natural;
10196    pragma Pack (Arr);
10197 @end smallexample
10198
10199 @noindent
10200 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10201 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10202 Ada 83 compilers did not attempt 31 bit packing.
10203
10204 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10205 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10206 substantial unintended performance penalty when porting legacy Ada 83 code.
10207 To help prevent this, GNAT generates a warning in such cases. If you really
10208 want 31 bit packing in a case like this, you can set the component size
10209 explicitly:
10210
10211 @smallexample @c ada
10212    type Arr is array (1 .. 32) of Natural;
10213    for Arr'Component_Size use 31;
10214 @end smallexample
10215
10216 @noindent
10217 Here 31-bit packing is achieved as required, and no warning is generated,
10218 since in this case the programmer intention is clear.
10219
10220 @node Pragma Pack for Records
10221 @section Pragma Pack for Records
10222 @cindex Pragma Pack (for records)
10223
10224 @noindent
10225 Pragma @code{Pack} applied to a record will pack the components to reduce
10226 wasted space from alignment gaps and by reducing the amount of space
10227 taken by components.  We distinguish between @emph{packable} components and
10228 @emph{non-packable} components.
10229 Components of the following types are considered packable:
10230 @itemize @bullet
10231 @item
10232 All primitive types are packable.
10233
10234 @item
10235 Small packed arrays, whose size does not exceed 64 bits, and where the
10236 size is statically known at compile time, are represented internally
10237 as modular integers, and so they are also packable.
10238
10239 @end itemize
10240
10241 @noindent
10242 All packable components occupy the exact number of bits corresponding to
10243 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10244 can start on an arbitrary bit boundary.
10245
10246 All other types are non-packable, they occupy an integral number of
10247 storage units, and
10248 are placed at a boundary corresponding to their alignment requirements.
10249
10250 For example, consider the record
10251
10252 @smallexample @c ada
10253    type Rb1 is array (1 .. 13) of Boolean;
10254    pragma Pack (rb1);
10255
10256    type Rb2 is array (1 .. 65) of Boolean;
10257    pragma Pack (rb2);
10258
10259    type x2 is record
10260       l1 : Boolean;
10261       l2 : Duration;
10262       l3 : Float;
10263       l4 : Boolean;
10264       l5 : Rb1;
10265       l6 : Rb2;
10266    end record;
10267    pragma Pack (x2);
10268 @end smallexample
10269
10270 @noindent
10271 The representation for the record x2 is as follows:
10272
10273 @smallexample @c ada
10274 for x2'Size use 224;
10275 for x2 use record
10276    l1 at  0 range  0 .. 0;
10277    l2 at  0 range  1 .. 64;
10278    l3 at 12 range  0 .. 31;
10279    l4 at 16 range  0 .. 0;
10280    l5 at 16 range  1 .. 13;
10281    l6 at 18 range  0 .. 71;
10282 end record;
10283 @end smallexample
10284
10285 @noindent
10286 Studying this example, we see that the packable fields @code{l1}
10287 and @code{l2} are
10288 of length equal to their sizes, and placed at specific bit boundaries (and
10289 not byte boundaries) to
10290 eliminate padding.  But @code{l3} is of a non-packable float type, so
10291 it is on the next appropriate alignment boundary.
10292
10293 The next two fields are fully packable, so @code{l4} and @code{l5} are
10294 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10295 array that is longer than 64 bits, so it is itself non-packable.  Thus
10296 the @code{l6} field is aligned to the next byte boundary, and takes an
10297 integral number of bytes, i.e.@: 72 bits.
10298
10299 @node Record Representation Clauses
10300 @section Record Representation Clauses
10301 @cindex Record Representation Clause
10302
10303 @noindent
10304 Record representation clauses may be given for all record types, including
10305 types obtained by record extension.  Component clauses are allowed for any
10306 static component.  The restrictions on component clauses depend on the type
10307 of the component.
10308
10309 @cindex Component Clause
10310 For all components of an elementary type, the only restriction on component
10311 clauses is that the size must be at least the 'Size value of the type
10312 (actually the Value_Size).  There are no restrictions due to alignment,
10313 and such components may freely cross storage boundaries.
10314
10315 Packed arrays with a size up to and including 64 bits are represented
10316 internally using a modular type with the appropriate number of bits, and
10317 thus the same lack of restriction applies.  For example, if you declare:
10318
10319 @smallexample @c ada
10320    type R is array (1 .. 49) of Boolean;
10321    pragma Pack (R);
10322    for R'Size use 49;
10323 @end smallexample
10324
10325 @noindent
10326 then a component clause for a component of type R may start on any
10327 specified bit boundary, and may specify a value of 49 bits or greater.
10328
10329 For packed bit arrays that are longer than 64 bits, there are two
10330 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10331 including the important case of single bits or boolean values, then
10332 there are no limitations on placement of such components, and they
10333 may start and end at arbitrary bit boundaries.
10334
10335 If the component size is not a power of 2 (e.g. 3 or 5), then
10336 an array of this type longer than 64 bits must always be placed on
10337 on a storage unit (byte) boundary and occupy an integral number
10338 of storage units (bytes). Any component clause that does not
10339 meet this requirement will be rejected.
10340
10341 Any aliased component, or component of an aliased type, must
10342 have its normal alignment and size. A component clause that
10343 does not meet this requirement will be rejected.
10344
10345 The tag field of a tagged type always occupies an address sized field at
10346 the start of the record.  No component clause may attempt to overlay this
10347 tag. When a tagged type appears as a component, the tag field must have
10348 proper alignment
10349
10350 In the case of a record extension T1, of a type T, no component clause applied
10351 to the type T1 can specify a storage location that would overlap the first
10352 T'Size bytes of the record.
10353
10354 For all other component types, including non-bit-packed arrays,
10355 the component can be placed at an arbitrary bit boundary,
10356 so for example, the following is permitted:
10357
10358 @smallexample @c ada
10359    type R is array (1 .. 10) of Boolean;
10360    for R'Size use 80;
10361
10362    type Q is record
10363       G, H : Boolean;
10364       L, M : R;
10365    end record;
10366
10367    for Q use record
10368       G at 0 range  0 ..   0;
10369       H at 0 range  1 ..   1;
10370       L at 0 range  2 ..  81;
10371       R at 0 range 82 .. 161;
10372    end record;
10373 @end smallexample
10374
10375 @noindent
10376 Note: the above rules apply to recent releases of GNAT 5.
10377 In GNAT 3, there are more severe restrictions on larger components.
10378 For non-primitive types, including packed arrays with a size greater than
10379 64 bits, component clauses must respect the alignment requirement of the
10380 type, in particular, always starting on a byte boundary, and the length
10381 must be a multiple of the storage unit.
10382
10383 @node Enumeration Clauses
10384 @section Enumeration Clauses
10385
10386 The only restriction on enumeration clauses is that the range of values
10387 must be representable.  For the signed case, if one or more of the
10388 representation values are negative, all values must be in the range:
10389
10390 @smallexample @c ada
10391    System.Min_Int .. System.Max_Int
10392 @end smallexample
10393
10394 @noindent
10395 For the unsigned case, where all values are non negative, the values must
10396 be in the range:
10397
10398 @smallexample @c ada
10399    0 .. System.Max_Binary_Modulus;
10400 @end smallexample
10401
10402 @noindent
10403 A @emph{confirming} representation clause is one in which the values range
10404 from 0 in sequence, i.e.@: a clause that confirms the default representation
10405 for an enumeration type.
10406 Such a confirming representation
10407 is permitted by these rules, and is specially recognized by the compiler so
10408 that no extra overhead results from the use of such a clause.
10409
10410 If an array has an index type which is an enumeration type to which an
10411 enumeration clause has been applied, then the array is stored in a compact
10412 manner.  Consider the declarations:
10413
10414 @smallexample @c ada
10415    type r is (A, B, C);
10416    for r use (A => 1, B => 5, C => 10);
10417    type t is array (r) of Character;
10418 @end smallexample
10419
10420 @noindent
10421 The array type t corresponds to a vector with exactly three elements and
10422 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10423 use of space, but means that accesses to elements of the array will incur
10424 the overhead of converting representation values to the corresponding
10425 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10426
10427 @node Address Clauses
10428 @section Address Clauses
10429 @cindex Address Clause
10430
10431 The reference manual allows a general restriction on representation clauses,
10432 as found in RM 13.1(22):
10433
10434 @quotation
10435 An implementation need not support representation
10436 items containing nonstatic expressions, except that
10437 an implementation should support a representation item
10438 for a given entity if each nonstatic expression in the
10439 representation item is a name that statically denotes
10440 a constant declared before the entity.
10441 @end quotation
10442
10443 @noindent
10444 In practice this is applicable only to address clauses, since this is the
10445 only case in which a non-static expression is permitted by the syntax.  As
10446 the AARM notes in sections 13.1 (22.a-22.h):
10447
10448 @display
10449   22.a   Reason: This is to avoid the following sort of thing:
10450
10451   22.b        X : Integer := F(@dots{});
10452               Y : Address := G(@dots{});
10453               for X'Address use Y;
10454
10455   22.c   In the above, we have to evaluate the
10456          initialization expression for X before we
10457          know where to put the result.  This seems
10458          like an unreasonable implementation burden.
10459
10460   22.d   The above code should instead be written
10461          like this:
10462
10463   22.e        Y : constant Address := G(@dots{});
10464               X : Integer := F(@dots{});
10465               for X'Address use Y;
10466
10467   22.f   This allows the expression ``Y'' to be safely
10468          evaluated before X is created.
10469
10470   22.g   The constant could be a formal parameter of mode in.
10471
10472   22.h   An implementation can support other nonstatic
10473          expressions if it wants to.  Expressions of type
10474          Address are hardly ever static, but their value
10475          might be known at compile time anyway in many
10476          cases.
10477 @end display
10478
10479 @noindent
10480 GNAT does indeed permit many additional cases of non-static expressions.  In
10481 particular, if the type involved is elementary there are no restrictions
10482 (since in this case, holding a temporary copy of the initialization value,
10483 if one is present, is inexpensive).  In addition, if there is no implicit or
10484 explicit initialization, then there are no restrictions.  GNAT will reject
10485 only the case where all three of these conditions hold:
10486
10487 @itemize @bullet
10488
10489 @item
10490 The type of the item is non-elementary (e.g.@: a record or array).
10491
10492 @item
10493 There is explicit or implicit initialization required for the object.
10494 Note that access values are always implicitly initialized, and also
10495 in GNAT, certain bit-packed arrays (those having a dynamic length or
10496 a length greater than 64) will also be implicitly initialized to zero.
10497
10498 @item
10499 The address value is non-static.  Here GNAT is more permissive than the
10500 RM, and allows the address value to be the address of a previously declared
10501 stand-alone variable, as long as it does not itself have an address clause.
10502
10503 @smallexample @c ada
10504            Anchor  : Some_Initialized_Type;
10505            Overlay : Some_Initialized_Type;
10506            for Overlay'Address use Anchor'Address;
10507 @end smallexample
10508
10509 @noindent
10510 However, the prefix of the address clause cannot be an array component, or
10511 a component of a discriminated record.
10512
10513 @end itemize
10514
10515 @noindent
10516 As noted above in section 22.h, address values are typically non-static.  In
10517 particular the To_Address function, even if applied to a literal value, is
10518 a non-static function call.  To avoid this minor annoyance, GNAT provides
10519 the implementation defined attribute 'To_Address.  The following two
10520 expressions have identical values:
10521
10522 @findex Attribute
10523 @findex To_Address
10524 @smallexample @c ada
10525    To_Address (16#1234_0000#)
10526    System'To_Address (16#1234_0000#);
10527 @end smallexample
10528
10529 @noindent
10530 except that the second form is considered to be a static expression, and
10531 thus when used as an address clause value is always permitted.
10532
10533 @noindent
10534 Additionally, GNAT treats as static an address clause that is an
10535 unchecked_conversion of a static integer value.  This simplifies the porting
10536 of legacy code, and provides a portable equivalent to the GNAT attribute
10537 @code{To_Address}.
10538
10539 Another issue with address clauses is the interaction with alignment
10540 requirements.  When an address clause is given for an object, the address
10541 value must be consistent with the alignment of the object (which is usually
10542 the same as the alignment of the type of the object).  If an address clause
10543 is given that specifies an inappropriately aligned address value, then the
10544 program execution is erroneous.
10545
10546 Since this source of erroneous behavior can have unfortunate effects, GNAT
10547 checks (at compile time if possible, generating a warning, or at execution
10548 time with a run-time check) that the alignment is appropriate.  If the
10549 run-time check fails, then @code{Program_Error} is raised.  This run-time
10550 check is suppressed if range checks are suppressed, or if the special GNAT
10551 check Alignment_Check is suppressed, or if
10552 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10553
10554 @findex Export
10555 An address clause cannot be given for an exported object.  More
10556 understandably the real restriction is that objects with an address
10557 clause cannot be exported.  This is because such variables are not
10558 defined by the Ada program, so there is no external object to export.
10559
10560 @findex Import
10561 It is permissible to give an address clause and a pragma Import for the
10562 same object.  In this case, the variable is not really defined by the
10563 Ada program, so there is no external symbol to be linked.  The link name
10564 and the external name are ignored in this case.  The reason that we allow this
10565 combination is that it provides a useful idiom to avoid unwanted
10566 initializations on objects with address clauses.
10567
10568 When an address clause is given for an object that has implicit or
10569 explicit initialization, then by default initialization takes place.  This
10570 means that the effect of the object declaration is to overwrite the
10571 memory at the specified address.  This is almost always not what the
10572 programmer wants, so GNAT will output a warning:
10573
10574 @smallexample
10575   with System;
10576   package G is
10577      type R is record
10578         M : Integer := 0;
10579      end record;
10580
10581      Ext : R;
10582      for Ext'Address use System'To_Address (16#1234_1234#);
10583          |
10584   >>> warning: implicit initialization of "Ext" may
10585       modify overlaid storage
10586   >>> warning: use pragma Import for "Ext" to suppress
10587       initialization (RM B(24))
10588
10589   end G;
10590 @end smallexample
10591
10592 @noindent
10593 As indicated by the warning message, the solution is to use a (dummy) pragma
10594 Import to suppress this initialization.  The pragma tell the compiler that the
10595 object is declared and initialized elsewhere.  The following package compiles
10596 without warnings (and the initialization is suppressed):
10597
10598 @smallexample @c ada
10599    with System;
10600    package G is
10601       type R is record
10602          M : Integer := 0;
10603       end record;
10604
10605       Ext : R;
10606       for Ext'Address use System'To_Address (16#1234_1234#);
10607       pragma Import (Ada, Ext);
10608    end G;
10609 @end smallexample
10610
10611 @noindent
10612 A final issue with address clauses involves their use for overlaying
10613 variables, as in the following example:
10614 @cindex Overlaying of objects
10615
10616 @smallexample @c ada
10617   A : Integer;
10618   B : Integer;
10619   for B'Address use A'Address;
10620 @end smallexample
10621
10622 @noindent
10623 or alternatively, using the form recommended by the RM:
10624
10625 @smallexample @c ada
10626   A    : Integer;
10627   Addr : constant Address := A'Address;
10628   B    : Integer;
10629   for B'Address use Addr;
10630 @end smallexample
10631
10632 @noindent
10633 In both of these cases, @code{A}
10634 and @code{B} become aliased to one another via the
10635 address clause. This use of address clauses to overlay
10636 variables, achieving an effect similar to unchecked
10637 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10638 the effect is implementation defined. Furthermore, the
10639 Ada RM specifically recommends that in a situation
10640 like this, @code{B} should be subject to the following
10641 implementation advice (RM 13.3(19)):
10642
10643 @quotation
10644 19  If the Address of an object is specified, or it is imported
10645     or exported, then the implementation should not perform
10646     optimizations based on assumptions of no aliases.
10647 @end quotation
10648
10649 @noindent
10650 GNAT follows this recommendation, and goes further by also applying
10651 this recommendation to the overlaid variable (@code{A}
10652 in the above example) in this case. This means that the overlay
10653 works "as expected", in that a modification to one of the variables
10654 will affect the value of the other.
10655
10656 @node Effect of Convention on Representation
10657 @section Effect of Convention on Representation
10658 @cindex Convention, effect on representation
10659
10660 @noindent
10661 Normally the specification of a foreign language convention for a type or
10662 an object has no effect on the chosen representation.  In particular, the
10663 representation chosen for data in GNAT generally meets the standard system
10664 conventions, and for example records are laid out in a manner that is
10665 consistent with C@.  This means that specifying convention C (for example)
10666 has no effect.
10667
10668 There are four exceptions to this general rule:
10669
10670 @itemize @bullet
10671
10672 @item Convention Fortran and array subtypes
10673 If pragma Convention Fortran is specified for an array subtype, then in
10674 accordance with the implementation advice in section 3.6.2(11) of the
10675 Ada Reference Manual, the array will be stored in a Fortran-compatible
10676 column-major manner, instead of the normal default row-major order.
10677
10678 @item Convention C and enumeration types
10679 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10680 to accommodate all values of the type.  For example, for the enumeration
10681 type declared by:
10682
10683 @smallexample @c ada
10684    type Color is (Red, Green, Blue);
10685 @end smallexample
10686
10687 @noindent
10688 8 bits is sufficient to store all values of the type, so by default, objects
10689 of type @code{Color} will be represented using 8 bits.  However, normal C
10690 convention is to use 32 bits for all enum values in C, since enum values
10691 are essentially of type int.  If pragma @code{Convention C} is specified for an
10692 Ada enumeration type, then the size is modified as necessary (usually to
10693 32 bits) to be consistent with the C convention for enum values.
10694
10695 Note that this treatment applies only to types. If Convention C is given for
10696 an enumeration object, where the enumeration type is not Convention C, then
10697 Object_Size bits are allocated. For example, for a normal enumeration type,
10698 with less than 256 elements, only 8 bits will be allocated for the object.
10699 Since this may be a surprise in terms of what C expects, GNAT will issue a
10700 warning in this situation. The warning can be suppressed by giving an explicit
10701 size clause specifying the desired size.
10702
10703 @item Convention C/Fortran and Boolean types
10704 In C, the usual convention for boolean values, that is values used for
10705 conditions, is that zero represents false, and nonzero values represent
10706 true.  In Ada, the normal convention is that two specific values, typically
10707 0/1, are used to represent false/true respectively.
10708
10709 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10710 value represents true).
10711
10712 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10713 C or Fortran convention for a derived Boolean, as in the following example:
10714
10715 @smallexample @c ada
10716    type C_Switch is new Boolean;
10717    pragma Convention (C, C_Switch);
10718 @end smallexample
10719
10720 @noindent
10721 then the GNAT generated code will treat any nonzero value as true.  For truth
10722 values generated by GNAT, the conventional value 1 will be used for True, but
10723 when one of these values is read, any nonzero value is treated as True.
10724
10725 @item Access types on OpenVMS
10726 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10727 arrays) are 64-bits long. An exception to this rule is for the case of
10728 C-convention access types where there is no explicit size clause present (or
10729 inherited for derived types). In this case, GNAT chooses to make these
10730 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10731 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10732
10733 @end itemize
10734
10735 @node Determining the Representations chosen by GNAT
10736 @section Determining the Representations chosen by GNAT
10737 @cindex Representation, determination of
10738 @cindex @code{-gnatR} switch
10739
10740 @noindent
10741 Although the descriptions in this section are intended to be complete, it is
10742 often easier to simply experiment to see what GNAT accepts and what the
10743 effect is on the layout of types and objects.
10744
10745 As required by the Ada RM, if a representation clause is not accepted, then
10746 it must be rejected as illegal by the compiler.  However, when a
10747 representation clause or pragma is accepted, there can still be questions
10748 of what the compiler actually does.  For example, if a partial record
10749 representation clause specifies the location of some components and not
10750 others, then where are the non-specified components placed? Or if pragma
10751 @code{Pack} is used on a record, then exactly where are the resulting
10752 fields placed? The section on pragma @code{Pack} in this chapter can be
10753 used to answer the second question, but it is often easier to just see
10754 what the compiler does.
10755
10756 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10757 with this option, then the compiler will output information on the actual
10758 representations chosen, in a format similar to source representation
10759 clauses.  For example, if we compile the package:
10760
10761 @smallexample @c ada
10762 package q is
10763    type r (x : boolean) is tagged record
10764       case x is
10765          when True => S : String (1 .. 100);
10766          when False => null;
10767       end case;
10768    end record;
10769
10770    type r2 is new r (false) with record
10771       y2 : integer;
10772    end record;
10773
10774    for r2 use record
10775       y2 at 16 range 0 .. 31;
10776    end record;
10777
10778    type x is record
10779       y : character;
10780    end record;
10781
10782    type x1 is array (1 .. 10) of x;
10783    for x1'component_size use 11;
10784
10785    type ia is access integer;
10786
10787    type Rb1 is array (1 .. 13) of Boolean;
10788    pragma Pack (rb1);
10789
10790    type Rb2 is array (1 .. 65) of Boolean;
10791    pragma Pack (rb2);
10792
10793    type x2 is record
10794       l1 : Boolean;
10795       l2 : Duration;
10796       l3 : Float;
10797       l4 : Boolean;
10798       l5 : Rb1;
10799       l6 : Rb2;
10800    end record;
10801    pragma Pack (x2);
10802 end q;
10803 @end smallexample
10804
10805 @noindent
10806 using the switch @code{-gnatR} we obtain the following output:
10807
10808 @smallexample
10809 Representation information for unit q
10810 -------------------------------------
10811
10812 for r'Size use ??;
10813 for r'Alignment use 4;
10814 for r use record
10815    x    at 4 range  0 .. 7;
10816    _tag at 0 range  0 .. 31;
10817    s    at 5 range  0 .. 799;
10818 end record;
10819
10820 for r2'Size use 160;
10821 for r2'Alignment use 4;
10822 for r2 use record
10823    x       at  4 range  0 .. 7;
10824    _tag    at  0 range  0 .. 31;
10825    _parent at  0 range  0 .. 63;
10826    y2      at 16 range  0 .. 31;
10827 end record;
10828
10829 for x'Size use 8;
10830 for x'Alignment use 1;
10831 for x use record
10832    y at 0 range  0 .. 7;
10833 end record;
10834
10835 for x1'Size use 112;
10836 for x1'Alignment use 1;
10837 for x1'Component_Size use 11;
10838
10839 for rb1'Size use 13;
10840 for rb1'Alignment use 2;
10841 for rb1'Component_Size use 1;
10842
10843 for rb2'Size use 72;
10844 for rb2'Alignment use 1;
10845 for rb2'Component_Size use 1;
10846
10847 for x2'Size use 224;
10848 for x2'Alignment use 4;
10849 for x2 use record
10850    l1 at  0 range  0 .. 0;
10851    l2 at  0 range  1 .. 64;
10852    l3 at 12 range  0 .. 31;
10853    l4 at 16 range  0 .. 0;
10854    l5 at 16 range  1 .. 13;
10855    l6 at 18 range  0 .. 71;
10856 end record;
10857 @end smallexample
10858
10859 @noindent
10860 The Size values are actually the Object_Size, i.e.@: the default size that
10861 will be allocated for objects of the type.
10862 The ?? size for type r indicates that we have a variant record, and the
10863 actual size of objects will depend on the discriminant value.
10864
10865 The Alignment values show the actual alignment chosen by the compiler
10866 for each record or array type.
10867
10868 The record representation clause for type r shows where all fields
10869 are placed, including the compiler generated tag field (whose location
10870 cannot be controlled by the programmer).
10871
10872 The record representation clause for the type extension r2 shows all the
10873 fields present, including the parent field, which is a copy of the fields
10874 of the parent type of r2, i.e.@: r1.
10875
10876 The component size and size clauses for types rb1 and rb2 show
10877 the exact effect of pragma @code{Pack} on these arrays, and the record
10878 representation clause for type x2 shows how pragma @code{Pack} affects
10879 this record type.
10880
10881 In some cases, it may be useful to cut and paste the representation clauses
10882 generated by the compiler into the original source to fix and guarantee
10883 the actual representation to be used.
10884
10885 @node Standard Library Routines
10886 @chapter Standard Library Routines
10887
10888 @noindent
10889 The Ada Reference Manual contains in Annex A a full description of an
10890 extensive set of standard library routines that can be used in any Ada
10891 program, and which must be provided by all Ada compilers.  They are
10892 analogous to the standard C library used by C programs.
10893
10894 GNAT implements all of the facilities described in annex A, and for most
10895 purposes the description in the Ada Reference Manual, or appropriate Ada
10896 text book, will be sufficient for making use of these facilities.
10897
10898 In the case of the input-output facilities,
10899 @xref{The Implementation of Standard I/O},
10900 gives details on exactly how GNAT interfaces to the
10901 file system.  For the remaining packages, the Ada Reference Manual
10902 should be sufficient.  The following is a list of the packages included,
10903 together with a brief description of the functionality that is provided.
10904
10905 For completeness, references are included to other predefined library
10906 routines defined in other sections of the Ada Reference Manual (these are
10907 cross-indexed from Annex A).
10908
10909 @table @code
10910 @item Ada (A.2)
10911 This is a parent package for all the standard library packages.  It is
10912 usually included implicitly in your program, and itself contains no
10913 useful data or routines.
10914
10915 @item Ada.Calendar (9.6)
10916 @code{Calendar} provides time of day access, and routines for
10917 manipulating times and durations.
10918
10919 @item Ada.Characters (A.3.1)
10920 This is a dummy parent package that contains no useful entities
10921
10922 @item Ada.Characters.Handling (A.3.2)
10923 This package provides some basic character handling capabilities,
10924 including classification functions for classes of characters (e.g.@: test
10925 for letters, or digits).
10926
10927 @item Ada.Characters.Latin_1 (A.3.3)
10928 This package includes a complete set of definitions of the characters
10929 that appear in type CHARACTER@.  It is useful for writing programs that
10930 will run in international environments.  For example, if you want an
10931 upper case E with an acute accent in a string, it is often better to use
10932 the definition of @code{UC_E_Acute} in this package.  Then your program
10933 will print in an understandable manner even if your environment does not
10934 support these extended characters.
10935
10936 @item Ada.Command_Line (A.15)
10937 This package provides access to the command line parameters and the name
10938 of the current program (analogous to the use of @code{argc} and @code{argv}
10939 in C), and also allows the exit status for the program to be set in a
10940 system-independent manner.
10941
10942 @item Ada.Decimal (F.2)
10943 This package provides constants describing the range of decimal numbers
10944 implemented, and also a decimal divide routine (analogous to the COBOL
10945 verb DIVIDE .. GIVING .. REMAINDER ..)
10946
10947 @item Ada.Direct_IO (A.8.4)
10948 This package provides input-output using a model of a set of records of
10949 fixed-length, containing an arbitrary definite Ada type, indexed by an
10950 integer record number.
10951
10952 @item Ada.Dynamic_Priorities (D.5)
10953 This package allows the priorities of a task to be adjusted dynamically
10954 as the task is running.
10955
10956 @item Ada.Exceptions (11.4.1)
10957 This package provides additional information on exceptions, and also
10958 contains facilities for treating exceptions as data objects, and raising
10959 exceptions with associated messages.
10960
10961 @item Ada.Finalization (7.6)
10962 This package contains the declarations and subprograms to support the
10963 use of controlled types, providing for automatic initialization and
10964 finalization (analogous to the constructors and destructors of C++)
10965
10966 @item Ada.Interrupts (C.3.2)
10967 This package provides facilities for interfacing to interrupts, which
10968 includes the set of signals or conditions that can be raised and
10969 recognized as interrupts.
10970
10971 @item Ada.Interrupts.Names (C.3.2)
10972 This package provides the set of interrupt names (actually signal
10973 or condition names) that can be handled by GNAT@.
10974
10975 @item Ada.IO_Exceptions (A.13)
10976 This package defines the set of exceptions that can be raised by use of
10977 the standard IO packages.
10978
10979 @item Ada.Numerics
10980 This package contains some standard constants and exceptions used
10981 throughout the numerics packages.  Note that the constants pi and e are
10982 defined here, and it is better to use these definitions than rolling
10983 your own.
10984
10985 @item Ada.Numerics.Complex_Elementary_Functions
10986 Provides the implementation of standard elementary functions (such as
10987 log and trigonometric functions) operating on complex numbers using the
10988 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10989 created by the package @code{Numerics.Complex_Types}.
10990
10991 @item Ada.Numerics.Complex_Types
10992 This is a predefined instantiation of
10993 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10994 build the type @code{Complex} and @code{Imaginary}.
10995
10996 @item Ada.Numerics.Discrete_Random
10997 This package provides a random number generator suitable for generating
10998 random integer values from a specified range.
10999
11000 @item Ada.Numerics.Float_Random
11001 This package provides a random number generator suitable for generating
11002 uniformly distributed floating point values.
11003
11004 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11005 This is a generic version of the package that provides the
11006 implementation of standard elementary functions (such as log and
11007 trigonometric functions) for an arbitrary complex type.
11008
11009 The following predefined instantiations of this package are provided:
11010
11011 @table @code
11012 @item Short_Float
11013 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11014 @item Float
11015 @code{Ada.Numerics.Complex_Elementary_Functions}
11016 @item Long_Float
11017 @code{Ada.Numerics.
11018  Long_Complex_Elementary_Functions}
11019 @end table
11020
11021 @item Ada.Numerics.Generic_Complex_Types
11022 This is a generic package that allows the creation of complex types,
11023 with associated complex arithmetic operations.
11024
11025 The following predefined instantiations of this package exist
11026 @table @code
11027 @item Short_Float
11028 @code{Ada.Numerics.Short_Complex_Complex_Types}
11029 @item Float
11030 @code{Ada.Numerics.Complex_Complex_Types}
11031 @item Long_Float
11032 @code{Ada.Numerics.Long_Complex_Complex_Types}
11033 @end table
11034
11035 @item Ada.Numerics.Generic_Elementary_Functions
11036 This is a generic package that provides the implementation of standard
11037 elementary functions (such as log an trigonometric functions) for an
11038 arbitrary float type.
11039
11040 The following predefined instantiations of this package exist
11041
11042 @table @code
11043 @item Short_Float
11044 @code{Ada.Numerics.Short_Elementary_Functions}
11045 @item Float
11046 @code{Ada.Numerics.Elementary_Functions}
11047 @item Long_Float
11048 @code{Ada.Numerics.Long_Elementary_Functions}
11049 @end table
11050
11051 @item Ada.Real_Time (D.8)
11052 This package provides facilities similar to those of @code{Calendar}, but
11053 operating with a finer clock suitable for real time control. Note that
11054 annex D requires that there be no backward clock jumps, and GNAT generally
11055 guarantees this behavior, but of course if the external clock on which
11056 the GNAT runtime depends is deliberately reset by some external event,
11057 then such a backward jump may occur.
11058
11059 @item Ada.Sequential_IO (A.8.1)
11060 This package provides input-output facilities for sequential files,
11061 which can contain a sequence of values of a single type, which can be
11062 any Ada type, including indefinite (unconstrained) types.
11063
11064 @item Ada.Storage_IO (A.9)
11065 This package provides a facility for mapping arbitrary Ada types to and
11066 from a storage buffer.  It is primarily intended for the creation of new
11067 IO packages.
11068
11069 @item Ada.Streams (13.13.1)
11070 This is a generic package that provides the basic support for the
11071 concept of streams as used by the stream attributes (@code{Input},
11072 @code{Output}, @code{Read} and @code{Write}).
11073
11074 @item Ada.Streams.Stream_IO (A.12.1)
11075 This package is a specialization of the type @code{Streams} defined in
11076 package @code{Streams} together with a set of operations providing
11077 Stream_IO capability.  The Stream_IO model permits both random and
11078 sequential access to a file which can contain an arbitrary set of values
11079 of one or more Ada types.
11080
11081 @item Ada.Strings (A.4.1)
11082 This package provides some basic constants used by the string handling
11083 packages.
11084
11085 @item Ada.Strings.Bounded (A.4.4)
11086 This package provides facilities for handling variable length
11087 strings.  The bounded model requires a maximum length.  It is thus
11088 somewhat more limited than the unbounded model, but avoids the use of
11089 dynamic allocation or finalization.
11090
11091 @item Ada.Strings.Fixed (A.4.3)
11092 This package provides facilities for handling fixed length strings.
11093
11094 @item Ada.Strings.Maps (A.4.2)
11095 This package provides facilities for handling character mappings and
11096 arbitrarily defined subsets of characters.  For instance it is useful in
11097 defining specialized translation tables.
11098
11099 @item Ada.Strings.Maps.Constants (A.4.6)
11100 This package provides a standard set of predefined mappings and
11101 predefined character sets.  For example, the standard upper to lower case
11102 conversion table is found in this package.  Note that upper to lower case
11103 conversion is non-trivial if you want to take the entire set of
11104 characters, including extended characters like E with an acute accent,
11105 into account.  You should use the mappings in this package (rather than
11106 adding 32 yourself) to do case mappings.
11107
11108 @item Ada.Strings.Unbounded (A.4.5)
11109 This package provides facilities for handling variable length
11110 strings.  The unbounded model allows arbitrary length strings, but
11111 requires the use of dynamic allocation and finalization.
11112
11113 @item Ada.Strings.Wide_Bounded (A.4.7)
11114 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11115 @itemx Ada.Strings.Wide_Maps (A.4.7)
11116 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11117 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11118 These packages provide analogous capabilities to the corresponding
11119 packages without @samp{Wide_} in the name, but operate with the types
11120 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11121 and @code{Character}.
11122
11123 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11124 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11125 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11126 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11127 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11128 These packages provide analogous capabilities to the corresponding
11129 packages without @samp{Wide_} in the name, but operate with the types
11130 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11131 of @code{String} and @code{Character}.
11132
11133 @item Ada.Synchronous_Task_Control (D.10)
11134 This package provides some standard facilities for controlling task
11135 communication in a synchronous manner.
11136
11137 @item Ada.Tags
11138 This package contains definitions for manipulation of the tags of tagged
11139 values.
11140
11141 @item Ada.Task_Attributes
11142 This package provides the capability of associating arbitrary
11143 task-specific data with separate tasks.
11144
11145 @item Ada.Text_IO
11146 This package provides basic text input-output capabilities for
11147 character, string and numeric data.  The subpackages of this
11148 package are listed next.
11149
11150 @item Ada.Text_IO.Decimal_IO
11151 Provides input-output facilities for decimal fixed-point types
11152
11153 @item Ada.Text_IO.Enumeration_IO
11154 Provides input-output facilities for enumeration types.
11155
11156 @item Ada.Text_IO.Fixed_IO
11157 Provides input-output facilities for ordinary fixed-point types.
11158
11159 @item Ada.Text_IO.Float_IO
11160 Provides input-output facilities for float types.  The following
11161 predefined instantiations of this generic package are available:
11162
11163 @table @code
11164 @item Short_Float
11165 @code{Short_Float_Text_IO}
11166 @item Float
11167 @code{Float_Text_IO}
11168 @item Long_Float
11169 @code{Long_Float_Text_IO}
11170 @end table
11171
11172 @item Ada.Text_IO.Integer_IO
11173 Provides input-output facilities for integer types.  The following
11174 predefined instantiations of this generic package are available:
11175
11176 @table @code
11177 @item Short_Short_Integer
11178 @code{Ada.Short_Short_Integer_Text_IO}
11179 @item Short_Integer
11180 @code{Ada.Short_Integer_Text_IO}
11181 @item Integer
11182 @code{Ada.Integer_Text_IO}
11183 @item Long_Integer
11184 @code{Ada.Long_Integer_Text_IO}
11185 @item Long_Long_Integer
11186 @code{Ada.Long_Long_Integer_Text_IO}
11187 @end table
11188
11189 @item Ada.Text_IO.Modular_IO
11190 Provides input-output facilities for modular (unsigned) types
11191
11192 @item Ada.Text_IO.Complex_IO (G.1.3)
11193 This package provides basic text input-output capabilities for complex
11194 data.
11195
11196 @item Ada.Text_IO.Editing (F.3.3)
11197 This package contains routines for edited output, analogous to the use
11198 of pictures in COBOL@.  The picture formats used by this package are a
11199 close copy of the facility in COBOL@.
11200
11201 @item Ada.Text_IO.Text_Streams (A.12.2)
11202 This package provides a facility that allows Text_IO files to be treated
11203 as streams, so that the stream attributes can be used for writing
11204 arbitrary data, including binary data, to Text_IO files.
11205
11206 @item Ada.Unchecked_Conversion (13.9)
11207 This generic package allows arbitrary conversion from one type to
11208 another of the same size, providing for breaking the type safety in
11209 special circumstances.
11210
11211 If the types have the same Size (more accurately the same Value_Size),
11212 then the effect is simply to transfer the bits from the source to the
11213 target type without any modification.  This usage is well defined, and
11214 for simple types whose representation is typically the same across
11215 all implementations, gives a portable method of performing such
11216 conversions.
11217
11218 If the types do not have the same size, then the result is implementation
11219 defined, and thus may be non-portable.  The following describes how GNAT
11220 handles such unchecked conversion cases.
11221
11222 If the types are of different sizes, and are both discrete types, then
11223 the effect is of a normal type conversion without any constraint checking.
11224 In particular if the result type has a larger size, the result will be
11225 zero or sign extended.  If the result type has a smaller size, the result
11226 will be truncated by ignoring high order bits.
11227
11228 If the types are of different sizes, and are not both discrete types,
11229 then the conversion works as though pointers were created to the source
11230 and target, and the pointer value is converted.  The effect is that bits
11231 are copied from successive low order storage units and bits of the source
11232 up to the length of the target type.
11233
11234 A warning is issued if the lengths differ, since the effect in this
11235 case is implementation dependent, and the above behavior may not match
11236 that of some other compiler.
11237
11238 A pointer to one type may be converted to a pointer to another type using
11239 unchecked conversion.  The only case in which the effect is undefined is
11240 when one or both pointers are pointers to unconstrained array types.  In
11241 this case, the bounds information may get incorrectly transferred, and in
11242 particular, GNAT uses double size pointers for such types, and it is
11243 meaningless to convert between such pointer types.  GNAT will issue a
11244 warning if the alignment of the target designated type is more strict
11245 than the alignment of the source designated type (since the result may
11246 be unaligned in this case).
11247
11248 A pointer other than a pointer to an unconstrained array type may be
11249 converted to and from System.Address.  Such usage is common in Ada 83
11250 programs, but note that Ada.Address_To_Access_Conversions is the
11251 preferred method of performing such conversions in Ada 95 and Ada 2005.
11252 Neither
11253 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11254 used in conjunction with pointers to unconstrained objects, since
11255 the bounds information cannot be handled correctly in this case.
11256
11257 @item Ada.Unchecked_Deallocation (13.11.2)
11258 This generic package allows explicit freeing of storage previously
11259 allocated by use of an allocator.
11260
11261 @item Ada.Wide_Text_IO (A.11)
11262 This package is similar to @code{Ada.Text_IO}, except that the external
11263 file supports wide character representations, and the internal types are
11264 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11265 and @code{String}.  It contains generic subpackages listed next.
11266
11267 @item Ada.Wide_Text_IO.Decimal_IO
11268 Provides input-output facilities for decimal fixed-point types
11269
11270 @item Ada.Wide_Text_IO.Enumeration_IO
11271 Provides input-output facilities for enumeration types.
11272
11273 @item Ada.Wide_Text_IO.Fixed_IO
11274 Provides input-output facilities for ordinary fixed-point types.
11275
11276 @item Ada.Wide_Text_IO.Float_IO
11277 Provides input-output facilities for float types.  The following
11278 predefined instantiations of this generic package are available:
11279
11280 @table @code
11281 @item Short_Float
11282 @code{Short_Float_Wide_Text_IO}
11283 @item Float
11284 @code{Float_Wide_Text_IO}
11285 @item Long_Float
11286 @code{Long_Float_Wide_Text_IO}
11287 @end table
11288
11289 @item Ada.Wide_Text_IO.Integer_IO
11290 Provides input-output facilities for integer types.  The following
11291 predefined instantiations of this generic package are available:
11292
11293 @table @code
11294 @item Short_Short_Integer
11295 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11296 @item Short_Integer
11297 @code{Ada.Short_Integer_Wide_Text_IO}
11298 @item Integer
11299 @code{Ada.Integer_Wide_Text_IO}
11300 @item Long_Integer
11301 @code{Ada.Long_Integer_Wide_Text_IO}
11302 @item Long_Long_Integer
11303 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11304 @end table
11305
11306 @item Ada.Wide_Text_IO.Modular_IO
11307 Provides input-output facilities for modular (unsigned) types
11308
11309 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11310 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11311 external file supports wide character representations.
11312
11313 @item Ada.Wide_Text_IO.Editing (F.3.4)
11314 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11315 types are @code{Wide_Character} and @code{Wide_String} instead of
11316 @code{Character} and @code{String}.
11317
11318 @item Ada.Wide_Text_IO.Streams (A.12.3)
11319 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11320 types are @code{Wide_Character} and @code{Wide_String} instead of
11321 @code{Character} and @code{String}.
11322
11323 @item Ada.Wide_Wide_Text_IO (A.11)
11324 This package is similar to @code{Ada.Text_IO}, except that the external
11325 file supports wide character representations, and the internal types are
11326 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11327 and @code{String}.  It contains generic subpackages listed next.
11328
11329 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11330 Provides input-output facilities for decimal fixed-point types
11331
11332 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11333 Provides input-output facilities for enumeration types.
11334
11335 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11336 Provides input-output facilities for ordinary fixed-point types.
11337
11338 @item Ada.Wide_Wide_Text_IO.Float_IO
11339 Provides input-output facilities for float types.  The following
11340 predefined instantiations of this generic package are available:
11341
11342 @table @code
11343 @item Short_Float
11344 @code{Short_Float_Wide_Wide_Text_IO}
11345 @item Float
11346 @code{Float_Wide_Wide_Text_IO}
11347 @item Long_Float
11348 @code{Long_Float_Wide_Wide_Text_IO}
11349 @end table
11350
11351 @item Ada.Wide_Wide_Text_IO.Integer_IO
11352 Provides input-output facilities for integer types.  The following
11353 predefined instantiations of this generic package are available:
11354
11355 @table @code
11356 @item Short_Short_Integer
11357 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11358 @item Short_Integer
11359 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11360 @item Integer
11361 @code{Ada.Integer_Wide_Wide_Text_IO}
11362 @item Long_Integer
11363 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11364 @item Long_Long_Integer
11365 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11366 @end table
11367
11368 @item Ada.Wide_Wide_Text_IO.Modular_IO
11369 Provides input-output facilities for modular (unsigned) types
11370
11371 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11372 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11373 external file supports wide character representations.
11374
11375 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11376 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11377 types are @code{Wide_Character} and @code{Wide_String} instead of
11378 @code{Character} and @code{String}.
11379
11380 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11381 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11382 types are @code{Wide_Character} and @code{Wide_String} instead of
11383 @code{Character} and @code{String}.
11384 @end table
11385
11386
11387
11388 @node The Implementation of Standard I/O
11389 @chapter The Implementation of Standard I/O
11390
11391 @noindent
11392 GNAT implements all the required input-output facilities described in
11393 A.6 through A.14.  These sections of the Ada Reference Manual describe the
11394 required behavior of these packages from the Ada point of view, and if
11395 you are writing a portable Ada program that does not need to know the
11396 exact manner in which Ada maps to the outside world when it comes to
11397 reading or writing external files, then you do not need to read this
11398 chapter.  As long as your files are all regular files (not pipes or
11399 devices), and as long as you write and read the files only from Ada, the
11400 description in the Ada Reference Manual is sufficient.
11401
11402 However, if you want to do input-output to pipes or other devices, such
11403 as the keyboard or screen, or if the files you are dealing with are
11404 either generated by some other language, or to be read by some other
11405 language, then you need to know more about the details of how the GNAT
11406 implementation of these input-output facilities behaves.
11407
11408 In this chapter we give a detailed description of exactly how GNAT
11409 interfaces to the file system.  As always, the sources of the system are
11410 available to you for answering questions at an even more detailed level,
11411 but for most purposes the information in this chapter will suffice.
11412
11413 Another reason that you may need to know more about how input-output is
11414 implemented arises when you have a program written in mixed languages
11415 where, for example, files are shared between the C and Ada sections of
11416 the same program.  GNAT provides some additional facilities, in the form
11417 of additional child library packages, that facilitate this sharing, and
11418 these additional facilities are also described in this chapter.
11419
11420 @menu
11421 * Standard I/O Packages::
11422 * FORM Strings::
11423 * Direct_IO::
11424 * Sequential_IO::
11425 * Text_IO::
11426 * Wide_Text_IO::
11427 * Wide_Wide_Text_IO::
11428 * Stream_IO::
11429 * Shared Files::
11430 * Filenames encoding::
11431 * Open Modes::
11432 * Operations on C Streams::
11433 * Interfacing to C Streams::
11434 @end menu
11435
11436 @node Standard I/O Packages
11437 @section Standard I/O Packages
11438
11439 @noindent
11440 The Standard I/O packages described in Annex A for
11441
11442 @itemize @bullet
11443 @item
11444 Ada.Text_IO
11445 @item
11446 Ada.Text_IO.Complex_IO
11447 @item
11448 Ada.Text_IO.Text_Streams
11449 @item
11450 Ada.Wide_Text_IO
11451 @item
11452 Ada.Wide_Text_IO.Complex_IO
11453 @item
11454 Ada.Wide_Text_IO.Text_Streams
11455 @item
11456 Ada.Wide_Wide_Text_IO
11457 @item
11458 Ada.Wide_Wide_Text_IO.Complex_IO
11459 @item
11460 Ada.Wide_Wide_Text_IO.Text_Streams
11461 @item
11462 Ada.Stream_IO
11463 @item
11464 Ada.Sequential_IO
11465 @item
11466 Ada.Direct_IO
11467 @end itemize
11468
11469 @noindent
11470 are implemented using the C
11471 library streams facility; where
11472
11473 @itemize @bullet
11474 @item
11475 All files are opened using @code{fopen}.
11476 @item
11477 All input/output operations use @code{fread}/@code{fwrite}.
11478 @end itemize
11479
11480 @noindent
11481 There is no internal buffering of any kind at the Ada library level. The only
11482 buffering is that provided at the system level in the implementation of the
11483 library routines that support streams. This facilitates shared use of these
11484 streams by mixed language programs. Note though that system level buffering is
11485 explicitly enabled at elaboration of the standard I/O packages and that can
11486 have an impact on mixed language programs, in particular those using I/O before
11487 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11488 the Ada elaboration routine before performing any I/O or when impractical,
11489 flush the common I/O streams and in particular Standard_Output before
11490 elaborating the Ada code.
11491
11492 @node FORM Strings
11493 @section FORM Strings
11494
11495 @noindent
11496 The format of a FORM string in GNAT is:
11497
11498 @smallexample
11499 "keyword=value,keyword=value,@dots{},keyword=value"
11500 @end smallexample
11501
11502 @noindent
11503 where letters may be in upper or lower case, and there are no spaces
11504 between values.  The order of the entries is not important.  Currently
11505 there are two keywords defined.
11506
11507 @smallexample
11508 SHARED=[YES|NO]
11509 WCEM=[n|h|u|s|e|8|b]
11510 @end smallexample
11511
11512 @noindent
11513 The use of these parameters is described later in this section.
11514
11515 @node Direct_IO
11516 @section Direct_IO
11517
11518 @noindent
11519 Direct_IO can only be instantiated for definite types.  This is a
11520 restriction of the Ada language, which means that the records are fixed
11521 length (the length being determined by @code{@var{type}'Size}, rounded
11522 up to the next storage unit boundary if necessary).
11523
11524 The records of a Direct_IO file are simply written to the file in index
11525 sequence, with the first record starting at offset zero, and subsequent
11526 records following.  There is no control information of any kind.  For
11527 example, if 32-bit integers are being written, each record takes
11528 4-bytes, so the record at index @var{K} starts at offset
11529 (@var{K}@minus{}1)*4.
11530
11531 There is no limit on the size of Direct_IO files, they are expanded as
11532 necessary to accommodate whatever records are written to the file.
11533
11534 @node Sequential_IO
11535 @section Sequential_IO
11536
11537 @noindent
11538 Sequential_IO may be instantiated with either a definite (constrained)
11539 or indefinite (unconstrained) type.
11540
11541 For the definite type case, the elements written to the file are simply
11542 the memory images of the data values with no control information of any
11543 kind.  The resulting file should be read using the same type, no validity
11544 checking is performed on input.
11545
11546 For the indefinite type case, the elements written consist of two
11547 parts.  First is the size of the data item, written as the memory image
11548 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11549 the data value.  The resulting file can only be read using the same
11550 (unconstrained) type.  Normal assignment checks are performed on these
11551 read operations, and if these checks fail, @code{Data_Error} is
11552 raised.  In particular, in the array case, the lengths must match, and in
11553 the variant record case, if the variable for a particular read operation
11554 is constrained, the discriminants must match.
11555
11556 Note that it is not possible to use Sequential_IO to write variable
11557 length array items, and then read the data back into different length
11558 arrays.  For example, the following will raise @code{Data_Error}:
11559
11560 @smallexample @c ada
11561  package IO is new Sequential_IO (String);
11562  F : IO.File_Type;
11563  S : String (1..4);
11564  @dots{}
11565  IO.Create (F)
11566  IO.Write (F, "hello!")
11567  IO.Reset (F, Mode=>In_File);
11568  IO.Read (F, S);
11569  Put_Line (S);
11570
11571 @end smallexample
11572
11573 @noindent
11574 On some Ada implementations, this will print @code{hell}, but the program is
11575 clearly incorrect, since there is only one element in the file, and that
11576 element is the string @code{hello!}.
11577
11578 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11579 using Stream_IO, and this is the preferred mechanism.  In particular, the
11580 above program fragment rewritten to use Stream_IO will work correctly.
11581
11582 @node Text_IO
11583 @section Text_IO
11584
11585 @noindent
11586 Text_IO files consist of a stream of characters containing the following
11587 special control characters:
11588
11589 @smallexample
11590 LF (line feed, 16#0A#) Line Mark
11591 FF (form feed, 16#0C#) Page Mark
11592 @end smallexample
11593
11594 @noindent
11595 A canonical Text_IO file is defined as one in which the following
11596 conditions are met:
11597
11598 @itemize @bullet
11599 @item
11600 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11601 of the line.
11602
11603 @item
11604 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11605 end of a page and consequently can appear only immediately following a
11606 @code{LF} (line mark) character.
11607
11608 @item
11609 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11610 (line mark, page mark).  In the former case, the page mark is implicitly
11611 assumed to be present.
11612 @end itemize
11613
11614 @noindent
11615 A file written using Text_IO will be in canonical form provided that no
11616 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11617 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11618 the file unless an explicit @code{New_Page} operation was performed
11619 before closing the file.
11620
11621 A canonical Text_IO file that is a regular file (i.e., not a device or a
11622 pipe) can be read using any of the routines in Text_IO@.  The
11623 semantics in this case will be exactly as defined in the Ada Reference
11624 Manual, and all the routines in Text_IO are fully implemented.
11625
11626 A text file that does not meet the requirements for a canonical Text_IO
11627 file has one of the following:
11628
11629 @itemize @bullet
11630 @item
11631 The file contains @code{FF} characters not immediately following a
11632 @code{LF} character.
11633
11634 @item
11635 The file contains @code{LF} or @code{FF} characters written by
11636 @code{Put} or @code{Put_Line}, which are not logically considered to be
11637 line marks or page marks.
11638
11639 @item
11640 The file ends in a character other than @code{LF} or @code{FF},
11641 i.e.@: there is no explicit line mark or page mark at the end of the file.
11642 @end itemize
11643
11644 @noindent
11645 Text_IO can be used to read such non-standard text files but subprograms
11646 to do with line or page numbers do not have defined meanings.  In
11647 particular, a @code{FF} character that does not follow a @code{LF}
11648 character may or may not be treated as a page mark from the point of
11649 view of page and line numbering.  Every @code{LF} character is considered
11650 to end a line, and there is an implied @code{LF} character at the end of
11651 the file.
11652
11653 @menu
11654 * Text_IO Stream Pointer Positioning::
11655 * Text_IO Reading and Writing Non-Regular Files::
11656 * Get_Immediate::
11657 * Treating Text_IO Files as Streams::
11658 * Text_IO Extensions::
11659 * Text_IO Facilities for Unbounded Strings::
11660 @end menu
11661
11662 @node Text_IO Stream Pointer Positioning
11663 @subsection Stream Pointer Positioning
11664
11665 @noindent
11666 @code{Ada.Text_IO} has a definition of current position for a file that
11667 is being read.  No internal buffering occurs in Text_IO, and usually the
11668 physical position in the stream used to implement the file corresponds
11669 to this logical position defined by Text_IO@.  There are two exceptions:
11670
11671 @itemize @bullet
11672 @item
11673 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11674 is positioned past the @code{LF} (line mark) that precedes the page
11675 mark.  Text_IO maintains an internal flag so that subsequent read
11676 operations properly handle the logical position which is unchanged by
11677 the @code{End_Of_Page} call.
11678
11679 @item
11680 After a call to @code{End_Of_File} that returns @code{True}, if the
11681 Text_IO file was positioned before the line mark at the end of file
11682 before the call, then the logical position is unchanged, but the stream
11683 is physically positioned right at the end of file (past the line mark,
11684 and past a possible page mark following the line mark.  Again Text_IO
11685 maintains internal flags so that subsequent read operations properly
11686 handle the logical position.
11687 @end itemize
11688
11689 @noindent
11690 These discrepancies have no effect on the observable behavior of
11691 Text_IO, but if a single Ada stream is shared between a C program and
11692 Ada program, or shared (using @samp{shared=yes} in the form string)
11693 between two Ada files, then the difference may be observable in some
11694 situations.
11695
11696 @node Text_IO Reading and Writing Non-Regular Files
11697 @subsection Reading and Writing Non-Regular Files
11698
11699 @noindent
11700 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11701 can be used for reading and writing.  Writing is not affected and the
11702 sequence of characters output is identical to the normal file case, but
11703 for reading, the behavior of Text_IO is modified to avoid undesirable
11704 look-ahead as follows:
11705
11706 An input file that is not a regular file is considered to have no page
11707 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11708 page mark) appearing in the file are considered to be data
11709 characters.  In particular:
11710
11711 @itemize @bullet
11712 @item
11713 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11714 following a line mark.  If a page mark appears, it will be treated as a
11715 data character.
11716
11717 @item
11718 This avoids the need to wait for an extra character to be typed or
11719 entered from the pipe to complete one of these operations.
11720
11721 @item
11722 @code{End_Of_Page} always returns @code{False}
11723
11724 @item
11725 @code{End_Of_File} will return @code{False} if there is a page mark at
11726 the end of the file.
11727 @end itemize
11728
11729 @noindent
11730 Output to non-regular files is the same as for regular files.  Page marks
11731 may be written to non-regular files using @code{New_Page}, but as noted
11732 above they will not be treated as page marks on input if the output is
11733 piped to another Ada program.
11734
11735 Another important discrepancy when reading non-regular files is that the end
11736 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11737 pressing the @key{EOT} key,
11738 then end of file
11739 is signaled once (i.e.@: the test @code{End_Of_File}
11740 will yield @code{True}, or a read will
11741 raise @code{End_Error}), but then reading can resume
11742 to read data past that end of
11743 file indication, until another end of file indication is entered.
11744
11745 @node Get_Immediate
11746 @subsection Get_Immediate
11747 @cindex Get_Immediate
11748
11749 @noindent
11750 Get_Immediate returns the next character (including control characters)
11751 from the input file.  In particular, Get_Immediate will return LF or FF
11752 characters used as line marks or page marks.  Such operations leave the
11753 file positioned past the control character, and it is thus not treated
11754 as having its normal function.  This means that page, line and column
11755 counts after this kind of Get_Immediate call are set as though the mark
11756 did not occur.  In the case where a Get_Immediate leaves the file
11757 positioned between the line mark and page mark (which is not normally
11758 possible), it is undefined whether the FF character will be treated as a
11759 page mark.
11760
11761 @node Treating Text_IO Files as Streams
11762 @subsection Treating Text_IO Files as Streams
11763 @cindex Stream files
11764
11765 @noindent
11766 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11767 as a stream.  Data written to a Text_IO file in this stream mode is
11768 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11769 16#0C# (@code{FF}), the resulting file may have non-standard
11770 format.  Similarly if read operations are used to read from a Text_IO
11771 file treated as a stream, then @code{LF} and @code{FF} characters may be
11772 skipped and the effect is similar to that described above for
11773 @code{Get_Immediate}.
11774
11775 @node Text_IO Extensions
11776 @subsection Text_IO Extensions
11777 @cindex Text_IO extensions
11778
11779 @noindent
11780 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11781 to the standard @code{Text_IO} package:
11782
11783 @itemize @bullet
11784 @item function File_Exists (Name : String) return Boolean;
11785 Determines if a file of the given name exists.
11786
11787 @item function Get_Line return String;
11788 Reads a string from the standard input file.  The value returned is exactly
11789 the length of the line that was read.
11790
11791 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11792 Similar, except that the parameter File specifies the file from which
11793 the string is to be read.
11794
11795 @end itemize
11796
11797 @node Text_IO Facilities for Unbounded Strings
11798 @subsection Text_IO Facilities for Unbounded Strings
11799 @cindex Text_IO for unbounded strings
11800 @cindex Unbounded_String, Text_IO operations
11801
11802 @noindent
11803 The package @code{Ada.Strings.Unbounded.Text_IO}
11804 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11805 subprograms useful for Text_IO operations on unbounded strings:
11806
11807 @itemize @bullet
11808
11809 @item function Get_Line (File : File_Type) return Unbounded_String;
11810 Reads a line from the specified file
11811 and returns the result as an unbounded string.
11812
11813 @item procedure Put (File : File_Type; U : Unbounded_String);
11814 Writes the value of the given unbounded string to the specified file
11815 Similar to the effect of
11816 @code{Put (To_String (U))} except that an extra copy is avoided.
11817
11818 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11819 Writes the value of the given unbounded string to the specified file,
11820 followed by a @code{New_Line}.
11821 Similar to the effect of @code{Put_Line (To_String (U))} except
11822 that an extra copy is avoided.
11823 @end itemize
11824
11825 @noindent
11826 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11827 and is optional.  If the parameter is omitted, then the standard input or
11828 output file is referenced as appropriate.
11829
11830 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11831 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11832 @code{Wide_Text_IO} functionality for unbounded wide strings.
11833
11834 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11835 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11836 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11837
11838 @node Wide_Text_IO
11839 @section Wide_Text_IO
11840
11841 @noindent
11842 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11843 both input and output files may contain special sequences that represent
11844 wide character values.  The encoding scheme for a given file may be
11845 specified using a FORM parameter:
11846
11847 @smallexample
11848 WCEM=@var{x}
11849 @end smallexample
11850
11851 @noindent
11852 as part of the FORM string (WCEM = wide character encoding method),
11853 where @var{x} is one of the following characters
11854
11855 @table @samp
11856 @item h
11857 Hex ESC encoding
11858 @item u
11859 Upper half encoding
11860 @item s
11861 Shift-JIS encoding
11862 @item e
11863 EUC Encoding
11864 @item 8
11865 UTF-8 encoding
11866 @item b
11867 Brackets encoding
11868 @end table
11869
11870 @noindent
11871 The encoding methods match those that
11872 can be used in a source
11873 program, but there is no requirement that the encoding method used for
11874 the source program be the same as the encoding method used for files,
11875 and different files may use different encoding methods.
11876
11877 The default encoding method for the standard files, and for opened files
11878 for which no WCEM parameter is given in the FORM string matches the
11879 wide character encoding specified for the main program (the default
11880 being brackets encoding if no coding method was specified with -gnatW).
11881
11882 @table @asis
11883 @item Hex Coding
11884 In this encoding, a wide character is represented by a five character
11885 sequence:
11886
11887 @smallexample
11888 ESC a b c d
11889 @end smallexample
11890
11891 @noindent
11892 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11893 characters (using upper case letters) of the wide character code.  For
11894 example, ESC A345 is used to represent the wide character with code
11895 16#A345#.  This scheme is compatible with use of the full
11896 @code{Wide_Character} set.
11897
11898 @item Upper Half Coding
11899 The wide character with encoding 16#abcd#, where the upper bit is on
11900 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11901 16#cd#.  The second byte may never be a format control character, but is
11902 not required to be in the upper half.  This method can be also used for
11903 shift-JIS or EUC where the internal coding matches the external coding.
11904
11905 @item Shift JIS Coding
11906 A wide character is represented by a two character sequence 16#ab# and
11907 16#cd#, with the restrictions described for upper half encoding as
11908 described above.  The internal character code is the corresponding JIS
11909 character according to the standard algorithm for Shift-JIS
11910 conversion.  Only characters defined in the JIS code set table can be
11911 used with this encoding method.
11912
11913 @item EUC Coding
11914 A wide character is represented by a two character sequence 16#ab# and
11915 16#cd#, with both characters being in the upper half.  The internal
11916 character code is the corresponding JIS character according to the EUC
11917 encoding algorithm.  Only characters defined in the JIS code set table
11918 can be used with this encoding method.
11919
11920 @item UTF-8 Coding
11921 A wide character is represented using
11922 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11923 10646-1/Am.2.  Depending on the character value, the representation
11924 is a one, two, or three byte sequence:
11925
11926 @smallexample
11927 16#0000#-16#007f#: 2#0xxxxxxx#
11928 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11929 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11930 @end smallexample
11931
11932 @noindent
11933 where the xxx bits correspond to the left-padded bits of the
11934 16-bit character value.  Note that all lower half ASCII characters
11935 are represented as ASCII bytes and all upper half characters and
11936 other wide characters are represented as sequences of upper-half
11937 (The full UTF-8 scheme allows for encoding 31-bit characters as
11938 6-byte sequences, but in this implementation, all UTF-8 sequences
11939 of four or more bytes length will raise a Constraint_Error, as
11940 will all invalid UTF-8 sequences.)
11941
11942 @item Brackets Coding
11943 In this encoding, a wide character is represented by the following eight
11944 character sequence:
11945
11946 @smallexample
11947 [ " a b c d " ]
11948 @end smallexample
11949
11950 @noindent
11951 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11952 characters (using uppercase letters) of the wide character code.  For
11953 example, @code{["A345"]} is used to represent the wide character with code
11954 @code{16#A345#}.
11955 This scheme is compatible with use of the full Wide_Character set.
11956 On input, brackets coding can also be used for upper half characters,
11957 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11958 is only used for wide characters with a code greater than @code{16#FF#}.
11959
11960 Note that brackets coding is not normally used in the context of
11961 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11962 a portable way of encoding source files. In the context of Wide_Text_IO
11963 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11964 any instance of the left bracket character other than to encode wide
11965 character values using the brackets encoding method. In practice it is
11966 expected that some standard wide character encoding method such
11967 as UTF-8 will be used for text input output.
11968
11969 If brackets notation is used, then any occurrence of a left bracket
11970 in the input file which is not the start of a valid wide character
11971 sequence will cause Constraint_Error to be raised. It is possible to
11972 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11973 input will interpret this as a left bracket.
11974
11975 However, when a left bracket is output, it will be output as a left bracket
11976 and not as ["5B"]. We make this decision because for normal use of
11977 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11978 brackets. For example, if we write:
11979
11980 @smallexample
11981    Put_Line ("Start of output [first run]");
11982 @end smallexample
11983
11984 @noindent
11985 we really do not want to have the left bracket in this message clobbered so
11986 that the output reads:
11987
11988 @smallexample
11989    Start of output ["5B"]first run]
11990 @end smallexample
11991
11992 @noindent
11993 In practice brackets encoding is reasonably useful for normal Put_Line use
11994 since we won't get confused between left brackets and wide character
11995 sequences in the output. But for input, or when files are written out
11996 and read back in, it really makes better sense to use one of the standard
11997 encoding methods such as UTF-8.
11998
11999 @end table
12000
12001 @noindent
12002 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12003 not all wide character
12004 values can be represented.  An attempt to output a character that cannot
12005 be represented using the encoding scheme for the file causes
12006 Constraint_Error to be raised.  An invalid wide character sequence on
12007 input also causes Constraint_Error to be raised.
12008
12009 @menu
12010 * Wide_Text_IO Stream Pointer Positioning::
12011 * Wide_Text_IO Reading and Writing Non-Regular Files::
12012 @end menu
12013
12014 @node Wide_Text_IO Stream Pointer Positioning
12015 @subsection Stream Pointer Positioning
12016
12017 @noindent
12018 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12019 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12020 case:
12021
12022 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12023 normal lower ASCII set (i.e.@: a character in the range:
12024
12025 @smallexample @c ada
12026 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12027 @end smallexample
12028
12029 @noindent
12030 then although the logical position of the file pointer is unchanged by
12031 the @code{Look_Ahead} call, the stream is physically positioned past the
12032 wide character sequence.  Again this is to avoid the need for buffering
12033 or backup, and all @code{Wide_Text_IO} routines check the internal
12034 indication that this situation has occurred so that this is not visible
12035 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12036 can be observed if the wide text file shares a stream with another file.
12037
12038 @node Wide_Text_IO Reading and Writing Non-Regular Files
12039 @subsection Reading and Writing Non-Regular Files
12040
12041 @noindent
12042 As in the case of Text_IO, when a non-regular file is read, it is
12043 assumed that the file contains no page marks (any form characters are
12044 treated as data characters), and @code{End_Of_Page} always returns
12045 @code{False}.  Similarly, the end of file indication is not sticky, so
12046 it is possible to read beyond an end of file.
12047
12048 @node Wide_Wide_Text_IO
12049 @section Wide_Wide_Text_IO
12050
12051 @noindent
12052 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12053 both input and output files may contain special sequences that represent
12054 wide wide character values.  The encoding scheme for a given file may be
12055 specified using a FORM parameter:
12056
12057 @smallexample
12058 WCEM=@var{x}
12059 @end smallexample
12060
12061 @noindent
12062 as part of the FORM string (WCEM = wide character encoding method),
12063 where @var{x} is one of the following characters
12064
12065 @table @samp
12066 @item h
12067 Hex ESC encoding
12068 @item u
12069 Upper half encoding
12070 @item s
12071 Shift-JIS encoding
12072 @item e
12073 EUC Encoding
12074 @item 8
12075 UTF-8 encoding
12076 @item b
12077 Brackets encoding
12078 @end table
12079
12080 @noindent
12081 The encoding methods match those that
12082 can be used in a source
12083 program, but there is no requirement that the encoding method used for
12084 the source program be the same as the encoding method used for files,
12085 and different files may use different encoding methods.
12086
12087 The default encoding method for the standard files, and for opened files
12088 for which no WCEM parameter is given in the FORM string matches the
12089 wide character encoding specified for the main program (the default
12090 being brackets encoding if no coding method was specified with -gnatW).
12091
12092 @table @asis
12093
12094 @item UTF-8 Coding
12095 A wide character is represented using
12096 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12097 10646-1/Am.2.  Depending on the character value, the representation
12098 is a one, two, three, or four byte sequence:
12099
12100 @smallexample
12101 16#000000#-16#00007f#: 2#0xxxxxxx#
12102 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12103 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12104 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12105 @end smallexample
12106
12107 @noindent
12108 where the xxx bits correspond to the left-padded bits of the
12109 21-bit character value.  Note that all lower half ASCII characters
12110 are represented as ASCII bytes and all upper half characters and
12111 other wide characters are represented as sequences of upper-half
12112 characters.
12113
12114 @item Brackets Coding
12115 In this encoding, a wide wide character is represented by the following eight
12116 character sequence if is in wide character range
12117
12118 @smallexample
12119 [ " a b c d " ]
12120 @end smallexample
12121
12122 and by the following ten character sequence if not
12123
12124 @smallexample
12125 [ " a b c d e f " ]
12126 @end smallexample
12127
12128 @noindent
12129 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12130 are the four or six hexadecimal
12131 characters (using uppercase letters) of the wide wide character code.  For
12132 example, @code{["01A345"]} is used to represent the wide wide character
12133 with code @code{16#01A345#}.
12134
12135 This scheme is compatible with use of the full Wide_Wide_Character set.
12136 On input, brackets coding can also be used for upper half characters,
12137 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12138 is only used for wide characters with a code greater than @code{16#FF#}.
12139
12140 @end table
12141
12142 @noindent
12143 If is also possible to use the other Wide_Character encoding methods,
12144 such as Shift-JIS, but the other schemes cannot support the full range
12145 of wide wide characters.
12146 An attempt to output a character that cannot
12147 be represented using the encoding scheme for the file causes
12148 Constraint_Error to be raised.  An invalid wide character sequence on
12149 input also causes Constraint_Error to be raised.
12150
12151 @menu
12152 * Wide_Wide_Text_IO Stream Pointer Positioning::
12153 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12154 @end menu
12155
12156 @node Wide_Wide_Text_IO Stream Pointer Positioning
12157 @subsection Stream Pointer Positioning
12158
12159 @noindent
12160 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12161 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12162 case:
12163
12164 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12165 normal lower ASCII set (i.e.@: a character in the range:
12166
12167 @smallexample @c ada
12168 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12169 @end smallexample
12170
12171 @noindent
12172 then although the logical position of the file pointer is unchanged by
12173 the @code{Look_Ahead} call, the stream is physically positioned past the
12174 wide character sequence.  Again this is to avoid the need for buffering
12175 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12176 indication that this situation has occurred so that this is not visible
12177 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12178 can be observed if the wide text file shares a stream with another file.
12179
12180 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12181 @subsection Reading and Writing Non-Regular Files
12182
12183 @noindent
12184 As in the case of Text_IO, when a non-regular file is read, it is
12185 assumed that the file contains no page marks (any form characters are
12186 treated as data characters), and @code{End_Of_Page} always returns
12187 @code{False}.  Similarly, the end of file indication is not sticky, so
12188 it is possible to read beyond an end of file.
12189
12190 @node Stream_IO
12191 @section Stream_IO
12192
12193 @noindent
12194 A stream file is a sequence of bytes, where individual elements are
12195 written to the file as described in the Ada Reference Manual.  The type
12196 @code{Stream_Element} is simply a byte.  There are two ways to read or
12197 write a stream file.
12198
12199 @itemize @bullet
12200 @item
12201 The operations @code{Read} and @code{Write} directly read or write a
12202 sequence of stream elements with no control information.
12203
12204 @item
12205 The stream attributes applied to a stream file transfer data in the
12206 manner described for stream attributes.
12207 @end itemize
12208
12209 @node Shared Files
12210 @section Shared Files
12211
12212 @noindent
12213 Section A.14 of the Ada Reference Manual allows implementations to
12214 provide a wide variety of behavior if an attempt is made to access the
12215 same external file with two or more internal files.
12216
12217 To provide a full range of functionality, while at the same time
12218 minimizing the problems of portability caused by this implementation
12219 dependence, GNAT handles file sharing as follows:
12220
12221 @itemize @bullet
12222 @item
12223 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12224 to open two or more files with the same full name is considered an error
12225 and is not supported.  The exception @code{Use_Error} will be
12226 raised.  Note that a file that is not explicitly closed by the program
12227 remains open until the program terminates.
12228
12229 @item
12230 If the form parameter @samp{shared=no} appears in the form string, the
12231 file can be opened or created with its own separate stream identifier,
12232 regardless of whether other files sharing the same external file are
12233 opened.  The exact effect depends on how the C stream routines handle
12234 multiple accesses to the same external files using separate streams.
12235
12236 @item
12237 If the form parameter @samp{shared=yes} appears in the form string for
12238 each of two or more files opened using the same full name, the same
12239 stream is shared between these files, and the semantics are as described
12240 in Ada Reference Manual, Section A.14.
12241 @end itemize
12242
12243 @noindent
12244 When a program that opens multiple files with the same name is ported
12245 from another Ada compiler to GNAT, the effect will be that
12246 @code{Use_Error} is raised.
12247
12248 The documentation of the original compiler and the documentation of the
12249 program should then be examined to determine if file sharing was
12250 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12251 and @code{Create} calls as required.
12252
12253 When a program is ported from GNAT to some other Ada compiler, no
12254 special attention is required unless the @samp{shared=@var{xxx}} form
12255 parameter is used in the program.  In this case, you must examine the
12256 documentation of the new compiler to see if it supports the required
12257 file sharing semantics, and form strings modified appropriately.  Of
12258 course it may be the case that the program cannot be ported if the
12259 target compiler does not support the required functionality.  The best
12260 approach in writing portable code is to avoid file sharing (and hence
12261 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12262 completely.
12263
12264 One common use of file sharing in Ada 83 is the use of instantiations of
12265 Sequential_IO on the same file with different types, to achieve
12266 heterogeneous input-output.  Although this approach will work in GNAT if
12267 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12268 for this purpose (using the stream attributes)
12269
12270 @node Filenames encoding
12271 @section Filenames encoding
12272
12273 @noindent
12274 An encoding form parameter can be used to specify the filename
12275 encoding @samp{encoding=@var{xxx}}.
12276
12277 @itemize @bullet
12278 @item
12279 If the form parameter @samp{encoding=utf8} appears in the form string, the
12280 filename must be encoded in UTF-8.
12281
12282 @item
12283 If the form parameter @samp{encoding=8bits} appears in the form
12284 string, the filename must be a standard 8bits string.
12285 @end itemize
12286
12287 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12288 value UTF-8 is used. This encoding form parameter is only supported on
12289 the Windows platform. On the other Operating Systems the runtime is
12290 supporting UTF-8 natively.
12291
12292 @node Open Modes
12293 @section Open Modes
12294
12295 @noindent
12296 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12297 using the mode shown in the following table:
12298
12299 @sp 2
12300 @center @code{Open} and @code{Create} Call Modes
12301 @smallexample
12302                                @b{OPEN }           @b{CREATE}
12303 Append_File                    "r+"             "w+"
12304 In_File                        "r"              "w+"
12305 Out_File (Direct_IO)           "r+"             "w"
12306 Out_File (all other cases)     "w"              "w"
12307 Inout_File                     "r+"             "w+"
12308 @end smallexample
12309
12310 @noindent
12311 If text file translation is required, then either @samp{b} or @samp{t}
12312 is added to the mode, depending on the setting of Text.  Text file
12313 translation refers to the mapping of CR/LF sequences in an external file
12314 to LF characters internally.  This mapping only occurs in DOS and
12315 DOS-like systems, and is not relevant to other systems.
12316
12317 A special case occurs with Stream_IO@.  As shown in the above table, the
12318 file is initially opened in @samp{r} or @samp{w} mode for the
12319 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12320 subsequently requires switching from reading to writing or vice-versa,
12321 then the file is reopened in @samp{r+} mode to permit the required operation.
12322
12323 @node Operations on C Streams
12324 @section Operations on C Streams
12325 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12326 access to the C library functions for operations on C streams:
12327
12328 @smallexample @c adanocomment
12329 package Interfaces.C_Streams is
12330   -- Note: the reason we do not use the types that are in
12331   -- Interfaces.C is that we want to avoid dragging in the
12332   -- code in this unit if possible.
12333   subtype chars is System.Address;
12334   -- Pointer to null-terminated array of characters
12335   subtype FILEs is System.Address;
12336   -- Corresponds to the C type FILE*
12337   subtype voids is System.Address;
12338   -- Corresponds to the C type void*
12339   subtype int is Integer;
12340   subtype long is Long_Integer;
12341   -- Note: the above types are subtypes deliberately, and it
12342   -- is part of this spec that the above correspondences are
12343   -- guaranteed.  This means that it is legitimate to, for
12344   -- example, use Integer instead of int.  We provide these
12345   -- synonyms for clarity, but in some cases it may be
12346   -- convenient to use the underlying types (for example to
12347   -- avoid an unnecessary dependency of a spec on the spec
12348   -- of this unit).
12349   type size_t is mod 2 ** Standard'Address_Size;
12350   NULL_Stream : constant FILEs;
12351   -- Value returned (NULL in C) to indicate an
12352   -- fdopen/fopen/tmpfile error
12353   ----------------------------------
12354   -- Constants Defined in stdio.h --
12355   ----------------------------------
12356   EOF : constant int;
12357   -- Used by a number of routines to indicate error or
12358   -- end of file
12359   IOFBF : constant int;
12360   IOLBF : constant int;
12361   IONBF : constant int;
12362   -- Used to indicate buffering mode for setvbuf call
12363   SEEK_CUR : constant int;
12364   SEEK_END : constant int;
12365   SEEK_SET : constant int;
12366   -- Used to indicate origin for fseek call
12367   function stdin return FILEs;
12368   function stdout return FILEs;
12369   function stderr return FILEs;
12370   -- Streams associated with standard files
12371   --------------------------
12372   -- Standard C functions --
12373   --------------------------
12374   -- The functions selected below are ones that are
12375   -- available in DOS, OS/2, UNIX and Xenix (but not
12376   -- necessarily in ANSI C).  These are very thin interfaces
12377   -- which copy exactly the C headers.  For more
12378   -- documentation on these functions, see the Microsoft C
12379   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12380   -- ISBN 1-55615-225-6), which includes useful information
12381   -- on system compatibility.
12382   procedure clearerr (stream : FILEs);
12383   function fclose (stream : FILEs) return int;
12384   function fdopen (handle : int; mode : chars) return FILEs;
12385   function feof (stream : FILEs) return int;
12386   function ferror (stream : FILEs) return int;
12387   function fflush (stream : FILEs) return int;
12388   function fgetc (stream : FILEs) return int;
12389   function fgets (strng : chars; n : int; stream : FILEs)
12390       return chars;
12391   function fileno (stream : FILEs) return int;
12392   function fopen (filename : chars; Mode : chars)
12393       return FILEs;
12394   -- Note: to maintain target independence, use
12395   -- text_translation_required, a boolean variable defined in
12396   -- a-sysdep.c to deal with the target dependent text
12397   -- translation requirement.  If this variable is set,
12398   -- then  b/t should be appended to the standard mode
12399   -- argument to set the text translation mode off or on
12400   -- as required.
12401   function fputc (C : int; stream : FILEs) return int;
12402   function fputs (Strng : chars; Stream : FILEs) return int;
12403   function fread
12404      (buffer : voids;
12405       size : size_t;
12406       count : size_t;
12407       stream : FILEs)
12408       return size_t;
12409   function freopen
12410      (filename : chars;
12411       mode : chars;
12412       stream : FILEs)
12413       return FILEs;
12414   function fseek
12415      (stream : FILEs;
12416       offset : long;
12417       origin : int)
12418       return int;
12419   function ftell (stream : FILEs) return long;
12420   function fwrite
12421      (buffer : voids;
12422       size : size_t;
12423       count : size_t;
12424       stream : FILEs)
12425       return size_t;
12426   function isatty (handle : int) return int;
12427   procedure mktemp (template : chars);
12428   -- The return value (which is just a pointer to template)
12429   -- is discarded
12430   procedure rewind (stream : FILEs);
12431   function rmtmp return int;
12432   function setvbuf
12433      (stream : FILEs;
12434       buffer : chars;
12435       mode : int;
12436       size : size_t)
12437       return int;
12438
12439   function tmpfile return FILEs;
12440   function ungetc (c : int; stream : FILEs) return int;
12441   function unlink (filename : chars) return int;
12442   ---------------------
12443   -- Extra functions --
12444   ---------------------
12445   -- These functions supply slightly thicker bindings than
12446   -- those above.  They are derived from functions in the
12447   -- C Run-Time Library, but may do a bit more work than
12448   -- just directly calling one of the Library functions.
12449   function is_regular_file (handle : int) return int;
12450   -- Tests if given handle is for a regular file (result 1)
12451   -- or for a non-regular file (pipe or device, result 0).
12452   ---------------------------------
12453   -- Control of Text/Binary Mode --
12454   ---------------------------------
12455   -- If text_translation_required is true, then the following
12456   -- functions may be used to dynamically switch a file from
12457   -- binary to text mode or vice versa.  These functions have
12458   -- no effect if text_translation_required is false (i.e.  in
12459   -- normal UNIX mode).  Use fileno to get a stream handle.
12460   procedure set_binary_mode (handle : int);
12461   procedure set_text_mode (handle : int);
12462   ----------------------------
12463   -- Full Path Name support --
12464   ----------------------------
12465   procedure full_name (nam : chars; buffer : chars);
12466   -- Given a NUL terminated string representing a file
12467   -- name, returns in buffer a NUL terminated string
12468   -- representing the full path name for the file name.
12469   -- On systems where it is relevant the   drive is also
12470   -- part of the full path name.  It is the responsibility
12471   -- of the caller to pass an actual parameter for buffer
12472   -- that is big enough for any full path name.  Use
12473   -- max_path_len given below as the size of buffer.
12474   max_path_len : integer;
12475   -- Maximum length of an allowable full path name on the
12476   -- system, including a terminating NUL character.
12477 end Interfaces.C_Streams;
12478 @end smallexample
12479
12480 @node Interfacing to C Streams
12481 @section Interfacing to C Streams
12482
12483 @noindent
12484 The packages in this section permit interfacing Ada files to C Stream
12485 operations.
12486
12487 @smallexample @c ada
12488  with Interfaces.C_Streams;
12489  package Ada.Sequential_IO.C_Streams is
12490     function C_Stream (F : File_Type)
12491        return Interfaces.C_Streams.FILEs;
12492     procedure Open
12493       (File : in out File_Type;
12494        Mode : in File_Mode;
12495        C_Stream : in Interfaces.C_Streams.FILEs;
12496        Form : in String := "");
12497  end Ada.Sequential_IO.C_Streams;
12498
12499   with Interfaces.C_Streams;
12500   package Ada.Direct_IO.C_Streams is
12501      function C_Stream (F : File_Type)
12502         return Interfaces.C_Streams.FILEs;
12503      procedure Open
12504        (File : in out File_Type;
12505         Mode : in File_Mode;
12506         C_Stream : in Interfaces.C_Streams.FILEs;
12507         Form : in String := "");
12508   end Ada.Direct_IO.C_Streams;
12509
12510   with Interfaces.C_Streams;
12511   package Ada.Text_IO.C_Streams is
12512      function C_Stream (F : File_Type)
12513         return Interfaces.C_Streams.FILEs;
12514      procedure Open
12515        (File : in out File_Type;
12516         Mode : in File_Mode;
12517         C_Stream : in Interfaces.C_Streams.FILEs;
12518         Form : in String := "");
12519   end Ada.Text_IO.C_Streams;
12520
12521   with Interfaces.C_Streams;
12522   package Ada.Wide_Text_IO.C_Streams is
12523      function C_Stream (F : File_Type)
12524         return Interfaces.C_Streams.FILEs;
12525      procedure Open
12526        (File : in out File_Type;
12527         Mode : in File_Mode;
12528         C_Stream : in Interfaces.C_Streams.FILEs;
12529         Form : in String := "");
12530  end Ada.Wide_Text_IO.C_Streams;
12531
12532   with Interfaces.C_Streams;
12533   package Ada.Wide_Wide_Text_IO.C_Streams is
12534      function C_Stream (F : File_Type)
12535         return Interfaces.C_Streams.FILEs;
12536      procedure Open
12537        (File : in out File_Type;
12538         Mode : in File_Mode;
12539         C_Stream : in Interfaces.C_Streams.FILEs;
12540         Form : in String := "");
12541  end Ada.Wide_Wide_Text_IO.C_Streams;
12542
12543  with Interfaces.C_Streams;
12544  package Ada.Stream_IO.C_Streams is
12545     function C_Stream (F : File_Type)
12546        return Interfaces.C_Streams.FILEs;
12547     procedure Open
12548       (File : in out File_Type;
12549        Mode : in File_Mode;
12550        C_Stream : in Interfaces.C_Streams.FILEs;
12551        Form : in String := "");
12552  end Ada.Stream_IO.C_Streams;
12553 @end smallexample
12554
12555 @noindent
12556 In each of these six packages, the @code{C_Stream} function obtains the
12557 @code{FILE} pointer from a currently opened Ada file.  It is then
12558 possible to use the @code{Interfaces.C_Streams} package to operate on
12559 this stream, or the stream can be passed to a C program which can
12560 operate on it directly.  Of course the program is responsible for
12561 ensuring that only appropriate sequences of operations are executed.
12562
12563 One particular use of relevance to an Ada program is that the
12564 @code{setvbuf} function can be used to control the buffering of the
12565 stream used by an Ada file.  In the absence of such a call the standard
12566 default buffering is used.
12567
12568 The @code{Open} procedures in these packages open a file giving an
12569 existing C Stream instead of a file name.  Typically this stream is
12570 imported from a C program, allowing an Ada file to operate on an
12571 existing C file.
12572
12573 @node The GNAT Library
12574 @chapter The GNAT Library
12575
12576 @noindent
12577 The GNAT library contains a number of general and special purpose packages.
12578 It represents functionality that the GNAT developers have found useful, and
12579 which is made available to GNAT users.  The packages described here are fully
12580 supported, and upwards compatibility will be maintained in future releases,
12581 so you can use these facilities with the confidence that the same functionality
12582 will be available in future releases.
12583
12584 The chapter here simply gives a brief summary of the facilities available.
12585 The full documentation is found in the spec file for the package.  The full
12586 sources of these library packages, including both spec and body, are provided
12587 with all GNAT releases.  For example, to find out the full specifications of
12588 the SPITBOL pattern matching capability, including a full tutorial and
12589 extensive examples, look in the @file{g-spipat.ads} file in the library.
12590
12591 For each entry here, the package name (as it would appear in a @code{with}
12592 clause) is given, followed by the name of the corresponding spec file in
12593 parentheses.  The packages are children in four hierarchies, @code{Ada},
12594 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12595 GNAT-specific hierarchy.
12596
12597 Note that an application program should only use packages in one of these
12598 four hierarchies if the package is defined in the Ada Reference Manual,
12599 or is listed in this section of the GNAT Programmers Reference Manual.
12600 All other units should be considered internal implementation units and
12601 should not be directly @code{with}'ed by application code.  The use of
12602 a @code{with} statement that references one of these internal implementation
12603 units makes an application potentially dependent on changes in versions
12604 of GNAT, and will generate a warning message.
12605
12606 @menu
12607 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12608 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12609 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12610 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12611 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12612 * Ada.Command_Line.Remove (a-colire.ads)::
12613 * Ada.Command_Line.Environment (a-colien.ads)::
12614 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12615 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12616 * Ada.Exceptions.Traceback (a-exctra.ads)::
12617 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12618 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12619 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12620 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12621 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12622 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12623 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12624 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12625 * GNAT.Altivec (g-altive.ads)::
12626 * GNAT.Altivec.Conversions (g-altcon.ads)::
12627 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12628 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12629 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12630 * GNAT.Array_Split (g-arrspl.ads)::
12631 * GNAT.AWK (g-awk.ads)::
12632 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12633 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12634 * GNAT.Bubble_Sort (g-bubsor.ads)::
12635 * GNAT.Bubble_Sort_A (g-busora.ads)::
12636 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12637 * GNAT.Byte_Swapping (g-bytswa.ads)::
12638 * GNAT.Calendar (g-calend.ads)::
12639 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12640 * GNAT.CRC32 (g-crc32.ads)::
12641 * GNAT.Case_Util (g-casuti.ads)::
12642 * GNAT.CGI (g-cgi.ads)::
12643 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12644 * GNAT.CGI.Debug (g-cgideb.ads)::
12645 * GNAT.Command_Line (g-comlin.ads)::
12646 * GNAT.Compiler_Version (g-comver.ads)::
12647 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12648 * GNAT.Current_Exception (g-curexc.ads)::
12649 * GNAT.Debug_Pools (g-debpoo.ads)::
12650 * GNAT.Debug_Utilities (g-debuti.ads)::
12651 * GNAT.Directory_Operations (g-dirope.ads)::
12652 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12653 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12654 * GNAT.Exception_Actions (g-excact.ads)::
12655 * GNAT.Exception_Traces (g-exctra.ads)::
12656 * GNAT.Exceptions (g-except.ads)::
12657 * GNAT.Expect (g-expect.ads)::
12658 * GNAT.Float_Control (g-flocon.ads)::
12659 * GNAT.Heap_Sort (g-heasor.ads)::
12660 * GNAT.Heap_Sort_A (g-hesora.ads)::
12661 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12662 * GNAT.HTable (g-htable.ads)::
12663 * GNAT.IO (g-io.ads)::
12664 * GNAT.IO_Aux (g-io_aux.ads)::
12665 * GNAT.Lock_Files (g-locfil.ads)::
12666 * GNAT.MD5 (g-md5.ads)::
12667 * GNAT.Memory_Dump (g-memdum.ads)::
12668 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12669 * GNAT.OS_Lib (g-os_lib.ads)::
12670 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12671 * GNAT.Regexp (g-regexp.ads)::
12672 * GNAT.Registry (g-regist.ads)::
12673 * GNAT.Regpat (g-regpat.ads)::
12674 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12675 * GNAT.Semaphores (g-semaph.ads)::
12676 * GNAT.SHA1 (g-sha1.ads)::
12677 * GNAT.Signals (g-signal.ads)::
12678 * GNAT.Sockets (g-socket.ads)::
12679 * GNAT.Source_Info (g-souinf.ads)::
12680 * GNAT.Spell_Checker (g-speche.ads)::
12681 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12682 * GNAT.Spitbol (g-spitbo.ads)::
12683 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12684 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12685 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12686 * GNAT.Strings (g-string.ads)::
12687 * GNAT.String_Split (g-strspl.ads)::
12688 * GNAT.UTF_32 (g-utf_32.ads)::
12689 * GNAT.Table (g-table.ads)::
12690 * GNAT.Task_Lock (g-tasloc.ads)::
12691 * GNAT.Threads (g-thread.ads)::
12692 * GNAT.Traceback (g-traceb.ads)::
12693 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12694 * GNAT.Wide_String_Split (g-wistsp.ads)::
12695 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12696 * Interfaces.C.Extensions (i-cexten.ads)::
12697 * Interfaces.C.Streams (i-cstrea.ads)::
12698 * Interfaces.CPP (i-cpp.ads)::
12699 * Interfaces.Os2lib (i-os2lib.ads)::
12700 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12701 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12702 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12703 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12704 * Interfaces.VxWorks (i-vxwork.ads)::
12705 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12706 * System.Address_Image (s-addima.ads)::
12707 * System.Assertions (s-assert.ads)::
12708 * System.Memory (s-memory.ads)::
12709 * System.Partition_Interface (s-parint.ads)::
12710 * System.Restrictions (s-restri.ads)::
12711 * System.Rident (s-rident.ads)::
12712 * System.Task_Info (s-tasinf.ads)::
12713 * System.Wch_Cnv (s-wchcnv.ads)::
12714 * System.Wch_Con (s-wchcon.ads)::
12715 @end menu
12716
12717 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12718 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12719 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12720 @cindex Latin_9 constants for Character
12721
12722 @noindent
12723 This child of @code{Ada.Characters}
12724 provides a set of definitions corresponding to those in the
12725 RM-defined package @code{Ada.Characters.Latin_1} but with the
12726 few modifications required for @code{Latin-9}
12727 The provision of such a package
12728 is specifically authorized by the Ada Reference Manual
12729 (RM A.3.3(27)).
12730
12731 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12732 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12733 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12734 @cindex Latin_1 constants for Wide_Character
12735
12736 @noindent
12737 This child of @code{Ada.Characters}
12738 provides a set of definitions corresponding to those in the
12739 RM-defined package @code{Ada.Characters.Latin_1} but with the
12740 types of the constants being @code{Wide_Character}
12741 instead of @code{Character}.  The provision of such a package
12742 is specifically authorized by the Ada Reference Manual
12743 (RM A.3.3(27)).
12744
12745 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12746 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12747 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12748 @cindex Latin_9 constants for Wide_Character
12749
12750 @noindent
12751 This child of @code{Ada.Characters}
12752 provides a set of definitions corresponding to those in the
12753 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12754 types of the constants being @code{Wide_Character}
12755 instead of @code{Character}.  The provision of such a package
12756 is specifically authorized by the Ada Reference Manual
12757 (RM A.3.3(27)).
12758
12759 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12760 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12761 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12762 @cindex Latin_1 constants for Wide_Wide_Character
12763
12764 @noindent
12765 This child of @code{Ada.Characters}
12766 provides a set of definitions corresponding to those in the
12767 RM-defined package @code{Ada.Characters.Latin_1} but with the
12768 types of the constants being @code{Wide_Wide_Character}
12769 instead of @code{Character}.  The provision of such a package
12770 is specifically authorized by the Ada Reference Manual
12771 (RM A.3.3(27)).
12772
12773 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12774 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12775 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12776 @cindex Latin_9 constants for Wide_Wide_Character
12777
12778 @noindent
12779 This child of @code{Ada.Characters}
12780 provides a set of definitions corresponding to those in the
12781 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12782 types of the constants being @code{Wide_Wide_Character}
12783 instead of @code{Character}.  The provision of such a package
12784 is specifically authorized by the Ada Reference Manual
12785 (RM A.3.3(27)).
12786
12787 @node Ada.Command_Line.Remove (a-colire.ads)
12788 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12789 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12790 @cindex Removing command line arguments
12791 @cindex Command line, argument removal
12792
12793 @noindent
12794 This child of @code{Ada.Command_Line}
12795 provides a mechanism for logically removing
12796 arguments from the argument list.  Once removed, an argument is not visible
12797 to further calls on the subprograms in @code{Ada.Command_Line} will not
12798 see the removed argument.
12799
12800 @node Ada.Command_Line.Environment (a-colien.ads)
12801 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12802 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12803 @cindex Environment entries
12804
12805 @noindent
12806 This child of @code{Ada.Command_Line}
12807 provides a mechanism for obtaining environment values on systems
12808 where this concept makes sense.
12809
12810 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12811 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12812 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12813 @cindex C Streams, Interfacing with Direct_IO
12814
12815 @noindent
12816 This package provides subprograms that allow interfacing between
12817 C streams and @code{Direct_IO}.  The stream identifier can be
12818 extracted from a file opened on the Ada side, and an Ada file
12819 can be constructed from a stream opened on the C side.
12820
12821 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12822 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12823 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12824 @cindex Null_Occurrence, testing for
12825
12826 @noindent
12827 This child subprogram provides a way of testing for the null
12828 exception occurrence (@code{Null_Occurrence}) without raising
12829 an exception.
12830
12831 @node Ada.Exceptions.Traceback (a-exctra.ads)
12832 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12833 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12834 @cindex Traceback for Exception Occurrence
12835
12836 @noindent
12837 This child package provides the subprogram (@code{Tracebacks}) to
12838 give a traceback array of addresses based on an exception
12839 occurrence.
12840
12841 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12842 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12843 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12844 @cindex C Streams, Interfacing with Sequential_IO
12845
12846 @noindent
12847 This package provides subprograms that allow interfacing between
12848 C streams and @code{Sequential_IO}.  The stream identifier can be
12849 extracted from a file opened on the Ada side, and an Ada file
12850 can be constructed from a stream opened on the C side.
12851
12852 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12853 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12854 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12855 @cindex C Streams, Interfacing with Stream_IO
12856
12857 @noindent
12858 This package provides subprograms that allow interfacing between
12859 C streams and @code{Stream_IO}.  The stream identifier can be
12860 extracted from a file opened on the Ada side, and an Ada file
12861 can be constructed from a stream opened on the C side.
12862
12863 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12864 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12865 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12866 @cindex @code{Unbounded_String}, IO support
12867 @cindex @code{Text_IO}, extensions for unbounded strings
12868
12869 @noindent
12870 This package provides subprograms for Text_IO for unbounded
12871 strings, avoiding the necessity for an intermediate operation
12872 with ordinary strings.
12873
12874 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12875 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12876 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12877 @cindex @code{Unbounded_Wide_String}, IO support
12878 @cindex @code{Text_IO}, extensions for unbounded wide strings
12879
12880 @noindent
12881 This package provides subprograms for Text_IO for unbounded
12882 wide strings, avoiding the necessity for an intermediate operation
12883 with ordinary wide strings.
12884
12885 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12886 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12887 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12888 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12889 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12890
12891 @noindent
12892 This package provides subprograms for Text_IO for unbounded
12893 wide wide strings, avoiding the necessity for an intermediate operation
12894 with ordinary wide wide strings.
12895
12896 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12897 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12898 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12899 @cindex C Streams, Interfacing with @code{Text_IO}
12900
12901 @noindent
12902 This package provides subprograms that allow interfacing between
12903 C streams and @code{Text_IO}.  The stream identifier can be
12904 extracted from a file opened on the Ada side, and an Ada file
12905 can be constructed from a stream opened on the C side.
12906
12907 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12908 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12909 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12910 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12911
12912 @noindent
12913 This package provides subprograms that allow interfacing between
12914 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12915 extracted from a file opened on the Ada side, and an Ada file
12916 can be constructed from a stream opened on the C side.
12917
12918 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12919 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12920 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12921 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12922
12923 @noindent
12924 This package provides subprograms that allow interfacing between
12925 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12926 extracted from a file opened on the Ada side, and an Ada file
12927 can be constructed from a stream opened on the C side.
12928
12929 @node GNAT.Altivec (g-altive.ads)
12930 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12931 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12932 @cindex AltiVec
12933
12934 @noindent
12935 This is the root package of the GNAT AltiVec binding. It provides
12936 definitions of constants and types common to all the versions of the
12937 binding.
12938
12939 @node GNAT.Altivec.Conversions (g-altcon.ads)
12940 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12941 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12942 @cindex AltiVec
12943
12944 @noindent
12945 This package provides the Vector/View conversion routines.
12946
12947 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12948 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12949 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12950 @cindex AltiVec
12951
12952 @noindent
12953 This package exposes the Ada interface to the AltiVec operations on
12954 vector objects. A soft emulation is included by default in the GNAT
12955 library. The hard binding is provided as a separate package. This unit
12956 is common to both bindings.
12957
12958 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12959 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12960 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12961 @cindex AltiVec
12962
12963 @noindent
12964 This package exposes the various vector types part of the Ada binding
12965 to AltiVec facilities.
12966
12967 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12968 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12969 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12970 @cindex AltiVec
12971
12972 @noindent
12973 This package provides public 'View' data types from/to which private
12974 vector representations can be converted via
12975 GNAT.Altivec.Conversions. This allows convenient access to individual
12976 vector elements and provides a simple way to initialize vector
12977 objects.
12978
12979 @node GNAT.Array_Split (g-arrspl.ads)
12980 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12981 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12982 @cindex Array splitter
12983
12984 @noindent
12985 Useful array-manipulation routines: given a set of separators, split
12986 an array wherever the separators appear, and provide direct access
12987 to the resulting slices.
12988
12989 @node GNAT.AWK (g-awk.ads)
12990 @section @code{GNAT.AWK} (@file{g-awk.ads})
12991 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12992 @cindex Parsing
12993 @cindex AWK
12994
12995 @noindent
12996 Provides AWK-like parsing functions, with an easy interface for parsing one
12997 or more files containing formatted data.  The file is viewed as a database
12998 where each record is a line and a field is a data element in this line.
12999
13000 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13001 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13002 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13003 @cindex Parsing
13004 @cindex Bounded Buffers
13005
13006 @noindent
13007 Provides a concurrent generic bounded buffer abstraction.  Instances are
13008 useful directly or as parts of the implementations of other abstractions,
13009 such as mailboxes.
13010
13011 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13012 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13013 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13014 @cindex Parsing
13015 @cindex Mailboxes
13016
13017 @noindent
13018 Provides a thread-safe asynchronous intertask mailbox communication facility.
13019
13020 @node GNAT.Bubble_Sort (g-bubsor.ads)
13021 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13022 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13023 @cindex Sorting
13024 @cindex Bubble sort
13025
13026 @noindent
13027 Provides a general implementation of bubble sort usable for sorting arbitrary
13028 data items.  Exchange and comparison procedures are provided by passing
13029 access-to-procedure values.
13030
13031 @node GNAT.Bubble_Sort_A (g-busora.ads)
13032 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13033 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13034 @cindex Sorting
13035 @cindex Bubble sort
13036
13037 @noindent
13038 Provides a general implementation of bubble sort usable for sorting arbitrary
13039 data items.  Move and comparison procedures are provided by passing
13040 access-to-procedure values. This is an older version, retained for
13041 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13042
13043 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13044 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13045 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13046 @cindex Sorting
13047 @cindex Bubble sort
13048
13049 @noindent
13050 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13051 are provided as generic parameters, this improves efficiency, especially
13052 if the procedures can be inlined, at the expense of duplicating code for
13053 multiple instantiations.
13054
13055 @node GNAT.Byte_Swapping (g-bytswa.ads)
13056 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13057 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13058 @cindex Byte swapping
13059 @cindex Endian
13060
13061 @noindent
13062 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13063 Machine-specific implementations are available in some cases.
13064
13065 @node GNAT.Calendar (g-calend.ads)
13066 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13067 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13068 @cindex @code{Calendar}
13069
13070 @noindent
13071 Extends the facilities provided by @code{Ada.Calendar} to include handling
13072 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13073 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13074 C @code{timeval} format.
13075
13076 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13077 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13078 @cindex @code{Calendar}
13079 @cindex Time
13080 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13081
13082 @node GNAT.CRC32 (g-crc32.ads)
13083 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13084 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13085 @cindex CRC32
13086 @cindex Cyclic Redundancy Check
13087
13088 @noindent
13089 This package implements the CRC-32 algorithm.  For a full description
13090 of this algorithm see
13091 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13092 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13093 Aug.@: 1988.  Sarwate, D.V@.
13094
13095 @node GNAT.Case_Util (g-casuti.ads)
13096 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13097 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13098 @cindex Casing utilities
13099 @cindex Character handling (@code{GNAT.Case_Util})
13100
13101 @noindent
13102 A set of simple routines for handling upper and lower casing of strings
13103 without the overhead of the full casing tables
13104 in @code{Ada.Characters.Handling}.
13105
13106 @node GNAT.CGI (g-cgi.ads)
13107 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13108 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13109 @cindex CGI (Common Gateway Interface)
13110
13111 @noindent
13112 This is a package for interfacing a GNAT program with a Web server via the
13113 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13114 parameters, which are a set of key/value pairs sent by the Web server.  It
13115 builds a table whose index is the key and provides some services to deal
13116 with this table.
13117
13118 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13119 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13120 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13121 @cindex CGI (Common Gateway Interface) cookie support
13122 @cindex Cookie support in CGI
13123
13124 @noindent
13125 This is a package to interface a GNAT program with a Web server via the
13126 Common Gateway Interface (CGI).  It exports services to deal with Web
13127 cookies (piece of information kept in the Web client software).
13128
13129 @node GNAT.CGI.Debug (g-cgideb.ads)
13130 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13131 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13132 @cindex CGI (Common Gateway Interface) debugging
13133
13134 @noindent
13135 This is a package to help debugging CGI (Common Gateway Interface)
13136 programs written in Ada.
13137
13138 @node GNAT.Command_Line (g-comlin.ads)
13139 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13140 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13141 @cindex Command line
13142
13143 @noindent
13144 Provides a high level interface to @code{Ada.Command_Line} facilities,
13145 including the ability to scan for named switches with optional parameters
13146 and expand file names using wild card notations.
13147
13148 @node GNAT.Compiler_Version (g-comver.ads)
13149 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13150 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13151 @cindex Compiler Version
13152 @cindex Version, of compiler
13153
13154 @noindent
13155 Provides a routine for obtaining the version of the compiler used to
13156 compile the program. More accurately this is the version of the binder
13157 used to bind the program (this will normally be the same as the version
13158 of the compiler if a consistent tool set is used to compile all units
13159 of a partition).
13160
13161 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13162 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13163 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13164 @cindex Interrupt
13165
13166 @noindent
13167 Provides a simple interface to handle Ctrl-C keyboard events.
13168
13169 @node GNAT.Current_Exception (g-curexc.ads)
13170 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13171 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13172 @cindex Current exception
13173 @cindex Exception retrieval
13174
13175 @noindent
13176 Provides access to information on the current exception that has been raised
13177 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13178 specification syntax.
13179 This is particularly useful in simulating typical facilities for
13180 obtaining information about exceptions provided by Ada 83 compilers.
13181
13182 @node GNAT.Debug_Pools (g-debpoo.ads)
13183 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13184 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13185 @cindex Debugging
13186 @cindex Debug pools
13187 @cindex Memory corruption debugging
13188
13189 @noindent
13190 Provide a debugging storage pools that helps tracking memory corruption
13191 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
13192 the @cite{GNAT User's Guide}.
13193
13194 @node GNAT.Debug_Utilities (g-debuti.ads)
13195 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13196 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13197 @cindex Debugging
13198
13199 @noindent
13200 Provides a few useful utilities for debugging purposes, including conversion
13201 to and from string images of address values. Supports both C and Ada formats
13202 for hexadecimal literals.
13203
13204 @node GNAT.Directory_Operations (g-dirope.ads)
13205 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13206 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13207 @cindex Directory operations
13208
13209 @noindent
13210 Provides a set of routines for manipulating directories, including changing
13211 the current directory, making new directories, and scanning the files in a
13212 directory.
13213
13214 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13215 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13216 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13217 @cindex Hash tables
13218
13219 @noindent
13220 A generic implementation of hash tables that can be used to hash arbitrary
13221 data.  Provided in two forms, a simple form with built in hash functions,
13222 and a more complex form in which the hash function is supplied.
13223
13224 @noindent
13225 This package provides a facility similar to that of @code{GNAT.HTable},
13226 except that this package declares a type that can be used to define
13227 dynamic instances of the hash table, while an instantiation of
13228 @code{GNAT.HTable} creates a single instance of the hash table.
13229
13230 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13231 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13232 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13233 @cindex Table implementation
13234 @cindex Arrays, extendable
13235
13236 @noindent
13237 A generic package providing a single dimension array abstraction where the
13238 length of the array can be dynamically modified.
13239
13240 @noindent
13241 This package provides a facility similar to that of @code{GNAT.Table},
13242 except that this package declares a type that can be used to define
13243 dynamic instances of the table, while an instantiation of
13244 @code{GNAT.Table} creates a single instance of the table type.
13245
13246 @node GNAT.Exception_Actions (g-excact.ads)
13247 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13248 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13249 @cindex Exception actions
13250
13251 @noindent
13252 Provides callbacks when an exception is raised. Callbacks can be registered
13253 for specific exceptions, or when any exception is raised. This
13254 can be used for instance to force a core dump to ease debugging.
13255
13256 @node GNAT.Exception_Traces (g-exctra.ads)
13257 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13258 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13259 @cindex Exception traces
13260 @cindex Debugging
13261
13262 @noindent
13263 Provides an interface allowing to control automatic output upon exception
13264 occurrences.
13265
13266 @node GNAT.Exceptions (g-except.ads)
13267 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13268 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13269 @cindex Exceptions, Pure
13270 @cindex Pure packages, exceptions
13271
13272 @noindent
13273 Normally it is not possible to raise an exception with
13274 a message from a subprogram in a pure package, since the
13275 necessary types and subprograms are in @code{Ada.Exceptions}
13276 which is not a pure unit. @code{GNAT.Exceptions} provides a
13277 facility for getting around this limitation for a few
13278 predefined exceptions, and for example allow raising
13279 @code{Constraint_Error} with a message from a pure subprogram.
13280
13281 @node GNAT.Expect (g-expect.ads)
13282 @section @code{GNAT.Expect} (@file{g-expect.ads})
13283 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13284
13285 @noindent
13286 Provides a set of subprograms similar to what is available
13287 with the standard Tcl Expect tool.
13288 It allows you to easily spawn and communicate with an external process.
13289 You can send commands or inputs to the process, and compare the output
13290 with some expected regular expression. Currently @code{GNAT.Expect}
13291 is implemented on all native GNAT ports except for OpenVMS@.
13292 It is not implemented for cross ports, and in particular is not
13293 implemented for VxWorks or LynxOS@.
13294
13295 @node GNAT.Float_Control (g-flocon.ads)
13296 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13297 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13298 @cindex Floating-Point Processor
13299
13300 @noindent
13301 Provides an interface for resetting the floating-point processor into the
13302 mode required for correct semantic operation in Ada.  Some third party
13303 library calls may cause this mode to be modified, and the Reset procedure
13304 in this package can be used to reestablish the required mode.
13305
13306 @node GNAT.Heap_Sort (g-heasor.ads)
13307 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13308 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13309 @cindex Sorting
13310
13311 @noindent
13312 Provides a general implementation of heap sort usable for sorting arbitrary
13313 data items. Exchange and comparison procedures are provided by passing
13314 access-to-procedure values.  The algorithm used is a modified heap sort
13315 that performs approximately N*log(N) comparisons in the worst case.
13316
13317 @node GNAT.Heap_Sort_A (g-hesora.ads)
13318 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13319 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13320 @cindex Sorting
13321
13322 @noindent
13323 Provides a general implementation of heap sort usable for sorting arbitrary
13324 data items. Move and comparison procedures are provided by passing
13325 access-to-procedure values.  The algorithm used is a modified heap sort
13326 that performs approximately N*log(N) comparisons in the worst case.
13327 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13328 interface, but may be slightly more efficient.
13329
13330 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13331 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13332 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13333 @cindex Sorting
13334
13335 @noindent
13336 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13337 are provided as generic parameters, this improves efficiency, especially
13338 if the procedures can be inlined, at the expense of duplicating code for
13339 multiple instantiations.
13340
13341 @node GNAT.HTable (g-htable.ads)
13342 @section @code{GNAT.HTable} (@file{g-htable.ads})
13343 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13344 @cindex Hash tables
13345
13346 @noindent
13347 A generic implementation of hash tables that can be used to hash arbitrary
13348 data.  Provides two approaches, one a simple static approach, and the other
13349 allowing arbitrary dynamic hash tables.
13350
13351 @node GNAT.IO (g-io.ads)
13352 @section @code{GNAT.IO} (@file{g-io.ads})
13353 @cindex @code{GNAT.IO} (@file{g-io.ads})
13354 @cindex Simple I/O
13355 @cindex Input/Output facilities
13356
13357 @noindent
13358 A simple preelaborable input-output package that provides a subset of
13359 simple Text_IO functions for reading characters and strings from
13360 Standard_Input, and writing characters, strings and integers to either
13361 Standard_Output or Standard_Error.
13362
13363 @node GNAT.IO_Aux (g-io_aux.ads)
13364 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13365 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13366 @cindex Text_IO
13367 @cindex Input/Output facilities
13368
13369 Provides some auxiliary functions for use with Text_IO, including a test
13370 for whether a file exists, and functions for reading a line of text.
13371
13372 @node GNAT.Lock_Files (g-locfil.ads)
13373 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13374 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13375 @cindex File locking
13376 @cindex Locking using files
13377
13378 @noindent
13379 Provides a general interface for using files as locks.  Can be used for
13380 providing program level synchronization.
13381
13382 @node GNAT.MD5 (g-md5.ads)
13383 @section @code{GNAT.MD5} (@file{g-md5.ads})
13384 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13385 @cindex Message Digest MD5
13386
13387 @noindent
13388 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13389
13390 @node GNAT.Memory_Dump (g-memdum.ads)
13391 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13392 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13393 @cindex Dump Memory
13394
13395 @noindent
13396 Provides a convenient routine for dumping raw memory to either the
13397 standard output or standard error files. Uses GNAT.IO for actual
13398 output.
13399
13400 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13401 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13402 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13403 @cindex Exception, obtaining most recent
13404
13405 @noindent
13406 Provides access to the most recently raised exception.  Can be used for
13407 various logging purposes, including duplicating functionality of some
13408 Ada 83 implementation dependent extensions.
13409
13410 @node GNAT.OS_Lib (g-os_lib.ads)
13411 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13412 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13413 @cindex Operating System interface
13414 @cindex Spawn capability
13415
13416 @noindent
13417 Provides a range of target independent operating system interface functions,
13418 including time/date management, file operations, subprocess management,
13419 including a portable spawn procedure, and access to environment variables
13420 and error return codes.
13421
13422 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13423 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13424 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13425 @cindex Hash functions
13426
13427 @noindent
13428 Provides a generator of static minimal perfect hash functions. No
13429 collisions occur and each item can be retrieved from the table in one
13430 probe (perfect property). The hash table size corresponds to the exact
13431 size of the key set and no larger (minimal property). The key set has to
13432 be know in advance (static property). The hash functions are also order
13433 preserving. If w2 is inserted after w1 in the generator, their
13434 hashcode are in the same order. These hashing functions are very
13435 convenient for use with realtime applications.
13436
13437 @node GNAT.Regexp (g-regexp.ads)
13438 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13439 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13440 @cindex Regular expressions
13441 @cindex Pattern matching
13442
13443 @noindent
13444 A simple implementation of regular expressions, using a subset of regular
13445 expression syntax copied from familiar Unix style utilities.  This is the
13446 simples of the three pattern matching packages provided, and is particularly
13447 suitable for ``file globbing'' applications.
13448
13449 @node GNAT.Registry (g-regist.ads)
13450 @section @code{GNAT.Registry} (@file{g-regist.ads})
13451 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13452 @cindex Windows Registry
13453
13454 @noindent
13455 This is a high level binding to the Windows registry.  It is possible to
13456 do simple things like reading a key value, creating a new key.  For full
13457 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13458 package provided with the Win32Ada binding
13459
13460 @node GNAT.Regpat (g-regpat.ads)
13461 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13462 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13463 @cindex Regular expressions
13464 @cindex Pattern matching
13465
13466 @noindent
13467 A complete implementation of Unix-style regular expression matching, copied
13468 from the original V7 style regular expression library written in C by
13469 Henry Spencer (and binary compatible with this C library).
13470
13471 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13472 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13473 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13474 @cindex Secondary Stack Info
13475
13476 @noindent
13477 Provide the capability to query the high water mark of the current task's
13478 secondary stack.
13479
13480 @node GNAT.Semaphores (g-semaph.ads)
13481 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13482 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13483 @cindex Semaphores
13484
13485 @noindent
13486 Provides classic counting and binary semaphores using protected types.
13487
13488 @node GNAT.SHA1 (g-sha1.ads)
13489 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13490 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13491 @cindex Secure Hash Algorithm SHA-1
13492
13493 @noindent
13494 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13495
13496 @node GNAT.Signals (g-signal.ads)
13497 @section @code{GNAT.Signals} (@file{g-signal.ads})
13498 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13499 @cindex Signals
13500
13501 @noindent
13502 Provides the ability to manipulate the blocked status of signals on supported
13503 targets.
13504
13505 @node GNAT.Sockets (g-socket.ads)
13506 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13507 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13508 @cindex Sockets
13509
13510 @noindent
13511 A high level and portable interface to develop sockets based applications.
13512 This package is based on the sockets thin binding found in
13513 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13514 on all native GNAT ports except for OpenVMS@.  It is not implemented
13515 for the LynxOS@ cross port.
13516
13517 @node GNAT.Source_Info (g-souinf.ads)
13518 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13519 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13520 @cindex Source Information
13521
13522 @noindent
13523 Provides subprograms that give access to source code information known at
13524 compile time, such as the current file name and line number.
13525
13526 @node GNAT.Spell_Checker (g-speche.ads)
13527 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13528 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13529 @cindex Spell checking
13530
13531 @noindent
13532 Provides a function for determining whether one string is a plausible
13533 near misspelling of another string.
13534
13535 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13536 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13537 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13538 @cindex SPITBOL pattern matching
13539 @cindex Pattern matching
13540
13541 @noindent
13542 A complete implementation of SNOBOL4 style pattern matching.  This is the
13543 most elaborate of the pattern matching packages provided.  It fully duplicates
13544 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13545 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13546
13547 @node GNAT.Spitbol (g-spitbo.ads)
13548 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13549 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13550 @cindex SPITBOL interface
13551
13552 @noindent
13553 The top level package of the collection of SPITBOL-style functionality, this
13554 package provides basic SNOBOL4 string manipulation functions, such as
13555 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13556 useful for constructing arbitrary mappings from strings in the style of
13557 the SNOBOL4 TABLE function.
13558
13559 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13560 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13561 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13562 @cindex Sets of strings
13563 @cindex SPITBOL Tables
13564
13565 @noindent
13566 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13567 for type @code{Standard.Boolean}, giving an implementation of sets of
13568 string values.
13569
13570 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13571 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13572 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13573 @cindex Integer maps
13574 @cindex Maps
13575 @cindex SPITBOL Tables
13576
13577 @noindent
13578 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13579 for type @code{Standard.Integer}, giving an implementation of maps
13580 from string to integer values.
13581
13582 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13583 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13584 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13585 @cindex String maps
13586 @cindex Maps
13587 @cindex SPITBOL Tables
13588
13589 @noindent
13590 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13591 a variable length string type, giving an implementation of general
13592 maps from strings to strings.
13593
13594 @node GNAT.Strings (g-string.ads)
13595 @section @code{GNAT.Strings} (@file{g-string.ads})
13596 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13597
13598 @noindent
13599 Common String access types and related subprograms. Basically it
13600 defines a string access and an array of string access types.
13601
13602 @node GNAT.String_Split (g-strspl.ads)
13603 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13604 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13605 @cindex String splitter
13606
13607 @noindent
13608 Useful string manipulation routines: given a set of separators, split
13609 a string wherever the separators appear, and provide direct access
13610 to the resulting slices. This package is instantiated from
13611 @code{GNAT.Array_Split}.
13612
13613 @node GNAT.UTF_32 (g-utf_32.ads)
13614 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13615 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13616 @cindex Wide character codes
13617
13618 @noindent
13619 This is a package intended to be used in conjunction with the
13620 @code{Wide_Character} type in Ada 95 and the
13621 @code{Wide_Wide_Character} type in Ada 2005 (available
13622 in @code{GNAT} in Ada 2005 mode). This package contains
13623 Unicode categorization routines, as well as lexical
13624 categorization routines corresponding to the Ada 2005
13625 lexical rules for identifiers and strings, and also a
13626 lower case to upper case fold routine corresponding to
13627 the Ada 2005 rules for identifier equivalence.
13628
13629 @node GNAT.Table (g-table.ads)
13630 @section @code{GNAT.Table} (@file{g-table.ads})
13631 @cindex @code{GNAT.Table} (@file{g-table.ads})
13632 @cindex Table implementation
13633 @cindex Arrays, extendable
13634
13635 @noindent
13636 A generic package providing a single dimension array abstraction where the
13637 length of the array can be dynamically modified.
13638
13639 @noindent
13640 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13641 except that this package declares a single instance of the table type,
13642 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13643 used to define dynamic instances of the table.
13644
13645 @node GNAT.Task_Lock (g-tasloc.ads)
13646 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13647 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13648 @cindex Task synchronization
13649 @cindex Task locking
13650 @cindex Locking
13651
13652 @noindent
13653 A very simple facility for locking and unlocking sections of code using a
13654 single global task lock.  Appropriate for use in situations where contention
13655 between tasks is very rarely expected.
13656
13657 @node GNAT.Threads (g-thread.ads)
13658 @section @code{GNAT.Threads} (@file{g-thread.ads})
13659 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13660 @cindex Foreign threads
13661 @cindex Threads, foreign
13662
13663 @noindent
13664 Provides facilities for dealing with foreign threads which need to be known
13665 by the GNAT run-time system. Consult the documentation of this package for
13666 further details if your program has threads that are created by a non-Ada
13667 environment which then accesses Ada code.
13668
13669 @node GNAT.Traceback (g-traceb.ads)
13670 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13671 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13672 @cindex Trace back facilities
13673
13674 @noindent
13675 Provides a facility for obtaining non-symbolic traceback information, useful
13676 in various debugging situations.
13677
13678 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13679 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13680 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13681 @cindex Trace back facilities
13682
13683 @noindent
13684 Provides symbolic traceback information that includes the subprogram
13685 name and line number information. Note that this capability is not available
13686 on all targets, see g-trasym.ads for list of supported targets.
13687
13688 @node GNAT.Wide_String_Split (g-wistsp.ads)
13689 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13690 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13691 @cindex Wide_String splitter
13692
13693 @noindent
13694 Useful wide string manipulation routines: given a set of separators, split
13695 a wide string wherever the separators appear, and provide direct access
13696 to the resulting slices. This package is instantiated from
13697 @code{GNAT.Array_Split}.
13698
13699 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13700 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13701 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13702 @cindex Wide_Wide_String splitter
13703
13704 @noindent
13705 Useful wide wide string manipulation routines: given a set of separators, split
13706 a wide wide string wherever the separators appear, and provide direct access
13707 to the resulting slices. This package is instantiated from
13708 @code{GNAT.Array_Split}.
13709
13710 @node Interfaces.C.Extensions (i-cexten.ads)
13711 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13712 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13713
13714 @noindent
13715 This package contains additional C-related definitions, intended
13716 for use with either manually or automatically generated bindings
13717 to C libraries.
13718
13719 @node Interfaces.C.Streams (i-cstrea.ads)
13720 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13721 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13722 @cindex  C streams, interfacing
13723
13724 @noindent
13725 This package is a binding for the most commonly used operations
13726 on C streams.
13727
13728 @node Interfaces.CPP (i-cpp.ads)
13729 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13730 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13731 @cindex  C++ interfacing
13732 @cindex  Interfacing, to C++
13733
13734 @noindent
13735 This package provides facilities for use in interfacing to C++.  It
13736 is primarily intended to be used in connection with automated tools
13737 for the generation of C++ interfaces.
13738
13739 @node Interfaces.Os2lib (i-os2lib.ads)
13740 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13741 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13742 @cindex Interfacing, to OS/2
13743 @cindex OS/2 interfacing
13744
13745 @noindent
13746 This package provides interface definitions to the OS/2 library.
13747 It is a thin binding which is a direct translation of the
13748 various @file{<bse@.h>} files.
13749
13750 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13751 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13752 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13753 @cindex OS/2 Error codes
13754 @cindex Interfacing, to OS/2
13755 @cindex OS/2 interfacing
13756
13757 @noindent
13758 This package provides definitions of the OS/2 error codes.
13759
13760 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13761 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13762 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13763 @cindex Interfacing, to OS/2
13764 @cindex Synchronization, OS/2
13765 @cindex OS/2 synchronization primitives
13766
13767 @noindent
13768 This is a child package that provides definitions for interfacing
13769 to the @code{OS/2} synchronization primitives.
13770
13771 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13772 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13773 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13774 @cindex Interfacing, to OS/2
13775 @cindex Thread control, OS/2
13776 @cindex OS/2 thread interfacing
13777
13778 @noindent
13779 This is a child package that provides definitions for interfacing
13780 to the @code{OS/2} thread primitives.
13781
13782 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13783 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13784 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13785 @cindex  IBM Packed Format
13786 @cindex  Packed Decimal
13787
13788 @noindent
13789 This package provides a set of routines for conversions to and
13790 from a packed decimal format compatible with that used on IBM
13791 mainframes.
13792
13793 @node Interfaces.VxWorks (i-vxwork.ads)
13794 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13795 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13796 @cindex Interfacing to VxWorks
13797 @cindex VxWorks, interfacing
13798
13799 @noindent
13800 This package provides a limited binding to the VxWorks API.
13801 In particular, it interfaces with the
13802 VxWorks hardware interrupt facilities.
13803
13804 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13805 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13806 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13807 @cindex Interfacing to VxWorks' I/O
13808 @cindex VxWorks, I/O interfacing
13809 @cindex VxWorks, Get_Immediate
13810 @cindex Get_Immediate, VxWorks
13811
13812 @noindent
13813 This package provides a binding to the ioctl (IO/Control)
13814 function of VxWorks, defining a set of option values and
13815 function codes. A particular use of this package is
13816 to enable the use of Get_Immediate under VxWorks.
13817
13818 @node System.Address_Image (s-addima.ads)
13819 @section @code{System.Address_Image} (@file{s-addima.ads})
13820 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13821 @cindex Address image
13822 @cindex Image, of an address
13823
13824 @noindent
13825 This function provides a useful debugging
13826 function that gives an (implementation dependent)
13827 string which identifies an address.
13828
13829 @node System.Assertions (s-assert.ads)
13830 @section @code{System.Assertions} (@file{s-assert.ads})
13831 @cindex @code{System.Assertions} (@file{s-assert.ads})
13832 @cindex Assertions
13833 @cindex Assert_Failure, exception
13834
13835 @noindent
13836 This package provides the declaration of the exception raised
13837 by an run-time assertion failure, as well as the routine that
13838 is used internally to raise this assertion.
13839
13840 @node System.Memory (s-memory.ads)
13841 @section @code{System.Memory} (@file{s-memory.ads})
13842 @cindex @code{System.Memory} (@file{s-memory.ads})
13843 @cindex Memory allocation
13844
13845 @noindent
13846 This package provides the interface to the low level routines used
13847 by the generated code for allocation and freeing storage for the
13848 default storage pool (analogous to the C routines malloc and free.
13849 It also provides a reallocation interface analogous to the C routine
13850 realloc. The body of this unit may be modified to provide alternative
13851 allocation mechanisms for the default pool, and in addition, direct
13852 calls to this unit may be made for low level allocation uses (for
13853 example see the body of @code{GNAT.Tables}).
13854
13855 @node System.Partition_Interface (s-parint.ads)
13856 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13857 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13858 @cindex Partition interfacing functions
13859
13860 @noindent
13861 This package provides facilities for partition interfacing.  It
13862 is used primarily in a distribution context when using Annex E
13863 with @code{GLADE}.
13864
13865 @node System.Restrictions (s-restri.ads)
13866 @section @code{System.Restrictions} (@file{s-restri.ads})
13867 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13868 @cindex Run-time restrictions access
13869
13870 @noindent
13871 This package provides facilities for accessing at run-time
13872 the status of restrictions specified at compile time for
13873 the partition. Information is available both with regard
13874 to actual restrictions specified, and with regard to
13875 compiler determined information on which restrictions
13876 are violated by one or more packages in the partition.
13877
13878 @node System.Rident (s-rident.ads)
13879 @section @code{System.Rident} (@file{s-rident.ads})
13880 @cindex @code{System.Rident} (@file{s-rident.ads})
13881 @cindex Restrictions definitions
13882
13883 @noindent
13884 This package provides definitions of the restrictions
13885 identifiers supported by GNAT, and also the format of
13886 the restrictions provided in package System.Restrictions.
13887 It is not normally necessary to @code{with} this generic package
13888 since the necessary instantiation is included in
13889 package System.Restrictions.
13890
13891 @node System.Task_Info (s-tasinf.ads)
13892 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13893 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13894 @cindex Task_Info pragma
13895
13896 @noindent
13897 This package provides target dependent functionality that is used
13898 to support the @code{Task_Info} pragma
13899
13900 @node System.Wch_Cnv (s-wchcnv.ads)
13901 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13902 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13903 @cindex Wide Character, Representation
13904 @cindex Wide String, Conversion
13905 @cindex Representation of wide characters
13906
13907 @noindent
13908 This package provides routines for converting between
13909 wide and wide wide characters and a representation as a value of type
13910 @code{Standard.String}, using a specified wide character
13911 encoding method.  It uses definitions in
13912 package @code{System.Wch_Con}.
13913
13914 @node System.Wch_Con (s-wchcon.ads)
13915 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13916 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13917
13918 @noindent
13919 This package provides definitions and descriptions of
13920 the various methods used for encoding wide characters
13921 in ordinary strings.  These definitions are used by
13922 the package @code{System.Wch_Cnv}.
13923
13924 @node Interfacing to Other Languages
13925 @chapter Interfacing to Other Languages
13926 @noindent
13927 The facilities in annex B of the Ada Reference Manual are fully
13928 implemented in GNAT, and in addition, a full interface to C++ is
13929 provided.
13930
13931 @menu
13932 * Interfacing to C::
13933 * Interfacing to C++::
13934 * Interfacing to COBOL::
13935 * Interfacing to Fortran::
13936 * Interfacing to non-GNAT Ada code::
13937 @end menu
13938
13939 @node Interfacing to C
13940 @section Interfacing to C
13941
13942 @noindent
13943 Interfacing to C with GNAT can use one of two approaches:
13944
13945 @itemize @bullet
13946 @item
13947 The types in the package @code{Interfaces.C} may be used.
13948 @item
13949 Standard Ada types may be used directly.  This may be less portable to
13950 other compilers, but will work on all GNAT compilers, which guarantee
13951 correspondence between the C and Ada types.
13952 @end itemize
13953
13954 @noindent
13955 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13956 effect, since this is the default.  The following table shows the
13957 correspondence between Ada scalar types and the corresponding C types.
13958
13959 @table @code
13960 @item Integer
13961 @code{int}
13962 @item Short_Integer
13963 @code{short}
13964 @item Short_Short_Integer
13965 @code{signed char}
13966 @item Long_Integer
13967 @code{long}
13968 @item Long_Long_Integer
13969 @code{long long}
13970 @item Short_Float
13971 @code{float}
13972 @item Float
13973 @code{float}
13974 @item Long_Float
13975 @code{double}
13976 @item Long_Long_Float
13977 This is the longest floating-point type supported by the hardware.
13978 @end table
13979
13980 @noindent
13981 Additionally, there are the following general correspondences between Ada
13982 and C types:
13983 @itemize @bullet
13984 @item
13985 Ada enumeration types map to C enumeration types directly if pragma
13986 @code{Convention C} is specified, which causes them to have int
13987 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13988 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13989 @code{int}, respectively) depending on the number of values passed.
13990 This is the only case in which pragma @code{Convention C} affects the
13991 representation of an Ada type.
13992
13993 @item
13994 Ada access types map to C pointers, except for the case of pointers to
13995 unconstrained types in Ada, which have no direct C equivalent.
13996
13997 @item
13998 Ada arrays map directly to C arrays.
13999
14000 @item
14001 Ada records map directly to C structures.
14002
14003 @item
14004 Packed Ada records map to C structures where all members are bit fields
14005 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14006 @end itemize
14007
14008 @node Interfacing to C++
14009 @section Interfacing to C++
14010
14011 @noindent
14012 The interface to C++ makes use of the following pragmas, which are
14013 primarily intended to be constructed automatically using a binding generator
14014 tool, although it is possible to construct them by hand.  No suitable binding
14015 generator tool is supplied with GNAT though.
14016
14017 Using these pragmas it is possible to achieve complete
14018 inter-operability between Ada tagged types and C++ class definitions.
14019 See @ref{Implementation Defined Pragmas}, for more details.
14020
14021 @table @code
14022 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
14023 The argument denotes an entity in the current declarative region that is
14024 declared as a tagged or untagged record type. It indicates that the type
14025 corresponds to an externally declared C++ class type, and is to be laid
14026 out the same way that C++ would lay out the type.
14027
14028 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14029 for backward compatibility but its functionality is available
14030 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14031
14032 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
14033 This pragma identifies an imported function (imported in the usual way
14034 with pragma @code{Import}) as corresponding to a C++ constructor.
14035 @end table
14036
14037 @node Interfacing to COBOL
14038 @section Interfacing to COBOL
14039
14040 @noindent
14041 Interfacing to COBOL is achieved as described in section B.4 of
14042 the Ada Reference Manual.
14043
14044 @node Interfacing to Fortran
14045 @section Interfacing to Fortran
14046
14047 @noindent
14048 Interfacing to Fortran is achieved as described in section B.5 of the
14049 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14050 multi-dimensional array causes the array to be stored in column-major
14051 order as required for convenient interface to Fortran.
14052
14053 @node Interfacing to non-GNAT Ada code
14054 @section Interfacing to non-GNAT Ada code
14055
14056 It is possible to specify the convention @code{Ada} in a pragma
14057 @code{Import} or pragma @code{Export}.  However this refers to
14058 the calling conventions used by GNAT, which may or may not be
14059 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14060 compiler to allow interoperation.
14061
14062 If arguments types are kept simple, and if the foreign compiler generally
14063 follows system calling conventions, then it may be possible to integrate
14064 files compiled by other Ada compilers, provided that the elaboration
14065 issues are adequately addressed (for example by eliminating the
14066 need for any load time elaboration).
14067
14068 In particular, GNAT running on VMS is designed to
14069 be highly compatible with the DEC Ada 83 compiler, so this is one
14070 case in which it is possible to import foreign units of this type,
14071 provided that the data items passed are restricted to simple scalar
14072 values or simple record types without variants, or simple array
14073 types with fixed bounds.
14074
14075 @node Specialized Needs Annexes
14076 @chapter Specialized Needs Annexes
14077
14078 @noindent
14079 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14080 required in all implementations.  However, as described in this chapter,
14081 GNAT implements all of these annexes:
14082
14083 @table @asis
14084 @item Systems Programming (Annex C)
14085 The Systems Programming Annex is fully implemented.
14086
14087 @item Real-Time Systems (Annex D)
14088 The Real-Time Systems Annex is fully implemented.
14089
14090 @item Distributed Systems (Annex E)
14091 Stub generation is fully implemented in the GNAT compiler.  In addition,
14092 a complete compatible PCS is available as part of the GLADE system,
14093 a separate product.  When the two
14094 products are used in conjunction, this annex is fully implemented.
14095
14096 @item Information Systems (Annex F)
14097 The Information Systems annex is fully implemented.
14098
14099 @item Numerics (Annex G)
14100 The Numerics Annex is fully implemented.
14101
14102 @item Safety and Security / High-Integrity Systems (Annex H)
14103 The Safety and Security Annex (termed the High-Integrity Systems Annex
14104 in Ada 2005) is fully implemented.
14105 @end table
14106
14107 @node Implementation of Specific Ada Features
14108 @chapter Implementation of Specific Ada Features
14109
14110 @noindent
14111 This chapter describes the GNAT implementation of several Ada language
14112 facilities.
14113
14114 @menu
14115 * Machine Code Insertions::
14116 * GNAT Implementation of Tasking::
14117 * GNAT Implementation of Shared Passive Packages::
14118 * Code Generation for Array Aggregates::
14119 * The Size of Discriminated Records with Default Discriminants::
14120 * Strict Conformance to the Ada Reference Manual::
14121 @end menu
14122
14123 @node Machine Code Insertions
14124 @section Machine Code Insertions
14125 @cindex Machine Code insertions
14126
14127 @noindent
14128 Package @code{Machine_Code} provides machine code support as described
14129 in the Ada Reference Manual in two separate forms:
14130 @itemize @bullet
14131 @item
14132 Machine code statements, consisting of qualified expressions that
14133 fit the requirements of RM section 13.8.
14134 @item
14135 An intrinsic callable procedure, providing an alternative mechanism of
14136 including machine instructions in a subprogram.
14137 @end itemize
14138
14139 @noindent
14140 The two features are similar, and both are closely related to the mechanism
14141 provided by the asm instruction in the GNU C compiler.  Full understanding
14142 and use of the facilities in this package requires understanding the asm
14143 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14144 by Richard Stallman. The relevant section is titled ``Extensions to the C
14145 Language Family'' @result{} ``Assembler Instructions with C Expression
14146 Operands''.
14147
14148 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14149 semantic restrictions and effects as described below.  Both are provided so
14150 that the procedure call can be used as a statement, and the function call
14151 can be used to form a code_statement.
14152
14153 The first example given in the GCC documentation is the C @code{asm}
14154 instruction:
14155 @smallexample
14156    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14157 @end smallexample
14158
14159 @noindent
14160 The equivalent can be written for GNAT as:
14161
14162 @smallexample @c ada
14163 Asm ("fsinx %1 %0",
14164      My_Float'Asm_Output ("=f", result),
14165      My_Float'Asm_Input  ("f",  angle));
14166 @end smallexample
14167
14168 @noindent
14169 The first argument to @code{Asm} is the assembler template, and is
14170 identical to what is used in GNU C@.  This string must be a static
14171 expression.  The second argument is the output operand list.  It is
14172 either a single @code{Asm_Output} attribute reference, or a list of such
14173 references enclosed in parentheses (technically an array aggregate of
14174 such references).
14175
14176 The @code{Asm_Output} attribute denotes a function that takes two
14177 parameters.  The first is a string, the second is the name of a variable
14178 of the type designated by the attribute prefix.  The first (string)
14179 argument is required to be a static expression and designates the
14180 constraint for the parameter (e.g.@: what kind of register is
14181 required).  The second argument is the variable to be updated with the
14182 result.  The possible values for constraint are the same as those used in
14183 the RTL, and are dependent on the configuration file used to build the
14184 GCC back end.  If there are no output operands, then this argument may
14185 either be omitted, or explicitly given as @code{No_Output_Operands}.
14186
14187 The second argument of @code{@var{my_float}'Asm_Output} functions as
14188 though it were an @code{out} parameter, which is a little curious, but
14189 all names have the form of expressions, so there is no syntactic
14190 irregularity, even though normally functions would not be permitted
14191 @code{out} parameters.  The third argument is the list of input
14192 operands.  It is either a single @code{Asm_Input} attribute reference, or
14193 a list of such references enclosed in parentheses (technically an array
14194 aggregate of such references).
14195
14196 The @code{Asm_Input} attribute denotes a function that takes two
14197 parameters.  The first is a string, the second is an expression of the
14198 type designated by the prefix.  The first (string) argument is required
14199 to be a static expression, and is the constraint for the parameter,
14200 (e.g.@: what kind of register is required).  The second argument is the
14201 value to be used as the input argument.  The possible values for the
14202 constant are the same as those used in the RTL, and are dependent on
14203 the configuration file used to built the GCC back end.
14204
14205 If there are no input operands, this argument may either be omitted, or
14206 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
14207 present in the above example, is a list of register names, called the
14208 @dfn{clobber} argument.  This argument, if given, must be a static string
14209 expression, and is a space or comma separated list of names of registers
14210 that must be considered destroyed as a result of the @code{Asm} call.  If
14211 this argument is the null string (the default value), then the code
14212 generator assumes that no additional registers are destroyed.
14213
14214 The fifth argument, not present in the above example, called the
14215 @dfn{volatile} argument, is by default @code{False}.  It can be set to
14216 the literal value @code{True} to indicate to the code generator that all
14217 optimizations with respect to the instruction specified should be
14218 suppressed, and that in particular, for an instruction that has outputs,
14219 the instruction will still be generated, even if none of the outputs are
14220 used.  See the full description in the GCC manual for further details.
14221 Generally it is strongly advisable to use Volatile for any ASM statement
14222 that is missing either input or output operands, or when two or more ASM
14223 statements appear in sequence, to avoid unwanted optimizations. A warning
14224 is generated if this advice is not followed.
14225
14226 The @code{Asm} subprograms may be used in two ways.  First the procedure
14227 forms can be used anywhere a procedure call would be valid, and
14228 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
14229 be used to intersperse machine instructions with other Ada statements.
14230 Second, the function forms, which return a dummy value of the limited
14231 private type @code{Asm_Insn}, can be used in code statements, and indeed
14232 this is the only context where such calls are allowed.  Code statements
14233 appear as aggregates of the form:
14234
14235 @smallexample @c ada
14236 Asm_Insn'(Asm (@dots{}));
14237 Asm_Insn'(Asm_Volatile (@dots{}));
14238 @end smallexample
14239
14240 @noindent
14241 In accordance with RM rules, such code statements are allowed only
14242 within subprograms whose entire body consists of such statements.  It is
14243 not permissible to intermix such statements with other Ada statements.
14244
14245 Typically the form using intrinsic procedure calls is more convenient
14246 and more flexible.  The code statement form is provided to meet the RM
14247 suggestion that such a facility should be made available.  The following
14248 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14249 is used, the arguments may be given in arbitrary order, following the
14250 normal rules for use of positional and named arguments)
14251
14252 @smallexample
14253 ASM_CALL ::= Asm (
14254                  [Template =>] static_string_EXPRESSION
14255                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14256                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14257                [,[Clobber  =>] static_string_EXPRESSION ]
14258                [,[Volatile =>] static_boolean_EXPRESSION] )
14259
14260 OUTPUT_OPERAND_LIST ::=
14261   [PREFIX.]No_Output_Operands
14262 | OUTPUT_OPERAND_ATTRIBUTE
14263 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14264
14265 OUTPUT_OPERAND_ATTRIBUTE ::=
14266   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14267
14268 INPUT_OPERAND_LIST ::=
14269   [PREFIX.]No_Input_Operands
14270 | INPUT_OPERAND_ATTRIBUTE
14271 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14272
14273 INPUT_OPERAND_ATTRIBUTE ::=
14274   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14275 @end smallexample
14276
14277 @noindent
14278 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14279 are declared in the package @code{Machine_Code} and must be referenced
14280 according to normal visibility rules. In particular if there is no
14281 @code{use} clause for this package, then appropriate package name
14282 qualification is required.
14283
14284 @node GNAT Implementation of Tasking
14285 @section GNAT Implementation of Tasking
14286
14287 @noindent
14288 This chapter outlines the basic GNAT approach to tasking (in particular,
14289 a multi-layered library for portability) and discusses issues related
14290 to compliance with the Real-Time Systems Annex.
14291
14292 @menu
14293 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14294 * Ensuring Compliance with the Real-Time Annex::
14295 @end menu
14296
14297 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14298 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14299
14300 @noindent
14301 GNAT's run-time support comprises two layers:
14302
14303 @itemize @bullet
14304 @item GNARL (GNAT Run-time Layer)
14305 @item GNULL (GNAT Low-level Library)
14306 @end itemize
14307
14308 @noindent
14309 In GNAT, Ada's tasking services rely on a platform and OS independent
14310 layer known as GNARL@.  This code is responsible for implementing the
14311 correct semantics of Ada's task creation, rendezvous, protected
14312 operations etc.
14313
14314 GNARL decomposes Ada's tasking semantics into simpler lower level
14315 operations such as create a thread, set the priority of a thread,
14316 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14317 operations constitutes GNULLI, the GNULL Interface.  This interface is
14318 directly inspired from the POSIX real-time API@.
14319
14320 If the underlying executive or OS implements the POSIX standard
14321 faithfully, the GNULL Interface maps as is to the services offered by
14322 the underlying kernel.  Otherwise, some target dependent glue code maps
14323 the services offered by the underlying kernel to the semantics expected
14324 by GNARL@.
14325
14326 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14327 key point is that each Ada task is mapped on a thread in the underlying
14328 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14329
14330 In addition Ada task priorities map onto the underlying thread priorities.
14331 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14332
14333 @itemize @bullet
14334 @item
14335 The underlying scheduler is used to schedule the Ada tasks.  This
14336 makes Ada tasks as efficient as kernel threads from a scheduling
14337 standpoint.
14338
14339 @item
14340 Interaction with code written in C containing threads is eased
14341 since at the lowest level Ada tasks and C threads map onto the same
14342 underlying kernel concept.
14343
14344 @item
14345 When an Ada task is blocked during I/O the remaining Ada tasks are
14346 able to proceed.
14347
14348 @item
14349 On multiprocessor systems Ada tasks can execute in parallel.
14350 @end itemize
14351
14352 @noindent
14353 Some threads libraries offer a mechanism to fork a new process, with the
14354 child process duplicating the threads from the parent.
14355 GNAT does not
14356 support this functionality when the parent contains more than one task.
14357 @cindex Forking a new process
14358
14359 @node Ensuring Compliance with the Real-Time Annex
14360 @subsection Ensuring Compliance with the Real-Time Annex
14361 @cindex Real-Time Systems Annex compliance
14362
14363 @noindent
14364 Although mapping Ada tasks onto
14365 the underlying threads has significant advantages, it does create some
14366 complications when it comes to respecting the scheduling semantics
14367 specified in the real-time annex (Annex D).
14368
14369 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14370 scheduling policy states:
14371
14372 @quotation
14373 @emph{When the active priority of a ready task that is not running
14374 changes, or the setting of its base priority takes effect, the
14375 task is removed from the ready queue for its old active priority
14376 and is added at the tail of the ready queue for its new active
14377 priority, except in the case where the active priority is lowered
14378 due to the loss of inherited priority, in which case the task is
14379 added at the head of the ready queue for its new active priority.}
14380 @end quotation
14381
14382 @noindent
14383 While most kernels do put tasks at the end of the priority queue when
14384 a task changes its priority, (which respects the main
14385 FIFO_Within_Priorities requirement), almost none keep a thread at the
14386 beginning of its priority queue when its priority drops from the loss
14387 of inherited priority.
14388
14389 As a result most vendors have provided incomplete Annex D implementations.
14390
14391 The GNAT run-time, has a nice cooperative solution to this problem
14392 which ensures that accurate FIFO_Within_Priorities semantics are
14393 respected.
14394
14395 The principle is as follows.  When an Ada task T is about to start
14396 running, it checks whether some other Ada task R with the same
14397 priority as T has been suspended due to the loss of priority
14398 inheritance.  If this is the case, T yields and is placed at the end of
14399 its priority queue.  When R arrives at the front of the queue it
14400 executes.
14401
14402 Note that this simple scheme preserves the relative order of the tasks
14403 that were ready to execute in the priority queue where R has been
14404 placed at the end.
14405
14406 @node GNAT Implementation of Shared Passive Packages
14407 @section GNAT Implementation of Shared Passive Packages
14408 @cindex Shared passive packages
14409
14410 @noindent
14411 GNAT fully implements the pragma @code{Shared_Passive} for
14412 @cindex pragma @code{Shared_Passive}
14413 the purpose of designating shared passive packages.
14414 This allows the use of passive partitions in the
14415 context described in the Ada Reference Manual; i.e. for communication
14416 between separate partitions of a distributed application using the
14417 features in Annex E.
14418 @cindex Annex E
14419 @cindex Distribution Systems Annex
14420
14421 However, the implementation approach used by GNAT provides for more
14422 extensive usage as follows:
14423
14424 @table @emph
14425 @item Communication between separate programs
14426
14427 This allows separate programs to access the data in passive
14428 partitions, using protected objects for synchronization where
14429 needed. The only requirement is that the two programs have a
14430 common shared file system. It is even possible for programs
14431 running on different machines with different architectures
14432 (e.g. different endianness) to communicate via the data in
14433 a passive partition.
14434
14435 @item Persistence between program runs
14436
14437 The data in a passive package can persist from one run of a
14438 program to another, so that a later program sees the final
14439 values stored by a previous run of the same program.
14440
14441 @end table
14442
14443 @noindent
14444 The implementation approach used is to store the data in files. A
14445 separate stream file is created for each object in the package, and
14446 an access to an object causes the corresponding file to be read or
14447 written.
14448
14449 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14450 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14451 set to the directory to be used for these files.
14452 The files in this directory
14453 have names that correspond to their fully qualified names. For
14454 example, if we have the package
14455
14456 @smallexample @c ada
14457 package X is
14458   pragma Shared_Passive (X);
14459   Y : Integer;
14460   Z : Float;
14461 end X;
14462 @end smallexample
14463
14464 @noindent
14465 and the environment variable is set to @code{/stemp/}, then the files created
14466 will have the names:
14467
14468 @smallexample
14469 /stemp/x.y
14470 /stemp/x.z
14471 @end smallexample
14472
14473 @noindent
14474 These files are created when a value is initially written to the object, and
14475 the files are retained until manually deleted. This provides the persistence
14476 semantics. If no file exists, it means that no partition has assigned a value
14477 to the variable; in this case the initial value declared in the package
14478 will be used. This model ensures that there are no issues in synchronizing
14479 the elaboration process, since elaboration of passive packages elaborates the
14480 initial values, but does not create the files.
14481
14482 The files are written using normal @code{Stream_IO} access.
14483 If you want to be able
14484 to communicate between programs or partitions running on different
14485 architectures, then you should use the XDR versions of the stream attribute
14486 routines, since these are architecture independent.
14487
14488 If active synchronization is required for access to the variables in the
14489 shared passive package, then as described in the Ada Reference Manual, the
14490 package may contain protected objects used for this purpose. In this case
14491 a lock file (whose name is @file{___lock} (three underscores)
14492 is created in the shared memory directory.
14493 @cindex @file{___lock} file (for shared passive packages)
14494 This is used to provide the required locking
14495 semantics for proper protected object synchronization.
14496
14497 As of January 2003, GNAT supports shared passive packages on all platforms
14498 except for OpenVMS.
14499
14500 @node Code Generation for Array Aggregates
14501 @section Code Generation for Array Aggregates
14502
14503 @menu
14504 * Static constant aggregates with static bounds::
14505 * Constant aggregates with unconstrained nominal types::
14506 * Aggregates with static bounds::
14507 * Aggregates with non-static bounds::
14508 * Aggregates in assignment statements::
14509 @end menu
14510
14511 @noindent
14512 Aggregates have a rich syntax and allow the user to specify the values of
14513 complex data structures by means of a single construct.  As a result, the
14514 code generated for aggregates can be quite complex and involve loops, case
14515 statements and multiple assignments.  In the simplest cases, however, the
14516 compiler will recognize aggregates whose components and constraints are
14517 fully static, and in those cases the compiler will generate little or no
14518 executable code.  The following is an outline of the code that GNAT generates
14519 for various aggregate constructs.  For further details, you will find it
14520 useful to examine the output produced by the -gnatG flag to see the expanded
14521 source that is input to the code generator.  You may also want to examine
14522 the assembly code generated at various levels of optimization.
14523
14524 The code generated for aggregates depends on the context, the component values,
14525 and the type.  In the context of an object declaration the code generated is
14526 generally simpler than in the case of an assignment.  As a general rule, static
14527 component values and static subtypes also lead to simpler code.
14528
14529 @node Static constant aggregates with static bounds
14530 @subsection Static constant aggregates with static bounds
14531
14532 @noindent
14533 For the declarations:
14534 @smallexample @c ada
14535     type One_Dim is array (1..10) of integer;
14536     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14537 @end smallexample
14538
14539 @noindent
14540 GNAT generates no executable code: the constant ar0 is placed in static memory.
14541 The same is true for constant aggregates with named associations:
14542
14543 @smallexample @c ada
14544     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14545     Cr3 : constant One_Dim := (others => 7777);
14546 @end smallexample
14547
14548 @noindent
14549 The same is true for multidimensional constant arrays such as:
14550
14551 @smallexample @c ada
14552     type two_dim is array (1..3, 1..3) of integer;
14553     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14554 @end smallexample
14555
14556 @noindent
14557 The same is true for arrays of one-dimensional arrays: the following are
14558 static:
14559
14560 @smallexample @c ada
14561 type ar1b  is array (1..3) of boolean;
14562 type ar_ar is array (1..3) of ar1b;
14563 None  : constant ar1b := (others => false);     --  fully static
14564 None2 : constant ar_ar := (1..3 => None);       --  fully static
14565 @end smallexample
14566
14567 @noindent
14568 However, for multidimensional aggregates with named associations, GNAT will
14569 generate assignments and loops, even if all associations are static.  The
14570 following two declarations generate a loop for the first dimension, and
14571 individual component assignments for the second dimension:
14572
14573 @smallexample @c ada
14574 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14575 Zero2: constant two_dim := (others => (others => 0));
14576 @end smallexample
14577
14578 @node Constant aggregates with unconstrained nominal types
14579 @subsection Constant aggregates with unconstrained nominal types
14580
14581 @noindent
14582 In such cases the aggregate itself establishes the subtype, so that
14583 associations with @code{others} cannot be used.  GNAT determines the
14584 bounds for the actual subtype of the aggregate, and allocates the
14585 aggregate statically as well.  No code is generated for the following:
14586
14587 @smallexample @c ada
14588     type One_Unc is array (natural range <>) of integer;
14589     Cr_Unc : constant One_Unc := (12,24,36);
14590 @end smallexample
14591
14592 @node Aggregates with static bounds
14593 @subsection Aggregates with static bounds
14594
14595 @noindent
14596 In all previous examples the aggregate was the initial (and immutable) value
14597 of a constant.  If the aggregate initializes a variable, then code is generated
14598 for it as a combination of individual assignments and loops over the target
14599 object.  The declarations
14600
14601 @smallexample @c ada
14602        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14603        Cr_Var2 : One_Dim := (others > -1);
14604 @end smallexample
14605
14606 @noindent
14607 generate the equivalent of
14608
14609 @smallexample @c ada
14610        Cr_Var1 (1) := 2;
14611        Cr_Var1 (2) := 3;
14612        Cr_Var1 (3) := 5;
14613        Cr_Var1 (4) := 11;
14614
14615        for I in Cr_Var2'range loop
14616           Cr_Var2 (I) := =-1;
14617        end loop;
14618 @end smallexample
14619
14620 @node Aggregates with non-static bounds
14621 @subsection Aggregates with non-static bounds
14622
14623 @noindent
14624 If the bounds of the aggregate are not statically compatible with the bounds
14625 of the nominal subtype  of the target, then constraint checks have to be
14626 generated on the bounds.  For a multidimensional array, constraint checks may
14627 have to be applied to sub-arrays individually, if they do not have statically
14628 compatible subtypes.
14629
14630 @node Aggregates in assignment statements
14631 @subsection Aggregates in assignment statements
14632
14633 @noindent
14634 In general, aggregate assignment requires the construction of a temporary,
14635 and a copy from the temporary to the target of the assignment.  This is because
14636 it is not always possible to convert the assignment into a series of individual
14637 component assignments.  For example, consider the simple case:
14638
14639 @smallexample @c ada
14640         A := (A(2), A(1));
14641 @end smallexample
14642
14643 @noindent
14644 This cannot be converted into:
14645
14646 @smallexample @c ada
14647         A(1) := A(2);
14648         A(2) := A(1);
14649 @end smallexample
14650
14651 @noindent
14652 So the aggregate has to be built first in a separate location, and then
14653 copied into the target.  GNAT recognizes simple cases where this intermediate
14654 step is not required, and the assignments can be performed in place, directly
14655 into the target.  The following sufficient criteria are applied:
14656
14657 @itemize @bullet
14658 @item
14659 The bounds of the aggregate are static, and the associations are static.
14660 @item
14661 The components of the aggregate are static constants, names of
14662 simple variables that are not renamings, or expressions not involving
14663 indexed components whose operands obey these rules.
14664 @end itemize
14665
14666 @noindent
14667 If any of these conditions are violated, the aggregate will be built in
14668 a temporary (created either by the front-end or the code generator) and then
14669 that temporary will be copied onto the target.
14670
14671
14672 @node The Size of Discriminated Records with Default Discriminants
14673 @section The Size of Discriminated Records with Default Discriminants
14674
14675 @noindent
14676 If a discriminated type @code{T} has discriminants with default values, it is
14677 possible to declare an object of this type without providing an explicit
14678 constraint:
14679
14680 @smallexample @c ada
14681 @group
14682 type Size is range 1..100;
14683
14684 type Rec (D : Size := 15) is record
14685    Name : String (1..D);
14686 end T;
14687
14688 Word : Rec;
14689 @end group
14690 @end smallexample
14691
14692 @noindent
14693 Such an object is said to be @emph{unconstrained}.
14694 The discriminant of the object
14695 can be modified by a full assignment to the object, as long as it preserves the
14696 relation between the value of the discriminant, and the value of the components
14697 that depend on it:
14698
14699 @smallexample @c ada
14700 @group
14701 Word := (3, "yes");
14702
14703 Word := (5, "maybe");
14704
14705 Word := (5, "no"); -- raises Constraint_Error
14706 @end group
14707 @end smallexample
14708
14709 @noindent
14710 In order to support this behavior efficiently, an unconstrained object is
14711 given the maximum size that any value of the type requires. In the case
14712 above, @code{Word} has storage for the discriminant and for
14713 a @code{String} of length 100.
14714 It is important to note that unconstrained objects do not require dynamic
14715 allocation. It would be an improper implementation to place on the heap those
14716 components whose size depends on discriminants. (This improper implementation
14717 was used by some Ada83 compilers, where the @code{Name} component above
14718 would have
14719 been stored as a pointer to a dynamic string). Following the principle that
14720 dynamic storage management should never be introduced implicitly,
14721 an Ada compiler should reserve the full size for an unconstrained declared
14722 object, and place it on the stack.
14723
14724 This maximum size approach
14725 has been a source of surprise to some users, who expect the default
14726 values of the discriminants to determine the size reserved for an
14727 unconstrained object: ``If the default is 15, why should the object occupy
14728 a larger size?''
14729 The answer, of course, is that the discriminant may be later modified,
14730 and its full range of values must be taken into account. This is why the
14731 declaration:
14732
14733 @smallexample
14734 @group
14735 type Rec (D : Positive := 15) is record
14736    Name : String (1..D);
14737 end record;
14738
14739 Too_Large : Rec;
14740 @end group
14741 @end smallexample
14742
14743 @noindent
14744 is flagged by the compiler with a warning:
14745 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14746 because the required size includes @code{Positive'Last}
14747 bytes. As the first example indicates, the proper approach is to declare an
14748 index type of ``reasonable'' range so that unconstrained objects are not too
14749 large.
14750
14751 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14752 created in the heap by means of an allocator, then it is @emph{not}
14753 unconstrained:
14754 it is constrained by the default values of the discriminants, and those values
14755 cannot be modified by full assignment. This is because in the presence of
14756 aliasing all views of the object (which may be manipulated by different tasks,
14757 say) must be consistent, so it is imperative that the object, once created,
14758 remain invariant.
14759
14760 @node Strict Conformance to the Ada Reference Manual
14761 @section Strict Conformance to the Ada Reference Manual
14762
14763 @noindent
14764 The dynamic semantics defined by the Ada Reference Manual impose a set of
14765 run-time checks to be generated. By default, the GNAT compiler will insert many
14766 run-time checks into the compiled code, including most of those required by the
14767 Ada Reference Manual. However, there are three checks that are not enabled
14768 in the default mode for efficiency reasons: arithmetic overflow checking for
14769 integer operations (including division by zero), checks for access before
14770 elaboration on subprogram calls, and stack overflow checking (most operating
14771 systems do not perform this check by default).
14772
14773 Strict conformance to the Ada Reference Manual can be achieved by adding
14774 three compiler options for overflow checking for integer operations
14775 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14776 calls and generic instantiations (@option{-gnatE}), and stack overflow
14777 checking (@option{-fstack-check}).
14778
14779 Note that the result of a floating point arithmetic operation in overflow and
14780 invalid situations, when the @code{Machine_Overflows} attribute of the result
14781 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14782 case for machines compliant with the IEEE floating-point standard, but on
14783 machines that are not fully compliant with this standard, such as Alpha, the
14784 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14785 behavior (although at the cost of a significant performance penalty), so
14786 infinite and and NaN values are properly generated.
14787
14788
14789 @node Project File Reference
14790 @chapter Project File Reference
14791
14792 @noindent
14793 This chapter describes the syntax and semantics of project files.
14794 Project files specify the options to be used when building a system.
14795 Project files can specify global settings for all tools,
14796 as well as tool-specific settings.
14797 See the chapter on project files in the GNAT Users guide for examples of use.
14798
14799 @menu
14800 * Reserved Words::
14801 * Lexical Elements::
14802 * Declarations::
14803 * Empty declarations::
14804 * Typed string declarations::
14805 * Variables::
14806 * Expressions::
14807 * Attributes::
14808 * Project Attributes::
14809 * Attribute References::
14810 * External Values::
14811 * Case Construction::
14812 * Packages::
14813 * Package Renamings::
14814 * Projects::
14815 * Project Extensions::
14816 * Project File Elaboration::
14817 @end menu
14818
14819 @node Reserved Words
14820 @section Reserved Words
14821
14822 @noindent
14823 All Ada reserved words are reserved in project files, and cannot be used
14824 as variable names or project names. In addition, the following are
14825 also reserved in project files:
14826
14827 @itemize
14828 @item @code{extends}
14829
14830 @item @code{external}
14831
14832 @item @code{project}
14833
14834 @end itemize
14835
14836 @node Lexical Elements
14837 @section Lexical Elements
14838
14839 @noindent
14840 Rules for identifiers are the same as in Ada. Identifiers
14841 are case-insensitive.  Strings are case sensitive, except where noted.
14842 Comments have the same form as in Ada.
14843
14844 @noindent
14845 Syntax:
14846
14847 @smallexample
14848 simple_name ::=
14849   identifier
14850
14851 name ::=
14852   simple_name @{. simple_name@}
14853 @end smallexample
14854
14855 @node Declarations
14856 @section Declarations
14857
14858 @noindent
14859 Declarations introduce new entities that denote types, variables, attributes,
14860 and packages. Some declarations can only appear immediately within a project
14861 declaration. Others can appear within a project or within a package.
14862
14863 Syntax:
14864 @smallexample
14865 declarative_item ::=
14866   simple_declarative_item |
14867   typed_string_declaration |
14868   package_declaration
14869
14870 simple_declarative_item ::=
14871   variable_declaration |
14872   typed_variable_declaration |
14873   attribute_declaration |
14874   case_construction |
14875   empty_declaration
14876 @end smallexample
14877
14878 @node Empty declarations
14879 @section Empty declarations
14880
14881 @smallexample
14882 empty_declaration ::=
14883   @b{null} ;
14884 @end smallexample
14885
14886 An empty declaration is allowed anywhere a declaration is allowed.
14887 It has no effect.
14888
14889 @node Typed string declarations
14890 @section Typed string declarations
14891
14892 @noindent
14893 Typed strings are sequences of string literals. Typed strings are the only
14894 named types in project files. They are used in case constructions, where they
14895 provide support for conditional attribute definitions.
14896
14897 Syntax:
14898 @smallexample
14899 typed_string_declaration ::=
14900   @b{type} <typed_string_>_simple_name @b{is}
14901    ( string_literal @{, string_literal@} );
14902 @end smallexample
14903
14904 @noindent
14905 A typed string declaration can only appear immediately within a project
14906 declaration.
14907
14908 All the string literals in a typed string declaration must be distinct.
14909
14910 @node Variables
14911 @section Variables
14912
14913 @noindent
14914 Variables denote values, and appear as constituents of expressions.
14915
14916 @smallexample
14917 typed_variable_declaration ::=
14918   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14919
14920 variable_declaration ::=
14921   <variable_>simple_name := expression;
14922 @end smallexample
14923
14924 @noindent
14925 The elaboration of a variable declaration introduces the variable and
14926 assigns to it the value of the expression. The name of the variable is
14927 available after the assignment symbol.
14928
14929 @noindent
14930 A typed_variable can only be declare once.
14931
14932 @noindent
14933 a non typed variable can be declared multiple times.
14934
14935 @noindent
14936 Before the completion of its first declaration, the value of variable
14937 is the null string.
14938
14939 @node Expressions
14940 @section Expressions
14941
14942 @noindent
14943 An expression is a formula that defines a computation or retrieval of a value.
14944 In a project file the value of an expression is either a string or a list
14945 of strings. A string value in an expression is either a literal, the current
14946 value of a variable, an external value, an attribute reference, or a
14947 concatenation operation.
14948
14949 Syntax:
14950
14951 @smallexample
14952 expression ::=
14953   term @{& term@}
14954
14955 term ::=
14956   string_literal |
14957   string_list |
14958   <variable_>name |
14959   external_value |
14960   attribute_reference
14961
14962 string_literal ::=
14963   (same as Ada)
14964
14965 string_list ::=
14966   ( <string_>expression @{ , <string_>expression @} )
14967 @end smallexample
14968
14969 @subsection Concatenation
14970 @noindent
14971 The following concatenation functions are defined:
14972
14973 @smallexample @c ada
14974   function "&" (X : String;      Y : String)      return String;
14975   function "&" (X : String_List; Y : String)      return String_List;
14976   function "&" (X : String_List; Y : String_List) return String_List;
14977 @end smallexample
14978
14979 @node Attributes
14980 @section Attributes
14981
14982 @noindent
14983 An attribute declaration defines a property of a project or package. This
14984 property can later be queried by means of an attribute reference.
14985 Attribute values are strings or string lists.
14986
14987 Some attributes are associative arrays. These attributes are mappings whose
14988 domain is a set of strings. These attributes are declared one association
14989 at a time, by specifying a point in the domain and the corresponding image
14990 of the attribute. They may also be declared as a full associative array,
14991 getting the same associations as the corresponding attribute in an imported
14992 or extended project.
14993
14994 Attributes that are not associative arrays are called simple attributes.
14995
14996 Syntax:
14997 @smallexample
14998 attribute_declaration ::=
14999   full_associative_array_declaration |
15000   @b{for} attribute_designator @b{use} expression ;
15001
15002 full_associative_array_declaration ::=
15003   @b{for} <associative_array_attribute_>simple_name @b{use}
15004   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15005
15006 attribute_designator ::=
15007   <simple_attribute_>simple_name |
15008   <associative_array_attribute_>simple_name ( string_literal )
15009 @end smallexample
15010
15011 @noindent
15012 Some attributes are project-specific, and can only appear immediately within
15013 a project declaration. Others are package-specific, and can only appear within
15014 the proper package.
15015
15016 The expression in an attribute definition must be a string or a string_list.
15017 The string literal appearing in the attribute_designator of an associative
15018 array attribute is case-insensitive.
15019
15020 @node Project Attributes
15021 @section Project Attributes
15022
15023 @noindent
15024 The following attributes apply to a project. All of them are simple
15025 attributes.
15026
15027 @table @code
15028 @item   Object_Dir
15029 Expression must be a path name. The attribute defines the
15030 directory in which the object files created by the build are to be placed. If
15031 not specified, object files are placed in the project directory.
15032
15033 @item   Exec_Dir
15034 Expression must be a path name. The attribute defines the
15035 directory in which the executables created by the build are to be placed.
15036 If not specified, executables are placed in the object directory.
15037
15038 @item  Source_Dirs
15039 Expression must be a list of path names. The attribute
15040 defines the directories in which the source files for the project are to be
15041 found. If not specified, source files are found in the project directory.
15042
15043 @item  Source_Files
15044 Expression must be a list of file names. The attribute
15045 defines the individual files, in the project directory, which are to be used
15046 as sources for the project. File names are path_names that contain no directory
15047 information. If the project has no sources the attribute must be declared
15048 explicitly with an empty list.
15049
15050 @item  Source_List_File
15051 Expression must a single path name. The attribute
15052 defines a text file that contains a list of source file names to be used
15053 as sources for the project
15054
15055 @item  Library_Dir
15056 Expression must be a path name. The attribute defines the
15057 directory in which a  library is to be built.  The directory must exist, must
15058 be distinct from the project's object directory, and must be writable.
15059
15060 @item  Library_Name
15061 Expression must be a string that is a legal file name,
15062 without extension. The attribute defines a string that is used to generate
15063 the name of the library to be built by the project.
15064
15065 @item  Library_Kind
15066 Argument must be a string value that must be one of the
15067 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15068 string is case-insensitive. If this attribute is not specified, the library is
15069 a static library. Otherwise, the library may be dynamic or relocatable. This
15070 distinction is operating-system dependent.
15071
15072 @item  Library_Version
15073 Expression must be a string value whose interpretation
15074 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15075 libraries as the internal name of the library (the @code{"soname"}). If the
15076 library file name (built from the @code{Library_Name}) is different from the
15077 @code{Library_Version}, then the library file will be a symbolic link to the
15078 actual file whose name will be @code{Library_Version}.
15079
15080 @item Library_Interface
15081 Expression must be a string list. Each element of the string list
15082 must designate a unit of the project.
15083 If this attribute is present in a Library Project File, then the project
15084 file is a Stand-alone Library_Project_File.
15085
15086 @item Library_Auto_Init
15087 Expression must be a single string "true" or "false", case-insensitive.
15088 If this attribute is present in a Stand-alone Library Project File,
15089 it indicates if initialization is automatic when the dynamic library
15090 is loaded.
15091
15092 @item Library_Options
15093 Expression must be a string list. Indicates additional switches that
15094 are to be used when building a shared library.
15095
15096 @item Library_GCC
15097 Expression must be a single string. Designates an alternative to "gcc"
15098 for building shared libraries.
15099
15100 @item  Library_Src_Dir
15101 Expression must be a path name. The attribute defines the
15102 directory in which the sources of the interfaces of a Stand-alone Library will
15103 be copied.  The directory must exist, must be distinct from the project's
15104 object directory and source directories of all projects in the project tree,
15105 and must be writable.
15106
15107 @item  Library_Src_Dir
15108 Expression must be a path name. The attribute defines the
15109 directory in which the ALI files of a Library will
15110 be copied.  The directory must exist, must be distinct from the project's
15111 object directory and source directories of all projects in the project tree,
15112 and must be writable.
15113
15114 @item  Library_Symbol_File
15115 Expression must be a single string. Its value is the single file name of a
15116 symbol file to be created when building a stand-alone library when the
15117 symbol policy is either "compliant", "controlled" or "restricted",
15118 on platforms that support symbol control, such as VMS. When symbol policy
15119 is "direct", then a file with this name must exist in the object directory.
15120
15121 @item   Library_Reference_Symbol_File
15122 Expression must be a single string. Its value is the path name of a
15123 reference symbol file that is read when the symbol policy is either
15124 "compliant" or "controlled", on platforms that support symbol control,
15125 such as VMS, when building a stand-alone library. The path may be an absolute
15126 path or a path relative to the project directory.
15127
15128 @item  Library_Symbol_Policy
15129 Expression must be a single string. Its case-insensitive value can only be
15130 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15131
15132 This attribute is not taken into account on all platforms. It controls the
15133 policy for exported symbols and, on some platforms (like VMS) that have the
15134 notions of major and minor IDs built in the library files, it controls
15135 the setting of these IDs.
15136
15137 "autonomous" or "default": exported symbols are not controlled.
15138
15139 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15140 it is equivalent to policy "autonomous". If there are exported symbols in
15141 the reference symbol file that are not in the object files of the interfaces,
15142 the major ID of the library is increased. If there are symbols in the
15143 object files of the interfaces that are not in the reference symbol file,
15144 these symbols are put at the end of the list in the newly created symbol file
15145 and the minor ID is increased.
15146
15147 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15148 The library will fail to build if the exported symbols in the object files of
15149 the interfaces do not match exactly the symbol in the symbol file.
15150
15151 "restricted": The attribute Library_Symbol_File must be defined. The library
15152 will fail to build if there are symbols in the symbol file that are not in
15153 the exported symbols of the object files of the interfaces. Additional symbols
15154 in the object files are not added to the symbol file.
15155
15156 "direct": The attribute Library_Symbol_File must be defined and must designate
15157 an existing file in the object directory. This symbol file is passed directly
15158 to the underlying linker without any symbol processing.
15159
15160 @item  Main
15161 Expression must be a list of strings that are legal file names.
15162 These file names designate existing compilation units in the source directory
15163 that are legal main subprograms.
15164
15165 When a project file is elaborated, as part of the execution of a gnatmake
15166 command, one or several executables are built and placed in the Exec_Dir.
15167 If the gnatmake command does not include explicit file names, the executables
15168 that are built correspond to the files specified by this attribute.
15169
15170 @item  Externally_Built
15171 Expression must be a single string. Its value must be either "true" of "false",
15172 case-insensitive. The default is "false". When the value of this attribute is
15173 "true", no attempt is made to compile the sources or to build the library,
15174 when the project is a library project.
15175
15176 @item Main_Language
15177 This is a simple attribute. Its value is a string that specifies the
15178 language of the main program.
15179
15180 @item  Languages
15181 Expression must be a string list. Each string designates
15182 a programming language that is known to GNAT. The strings are case-insensitive.
15183
15184 @item  Locally_Removed_Files
15185 This attribute is legal only in a project file that extends another.
15186 Expression must be a list of strings that are legal file names.
15187 Each file name must designate a source that would normally be inherited
15188 by the current project file. It cannot designate an immediate source that is
15189 not inherited. Each of the source files in the list are not considered to
15190 be sources of the project file: they are not inherited.
15191 @end table
15192
15193 @node Attribute References
15194 @section Attribute References
15195
15196 @noindent
15197 Attribute references are used to retrieve the value of previously defined
15198 attribute for a package or project.
15199 Syntax:
15200 @smallexample
15201 attribute_reference ::=
15202   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15203
15204 attribute_prefix ::=
15205   @b{project} |
15206   <project_simple_name | package_identifier |
15207   <project_>simple_name . package_identifier
15208 @end smallexample
15209
15210 @noindent
15211 If an attribute has not been specified for a given package or project, its
15212 value is the null string or the empty list.
15213
15214 @node External Values
15215 @section External Values
15216
15217 @noindent
15218 An external value is an expression whose value is obtained from the command
15219 that invoked the processing of the current project file (typically a
15220 gnatmake command).
15221
15222 Syntax:
15223 @smallexample
15224 external_value ::=
15225   @b{external} ( string_literal [, string_literal] )
15226 @end smallexample
15227
15228 @noindent
15229 The first string_literal is the string to be used on the command line or
15230 in the environment to specify the external value. The second string_literal,
15231 if present, is the default to use if there is no specification for this
15232 external value either on the command line or in the environment.
15233
15234 @node Case Construction
15235 @section Case Construction
15236
15237 @noindent
15238 A case construction supports attribute and variable declarations that depend
15239 on the value of a previously declared variable.
15240
15241 Syntax:
15242 @smallexample
15243 case_construction ::=
15244   @b{case} <typed_variable_>name @b{is}
15245     @{case_item@}
15246   @b{end case} ;
15247
15248 case_item ::=
15249   @b{when} discrete_choice_list =>
15250     @{case_construction |
15251       attribute_declaration |
15252       variable_declaration |
15253       empty_declaration@}
15254
15255 discrete_choice_list ::=
15256   string_literal @{| string_literal@} |
15257     @b{others}
15258 @end smallexample
15259
15260 @noindent
15261 Inside a case construction, variable declarations must be for variables that
15262 have already been declared before the case construction.
15263
15264 All choices in a choice list must be distinct. The choice lists of two
15265 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15266 alternatives do not need to include all values of the type. An @code{others}
15267 choice must appear last in the list of alternatives.
15268
15269 @node Packages
15270 @section Packages
15271
15272 @noindent
15273 A package provides a grouping of variable declarations and attribute
15274 declarations to be used when invoking various GNAT tools. The name of
15275 the package indicates the tool(s) to which it applies.
15276 Syntax:
15277
15278 @smallexample
15279 package_declaration ::=
15280   package_specification | package_renaming
15281
15282 package_specification ::=
15283   @b{package} package_identifier @b{is}
15284     @{simple_declarative_item@}
15285   @b{end} package_identifier ;
15286
15287 package_identifier ::=
15288   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15289   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15290   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15291 @end smallexample
15292
15293 @subsection Package Naming
15294
15295 @noindent
15296 The attributes of a @code{Naming} package specifies the naming conventions
15297 that apply to the source files in a project. When invoking other GNAT tools,
15298 they will use the sources in the source directories that satisfy these
15299 naming conventions.
15300
15301 The following attributes apply to a @code{Naming} package:
15302
15303 @table @code
15304 @item Casing
15305 This is a simple attribute whose value is a string. Legal values of this
15306 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15307 These strings are themselves case insensitive.
15308
15309 @noindent
15310 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15311
15312 @item Dot_Replacement
15313 This is a simple attribute whose string value satisfies the following
15314 requirements:
15315
15316 @itemize @bullet
15317 @item It must not be empty
15318 @item It cannot start or end with an alphanumeric character
15319 @item It cannot be a single underscore
15320 @item It cannot start with an underscore followed by an alphanumeric
15321 @item It cannot contain a dot @code{'.'} if longer than one character
15322 @end itemize
15323
15324 @noindent
15325 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15326
15327 @item Spec_Suffix
15328 This is an associative array attribute, defined on language names,
15329 whose image is a string that must satisfy the following
15330 conditions:
15331
15332 @itemize @bullet
15333 @item It must not be empty
15334 @item It cannot start with an alphanumeric character
15335 @item It cannot start with an underscore followed by an alphanumeric character
15336 @end itemize
15337
15338 @noindent
15339 For Ada, the attribute denotes the suffix used in file names that contain
15340 library unit declarations, that is to say units that are package and
15341 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15342 specified, then the default is @code{".ads"}.
15343
15344 For C and C++, the attribute denotes the suffix used in file names that
15345 contain prototypes.
15346
15347 @item Body_Suffix
15348 This is an associative array attribute defined on language names,
15349 whose image is a string that must satisfy the following
15350 conditions:
15351
15352 @itemize @bullet
15353 @item It must not be empty
15354 @item It cannot start with an alphanumeric character
15355 @item It cannot start with an underscore followed by an alphanumeric character
15356 @item It cannot be a suffix of @code{Spec_Suffix}
15357 @end itemize
15358
15359 @noindent
15360 For Ada, the attribute denotes the suffix used in file names that contain
15361 library bodies, that is to say units that are package and subprogram bodies.
15362 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15363 @code{".adb"}.
15364
15365 For C and C++, the attribute denotes the suffix used in file names that contain
15366 source code.
15367
15368 @item Separate_Suffix
15369 This is a simple attribute whose value satisfies the same conditions as
15370 @code{Body_Suffix}.
15371
15372 This attribute is specific to Ada. It denotes the suffix used in file names
15373 that contain separate bodies. If it is not specified, then it defaults to same
15374 value as @code{Body_Suffix ("Ada")}.
15375
15376 @item Spec
15377 This is an associative array attribute, specific to Ada, defined over
15378 compilation unit names. The image is a string that is the name of the file
15379 that contains that library unit. The file name is case sensitive if the
15380 conventions of the host operating system require it.
15381
15382 @item Body
15383 This is an associative array attribute, specific to Ada, defined over
15384 compilation unit names. The image is a string that is the name of the file
15385 that contains the library unit body for the named unit. The file name is case
15386 sensitive if the conventions of the host operating system require it.
15387
15388 @item Specification_Exceptions
15389 This is an associative array attribute defined on language names,
15390 whose value is a list of strings.
15391
15392 This attribute is not significant for Ada.
15393
15394 For C and C++, each string in the list denotes the name of a file that
15395 contains prototypes, but whose suffix is not necessarily the
15396 @code{Spec_Suffix} for the language.
15397
15398 @item Implementation_Exceptions
15399 This is an associative array attribute defined on language names,
15400 whose value is a list of strings.
15401
15402 This attribute is not significant for Ada.
15403
15404 For C and C++, each string in the list denotes the name of a file that
15405 contains source code, but whose suffix is not necessarily the
15406 @code{Body_Suffix} for the language.
15407 @end table
15408
15409 The following attributes of package @code{Naming} are obsolescent. They are
15410 kept as synonyms of other attributes for compatibility with previous versions
15411 of the Project Manager.
15412
15413 @table @code
15414 @item Specification_Suffix
15415 This is a synonym of @code{Spec_Suffix}.
15416
15417 @item Implementation_Suffix
15418 This is a synonym of @code{Body_Suffix}.
15419
15420 @item Specification
15421 This is a synonym of @code{Spec}.
15422
15423 @item Implementation
15424 This is a synonym of @code{Body}.
15425 @end table
15426
15427 @subsection package Compiler
15428
15429 @noindent
15430 The attributes of the @code{Compiler} package specify the compilation options
15431 to be used by the underlying compiler.
15432
15433 @table @code
15434 @item  Default_Switches
15435 This is an associative array attribute. Its
15436 domain is a set of language names. Its range is a string list that
15437 specifies the compilation options to be used when compiling a component
15438 written in that language, for which no file-specific switches have been
15439 specified.
15440
15441 @item  Switches
15442 This is an associative array attribute. Its domain is
15443 a set of file names. Its range is a string list that specifies the
15444 compilation options to be used when compiling the named file. If a file
15445 is not specified in the Switches attribute, it is compiled with the
15446 options specified by Default_Switches of its language, if defined.
15447
15448 @item  Local_Configuration_Pragmas.
15449 This is a simple attribute, whose
15450 value is a path name that designates a file containing configuration pragmas
15451 to be used for all invocations of the compiler for immediate sources of the
15452 project.
15453 @end table
15454
15455 @subsection package Builder
15456
15457 @noindent
15458 The attributes of package @code{Builder} specify the compilation, binding, and
15459 linking options to be used when building an executable for a project. The
15460 following attributes apply to package @code{Builder}:
15461
15462 @table @code
15463 @item Default_Switches
15464 This is an associative array attribute. Its
15465 domain is a set of language names. Its range is a string list that
15466 specifies options to be used when building a main
15467 written in that language, for which no file-specific switches have been
15468 specified.
15469
15470 @item Switches
15471 This is an associative array attribute. Its domain is
15472 a set of file names. Its range is a string list that specifies
15473 options to be used when building the named main file. If a main file
15474 is not specified in the Switches attribute, it is built with the
15475 options specified by Default_Switches of its language, if defined.
15476
15477 @item Global_Configuration_Pragmas
15478 This is a simple attribute, whose
15479 value is a path name that designates a file that contains configuration pragmas
15480 to be used in every build of an executable. If both local and global
15481 configuration pragmas are specified, a compilation makes use of both sets.
15482
15483
15484 @item Executable
15485 This is an associative array attribute. Its domain is
15486 a set of main source file names. Its range is a simple string that specifies
15487 the executable file name to be used when linking the specified main source.
15488 If a main source is not specified in the Executable attribute, the executable
15489 file name is deducted from the main source file name.
15490 This attribute has no effect if its value is the empty string.
15491
15492 @item Executable_Suffix
15493 This is a simple attribute whose value is the suffix to be added to
15494 the executables that don't have an attribute Executable specified.
15495 @end table
15496
15497 @subsection package Gnatls
15498
15499 @noindent
15500 The attributes of package @code{Gnatls} specify the tool options to be used
15501 when invoking the library browser @command{gnatls}.
15502 The following attributes apply to package @code{Gnatls}:
15503
15504 @table @code
15505 @item Switches
15506 This is a single attribute with a string list value. Each non empty string
15507 in the list is an option when invoking @code{gnatls}.
15508 @end table
15509
15510 @subsection package Binder
15511
15512 @noindent
15513 The attributes of package @code{Binder} specify the options to be used
15514 when invoking the binder in the construction of an executable.
15515 The following attributes apply to package @code{Binder}:
15516
15517 @table @code
15518 @item     Default_Switches
15519 This is an associative array attribute. Its
15520 domain is a set of language names. Its range is a string list that
15521 specifies options to be used when binding a main
15522 written in that language, for which no file-specific switches have been
15523 specified.
15524
15525 @item Switches
15526 This is an associative array attribute. Its domain is
15527 a set of file names. Its range is a string list that specifies
15528 options to be used when binding the named main file. If a main file
15529 is not specified in the Switches attribute, it is bound with the
15530 options specified by Default_Switches of its language, if defined.
15531 @end table
15532
15533 @subsection package Linker
15534
15535 @noindent
15536 The attributes of package @code{Linker} specify the options to be used when
15537 invoking the linker in the construction of an executable.
15538 The following attributes apply to package @code{Linker}:
15539
15540 @table @code
15541 @item     Default_Switches
15542 This is an associative array attribute. Its
15543 domain is a set of language names. Its range is a string list that
15544 specifies options to be used when linking a main
15545 written in that language, for which no file-specific switches have been
15546 specified.
15547
15548 @item Switches
15549 This is an associative array attribute. Its domain is
15550 a set of file names. Its range is a string list that specifies
15551 options to be used when linking the named main file. If a main file
15552 is not specified in the Switches attribute, it is linked with the
15553 options specified by Default_Switches of its language, if defined.
15554
15555 @item  Linker_Options
15556 This is a string list attribute. Its value specifies additional options that
15557 be given to the linker when linking an executable. This attribute is not
15558 used in the main project, only in projects imported directly or indirectly.
15559
15560 @end table
15561
15562 @subsection package Cross_Reference
15563
15564 @noindent
15565 The attributes of package @code{Cross_Reference} specify the tool options
15566 to be used
15567 when invoking the library tool @command{gnatxref}.
15568 The following attributes apply to package @code{Cross_Reference}:
15569
15570 @table @code
15571 @item     Default_Switches
15572 This is an associative array attribute. Its
15573 domain is a set of language names. Its range is a string list that
15574 specifies options to be used when calling @command{gnatxref} on a source
15575 written in that language, for which no file-specific switches have been
15576 specified.
15577
15578 @item Switches
15579 This is an associative array attribute. Its domain is
15580 a set of file names. Its range is a string list that specifies
15581 options to be used when calling @command{gnatxref} on the named main source.
15582 If a source is not specified in the Switches attribute, @command{gnatxref} will
15583 be called with the options specified by Default_Switches of its language,
15584 if defined.
15585 @end table
15586
15587 @subsection package   Finder
15588
15589 @noindent
15590 The attributes of package @code{Finder} specify the tool options to be used
15591 when invoking the search tool @command{gnatfind}.
15592 The following attributes apply to package @code{Finder}:
15593
15594 @table @code
15595 @item     Default_Switches
15596 This is an associative array attribute. Its
15597 domain is a set of language names. Its range is a string list that
15598 specifies options to be used when calling @command{gnatfind} on a source
15599 written in that language, for which no file-specific switches have been
15600 specified.
15601
15602 @item Switches
15603 This is an associative array attribute. Its domain is
15604 a set of file names. Its range is a string list that specifies
15605 options to be used when calling @command{gnatfind} on the named main source.
15606 If a source is not specified in the Switches attribute, @command{gnatfind} will
15607 be called with the options specified by Default_Switches of its language,
15608 if defined.
15609 @end table
15610
15611 @subsection package Pretty_Printer
15612
15613 @noindent
15614 The attributes of package @code{Pretty_Printer}
15615 specify the tool options to be used
15616 when invoking the formatting tool @command{gnatpp}.
15617 The following attributes apply to package @code{Pretty_Printer}:
15618
15619 @table @code
15620 @item     Default_switches
15621 This is an associative array attribute. Its
15622 domain is a set of language names. Its range is a string list that
15623 specifies options to be used when calling @command{gnatpp} on a source
15624 written in that language, for which no file-specific switches have been
15625 specified.
15626
15627 @item Switches
15628 This is an associative array attribute. Its domain is
15629 a set of file names. Its range is a string list that specifies
15630 options to be used when calling @command{gnatpp} on the named main source.
15631 If a source is not specified in the Switches attribute, @command{gnatpp} will
15632 be called with the options specified by Default_Switches of its language,
15633 if defined.
15634 @end table
15635
15636 @subsection package gnatstub
15637
15638 @noindent
15639 The attributes of package @code{gnatstub}
15640 specify the tool options to be used
15641 when invoking the tool @command{gnatstub}.
15642 The following attributes apply to package @code{gnatstub}:
15643
15644 @table @code
15645 @item     Default_switches
15646 This is an associative array attribute. Its
15647 domain is a set of language names. Its range is a string list that
15648 specifies options to be used when calling @command{gnatstub} on a source
15649 written in that language, for which no file-specific switches have been
15650 specified.
15651
15652 @item Switches
15653 This is an associative array attribute. Its domain is
15654 a set of file names. Its range is a string list that specifies
15655 options to be used when calling @command{gnatstub} on the named main source.
15656 If a source is not specified in the Switches attribute, @command{gnatpp} will
15657 be called with the options specified by Default_Switches of its language,
15658 if defined.
15659 @end table
15660
15661 @subsection package Eliminate
15662
15663 @noindent
15664 The attributes of package @code{Eliminate}
15665 specify the tool options to be used
15666 when invoking the tool @command{gnatelim}.
15667 The following attributes apply to package @code{Eliminate}:
15668
15669 @table @code
15670 @item     Default_switches
15671 This is an associative array attribute. Its
15672 domain is a set of language names. Its range is a string list that
15673 specifies options to be used when calling @command{gnatelim} on a source
15674 written in that language, for which no file-specific switches have been
15675 specified.
15676
15677 @item Switches
15678 This is an associative array attribute. Its domain is
15679 a set of file names. Its range is a string list that specifies
15680 options to be used when calling @command{gnatelim} on the named main source.
15681 If a source is not specified in the Switches attribute, @command{gnatelim} will
15682 be called with the options specified by Default_Switches of its language,
15683 if defined.
15684 @end table
15685
15686 @subsection package Metrics
15687
15688 @noindent
15689 The attributes of package @code{Metrics}
15690 specify the tool options to be used
15691 when invoking the tool @command{gnatmetric}.
15692 The following attributes apply to package @code{Metrics}:
15693
15694 @table @code
15695 @item     Default_switches
15696 This is an associative array attribute. Its
15697 domain is a set of language names. Its range is a string list that
15698 specifies options to be used when calling @command{gnatmetric} on a source
15699 written in that language, for which no file-specific switches have been
15700 specified.
15701
15702 @item Switches
15703 This is an associative array attribute. Its domain is
15704 a set of file names. Its range is a string list that specifies
15705 options to be used when calling @command{gnatmetric} on the named main source.
15706 If a source is not specified in the Switches attribute, @command{gnatmetric}
15707 will be called with the options specified by Default_Switches of its language,
15708 if defined.
15709 @end table
15710
15711 @subsection  package IDE
15712
15713 @noindent
15714 The attributes of package @code{IDE} specify the options to be used when using
15715 an Integrated Development Environment such as @command{GPS}.
15716
15717 @table @code
15718 @item Remote_Host
15719 This is a simple attribute. Its value is a string that designates the remote
15720 host in a cross-compilation environment, to be used for remote compilation and
15721 debugging. This field should not be specified when running on the local
15722 machine.
15723
15724 @item Program_Host
15725 This is a simple attribute. Its value is a string that specifies the
15726 name of IP address of the embedded target in a cross-compilation environment,
15727 on which the program should execute.
15728
15729 @item Communication_Protocol
15730 This is a simple string attribute. Its value is the name of the protocol
15731 to use to communicate with the target in a cross-compilation environment,
15732 e.g. @code{"wtx"} or @code{"vxworks"}.
15733
15734 @item Compiler_Command
15735 This is an associative array attribute, whose domain is a language name. Its
15736 value is  string that denotes the command to be used to invoke the compiler.
15737 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15738 gnatmake, in particular in the handling of switches.
15739
15740 @item Debugger_Command
15741 This is simple attribute, Its value is a string that specifies the name of
15742 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15743
15744 @item Default_Switches
15745 This is an associative array attribute. Its indexes are the name of the
15746 external tools that the GNAT Programming System (GPS) is supporting. Its
15747 value is a list of switches to use when invoking that tool.
15748
15749 @item  Gnatlist
15750 This is a simple attribute.  Its value is a string that specifies the name
15751 of the @command{gnatls} utility to be used to retrieve information about the
15752 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15753
15754 @item VCS_Kind
15755 This is a simple attribute. Its value is a string used to specify the
15756 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15757 ClearCase or Perforce.
15758
15759 @item VCS_File_Check
15760 This is a simple attribute. Its value is a string that specifies the
15761 command used by the VCS to check the validity of a file, either
15762 when the user explicitly asks for a check, or as a sanity check before
15763 doing the check-in.
15764
15765 @item VCS_Log_Check
15766 This is a simple attribute. Its value is a string that specifies
15767 the command used by the VCS to check the validity of a log file.
15768
15769 @item VCS_Repository_Root
15770 The VCS repository root path. This is used to create tags or branches
15771 of the repository. For subversion the value should be the @code{URL}
15772 as specified to check-out the working copy of the repository.
15773
15774 @item VCS_Patch_Root
15775 The local root directory to use for building patch file. All patch chunks
15776 will be relative to this path. The root project directory is used if
15777 this value is not defined.
15778
15779 @end table
15780
15781 @node Package Renamings
15782 @section Package Renamings
15783
15784 @noindent
15785 A package can be defined by a renaming declaration. The new package renames
15786 a package declared in a different project file, and has the same attributes
15787 as the package it renames.
15788 Syntax:
15789 @smallexample
15790 package_renaming ::==
15791   @b{package} package_identifier @b{renames}
15792        <project_>simple_name.package_identifier ;
15793 @end smallexample
15794
15795 @noindent
15796 The package_identifier of the renamed package must be the same as the
15797 package_identifier. The project whose name is the prefix of the renamed
15798 package must contain a package declaration with this name. This project
15799 must appear in the context_clause of the enclosing project declaration,
15800 or be the parent project of the enclosing child project.
15801
15802 @node Projects
15803 @section Projects
15804
15805 @noindent
15806 A project file specifies a set of rules for constructing a software system.
15807 A project file can be self-contained, or depend on other project files.
15808 Dependencies are expressed through a context clause that names other projects.
15809
15810 Syntax:
15811
15812 @smallexample
15813 project ::=
15814   context_clause project_declaration
15815
15816 project_declaration ::=
15817   simple_project_declaration | project_extension
15818
15819 simple_project_declaration ::=
15820   @b{project} <project_>simple_name @b{is}
15821     @{declarative_item@}
15822   @b{end} <project_>simple_name;
15823
15824 context_clause ::=
15825   @{with_clause@}
15826
15827 with_clause ::=
15828   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15829
15830 path_name ::=
15831    string_literal
15832 @end smallexample
15833
15834 @noindent
15835 A path name denotes a project file. A path name can be absolute or relative.
15836 An absolute path name includes a sequence of directories, in the syntax of
15837 the host operating system, that identifies uniquely the project file in the
15838 file system. A relative path name identifies the project file, relative
15839 to the directory that contains the current project, or relative to a
15840 directory listed in the environment variable ADA_PROJECT_PATH.
15841 Path names are case sensitive if file names in the host operating system
15842 are case sensitive.
15843
15844 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15845 directory names separated by colons (semicolons on Windows).
15846
15847 A given project name can appear only once in a context_clause.
15848
15849 It is illegal for a project imported by a context clause to refer, directly
15850 or indirectly, to the project in which this context clause appears (the
15851 dependency graph cannot contain cycles), except when one of the with_clause
15852 in the cycle is a @code{limited with}.
15853
15854 @node Project Extensions
15855 @section Project Extensions
15856
15857 @noindent
15858 A project extension introduces a new project, which inherits the declarations
15859 of another project.
15860 Syntax:
15861 @smallexample
15862
15863 project_extension ::=
15864   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15865     @{declarative_item@}
15866   @b{end} <project_>simple_name;
15867 @end smallexample
15868
15869 @noindent
15870 The project extension declares a child project. The child project inherits
15871 all the declarations and all the files of the parent project, These inherited
15872 declaration can be overridden in the child project, by means of suitable
15873 declarations.
15874
15875 @node Project File Elaboration
15876 @section Project File Elaboration
15877
15878 @noindent
15879 A project file is processed as part of the invocation of a gnat tool that
15880 uses the project option. Elaboration of the process file consists in the
15881 sequential elaboration of all its declarations. The computed values of
15882 attributes and variables in the project are then used to establish the
15883 environment in which the gnat tool will execute.
15884
15885 @node Obsolescent Features
15886 @chapter Obsolescent Features
15887
15888 @noindent
15889 This chapter describes features that are provided by GNAT, but are
15890 considered obsolescent since there are preferred ways of achieving
15891 the same effect. These features are provided solely for historical
15892 compatibility purposes.
15893
15894 @menu
15895 * pragma No_Run_Time::
15896 * pragma Ravenscar::
15897 * pragma Restricted_Run_Time::
15898 @end menu
15899
15900 @node pragma No_Run_Time
15901 @section pragma No_Run_Time
15902
15903 The pragma @code{No_Run_Time} is used to achieve an affect similar
15904 to the use of the "Zero Foot Print" configurable run time, but without
15905 requiring a specially configured run time. The result of using this
15906 pragma, which must be used for all units in a partition, is to restrict
15907 the use of any language features requiring run-time support code. The
15908 preferred usage is to use an appropriately configured run-time that
15909 includes just those features that are to be made accessible.
15910
15911 @node pragma Ravenscar
15912 @section pragma Ravenscar
15913
15914 The pragma @code{Ravenscar} has exactly the same effect as pragma
15915 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15916 is part of the new Ada 2005 standard.
15917
15918 @node pragma Restricted_Run_Time
15919 @section pragma Restricted_Run_Time
15920
15921 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15922 pragma @code{Profile (Restricted)}. The latter usage is
15923 preferred since the Ada 2005 pragma @code{Profile} is intended for
15924 this kind of implementation dependent addition.
15925
15926 @include fdl.texi
15927 @c GNU Free Documentation License
15928
15929 @node Index,,GNU Free Documentation License, Top
15930 @unnumbered Index
15931
15932 @printindex cp
15933
15934 @contents
15935
15936 @bye