OSDN Git Service

2007-06-11 Bob Duff <duff@adacore.com>
[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 Comment::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
119 * Pragma CPP_Class::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
123 * Pragma Debug::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
127 * Pragma Eliminate::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
135 * Pragma External::
136 * Pragma External_Name_Casing::
137 * Pragma Finalize_Storage_Only::
138 * Pragma Float_Representation::
139 * Pragma Ident::
140 * Pragma Import_Exception::
141 * Pragma Import_Function::
142 * Pragma Import_Object::
143 * Pragma Import_Procedure::
144 * Pragma Import_Valued_Procedure::
145 * Pragma Initialize_Scalars::
146 * Pragma Inline_Always::
147 * Pragma Inline_Generic::
148 * Pragma Interface::
149 * Pragma Interface_Name::
150 * Pragma Interrupt_Handler::
151 * Pragma Interrupt_State::
152 * Pragma Keep_Names::
153 * Pragma License::
154 * Pragma Link_With::
155 * Pragma Linker_Alias::
156 * Pragma Linker_Constructor::
157 * Pragma Linker_Destructor::
158 * Pragma Linker_Section::
159 * Pragma Long_Float::
160 * Pragma Machine_Attribute::
161 * Pragma Main_Storage::
162 * Pragma No_Body::
163 * Pragma No_Return::
164 * Pragma No_Strict_Aliasing ::
165 * Pragma Normalize_Scalars::
166 * Pragma Obsolescent::
167 * Pragma Passive::
168 * Pragma Persistent_BSS::
169 * Pragma Polling::
170 * Pragma Profile (Ravenscar)::
171 * Pragma Profile (Restricted)::
172 * Pragma Psect_Object::
173 * Pragma Pure_Function::
174 * Pragma Restriction_Warnings::
175 * Pragma Source_File_Name::
176 * Pragma Source_File_Name_Project::
177 * Pragma Source_Reference::
178 * Pragma Stream_Convert::
179 * Pragma Style_Checks::
180 * Pragma Subtitle::
181 * Pragma Suppress::
182 * Pragma Suppress_All::
183 * Pragma Suppress_Exception_Locations::
184 * Pragma Suppress_Initialization::
185 * Pragma Task_Info::
186 * Pragma Task_Name::
187 * Pragma Task_Storage::
188 * Pragma Time_Slice::
189 * Pragma Title::
190 * Pragma Unchecked_Union::
191 * Pragma Unimplemented_Unit::
192 * Pragma Universal_Aliasing ::
193 * Pragma Universal_Data::
194 * Pragma Unreferenced::
195 * Pragma Unreferenced_Objects::
196 * Pragma Unreserve_All_Interrupts::
197 * Pragma Unsuppress::
198 * Pragma Use_VADS_Size::
199 * Pragma Validity_Checks::
200 * Pragma Volatile::
201 * Pragma Warnings::
202 * Pragma Weak_External::
203 * Pragma Wide_Character_Encoding::
204
205 Implementation Defined Attributes
206
207 * Abort_Signal::
208 * Address_Size::
209 * Asm_Input::
210 * Asm_Output::
211 * AST_Entry::
212 * Bit::
213 * Bit_Position::
214 * Code_Address::
215 * Default_Bit_Order::
216 * Elaborated::
217 * Elab_Body::
218 * Elab_Spec::
219 * Emax::
220 * Enum_Rep::
221 * Epsilon::
222 * Fixed_Value::
223 * Has_Access_Values::
224 * Has_Discriminants::
225 * Img::
226 * Integer_Value::
227 * Large::
228 * Machine_Size::
229 * Mantissa::
230 * Max_Interrupt_Priority::
231 * Max_Priority::
232 * Maximum_Alignment::
233 * Mechanism_Code::
234 * Null_Parameter::
235 * Object_Size::
236 * Passed_By_Reference::
237 * Range_Length::
238 * Safe_Emax::
239 * Safe_Large::
240 * Small::
241 * Storage_Unit::
242 * Stub_Type::
243 * Target_Name::
244 * Tick::
245 * To_Address::
246 * Type_Class::
247 * UET_Address::
248 * Unconstrained_Array::
249 * Universal_Literal_String::
250 * Unrestricted_Access::
251 * VADS_Size::
252 * Value_Size::
253 * Wchar_T_Size::
254 * Word_Size::
255
256 The Implementation of Standard I/O
257
258 * Standard I/O Packages::
259 * FORM Strings::
260 * Direct_IO::
261 * Sequential_IO::
262 * Text_IO::
263 * Wide_Text_IO::
264 * Wide_Wide_Text_IO::
265 * Stream_IO::
266 * Shared Files::
267 * Filenames encoding::
268 * Open Modes::
269 * Operations on C Streams::
270 * Interfacing to C Streams::
271
272 The GNAT Library
273
274 * Ada.Characters.Latin_9 (a-chlat9.ads)::
275 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
276 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
277 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
278 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
279 * Ada.Command_Line.Remove (a-colire.ads)::
280 * Ada.Command_Line.Environment (a-colien.ads)::
281 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
282 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
283 * Ada.Exceptions.Traceback (a-exctra.ads)::
284 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
285 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
286 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
287 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
288 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
289 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
290 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
291 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
292 * GNAT.Altivec (g-altive.ads)::
293 * GNAT.Altivec.Conversions (g-altcon.ads)::
294 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
295 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
296 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
297 * GNAT.Array_Split (g-arrspl.ads)::
298 * GNAT.AWK (g-awk.ads)::
299 * GNAT.Bounded_Buffers (g-boubuf.ads)::
300 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
301 * GNAT.Bubble_Sort (g-bubsor.ads)::
302 * GNAT.Bubble_Sort_A (g-busora.ads)::
303 * GNAT.Bubble_Sort_G (g-busorg.ads)::
304 * GNAT.Byte_Swapping (g-bytswa.ads)::
305 * GNAT.Calendar (g-calend.ads)::
306 * GNAT.Calendar.Time_IO (g-catiio.ads)::
307 * GNAT.Case_Util (g-casuti.ads)::
308 * GNAT.CGI (g-cgi.ads)::
309 * GNAT.CGI.Cookie (g-cgicoo.ads)::
310 * GNAT.CGI.Debug (g-cgideb.ads)::
311 * GNAT.Command_Line (g-comlin.ads)::
312 * GNAT.Compiler_Version (g-comver.ads)::
313 * GNAT.Ctrl_C (g-ctrl_c.ads)::
314 * GNAT.CRC32 (g-crc32.ads)::
315 * GNAT.Current_Exception (g-curexc.ads)::
316 * GNAT.Debug_Pools (g-debpoo.ads)::
317 * GNAT.Debug_Utilities (g-debuti.ads)::
318 * GNAT.Directory_Operations (g-dirope.ads)::
319 * GNAT.Dynamic_HTables (g-dynhta.ads)::
320 * GNAT.Dynamic_Tables (g-dyntab.ads)::
321 * GNAT.Exception_Actions (g-excact.ads)::
322 * GNAT.Exception_Traces (g-exctra.ads)::
323 * GNAT.Exceptions (g-except.ads)::
324 * GNAT.Expect (g-expect.ads)::
325 * GNAT.Float_Control (g-flocon.ads)::
326 * GNAT.Heap_Sort (g-heasor.ads)::
327 * GNAT.Heap_Sort_A (g-hesora.ads)::
328 * GNAT.Heap_Sort_G (g-hesorg.ads)::
329 * GNAT.HTable (g-htable.ads)::
330 * GNAT.IO (g-io.ads)::
331 * GNAT.IO_Aux (g-io_aux.ads)::
332 * GNAT.Lock_Files (g-locfil.ads)::
333 * GNAT.MD5 (g-md5.ads)::
334 * GNAT.Memory_Dump (g-memdum.ads)::
335 * GNAT.Most_Recent_Exception (g-moreex.ads)::
336 * GNAT.OS_Lib (g-os_lib.ads)::
337 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
338 * GNAT.Regexp (g-regexp.ads)::
339 * GNAT.Registry (g-regist.ads)::
340 * GNAT.Regpat (g-regpat.ads)::
341 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
342 * GNAT.Semaphores (g-semaph.ads)::
343 * GNAT.SHA1 (g-sha1.ads)::
344 * GNAT.Signals (g-signal.ads)::
345 * GNAT.Sockets (g-socket.ads)::
346 * GNAT.Source_Info (g-souinf.ads)::
347 * GNAT.Spell_Checker (g-speche.ads)::
348 * GNAT.Spitbol.Patterns (g-spipat.ads)::
349 * GNAT.Spitbol (g-spitbo.ads)::
350 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
351 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
352 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
353 * GNAT.Strings (g-string.ads)::
354 * GNAT.String_Split (g-strspl.ads)::
355 * GNAT.Table (g-table.ads)::
356 * GNAT.Task_Lock (g-tasloc.ads)::
357 * GNAT.Threads (g-thread.ads)::
358 * GNAT.Traceback (g-traceb.ads)::
359 * GNAT.Traceback.Symbolic (g-trasym.ads)::
360 * GNAT.Wide_String_Split (g-wistsp.ads)::
361 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
362 * Interfaces.C.Extensions (i-cexten.ads)::
363 * Interfaces.C.Streams (i-cstrea.ads)::
364 * Interfaces.CPP (i-cpp.ads)::
365 * Interfaces.Os2lib (i-os2lib.ads)::
366 * Interfaces.Os2lib.Errors (i-os2err.ads)::
367 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
368 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
369 * Interfaces.Packed_Decimal (i-pacdec.ads)::
370 * Interfaces.VxWorks (i-vxwork.ads)::
371 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
372 * System.Address_Image (s-addima.ads)::
373 * System.Assertions (s-assert.ads)::
374 * System.Memory (s-memory.ads)::
375 * System.Partition_Interface (s-parint.ads)::
376 * System.Restrictions (s-restri.ads)::
377 * System.Rident (s-rident.ads)::
378 * System.Task_Info (s-tasinf.ads)::
379 * System.Wch_Cnv (s-wchcnv.ads)::
380 * System.Wch_Con (s-wchcon.ads)::
381
382 Text_IO
383
384 * Text_IO Stream Pointer Positioning::
385 * Text_IO Reading and Writing Non-Regular Files::
386 * Get_Immediate::
387 * Treating Text_IO Files as Streams::
388 * Text_IO Extensions::
389 * Text_IO Facilities for Unbounded Strings::
390
391 Wide_Text_IO
392
393 * Wide_Text_IO Stream Pointer Positioning::
394 * Wide_Text_IO Reading and Writing Non-Regular Files::
395
396 Wide_Wide_Text_IO
397
398 * Wide_Wide_Text_IO Stream Pointer Positioning::
399 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
400
401 Interfacing to Other Languages
402
403 * Interfacing to C::
404 * Interfacing to C++::
405 * Interfacing to COBOL::
406 * Interfacing to Fortran::
407 * Interfacing to non-GNAT Ada code::
408
409 Specialized Needs Annexes
410
411 Implementation of Specific Ada Features
412 * Machine Code Insertions::
413 * GNAT Implementation of Tasking::
414 * GNAT Implementation of Shared Passive Packages::
415 * Code Generation for Array Aggregates::
416 * The Size of Discriminated Records with Default Discriminants::
417 * Strict Conformance to the Ada Reference Manual::
418
419 Project File Reference
420
421 Obsolescent Features
422
423 GNU Free Documentation License
424
425 Index
426 @end menu
427
428 @end ifnottex
429
430 @node About This Guide
431 @unnumbered About This Guide
432
433 @noindent
434 This manual contains useful information in writing programs using the
435 @value{EDITION} compiler.  It includes information on implementation dependent
436 characteristics of @value{EDITION}, including all the information required by
437 Annex M of the Ada language standard.
438
439 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
440 Ada 83 compatibility mode.
441 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
442 but you can override with a compiler switch
443 to explicitly specify the language version.
444 (Please refer to the section ``Compiling Different Versions of Ada'', in
445 @cite{@value{EDITION} User's Guide}, for details on these switches.)
446 Throughout this manual, references to ``Ada'' without a year suffix
447 apply to both the Ada 95 and Ada 2005 versions of the language.
448
449 Ada is designed to be highly portable.
450 In general, a program will have the same effect even when compiled by
451 different compilers on different platforms.
452 However, since Ada is designed to be used in a
453 wide variety of applications, it also contains a number of system
454 dependent features to be used in interfacing to the external world.
455 @cindex Implementation-dependent features
456 @cindex Portability
457
458 Note: Any program that makes use of implementation-dependent features
459 may be non-portable.  You should follow good programming practice and
460 isolate and clearly document any sections of your program that make use
461 of these features in a non-portable manner.
462
463 @ifset PROEDITION
464 For ease of exposition, ``GNAT Pro'' will be referred to simply as
465 ``GNAT'' in the remainder of this document.
466 @end ifset
467
468 @menu
469 * What This Reference Manual Contains::
470 * Conventions::
471 * Related Information::
472 @end menu
473
474 @node What This Reference Manual Contains
475 @unnumberedsec What This Reference Manual Contains
476
477 @noindent
478 This reference manual contains the following chapters:
479
480 @itemize @bullet
481 @item
482 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
483 pragmas, which can be used to extend and enhance the functionality of the
484 compiler.
485
486 @item
487 @ref{Implementation Defined Attributes}, lists GNAT
488 implementation-dependent attributes which can be used to extend and
489 enhance the functionality of the compiler.
490
491 @item
492 @ref{Implementation Advice}, provides information on generally
493 desirable behavior which are not requirements that all compilers must
494 follow since it cannot be provided on all systems, or which may be
495 undesirable on some systems.
496
497 @item
498 @ref{Implementation Defined Characteristics}, provides a guide to
499 minimizing implementation dependent features.
500
501 @item
502 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
503 implemented by GNAT, and how they can be imported into user
504 application programs.
505
506 @item
507 @ref{Representation Clauses and Pragmas}, describes in detail the
508 way that GNAT represents data, and in particular the exact set
509 of representation clauses and pragmas that is accepted.
510
511 @item
512 @ref{Standard Library Routines}, provides a listing of packages and a
513 brief description of the functionality that is provided by Ada's
514 extensive set of standard library routines as implemented by GNAT@.
515
516 @item
517 @ref{The Implementation of Standard I/O}, details how the GNAT
518 implementation of the input-output facilities.
519
520 @item
521 @ref{The GNAT Library}, is a catalog of packages that complement
522 the Ada predefined library.
523
524 @item
525 @ref{Interfacing to Other Languages}, describes how programs
526 written in Ada using GNAT can be interfaced to other programming
527 languages.
528
529 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
530 of the specialized needs annexes.
531
532 @item
533 @ref{Implementation of Specific Ada Features}, discusses issues related
534 to GNAT's implementation of machine code insertions, tasking, and several
535 other features.
536
537 @item
538 @ref{Project File Reference}, presents the syntax and semantics
539 of project files.
540
541 @item
542 @ref{Obsolescent Features} documents implementation dependent features,
543 including pragmas and attributes, which are considered obsolescent, since
544 there are other preferred ways of achieving the same results. These
545 obsolescent forms are retained for backwards compatibility.
546
547 @end itemize
548
549 @cindex Ada 95 Language Reference Manual
550 @cindex Ada 2005 Language Reference Manual
551 @noindent
552 This reference manual assumes a basic familiarity with the Ada 95 language, as
553 described in the International Standard ANSI/ISO/IEC-8652:1995,
554 January 1995.
555 It does not require knowledge of the new features introduced by Ada 2005,
556 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
557 and Amendment 1).
558 Both reference manuals are included in the GNAT documentation
559 package.
560
561 @node Conventions
562 @unnumberedsec Conventions
563 @cindex Conventions, typographical
564 @cindex Typographical conventions
565
566 @noindent
567 Following are examples of the typographical and graphic conventions used
568 in this guide:
569
570 @itemize @bullet
571 @item
572 @code{Functions}, @code{utility program names}, @code{standard names},
573 and @code{classes}.
574
575 @item
576 @code{Option flags}
577
578 @item
579 @file{File Names}, @samp{button names}, and @samp{field names}.
580
581 @item
582 @code{Variables}.
583
584 @item
585 @emph{Emphasis}.
586
587 @item
588 [optional information or parameters]
589
590 @item
591 Examples are described by text
592 @smallexample
593 and then shown this way.
594 @end smallexample
595 @end itemize
596
597 @noindent
598 Commands that are entered by the user are preceded in this manual by the
599 characters @samp{$ } (dollar sign followed by space).  If your system uses this
600 sequence as a prompt, then the commands will appear exactly as you see them
601 in the manual.  If your system uses some other prompt, then the command will
602 appear with the @samp{$} replaced by whatever prompt character you are using.
603
604 @node Related Information
605 @unnumberedsec Related Information
606 @noindent
607 See the following documents for further information on GNAT:
608
609 @itemize @bullet
610 @item
611 @cite{GNAT User's Guide}, which provides information on how to use
612 the GNAT compiler system.
613
614 @item
615 @cite{Ada 95 Reference Manual}, which contains all reference
616 material for the Ada 95 programming language.
617
618 @item
619 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
620 of the Ada 95 standard.  The annotations describe
621 detailed aspects of the design decision, and in particular contain useful
622 sections on Ada 83 compatibility.
623
624 @item
625 @cite{Ada 2005 Reference Manual}, which contains all reference
626 material for the Ada 2005 programming language.
627
628 @item
629 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
630 of the Ada 2005 standard.  The annotations describe
631 detailed aspects of the design decision, and in particular contain useful
632 sections on Ada 83 and Ada 95 compatibility.
633
634 @item
635 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
636 which contains specific information on compatibility between GNAT and
637 DEC Ada 83 systems.
638
639 @item
640 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
641 describes in detail the pragmas and attributes provided by the DEC Ada 83
642 compiler system.
643
644 @end itemize
645
646 @node Implementation Defined Pragmas
647 @chapter Implementation Defined Pragmas
648
649 @noindent
650 Ada defines a set of pragmas that can be used to supply additional
651 information to the compiler.  These language defined pragmas are
652 implemented in GNAT and work as described in the Ada Reference
653 Manual.
654
655 In addition, Ada allows implementations to define additional pragmas
656 whose meaning is defined by the implementation.  GNAT provides a number
657 of these implementation-dependent pragmas which can be used to extend
658 and enhance the functionality of the compiler.  This section of the GNAT
659 Reference Manual describes these additional pragmas.
660
661 Note that any program using these pragmas may not be portable to other
662 compilers (although GNAT implements this set of pragmas on all
663 platforms).  Therefore if portability to other compilers is an important
664 consideration, the use of these pragmas should be minimized.
665
666 @menu
667 * Pragma Abort_Defer::
668 * Pragma Ada_83::
669 * Pragma Ada_95::
670 * Pragma Ada_05::
671 * Pragma Ada_2005::
672 * Pragma Annotate::
673 * Pragma Assert::
674 * Pragma Ast_Entry::
675 * Pragma C_Pass_By_Copy::
676 * Pragma Comment::
677 * Pragma Common_Object::
678 * Pragma Compile_Time_Error::
679 * Pragma Compile_Time_Warning::
680 * Pragma Complete_Representation::
681 * Pragma Complex_Representation::
682 * Pragma Component_Alignment::
683 * Pragma Convention_Identifier::
684 * Pragma CPP_Class::
685 * Pragma CPP_Constructor::
686 * Pragma CPP_Virtual::
687 * Pragma CPP_Vtable::
688 * Pragma Debug::
689 * Pragma Debug_Policy::
690 * Pragma Detect_Blocking::
691 * Pragma Elaboration_Checks::
692 * Pragma Eliminate::
693 * Pragma Export_Exception::
694 * Pragma Export_Function::
695 * Pragma Export_Object::
696 * Pragma Export_Procedure::
697 * Pragma Export_Value::
698 * Pragma Export_Valued_Procedure::
699 * Pragma Extend_System::
700 * Pragma External::
701 * Pragma External_Name_Casing::
702 * Pragma Finalize_Storage_Only::
703 * Pragma Float_Representation::
704 * Pragma Ident::
705 * Pragma Import_Exception::
706 * Pragma Import_Function::
707 * Pragma Import_Object::
708 * Pragma Import_Procedure::
709 * Pragma Import_Valued_Procedure::
710 * Pragma Initialize_Scalars::
711 * Pragma Inline_Always::
712 * Pragma Inline_Generic::
713 * Pragma Interface::
714 * Pragma Interface_Name::
715 * Pragma Interrupt_Handler::
716 * Pragma Interrupt_State::
717 * Pragma Keep_Names::
718 * Pragma License::
719 * Pragma Link_With::
720 * Pragma Linker_Alias::
721 * Pragma Linker_Constructor::
722 * Pragma Linker_Destructor::
723 * Pragma Linker_Section::
724 * Pragma Long_Float::
725 * Pragma Machine_Attribute::
726 * Pragma Main_Storage::
727 * Pragma No_Body::
728 * Pragma No_Return::
729 * Pragma No_Strict_Aliasing::
730 * Pragma Normalize_Scalars::
731 * Pragma Obsolescent::
732 * Pragma Passive::
733 * Pragma Persistent_BSS::
734 * Pragma Polling::
735 * Pragma Profile (Ravenscar)::
736 * Pragma Profile (Restricted)::
737 * Pragma Psect_Object::
738 * Pragma Pure_Function::
739 * Pragma Restriction_Warnings::
740 * Pragma Source_File_Name::
741 * Pragma Source_File_Name_Project::
742 * Pragma Source_Reference::
743 * Pragma Stream_Convert::
744 * Pragma Style_Checks::
745 * Pragma Subtitle::
746 * Pragma Suppress::
747 * Pragma Suppress_All::
748 * Pragma Suppress_Exception_Locations::
749 * Pragma Suppress_Initialization::
750 * Pragma Task_Info::
751 * Pragma Task_Name::
752 * Pragma Task_Storage::
753 * Pragma Time_Slice::
754 * Pragma Title::
755 * Pragma Unchecked_Union::
756 * Pragma Unimplemented_Unit::
757 * Pragma Universal_Aliasing ::
758 * Pragma Universal_Data::
759 * Pragma Unreferenced::
760 * Pragma Unreferenced_Objects::
761 * Pragma Unreserve_All_Interrupts::
762 * Pragma Unsuppress::
763 * Pragma Use_VADS_Size::
764 * Pragma Validity_Checks::
765 * Pragma Volatile::
766 * Pragma Warnings::
767 * Pragma Weak_External::
768 * Pragma Wide_Character_Encoding::
769 @end menu
770
771 @node Pragma Abort_Defer
772 @unnumberedsec Pragma Abort_Defer
773 @findex Abort_Defer
774 @cindex Deferring aborts
775 @noindent
776 Syntax:
777 @smallexample
778 pragma Abort_Defer;
779 @end smallexample
780
781 @noindent
782 This pragma must appear at the start of the statement sequence of a
783 handled sequence of statements (right after the @code{begin}).  It has
784 the effect of deferring aborts for the sequence of statements (but not
785 for the declarations or handlers, if any, associated with this statement
786 sequence).
787
788 @node Pragma Ada_83
789 @unnumberedsec Pragma Ada_83
790 @findex Ada_83
791 @noindent
792 Syntax:
793 @smallexample @c ada
794 pragma Ada_83;
795 @end smallexample
796
797 @noindent
798 A configuration pragma that establishes Ada 83 mode for the unit to
799 which it applies, regardless of the mode set by the command line
800 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
801 the syntax and semantics of Ada 83, as defined in the original Ada
802 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
803 (and Ada 2005) are not recognized, optional package bodies are allowed,
804 and generics may name types with unknown discriminants without using
805 the @code{(<>)} notation.  In addition, some but not all of the additional
806 restrictions of Ada 83 are enforced.
807
808 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
809 Ada 83 code to be compiled and adapted to GNAT with less effort.
810 Secondly, it aids in keeping code backwards compatible with Ada 83.
811 However, there is no guarantee that code that is processed correctly
812 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
813 83 compiler, since GNAT does not enforce all the additional checks
814 required by Ada 83.
815
816 @node Pragma Ada_95
817 @unnumberedsec Pragma Ada_95
818 @findex Ada_95
819 @noindent
820 Syntax:
821 @smallexample @c ada
822 pragma Ada_95;
823 @end smallexample
824
825 @noindent
826 A configuration pragma that establishes Ada 95 mode for the unit to which
827 it applies, regardless of the mode set by the command line switches.
828 This mode is set automatically for the @code{Ada} and @code{System}
829 packages and their children, so you need not specify it in these
830 contexts.  This pragma is useful when writing a reusable component that
831 itself uses Ada 95 features, but which is intended to be usable from
832 either Ada 83 or Ada 95 programs.
833
834 @node Pragma Ada_05
835 @unnumberedsec Pragma Ada_05
836 @findex Ada_05
837 @noindent
838 Syntax:
839 @smallexample @c ada
840 pragma Ada_05;
841 @end smallexample
842
843 @noindent
844 A configuration pragma that establishes Ada 2005 mode for the unit to which
845 it applies, regardless of the mode set by the command line switches.
846 This mode is set automatically for the @code{Ada} and @code{System}
847 packages and their children, so you need not specify it in these
848 contexts.  This pragma is useful when writing a reusable component that
849 itself uses Ada 2005 features, but which is intended to be usable from
850 either Ada 83 or Ada 95 programs.
851
852 @node Pragma Ada_2005
853 @unnumberedsec Pragma Ada_2005
854 @findex Ada_2005
855 @noindent
856 Syntax:
857 @smallexample @c ada
858 pragma Ada_2005;
859 @end smallexample
860
861 @noindent
862 This configuration pragma is a synonym for pragma Ada_05 and has the
863 same syntax and effect.
864
865 @node Pragma Annotate
866 @unnumberedsec Pragma Annotate
867 @findex Annotate
868 @noindent
869 Syntax:
870 @smallexample @c ada
871 pragma Annotate (IDENTIFIER @{, ARG@});
872
873 ARG ::= NAME | EXPRESSION
874 @end smallexample
875
876 @noindent
877 This pragma is used to annotate programs.  @var{identifier} identifies
878 the type of annotation.  GNAT verifies this is an identifier, but does
879 not otherwise analyze it.  The @var{arg} argument
880 can be either a string literal or an
881 expression.  String literals are assumed to be of type
882 @code{Standard.String}.  Names of entities are simply analyzed as entity
883 names.  All other expressions are analyzed as expressions, and must be
884 unambiguous.
885
886 The analyzed pragma is retained in the tree, but not otherwise processed
887 by any part of the GNAT compiler.  This pragma is intended for use by
888 external tools, including ASIS@.
889
890 @node Pragma Assert
891 @unnumberedsec Pragma Assert
892 @findex Assert
893 @noindent
894 Syntax:
895 @smallexample @c ada
896 pragma Assert (
897   boolean_EXPRESSION
898   [, static_string_EXPRESSION]);
899 @end smallexample
900
901 @noindent
902 The effect of this pragma depends on whether the corresponding command
903 line switch is set to activate assertions.  The pragma expands into code
904 equivalent to the following:
905
906 @smallexample @c ada
907 if assertions-enabled then
908    if not boolean_EXPRESSION then
909       System.Assertions.Raise_Assert_Failure
910         (string_EXPRESSION);
911    end if;
912 end if;
913 @end smallexample
914
915 @noindent
916 The string argument, if given, is the message that will be associated
917 with the exception occurrence if the exception is raised.  If no second
918 argument is given, the default message is @samp{@var{file}:@var{nnn}},
919 where @var{file} is the name of the source file containing the assert,
920 and @var{nnn} is the line number of the assert.  A pragma is not a
921 statement, so if a statement sequence contains nothing but a pragma
922 assert, then a null statement is required in addition, as in:
923
924 @smallexample @c ada
925 @dots{}
926 if J > 3 then
927    pragma Assert (K > 3, "Bad value for K");
928    null;
929 end if;
930 @end smallexample
931
932 @noindent
933 Note that, as with the @code{if} statement to which it is equivalent, the
934 type of the expression is either @code{Standard.Boolean}, or any type derived
935 from this standard type.
936
937 If assertions are disabled (switch @code{-gnata} not used), then there
938 is no effect (and in particular, any side effects from the expression
939 are suppressed).  More precisely it is not quite true that the pragma
940 has no effect, since the expression is analyzed, and may cause types
941 to be frozen if they are mentioned here for the first time.
942
943 If assertions are enabled, then the given expression is tested, and if
944 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
945 which results in the raising of @code{Assert_Failure} with the given message.
946
947 If the boolean expression has side effects, these side effects will turn
948 on and off with the setting of the assertions mode, resulting in
949 assertions that have an effect on the program.  You should generally
950 avoid side effects in the expression arguments of this pragma.  However,
951 the expressions are analyzed for semantic correctness whether or not
952 assertions are enabled, so turning assertions on and off cannot affect
953 the legality of a program.
954
955 @node Pragma Ast_Entry
956 @unnumberedsec Pragma Ast_Entry
957 @cindex OpenVMS
958 @findex Ast_Entry
959 @noindent
960 Syntax:
961 @smallexample @c ada
962 pragma AST_Entry (entry_IDENTIFIER);
963 @end smallexample
964
965 @noindent
966 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
967 argument is the simple name of a single entry; at most one @code{AST_Entry}
968 pragma is allowed for any given entry.  This pragma must be used in
969 conjunction with the @code{AST_Entry} attribute, and is only allowed after
970 the entry declaration and in the same task type specification or single task
971 as the entry to which it applies.  This pragma specifies that the given entry
972 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
973 resulting from an OpenVMS system service call.  The pragma does not affect
974 normal use of the entry.  For further details on this pragma, see the
975 DEC Ada Language Reference Manual, section 9.12a.
976
977 @node Pragma C_Pass_By_Copy
978 @unnumberedsec Pragma C_Pass_By_Copy
979 @cindex Passing by copy
980 @findex C_Pass_By_Copy
981 @noindent
982 Syntax:
983 @smallexample @c ada
984 pragma C_Pass_By_Copy
985   ([Max_Size =>] static_integer_EXPRESSION);
986 @end smallexample
987
988 @noindent
989 Normally the default mechanism for passing C convention records to C
990 convention subprograms is to pass them by reference, as suggested by RM
991 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
992 this default, by requiring that record formal parameters be passed by
993 copy if all of the following conditions are met:
994
995 @itemize @bullet
996 @item
997 The size of the record type does not exceed@*@var{static_integer_expression}.
998 @item
999 The record type has @code{Convention C}.
1000 @item
1001 The formal parameter has this record type, and the subprogram has a
1002 foreign (non-Ada) convention.
1003 @end itemize
1004
1005 @noindent
1006 If these conditions are met the argument is passed by copy, i.e.@: in a
1007 manner consistent with what C expects if the corresponding formal in the
1008 C prototype is a struct (rather than a pointer to a struct).
1009
1010 You can also pass records by copy by specifying the convention
1011 @code{C_Pass_By_Copy} for the record type, or by using the extended
1012 @code{Import} and @code{Export} pragmas, which allow specification of
1013 passing mechanisms on a parameter by parameter basis.
1014
1015 @node Pragma Comment
1016 @unnumberedsec Pragma Comment
1017 @findex Comment
1018 @noindent
1019 Syntax:
1020
1021 @smallexample @c ada
1022 pragma Comment (static_string_EXPRESSION);
1023 @end smallexample
1024
1025 @noindent
1026 This is almost identical in effect to pragma @code{Ident}.  It allows the
1027 placement of a comment into the object file and hence into the
1028 executable file if the operating system permits such usage.  The
1029 difference is that @code{Comment}, unlike @code{Ident}, has
1030 no limitations on placement of the pragma (it can be placed
1031 anywhere in the main source unit), and if more than one pragma
1032 is used, all comments are retained.
1033
1034 @node Pragma Common_Object
1035 @unnumberedsec Pragma Common_Object
1036 @findex Common_Object
1037 @noindent
1038 Syntax:
1039
1040 @smallexample @c ada
1041 pragma Common_Object (
1042      [Internal =>] local_NAME,
1043   [, [External =>] EXTERNAL_SYMBOL]
1044   [, [Size     =>] EXTERNAL_SYMBOL] );
1045
1046 EXTERNAL_SYMBOL ::=
1047   IDENTIFIER
1048 | static_string_EXPRESSION
1049 @end smallexample
1050
1051 @noindent
1052 This pragma enables the shared use of variables stored in overlaid
1053 linker areas corresponding to the use of @code{COMMON}
1054 in Fortran.  The single
1055 object @var{local_NAME} is assigned to the area designated by
1056 the @var{External} argument.
1057 You may define a record to correspond to a series
1058 of fields.  The @var{size} argument
1059 is syntax checked in GNAT, but otherwise ignored.
1060
1061 @code{Common_Object} is not supported on all platforms.  If no
1062 support is available, then the code generator will issue a message
1063 indicating that the necessary attribute for implementation of this
1064 pragma is not available.
1065
1066 @node Pragma Compile_Time_Error
1067 @unnumberedsec Pragma Compile_Time_Error
1068 @findex Compile_Time_Error
1069 @noindent
1070 Syntax:
1071
1072 @smallexample @c ada
1073 pragma Compile_Time_Error
1074          (boolean_EXPRESSION, static_string_EXPRESSION);
1075 @end smallexample
1076
1077 @noindent
1078 This pragma can be used to generate additional compile time
1079 error messages. It
1080 is particularly useful in generics, where errors can be issued for
1081 specific problematic instantiations. The first parameter is a boolean
1082 expression. The pragma is effective only if the value of this expression
1083 is known at compile time, and has the value True. The set of expressions
1084 whose values are known at compile time includes all static boolean
1085 expressions, and also other values which the compiler can determine
1086 at compile time (e.g. the size of a record type set by an explicit
1087 size representation clause, or the value of a variable which was
1088 initialized to a constant and is known not to have been modified).
1089 If these conditions are met, an error message is generated using
1090 the value given as the second argument. This string value may contain
1091 embedded ASCII.LF characters to break the message into multiple lines.
1092
1093 @node Pragma Compile_Time_Warning
1094 @unnumberedsec Pragma Compile_Time_Warning
1095 @findex Compile_Time_Warning
1096 @noindent
1097 Syntax:
1098
1099 @smallexample @c ada
1100 pragma Compile_Time_Warning
1101          (boolean_EXPRESSION, static_string_EXPRESSION);
1102 @end smallexample
1103
1104 @noindent
1105 This pragma can be used to generate additional compile time warnings. It
1106 is particularly useful in generics, where warnings can be issued for
1107 specific problematic instantiations. The first parameter is a boolean
1108 expression. The pragma is effective only if the value of this expression
1109 is known at compile time, and has the value True. The set of expressions
1110 whose values are known at compile time includes all static boolean
1111 expressions, and also other values which the compiler can determine
1112 at compile time (e.g. the size of a record type set by an explicit
1113 size representation clause, or the value of a variable which was
1114 initialized to a constant and is known not to have been modified).
1115 If these conditions are met, a warning message is generated using
1116 the value given as the second argument. This string value may contain
1117 embedded ASCII.LF characters to break the message into multiple lines.
1118
1119 @node Pragma Complete_Representation
1120 @unnumberedsec Pragma Complete_Representation
1121 @findex Complete_Representation
1122 @noindent
1123 Syntax:
1124
1125 @smallexample @c ada
1126 pragma Complete_Representation;
1127 @end smallexample
1128
1129 @noindent
1130 This pragma must appear immediately within a record representation
1131 clause. Typical placements are before the first component clause
1132 or after the last component clause. The effect is to give an error
1133 message if any component is missing a component clause. This pragma
1134 may be used to ensure that a record representation clause is
1135 complete, and that this invariant is maintained if fields are
1136 added to the record in the future.
1137
1138 @node Pragma Complex_Representation
1139 @unnumberedsec Pragma Complex_Representation
1140 @findex Complex_Representation
1141 @noindent
1142 Syntax:
1143
1144 @smallexample @c ada
1145 pragma Complex_Representation
1146         ([Entity =>] local_NAME);
1147 @end smallexample
1148
1149 @noindent
1150 The @var{Entity} argument must be the name of a record type which has
1151 two fields of the same floating-point type.  The effect of this pragma is
1152 to force gcc to use the special internal complex representation form for
1153 this record, which may be more efficient.  Note that this may result in
1154 the code for this type not conforming to standard ABI (application
1155 binary interface) requirements for the handling of record types.  For
1156 example, in some environments, there is a requirement for passing
1157 records by pointer, and the use of this pragma may result in passing
1158 this type in floating-point registers.
1159
1160 @node Pragma Component_Alignment
1161 @unnumberedsec Pragma Component_Alignment
1162 @cindex Alignments of components
1163 @findex Component_Alignment
1164 @noindent
1165 Syntax:
1166
1167 @smallexample @c ada
1168 pragma Component_Alignment (
1169      [Form =>] ALIGNMENT_CHOICE
1170   [, [Name =>] type_local_NAME]);
1171
1172 ALIGNMENT_CHOICE ::=
1173   Component_Size
1174 | Component_Size_4
1175 | Storage_Unit
1176 | Default
1177 @end smallexample
1178
1179 @noindent
1180 Specifies the alignment of components in array or record types.
1181 The meaning of the @var{Form} argument is as follows:
1182
1183 @table @code
1184 @findex Component_Size
1185 @item Component_Size
1186 Aligns scalar components and subcomponents of the array or record type
1187 on boundaries appropriate to their inherent size (naturally
1188 aligned).  For example, 1-byte components are aligned on byte boundaries,
1189 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1190 integer components are aligned on 4-byte boundaries and so on.  These
1191 alignment rules correspond to the normal rules for C compilers on all
1192 machines except the VAX@.
1193
1194 @findex Component_Size_4
1195 @item Component_Size_4
1196 Naturally aligns components with a size of four or fewer
1197 bytes.  Components that are larger than 4 bytes are placed on the next
1198 4-byte boundary.
1199
1200 @findex Storage_Unit
1201 @item Storage_Unit
1202 Specifies that array or record components are byte aligned, i.e.@:
1203 aligned on boundaries determined by the value of the constant
1204 @code{System.Storage_Unit}.
1205
1206 @cindex OpenVMS
1207 @item Default
1208 Specifies that array or record components are aligned on default
1209 boundaries, appropriate to the underlying hardware or operating system or
1210 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1211 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1212 the @code{Default} choice is the same as @code{Component_Size} (natural
1213 alignment).
1214 @end table
1215
1216 @noindent
1217 If the @code{Name} parameter is present, @var{type_local_NAME} must
1218 refer to a local record or array type, and the specified alignment
1219 choice applies to the specified type.  The use of
1220 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1221 @code{Component_Alignment} pragma to be ignored.  The use of
1222 @code{Component_Alignment} together with a record representation clause
1223 is only effective for fields not specified by the representation clause.
1224
1225 If the @code{Name} parameter is absent, the pragma can be used as either
1226 a configuration pragma, in which case it applies to one or more units in
1227 accordance with the normal rules for configuration pragmas, or it can be
1228 used within a declarative part, in which case it applies to types that
1229 are declared within this declarative part, or within any nested scope
1230 within this declarative part.  In either case it specifies the alignment
1231 to be applied to any record or array type which has otherwise standard
1232 representation.
1233
1234 If the alignment for a record or array type is not specified (using
1235 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1236 clause), the GNAT uses the default alignment as described previously.
1237
1238 @node Pragma Convention_Identifier
1239 @unnumberedsec Pragma Convention_Identifier
1240 @findex Convention_Identifier
1241 @cindex Conventions, synonyms
1242 @noindent
1243 Syntax:
1244
1245 @smallexample @c ada
1246 pragma Convention_Identifier (
1247          [Name =>]       IDENTIFIER,
1248          [Convention =>] convention_IDENTIFIER);
1249 @end smallexample
1250
1251 @noindent
1252 This pragma provides a mechanism for supplying synonyms for existing
1253 convention identifiers. The @code{Name} identifier can subsequently
1254 be used as a synonym for the given convention in other pragmas (including
1255 for example pragma @code{Import} or another @code{Convention_Identifier}
1256 pragma). As an example of the use of this, suppose you had legacy code
1257 which used Fortran77 as the identifier for Fortran. Then the pragma:
1258
1259 @smallexample @c ada
1260 pragma Convention_Identifier (Fortran77, Fortran);
1261 @end smallexample
1262
1263 @noindent
1264 would allow the use of the convention identifier @code{Fortran77} in
1265 subsequent code, avoiding the need to modify the sources. As another
1266 example, you could use this to parametrize convention requirements
1267 according to systems. Suppose you needed to use @code{Stdcall} on
1268 windows systems, and @code{C} on some other system, then you could
1269 define a convention identifier @code{Library} and use a single
1270 @code{Convention_Identifier} pragma to specify which convention
1271 would be used system-wide.
1272
1273 @node Pragma CPP_Class
1274 @unnumberedsec Pragma CPP_Class
1275 @findex CPP_Class
1276 @cindex Interfacing with C++
1277 @noindent
1278 Syntax:
1279
1280 @smallexample @c ada
1281 pragma CPP_Class ([Entity =>] local_NAME);
1282 @end smallexample
1283
1284 @noindent
1285 The argument denotes an entity in the current declarative region that is
1286 declared as a tagged record type. It indicates that the type corresponds
1287 to an externally declared C++ class type, and is to be laid out the same
1288 way that C++ would lay out the type.
1289
1290 Types for which @code{CPP_Class} is specified do not have assignment or
1291 equality operators defined (such operations can be imported or declared
1292 as subprograms as required). Initialization is allowed only by constructor
1293 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1294 limited if not explicitly declared as limited or derived from a limited
1295 type, and a warning is issued in that case.
1296
1297 Pragma @code{CPP_Class} is intended primarily for automatic generation
1298 using an automatic binding generator tool.
1299 See @ref{Interfacing to C++} for related information.
1300
1301 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1302 for backward compatibility but its functionality is available
1303 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1304
1305 @node Pragma CPP_Constructor
1306 @unnumberedsec Pragma CPP_Constructor
1307 @cindex Interfacing with C++
1308 @findex CPP_Constructor
1309 @noindent
1310 Syntax:
1311
1312 @smallexample @c ada
1313 pragma CPP_Constructor ([Entity =>] local_NAME
1314   [, [External_Name =>] static_string_EXPRESSION ]
1315   [, [Link_Name     =>] static_string_EXPRESSION ]);
1316 @end smallexample
1317
1318 @noindent
1319 This pragma identifies an imported function (imported in the usual way
1320 with pragma @code{Import}) as corresponding to a C++ constructor. If
1321 @code{External_Name} and @code{Link_Name} are not specified then the
1322 @code{Entity} argument is a name that must have been previously mentioned
1323 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1324 must be of one of the following forms:
1325
1326 @itemize @bullet
1327 @item
1328 @code{function @var{Fname} return @var{T}'Class}
1329
1330 @item
1331 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1332 @end itemize
1333
1334 @noindent
1335 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1336
1337 The first form is the default constructor, used when an object of type
1338 @var{T} is created on the Ada side with no explicit constructor.  Other
1339 constructors (including the copy constructor, which is simply a special
1340 case of the second form in which the one and only argument is of type
1341 @var{T}), can only appear in two contexts:
1342
1343 @itemize @bullet
1344 @item
1345 On the right side of an initialization of an object of type @var{T}.
1346 @item
1347 In an extension aggregate for an object of a type derived from @var{T}.
1348 @end itemize
1349
1350 @noindent
1351 Although the constructor is described as a function that returns a value
1352 on the Ada side, it is typically a procedure with an extra implicit
1353 argument (the object being initialized) at the implementation
1354 level.  GNAT issues the appropriate call, whatever it is, to get the
1355 object properly initialized.
1356
1357 In the case of derived objects, you may use one of two possible forms
1358 for declaring and creating an object:
1359
1360 @itemize @bullet
1361 @item @code{New_Object : Derived_T}
1362 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1363 @end itemize
1364
1365 @noindent
1366 In the first case the default constructor is called and extension fields
1367 if any are initialized according to the default initialization
1368 expressions in the Ada declaration.  In the second case, the given
1369 constructor is called and the extension aggregate indicates the explicit
1370 values of the extension fields.
1371
1372 If no constructors are imported, it is impossible to create any objects
1373 on the Ada side.  If no default constructor is imported, only the
1374 initialization forms using an explicit call to a constructor are
1375 permitted.
1376
1377 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1378 using an automatic binding generator tool.
1379 See @ref{Interfacing to C++} for more related information.
1380
1381 @node Pragma CPP_Virtual
1382 @unnumberedsec Pragma CPP_Virtual
1383 @cindex Interfacing to C++
1384 @findex CPP_Virtual
1385 @noindent
1386 This pragma is now obsolete has has no effect because GNAT generates
1387 the same object layout than the G++ compiler.
1388
1389 See @ref{Interfacing to C++} for related information.
1390
1391 @node Pragma CPP_Vtable
1392 @unnumberedsec Pragma CPP_Vtable
1393 @cindex Interfacing with C++
1394 @findex CPP_Vtable
1395 @noindent
1396 This pragma is now obsolete has has no effect because GNAT generates
1397 the same object layout than the G++ compiler.
1398
1399 See @ref{Interfacing to C++} for related information.
1400
1401 @node Pragma Debug
1402 @unnumberedsec Pragma Debug
1403 @findex Debug
1404 @noindent
1405 Syntax:
1406
1407 @smallexample @c ada
1408 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1409
1410 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1411   PROCEDURE_NAME
1412 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1413 @end smallexample
1414
1415 @noindent
1416 The procedure call argument has the syntactic form of an expression, meeting
1417 the syntactic requirements for pragmas.
1418
1419 If debug pragmas are not enabled or if the condition is present and evaluates
1420 to False, this pragma has no effect. If debug pragmas are enabled, the
1421 semantics of the pragma is exactly equivalent to the procedure call statement
1422 corresponding to the argument with a terminating semicolon. Pragmas are
1423 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1424 intersperse calls to debug procedures in the middle of declarations. Debug
1425 pragmas can be enabled either by use of the command line switch @code{-gnata}
1426 or by use of the configuration pragma @code{Debug_Policy}.
1427
1428 @node Pragma Debug_Policy
1429 @unnumberedsec Pragma Debug_Policy
1430 @findex Debug_Policy
1431 @noindent
1432 Syntax:
1433
1434 @smallexample @c ada
1435 pragma Debug_Policy (CHECK | IGNORE);
1436 @end smallexample
1437
1438 @noindent
1439 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1440 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1441 This pragma overrides the effect of the @code{-gnata} switch on the
1442 command line.
1443
1444 @node Pragma Detect_Blocking
1445 @unnumberedsec Pragma Detect_Blocking
1446 @findex Detect_Blocking
1447 @noindent
1448 Syntax:
1449
1450 @smallexample @c ada
1451 pragma Detect_Blocking;
1452 @end smallexample
1453
1454 @noindent
1455 This is a configuration pragma that forces the detection of potentially
1456 blocking operations within a protected operation, and to raise Program_Error
1457 if that happens.
1458
1459 @node Pragma Elaboration_Checks
1460 @unnumberedsec Pragma Elaboration_Checks
1461 @cindex Elaboration control
1462 @findex Elaboration_Checks
1463 @noindent
1464 Syntax:
1465
1466 @smallexample @c ada
1467 pragma Elaboration_Checks (Dynamic | Static);
1468 @end smallexample
1469
1470 @noindent
1471 This is a configuration pragma that provides control over the
1472 elaboration model used by the compilation affected by the
1473 pragma.  If the parameter is @code{Dynamic},
1474 then the dynamic elaboration
1475 model described in the Ada Reference Manual is used, as though
1476 the @code{-gnatE} switch had been specified on the command
1477 line.  If the parameter is @code{Static}, then the default GNAT static
1478 model is used.  This configuration pragma overrides the setting
1479 of the command line.  For full details on the elaboration models
1480 used by the GNAT compiler, see section ``Elaboration Order
1481 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1482
1483 @node Pragma Eliminate
1484 @unnumberedsec Pragma Eliminate
1485 @cindex Elimination of unused subprograms
1486 @findex Eliminate
1487 @noindent
1488 Syntax:
1489
1490 @smallexample @c ada
1491 pragma Eliminate (
1492     [Unit_Name =>] IDENTIFIER |
1493                    SELECTED_COMPONENT);
1494
1495 pragma Eliminate (
1496     [Unit_Name       =>]  IDENTIFIER |
1497                           SELECTED_COMPONENT,
1498     [Entity          =>]  IDENTIFIER |
1499                           SELECTED_COMPONENT |
1500                           STRING_LITERAL
1501     [,OVERLOADING_RESOLUTION]);
1502
1503 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1504                            SOURCE_LOCATION
1505
1506 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1507                                       FUNCTION_PROFILE
1508
1509 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1510
1511 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1512                       Result_Type => result_SUBTYPE_NAME]
1513
1514 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1515 SUBTYPE_NAME    ::= STRING_VALUE
1516
1517 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1518 SOURCE_TRACE    ::= STRING_VALUE
1519
1520 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1521 @end smallexample
1522
1523 @noindent
1524 This pragma indicates that the given entity is not used outside the
1525 compilation unit it is defined in. The entity must be an explicitly declared
1526 subprogram; this includes  generic subprogram instances and
1527 subprograms declared in generic package instances.
1528
1529 If the entity to be eliminated is a library level subprogram, then
1530 the first form of pragma @code{Eliminate} is used with only a single argument.
1531 In this form, the @code{Unit_Name} argument specifies the name of the
1532 library  level unit to be eliminated.
1533
1534 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1535 are required. If item is an entity of a library package, then the first
1536 argument specifies the unit name, and the second argument specifies
1537 the particular entity.  If the second argument is in string form, it must
1538 correspond to the internal manner in which GNAT stores entity names (see
1539 compilation unit Namet in the compiler sources for details).
1540
1541 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1542 to distinguish between overloaded subprograms. If a pragma does not contain
1543 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1544 subprograms denoted by the first two parameters.
1545
1546 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1547 to be eliminated in a manner similar to that used for the extended
1548 @code{Import} and @code{Export} pragmas, except that the subtype names are
1549 always given as strings. At the moment, this form of distinguishing
1550 overloaded subprograms is implemented only partially, so we do not recommend
1551 using it for practical subprogram elimination.
1552
1553 Note, that in case of a parameterless procedure its profile is represented
1554 as @code{Parameter_Types => ("")}
1555
1556 Alternatively, the @code{Source_Location} parameter is used to specify
1557 which overloaded alternative is to be eliminated by pointing to the
1558 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1559 source text. The string literal (or concatenation of string literals)
1560 given as SOURCE_TRACE must have the following format:
1561
1562 @smallexample @c ada
1563 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1564
1565 LBRACKET ::= [
1566 RBRACKET ::= ]
1567
1568 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1569 FILE_NAME       ::= STRING_LITERAL
1570 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1571 @end smallexample
1572
1573 SOURCE_TRACE should be the short name of the source file (with no directory
1574 information), and LINE_NUMBER is supposed to point to the line where the
1575 defining name of the subprogram is located.
1576
1577 For the subprograms that are not a part of generic instantiations, only one
1578 SOURCE_LOCATION is used. If a subprogram is declared in a package
1579 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1580 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1581 second one denotes the declaration of the corresponding subprogram in the
1582 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1583 in case of nested instantiations.
1584
1585 The effect of the pragma is to allow the compiler to eliminate
1586 the code or data associated with the named entity.  Any reference to
1587 an eliminated entity outside the compilation unit it is defined in,
1588 causes a compile time or link time error.
1589
1590 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1591 in a system independent manner, with unused entities eliminated, without
1592 the requirement of modifying the source text.  Normally the required set
1593 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1594 tool. Elimination of unused entities local to a compilation unit is
1595 automatic, without requiring the use of pragma @code{Eliminate}.
1596
1597 Note that the reason this pragma takes string literals where names might
1598 be expected is that a pragma @code{Eliminate} can appear in a context where the
1599 relevant names are not visible.
1600
1601 Note that any change in the source files that includes removing, splitting of
1602 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1603 parameter illegal.
1604
1605 @node Pragma Export_Exception
1606 @unnumberedsec Pragma Export_Exception
1607 @cindex OpenVMS
1608 @findex Export_Exception
1609 @noindent
1610 Syntax:
1611
1612 @smallexample @c ada
1613 pragma Export_Exception (
1614      [Internal =>] local_NAME,
1615   [, [External =>] EXTERNAL_SYMBOL,]
1616   [, [Form     =>] Ada | VMS]
1617   [, [Code     =>] static_integer_EXPRESSION]);
1618
1619 EXTERNAL_SYMBOL ::=
1620   IDENTIFIER
1621 | static_string_EXPRESSION
1622 @end smallexample
1623
1624 @noindent
1625 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1626 causes the specified exception to be propagated outside of the Ada program,
1627 so that it can be handled by programs written in other OpenVMS languages.
1628 This pragma establishes an external name for an Ada exception and makes the
1629 name available to the OpenVMS Linker as a global symbol.  For further details
1630 on this pragma, see the
1631 DEC Ada Language Reference Manual, section 13.9a3.2.
1632
1633 @node Pragma Export_Function
1634 @unnumberedsec Pragma Export_Function
1635 @cindex Argument passing mechanisms
1636 @findex Export_Function
1637
1638 @noindent
1639 Syntax:
1640
1641 @smallexample @c ada
1642 pragma Export_Function (
1643      [Internal         =>] local_NAME,
1644   [, [External         =>] EXTERNAL_SYMBOL]
1645   [, [Parameter_Types  =>] PARAMETER_TYPES]
1646   [, [Result_Type      =>] result_SUBTYPE_MARK]
1647   [, [Mechanism        =>] MECHANISM]
1648   [, [Result_Mechanism =>] MECHANISM_NAME]);
1649
1650 EXTERNAL_SYMBOL ::=
1651   IDENTIFIER
1652 | static_string_EXPRESSION
1653 | ""
1654
1655 PARAMETER_TYPES ::=
1656   null
1657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1658
1659 TYPE_DESIGNATOR ::=
1660   subtype_NAME
1661 | subtype_Name ' Access
1662
1663 MECHANISM ::=
1664   MECHANISM_NAME
1665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1666
1667 MECHANISM_ASSOCIATION ::=
1668   [formal_parameter_NAME =>] MECHANISM_NAME
1669
1670 MECHANISM_NAME ::=
1671   Value
1672 | Reference
1673 | Descriptor [([Class =>] CLASS_NAME)]
1674
1675 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1676 @end smallexample
1677
1678 @noindent
1679 Use this pragma to make a function externally callable and optionally
1680 provide information on mechanisms to be used for passing parameter and
1681 result values.  We recommend, for the purposes of improving portability,
1682 this pragma always be used in conjunction with a separate pragma
1683 @code{Export}, which must precede the pragma @code{Export_Function}.
1684 GNAT does not require a separate pragma @code{Export}, but if none is
1685 present, @code{Convention Ada} is assumed, which is usually
1686 not what is wanted, so it is usually appropriate to use this
1687 pragma in conjunction with a @code{Export} or @code{Convention}
1688 pragma that specifies the desired foreign convention.
1689 Pragma @code{Export_Function}
1690 (and @code{Export}, if present) must appear in the same declarative
1691 region as the function to which they apply.
1692
1693 @var{internal_name} must uniquely designate the function to which the
1694 pragma applies.  If more than one function name exists of this name in
1695 the declarative part you must use the @code{Parameter_Types} and
1696 @code{Result_Type} parameters is mandatory to achieve the required
1697 unique designation.  @var{subtype_ mark}s in these parameters must
1698 exactly match the subtypes in the corresponding function specification,
1699 using positional notation to match parameters with subtype marks.
1700 The form with an @code{'Access} attribute can be used to match an
1701 anonymous access parameter.
1702
1703 @cindex OpenVMS
1704 @cindex Passing by descriptor
1705 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1706
1707 @cindex Suppressing external name
1708 Special treatment is given if the EXTERNAL is an explicit null
1709 string or a static string expressions that evaluates to the null
1710 string. In this case, no external name is generated. This form
1711 still allows the specification of parameter mechanisms.
1712
1713 @node Pragma Export_Object
1714 @unnumberedsec Pragma Export_Object
1715 @findex Export_Object
1716 @noindent
1717 Syntax:
1718
1719 @smallexample @c ada
1720 pragma Export_Object
1721       [Internal =>] local_NAME,
1722    [, [External =>] EXTERNAL_SYMBOL]
1723    [, [Size     =>] EXTERNAL_SYMBOL]
1724
1725 EXTERNAL_SYMBOL ::=
1726   IDENTIFIER
1727 | static_string_EXPRESSION
1728 @end smallexample
1729
1730 @noindent
1731 This pragma designates an object as exported, and apart from the
1732 extended rules for external symbols, is identical in effect to the use of
1733 the normal @code{Export} pragma applied to an object.  You may use a
1734 separate Export pragma (and you probably should from the point of view
1735 of portability), but it is not required.  @var{Size} is syntax checked,
1736 but otherwise ignored by GNAT@.
1737
1738 @node Pragma Export_Procedure
1739 @unnumberedsec Pragma Export_Procedure
1740 @findex Export_Procedure
1741 @noindent
1742 Syntax:
1743
1744 @smallexample @c ada
1745 pragma Export_Procedure (
1746      [Internal        =>] local_NAME
1747   [, [External        =>] EXTERNAL_SYMBOL]
1748   [, [Parameter_Types =>] PARAMETER_TYPES]
1749   [, [Mechanism       =>] MECHANISM]);
1750
1751 EXTERNAL_SYMBOL ::=
1752   IDENTIFIER
1753 | static_string_EXPRESSION
1754 | ""
1755
1756 PARAMETER_TYPES ::=
1757   null
1758 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1759
1760 TYPE_DESIGNATOR ::=
1761   subtype_NAME
1762 | subtype_Name ' Access
1763
1764 MECHANISM ::=
1765   MECHANISM_NAME
1766 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1767
1768 MECHANISM_ASSOCIATION ::=
1769   [formal_parameter_NAME =>] MECHANISM_NAME
1770
1771 MECHANISM_NAME ::=
1772   Value
1773 | Reference
1774 | Descriptor [([Class =>] CLASS_NAME)]
1775
1776 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1777 @end smallexample
1778
1779 @noindent
1780 This pragma is identical to @code{Export_Function} except that it
1781 applies to a procedure rather than a function and the parameters
1782 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1783 GNAT does not require a separate pragma @code{Export}, but if none is
1784 present, @code{Convention Ada} is assumed, which is usually
1785 not what is wanted, so it is usually appropriate to use this
1786 pragma in conjunction with a @code{Export} or @code{Convention}
1787 pragma that specifies the desired foreign convention.
1788
1789 @cindex OpenVMS
1790 @cindex Passing by descriptor
1791 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1792
1793 @cindex Suppressing external name
1794 Special treatment is given if the EXTERNAL is an explicit null
1795 string or a static string expressions that evaluates to the null
1796 string. In this case, no external name is generated. This form
1797 still allows the specification of parameter mechanisms.
1798
1799 @node Pragma Export_Value
1800 @unnumberedsec Pragma Export_Value
1801 @findex Export_Value
1802 @noindent
1803 Syntax:
1804
1805 @smallexample @c ada
1806 pragma Export_Value (
1807   [Value     =>] static_integer_EXPRESSION,
1808   [Link_Name =>] static_string_EXPRESSION);
1809 @end smallexample
1810
1811 @noindent
1812 This pragma serves to export a static integer value for external use.
1813 The first argument specifies the value to be exported. The Link_Name
1814 argument specifies the symbolic name to be associated with the integer
1815 value. This pragma is useful for defining a named static value in Ada
1816 that can be referenced in assembly language units to be linked with
1817 the application. This pragma is currently supported only for the
1818 AAMP target and is ignored for other targets.
1819
1820 @node Pragma Export_Valued_Procedure
1821 @unnumberedsec Pragma Export_Valued_Procedure
1822 @findex Export_Valued_Procedure
1823 @noindent
1824 Syntax:
1825
1826 @smallexample @c ada
1827 pragma Export_Valued_Procedure (
1828      [Internal        =>] local_NAME
1829   [, [External        =>] EXTERNAL_SYMBOL]
1830   [, [Parameter_Types =>] PARAMETER_TYPES]
1831   [, [Mechanism       =>] MECHANISM]);
1832
1833 EXTERNAL_SYMBOL ::=
1834   IDENTIFIER
1835 | static_string_EXPRESSION
1836 | ""
1837
1838 PARAMETER_TYPES ::=
1839   null
1840 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1841
1842 TYPE_DESIGNATOR ::=
1843   subtype_NAME
1844 | subtype_Name ' Access
1845
1846 MECHANISM ::=
1847   MECHANISM_NAME
1848 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1849
1850 MECHANISM_ASSOCIATION ::=
1851   [formal_parameter_NAME =>] MECHANISM_NAME
1852
1853 MECHANISM_NAME ::=
1854   Value
1855 | Reference
1856 | Descriptor [([Class =>] CLASS_NAME)]
1857
1858 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1859 @end smallexample
1860
1861 @noindent
1862 This pragma is identical to @code{Export_Procedure} except that the
1863 first parameter of @var{local_NAME}, which must be present, must be of
1864 mode @code{OUT}, and externally the subprogram is treated as a function
1865 with this parameter as the result of the function.  GNAT provides for
1866 this capability to allow the use of @code{OUT} and @code{IN OUT}
1867 parameters in interfacing to external functions (which are not permitted
1868 in Ada functions).
1869 GNAT does not require a separate pragma @code{Export}, but if none is
1870 present, @code{Convention Ada} is assumed, which is almost certainly
1871 not what is wanted since the whole point of this pragma is to interface
1872 with foreign language functions, so it is usually appropriate to use this
1873 pragma in conjunction with a @code{Export} or @code{Convention}
1874 pragma that specifies the desired foreign convention.
1875
1876 @cindex OpenVMS
1877 @cindex Passing by descriptor
1878 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1879
1880 @cindex Suppressing external name
1881 Special treatment is given if the EXTERNAL is an explicit null
1882 string or a static string expressions that evaluates to the null
1883 string. In this case, no external name is generated. This form
1884 still allows the specification of parameter mechanisms.
1885
1886 @node Pragma Extend_System
1887 @unnumberedsec Pragma Extend_System
1888 @cindex @code{system}, extending
1889 @cindex Dec Ada 83
1890 @findex Extend_System
1891 @noindent
1892 Syntax:
1893
1894 @smallexample @c ada
1895 pragma Extend_System ([Name =>] IDENTIFIER);
1896 @end smallexample
1897
1898 @noindent
1899 This pragma is used to provide backwards compatibility with other
1900 implementations that extend the facilities of package @code{System}.  In
1901 GNAT, @code{System} contains only the definitions that are present in
1902 the Ada RM@.  However, other implementations, notably the DEC Ada 83
1903 implementation, provide many extensions to package @code{System}.
1904
1905 For each such implementation accommodated by this pragma, GNAT provides a
1906 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1907 implementation, which provides the required additional definitions.  You
1908 can use this package in two ways.  You can @code{with} it in the normal
1909 way and access entities either by selection or using a @code{use}
1910 clause.  In this case no special processing is required.
1911
1912 However, if existing code contains references such as
1913 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1914 definitions provided in package @code{System}, you may use this pragma
1915 to extend visibility in @code{System} in a non-standard way that
1916 provides greater compatibility with the existing code.  Pragma
1917 @code{Extend_System} is a configuration pragma whose single argument is
1918 the name of the package containing the extended definition
1919 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1920 control of this pragma will be processed using special visibility
1921 processing that looks in package @code{System.Aux_@var{xxx}} where
1922 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1923 package @code{System}, but not found in package @code{System}.
1924
1925 You can use this pragma either to access a predefined @code{System}
1926 extension supplied with the compiler, for example @code{Aux_DEC} or
1927 you can construct your own extension unit following the above
1928 definition.  Note that such a package is a child of @code{System}
1929 and thus is considered part of the implementation.  To compile
1930 it you will have to use the appropriate switch for compiling
1931 system units.  See the GNAT User's Guide for details.
1932
1933 @node Pragma External
1934 @unnumberedsec Pragma External
1935 @findex External
1936 @noindent
1937 Syntax:
1938
1939 @smallexample @c ada
1940 pragma External (
1941   [   Convention    =>] convention_IDENTIFIER,
1942   [   Entity        =>] local_NAME
1943   [, [External_Name =>] static_string_EXPRESSION ]
1944   [, [Link_Name     =>] static_string_EXPRESSION ]);
1945 @end smallexample
1946
1947 @noindent
1948 This pragma is identical in syntax and semantics to pragma
1949 @code{Export} as defined in the Ada Reference Manual.  It is
1950 provided for compatibility with some Ada 83 compilers that
1951 used this pragma for exactly the same purposes as pragma
1952 @code{Export} before the latter was standardized.
1953
1954 @node Pragma External_Name_Casing
1955 @unnumberedsec Pragma External_Name_Casing
1956 @cindex Dec Ada 83 casing compatibility
1957 @cindex External Names, casing
1958 @cindex Casing of External names
1959 @findex External_Name_Casing
1960 @noindent
1961 Syntax:
1962
1963 @smallexample @c ada
1964 pragma External_Name_Casing (
1965   Uppercase | Lowercase
1966   [, Uppercase | Lowercase | As_Is]);
1967 @end smallexample
1968
1969 @noindent
1970 This pragma provides control over the casing of external names associated
1971 with Import and Export pragmas.  There are two cases to consider:
1972
1973 @table @asis
1974 @item Implicit external names
1975 Implicit external names are derived from identifiers.  The most common case
1976 arises when a standard Ada Import or Export pragma is used with only two
1977 arguments, as in:
1978
1979 @smallexample @c ada
1980    pragma Import (C, C_Routine);
1981 @end smallexample
1982
1983 @noindent
1984 Since Ada is a case-insensitive language, the spelling of the identifier in
1985 the Ada source program does not provide any information on the desired
1986 casing of the external name, and so a convention is needed.  In GNAT the
1987 default treatment is that such names are converted to all lower case
1988 letters.  This corresponds to the normal C style in many environments.
1989 The first argument of pragma @code{External_Name_Casing} can be used to
1990 control this treatment.  If @code{Uppercase} is specified, then the name
1991 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1992 then the normal default of all lower case letters will be used.
1993
1994 This same implicit treatment is also used in the case of extended DEC Ada 83
1995 compatible Import and Export pragmas where an external name is explicitly
1996 specified using an identifier rather than a string.
1997
1998 @item Explicit external names
1999 Explicit external names are given as string literals.  The most common case
2000 arises when a standard Ada Import or Export pragma is used with three
2001 arguments, as in:
2002
2003 @smallexample @c ada
2004 pragma Import (C, C_Routine, "C_routine");
2005 @end smallexample
2006
2007 @noindent
2008 In this case, the string literal normally provides the exact casing required
2009 for the external name.  The second argument of pragma
2010 @code{External_Name_Casing} may be used to modify this behavior.
2011 If @code{Uppercase} is specified, then the name
2012 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2013 then the name will be forced to all lowercase letters.  A specification of
2014 @code{As_Is} provides the normal default behavior in which the casing is
2015 taken from the string provided.
2016 @end table
2017
2018 @noindent
2019 This pragma may appear anywhere that a pragma is valid.  In particular, it
2020 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2021 case it applies to all subsequent compilations, or it can be used as a program
2022 unit pragma, in which case it only applies to the current unit, or it can
2023 be used more locally to control individual Import/Export pragmas.
2024
2025 It is primarily intended for use with OpenVMS systems, where many
2026 compilers convert all symbols to upper case by default.  For interfacing to
2027 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2028 the pragma:
2029
2030 @smallexample @c ada
2031 pragma External_Name_Casing (Uppercase, Uppercase);
2032 @end smallexample
2033
2034 @noindent
2035 to enforce the upper casing of all external symbols.
2036
2037 @node Pragma Finalize_Storage_Only
2038 @unnumberedsec Pragma Finalize_Storage_Only
2039 @findex Finalize_Storage_Only
2040 @noindent
2041 Syntax:
2042
2043 @smallexample @c ada
2044 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2045 @end smallexample
2046
2047 @noindent
2048 This pragma allows the compiler not to emit a Finalize call for objects
2049 defined at the library level.  This is mostly useful for types where
2050 finalization is only used to deal with storage reclamation since in most
2051 environments it is not necessary to reclaim memory just before terminating
2052 execution, hence the name.
2053
2054 @node Pragma Float_Representation
2055 @unnumberedsec Pragma Float_Representation
2056 @cindex OpenVMS
2057 @findex Float_Representation
2058 @noindent
2059 Syntax:
2060
2061 @smallexample @c ada
2062 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2063
2064 FLOAT_REP ::= VAX_Float | IEEE_Float
2065 @end smallexample
2066
2067 @noindent
2068 In the one argument form, this pragma is a configuration pragma which
2069 allows control over the internal representation chosen for the predefined
2070 floating point types declared in the packages @code{Standard} and
2071 @code{System}. On all systems other than OpenVMS, the argument must
2072 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2073 argument may be @code{VAX_Float} to specify the use of the VAX float
2074 format for the floating-point types in Standard. This requires that
2075 the standard runtime libraries be recompiled. See the
2076 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2077 of the GNAT Users Guide for details on the use of this command.
2078
2079 The two argument form specifies the representation to be used for
2080 the specified floating-point type. On all systems other than OpenVMS,
2081 the argument must
2082 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2083 argument may be @code{VAX_Float} to specify the use of the VAX float
2084 format, as follows:
2085
2086 @itemize @bullet
2087 @item
2088 For digits values up to 6, F float format will be used.
2089 @item
2090 For digits values from 7 to 9, G float format will be used.
2091 @item
2092 For digits values from 10 to 15, F float format will be used.
2093 @item
2094 Digits values above 15 are not allowed.
2095 @end itemize
2096
2097 @node Pragma Ident
2098 @unnumberedsec Pragma Ident
2099 @findex Ident
2100 @noindent
2101 Syntax:
2102
2103 @smallexample @c ada
2104 pragma Ident (static_string_EXPRESSION);
2105 @end smallexample
2106
2107 @noindent
2108 This pragma provides a string identification in the generated object file,
2109 if the system supports the concept of this kind of identification string.
2110 This pragma is allowed only in the outermost declarative part or
2111 declarative items of a compilation unit. If more than one @code{Ident}
2112 pragma is given, only the last one processed is effective.
2113 @cindex OpenVMS
2114 On OpenVMS systems, the effect of the pragma is identical to the effect of
2115 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2116 maximum allowed length is 31 characters, so if it is important to
2117 maintain compatibility with this compiler, you should obey this length
2118 limit.
2119
2120 @node Pragma Import_Exception
2121 @unnumberedsec Pragma Import_Exception
2122 @cindex OpenVMS
2123 @findex Import_Exception
2124 @noindent
2125 Syntax:
2126
2127 @smallexample @c ada
2128 pragma Import_Exception (
2129      [Internal =>] local_NAME,
2130   [, [External =>] EXTERNAL_SYMBOL,]
2131   [, [Form     =>] Ada | VMS]
2132   [, [Code     =>] static_integer_EXPRESSION]);
2133
2134 EXTERNAL_SYMBOL ::=
2135   IDENTIFIER
2136 | static_string_EXPRESSION
2137 @end smallexample
2138
2139 @noindent
2140 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2141 It allows OpenVMS conditions (for example, from OpenVMS system services or
2142 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2143 The pragma specifies that the exception associated with an exception
2144 declaration in an Ada program be defined externally (in non-Ada code).
2145 For further details on this pragma, see the
2146 DEC Ada Language Reference Manual, section 13.9a.3.1.
2147
2148 @node Pragma Import_Function
2149 @unnumberedsec Pragma Import_Function
2150 @findex Import_Function
2151 @noindent
2152 Syntax:
2153
2154 @smallexample @c ada
2155 pragma Import_Function (
2156      [Internal                 =>] local_NAME,
2157   [, [External                 =>] EXTERNAL_SYMBOL]
2158   [, [Parameter_Types          =>] PARAMETER_TYPES]
2159   [, [Result_Type              =>] SUBTYPE_MARK]
2160   [, [Mechanism                =>] MECHANISM]
2161   [, [Result_Mechanism         =>] MECHANISM_NAME]
2162   [, [First_Optional_Parameter =>] IDENTIFIER]);
2163
2164 EXTERNAL_SYMBOL ::=
2165   IDENTIFIER
2166 | static_string_EXPRESSION
2167
2168 PARAMETER_TYPES ::=
2169   null
2170 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2171
2172 TYPE_DESIGNATOR ::=
2173   subtype_NAME
2174 | subtype_Name ' Access
2175
2176 MECHANISM ::=
2177   MECHANISM_NAME
2178 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2179
2180 MECHANISM_ASSOCIATION ::=
2181   [formal_parameter_NAME =>] MECHANISM_NAME
2182
2183 MECHANISM_NAME ::=
2184   Value
2185 | Reference
2186 | Descriptor [([Class =>] CLASS_NAME)]
2187
2188 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2189 @end smallexample
2190
2191 @noindent
2192 This pragma is used in conjunction with a pragma @code{Import} to
2193 specify additional information for an imported function.  The pragma
2194 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2195 @code{Import_Function} pragma and both must appear in the same
2196 declarative part as the function specification.
2197
2198 The @var{Internal} argument must uniquely designate
2199 the function to which the
2200 pragma applies.  If more than one function name exists of this name in
2201 the declarative part you must use the @code{Parameter_Types} and
2202 @var{Result_Type} parameters to achieve the required unique
2203 designation.  Subtype marks in these parameters must exactly match the
2204 subtypes in the corresponding function specification, using positional
2205 notation to match parameters with subtype marks.
2206 The form with an @code{'Access} attribute can be used to match an
2207 anonymous access parameter.
2208
2209 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2210 parameters to specify passing mechanisms for the
2211 parameters and result.  If you specify a single mechanism name, it
2212 applies to all parameters.  Otherwise you may specify a mechanism on a
2213 parameter by parameter basis using either positional or named
2214 notation.  If the mechanism is not specified, the default mechanism
2215 is used.
2216
2217 @cindex OpenVMS
2218 @cindex Passing by descriptor
2219 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2220
2221 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2222 It specifies that the designated parameter and all following parameters
2223 are optional, meaning that they are not passed at the generated code
2224 level (this is distinct from the notion of optional parameters in Ada
2225 where the parameters are passed anyway with the designated optional
2226 parameters).  All optional parameters must be of mode @code{IN} and have
2227 default parameter values that are either known at compile time
2228 expressions, or uses of the @code{'Null_Parameter} attribute.
2229
2230 @node Pragma Import_Object
2231 @unnumberedsec Pragma Import_Object
2232 @findex Import_Object
2233 @noindent
2234 Syntax:
2235
2236 @smallexample @c ada
2237 pragma Import_Object
2238      [Internal =>] local_NAME,
2239   [, [External =>] EXTERNAL_SYMBOL],
2240   [, [Size     =>] EXTERNAL_SYMBOL]);
2241
2242 EXTERNAL_SYMBOL ::=
2243   IDENTIFIER
2244 | static_string_EXPRESSION
2245 @end smallexample
2246
2247 @noindent
2248 This pragma designates an object as imported, and apart from the
2249 extended rules for external symbols, is identical in effect to the use of
2250 the normal @code{Import} pragma applied to an object.  Unlike the
2251 subprogram case, you need not use a separate @code{Import} pragma,
2252 although you may do so (and probably should do so from a portability
2253 point of view).  @var{size} is syntax checked, but otherwise ignored by
2254 GNAT@.
2255
2256 @node Pragma Import_Procedure
2257 @unnumberedsec Pragma Import_Procedure
2258 @findex Import_Procedure
2259 @noindent
2260 Syntax:
2261
2262 @smallexample @c ada
2263 pragma Import_Procedure (
2264      [Internal                 =>] local_NAME,
2265   [, [External                 =>] EXTERNAL_SYMBOL]
2266   [, [Parameter_Types          =>] PARAMETER_TYPES]
2267   [, [Mechanism                =>] MECHANISM]
2268   [, [First_Optional_Parameter =>] IDENTIFIER]);
2269
2270 EXTERNAL_SYMBOL ::=
2271   IDENTIFIER
2272 | static_string_EXPRESSION
2273
2274 PARAMETER_TYPES ::=
2275   null
2276 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2277
2278 TYPE_DESIGNATOR ::=
2279   subtype_NAME
2280 | subtype_Name ' Access
2281
2282 MECHANISM ::=
2283   MECHANISM_NAME
2284 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2285
2286 MECHANISM_ASSOCIATION ::=
2287   [formal_parameter_NAME =>] MECHANISM_NAME
2288
2289 MECHANISM_NAME ::=
2290   Value
2291 | Reference
2292 | Descriptor [([Class =>] CLASS_NAME)]
2293
2294 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2295 @end smallexample
2296
2297 @noindent
2298 This pragma is identical to @code{Import_Function} except that it
2299 applies to a procedure rather than a function and the parameters
2300 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2301
2302 @node Pragma Import_Valued_Procedure
2303 @unnumberedsec Pragma Import_Valued_Procedure
2304 @findex Import_Valued_Procedure
2305 @noindent
2306 Syntax:
2307
2308 @smallexample @c ada
2309 pragma Import_Valued_Procedure (
2310      [Internal                 =>] local_NAME,
2311   [, [External                 =>] EXTERNAL_SYMBOL]
2312   [, [Parameter_Types          =>] PARAMETER_TYPES]
2313   [, [Mechanism                =>] MECHANISM]
2314   [, [First_Optional_Parameter =>] IDENTIFIER]);
2315
2316 EXTERNAL_SYMBOL ::=
2317   IDENTIFIER
2318 | static_string_EXPRESSION
2319
2320 PARAMETER_TYPES ::=
2321   null
2322 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2323
2324 TYPE_DESIGNATOR ::=
2325   subtype_NAME
2326 | subtype_Name ' Access
2327
2328 MECHANISM ::=
2329   MECHANISM_NAME
2330 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2331
2332 MECHANISM_ASSOCIATION ::=
2333   [formal_parameter_NAME =>] MECHANISM_NAME
2334
2335 MECHANISM_NAME ::=
2336   Value
2337 | Reference
2338 | Descriptor [([Class =>] CLASS_NAME)]
2339
2340 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2341 @end smallexample
2342
2343 @noindent
2344 This pragma is identical to @code{Import_Procedure} except that the
2345 first parameter of @var{local_NAME}, which must be present, must be of
2346 mode @code{OUT}, and externally the subprogram is treated as a function
2347 with this parameter as the result of the function.  The purpose of this
2348 capability is to allow the use of @code{OUT} and @code{IN OUT}
2349 parameters in interfacing to external functions (which are not permitted
2350 in Ada functions).  You may optionally use the @code{Mechanism}
2351 parameters to specify passing mechanisms for the parameters.
2352 If you specify a single mechanism name, it applies to all parameters.
2353 Otherwise you may specify a mechanism on a parameter by parameter
2354 basis using either positional or named notation.  If the mechanism is not
2355 specified, the default mechanism is used.
2356
2357 Note that it is important to use this pragma in conjunction with a separate
2358 pragma Import that specifies the desired convention, since otherwise the
2359 default convention is Ada, which is almost certainly not what is required.
2360
2361 @node Pragma Initialize_Scalars
2362 @unnumberedsec Pragma Initialize_Scalars
2363 @findex Initialize_Scalars
2364 @cindex debugging with Initialize_Scalars
2365 @noindent
2366 Syntax:
2367
2368 @smallexample @c ada
2369 pragma Initialize_Scalars;
2370 @end smallexample
2371
2372 @noindent
2373 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2374 two important differences.  First, there is no requirement for the pragma
2375 to be used uniformly in all units of a partition, in particular, it is fine
2376 to use this just for some or all of the application units of a partition,
2377 without needing to recompile the run-time library.
2378
2379 In the case where some units are compiled with the pragma, and some without,
2380 then a declaration of a variable where the type is defined in package
2381 Standard or is locally declared will always be subject to initialization,
2382 as will any declaration of a scalar variable.  For composite variables,
2383 whether the variable is initialized may also depend on whether the package
2384 in which the type of the variable is declared is compiled with the pragma.
2385
2386 The other important difference is that you can control the value used
2387 for initializing scalar objects.  At bind time, you can select several
2388 options for initialization. You can
2389 initialize with invalid values (similar to Normalize_Scalars, though for
2390 Initialize_Scalars it is not always possible to determine the invalid
2391 values in complex cases like signed component fields with non-standard
2392 sizes). You can also initialize with high or
2393 low values, or with a specified bit pattern.  See the users guide for binder
2394 options for specifying these cases.
2395
2396 This means that you can compile a program, and then without having to
2397 recompile the program, you can run it with different values being used
2398 for initializing otherwise uninitialized values, to test if your program
2399 behavior depends on the choice.  Of course the behavior should not change,
2400 and if it does, then most likely you have an erroneous reference to an
2401 uninitialized value.
2402
2403 It is even possible to change the value at execution time eliminating even
2404 the need to rebind with a different switch using an environment variable.
2405 See the GNAT users guide for details.
2406
2407 Note that pragma @code{Initialize_Scalars} is particularly useful in
2408 conjunction with the enhanced validity checking that is now provided
2409 in GNAT, which checks for invalid values under more conditions.
2410 Using this feature (see description of the @code{-gnatV} flag in the
2411 users guide) in conjunction with pragma @code{Initialize_Scalars}
2412 provides a powerful new tool to assist in the detection of problems
2413 caused by uninitialized variables.
2414
2415 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2416 effect on the generated code. This may cause your code to be
2417 substantially larger. It may also cause an increase in the amount
2418 of stack required, so it is probably a good idea to turn on stack
2419 checking (see description of stack checking in the GNAT users guide)
2420 when using this pragma.
2421
2422 @node Pragma Inline_Always
2423 @unnumberedsec Pragma Inline_Always
2424 @findex Inline_Always
2425 @noindent
2426 Syntax:
2427
2428 @smallexample @c ada
2429 pragma Inline_Always (NAME [, NAME]);
2430 @end smallexample
2431
2432 @noindent
2433 Similar to pragma @code{Inline} except that inlining is not subject to
2434 the use of option @code{-gnatn} and the inlining happens regardless of
2435 whether this option is used.
2436
2437 @node Pragma Inline_Generic
2438 @unnumberedsec Pragma Inline_Generic
2439 @findex Inline_Generic
2440 @noindent
2441 Syntax:
2442
2443 @smallexample @c ada
2444 pragma Inline_Generic (generic_package_NAME);
2445 @end smallexample
2446
2447 @noindent
2448 This is implemented for compatibility with DEC Ada 83 and is recognized,
2449 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2450 by default when using GNAT@.
2451
2452 @node Pragma Interface
2453 @unnumberedsec Pragma Interface
2454 @findex Interface
2455 @noindent
2456 Syntax:
2457
2458 @smallexample @c ada
2459 pragma Interface (
2460      [Convention    =>] convention_identifier,
2461      [Entity =>] local_NAME
2462   [, [External_Name =>] static_string_expression],
2463   [, [Link_Name     =>] static_string_expression]);
2464 @end smallexample
2465
2466 @noindent
2467 This pragma is identical in syntax and semantics to
2468 the standard Ada pragma @code{Import}.  It is provided for compatibility
2469 with Ada 83.  The definition is upwards compatible both with pragma
2470 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2471 with some extended implementations of this pragma in certain Ada 83
2472 implementations.
2473
2474 @node Pragma Interface_Name
2475 @unnumberedsec Pragma Interface_Name
2476 @findex Interface_Name
2477 @noindent
2478 Syntax:
2479
2480 @smallexample @c ada
2481 pragma Interface_Name (
2482      [Entity        =>] local_NAME
2483   [, [External_Name =>] static_string_EXPRESSION]
2484   [, [Link_Name     =>] static_string_EXPRESSION]);
2485 @end smallexample
2486
2487 @noindent
2488 This pragma provides an alternative way of specifying the interface name
2489 for an interfaced subprogram, and is provided for compatibility with Ada
2490 83 compilers that use the pragma for this purpose.  You must provide at
2491 least one of @var{External_Name} or @var{Link_Name}.
2492
2493 @node Pragma Interrupt_Handler
2494 @unnumberedsec Pragma Interrupt_Handler
2495 @findex Interrupt_Handler
2496 @noindent
2497 Syntax:
2498
2499 @smallexample @c ada
2500 pragma Interrupt_Handler (procedure_local_NAME);
2501 @end smallexample
2502
2503 @noindent
2504 This program unit pragma is supported for parameterless protected procedures
2505 as described in Annex C of the Ada Reference Manual. On the AAMP target
2506 the pragma can also be specified for nonprotected parameterless procedures
2507 that are declared at the library level (which includes procedures
2508 declared at the top level of a library package). In the case of AAMP,
2509 when this pragma is applied to a nonprotected procedure, the instruction
2510 @code{IERET} is generated for returns from the procedure, enabling
2511 maskable interrupts, in place of the normal return instruction.
2512
2513 @node Pragma Interrupt_State
2514 @unnumberedsec Pragma Interrupt_State
2515 @findex Interrupt_State
2516 @noindent
2517 Syntax:
2518
2519 @smallexample @c ada
2520 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2521 @end smallexample
2522
2523 @noindent
2524 Normally certain interrupts are reserved to the implementation.  Any attempt
2525 to attach an interrupt causes Program_Error to be raised, as described in
2526 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2527 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2528 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2529 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2530 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2531 Ada exceptions, or used to implement run-time functions such as the
2532 @code{abort} statement and stack overflow checking.
2533
2534 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2535 such uses of interrupts.  It subsumes the functionality of pragma
2536 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2537 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2538 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2539 and may be used to mark interrupts required by the board support package
2540 as reserved.
2541
2542 Interrupts can be in one of three states:
2543 @itemize @bullet
2544 @item System
2545
2546 The interrupt is reserved (no Ada handler can be installed), and the
2547 Ada run-time may not install a handler. As a result you are guaranteed
2548 standard system default action if this interrupt is raised.
2549
2550 @item Runtime
2551
2552 The interrupt is reserved (no Ada handler can be installed). The run time
2553 is allowed to install a handler for internal control purposes, but is
2554 not required to do so.
2555
2556 @item User
2557
2558 The interrupt is unreserved.  The user may install a handler to provide
2559 some other action.
2560 @end itemize
2561
2562 @noindent
2563 These states are the allowed values of the @code{State} parameter of the
2564 pragma.  The @code{Name} parameter is a value of the type
2565 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2566 @code{Ada.Interrupts.Names}.
2567
2568 This is a configuration pragma, and the binder will check that there
2569 are no inconsistencies between different units in a partition in how a
2570 given interrupt is specified. It may appear anywhere a pragma is legal.
2571
2572 The effect is to move the interrupt to the specified state.
2573
2574 By declaring interrupts to be SYSTEM, you guarantee the standard system
2575 action, such as a core dump.
2576
2577 By declaring interrupts to be USER, you guarantee that you can install
2578 a handler.
2579
2580 Note that certain signals on many operating systems cannot be caught and
2581 handled by applications.  In such cases, the pragma is ignored.  See the
2582 operating system documentation, or the value of the array @code{Reserved}
2583 declared in the specification of package @code{System.OS_Interface}.
2584
2585 Overriding the default state of signals used by the Ada runtime may interfere
2586 with an application's runtime behavior in the cases of the synchronous signals,
2587 and in the case of the signal used to implement the @code{abort} statement.
2588
2589 @node Pragma Keep_Names
2590 @unnumberedsec Pragma Keep_Names
2591 @findex Keep_Names
2592 @noindent
2593 Syntax:
2594
2595 @smallexample @c ada
2596 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2597 @end smallexample
2598
2599 @noindent
2600 The @var{local_NAME} argument
2601 must refer to an enumeration first subtype
2602 in the current declarative part. The effect is to retain the enumeration
2603 literal names for use by @code{Image} and @code{Value} even if a global
2604 @code{Discard_Names} pragma applies. This is useful when you want to
2605 generally suppress enumeration literal names and for example you therefore
2606 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2607 want to retain the names for specific enumeration types.
2608
2609 @node Pragma License
2610 @unnumberedsec Pragma License
2611 @findex License
2612 @cindex License checking
2613 @noindent
2614 Syntax:
2615
2616 @smallexample @c ada
2617 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2618 @end smallexample
2619
2620 @noindent
2621 This pragma is provided to allow automated checking for appropriate license
2622 conditions with respect to the standard and modified GPL@.  A pragma
2623 @code{License}, which is a configuration pragma that typically appears at
2624 the start of a source file or in a separate @file{gnat.adc} file, specifies
2625 the licensing conditions of a unit as follows:
2626
2627 @itemize @bullet
2628 @item Unrestricted
2629 This is used for a unit that can be freely used with no license restrictions.
2630 Examples of such units are public domain units, and units from the Ada
2631 Reference Manual.
2632
2633 @item GPL
2634 This is used for a unit that is licensed under the unmodified GPL, and which
2635 therefore cannot be @code{with}'ed by a restricted unit.
2636
2637 @item Modified_GPL
2638 This is used for a unit licensed under the GNAT modified GPL that includes
2639 a special exception paragraph that specifically permits the inclusion of
2640 the unit in programs without requiring the entire program to be released
2641 under the GPL@.
2642
2643 @item Restricted
2644 This is used for a unit that is restricted in that it is not permitted to
2645 depend on units that are licensed under the GPL@.  Typical examples are
2646 proprietary code that is to be released under more restrictive license
2647 conditions.  Note that restricted units are permitted to @code{with} units
2648 which are licensed under the modified GPL (this is the whole point of the
2649 modified GPL).
2650
2651 @end itemize
2652
2653 @noindent
2654 Normally a unit with no @code{License} pragma is considered to have an
2655 unknown license, and no checking is done.  However, standard GNAT headers
2656 are recognized, and license information is derived from them as follows.
2657
2658 @itemize @bullet
2659
2660 A GNAT license header starts with a line containing 78 hyphens.  The following
2661 comment text is searched for the appearance of any of the following strings.
2662
2663 If the string ``GNU General Public License'' is found, then the unit is assumed
2664 to have GPL license, unless the string ``As a special exception'' follows, in
2665 which case the license is assumed to be modified GPL@.
2666
2667 If one of the strings
2668 ``This specification is adapted from the Ada Semantic Interface'' or
2669 ``This specification is derived from the Ada Reference Manual'' is found
2670 then the unit is assumed to be unrestricted.
2671 @end itemize
2672
2673 @noindent
2674 These default actions means that a program with a restricted license pragma
2675 will automatically get warnings if a GPL unit is inappropriately
2676 @code{with}'ed.  For example, the program:
2677
2678 @smallexample @c ada
2679 with Sem_Ch3;
2680 with GNAT.Sockets;
2681 procedure Secret_Stuff is
2682   @dots{}
2683 end Secret_Stuff
2684 @end smallexample
2685
2686 @noindent
2687 if compiled with pragma @code{License} (@code{Restricted}) in a
2688 @file{gnat.adc} file will generate the warning:
2689
2690 @smallexample
2691 1.  with Sem_Ch3;
2692         |
2693    >>> license of withed unit "Sem_Ch3" is incompatible
2694
2695 2.  with GNAT.Sockets;
2696 3.  procedure Secret_Stuff is
2697 @end smallexample
2698
2699 @noindent
2700 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2701 compiler and is licensed under the
2702 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2703 run time, and is therefore licensed under the modified GPL@.
2704
2705 @node Pragma Link_With
2706 @unnumberedsec Pragma Link_With
2707 @findex Link_With
2708 @noindent
2709 Syntax:
2710
2711 @smallexample @c ada
2712 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2713 @end smallexample
2714
2715 @noindent
2716 This pragma is provided for compatibility with certain Ada 83 compilers.
2717 It has exactly the same effect as pragma @code{Linker_Options} except
2718 that spaces occurring within one of the string expressions are treated
2719 as separators. For example, in the following case:
2720
2721 @smallexample @c ada
2722 pragma Link_With ("-labc -ldef");
2723 @end smallexample
2724
2725 @noindent
2726 results in passing the strings @code{-labc} and @code{-ldef} as two
2727 separate arguments to the linker. In addition pragma Link_With allows
2728 multiple arguments, with the same effect as successive pragmas.
2729
2730 @node Pragma Linker_Alias
2731 @unnumberedsec Pragma Linker_Alias
2732 @findex Linker_Alias
2733 @noindent
2734 Syntax:
2735
2736 @smallexample @c ada
2737 pragma Linker_Alias (
2738   [Entity =>] local_NAME
2739   [Target =>] static_string_EXPRESSION);
2740 @end smallexample
2741
2742 @noindent
2743 @var{local_NAME} must refer to an object that is declared at the library
2744 level. This pragma establishes the given entity as a linker alias for the
2745 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2746 and causes @var{local_NAME} to be emitted as an alias for the symbol
2747 @var{static_string_EXPRESSION} in the object file, that is to say no space
2748 is reserved for @var{local_NAME} by the assembler and it will be resolved
2749 to the same address as @var{static_string_EXPRESSION} by the linker.
2750
2751 The actual linker name for the target must be used (e.g. the fully
2752 encoded name with qualification in Ada, or the mangled name in C++),
2753 or it must be declared using the C convention with @code{pragma Import}
2754 or @code{pragma Export}.
2755
2756 Not all target machines support this pragma. On some of them it is accepted
2757 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2758
2759 @smallexample @c ada
2760 --  Example of the use of pragma Linker_Alias
2761
2762 package p is
2763   i : Integer := 1;
2764   pragma Export (C, i);
2765
2766   new_name_for_i : Integer;
2767   pragma Linker_Alias (new_name_for_i, "i");
2768 end p;
2769 @end smallexample
2770
2771 @node Pragma Linker_Constructor
2772 @unnumberedsec Pragma Linker_Constructor
2773 @findex Linker_Constructor
2774 @noindent
2775 Syntax:
2776
2777 @smallexample @c ada
2778 pragma Linker_Constructor (procedure_LOCAL_NAME);
2779 @end smallexample
2780
2781 @noindent
2782 @var{procedure_local_NAME} must refer to a parameterless procedure that
2783 is declared at the library level. A procedure to which this pragma is
2784 applied will be treated as an initialization routine by the linker.
2785 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2786 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2787 of the executable is called (or immediately after the shared library is
2788 loaded if the procedure is linked in a shared library), in particular
2789 before the Ada run-time environment is set up.
2790
2791 Because of these specific contexts, the set of operations such a procedure
2792 can perform is very limited and the type of objects it can manipulate is
2793 essentially restricted to the elementary types. In particular, it must only
2794 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2795
2796 This pragma is used by GNAT to implement auto-initialization of shared Stand
2797 Alone Libraries, which provides a related capability without the restrictions
2798 listed above. Where possible, the use of Stand Alone Libraries is preferable
2799 to the use of this pragma.
2800
2801 @node Pragma Linker_Destructor
2802 @unnumberedsec Pragma Linker_Destructor
2803 @findex Linker_Destructor
2804 @noindent
2805 Syntax:
2806
2807 @smallexample @c ada
2808 pragma Linker_Destructor (procedure_LOCAL_NAME);
2809 @end smallexample
2810
2811 @noindent
2812 @var{procedure_local_NAME} must refer to a parameterless procedure that
2813 is declared at the library level. A procedure to which this pragma is
2814 applied will be treated as a finalization routine by the linker.
2815 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2816 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2817 of the executable has exited (or immediately before the shared library
2818 is unloaded if the procedure is linked in a shared library), in particular
2819 after the Ada run-time environment is shut down.
2820
2821 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2822 because of these specific contexts.
2823
2824 @node Pragma Linker_Section
2825 @unnumberedsec Pragma Linker_Section
2826 @findex Linker_Section
2827 @noindent
2828 Syntax:
2829
2830 @smallexample @c ada
2831 pragma Linker_Section (
2832   [Entity  =>] local_NAME
2833   [Section =>] static_string_EXPRESSION);
2834 @end smallexample
2835
2836 @noindent
2837 @var{local_NAME} must refer to an object that is declared at the library
2838 level. This pragma specifies the name of the linker section for the given
2839 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2840 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2841 section of the executable (assuming the linker doesn't rename the section).
2842
2843 The compiler normally places library-level objects in standard sections
2844 depending on their type: procedures and functions generally go in the
2845 @code{.text} section, initialized variables in the @code{.data} section
2846 and uninitialized variables in the @code{.bss} section.
2847
2848 Other, special sections may exist on given target machines to map special
2849 hardware, for example I/O ports or flash memory. This pragma is a means to
2850 defer the final layout of the executable to the linker, thus fully working
2851 at the symbolic level with the compiler.
2852
2853 Some file formats do not support arbitrary sections so not all target
2854 machines support this pragma. The use of this pragma may cause a program
2855 execution to be erroneous if it is used to place an entity into an
2856 inappropriate section (e.g. a modified variable into the @code{.text}
2857 section). See also @code{pragma Persistent_BSS}.
2858
2859 @smallexample @c ada
2860 --  Example of the use of pragma Linker_Section
2861
2862 package IO_Card is
2863   Port_A : Integer;
2864   pragma Volatile (Port_A);
2865   pragma Linker_Section (Port_A, ".bss.port_a");
2866
2867   Port_B : Integer;
2868   pragma Volatile (Port_B);
2869   pragma Linker_Section (Port_B, ".bss.port_b");
2870 end IO_Card;
2871 @end smallexample
2872
2873 @node Pragma Long_Float
2874 @unnumberedsec Pragma Long_Float
2875 @cindex OpenVMS
2876 @findex Long_Float
2877 @noindent
2878 Syntax:
2879
2880 @smallexample @c ada
2881 pragma Long_Float (FLOAT_FORMAT);
2882
2883 FLOAT_FORMAT ::= D_Float | G_Float
2884 @end smallexample
2885
2886 @noindent
2887 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2888 It allows control over the internal representation chosen for the predefined
2889 type @code{Long_Float} and for floating point type representations with
2890 @code{digits} specified in the range 7 through 15.
2891 For further details on this pragma, see the
2892 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2893 this pragma, the standard runtime libraries must be recompiled.  See the
2894 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2895 of the GNAT User's Guide for details on the use of this command.
2896
2897 @node Pragma Machine_Attribute
2898 @unnumberedsec Pragma Machine_Attribute
2899 @findex Machine_Attribute
2900 @noindent
2901 Syntax:
2902
2903 @smallexample @c ada
2904 pragma Machine_Attribute (
2905   [Attribute_Name =>] string_EXPRESSION,
2906   [Entity         =>] local_NAME);
2907 @end smallexample
2908
2909 @noindent
2910 Machine-dependent attributes can be specified for types and/or
2911 declarations.  This pragma is semantically equivalent to
2912 @code{__attribute__((@var{string_expression}))} in GNU C,
2913 where @code{@var{string_expression}} is
2914 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2915 defined for each machine.  See the GCC manual for further information.
2916 It is not possible to specify attributes defined by other languages,
2917 only attributes defined by the machine the code is intended to run on.
2918
2919 @node Pragma Main_Storage
2920 @unnumberedsec Pragma Main_Storage
2921 @cindex OpenVMS
2922 @findex Main_Storage
2923 @noindent
2924 Syntax:
2925
2926 @smallexample @c ada
2927 pragma Main_Storage
2928   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2929
2930 MAIN_STORAGE_OPTION ::=
2931   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2932 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2933
2934 @end smallexample
2935
2936 @noindent
2937 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2938 no effect in GNAT, other than being syntax checked.  Note that the pragma
2939 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2940
2941 @node Pragma No_Body
2942 @unnumberedsec Pragma No_Body
2943 @findex No_Body
2944 @noindent
2945 Syntax:
2946
2947 @smallexample @c ada
2948 pragma No_Body;
2949 @end smallexample
2950
2951 @noindent
2952 There are a number of cases in which a package spec does not require a body,
2953 and in fact a body is not permitted. GNAT will not permit the spec to be
2954 compiled if there is a body around. The pragma No_Body allows you to provide
2955 a body file, even in a case where no body is allowed. The body file must
2956 contain only comments and a single No_Body pragma. This is recognized by
2957 the compiler as indicating that no body is logically present.
2958
2959 This is particularly useful during maintenance when a package is modified in
2960 such a way that a body needed before is no longer needed. The provision of a
2961 dummy body with a No_Body pragma ensures that there is no inteference from
2962 earlier versions of the package body.
2963
2964 @node Pragma No_Return
2965 @unnumberedsec Pragma No_Return
2966 @findex No_Return
2967 @noindent
2968 Syntax:
2969
2970 @smallexample @c ada
2971 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
2972 @end smallexample
2973
2974 @noindent
2975 Each @var{procedure_local_NAME} argument must refer to one or more procedure
2976 declarations in the current declarative part.  A procedure to which this
2977 pragma is applied may not contain any explicit @code{return} statements.
2978 In addition, if the procedure contains any implicit returns from falling
2979 off the end of a statement sequence, then execution of that implicit
2980 return will cause Program_Error to be raised.
2981
2982 One use of this pragma is to identify procedures whose only purpose is to raise
2983 an exception. Another use of this pragma is to suppress incorrect warnings
2984 about missing returns in functions, where the last statement of a function
2985 statement sequence is a call to such a procedure.
2986
2987 Note that in Ada 2005 mode, this pragma is part of the language, and is
2988 identical in effect to the pragma as implemented in Ada 95 mode.
2989
2990 @node Pragma No_Strict_Aliasing
2991 @unnumberedsec Pragma No_Strict_Aliasing
2992 @findex No_Strict_Aliasing
2993 @noindent
2994 Syntax:
2995
2996 @smallexample @c ada
2997 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
2998 @end smallexample
2999
3000 @noindent
3001 @var{type_LOCAL_NAME} must refer to an access type
3002 declaration in the current declarative part.  The effect is to inhibit
3003 strict aliasing optimization for the given type.  The form with no
3004 arguments is a configuration pragma which applies to all access types
3005 declared in units to which the pragma applies. For a detailed
3006 description of the strict aliasing optimization, and the situations
3007 in which it must be suppressed, see section
3008 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3009
3010 @node Pragma Normalize_Scalars
3011 @unnumberedsec Pragma Normalize_Scalars
3012 @findex Normalize_Scalars
3013 @noindent
3014 Syntax:
3015
3016 @smallexample @c ada
3017 pragma Normalize_Scalars;
3018 @end smallexample
3019
3020 @noindent
3021 This is a language defined pragma which is fully implemented in GNAT@.  The
3022 effect is to cause all scalar objects that are not otherwise initialized
3023 to be initialized.  The initial values are implementation dependent and
3024 are as follows:
3025
3026 @table @code
3027 @item Standard.Character
3028 @noindent
3029 Objects whose root type is Standard.Character are initialized to
3030 Character'Last unless the subtype range excludes NUL (in which case
3031 NUL is used). This choice will always generate an invalid value if
3032 one exists.
3033
3034 @item Standard.Wide_Character
3035 @noindent
3036 Objects whose root type is Standard.Wide_Character are initialized to
3037 Wide_Character'Last unless the subtype range excludes NUL (in which case
3038 NUL is used). This choice will always generate an invalid value if
3039 one exists.
3040
3041 @item Standard.Wide_Wide_Character
3042 @noindent
3043 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3044 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3045 which case NUL is used). This choice will always generate an invalid value if
3046 one exists.
3047
3048 @item Integer types
3049 @noindent
3050 Objects of an integer type are treated differently depending on whether
3051 negative values are present in the subtype. If no negative values are
3052 present, then all one bits is used as the initial value except in the
3053 special case where zero is excluded from the subtype, in which case
3054 all zero bits are used. This choice will always generate an invalid
3055 value if one exists.
3056
3057 For subtypes with negative values present, the largest negative number
3058 is used, except in the unusual case where this largest negative number
3059 is in the subtype, and the largest positive number is not, in which case
3060 the largest positive value is used. This choice will always generate
3061 an invalid value if one exists.
3062
3063 @item Floating-Point Types
3064 Objects of all floating-point types are initialized to all 1-bits. For
3065 standard IEEE format, this corresponds to a NaN (not a number) which is
3066 indeed an invalid value.
3067
3068 @item Fixed-Point Types
3069 Objects of all fixed-point types are treated as described above for integers,
3070 with the rules applying to the underlying integer value used to represent
3071 the fixed-point value.
3072
3073 @item Modular types
3074 Objects of a modular type are initialized to all one bits, except in
3075 the special case where zero is excluded from the subtype, in which
3076 case all zero bits are used. This choice will always generate an
3077 invalid value if one exists.
3078
3079 @item Enumeration types
3080 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3081 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3082 whose Pos value is zero, in which case a code of zero is used. This choice
3083 will always generate an invalid value if one exists.
3084
3085 @end table
3086
3087 @node Pragma Obsolescent
3088 @unnumberedsec Pragma Obsolescent
3089 @findex Obsolescent
3090 @noindent
3091 Syntax:
3092
3093 @smallexample @c ada
3094 pragma Obsolescent
3095   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3096 @end smallexample
3097
3098 @noindent
3099 This pragma can occur immediately following a declaration of an entity,
3100 including the case of a record component, and usually the Entity name
3101 must match the name of the entity declared by this declaration.
3102 Alternatively, the pragma can immediately follow an
3103 enumeration type declaration, where the entity argument names one of the
3104 enumeration literals.
3105
3106 This pragma is used to indicate that the named entity
3107 is considered obsolescent and should not be used. Typically this is
3108 used when an API must be modified by eventually removing or modifying
3109 existing subprograms or other entities. The pragma can be used at an
3110 intermediate stage when the entity is still present, but will be
3111 removed later.
3112
3113 The effect of this pragma is to output a warning message on
3114 a call to a program thus marked that the
3115 subprogram is obsolescent if the appropriate warning option in the
3116 compiler is activated. If the string parameter is present, then a second
3117 warning message is given containing this text.
3118 In addition, a call to such a program is considered a violation of
3119 pragma Restrictions (No_Obsolescent_Features).
3120
3121 This pragma can also be used as a program unit pragma for a package,
3122 in which case the entity name is the name of the package, and the
3123 pragma indicates that the entire package is considered
3124 obsolescent. In this case a client @code{with}'ing such a package
3125 violates the restriction, and the @code{with} statement is
3126 flagged with warnings if the warning option is set.
3127
3128 If the optional third parameter is present (which must be exactly
3129 the identifier Ada_05, no other argument is allowed), then the
3130 indication of obsolescence applies only when compiling in Ada 2005
3131 mode. This is primarily intended for dealing with the situations
3132 in the predefined library where subprograms or packages
3133 have become defined as obsolescent in Ada 2005
3134 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3135
3136 The following examples show typical uses of this pragma:
3137
3138 @smallexample @c ada
3139 package p is
3140    pragma Obsolescent
3141      (Entity => p, "use pp instead of p");
3142 end p;
3143
3144 package q is
3145    procedure q2;
3146    pragma Obsolescent
3147      (Entity => q2, "use q2new instead");
3148
3149    type R is new integer;
3150    pragma Obsolescent
3151      (Entity => R, "use RR in Ada 2005", Ada_05);
3152
3153    type M is record
3154       F1 : Integer;
3155       F2 : Integer;
3156       pragma Obsolescent (Entity => F2);
3157       F3 : Integer;
3158    end record;
3159
3160    type E is (a, bc, 'd', quack);
3161    pragma Obsolescent (Entity => bc)
3162    pragma Obsolescent (Entity => 'd')
3163
3164    function "+"
3165      (a, b : character) return character;
3166    pragma Obsolescent (Entity => "+");
3167 end;
3168 @end smallexample
3169
3170 @noindent
3171 In an earlier version of GNAT, the Entity parameter was not required,
3172 and this form is still accepted for compatibility purposes. If the
3173 Entity parameter is omitted, then the pragma applies to the declaration
3174 immediately preceding the pragma (this form cannot be used for the
3175 enumeration literal case).
3176
3177 @node Pragma Passive
3178 @unnumberedsec Pragma Passive
3179 @findex Passive
3180 @noindent
3181 Syntax:
3182
3183 @smallexample @c ada
3184 pragma Passive ([Semaphore | No]);
3185 @end smallexample
3186
3187 @noindent
3188 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3189 compatibility with DEC Ada 83 implementations, where it is used within a
3190 task definition to request that a task be made passive.  If the argument
3191 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3192 treats the pragma as an assertion that the containing task is passive
3193 and that optimization of context switch with this task is permitted and
3194 desired.  If the argument @code{No} is present, the task must not be
3195 optimized.  GNAT does not attempt to optimize any tasks in this manner
3196 (since protected objects are available in place of passive tasks).
3197
3198 @node Pragma Persistent_BSS
3199 @unnumberedsec Pragma Persistent_BSS
3200 @findex Persistent_BSS
3201 @noindent
3202 Syntax:
3203
3204 @smallexample @c ada
3205 pragma Persistent_BSS [local_NAME]
3206 @end smallexample
3207
3208 @noindent
3209 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3210 section. On some targets the linker and loader provide for special
3211 treatment of this section, allowing a program to be reloaded without
3212 affecting the contents of this data (hence the name persistent).
3213
3214 There are two forms of usage. If an argument is given, it must be the
3215 local name of a library level object, with no explicit initialization
3216 and whose type is potentially persistent. If no argument is given, then
3217 the pragma is a configuration pragma, and applies to all library level
3218 objects with no explicit initialization of potentially persistent types.
3219
3220 A potentially persistent type is a scalar type, or a non-tagged,
3221 non-discriminated record, all of whose components have no explicit
3222 initialization and are themselves of a potentially persistent type,
3223 or an array, all of whose constraints are static, and whose component
3224 type is potentially persistent.
3225
3226 If this pragma is used on a target where this feature is not supported,
3227 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3228
3229 @node Pragma Polling
3230 @unnumberedsec Pragma Polling
3231 @findex Polling
3232 @noindent
3233 Syntax:
3234
3235 @smallexample @c ada
3236 pragma Polling (ON | OFF);
3237 @end smallexample
3238
3239 @noindent
3240 This pragma controls the generation of polling code.  This is normally off.
3241 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3242 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3243 runtime library, and can be found in file @file{a-excpol.adb}.
3244
3245 Pragma @code{Polling} can appear as a configuration pragma (for example it
3246 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3247 can be used in the statement or declaration sequence to control polling
3248 more locally.
3249
3250 A call to the polling routine is generated at the start of every loop and
3251 at the start of every subprogram call.  This guarantees that the @code{Poll}
3252 routine is called frequently, and places an upper bound (determined by
3253 the complexity of the code) on the period between two @code{Poll} calls.
3254
3255 The primary purpose of the polling interface is to enable asynchronous
3256 aborts on targets that cannot otherwise support it (for example Windows
3257 NT), but it may be used for any other purpose requiring periodic polling.
3258 The standard version is null, and can be replaced by a user program.  This
3259 will require re-compilation of the @code{Ada.Exceptions} package that can
3260 be found in files @file{a-except.ads} and @file{a-except.adb}.
3261
3262 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3263 distribution) is used to enable the asynchronous abort capability on
3264 targets that do not normally support the capability.  The version of
3265 @code{Poll} in this file makes a call to the appropriate runtime routine
3266 to test for an abort condition.
3267
3268 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
3269 the @cite{GNAT User's Guide} for details.
3270
3271 @node Pragma Profile (Ravenscar)
3272 @unnumberedsec Pragma Profile (Ravenscar)
3273 @findex Ravenscar
3274 @noindent
3275 Syntax:
3276
3277 @smallexample @c ada
3278 pragma Profile (Ravenscar);
3279 @end smallexample
3280
3281 @noindent
3282 A configuration pragma that establishes the following set of configuration
3283 pragmas:
3284
3285 @table @code
3286 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3287 [RM D.2.2] Tasks are dispatched following a preemptive
3288 priority-ordered scheduling policy.
3289
3290 @item Locking_Policy (Ceiling_Locking)
3291 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3292 the ceiling priority of the corresponding protected object.
3293 @c
3294 @c @item Detect_Blocking
3295 @c This pragma forces the detection of potentially blocking operations within a
3296 @c protected operation, and to raise Program_Error if that happens.
3297 @end table
3298 @noindent
3299
3300 plus the following set of restrictions:
3301
3302 @table @code
3303 @item Max_Entry_Queue_Length = 1
3304 Defines the maximum number of calls that are queued on a (protected) entry.
3305 Note that this restrictions is checked at run time. Violation of this
3306 restriction results in the raising of Program_Error exception at the point of
3307 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3308 always 1 and hence no task can be queued on a protected entry.
3309
3310 @item Max_Protected_Entries = 1
3311 [RM D.7] Specifies the maximum number of entries per protected type. The
3312 bounds of every entry family of a protected unit shall be static, or shall be
3313 defined by a discriminant of a subtype whose corresponding bound is static.
3314 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3315
3316 @item Max_Task_Entries = 0
3317 [RM D.7] Specifies the maximum number of entries
3318 per task.  The bounds of every entry family
3319 of a task unit shall be static, or shall be
3320 defined by a discriminant of a subtype whose
3321 corresponding bound is static.  A value of zero
3322 indicates that no rendezvous are possible.  For
3323 the Profile (Ravenscar), the value of Max_Task_Entries is always
3324 0 (zero).
3325
3326 @item No_Abort_Statements
3327 [RM D.7] There are no abort_statements, and there are
3328 no calls to Task_Identification.Abort_Task.
3329
3330 @item No_Asynchronous_Control
3331 [RM D.7] There are no semantic dependences on the package
3332 Asynchronous_Task_Control.
3333
3334 @item No_Calendar
3335 There are no semantic dependencies on the package Ada.Calendar.
3336
3337 @item No_Dynamic_Attachment
3338 There is no call to any of the operations defined in package Ada.Interrupts
3339 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3340 Detach_Handler, and Reference).
3341
3342 @item No_Dynamic_Priorities
3343 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3344
3345 @item No_Implicit_Heap_Allocations
3346 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3347
3348 @item No_Local_Protected_Objects
3349 Protected objects and access types that designate
3350 such objects shall be declared only at library level.
3351
3352 @item No_Protected_Type_Allocators
3353 There are no allocators for protected types or
3354 types containing protected subcomponents.
3355
3356 @item No_Relative_Delay
3357 There are no delay_relative statements.
3358
3359 @item No_Requeue_Statements
3360 Requeue statements are not allowed.
3361
3362 @item No_Select_Statements
3363 There are no select_statements.
3364
3365 @item No_Task_Allocators
3366 [RM D.7] There are no allocators for task types
3367 or types containing task subcomponents.
3368
3369 @item No_Task_Attributes_Package
3370 There are no semantic dependencies on the Ada.Task_Attributes package.
3371
3372 @item No_Task_Hierarchy
3373 [RM D.7] All (non-environment) tasks depend
3374 directly on the environment task of the partition.
3375
3376 @item No_Task_Termination
3377 Tasks which terminate are erroneous.
3378
3379 @item Simple_Barriers
3380 Entry barrier condition expressions shall be either static
3381 boolean expressions or boolean objects which are declared in
3382 the protected type which contains the entry.
3383 @end table
3384
3385 @noindent
3386 This set of configuration pragmas and restrictions correspond to the
3387 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3388 published by the @cite{International Real-Time Ada Workshop}, 1997,
3389 and whose most recent description is available at
3390 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3391
3392 The original definition of the profile was revised at subsequent IRTAW
3393 meetings. It has been included in the ISO
3394 @cite{Guide for the Use of the Ada Programming Language in High
3395 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3396 the next revision of the standard. The formal definition given by
3397 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3398 AI-305) available at
3399 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3400 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3401 respectively.
3402
3403 The above set is a superset of the restrictions provided by pragma
3404 @code{Profile (Restricted)}, it includes six additional restrictions
3405 (@code{Simple_Barriers}, @code{No_Select_Statements},
3406 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3407 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3408 that pragma @code{Profile (Ravenscar)}, like the pragma
3409 @code{Profile (Restricted)},
3410 automatically causes the use of a simplified,
3411 more efficient version of the tasking run-time system.
3412
3413 @node Pragma Profile (Restricted)
3414 @unnumberedsec Pragma Profile (Restricted)
3415 @findex Restricted Run Time
3416 @noindent
3417 Syntax:
3418
3419 @smallexample @c ada
3420 pragma Profile (Restricted);
3421 @end smallexample
3422
3423 @noindent
3424 A configuration pragma that establishes the following set of restrictions:
3425
3426 @itemize @bullet
3427 @item No_Abort_Statements
3428 @item No_Entry_Queue
3429 @item No_Task_Hierarchy
3430 @item No_Task_Allocators
3431 @item No_Dynamic_Priorities
3432 @item No_Terminate_Alternatives
3433 @item No_Dynamic_Attachment
3434 @item No_Protected_Type_Allocators
3435 @item No_Local_Protected_Objects
3436 @item No_Requeue_Statements
3437 @item No_Task_Attributes_Package
3438 @item Max_Asynchronous_Select_Nesting =  0
3439 @item Max_Task_Entries =  0
3440 @item Max_Protected_Entries = 1
3441 @item Max_Select_Alternatives = 0
3442 @end itemize
3443
3444 @noindent
3445 This set of restrictions causes the automatic selection of a simplified
3446 version of the run time that provides improved performance for the
3447 limited set of tasking functionality permitted by this set of restrictions.
3448
3449 @node Pragma Psect_Object
3450 @unnumberedsec Pragma Psect_Object
3451 @findex Psect_Object
3452 @noindent
3453 Syntax:
3454
3455 @smallexample @c ada
3456 pragma Psect_Object (
3457      [Internal =>] local_NAME,
3458   [, [External =>] EXTERNAL_SYMBOL]
3459   [, [Size     =>] EXTERNAL_SYMBOL]);
3460
3461 EXTERNAL_SYMBOL ::=
3462   IDENTIFIER
3463 | static_string_EXPRESSION
3464 @end smallexample
3465
3466 @noindent
3467 This pragma is identical in effect to pragma @code{Common_Object}.
3468
3469 @node Pragma Pure_Function
3470 @unnumberedsec Pragma Pure_Function
3471 @findex Pure_Function
3472 @noindent
3473 Syntax:
3474
3475 @smallexample @c ada
3476 pragma Pure_Function ([Entity =>] function_local_NAME);
3477 @end smallexample
3478
3479 @noindent
3480 This pragma appears in the same declarative part as a function
3481 declaration (or a set of function declarations if more than one
3482 overloaded declaration exists, in which case the pragma applies
3483 to all entities).  It specifies that the function @code{Entity} is
3484 to be considered pure for the purposes of code generation.  This means
3485 that the compiler can assume that there are no side effects, and
3486 in particular that two calls with identical arguments produce the
3487 same result.  It also means that the function can be used in an
3488 address clause.
3489
3490 Note that, quite deliberately, there are no static checks to try
3491 to ensure that this promise is met, so @code{Pure_Function} can be used
3492 with functions that are conceptually pure, even if they do modify
3493 global variables.  For example, a square root function that is
3494 instrumented to count the number of times it is called is still
3495 conceptually pure, and can still be optimized, even though it
3496 modifies a global variable (the count).  Memo functions are another
3497 example (where a table of previous calls is kept and consulted to
3498 avoid re-computation).
3499
3500 @findex Pure
3501 Note: Most functions in a @code{Pure} package are automatically pure, and
3502 there is no need to use pragma @code{Pure_Function} for such functions.  One
3503 exception is any function that has at least one formal of type
3504 @code{System.Address} or a type derived from it.  Such functions are not
3505 considered pure by default, since the compiler assumes that the
3506 @code{Address} parameter may be functioning as a pointer and that the
3507 referenced data may change even if the address value does not.
3508 Similarly, imported functions are not considered to be pure by default,
3509 since there is no way of checking that they are in fact pure.  The use
3510 of pragma @code{Pure_Function} for such a function will override these default
3511 assumption, and cause the compiler to treat a designated subprogram as pure
3512 in these cases.
3513
3514 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3515 applies to the underlying renamed function.  This can be used to
3516 disambiguate cases of overloading where some but not all functions
3517 in a set of overloaded functions are to be designated as pure.
3518
3519 If pragma @code{Pure_Function} is applied to a library level function, the
3520 function is also considered pure from an optimization point of view, but the
3521 unit is not a Pure unit in the categorization sense. So for example, a function
3522 thus marked is free to @code{with} non-pure units.
3523
3524 @node Pragma Restriction_Warnings
3525 @unnumberedsec Pragma Restriction_Warnings
3526 @findex Restriction_Warnings
3527 @noindent
3528 Syntax:
3529
3530 @smallexample @c ada
3531 pragma Restriction_Warnings
3532   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3533 @end smallexample
3534
3535 @noindent
3536 This pragma allows a series of restriction identifiers to be
3537 specified (the list of allowed identifiers is the same as for
3538 pragma @code{Restrictions}). For each of these identifiers
3539 the compiler checks for violations of the restriction, but
3540 generates a warning message rather than an error message
3541 if the restriction is violated.
3542
3543 @node Pragma Source_File_Name
3544 @unnumberedsec Pragma Source_File_Name
3545 @findex Source_File_Name
3546 @noindent
3547 Syntax:
3548
3549 @smallexample @c ada
3550 pragma Source_File_Name (
3551   [Unit_Name   =>] unit_NAME,
3552   Spec_File_Name =>  STRING_LITERAL);
3553
3554 pragma Source_File_Name (
3555   [Unit_Name   =>] unit_NAME,
3556   Body_File_Name =>  STRING_LITERAL);
3557 @end smallexample
3558
3559 @noindent
3560 Use this to override the normal naming convention.  It is a configuration
3561 pragma, and so has the usual applicability of configuration pragmas
3562 (i.e.@: it applies to either an entire partition, or to all units in a
3563 compilation, or to a single unit, depending on how it is used.
3564 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3565 the second argument is required, and indicates whether this is the file
3566 name for the spec or for the body.
3567
3568 Another form of the @code{Source_File_Name} pragma allows
3569 the specification of patterns defining alternative file naming schemes
3570 to apply to all files.
3571
3572 @smallexample @c ada
3573 pragma Source_File_Name
3574   (Spec_File_Name => STRING_LITERAL
3575    [,Casing => CASING_SPEC]
3576    [,Dot_Replacement => STRING_LITERAL]);
3577
3578 pragma Source_File_Name
3579   (Body_File_Name => STRING_LITERAL
3580    [,Casing => CASING_SPEC]
3581    [,Dot_Replacement => STRING_LITERAL]);
3582
3583 pragma Source_File_Name
3584   (Subunit_File_Name => STRING_LITERAL
3585    [,Casing => CASING_SPEC]
3586    [,Dot_Replacement => STRING_LITERAL]);
3587
3588 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3589 @end smallexample
3590
3591 @noindent
3592 The first argument is a pattern that contains a single asterisk indicating
3593 the point at which the unit name is to be inserted in the pattern string
3594 to form the file name.  The second argument is optional.  If present it
3595 specifies the casing of the unit name in the resulting file name string.
3596 The default is lower case.  Finally the third argument allows for systematic
3597 replacement of any dots in the unit name by the specified string literal.
3598
3599 A pragma Source_File_Name cannot appear after a
3600 @ref{Pragma Source_File_Name_Project}.
3601
3602 For more details on the use of the @code{Source_File_Name} pragma,
3603 see the sections ``Using Other File Names'' and
3604 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3605
3606 @node Pragma Source_File_Name_Project
3607 @unnumberedsec Pragma Source_File_Name_Project
3608 @findex Source_File_Name_Project
3609 @noindent
3610
3611 This pragma has the same syntax and semantics as pragma Source_File_Name.
3612 It is only allowed as a stand alone configuration pragma.
3613 It cannot appear after a @ref{Pragma Source_File_Name}, and
3614 most importantly, once pragma Source_File_Name_Project appears,
3615 no further Source_File_Name pragmas are allowed.
3616
3617 The intention is that Source_File_Name_Project pragmas are always
3618 generated by the Project Manager in a manner consistent with the naming
3619 specified in a project file, and when naming is controlled in this manner,
3620 it is not permissible to attempt to modify this naming scheme using
3621 Source_File_Name pragmas (which would not be known to the project manager).
3622
3623 @node Pragma Source_Reference
3624 @unnumberedsec Pragma Source_Reference
3625 @findex Source_Reference
3626 @noindent
3627 Syntax:
3628
3629 @smallexample @c ada
3630 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3631 @end smallexample
3632
3633 @noindent
3634 This pragma must appear as the first line of a source file.
3635 @var{integer_literal} is the logical line number of the line following
3636 the pragma line (for use in error messages and debugging
3637 information).  @var{string_literal} is a static string constant that
3638 specifies the file name to be used in error messages and debugging
3639 information.  This is most notably used for the output of @code{gnatchop}
3640 with the @code{-r} switch, to make sure that the original unchopped
3641 source file is the one referred to.
3642
3643 The second argument must be a string literal, it cannot be a static
3644 string expression other than a string literal.  This is because its value
3645 is needed for error messages issued by all phases of the compiler.
3646
3647 @node Pragma Stream_Convert
3648 @unnumberedsec Pragma Stream_Convert
3649 @findex Stream_Convert
3650 @noindent
3651 Syntax:
3652
3653 @smallexample @c ada
3654 pragma Stream_Convert (
3655   [Entity =>] type_local_NAME,
3656   [Read   =>] function_NAME,
3657   [Write  =>] function_NAME);
3658 @end smallexample
3659
3660 @noindent
3661 This pragma provides an efficient way of providing stream functions for
3662 types defined in packages.  Not only is it simpler to use than declaring
3663 the necessary functions with attribute representation clauses, but more
3664 significantly, it allows the declaration to made in such a way that the
3665 stream packages are not loaded unless they are needed.  The use of
3666 the Stream_Convert pragma adds no overhead at all, unless the stream
3667 attributes are actually used on the designated type.
3668
3669 The first argument specifies the type for which stream functions are
3670 provided.  The second parameter provides a function used to read values
3671 of this type.  It must name a function whose argument type may be any
3672 subtype, and whose returned type must be the type given as the first
3673 argument to the pragma.
3674
3675 The meaning of the @var{Read}
3676 parameter is that if a stream attribute directly
3677 or indirectly specifies reading of the type given as the first parameter,
3678 then a value of the type given as the argument to the Read function is
3679 read from the stream, and then the Read function is used to convert this
3680 to the required target type.
3681
3682 Similarly the @var{Write} parameter specifies how to treat write attributes
3683 that directly or indirectly apply to the type given as the first parameter.
3684 It must have an input parameter of the type specified by the first parameter,
3685 and the return type must be the same as the input type of the Read function.
3686 The effect is to first call the Write function to convert to the given stream
3687 type, and then write the result type to the stream.
3688
3689 The Read and Write functions must not be overloaded subprograms.  If necessary
3690 renamings can be supplied to meet this requirement.
3691 The usage of this attribute is best illustrated by a simple example, taken
3692 from the GNAT implementation of package Ada.Strings.Unbounded:
3693
3694 @smallexample @c ada
3695 function To_Unbounded (S : String)
3696            return Unbounded_String
3697   renames To_Unbounded_String;
3698
3699 pragma Stream_Convert
3700   (Unbounded_String, To_Unbounded, To_String);
3701 @end smallexample
3702
3703 @noindent
3704 The specifications of the referenced functions, as given in the Ada
3705 Reference Manual are:
3706
3707 @smallexample @c ada
3708 function To_Unbounded_String (Source : String)
3709   return Unbounded_String;
3710
3711 function To_String (Source : Unbounded_String)
3712   return String;
3713 @end smallexample
3714
3715 @noindent
3716 The effect is that if the value of an unbounded string is written to a
3717 stream, then the representation of the item in the stream is in the same
3718 format used for @code{Standard.String}, and this same representation is
3719 expected when a value of this type is read from the stream.
3720
3721 @node Pragma Style_Checks
3722 @unnumberedsec Pragma Style_Checks
3723 @findex Style_Checks
3724 @noindent
3725 Syntax:
3726
3727 @smallexample @c ada
3728 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3729                      On | Off [, local_NAME]);
3730 @end smallexample
3731
3732 @noindent
3733 This pragma is used in conjunction with compiler switches to control the
3734 built in style checking provided by GNAT@.  The compiler switches, if set,
3735 provide an initial setting for the switches, and this pragma may be used
3736 to modify these settings, or the settings may be provided entirely by
3737 the use of the pragma.  This pragma can be used anywhere that a pragma
3738 is legal, including use as a configuration pragma (including use in
3739 the @file{gnat.adc} file).
3740
3741 The form with a string literal specifies which style options are to be
3742 activated.  These are additive, so they apply in addition to any previously
3743 set style check options.  The codes for the options are the same as those
3744 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3745 For example the following two methods can be used to enable
3746 layout checking:
3747
3748 @itemize @bullet
3749 @item
3750 @smallexample @c ada
3751 pragma Style_Checks ("l");
3752 @end smallexample
3753
3754 @item
3755 @smallexample
3756 gcc -c -gnatyl @dots{}
3757 @end smallexample
3758 @end itemize
3759
3760 @noindent
3761 The form ALL_CHECKS activates all standard checks (its use is equivalent
3762 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3763 Guide for details.
3764
3765 The forms with @code{Off} and @code{On}
3766 can be used to temporarily disable style checks
3767 as shown in the following example:
3768
3769 @smallexample @c ada
3770 @iftex
3771 @leftskip=0cm
3772 @end iftex
3773 pragma Style_Checks ("k"); -- requires keywords in lower case
3774 pragma Style_Checks (Off); -- turn off style checks
3775 NULL;                      -- this will not generate an error message
3776 pragma Style_Checks (On);  -- turn style checks back on
3777 NULL;                      -- this will generate an error message
3778 @end smallexample
3779
3780 @noindent
3781 Finally the two argument form is allowed only if the first argument is
3782 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3783 for the specified entity, as shown in the following example:
3784
3785 @smallexample @c ada
3786 @iftex
3787 @leftskip=0cm
3788 @end iftex
3789 pragma Style_Checks ("r"); -- require consistency of identifier casing
3790 Arg : Integer;
3791 Rf1 : Integer := ARG;      -- incorrect, wrong case
3792 pragma Style_Checks (Off, Arg);
3793 Rf2 : Integer := ARG;      -- OK, no error
3794 @end smallexample
3795
3796 @node Pragma Subtitle
3797 @unnumberedsec Pragma Subtitle
3798 @findex Subtitle
3799 @noindent
3800 Syntax:
3801
3802 @smallexample @c ada
3803 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3804 @end smallexample
3805
3806 @noindent
3807 This pragma is recognized for compatibility with other Ada compilers
3808 but is ignored by GNAT@.
3809
3810 @node Pragma Suppress
3811 @unnumberedsec Pragma Suppress
3812 @findex Suppress
3813 @noindent
3814 Syntax:
3815
3816 @smallexample @c ada
3817 pragma Suppress (Identifier [, [On =>] Name]);
3818 @end smallexample
3819
3820 @noindent
3821 This is a standard pragma, and supports all the check names required in
3822 the RM. It is included here because GNAT recognizes one additional check
3823 name: @code{Alignment_Check} which can be used to suppress alignment checks
3824 on addresses used in address clauses. Such checks can also be suppressed
3825 by suppressing range checks, but the specific use of @code{Alignment_Check}
3826 allows suppression of alignment checks without suppressing other range checks.
3827
3828 @node Pragma Suppress_All
3829 @unnumberedsec Pragma Suppress_All
3830 @findex Suppress_All
3831 @noindent
3832 Syntax:
3833
3834 @smallexample @c ada
3835 pragma Suppress_All;
3836 @end smallexample
3837
3838 @noindent
3839 This pragma can only appear immediately following a compilation
3840 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3841 which it follows.  This pragma is implemented for compatibility with DEC
3842 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3843 configuration pragma is the preferred usage in GNAT@.
3844
3845 @node Pragma Suppress_Exception_Locations
3846 @unnumberedsec Pragma Suppress_Exception_Locations
3847 @findex Suppress_Exception_Locations
3848 @noindent
3849 Syntax:
3850
3851 @smallexample @c ada
3852 pragma Suppress_Exception_Locations;
3853 @end smallexample
3854
3855 @noindent
3856 In normal mode, a raise statement for an exception by default generates
3857 an exception message giving the file name and line number for the location
3858 of the raise. This is useful for debugging and logging purposes, but this
3859 entails extra space for the strings for the messages. The configuration
3860 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3861 generation of these strings, with the result that space is saved, but the
3862 exception message for such raises is null. This configuration pragma may
3863 appear in a global configuration pragma file, or in a specific unit as
3864 usual. It is not required that this pragma be used consistently within
3865 a partition, so it is fine to have some units within a partition compiled
3866 with this pragma and others compiled in normal mode without it.
3867
3868 @node Pragma Suppress_Initialization
3869 @unnumberedsec Pragma Suppress_Initialization
3870 @findex Suppress_Initialization
3871 @cindex Suppressing initialization
3872 @cindex Initialization, suppression of
3873 @noindent
3874 Syntax:
3875
3876 @smallexample @c ada
3877 pragma Suppress_Initialization ([Entity =>] type_Name);
3878 @end smallexample
3879
3880 @noindent
3881 This pragma suppresses any implicit or explicit initialization
3882 associated with the given type name for all variables of this type.
3883
3884 @node Pragma Task_Info
3885 @unnumberedsec Pragma Task_Info
3886 @findex Task_Info
3887 @noindent
3888 Syntax
3889
3890 @smallexample @c ada
3891 pragma Task_Info (EXPRESSION);
3892 @end smallexample
3893
3894 @noindent
3895 This pragma appears within a task definition (like pragma
3896 @code{Priority}) and applies to the task in which it appears.  The
3897 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3898 The @code{Task_Info} pragma provides system dependent control over
3899 aspects of tasking implementation, for example, the ability to map
3900 tasks to specific processors.  For details on the facilities available
3901 for the version of GNAT that you are using, see the documentation
3902 in the specification of package System.Task_Info in the runtime
3903 library.
3904
3905 @node Pragma Task_Name
3906 @unnumberedsec Pragma Task_Name
3907 @findex Task_Name
3908 @noindent
3909 Syntax
3910
3911 @smallexample @c ada
3912 pragma Task_Name (string_EXPRESSION);
3913 @end smallexample
3914
3915 @noindent
3916 This pragma appears within a task definition (like pragma
3917 @code{Priority}) and applies to the task in which it appears.  The
3918 argument must be of type String, and provides a name to be used for
3919 the task instance when the task is created.  Note that this expression
3920 is not required to be static, and in particular, it can contain
3921 references to task discriminants.  This facility can be used to
3922 provide different names for different tasks as they are created,
3923 as illustrated in the example below.
3924
3925 The task name is recorded internally in the run-time structures
3926 and is accessible to tools like the debugger.  In addition the
3927 routine @code{Ada.Task_Identification.Image} will return this
3928 string, with a unique task address appended.
3929
3930 @smallexample @c ada
3931 --  Example of the use of pragma Task_Name
3932
3933 with Ada.Task_Identification;
3934 use Ada.Task_Identification;
3935 with Text_IO; use Text_IO;
3936 procedure t3 is
3937
3938    type Astring is access String;
3939
3940    task type Task_Typ (Name : access String) is
3941       pragma Task_Name (Name.all);
3942    end Task_Typ;
3943
3944    task body Task_Typ is
3945       Nam : constant String := Image (Current_Task);
3946    begin
3947       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3948    end Task_Typ;
3949
3950    type Ptr_Task is access Task_Typ;
3951    Task_Var : Ptr_Task;
3952
3953 begin
3954    Task_Var :=
3955      new Task_Typ (new String'("This is task 1"));
3956    Task_Var :=
3957      new Task_Typ (new String'("This is task 2"));
3958 end;
3959 @end smallexample
3960
3961 @node Pragma Task_Storage
3962 @unnumberedsec Pragma Task_Storage
3963 @findex Task_Storage
3964 Syntax:
3965
3966 @smallexample @c ada
3967 pragma Task_Storage (
3968   [Task_Type =>] local_NAME,
3969   [Top_Guard =>] static_integer_EXPRESSION);
3970 @end smallexample
3971
3972 @noindent
3973 This pragma specifies the length of the guard area for tasks.  The guard
3974 area is an additional storage area allocated to a task.  A value of zero
3975 means that either no guard area is created or a minimal guard area is
3976 created, depending on the target.  This pragma can appear anywhere a
3977 @code{Storage_Size} attribute definition clause is allowed for a task
3978 type.
3979
3980 @node Pragma Time_Slice
3981 @unnumberedsec Pragma Time_Slice
3982 @findex Time_Slice
3983 @noindent
3984 Syntax:
3985
3986 @smallexample @c ada
3987 pragma Time_Slice (static_duration_EXPRESSION);
3988 @end smallexample
3989
3990 @noindent
3991 For implementations of GNAT on operating systems where it is possible
3992 to supply a time slice value, this pragma may be used for this purpose.
3993 It is ignored if it is used in a system that does not allow this control,
3994 or if it appears in other than the main program unit.
3995 @cindex OpenVMS
3996 Note that the effect of this pragma is identical to the effect of the
3997 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3998
3999 @node Pragma Title
4000 @unnumberedsec Pragma Title
4001 @findex Title
4002 @noindent
4003 Syntax:
4004
4005 @smallexample @c ada
4006 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4007
4008 TITLING_OPTION ::=
4009   [Title    =>] STRING_LITERAL,
4010 | [Subtitle =>] STRING_LITERAL
4011 @end smallexample
4012
4013 @noindent
4014 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4015 pragma used in DEC Ada 83 implementations to provide a title and/or
4016 subtitle for the program listing.  The program listing generated by GNAT
4017 does not have titles or subtitles.
4018
4019 Unlike other pragmas, the full flexibility of named notation is allowed
4020 for this pragma, i.e.@: the parameters may be given in any order if named
4021 notation is used, and named and positional notation can be mixed
4022 following the normal rules for procedure calls in Ada.
4023
4024 @node Pragma Unchecked_Union
4025 @unnumberedsec Pragma Unchecked_Union
4026 @cindex Unions in C
4027 @findex Unchecked_Union
4028 @noindent
4029 Syntax:
4030
4031 @smallexample @c ada
4032 pragma Unchecked_Union (first_subtype_local_NAME);
4033 @end smallexample
4034
4035 @noindent
4036 This pragma is used to specify a representation of a record type that is
4037 equivalent to a C union. It was introduced as a GNAT implementation defined
4038 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4039 pragma, making it language defined, and GNAT fully implements this extended
4040 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4041 details, consult the Ada 2005 Reference Manual, section B.3.3.
4042
4043 @node Pragma Unimplemented_Unit
4044 @unnumberedsec Pragma Unimplemented_Unit
4045 @findex Unimplemented_Unit
4046 @noindent
4047 Syntax:
4048
4049 @smallexample @c ada
4050 pragma Unimplemented_Unit;
4051 @end smallexample
4052
4053 @noindent
4054 If this pragma occurs in a unit that is processed by the compiler, GNAT
4055 aborts with the message @samp{@var{xxx} not implemented}, where
4056 @var{xxx} is the name of the current compilation unit.  This pragma is
4057 intended to allow the compiler to handle unimplemented library units in
4058 a clean manner.
4059
4060 The abort only happens if code is being generated.  Thus you can use
4061 specs of unimplemented packages in syntax or semantic checking mode.
4062
4063 @node Pragma Universal_Aliasing
4064 @unnumberedsec Pragma Universal_Aliasing
4065 @findex Universal_Aliasing
4066 @noindent
4067 Syntax:
4068
4069 @smallexample @c ada
4070 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4071 @end smallexample
4072
4073 @noindent
4074 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4075 declarative part.  The effect is to inhibit strict type-based aliasing
4076 optimization for the given type.  In other words, the effect is as though
4077 access types designating this type were subject to pragma No_Strict_Aliasing.
4078 For a detailed description of the strict aliasing optimization, and the
4079 situations in which it must be suppressed, see section
4080 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4081
4082 @node Pragma Universal_Data
4083 @unnumberedsec Pragma Universal_Data
4084 @findex Universal_Data
4085 @noindent
4086 Syntax:
4087
4088 @smallexample @c ada
4089 pragma Universal_Data [(library_unit_Name)];
4090 @end smallexample
4091
4092 @noindent
4093 This pragma is supported only for the AAMP target and is ignored for
4094 other targets. The pragma specifies that all library-level objects
4095 (Counter 0 data) associated with the library unit are to be accessed
4096 and updated using universal addressing (24-bit addresses for AAMP5)
4097 rather than the default of 16-bit Data Environment (DENV) addressing.
4098 Use of this pragma will generally result in less efficient code for
4099 references to global data associated with the library unit, but
4100 allows such data to be located anywhere in memory. This pragma is
4101 a library unit pragma, but can also be used as a configuration pragma
4102 (including use in the @file{gnat.adc} file). The functionality
4103 of this pragma is also available by applying the -univ switch on the
4104 compilations of units where universal addressing of the data is desired.
4105
4106 @node Pragma Unreferenced
4107 @unnumberedsec Pragma Unreferenced
4108 @findex Unreferenced
4109 @cindex Warnings, unreferenced
4110 @noindent
4111 Syntax:
4112
4113 @smallexample @c ada
4114 pragma Unreferenced (local_NAME @{, local_NAME@});
4115 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4116 @end smallexample
4117
4118 @noindent
4119 This pragma signals that the entities whose names are listed are
4120 deliberately not referenced in the current source unit. This
4121 suppresses warnings about the
4122 entities being unreferenced, and in addition a warning will be
4123 generated if one of these entities is in fact referenced in the
4124 same unit as the pragma (or in the corresponding body, or one
4125 of its subunits).
4126
4127 This is particularly useful for clearly signaling that a particular
4128 parameter is not referenced in some particular subprogram implementation
4129 and that this is deliberate. It can also be useful in the case of
4130 objects declared only for their initialization or finalization side
4131 effects.
4132
4133 If @code{local_NAME} identifies more than one matching homonym in the
4134 current scope, then the entity most recently declared is the one to which
4135 the pragma applies. Note that in the case of accept formals, the pragma
4136 Unreferenced may appear immediately after the keyword @code{do} which
4137 allows the indication of whether or not accept formals are referenced
4138 or not to be given individually for each accept statement.
4139
4140 The left hand side of an assignment does not count as a reference for the
4141 purpose of this pragma. Thus it is fine to assign to an entity for which
4142 pragma Unreferenced is given.
4143
4144 Note that if a warning is desired for all calls to a given subprogram,
4145 regardless of whether they occur in the same unit as the subprogram
4146 declaration, then this pragma should not be used (calls from another
4147 unit would not be flagged); pragma Obsolescent can be used instead
4148 for this purpose, see @xref{Pragma Obsolescent}.
4149
4150 The second form of pragma @code{Unreferenced} is used within a context
4151 clause. In this case the arguments must be unit names of units previously
4152 mentioned in @code{with} clauses (similar to the usage of pragma
4153 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4154 units.
4155
4156 @node Pragma Unreferenced_Objects
4157 @unnumberedsec Pragma Unreferenced_Objects
4158 @findex Unreferenced_Objects
4159 @cindex Warnings, unreferenced
4160 @noindent
4161 Syntax:
4162
4163 @smallexample @c ada
4164 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4165 @end smallexample
4166
4167 @noindent
4168 This pragma signals that for the types or subtypes whose names are
4169 listed, objects which are declared with one of these types or subtypes may
4170 not be referenced, and if no references appear, no warnings are given.
4171
4172 This is particularly useful for objects which are declared solely for their
4173 initialization and finalization effect. Such variables are sometimes referred
4174 to as RAII variables (Resource Acquisition Is Initialization). Using this
4175 pragma on the relevant type (most typically a limited controlled type), the
4176 compiler will automatically suppress unwanted warnings about these variables
4177 not being referenced.
4178
4179 @node Pragma Unreserve_All_Interrupts
4180 @unnumberedsec Pragma Unreserve_All_Interrupts
4181 @findex Unreserve_All_Interrupts
4182 @noindent
4183 Syntax:
4184
4185 @smallexample @c ada
4186 pragma Unreserve_All_Interrupts;
4187 @end smallexample
4188
4189 @noindent
4190 Normally certain interrupts are reserved to the implementation.  Any attempt
4191 to attach an interrupt causes Program_Error to be raised, as described in
4192 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4193 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4194 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4195 interrupt execution.
4196
4197 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4198 a program, then all such interrupts are unreserved.  This allows the
4199 program to handle these interrupts, but disables their standard
4200 functions.  For example, if this pragma is used, then pressing
4201 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4202 a program can then handle the @code{SIGINT} interrupt as it chooses.
4203
4204 For a full list of the interrupts handled in a specific implementation,
4205 see the source code for the specification of @code{Ada.Interrupts.Names} in
4206 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4207 list of interrupts recognized for a given target.  The documentation in
4208 this file also specifies what interrupts are affected by the use of
4209 the @code{Unreserve_All_Interrupts} pragma.
4210
4211 For a more general facility for controlling what interrupts can be
4212 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4213 of the @code{Unreserve_All_Interrupts} pragma.
4214
4215 @node Pragma Unsuppress
4216 @unnumberedsec Pragma Unsuppress
4217 @findex Unsuppress
4218 @noindent
4219 Syntax:
4220
4221 @smallexample @c ada
4222 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4223 @end smallexample
4224
4225 @noindent
4226 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4227 there is no corresponding pragma @code{Suppress} in effect, it has no
4228 effect.  The range of the effect is the same as for pragma
4229 @code{Suppress}.  The meaning of the arguments is identical to that used
4230 in pragma @code{Suppress}.
4231
4232 One important application is to ensure that checks are on in cases where
4233 code depends on the checks for its correct functioning, so that the code
4234 will compile correctly even if the compiler switches are set to suppress
4235 checks.
4236
4237 @node Pragma Use_VADS_Size
4238 @unnumberedsec Pragma Use_VADS_Size
4239 @cindex @code{Size}, VADS compatibility
4240 @findex Use_VADS_Size
4241 @noindent
4242 Syntax:
4243
4244 @smallexample @c ada
4245 pragma Use_VADS_Size;
4246 @end smallexample
4247
4248 @noindent
4249 This is a configuration pragma.  In a unit to which it applies, any use
4250 of the 'Size attribute is automatically interpreted as a use of the
4251 'VADS_Size attribute.  Note that this may result in incorrect semantic
4252 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4253 the handling of existing code which depends on the interpretation of Size
4254 as implemented in the VADS compiler.  See description of the VADS_Size
4255 attribute for further details.
4256
4257 @node Pragma Validity_Checks
4258 @unnumberedsec Pragma Validity_Checks
4259 @findex Validity_Checks
4260 @noindent
4261 Syntax:
4262
4263 @smallexample @c ada
4264 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4265 @end smallexample
4266
4267 @noindent
4268 This pragma is used in conjunction with compiler switches to control the
4269 built-in validity checking provided by GNAT@.  The compiler switches, if set
4270 provide an initial setting for the switches, and this pragma may be used
4271 to modify these settings, or the settings may be provided entirely by
4272 the use of the pragma.  This pragma can be used anywhere that a pragma
4273 is legal, including use as a configuration pragma (including use in
4274 the @file{gnat.adc} file).
4275
4276 The form with a string literal specifies which validity options are to be
4277 activated.  The validity checks are first set to include only the default
4278 reference manual settings, and then a string of letters in the string
4279 specifies the exact set of options required.  The form of this string
4280 is exactly as described for the @code{-gnatVx} compiler switch (see the
4281 GNAT users guide for details).  For example the following two methods
4282 can be used to enable validity checking for mode @code{in} and
4283 @code{in out} subprogram parameters:
4284
4285 @itemize @bullet
4286 @item
4287 @smallexample @c ada
4288 pragma Validity_Checks ("im");
4289 @end smallexample
4290
4291 @item
4292 @smallexample
4293 gcc -c -gnatVim @dots{}
4294 @end smallexample
4295 @end itemize
4296
4297 @noindent
4298 The form ALL_CHECKS activates all standard checks (its use is equivalent
4299 to the use of the @code{gnatva} switch.
4300
4301 The forms with @code{Off} and @code{On}
4302 can be used to temporarily disable validity checks
4303 as shown in the following example:
4304
4305 @smallexample @c ada
4306 @iftex
4307 @leftskip=0cm
4308 @end iftex
4309 pragma Validity_Checks ("c"); -- validity checks for copies
4310 pragma Validity_Checks (Off); -- turn off validity checks
4311 A := B;                       -- B will not be validity checked
4312 pragma Validity_Checks (On);  -- turn validity checks back on
4313 A := C;                       -- C will be validity checked
4314 @end smallexample
4315
4316 @node Pragma Volatile
4317 @unnumberedsec Pragma Volatile
4318 @findex Volatile
4319 @noindent
4320 Syntax:
4321
4322 @smallexample @c ada
4323 pragma Volatile (local_NAME);
4324 @end smallexample
4325
4326 @noindent
4327 This pragma is defined by the Ada Reference Manual, and the GNAT
4328 implementation is fully conformant with this definition.  The reason it
4329 is mentioned in this section is that a pragma of the same name was supplied
4330 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4331 implementation of pragma Volatile is upwards compatible with the
4332 implementation in DEC Ada 83.
4333
4334 @node Pragma Warnings
4335 @unnumberedsec Pragma Warnings
4336 @findex Warnings
4337 @noindent
4338 Syntax:
4339
4340 @smallexample @c ada
4341 pragma Warnings (On | Off);
4342 pragma Warnings (On | Off, local_NAME);
4343 pragma Warnings (static_string_EXPRESSION);
4344 pragma Warnings (On | Off, static_string_EXPRESSION);
4345 @end smallexample
4346
4347 @noindent
4348 Normally warnings are enabled, with the output being controlled by
4349 the command line switch.  Warnings (@code{Off}) turns off generation of
4350 warnings until a Warnings (@code{On}) is encountered or the end of the
4351 current unit.  If generation of warnings is turned off using this
4352 pragma, then no warning messages are output, regardless of the
4353 setting of the command line switches.
4354
4355 The form with a single argument may be used as a configuration pragma.
4356
4357 If the @var{local_NAME} parameter is present, warnings are suppressed for
4358 the specified entity.  This suppression is effective from the point where
4359 it occurs till the end of the extended scope of the variable (similar to
4360 the scope of @code{Suppress}).
4361
4362 The form with a single static_string_EXPRESSION argument provides more precise
4363 control over which warnings are active. The string is a list of letters
4364 specifying which warnings are to be activated and which deactivated. The
4365 code for these letters is the same as the string used in the command
4366 line switch controlling warnings. The following is a brief summary. For
4367 full details see the GNAT Users Guide:
4368
4369 @smallexample
4370 a   turn on all optional warnings (except d,h,l)
4371 A   turn off all optional warnings
4372 b   turn on warnings for bad fixed value (not multiple of small)
4373 B   turn off warnings for bad fixed value (not multiple of small)
4374 c   turn on warnings for constant conditional
4375 C   turn off warnings for constant conditional
4376 d   turn on warnings for implicit dereference
4377 D   turn off warnings for implicit dereference
4378 e   treat all warnings as errors
4379 f   turn on warnings for unreferenced formal
4380 F   turn off warnings for unreferenced formal
4381 g   turn on warnings for unrecognized pragma
4382 G   turn off warnings for unrecognized pragma
4383 h   turn on warnings for hiding variable
4384 H   turn off warnings for hiding variable
4385 i   turn on warnings for implementation unit
4386 I   turn off warnings for implementation unit
4387 j   turn on warnings for obsolescent (annex J) feature
4388 J   turn off warnings for obsolescent (annex J) feature
4389 k   turn on warnings on constant variable
4390 K   turn off warnings on constant variable
4391 l   turn on warnings for missing elaboration pragma
4392 L   turn off warnings for missing elaboration pragma
4393 m   turn on warnings for variable assigned but not read
4394 M   turn off warnings for variable assigned but not read
4395 n   normal warning mode (cancels -gnatws/-gnatwe)
4396 o   turn on warnings for address clause overlay
4397 O   turn off warnings for address clause overlay
4398 p   turn on warnings for ineffective pragma Inline
4399 P   turn off warnings for ineffective pragma Inline
4400 q   turn on warnings for questionable missing parentheses
4401 Q   turn off warnings for questionable missing parentheses
4402 r   turn on warnings for redundant construct
4403 R   turn off warnings for redundant construct
4404 s   suppress all warnings
4405 t   turn on warnings for tracking deleted code
4406 T   turn off warnings for tracking deleted code
4407 u   turn on warnings for unused entity
4408 U   turn off warnings for unused entity
4409 v   turn on warnings for unassigned variable
4410 V   turn off warnings for unassigned variable
4411 w   turn on warnings for wrong low bound assumption
4412 W   turn off warnings for wrong low bound assumption
4413 x   turn on warnings for export/import
4414 X   turn off warnings for export/import
4415 y   turn on warnings for Ada 2005 incompatibility
4416 Y   turn off warnings for Ada 2005 incompatibility
4417 z   turn on size/align warnings for unchecked conversion
4418 Z   turn off size/align warnings for unchecked conversion
4419 @end smallexample
4420
4421 @noindent
4422 The specified warnings will be in effect until the end of the program
4423 or another pragma Warnings is encountered. The effect of the pragma is
4424 cumulative. Initially the set of warnings is the standard default set
4425 as possibly modified by compiler switches. Then each pragma Warning
4426 modifies this set of warnings as specified. This form of the pragma may
4427 also be used as a configuration pragma.
4428
4429 The fourth form, with an On|Off parameter and a string, is used to
4430 control individual messages, based on their text. The string argument
4431 is a pattern that is used to match against the text of individual
4432 warning messages (not including the initial "warnings: " tag).
4433
4434 The pattern may start with an asterisk, which matches otherwise unmatched
4435 characters at the start of the message, and it may also end with an asterisk
4436 which matches otherwise unmatched characters at the end of the message. For
4437 example, the string "*alignment*" could be used to match any warnings about
4438 alignment problems. Within the string, the sequence "*" can be used to match
4439 any sequence of characters enclosed in quotation marks. No other regular
4440 expression notations are permitted. All characters other than asterisk in
4441 these three specific cases are treated as literal characters in the match.
4442
4443 There are two ways to use this pragma. The OFF form can be used as a
4444 configuration pragma. The effect is to suppress all warnings (if any)
4445 that match the pattern string throughout the compilation.
4446
4447 The second usage is to suppress a warning locally, and in this case, two
4448 pragmas must appear in sequence:
4449
4450 @smallexample @c ada
4451 pragma Warnings (Off, Pattern);
4452 .. code where given warning is to be suppressed
4453 pragma Warnings (On, Pattern);
4454 @end smallexample
4455
4456 @noindent
4457 In this usage, the pattern string must match in the Off and On pragmas,
4458 and at least one matching warning must be suppressed.
4459
4460 @node Pragma Weak_External
4461 @unnumberedsec Pragma Weak_External
4462 @findex Weak_External
4463 @noindent
4464 Syntax:
4465
4466 @smallexample @c ada
4467 pragma Weak_External ([Entity =>] local_NAME);
4468 @end smallexample
4469
4470 @noindent
4471 @var{local_NAME} must refer to an object that is declared at the library
4472 level. This pragma specifies that the given entity should be marked as a
4473 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4474 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4475 of a regular symbol, that is to say a symbol that does not have to be
4476 resolved by the linker if used in conjunction with a pragma Import.
4477
4478 When a weak symbol is not resolved by the linker, its address is set to
4479 zero. This is useful in writing interfaces to external modules that may
4480 or may not be linked in the final executable, for example depending on
4481 configuration settings.
4482
4483 If a program references at run time an entity to which this pragma has been
4484 applied, and the corresponding symbol was not resolved at link time, then
4485 the execution of the program is erroneous. It is not erroneous to take the
4486 Address of such an entity, for example to guard potential references,
4487 as shown in the example below.
4488
4489 Some file formats do not support weak symbols so not all target machines
4490 support this pragma.
4491
4492 @smallexample @c ada
4493 --  Example of the use of pragma Weak_External
4494
4495 package External_Module is
4496   key : Integer;
4497   pragma Import (C, key);
4498   pragma Weak_External (key);
4499   function Present return boolean;
4500 end External_Module;
4501
4502 with System; use System;
4503 package body External_Module is
4504   function Present return boolean is
4505   begin
4506     return key'Address /= System.Null_Address;
4507   end Present;
4508 end External_Module;
4509 @end smallexample
4510
4511 @node Pragma Wide_Character_Encoding
4512 @unnumberedsec Pragma Wide_Character_Encoding
4513 @findex Wide_Character_Encoding
4514 @noindent
4515 Syntax:
4516
4517 @smallexample @c ada
4518 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4519 @end smallexample
4520
4521 @noindent
4522 This pragma specifies the wide character encoding to be used in program
4523 source text appearing subsequently. It is a configuration pragma, but may
4524 also be used at any point that a pragma is allowed, and it is permissible
4525 to have more than one such pragma in a file, allowing multiple encodings
4526 to appear within the same file.
4527
4528 The argument can be an identifier or a character literal. In the identifier
4529 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4530 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4531 case it is correspondingly one of the characters h,u,s,e,8,b.
4532
4533 Note that when the pragma is used within a file, it affects only the
4534 encoding within that file, and does not affect withed units, specs,
4535 or subunits.
4536
4537 @node Implementation Defined Attributes
4538 @chapter Implementation Defined Attributes
4539 Ada defines (throughout the Ada reference manual,
4540 summarized in Annex K),
4541 a set of attributes that provide useful additional functionality in all
4542 areas of the language.  These language defined attributes are implemented
4543 in GNAT and work as described in the Ada Reference Manual.
4544
4545 In addition, Ada allows implementations to define additional
4546 attributes whose meaning is defined by the implementation.  GNAT provides
4547 a number of these implementation-dependent attributes which can be used
4548 to extend and enhance the functionality of the compiler.  This section of
4549 the GNAT reference manual describes these additional attributes.
4550
4551 Note that any program using these attributes may not be portable to
4552 other compilers (although GNAT implements this set of attributes on all
4553 platforms).  Therefore if portability to other compilers is an important
4554 consideration, you should minimize the use of these attributes.
4555
4556 @menu
4557 * Abort_Signal::
4558 * Address_Size::
4559 * Asm_Input::
4560 * Asm_Output::
4561 * AST_Entry::
4562 * Bit::
4563 * Bit_Position::
4564 * Code_Address::
4565 * Default_Bit_Order::
4566 * Elaborated::
4567 * Elab_Body::
4568 * Elab_Spec::
4569 * Emax::
4570 * Enum_Rep::
4571 * Epsilon::
4572 * Fixed_Value::
4573 * Has_Access_Values::
4574 * Has_Discriminants::
4575 * Img::
4576 * Integer_Value::
4577 * Large::
4578 * Machine_Size::
4579 * Mantissa::
4580 * Max_Interrupt_Priority::
4581 * Max_Priority::
4582 * Maximum_Alignment::
4583 * Mechanism_Code::
4584 * Null_Parameter::
4585 * Object_Size::
4586 * Passed_By_Reference::
4587 * Range_Length::
4588 * Safe_Emax::
4589 * Safe_Large::
4590 * Small::
4591 * Storage_Unit::
4592 * Stub_Type::
4593 * Target_Name::
4594 * Tick::
4595 * To_Address::
4596 * Type_Class::
4597 * UET_Address::
4598 * Unconstrained_Array::
4599 * Universal_Literal_String::
4600 * Unrestricted_Access::
4601 * VADS_Size::
4602 * Value_Size::
4603 * Wchar_T_Size::
4604 * Word_Size::
4605 @end menu
4606
4607 @node Abort_Signal
4608 @unnumberedsec Abort_Signal
4609 @findex Abort_Signal
4610 @noindent
4611 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4612 prefix) provides the entity for the special exception used to signal
4613 task abort or asynchronous transfer of control.  Normally this attribute
4614 should only be used in the tasking runtime (it is highly peculiar, and
4615 completely outside the normal semantics of Ada, for a user program to
4616 intercept the abort exception).
4617
4618 @node Address_Size
4619 @unnumberedsec Address_Size
4620 @cindex Size of @code{Address}
4621 @findex Address_Size
4622 @noindent
4623 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4624 prefix) is a static constant giving the number of bits in an
4625 @code{Address}. It is the same value as System.Address'Size,
4626 but has the advantage of being static, while a direct
4627 reference to System.Address'Size is non-static because Address
4628 is a private type.
4629
4630 @node Asm_Input
4631 @unnumberedsec Asm_Input
4632 @findex Asm_Input
4633 @noindent
4634 The @code{Asm_Input} attribute denotes a function that takes two
4635 parameters.  The first is a string, the second is an expression of the
4636 type designated by the prefix.  The first (string) argument is required
4637 to be a static expression, and is the constraint for the parameter,
4638 (e.g.@: what kind of register is required).  The second argument is the
4639 value to be used as the input argument.  The possible values for the
4640 constant are the same as those used in the RTL, and are dependent on
4641 the configuration file used to built the GCC back end.
4642 @ref{Machine Code Insertions}
4643
4644 @node Asm_Output
4645 @unnumberedsec Asm_Output
4646 @findex Asm_Output
4647 @noindent
4648 The @code{Asm_Output} attribute denotes a function that takes two
4649 parameters.  The first is a string, the second is the name of a variable
4650 of the type designated by the attribute prefix.  The first (string)
4651 argument is required to be a static expression and designates the
4652 constraint for the parameter (e.g.@: what kind of register is
4653 required).  The second argument is the variable to be updated with the
4654 result.  The possible values for constraint are the same as those used in
4655 the RTL, and are dependent on the configuration file used to build the
4656 GCC back end.  If there are no output operands, then this argument may
4657 either be omitted, or explicitly given as @code{No_Output_Operands}.
4658 @ref{Machine Code Insertions}
4659
4660 @node AST_Entry
4661 @unnumberedsec AST_Entry
4662 @cindex OpenVMS
4663 @findex AST_Entry
4664 @noindent
4665 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4666 the name of an entry, it yields a value of the predefined type AST_Handler
4667 (declared in the predefined package System, as extended by the use of
4668 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4669 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4670 Language Reference Manual}, section 9.12a.
4671
4672 @node Bit
4673 @unnumberedsec Bit
4674 @findex Bit
4675 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4676 offset within the storage unit (byte) that contains the first bit of
4677 storage allocated for the object.  The value of this attribute is of the
4678 type @code{Universal_Integer}, and is always a non-negative number not
4679 exceeding the value of @code{System.Storage_Unit}.
4680
4681 For an object that is a variable or a constant allocated in a register,
4682 the value is zero.  (The use of this attribute does not force the
4683 allocation of a variable to memory).
4684
4685 For an object that is a formal parameter, this attribute applies
4686 to either the matching actual parameter or to a copy of the
4687 matching actual parameter.
4688
4689 For an access object the value is zero.  Note that
4690 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4691 designated object.  Similarly for a record component
4692 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4693 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4694 are subject to index checks.
4695
4696 This attribute is designed to be compatible with the DEC Ada 83 definition
4697 and implementation of the @code{Bit} attribute.
4698
4699 @node Bit_Position
4700 @unnumberedsec Bit_Position
4701 @findex Bit_Position
4702 @noindent
4703 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4704 of the fields of the record type, yields the bit
4705 offset within the record contains the first bit of
4706 storage allocated for the object.  The value of this attribute is of the
4707 type @code{Universal_Integer}.  The value depends only on the field
4708 @var{C} and is independent of the alignment of
4709 the containing record @var{R}.
4710
4711 @node Code_Address
4712 @unnumberedsec Code_Address
4713 @findex Code_Address
4714 @cindex Subprogram address
4715 @cindex Address of subprogram code
4716 @noindent
4717 The @code{'Address}
4718 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4719 intended effect seems to be to provide
4720 an address value which can be used to call the subprogram by means of
4721 an address clause as in the following example:
4722
4723 @smallexample @c ada
4724 procedure K is @dots{}
4725
4726 procedure L;
4727 for L'Address use K'Address;
4728 pragma Import (Ada, L);
4729 @end smallexample
4730
4731 @noindent
4732 A call to @code{L} is then expected to result in a call to @code{K}@.
4733 In Ada 83, where there were no access-to-subprogram values, this was
4734 a common work-around for getting the effect of an indirect call.
4735 GNAT implements the above use of @code{Address} and the technique
4736 illustrated by the example code works correctly.
4737
4738 However, for some purposes, it is useful to have the address of the start
4739 of the generated code for the subprogram.  On some architectures, this is
4740 not necessarily the same as the @code{Address} value described above.
4741 For example, the @code{Address} value may reference a subprogram
4742 descriptor rather than the subprogram itself.
4743
4744 The @code{'Code_Address} attribute, which can only be applied to
4745 subprogram entities, always returns the address of the start of the
4746 generated code of the specified subprogram, which may or may not be
4747 the same value as is returned by the corresponding @code{'Address}
4748 attribute.
4749
4750 @node Default_Bit_Order
4751 @unnumberedsec Default_Bit_Order
4752 @cindex Big endian
4753 @cindex Little endian
4754 @findex Default_Bit_Order
4755 @noindent
4756 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4757 permissible prefix), provides the value @code{System.Default_Bit_Order}
4758 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4759 @code{Low_Order_First}).  This is used to construct the definition of
4760 @code{Default_Bit_Order} in package @code{System}.
4761
4762 @node Elaborated
4763 @unnumberedsec Elaborated
4764 @findex Elaborated
4765 @noindent
4766 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4767 value is a Boolean which indicates whether or not the given unit has been
4768 elaborated.  This attribute is primarily intended for internal use by the
4769 generated code for dynamic elaboration checking, but it can also be used
4770 in user programs.  The value will always be True once elaboration of all
4771 units has been completed.  An exception is for units which need no
4772 elaboration, the value is always False for such units.
4773
4774 @node Elab_Body
4775 @unnumberedsec Elab_Body
4776 @findex Elab_Body
4777 @noindent
4778 This attribute can only be applied to a program unit name.  It returns
4779 the entity for the corresponding elaboration procedure for elaborating
4780 the body of the referenced unit.  This is used in the main generated
4781 elaboration procedure by the binder and is not normally used in any
4782 other context.  However, there may be specialized situations in which it
4783 is useful to be able to call this elaboration procedure from Ada code,
4784 e.g.@: if it is necessary to do selective re-elaboration to fix some
4785 error.
4786
4787 @node Elab_Spec
4788 @unnumberedsec Elab_Spec
4789 @findex Elab_Spec
4790 @noindent
4791 This attribute can only be applied to a program unit name.  It returns
4792 the entity for the corresponding elaboration procedure for elaborating
4793 the specification of the referenced unit.  This is used in the main
4794 generated elaboration procedure by the binder and is not normally used
4795 in any other context.  However, there may be specialized situations in
4796 which it is useful to be able to call this elaboration procedure from
4797 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4798 some error.
4799
4800 @node Emax
4801 @unnumberedsec Emax
4802 @cindex Ada 83 attributes
4803 @findex Emax
4804 @noindent
4805 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4806 the Ada 83 reference manual for an exact description of the semantics of
4807 this attribute.
4808
4809 @node Enum_Rep
4810 @unnumberedsec Enum_Rep
4811 @cindex Representation of enums
4812 @findex Enum_Rep
4813 @noindent
4814 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4815 function with the following spec:
4816
4817 @smallexample @c ada
4818 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4819   return @i{Universal_Integer};
4820 @end smallexample
4821
4822 @noindent
4823 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4824 enumeration type or to a non-overloaded enumeration
4825 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4826 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4827 enumeration literal or object.
4828
4829 The function returns the representation value for the given enumeration
4830 value.  This will be equal to value of the @code{Pos} attribute in the
4831 absence of an enumeration representation clause.  This is a static
4832 attribute (i.e.@: the result is static if the argument is static).
4833
4834 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4835 in which case it simply returns the integer value.  The reason for this
4836 is to allow it to be used for @code{(<>)} discrete formal arguments in
4837 a generic unit that can be instantiated with either enumeration types
4838 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4839 type whose upper bound exceeds the upper bound of the largest signed
4840 integer type, and the argument is a variable, so that the universal
4841 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4842 may raise @code{Constraint_Error}.
4843
4844 @node Epsilon
4845 @unnumberedsec Epsilon
4846 @cindex Ada 83 attributes
4847 @findex Epsilon
4848 @noindent
4849 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4850 the Ada 83 reference manual for an exact description of the semantics of
4851 this attribute.
4852
4853 @node Fixed_Value
4854 @unnumberedsec Fixed_Value
4855 @findex Fixed_Value
4856 @noindent
4857 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4858 function with the following specification:
4859
4860 @smallexample @c ada
4861 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4862   return @var{S};
4863 @end smallexample
4864
4865 @noindent
4866 The value returned is the fixed-point value @var{V} such that
4867
4868 @smallexample @c ada
4869 @var{V} = Arg * @var{S}'Small
4870 @end smallexample
4871
4872 @noindent
4873 The effect is thus similar to first converting the argument to the
4874 integer type used to represent @var{S}, and then doing an unchecked
4875 conversion to the fixed-point type.  The difference is
4876 that there are full range checks, to ensure that the result is in range.
4877 This attribute is primarily intended for use in implementation of the
4878 input-output functions for fixed-point values.
4879
4880 @node Has_Access_Values
4881 @unnumberedsec Has_Access_Values
4882 @cindex Access values, testing for
4883 @findex Has_Access_Values
4884 @noindent
4885 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4886 is a Boolean value which is True if the is an access type, or is a composite
4887 type with a component (at any nesting depth) that is an access type, and is
4888 False otherwise.
4889 The intended use of this attribute is in conjunction with generic
4890 definitions.  If the attribute is applied to a generic private type, it
4891 indicates whether or not the corresponding actual type has access values.
4892
4893 @node Has_Discriminants
4894 @unnumberedsec Has_Discriminants
4895 @cindex Discriminants, testing for
4896 @findex Has_Discriminants
4897 @noindent
4898 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4899 is a Boolean value which is True if the type has discriminants, and False
4900 otherwise.  The intended use of this attribute is in conjunction with generic
4901 definitions.  If the attribute is applied to a generic private type, it
4902 indicates whether or not the corresponding actual type has discriminants.
4903
4904 @node Img
4905 @unnumberedsec Img
4906 @findex Img
4907 @noindent
4908 The @code{Img} attribute differs from @code{Image} in that it may be
4909 applied to objects as well as types, in which case it gives the
4910 @code{Image} for the subtype of the object.  This is convenient for
4911 debugging:
4912
4913 @smallexample @c ada
4914 Put_Line ("X = " & X'Img);
4915 @end smallexample
4916
4917 @noindent
4918 has the same meaning as the more verbose:
4919
4920 @smallexample @c ada
4921 Put_Line ("X = " & @var{T}'Image (X));
4922 @end smallexample
4923
4924 @noindent
4925 where @var{T} is the (sub)type of the object @code{X}.
4926
4927 @node Integer_Value
4928 @unnumberedsec Integer_Value
4929 @findex Integer_Value
4930 @noindent
4931 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4932 function with the following spec:
4933
4934 @smallexample @c ada
4935 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4936   return @var{S};
4937 @end smallexample
4938
4939 @noindent
4940 The value returned is the integer value @var{V}, such that
4941
4942 @smallexample @c ada
4943 Arg = @var{V} * @var{T}'Small
4944 @end smallexample
4945
4946 @noindent
4947 where @var{T} is the type of @code{Arg}.
4948 The effect is thus similar to first doing an unchecked conversion from
4949 the fixed-point type to its corresponding implementation type, and then
4950 converting the result to the target integer type.  The difference is
4951 that there are full range checks, to ensure that the result is in range.
4952 This attribute is primarily intended for use in implementation of the
4953 standard input-output functions for fixed-point values.
4954
4955 @node Large
4956 @unnumberedsec Large
4957 @cindex Ada 83 attributes
4958 @findex Large
4959 @noindent
4960 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4961 the Ada 83 reference manual for an exact description of the semantics of
4962 this attribute.
4963
4964 @node Machine_Size
4965 @unnumberedsec Machine_Size
4966 @findex Machine_Size
4967 @noindent
4968 This attribute is identical to the @code{Object_Size} attribute.  It is
4969 provided for compatibility with the DEC Ada 83 attribute of this name.
4970
4971 @node Mantissa
4972 @unnumberedsec Mantissa
4973 @cindex Ada 83 attributes
4974 @findex Mantissa
4975 @noindent
4976 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4977 the Ada 83 reference manual for an exact description of the semantics of
4978 this attribute.
4979
4980 @node Max_Interrupt_Priority
4981 @unnumberedsec Max_Interrupt_Priority
4982 @cindex Interrupt priority, maximum
4983 @findex Max_Interrupt_Priority
4984 @noindent
4985 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4986 permissible prefix), provides the same value as
4987 @code{System.Max_Interrupt_Priority}.
4988
4989 @node Max_Priority
4990 @unnumberedsec Max_Priority
4991 @cindex Priority, maximum
4992 @findex Max_Priority
4993 @noindent
4994 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4995 prefix) provides the same value as @code{System.Max_Priority}.
4996
4997 @node Maximum_Alignment
4998 @unnumberedsec Maximum_Alignment
4999 @cindex Alignment, maximum
5000 @findex Maximum_Alignment
5001 @noindent
5002 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5003 permissible prefix) provides the maximum useful alignment value for the
5004 target.  This is a static value that can be used to specify the alignment
5005 for an object, guaranteeing that it is properly aligned in all
5006 cases.
5007
5008 @node Mechanism_Code
5009 @unnumberedsec Mechanism_Code
5010 @cindex Return values, passing mechanism
5011 @cindex Parameters, passing mechanism
5012 @findex Mechanism_Code
5013 @noindent
5014 @code{@var{function}'Mechanism_Code} yields an integer code for the
5015 mechanism used for the result of function, and
5016 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5017 used for formal parameter number @var{n} (a static integer value with 1
5018 meaning the first parameter) of @var{subprogram}.  The code returned is:
5019
5020 @table @asis
5021 @item 1
5022 by copy (value)
5023 @item 2
5024 by reference
5025 @item 3
5026 by descriptor (default descriptor class)
5027 @item 4
5028 by descriptor (UBS: unaligned bit string)
5029 @item 5
5030 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5031 @item 6
5032 by descriptor (UBA: unaligned bit array)
5033 @item 7
5034 by descriptor (S: string, also scalar access type parameter)
5035 @item 8
5036 by descriptor (SB: string with arbitrary bounds)
5037 @item 9
5038 by descriptor (A: contiguous array)
5039 @item 10
5040 by descriptor (NCA: non-contiguous array)
5041 @end table
5042
5043 @noindent
5044 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5045 @cindex OpenVMS
5046
5047 @node Null_Parameter
5048 @unnumberedsec Null_Parameter
5049 @cindex Zero address, passing
5050 @findex Null_Parameter
5051 @noindent
5052 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5053 type or subtype @var{T} allocated at machine address zero.  The attribute
5054 is allowed only as the default expression of a formal parameter, or as
5055 an actual expression of a subprogram call.  In either case, the
5056 subprogram must be imported.
5057
5058 The identity of the object is represented by the address zero in the
5059 argument list, independent of the passing mechanism (explicit or
5060 default).
5061
5062 This capability is needed to specify that a zero address should be
5063 passed for a record or other composite object passed by reference.
5064 There is no way of indicating this without the @code{Null_Parameter}
5065 attribute.
5066
5067 @node Object_Size
5068 @unnumberedsec Object_Size
5069 @cindex Size, used for objects
5070 @findex Object_Size
5071 @noindent
5072 The size of an object is not necessarily the same as the size of the type
5073 of an object.  This is because by default object sizes are increased to be
5074 a multiple of the alignment of the object.  For example,
5075 @code{Natural'Size} is
5076 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5077 Similarly, a record containing an integer and a character:
5078
5079 @smallexample @c ada
5080 type Rec is record
5081    I : Integer;
5082    C : Character;
5083 end record;
5084 @end smallexample
5085
5086 @noindent
5087 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5088 alignment will be 4, because of the
5089 integer field, and so the default size of record objects for this type
5090 will be 64 (8 bytes).
5091
5092 The @code{@var{type}'Object_Size} attribute
5093 has been added to GNAT to allow the
5094 default object size of a type to be easily determined.  For example,
5095 @code{Natural'Object_Size} is 32, and
5096 @code{Rec'Object_Size} (for the record type in the above example) will be
5097 64.  Note also that, unlike the situation with the
5098 @code{Size} attribute as defined in the Ada RM, the
5099 @code{Object_Size} attribute can be specified individually
5100 for different subtypes.  For example:
5101
5102 @smallexample @c ada
5103 type R is new Integer;
5104 subtype R1 is R range 1 .. 10;
5105 subtype R2 is R range 1 .. 10;
5106 for R2'Object_Size use 8;
5107 @end smallexample
5108
5109 @noindent
5110 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5111 32 since the default object size for a subtype is the same as the object size
5112 for the parent subtype.  This means that objects of type @code{R}
5113 or @code{R1} will
5114 by default be 32 bits (four bytes).  But objects of type
5115 @code{R2} will be only
5116 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5117
5118 Although @code{Object_Size} does properly reflect the default object size
5119 value, it is not necessarily the case that all objects will be of this size
5120 in a case where it is not specified explicitly. The compiler is free to
5121 increase the size and alignment of stand alone objects to improve efficiency
5122 of the generated code and sometimes does so in the case of large composite
5123 objects. If the size of a stand alone object is critical to the
5124 application, it should be specified explicitly.
5125
5126 @node Passed_By_Reference
5127 @unnumberedsec Passed_By_Reference
5128 @cindex Parameters, when passed by reference
5129 @findex Passed_By_Reference
5130 @noindent
5131 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5132 a value of type @code{Boolean} value that is @code{True} if the type is
5133 normally passed by reference and @code{False} if the type is normally
5134 passed by copy in calls.  For scalar types, the result is always @code{False}
5135 and is static.  For non-scalar types, the result is non-static.
5136
5137 @node Range_Length
5138 @unnumberedsec Range_Length
5139 @findex Range_Length
5140 @noindent
5141 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5142 the number of values represented by the subtype (zero for a null
5143 range).  The result is static for static subtypes.  @code{Range_Length}
5144 applied to the index subtype of a one dimensional array always gives the
5145 same result as @code{Range} applied to the array itself.
5146
5147 @node Safe_Emax
5148 @unnumberedsec Safe_Emax
5149 @cindex Ada 83 attributes
5150 @findex Safe_Emax
5151 @noindent
5152 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5153 the Ada 83 reference manual for an exact description of the semantics of
5154 this attribute.
5155
5156 @node Safe_Large
5157 @unnumberedsec Safe_Large
5158 @cindex Ada 83 attributes
5159 @findex Safe_Large
5160 @noindent
5161 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5162 the Ada 83 reference manual for an exact description of the semantics of
5163 this attribute.
5164
5165 @node Small
5166 @unnumberedsec Small
5167 @cindex Ada 83 attributes
5168 @findex Small
5169 @noindent
5170 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5171 fixed-point types.
5172 GNAT also allows this attribute to be applied to floating-point types
5173 for compatibility with Ada 83.  See
5174 the Ada 83 reference manual for an exact description of the semantics of
5175 this attribute when applied to floating-point types.
5176
5177 @node Storage_Unit
5178 @unnumberedsec Storage_Unit
5179 @findex Storage_Unit
5180 @noindent
5181 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5182 prefix) provides the same value as @code{System.Storage_Unit}.
5183
5184 @node Stub_Type
5185 @unnumberedsec Stub_Type
5186 @findex Stub_Type
5187 @noindent
5188 The GNAT implementation of remote access-to-classwide types is
5189 organized as described in AARM section E.4 (20.t): a value of an RACW type
5190 (designating a remote object) is represented as a normal access
5191 value, pointing to a "stub" object which in turn contains the
5192 necessary information to contact the designated remote object. A
5193 call on any dispatching operation of such a stub object does the
5194 remote call, if necessary, using the information in the stub object
5195 to locate the target partition, etc.
5196
5197 For a prefix @code{T} that denotes a remote access-to-classwide type,
5198 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5199
5200 By construction, the layout of @code{T'Stub_Type} is identical to that of
5201 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5202 unit @code{System.Partition_Interface}. Use of this attribute will create
5203 an implicit dependency on this unit.
5204
5205 @node Target_Name
5206 @unnumberedsec Target_Name
5207 @findex Target_Name
5208 @noindent
5209 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5210 prefix) provides a static string value that identifies the target
5211 for the current compilation. For GCC implementations, this is the
5212 standard gcc target name without the terminating slash (for
5213 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5214
5215 @node Tick
5216 @unnumberedsec Tick
5217 @findex Tick
5218 @noindent
5219 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5220 provides the same value as @code{System.Tick},
5221
5222 @node To_Address
5223 @unnumberedsec To_Address
5224 @findex To_Address
5225 @noindent
5226 The @code{System'To_Address}
5227 (@code{System} is the only permissible prefix)
5228 denotes a function identical to
5229 @code{System.Storage_Elements.To_Address} except that
5230 it is a static attribute.  This means that if its argument is
5231 a static expression, then the result of the attribute is a
5232 static expression.  The result is that such an expression can be
5233 used in contexts (e.g.@: preelaborable packages) which require a
5234 static expression and where the function call could not be used
5235 (since the function call is always non-static, even if its
5236 argument is static).
5237
5238 @node Type_Class
5239 @unnumberedsec Type_Class
5240 @findex Type_Class
5241 @noindent
5242 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5243 the value of the type class for the full type of @var{type}.  If
5244 @var{type} is a generic formal type, the value is the value for the
5245 corresponding actual subtype.  The value of this attribute is of type
5246 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5247
5248 @smallexample @c ada
5249   type Type_Class is
5250     (Type_Class_Enumeration,
5251      Type_Class_Integer,
5252      Type_Class_Fixed_Point,
5253      Type_Class_Floating_Point,
5254      Type_Class_Array,
5255      Type_Class_Record,
5256      Type_Class_Access,
5257      Type_Class_Task,
5258      Type_Class_Address);
5259 @end smallexample
5260
5261 @noindent
5262 Protected types yield the value @code{Type_Class_Task}, which thus
5263 applies to all concurrent types.  This attribute is designed to
5264 be compatible with the DEC Ada 83 attribute of the same name.
5265
5266 @node UET_Address
5267 @unnumberedsec UET_Address
5268 @findex UET_Address
5269 @noindent
5270 The @code{UET_Address} attribute can only be used for a prefix which
5271 denotes a library package.  It yields the address of the unit exception
5272 table when zero cost exception handling is used.  This attribute is
5273 intended only for use within the GNAT implementation.  See the unit
5274 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5275 for details on how this attribute is used in the implementation.
5276
5277 @node Unconstrained_Array
5278 @unnumberedsec Unconstrained_Array
5279 @findex Unconstrained_Array
5280 @noindent
5281 The @code{Unconstrained_Array} attribute can be used with a prefix that
5282 denotes any type or subtype. It is a static attribute that yields
5283 @code{True} if the prefix designates an unconstrained array,
5284 and @code{False} otherwise. In a generic instance, the result is
5285 still static, and yields the result of applying this test to the
5286 generic actual.
5287
5288 @node Universal_Literal_String
5289 @unnumberedsec Universal_Literal_String
5290 @cindex Named numbers, representation of
5291 @findex Universal_Literal_String
5292 @noindent
5293 The prefix of @code{Universal_Literal_String} must be a named
5294 number.  The static result is the string consisting of the characters of
5295 the number as defined in the original source.  This allows the user
5296 program to access the actual text of named numbers without intermediate
5297 conversions and without the need to enclose the strings in quotes (which
5298 would preclude their use as numbers).  This is used internally for the
5299 construction of values of the floating-point attributes from the file
5300 @file{ttypef.ads}, but may also be used by user programs.
5301
5302 For example, the following program prints the first 50 digits of pi:
5303
5304 @smallexample @c ada
5305 with Text_IO; use Text_IO;
5306 with Ada.Numerics;
5307 procedure Pi is
5308 begin
5309    Put (Ada.Numerics.Pi'Universal_Literal_String);
5310 end;
5311 @end smallexample
5312
5313 @node Unrestricted_Access
5314 @unnumberedsec Unrestricted_Access
5315 @cindex @code{Access}, unrestricted
5316 @findex Unrestricted_Access
5317 @noindent
5318 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5319 except that all accessibility and aliased view checks are omitted.  This
5320 is a user-beware attribute.  It is similar to
5321 @code{Address}, for which it is a desirable replacement where the value
5322 desired is an access type.  In other words, its effect is identical to
5323 first applying the @code{Address} attribute and then doing an unchecked
5324 conversion to a desired access type.  In GNAT, but not necessarily in
5325 other implementations, the use of static chains for inner level
5326 subprograms means that @code{Unrestricted_Access} applied to a
5327 subprogram yields a value that can be called as long as the subprogram
5328 is in scope (normal Ada accessibility rules restrict this usage).
5329
5330 It is possible to use @code{Unrestricted_Access} for any type, but care
5331 must be exercised if it is used to create pointers to unconstrained
5332 objects. In this case, the resulting pointer has the same scope as the
5333 context of the attribute, and may not be returned to some enclosing
5334 scope. For instance, a function cannot use @code{Unrestricted_Access}
5335 to create a unconstrained pointer and then return that value to the
5336 caller.
5337
5338 @node VADS_Size
5339 @unnumberedsec VADS_Size
5340 @cindex @code{Size}, VADS compatibility
5341 @findex VADS_Size
5342 @noindent
5343 The @code{'VADS_Size} attribute is intended to make it easier to port
5344 legacy code which relies on the semantics of @code{'Size} as implemented
5345 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5346 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5347 to a predefined or other primitive type with no Size clause yields the
5348 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5349 typical machines).  In addition @code{'VADS_Size} applied to an object
5350 gives the result that would be obtained by applying the attribute to
5351 the corresponding type.
5352
5353 @node Value_Size
5354 @unnumberedsec Value_Size
5355 @cindex @code{Size}, setting for not-first subtype
5356 @findex Value_Size
5357 @code{@var{type}'Value_Size} is the number of bits required to represent
5358 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5359 but, unlike @code{Size}, may be set for non-first subtypes.
5360
5361 @node Wchar_T_Size
5362 @unnumberedsec Wchar_T_Size
5363 @findex Wchar_T_Size
5364 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5365 prefix) provides the size in bits of the C @code{wchar_t} type
5366 primarily for constructing the definition of this type in
5367 package @code{Interfaces.C}.
5368
5369 @node Word_Size
5370 @unnumberedsec Word_Size
5371 @findex Word_Size
5372 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5373 prefix) provides the value @code{System.Word_Size}.
5374
5375 @c ------------------------
5376 @node Implementation Advice
5377 @chapter Implementation Advice
5378 @noindent
5379 The main text of the Ada Reference Manual describes the required
5380 behavior of all Ada compilers, and the GNAT compiler conforms to
5381 these requirements.
5382
5383 In addition, there are sections throughout the Ada Reference Manual headed
5384 by the phrase ``Implementation advice''.  These sections are not normative,
5385 i.e., they do not specify requirements that all compilers must
5386 follow.  Rather they provide advice on generally desirable behavior.  You
5387 may wonder why they are not requirements.  The most typical answer is
5388 that they describe behavior that seems generally desirable, but cannot
5389 be provided on all systems, or which may be undesirable on some systems.
5390
5391 As far as practical, GNAT follows the implementation advice sections in
5392 the Ada Reference Manual.  This chapter contains a table giving the
5393 reference manual section number, paragraph number and several keywords
5394 for each advice.  Each entry consists of the text of the advice followed
5395 by the GNAT interpretation of this advice.  Most often, this simply says
5396 ``followed'', which means that GNAT follows the advice.  However, in a
5397 number of cases, GNAT deliberately deviates from this advice, in which
5398 case the text describes what GNAT does and why.
5399
5400 @cindex Error detection
5401 @unnumberedsec 1.1.3(20): Error Detection
5402 @sp 1
5403 @cartouche
5404 If an implementation detects the use of an unsupported Specialized Needs
5405 Annex feature at run time, it should raise @code{Program_Error} if
5406 feasible.
5407 @end cartouche
5408 Not relevant.  All specialized needs annex features are either supported,
5409 or diagnosed at compile time.
5410
5411 @cindex Child Units
5412 @unnumberedsec 1.1.3(31): Child Units
5413 @sp 1
5414 @cartouche
5415 If an implementation wishes to provide implementation-defined
5416 extensions to the functionality of a language-defined library unit, it
5417 should normally do so by adding children to the library unit.
5418 @end cartouche
5419 Followed.
5420
5421 @cindex Bounded errors
5422 @unnumberedsec 1.1.5(12): Bounded Errors
5423 @sp 1
5424 @cartouche
5425 If an implementation detects a bounded error or erroneous
5426 execution, it should raise @code{Program_Error}.
5427 @end cartouche
5428 Followed in all cases in which the implementation detects a bounded
5429 error or erroneous execution.  Not all such situations are detected at
5430 runtime.
5431
5432 @cindex Pragmas
5433 @unnumberedsec 2.8(16): Pragmas
5434 @sp 1
5435 @cartouche
5436 Normally, implementation-defined pragmas should have no semantic effect
5437 for error-free programs; that is, if the implementation-defined pragmas
5438 are removed from a working program, the program should still be legal,
5439 and should still have the same semantics.
5440 @end cartouche
5441 The following implementation defined pragmas are exceptions to this
5442 rule:
5443
5444 @table @code
5445 @item Abort_Defer
5446 Affects semantics
5447 @item Ada_83
5448 Affects legality
5449 @item Assert
5450 Affects semantics
5451 @item CPP_Class
5452 Affects semantics
5453 @item CPP_Constructor
5454 Affects semantics
5455 @item Debug
5456 Affects semantics
5457 @item Interface_Name
5458 Affects semantics
5459 @item Machine_Attribute
5460 Affects semantics
5461 @item Unimplemented_Unit
5462 Affects legality
5463 @item Unchecked_Union
5464 Affects semantics
5465 @end table
5466
5467 @noindent
5468 In each of the above cases, it is essential to the purpose of the pragma
5469 that this advice not be followed.  For details see the separate section
5470 on implementation defined pragmas.
5471
5472 @unnumberedsec 2.8(17-19): Pragmas
5473 @sp 1
5474 @cartouche
5475 Normally, an implementation should not define pragmas that can
5476 make an illegal program legal, except as follows:
5477 @end cartouche
5478 @sp 1
5479 @cartouche
5480 A pragma used to complete a declaration, such as a pragma @code{Import};
5481 @end cartouche
5482 @sp 1
5483 @cartouche
5484 A pragma used to configure the environment by adding, removing, or
5485 replacing @code{library_items}.
5486 @end cartouche
5487 See response to paragraph 16 of this same section.
5488
5489 @cindex Character Sets
5490 @cindex Alternative Character Sets
5491 @unnumberedsec 3.5.2(5): Alternative Character Sets
5492 @sp 1
5493 @cartouche
5494 If an implementation supports a mode with alternative interpretations
5495 for @code{Character} and @code{Wide_Character}, the set of graphic
5496 characters of @code{Character} should nevertheless remain a proper
5497 subset of the set of graphic characters of @code{Wide_Character}.  Any
5498 character set ``localizations'' should be reflected in the results of
5499 the subprograms defined in the language-defined package
5500 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5501 an alternative interpretation of @code{Character}, the implementation should
5502 also support a corresponding change in what is a legal
5503 @code{identifier_letter}.
5504 @end cartouche
5505 Not all wide character modes follow this advice, in particular the JIS
5506 and IEC modes reflect standard usage in Japan, and in these encoding,
5507 the upper half of the Latin-1 set is not part of the wide-character
5508 subset, since the most significant bit is used for wide character
5509 encoding.  However, this only applies to the external forms.  Internally
5510 there is no such restriction.
5511
5512 @cindex Integer types
5513 @unnumberedsec 3.5.4(28): Integer Types
5514
5515 @sp 1
5516 @cartouche
5517 An implementation should support @code{Long_Integer} in addition to
5518 @code{Integer} if the target machine supports 32-bit (or longer)
5519 arithmetic.  No other named integer subtypes are recommended for package
5520 @code{Standard}.  Instead, appropriate named integer subtypes should be
5521 provided in the library package @code{Interfaces} (see B.2).
5522 @end cartouche
5523 @code{Long_Integer} is supported.  Other standard integer types are supported
5524 so this advice is not fully followed.  These types
5525 are supported for convenient interface to C, and so that all hardware
5526 types of the machine are easily available.
5527 @unnumberedsec 3.5.4(29): Integer Types
5528
5529 @sp 1
5530 @cartouche
5531 An implementation for a two's complement machine should support
5532 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5533 implementation should support a non-binary modules up to @code{Integer'Last}.
5534 @end cartouche
5535 Followed.
5536
5537 @cindex Enumeration values
5538 @unnumberedsec 3.5.5(8): Enumeration Values
5539 @sp 1
5540 @cartouche
5541 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5542 subtype, if the value of the operand does not correspond to the internal
5543 code for any enumeration literal of its type (perhaps due to an
5544 un-initialized variable), then the implementation should raise
5545 @code{Program_Error}.  This is particularly important for enumeration
5546 types with noncontiguous internal codes specified by an
5547 enumeration_representation_clause.
5548 @end cartouche
5549 Followed.
5550
5551 @cindex Float types
5552 @unnumberedsec 3.5.7(17): Float Types
5553 @sp 1
5554 @cartouche
5555 An implementation should support @code{Long_Float} in addition to
5556 @code{Float} if the target machine supports 11 or more digits of
5557 precision.  No other named floating point subtypes are recommended for
5558 package @code{Standard}.  Instead, appropriate named floating point subtypes
5559 should be provided in the library package @code{Interfaces} (see B.2).
5560 @end cartouche
5561 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5562 former provides improved compatibility with other implementations
5563 supporting this type.  The latter corresponds to the highest precision
5564 floating-point type supported by the hardware.  On most machines, this
5565 will be the same as @code{Long_Float}, but on some machines, it will
5566 correspond to the IEEE extended form.  The notable case is all ia32
5567 (x86) implementations, where @code{Long_Long_Float} corresponds to
5568 the 80-bit extended precision format supported in hardware on this
5569 processor.  Note that the 128-bit format on SPARC is not supported,
5570 since this is a software rather than a hardware format.
5571
5572 @cindex Multidimensional arrays
5573 @cindex Arrays, multidimensional
5574 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5575 @sp 1
5576 @cartouche
5577 An implementation should normally represent multidimensional arrays in
5578 row-major order, consistent with the notation used for multidimensional
5579 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5580 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5581 column-major order should be used instead (see B.5, ``Interfacing with
5582 Fortran'').
5583 @end cartouche
5584 Followed.
5585
5586 @findex Duration'Small
5587 @unnumberedsec 9.6(30-31): Duration'Small
5588 @sp 1
5589 @cartouche
5590 Whenever possible in an implementation, the value of @code{Duration'Small}
5591 should be no greater than 100 microseconds.
5592 @end cartouche
5593 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5594
5595 @sp 1
5596 @cartouche
5597 The time base for @code{delay_relative_statements} should be monotonic;
5598 it need not be the same time base as used for @code{Calendar.Clock}.
5599 @end cartouche
5600 Followed.
5601
5602 @unnumberedsec 10.2.1(12): Consistent Representation
5603 @sp 1
5604 @cartouche
5605 In an implementation, a type declared in a pre-elaborated package should
5606 have the same representation in every elaboration of a given version of
5607 the package, whether the elaborations occur in distinct executions of
5608 the same program, or in executions of distinct programs or partitions
5609 that include the given version.
5610 @end cartouche
5611 Followed, except in the case of tagged types.  Tagged types involve
5612 implicit pointers to a local copy of a dispatch table, and these pointers
5613 have representations which thus depend on a particular elaboration of the
5614 package.  It is not easy to see how it would be possible to follow this
5615 advice without severely impacting efficiency of execution.
5616
5617 @cindex Exception information
5618 @unnumberedsec 11.4.1(19): Exception Information
5619 @sp 1
5620 @cartouche
5621 @code{Exception_Message} by default and @code{Exception_Information}
5622 should produce information useful for
5623 debugging.  @code{Exception_Message} should be short, about one
5624 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5625 should not include the
5626 @code{Exception_Name}.  @code{Exception_Information} should include both
5627 the @code{Exception_Name} and the @code{Exception_Message}.
5628 @end cartouche
5629 Followed.  For each exception that doesn't have a specified
5630 @code{Exception_Message}, the compiler generates one containing the location
5631 of the raise statement.  This location has the form ``file:line'', where
5632 file is the short file name (without path information) and line is the line
5633 number in the file.  Note that in the case of the Zero Cost Exception
5634 mechanism, these messages become redundant with the Exception_Information that
5635 contains a full backtrace of the calling sequence, so they are disabled.
5636 To disable explicitly the generation of the source location message, use the
5637 Pragma @code{Discard_Names}.
5638
5639 @cindex Suppression of checks
5640 @cindex Checks, suppression of
5641 @unnumberedsec 11.5(28): Suppression of Checks
5642 @sp 1
5643 @cartouche
5644 The implementation should minimize the code executed for checks that
5645 have been suppressed.
5646 @end cartouche
5647 Followed.
5648
5649 @cindex Representation clauses
5650 @unnumberedsec 13.1 (21-24): Representation Clauses
5651 @sp 1
5652 @cartouche
5653 The recommended level of support for all representation items is
5654 qualified as follows:
5655 @end cartouche
5656 @sp 1
5657 @cartouche
5658 An implementation need not support representation items containing
5659 non-static expressions, except that an implementation should support a
5660 representation item for a given entity if each non-static expression in
5661 the representation item is a name that statically denotes a constant
5662 declared before the entity.
5663 @end cartouche
5664 Followed.  In fact, GNAT goes beyond the recommended level of support
5665 by allowing nonstatic expressions in some representation clauses even
5666 without the need to declare constants initialized with the values of
5667 such expressions.
5668 For example:
5669
5670 @smallexample @c ada
5671   X : Integer;
5672   Y : Float;
5673   for Y'Address use X'Address;>>
5674 @end smallexample
5675
5676
5677 @sp 1
5678 @cartouche
5679 An implementation need not support a specification for the @code{Size}
5680 for a given composite subtype, nor the size or storage place for an
5681 object (including a component) of a given composite subtype, unless the
5682 constraints on the subtype and its composite subcomponents (if any) are
5683 all static constraints.
5684 @end cartouche
5685 Followed.  Size Clauses are not permitted on non-static components, as
5686 described above.
5687
5688 @sp 1
5689 @cartouche
5690 An aliased component, or a component whose type is by-reference, should
5691 always be allocated at an addressable location.
5692 @end cartouche
5693 Followed.
5694
5695 @cindex Packed types
5696 @unnumberedsec 13.2(6-8): Packed Types
5697 @sp 1
5698 @cartouche
5699 If a type is packed, then the implementation should try to minimize
5700 storage allocated to objects of the type, possibly at the expense of
5701 speed of accessing components, subject to reasonable complexity in
5702 addressing calculations.
5703 @end cartouche
5704 @sp 1
5705 @cartouche
5706 The recommended level of support pragma @code{Pack} is:
5707
5708 For a packed record type, the components should be packed as tightly as
5709 possible subject to the Sizes of the component subtypes, and subject to
5710 any @code{record_representation_clause} that applies to the type; the
5711 implementation may, but need not, reorder components or cross aligned
5712 word boundaries to improve the packing.  A component whose @code{Size} is
5713 greater than the word size may be allocated an integral number of words.
5714 @end cartouche
5715 Followed.  Tight packing of arrays is supported for all component sizes
5716 up to 64-bits. If the array component size is 1 (that is to say, if
5717 the component is a boolean type or an enumeration type with two values)
5718 then values of the type are implicitly initialized to zero. This
5719 happens both for objects of the packed type, and for objects that have a
5720 subcomponent of the packed type.
5721
5722 @sp 1
5723 @cartouche
5724 An implementation should support Address clauses for imported
5725 subprograms.
5726 @end cartouche
5727 Followed.
5728 @cindex @code{Address} clauses
5729 @unnumberedsec 13.3(14-19): Address Clauses
5730
5731 @sp 1
5732 @cartouche
5733 For an array @var{X}, @code{@var{X}'Address} should point at the first
5734 component of the array, and not at the array bounds.
5735 @end cartouche
5736 Followed.
5737
5738 @sp 1
5739 @cartouche
5740 The recommended level of support for the @code{Address} attribute is:
5741
5742 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5743 object that is aliased or of a by-reference type, or is an entity whose
5744 @code{Address} has been specified.
5745 @end cartouche
5746 Followed.  A valid address will be produced even if none of those
5747 conditions have been met.  If necessary, the object is forced into
5748 memory to ensure the address is valid.
5749
5750 @sp 1
5751 @cartouche
5752 An implementation should support @code{Address} clauses for imported
5753 subprograms.
5754 @end cartouche
5755 Followed.
5756
5757 @sp 1
5758 @cartouche
5759 Objects (including subcomponents) that are aliased or of a by-reference
5760 type should be allocated on storage element boundaries.
5761 @end cartouche
5762 Followed.
5763
5764 @sp 1
5765 @cartouche
5766 If the @code{Address} of an object is specified, or it is imported or exported,
5767 then the implementation should not perform optimizations based on
5768 assumptions of no aliases.
5769 @end cartouche
5770 Followed.
5771
5772 @cindex @code{Alignment} clauses
5773 @unnumberedsec 13.3(29-35): Alignment Clauses
5774 @sp 1
5775 @cartouche
5776 The recommended level of support for the @code{Alignment} attribute for
5777 subtypes is:
5778
5779 An implementation should support specified Alignments that are factors
5780 and multiples of the number of storage elements per word, subject to the
5781 following:
5782 @end cartouche
5783 Followed.
5784
5785 @sp 1
5786 @cartouche
5787 An implementation need not support specified @code{Alignment}s for
5788 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5789 loaded and stored by available machine instructions.
5790 @end cartouche
5791 Followed.
5792
5793 @sp 1
5794 @cartouche
5795 An implementation need not support specified @code{Alignment}s that are
5796 greater than the maximum @code{Alignment} the implementation ever returns by
5797 default.
5798 @end cartouche
5799 Followed.
5800
5801 @sp 1
5802 @cartouche
5803 The recommended level of support for the @code{Alignment} attribute for
5804 objects is:
5805
5806 Same as above, for subtypes, but in addition:
5807 @end cartouche
5808 Followed.
5809
5810 @sp 1
5811 @cartouche
5812 For stand-alone library-level objects of statically constrained
5813 subtypes, the implementation should support all @code{Alignment}s
5814 supported by the target linker.  For example, page alignment is likely to
5815 be supported for such objects, but not for subtypes.
5816 @end cartouche
5817 Followed.
5818
5819 @cindex @code{Size} clauses
5820 @unnumberedsec 13.3(42-43): Size Clauses
5821 @sp 1
5822 @cartouche
5823 The recommended level of support for the @code{Size} attribute of
5824 objects is:
5825
5826 A @code{Size} clause should be supported for an object if the specified
5827 @code{Size} is at least as large as its subtype's @code{Size}, and
5828 corresponds to a size in storage elements that is a multiple of the
5829 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5830 @end cartouche
5831 Followed.
5832
5833 @unnumberedsec 13.3(50-56): Size Clauses
5834 @sp 1
5835 @cartouche
5836 If the @code{Size} of a subtype is specified, and allows for efficient
5837 independent addressability (see 9.10) on the target architecture, then
5838 the @code{Size} of the following objects of the subtype should equal the
5839 @code{Size} of the subtype:
5840
5841 Aliased objects (including components).
5842 @end cartouche
5843 Followed.
5844
5845 @sp 1
5846 @cartouche
5847 @code{Size} clause on a composite subtype should not affect the
5848 internal layout of components.
5849 @end cartouche
5850 Followed.
5851
5852 @sp 1
5853 @cartouche
5854 The recommended level of support for the @code{Size} attribute of subtypes is:
5855 @end cartouche
5856 @sp 1
5857 @cartouche
5858 The @code{Size} (if not specified) of a static discrete or fixed point
5859 subtype should be the number of bits needed to represent each value
5860 belonging to the subtype using an unbiased representation, leaving space
5861 for a sign bit only if the subtype contains negative values.  If such a
5862 subtype is a first subtype, then an implementation should support a
5863 specified @code{Size} for it that reflects this representation.
5864 @end cartouche
5865 Followed.
5866
5867 @sp 1
5868 @cartouche
5869 For a subtype implemented with levels of indirection, the @code{Size}
5870 should include the size of the pointers, but not the size of what they
5871 point at.
5872 @end cartouche
5873 Followed.
5874
5875 @cindex @code{Component_Size} clauses
5876 @unnumberedsec 13.3(71-73): Component Size Clauses
5877 @sp 1
5878 @cartouche
5879 The recommended level of support for the @code{Component_Size}
5880 attribute is:
5881 @end cartouche
5882 @sp 1
5883 @cartouche
5884 An implementation need not support specified @code{Component_Sizes} that are
5885 less than the @code{Size} of the component subtype.
5886 @end cartouche
5887 Followed.
5888
5889 @sp 1
5890 @cartouche
5891 An implementation should support specified @code{Component_Size}s that
5892 are factors and multiples of the word size.  For such
5893 @code{Component_Size}s, the array should contain no gaps between
5894 components.  For other @code{Component_Size}s (if supported), the array
5895 should contain no gaps between components when packing is also
5896 specified; the implementation should forbid this combination in cases
5897 where it cannot support a no-gaps representation.
5898 @end cartouche
5899 Followed.
5900
5901 @cindex Enumeration representation clauses
5902 @cindex Representation clauses, enumeration
5903 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5904 @sp 1
5905 @cartouche
5906 The recommended level of support for enumeration representation clauses
5907 is:
5908
5909 An implementation need not support enumeration representation clauses
5910 for boolean types, but should at minimum support the internal codes in
5911 the range @code{System.Min_Int.System.Max_Int}.
5912 @end cartouche
5913 Followed.
5914
5915 @cindex Record representation clauses
5916 @cindex Representation clauses, records
5917 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5918 @sp 1
5919 @cartouche
5920 The recommended level of support for
5921 @*@code{record_representation_clauses} is:
5922
5923 An implementation should support storage places that can be extracted
5924 with a load, mask, shift sequence of machine code, and set with a load,
5925 shift, mask, store sequence, given the available machine instructions
5926 and run-time model.
5927 @end cartouche
5928 Followed.
5929
5930 @sp 1
5931 @cartouche
5932 A storage place should be supported if its size is equal to the
5933 @code{Size} of the component subtype, and it starts and ends on a
5934 boundary that obeys the @code{Alignment} of the component subtype.
5935 @end cartouche
5936 Followed.
5937
5938 @sp 1
5939 @cartouche
5940 If the default bit ordering applies to the declaration of a given type,
5941 then for a component whose subtype's @code{Size} is less than the word
5942 size, any storage place that does not cross an aligned word boundary
5943 should be supported.
5944 @end cartouche
5945 Followed.
5946
5947 @sp 1
5948 @cartouche
5949 An implementation may reserve a storage place for the tag field of a
5950 tagged type, and disallow other components from overlapping that place.
5951 @end cartouche
5952 Followed.  The storage place for the tag field is the beginning of the tagged
5953 record, and its size is Address'Size.  GNAT will reject an explicit component
5954 clause for the tag field.
5955
5956 @sp 1
5957 @cartouche
5958 An implementation need not support a @code{component_clause} for a
5959 component of an extension part if the storage place is not after the
5960 storage places of all components of the parent type, whether or not
5961 those storage places had been specified.
5962 @end cartouche
5963 Followed.  The above advice on record representation clauses is followed,
5964 and all mentioned features are implemented.
5965
5966 @cindex Storage place attributes
5967 @unnumberedsec 13.5.2(5): Storage Place Attributes
5968 @sp 1
5969 @cartouche
5970 If a component is represented using some form of pointer (such as an
5971 offset) to the actual data of the component, and this data is contiguous
5972 with the rest of the object, then the storage place attributes should
5973 reflect the place of the actual data, not the pointer.  If a component is
5974 allocated discontinuously from the rest of the object, then a warning
5975 should be generated upon reference to one of its storage place
5976 attributes.
5977 @end cartouche
5978 Followed.  There are no such components in GNAT@.
5979
5980 @cindex Bit ordering
5981 @unnumberedsec 13.5.3(7-8): Bit Ordering
5982 @sp 1
5983 @cartouche
5984 The recommended level of support for the non-default bit ordering is:
5985 @end cartouche
5986 @sp 1
5987 @cartouche
5988 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5989 should support the non-default bit ordering in addition to the default
5990 bit ordering.
5991 @end cartouche
5992 Followed.  Word size does not equal storage size in this implementation.
5993 Thus non-default bit ordering is not supported.
5994
5995 @cindex @code{Address}, as private type
5996 @unnumberedsec 13.7(37): Address as Private
5997 @sp 1
5998 @cartouche
5999 @code{Address} should be of a private type.
6000 @end cartouche
6001 Followed.
6002
6003 @cindex Operations, on @code{Address}
6004 @cindex @code{Address}, operations of
6005 @unnumberedsec 13.7.1(16): Address Operations
6006 @sp 1
6007 @cartouche
6008 Operations in @code{System} and its children should reflect the target
6009 environment semantics as closely as is reasonable.  For example, on most
6010 machines, it makes sense for address arithmetic to ``wrap around''.
6011 Operations that do not make sense should raise @code{Program_Error}.
6012 @end cartouche
6013 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6014 operation raises @code{Program_Error}, since all operations make sense.
6015
6016 @cindex Unchecked conversion
6017 @unnumberedsec 13.9(14-17): Unchecked Conversion
6018 @sp 1
6019 @cartouche
6020 The @code{Size} of an array object should not include its bounds; hence,
6021 the bounds should not be part of the converted data.
6022 @end cartouche
6023 Followed.
6024
6025 @sp 1
6026 @cartouche
6027 The implementation should not generate unnecessary run-time checks to
6028 ensure that the representation of @var{S} is a representation of the
6029 target type.  It should take advantage of the permission to return by
6030 reference when possible.  Restrictions on unchecked conversions should be
6031 avoided unless required by the target environment.
6032 @end cartouche
6033 Followed.  There are no restrictions on unchecked conversion.  A warning is
6034 generated if the source and target types do not have the same size since
6035 the semantics in this case may be target dependent.
6036
6037 @sp 1
6038 @cartouche
6039 The recommended level of support for unchecked conversions is:
6040 @end cartouche
6041 @sp 1
6042 @cartouche
6043 Unchecked conversions should be supported and should be reversible in
6044 the cases where this clause defines the result.  To enable meaningful use
6045 of unchecked conversion, a contiguous representation should be used for
6046 elementary subtypes, for statically constrained array subtypes whose
6047 component subtype is one of the subtypes described in this paragraph,
6048 and for record subtypes without discriminants whose component subtypes
6049 are described in this paragraph.
6050 @end cartouche
6051 Followed.
6052
6053 @cindex Heap usage, implicit
6054 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6055 @sp 1
6056 @cartouche
6057 An implementation should document any cases in which it dynamically
6058 allocates heap storage for a purpose other than the evaluation of an
6059 allocator.
6060 @end cartouche
6061 Followed, the only other points at which heap storage is dynamically
6062 allocated are as follows:
6063
6064 @itemize @bullet
6065 @item
6066 At initial elaboration time, to allocate dynamically sized global
6067 objects.
6068
6069 @item
6070 To allocate space for a task when a task is created.
6071
6072 @item
6073 To extend the secondary stack dynamically when needed.  The secondary
6074 stack is used for returning variable length results.
6075 @end itemize
6076
6077 @sp 1
6078 @cartouche
6079 A default (implementation-provided) storage pool for an
6080 access-to-constant type should not have overhead to support deallocation of
6081 individual objects.
6082 @end cartouche
6083 Followed.
6084
6085 @sp 1
6086 @cartouche
6087 A storage pool for an anonymous access type should be created at the
6088 point of an allocator for the type, and be reclaimed when the designated
6089 object becomes inaccessible.
6090 @end cartouche
6091 Followed.
6092
6093 @cindex Unchecked deallocation
6094 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6095 @sp 1
6096 @cartouche
6097 For a standard storage pool, @code{Free} should actually reclaim the
6098 storage.
6099 @end cartouche
6100 Followed.
6101
6102 @cindex Stream oriented attributes
6103 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6104 @sp 1
6105 @cartouche
6106 If a stream element is the same size as a storage element, then the
6107 normal in-memory representation should be used by @code{Read} and
6108 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6109 should use the smallest number of stream elements needed to represent
6110 all values in the base range of the scalar type.
6111 @end cartouche
6112
6113 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6114 which specifies using the size of the first subtype.
6115 However, such an implementation is based on direct binary
6116 representations and is therefore target- and endianness-dependent.
6117 To address this issue, GNAT also supplies an alternate implementation
6118 of the stream attributes @code{Read} and @code{Write},
6119 which uses the target-independent XDR standard representation
6120 for scalar types.
6121 @cindex XDR representation
6122 @cindex @code{Read} attribute
6123 @cindex @code{Write} attribute
6124 @cindex Stream oriented attributes
6125 The XDR implementation is provided as an alternative body of the
6126 @code{System.Stream_Attributes} package, in the file
6127 @file{s-strxdr.adb} in the GNAT library.
6128 There is no @file{s-strxdr.ads} file.
6129 In order to install the XDR implementation, do the following:
6130 @enumerate
6131 @item Replace the default implementation of the
6132 @code{System.Stream_Attributes} package with the XDR implementation.
6133 For example on a Unix platform issue the commands:
6134 @smallexample
6135 $ mv s-stratt.adb s-strold.adb
6136 $ mv s-strxdr.adb s-stratt.adb
6137 @end smallexample
6138
6139 @item
6140 Rebuild the GNAT run-time library as documented in the
6141 @cite{GNAT User's Guide}
6142 @end enumerate
6143
6144 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6145 @sp 1
6146 @cartouche
6147 If an implementation provides additional named predefined integer types,
6148 then the names should end with @samp{Integer} as in
6149 @samp{Long_Integer}.  If an implementation provides additional named
6150 predefined floating point types, then the names should end with
6151 @samp{Float} as in @samp{Long_Float}.
6152 @end cartouche
6153 Followed.
6154
6155 @findex Ada.Characters.Handling
6156 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6157 @sp 1
6158 @cartouche
6159 If an implementation provides a localized definition of @code{Character}
6160 or @code{Wide_Character}, then the effects of the subprograms in
6161 @code{Characters.Handling} should reflect the localizations.  See also
6162 3.5.2.
6163 @end cartouche
6164 Followed.  GNAT provides no such localized definitions.
6165
6166 @cindex Bounded-length strings
6167 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6168 @sp 1
6169 @cartouche
6170 Bounded string objects should not be implemented by implicit pointers
6171 and dynamic allocation.
6172 @end cartouche
6173 Followed.  No implicit pointers or dynamic allocation are used.
6174
6175 @cindex Random number generation
6176 @unnumberedsec A.5.2(46-47): Random Number Generation
6177 @sp 1
6178 @cartouche
6179 Any storage associated with an object of type @code{Generator} should be
6180 reclaimed on exit from the scope of the object.
6181 @end cartouche
6182 Followed.
6183
6184 @sp 1
6185 @cartouche
6186 If the generator period is sufficiently long in relation to the number
6187 of distinct initiator values, then each possible value of
6188 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6189 random numbers that does not, in a practical sense, overlap the sequence
6190 initiated by any other value.  If this is not possible, then the mapping
6191 between initiator values and generator states should be a rapidly
6192 varying function of the initiator value.
6193 @end cartouche
6194 Followed.  The generator period is sufficiently long for the first
6195 condition here to hold true.
6196
6197 @findex Get_Immediate
6198 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6199 @sp 1
6200 @cartouche
6201 The @code{Get_Immediate} procedures should be implemented with
6202 unbuffered input.  For a device such as a keyboard, input should be
6203 @dfn{available} if a key has already been typed, whereas for a disk
6204 file, input should always be available except at end of file.  For a file
6205 associated with a keyboard-like device, any line-editing features of the
6206 underlying operating system should be disabled during the execution of
6207 @code{Get_Immediate}.
6208 @end cartouche
6209 Followed on all targets except VxWorks. For VxWorks, there is no way to
6210 provide this functionality that does not result in the input buffer being
6211 flushed before the @code{Get_Immediate} call. A special unit
6212 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6213 this functionality.
6214
6215 @findex Export
6216 @unnumberedsec B.1(39-41): Pragma @code{Export}
6217 @sp 1
6218 @cartouche
6219 If an implementation supports pragma @code{Export} to a given language,
6220 then it should also allow the main subprogram to be written in that
6221 language.  It should support some mechanism for invoking the elaboration
6222 of the Ada library units included in the system, and for invoking the
6223 finalization of the environment task.  On typical systems, the
6224 recommended mechanism is to provide two subprograms whose link names are
6225 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6226 elaboration code for library units.  @code{adafinal} should contain the
6227 finalization code.  These subprograms should have no effect the second
6228 and subsequent time they are called.
6229 @end cartouche
6230 Followed.
6231
6232 @sp 1
6233 @cartouche
6234 Automatic elaboration of pre-elaborated packages should be
6235 provided when pragma @code{Export} is supported.
6236 @end cartouche
6237 Followed when the main program is in Ada.  If the main program is in a
6238 foreign language, then
6239 @code{adainit} must be called to elaborate pre-elaborated
6240 packages.
6241
6242 @sp 1
6243 @cartouche
6244 For each supported convention @var{L} other than @code{Intrinsic}, an
6245 implementation should support @code{Import} and @code{Export} pragmas
6246 for objects of @var{L}-compatible types and for subprograms, and pragma
6247 @code{Convention} for @var{L}-eligible types and for subprograms,
6248 presuming the other language has corresponding features.  Pragma
6249 @code{Convention} need not be supported for scalar types.
6250 @end cartouche
6251 Followed.
6252
6253 @cindex Package @code{Interfaces}
6254 @findex Interfaces
6255 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6256 @sp 1
6257 @cartouche
6258 For each implementation-defined convention identifier, there should be a
6259 child package of package Interfaces with the corresponding name.  This
6260 package should contain any declarations that would be useful for
6261 interfacing to the language (implementation) represented by the
6262 convention.  Any declarations useful for interfacing to any language on
6263 the given hardware architecture should be provided directly in
6264 @code{Interfaces}.
6265 @end cartouche
6266 Followed. An additional package not defined
6267 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6268 for interfacing to C++.
6269
6270 @sp 1
6271 @cartouche
6272 An implementation supporting an interface to C, COBOL, or Fortran should
6273 provide the corresponding package or packages described in the following
6274 clauses.
6275 @end cartouche
6276 Followed.  GNAT provides all the packages described in this section.
6277
6278 @cindex C, interfacing with
6279 @unnumberedsec B.3(63-71): Interfacing with C
6280 @sp 1
6281 @cartouche
6282 An implementation should support the following interface correspondences
6283 between Ada and C@.
6284 @end cartouche
6285 Followed.
6286
6287 @sp 1
6288 @cartouche
6289 An Ada procedure corresponds to a void-returning C function.
6290 @end cartouche
6291 Followed.
6292
6293 @sp 1
6294 @cartouche
6295 An Ada function corresponds to a non-void C function.
6296 @end cartouche
6297 Followed.
6298
6299 @sp 1
6300 @cartouche
6301 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6302 function.
6303 @end cartouche
6304 Followed.
6305
6306 @sp 1
6307 @cartouche
6308 An Ada @code{in} parameter of an access-to-object type with designated
6309 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6310 where @var{t} is the C type corresponding to the Ada type @var{T}.
6311 @end cartouche
6312 Followed.
6313
6314 @sp 1
6315 @cartouche
6316 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6317 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6318 argument to a C function, where @var{t} is the C type corresponding to
6319 the Ada type @var{T}.  In the case of an elementary @code{out} or
6320 @code{in out} parameter, a pointer to a temporary copy is used to
6321 preserve by-copy semantics.
6322 @end cartouche
6323 Followed.
6324
6325 @sp 1
6326 @cartouche
6327 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6328 @code{@var{t}*} argument to a C function, where @var{t} is the C
6329 structure corresponding to the Ada type @var{T}.
6330 @end cartouche
6331 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6332 pragma, or Convention, or by explicitly specifying the mechanism for a given
6333 call using an extended import or export pragma.
6334
6335 @sp 1
6336 @cartouche
6337 An Ada parameter of an array type with component type @var{T}, of any
6338 mode, is passed as a @code{@var{t}*} argument to a C function, where
6339 @var{t} is the C type corresponding to the Ada type @var{T}.
6340 @end cartouche
6341 Followed.
6342
6343 @sp 1
6344 @cartouche
6345 An Ada parameter of an access-to-subprogram type is passed as a pointer
6346 to a C function whose prototype corresponds to the designated
6347 subprogram's specification.
6348 @end cartouche
6349 Followed.
6350
6351 @cindex COBOL, interfacing with
6352 @unnumberedsec B.4(95-98): Interfacing with COBOL
6353 @sp 1
6354 @cartouche
6355 An Ada implementation should support the following interface
6356 correspondences between Ada and COBOL@.
6357 @end cartouche
6358 Followed.
6359
6360 @sp 1
6361 @cartouche
6362 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6363 the COBOL type corresponding to @var{T}.
6364 @end cartouche
6365 Followed.
6366
6367 @sp 1
6368 @cartouche
6369 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6370 the corresponding COBOL type.
6371 @end cartouche
6372 Followed.
6373
6374 @sp 1
6375 @cartouche
6376 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6377 COBOL type corresponding to the Ada parameter type; for scalars, a local
6378 copy is used if necessary to ensure by-copy semantics.
6379 @end cartouche
6380 Followed.
6381
6382 @cindex Fortran, interfacing with
6383 @unnumberedsec B.5(22-26): Interfacing with Fortran
6384 @sp 1
6385 @cartouche
6386 An Ada implementation should support the following interface
6387 correspondences between Ada and Fortran:
6388 @end cartouche
6389 Followed.
6390
6391 @sp 1
6392 @cartouche
6393 An Ada procedure corresponds to a Fortran subroutine.
6394 @end cartouche
6395 Followed.
6396
6397 @sp 1
6398 @cartouche
6399 An Ada function corresponds to a Fortran function.
6400 @end cartouche
6401 Followed.
6402
6403 @sp 1
6404 @cartouche
6405 An Ada parameter of an elementary, array, or record type @var{T} is
6406 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6407 the Fortran type corresponding to the Ada type @var{T}, and where the
6408 INTENT attribute of the corresponding dummy argument matches the Ada
6409 formal parameter mode; the Fortran implementation's parameter passing
6410 conventions are used.  For elementary types, a local copy is used if
6411 necessary to ensure by-copy semantics.
6412 @end cartouche
6413 Followed.
6414
6415 @sp 1
6416 @cartouche
6417 An Ada parameter of an access-to-subprogram type is passed as a
6418 reference to a Fortran procedure whose interface corresponds to the
6419 designated subprogram's specification.
6420 @end cartouche
6421 Followed.
6422
6423 @cindex Machine operations
6424 @unnumberedsec C.1(3-5): Access to Machine Operations
6425 @sp 1
6426 @cartouche
6427 The machine code or intrinsic support should allow access to all
6428 operations normally available to assembly language programmers for the
6429 target environment, including privileged instructions, if any.
6430 @end cartouche
6431 Followed.
6432
6433 @sp 1
6434 @cartouche
6435 The interfacing pragmas (see Annex B) should support interface to
6436 assembler; the default assembler should be associated with the
6437 convention identifier @code{Assembler}.
6438 @end cartouche
6439 Followed.
6440
6441 @sp 1
6442 @cartouche
6443 If an entity is exported to assembly language, then the implementation
6444 should allocate it at an addressable location, and should ensure that it
6445 is retained by the linking process, even if not otherwise referenced
6446 from the Ada code.  The implementation should assume that any call to a
6447 machine code or assembler subprogram is allowed to read or update every
6448 object that is specified as exported.
6449 @end cartouche
6450 Followed.
6451
6452 @unnumberedsec C.1(10-16): Access to Machine Operations
6453 @sp 1
6454 @cartouche
6455 The implementation should ensure that little or no overhead is
6456 associated with calling intrinsic and machine-code subprograms.
6457 @end cartouche
6458 Followed for both intrinsics and machine-code subprograms.
6459
6460 @sp 1
6461 @cartouche
6462 It is recommended that intrinsic subprograms be provided for convenient
6463 access to any machine operations that provide special capabilities or
6464 efficiency and that are not otherwise available through the language
6465 constructs.
6466 @end cartouche
6467 Followed.  A full set of machine operation intrinsic subprograms is provided.
6468
6469 @sp 1
6470 @cartouche
6471 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6472 swap, decrement and test, enqueue/dequeue.
6473 @end cartouche
6474 Followed on any target supporting such operations.
6475
6476 @sp 1
6477 @cartouche
6478 Standard numeric functions---e.g.@:, sin, log.
6479 @end cartouche
6480 Followed on any target supporting such operations.
6481
6482 @sp 1
6483 @cartouche
6484 String manipulation operations---e.g.@:, translate and test.
6485 @end cartouche
6486 Followed on any target supporting such operations.
6487
6488 @sp 1
6489 @cartouche
6490 Vector operations---e.g.@:, compare vector against thresholds.
6491 @end cartouche
6492 Followed on any target supporting such operations.
6493
6494 @sp 1
6495 @cartouche
6496 Direct operations on I/O ports.
6497 @end cartouche
6498 Followed on any target supporting such operations.
6499
6500 @cindex Interrupt support
6501 @unnumberedsec C.3(28): Interrupt Support
6502 @sp 1
6503 @cartouche
6504 If the @code{Ceiling_Locking} policy is not in effect, the
6505 implementation should provide means for the application to specify which
6506 interrupts are to be blocked during protected actions, if the underlying
6507 system allows for a finer-grain control of interrupt blocking.
6508 @end cartouche
6509 Followed.  The underlying system does not allow for finer-grain control
6510 of interrupt blocking.
6511
6512 @cindex Protected procedure handlers
6513 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6514 @sp 1
6515 @cartouche
6516 Whenever possible, the implementation should allow interrupt handlers to
6517 be called directly by the hardware.
6518 @end cartouche
6519 @c SGI info:
6520 @ignore
6521 This is never possible under IRIX, so this is followed by default.
6522 @end ignore
6523 Followed on any target where the underlying operating system permits
6524 such direct calls.
6525
6526 @sp 1
6527 @cartouche
6528 Whenever practical, violations of any
6529 implementation-defined restrictions should be detected before run time.
6530 @end cartouche
6531 Followed.  Compile time warnings are given when possible.
6532
6533 @cindex Package @code{Interrupts}
6534 @findex Interrupts
6535 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6536
6537 @sp 1
6538 @cartouche
6539 If implementation-defined forms of interrupt handler procedures are
6540 supported, such as protected procedures with parameters, then for each
6541 such form of a handler, a type analogous to @code{Parameterless_Handler}
6542 should be specified in a child package of @code{Interrupts}, with the
6543 same operations as in the predefined package Interrupts.
6544 @end cartouche
6545 Followed.
6546
6547 @cindex Pre-elaboration requirements
6548 @unnumberedsec C.4(14): Pre-elaboration Requirements
6549 @sp 1
6550 @cartouche
6551 It is recommended that pre-elaborated packages be implemented in such a
6552 way that there should be little or no code executed at run time for the
6553 elaboration of entities not already covered by the Implementation
6554 Requirements.
6555 @end cartouche
6556 Followed.  Executable code is generated in some cases, e.g.@: loops
6557 to initialize large arrays.
6558
6559 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6560
6561 @sp 1
6562 @cartouche
6563 If the pragma applies to an entity, then the implementation should
6564 reduce the amount of storage used for storing names associated with that
6565 entity.
6566 @end cartouche
6567 Followed.
6568
6569 @cindex Package @code{Task_Attributes}
6570 @findex Task_Attributes
6571 @unnumberedsec C.7.2(30): The Package Task_Attributes
6572 @sp 1
6573 @cartouche
6574 Some implementations are targeted to domains in which memory use at run
6575 time must be completely deterministic.  For such implementations, it is
6576 recommended that the storage for task attributes will be pre-allocated
6577 statically and not from the heap.  This can be accomplished by either
6578 placing restrictions on the number and the size of the task's
6579 attributes, or by using the pre-allocated storage for the first @var{N}
6580 attribute objects, and the heap for the others.  In the latter case,
6581 @var{N} should be documented.
6582 @end cartouche
6583 Not followed.  This implementation is not targeted to such a domain.
6584
6585 @cindex Locking Policies
6586 @unnumberedsec D.3(17): Locking Policies
6587
6588 @sp 1
6589 @cartouche
6590 The implementation should use names that end with @samp{_Locking} for
6591 locking policies defined by the implementation.
6592 @end cartouche
6593 Followed.  A single implementation-defined locking policy is defined,
6594 whose name (@code{Inheritance_Locking}) follows this suggestion.
6595
6596 @cindex Entry queuing policies
6597 @unnumberedsec D.4(16): Entry Queuing Policies
6598 @sp 1
6599 @cartouche
6600 Names that end with @samp{_Queuing} should be used
6601 for all implementation-defined queuing policies.
6602 @end cartouche
6603 Followed.  No such implementation-defined queuing policies exist.
6604
6605 @cindex Preemptive abort
6606 @unnumberedsec D.6(9-10): Preemptive Abort
6607 @sp 1
6608 @cartouche
6609 Even though the @code{abort_statement} is included in the list of
6610 potentially blocking operations (see 9.5.1), it is recommended that this
6611 statement be implemented in a way that never requires the task executing
6612 the @code{abort_statement} to block.
6613 @end cartouche
6614 Followed.
6615
6616 @sp 1
6617 @cartouche
6618 On a multi-processor, the delay associated with aborting a task on
6619 another processor should be bounded; the implementation should use
6620 periodic polling, if necessary, to achieve this.
6621 @end cartouche
6622 Followed.
6623
6624 @cindex Tasking restrictions
6625 @unnumberedsec D.7(21): Tasking Restrictions
6626 @sp 1
6627 @cartouche
6628 When feasible, the implementation should take advantage of the specified
6629 restrictions to produce a more efficient implementation.
6630 @end cartouche
6631 GNAT currently takes advantage of these restrictions by providing an optimized
6632 run time when the Ravenscar profile and the GNAT restricted run time set
6633 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6634 pragma @code{Profile (Restricted)} for more details.
6635
6636 @cindex Time, monotonic
6637 @unnumberedsec D.8(47-49): Monotonic Time
6638 @sp 1
6639 @cartouche
6640 When appropriate, implementations should provide configuration
6641 mechanisms to change the value of @code{Tick}.
6642 @end cartouche
6643 Such configuration mechanisms are not appropriate to this implementation
6644 and are thus not supported.
6645
6646 @sp 1
6647 @cartouche
6648 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6649 be implemented as transformations of the same time base.
6650 @end cartouche
6651 Followed.
6652
6653 @sp 1
6654 @cartouche
6655 It is recommended that the @dfn{best} time base which exists in
6656 the underlying system be available to the application through
6657 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6658 @end cartouche
6659 Followed.
6660
6661 @cindex Partition communication subsystem
6662 @cindex PCS
6663 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6664 @sp 1
6665 @cartouche
6666 Whenever possible, the PCS on the called partition should allow for
6667 multiple tasks to call the RPC-receiver with different messages and
6668 should allow them to block until the corresponding subprogram body
6669 returns.
6670 @end cartouche
6671 Followed by GLADE, a separately supplied PCS that can be used with
6672 GNAT.
6673
6674 @sp 1
6675 @cartouche
6676 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6677 should raise @code{Storage_Error} if it runs out of space trying to
6678 write the @code{Item} into the stream.
6679 @end cartouche
6680 Followed by GLADE, a separately supplied PCS that can be used with
6681 GNAT@.
6682
6683 @cindex COBOL support
6684 @unnumberedsec F(7): COBOL Support
6685 @sp 1
6686 @cartouche
6687 If COBOL (respectively, C) is widely supported in the target
6688 environment, implementations supporting the Information Systems Annex
6689 should provide the child package @code{Interfaces.COBOL} (respectively,
6690 @code{Interfaces.C}) specified in Annex B and should support a
6691 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6692 pragmas (see Annex B), thus allowing Ada programs to interface with
6693 programs written in that language.
6694 @end cartouche
6695 Followed.
6696
6697 @cindex Decimal radix support
6698 @unnumberedsec F.1(2): Decimal Radix Support
6699 @sp 1
6700 @cartouche
6701 Packed decimal should be used as the internal representation for objects
6702 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6703 @end cartouche
6704 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6705 representations.
6706
6707 @cindex Numerics
6708 @unnumberedsec G: Numerics
6709 @sp 2
6710 @cartouche
6711 If Fortran (respectively, C) is widely supported in the target
6712 environment, implementations supporting the Numerics Annex
6713 should provide the child package @code{Interfaces.Fortran} (respectively,
6714 @code{Interfaces.C}) specified in Annex B and should support a
6715 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6716 pragmas (see Annex B), thus allowing Ada programs to interface with
6717 programs written in that language.
6718 @end cartouche
6719 Followed.
6720
6721 @cindex Complex types
6722 @unnumberedsec G.1.1(56-58): Complex Types
6723 @sp 2
6724 @cartouche
6725 Because the usual mathematical meaning of multiplication of a complex
6726 operand and a real operand is that of the scaling of both components of
6727 the former by the latter, an implementation should not perform this
6728 operation by first promoting the real operand to complex type and then
6729 performing a full complex multiplication.  In systems that, in the
6730 future, support an Ada binding to IEC 559:1989, the latter technique
6731 will not generate the required result when one of the components of the
6732 complex operand is infinite.  (Explicit multiplication of the infinite
6733 component by the zero component obtained during promotion yields a NaN
6734 that propagates into the final result.) Analogous advice applies in the
6735 case of multiplication of a complex operand and a pure-imaginary
6736 operand, and in the case of division of a complex operand by a real or
6737 pure-imaginary operand.
6738 @end cartouche
6739 Not followed.
6740
6741 @sp 1
6742 @cartouche
6743 Similarly, because the usual mathematical meaning of addition of a
6744 complex operand and a real operand is that the imaginary operand remains
6745 unchanged, an implementation should not perform this operation by first
6746 promoting the real operand to complex type and then performing a full
6747 complex addition.  In implementations in which the @code{Signed_Zeros}
6748 attribute of the component type is @code{True} (and which therefore
6749 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6750 predefined arithmetic operations), the latter technique will not
6751 generate the required result when the imaginary component of the complex
6752 operand is a negatively signed zero.  (Explicit addition of the negative
6753 zero to the zero obtained during promotion yields a positive zero.)
6754 Analogous advice applies in the case of addition of a complex operand
6755 and a pure-imaginary operand, and in the case of subtraction of a
6756 complex operand and a real or pure-imaginary operand.
6757 @end cartouche
6758 Not followed.
6759
6760 @sp 1
6761 @cartouche
6762 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6763 attempt to provide a rational treatment of the signs of zero results and
6764 result components.  As one example, the result of the @code{Argument}
6765 function should have the sign of the imaginary component of the
6766 parameter @code{X} when the point represented by that parameter lies on
6767 the positive real axis; as another, the sign of the imaginary component
6768 of the @code{Compose_From_Polar} function should be the same as
6769 (respectively, the opposite of) that of the @code{Argument} parameter when that
6770 parameter has a value of zero and the @code{Modulus} parameter has a
6771 nonnegative (respectively, negative) value.
6772 @end cartouche
6773 Followed.
6774
6775 @cindex Complex elementary functions
6776 @unnumberedsec G.1.2(49): Complex Elementary Functions
6777 @sp 1
6778 @cartouche
6779 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6780 @code{True} should attempt to provide a rational treatment of the signs
6781 of zero results and result components.  For example, many of the complex
6782 elementary functions have components that are odd functions of one of
6783 the parameter components; in these cases, the result component should
6784 have the sign of the parameter component at the origin.  Other complex
6785 elementary functions have zero components whose sign is opposite that of
6786 a parameter component at the origin, or is always positive or always
6787 negative.
6788 @end cartouche
6789 Followed.
6790
6791 @cindex Accuracy requirements
6792 @unnumberedsec G.2.4(19): Accuracy Requirements
6793 @sp 1
6794 @cartouche
6795 The versions of the forward trigonometric functions without a
6796 @code{Cycle} parameter should not be implemented by calling the
6797 corresponding version with a @code{Cycle} parameter of
6798 @code{2.0*Numerics.Pi}, since this will not provide the required
6799 accuracy in some portions of the domain.  For the same reason, the
6800 version of @code{Log} without a @code{Base} parameter should not be
6801 implemented by calling the corresponding version with a @code{Base}
6802 parameter of @code{Numerics.e}.
6803 @end cartouche
6804 Followed.
6805
6806 @cindex Complex arithmetic accuracy
6807 @cindex Accuracy, complex arithmetic
6808 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6809
6810 @sp 1
6811 @cartouche
6812 The version of the @code{Compose_From_Polar} function without a
6813 @code{Cycle} parameter should not be implemented by calling the
6814 corresponding version with a @code{Cycle} parameter of
6815 @code{2.0*Numerics.Pi}, since this will not provide the required
6816 accuracy in some portions of the domain.
6817 @end cartouche
6818 Followed.
6819
6820 @c -----------------------------------------
6821 @node Implementation Defined Characteristics
6822 @chapter Implementation Defined Characteristics
6823
6824 @noindent
6825 In addition to the implementation dependent pragmas and attributes, and
6826 the implementation advice, there are a number of other Ada features
6827 that are potentially implementation dependent.  These are mentioned
6828 throughout the Ada Reference Manual, and are summarized in annex M@.
6829
6830 A requirement for conforming Ada compilers is that they provide
6831 documentation describing how the implementation deals with each of these
6832 issues.  In this chapter, you will find each point in annex M listed
6833 followed by a description in italic font of how GNAT
6834 @c SGI info:
6835 @ignore
6836 in the ProDev Ada
6837 implementation on IRIX 5.3 operating system or greater
6838 @end ignore
6839 handles the implementation dependence.
6840
6841 You can use this chapter as a guide to minimizing implementation
6842 dependent features in your programs if portability to other compilers
6843 and other operating systems is an important consideration.  The numbers
6844 in each section below correspond to the paragraph number in the Ada
6845 Reference Manual.
6846
6847 @sp 1
6848 @cartouche
6849 @noindent
6850 @strong{2}.  Whether or not each recommendation given in Implementation
6851 Advice is followed.  See 1.1.2(37).
6852 @end cartouche
6853 @noindent
6854 @xref{Implementation Advice}.
6855
6856 @sp 1
6857 @cartouche
6858 @noindent
6859 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6860 @end cartouche
6861 @noindent
6862 The complexity of programs that can be processed is limited only by the
6863 total amount of available virtual memory, and disk space for the
6864 generated object files.
6865
6866 @sp 1
6867 @cartouche
6868 @noindent
6869 @strong{4}.  Variations from the standard that are impractical to avoid
6870 given the implementation's execution environment.  See 1.1.3(6).
6871 @end cartouche
6872 @noindent
6873 There are no variations from the standard.
6874
6875 @sp 1
6876 @cartouche
6877 @noindent
6878 @strong{5}.  Which @code{code_statement}s cause external
6879 interactions.  See 1.1.3(10).
6880 @end cartouche
6881 @noindent
6882 Any @code{code_statement} can potentially cause external interactions.
6883
6884 @sp 1
6885 @cartouche
6886 @noindent
6887 @strong{6}.  The coded representation for the text of an Ada
6888 program.  See 2.1(4).
6889 @end cartouche
6890 @noindent
6891 See separate section on source representation.
6892
6893 @sp 1
6894 @cartouche
6895 @noindent
6896 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6897 @end cartouche
6898 @noindent
6899 See separate section on source representation.
6900
6901 @sp 1
6902 @cartouche
6903 @noindent
6904 @strong{8}.  The representation for an end of line.  See 2.2(2).
6905 @end cartouche
6906 @noindent
6907 See separate section on source representation.
6908
6909 @sp 1
6910 @cartouche
6911 @noindent
6912 @strong{9}.  Maximum supported line length and lexical element
6913 length.  See 2.2(15).
6914 @end cartouche
6915 @noindent
6916 The maximum line length is 255 characters an the maximum length of a
6917 lexical element is also 255 characters.
6918
6919 @sp 1
6920 @cartouche
6921 @noindent
6922 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6923 @end cartouche
6924 @noindent
6925
6926 @xref{Implementation Defined Pragmas}.
6927
6928 @sp 1
6929 @cartouche
6930 @noindent
6931 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6932 @end cartouche
6933 @noindent
6934 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6935 parameter, checks that the optimization flag is set, and aborts if it is
6936 not.
6937
6938 @sp 1
6939 @cartouche
6940 @noindent
6941 @strong{12}.  The sequence of characters of the value returned by
6942 @code{@var{S}'Image} when some of the graphic characters of
6943 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6944 3.5(37).
6945 @end cartouche
6946 @noindent
6947 The sequence of characters is as defined by the wide character encoding
6948 method used for the source.  See section on source representation for
6949 further details.
6950
6951 @sp 1
6952 @cartouche
6953 @noindent
6954 @strong{13}.  The predefined integer types declared in
6955 @code{Standard}.  See 3.5.4(25).
6956 @end cartouche
6957 @noindent
6958 @table @code
6959 @item Short_Short_Integer
6960 8 bit signed
6961 @item Short_Integer
6962 (Short) 16 bit signed
6963 @item Integer
6964 32 bit signed
6965 @item Long_Integer
6966 64 bit signed (Alpha OpenVMS only)
6967 32 bit signed (all other targets)
6968 @item Long_Long_Integer
6969 64 bit signed
6970 @end table
6971
6972 @sp 1
6973 @cartouche
6974 @noindent
6975 @strong{14}.  Any nonstandard integer types and the operators defined
6976 for them.  See 3.5.4(26).
6977 @end cartouche
6978 @noindent
6979 There are no nonstandard integer types.
6980
6981 @sp 1
6982 @cartouche
6983 @noindent
6984 @strong{15}.  Any nonstandard real types and the operators defined for
6985 them.  See 3.5.6(8).
6986 @end cartouche
6987 @noindent
6988 There are no nonstandard real types.
6989
6990 @sp 1
6991 @cartouche
6992 @noindent
6993 @strong{16}.  What combinations of requested decimal precision and range
6994 are supported for floating point types.  See 3.5.7(7).
6995 @end cartouche
6996 @noindent
6997 The precision and range is as defined by the IEEE standard.
6998
6999 @sp 1
7000 @cartouche
7001 @noindent
7002 @strong{17}.  The predefined floating point types declared in
7003 @code{Standard}.  See 3.5.7(16).
7004 @end cartouche
7005 @noindent
7006 @table @code
7007 @item Short_Float
7008 32 bit IEEE short
7009 @item Float
7010 (Short) 32 bit IEEE short
7011 @item Long_Float
7012 64 bit IEEE long
7013 @item Long_Long_Float
7014 64 bit IEEE long (80 bit IEEE long on x86 processors)
7015 @end table
7016
7017 @sp 1
7018 @cartouche
7019 @noindent
7020 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7021 @end cartouche
7022 @noindent
7023 @code{Fine_Delta} is 2**(@minus{}63)
7024
7025 @sp 1
7026 @cartouche
7027 @noindent
7028 @strong{19}.  What combinations of small, range, and digits are
7029 supported for fixed point types.  See 3.5.9(10).
7030 @end cartouche
7031 @noindent
7032 Any combinations are permitted that do not result in a small less than
7033 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7034 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7035 is 64 bits (true of all architectures except ia32), then the output from
7036 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7037 is because floating-point conversions are used to convert fixed point.
7038
7039 @sp 1
7040 @cartouche
7041 @noindent
7042 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7043 within an unnamed @code{block_statement}.  See 3.9(10).
7044 @end cartouche
7045 @noindent
7046 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7047 decimal integer are allocated.
7048
7049 @sp 1
7050 @cartouche
7051 @noindent
7052 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7053 @end cartouche
7054 @noindent
7055 @xref{Implementation Defined Attributes}.
7056
7057 @sp 1
7058 @cartouche
7059 @noindent
7060 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7061 @end cartouche
7062 @noindent
7063 There are no implementation-defined time types.
7064
7065 @sp 1
7066 @cartouche
7067 @noindent
7068 @strong{23}.  The time base associated with relative delays.
7069 @end cartouche
7070 @noindent
7071 See 9.6(20).  The time base used is that provided by the C library
7072 function @code{gettimeofday}.
7073
7074 @sp 1
7075 @cartouche
7076 @noindent
7077 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7078 9.6(23).
7079 @end cartouche
7080 @noindent
7081 The time base used is that provided by the C library function
7082 @code{gettimeofday}.
7083
7084 @sp 1
7085 @cartouche
7086 @noindent
7087 @strong{25}.  The time zone used for package @code{Calendar}
7088 operations.  See 9.6(24).
7089 @end cartouche
7090 @noindent
7091 The time zone used by package @code{Calendar} is the current system time zone
7092 setting for local time, as accessed by the C library function
7093 @code{localtime}.
7094
7095 @sp 1
7096 @cartouche
7097 @noindent
7098 @strong{26}.  Any limit on @code{delay_until_statements} of
7099 @code{select_statements}.  See 9.6(29).
7100 @end cartouche
7101 @noindent
7102 There are no such limits.
7103
7104 @sp 1
7105 @cartouche
7106 @noindent
7107 @strong{27}.  Whether or not two non overlapping parts of a composite
7108 object are independently addressable, in the case where packing, record
7109 layout, or @code{Component_Size} is specified for the object.  See
7110 9.10(1).
7111 @end cartouche
7112 @noindent
7113 Separate components are independently addressable if they do not share
7114 overlapping storage units.
7115
7116 @sp 1
7117 @cartouche
7118 @noindent
7119 @strong{28}.  The representation for a compilation.  See 10.1(2).
7120 @end cartouche
7121 @noindent
7122 A compilation is represented by a sequence of files presented to the
7123 compiler in a single invocation of the @code{gcc} command.
7124
7125 @sp 1
7126 @cartouche
7127 @noindent
7128 @strong{29}.  Any restrictions on compilations that contain multiple
7129 compilation_units.  See 10.1(4).
7130 @end cartouche
7131 @noindent
7132 No single file can contain more than one compilation unit, but any
7133 sequence of files can be presented to the compiler as a single
7134 compilation.
7135
7136 @sp 1
7137 @cartouche
7138 @noindent
7139 @strong{30}.  The mechanisms for creating an environment and for adding
7140 and replacing compilation units.  See 10.1.4(3).
7141 @end cartouche
7142 @noindent
7143 See separate section on compilation model.
7144
7145 @sp 1
7146 @cartouche
7147 @noindent
7148 @strong{31}.  The manner of explicitly assigning library units to a
7149 partition.  See 10.2(2).
7150 @end cartouche
7151 @noindent
7152 If a unit contains an Ada main program, then the Ada units for the partition
7153 are determined by recursive application of the rules in the Ada Reference
7154 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7155 are needed by the main program, and then this definition of need is applied
7156 recursively to those units, and the partition contains the transitive
7157 closure determined by this relationship.  In short, all the necessary units
7158 are included, with no need to explicitly specify the list.  If additional
7159 units are required, e.g.@: by foreign language units, then all units must be
7160 mentioned in the context clause of one of the needed Ada units.
7161
7162 If the partition contains no main program, or if the main program is in
7163 a language other than Ada, then GNAT
7164 provides the binder options @code{-z} and @code{-n} respectively, and in
7165 this case a list of units can be explicitly supplied to the binder for
7166 inclusion in the partition (all units needed by these units will also
7167 be included automatically).  For full details on the use of these
7168 options, refer to the @cite{GNAT User's Guide} sections on Binding
7169 and Linking.
7170
7171 @sp 1
7172 @cartouche
7173 @noindent
7174 @strong{32}.  The implementation-defined means, if any, of specifying
7175 which compilation units are needed by a given compilation unit.  See
7176 10.2(2).
7177 @end cartouche
7178 @noindent
7179 The units needed by a given compilation unit are as defined in
7180 the Ada Reference Manual section 10.2(2-6).  There are no
7181 implementation-defined pragmas or other implementation-defined
7182 means for specifying needed units.
7183
7184 @sp 1
7185 @cartouche
7186 @noindent
7187 @strong{33}.  The manner of designating the main subprogram of a
7188 partition.  See 10.2(7).
7189 @end cartouche
7190 @noindent
7191 The main program is designated by providing the name of the
7192 corresponding @file{ALI} file as the input parameter to the binder.
7193
7194 @sp 1
7195 @cartouche
7196 @noindent
7197 @strong{34}.  The order of elaboration of @code{library_items}.  See
7198 10.2(18).
7199 @end cartouche
7200 @noindent
7201 The first constraint on ordering is that it meets the requirements of
7202 Chapter 10 of the Ada Reference Manual.  This still leaves some
7203 implementation dependent choices, which are resolved by first
7204 elaborating bodies as early as possible (i.e., in preference to specs
7205 where there is a choice), and second by evaluating the immediate with
7206 clauses of a unit to determine the probably best choice, and
7207 third by elaborating in alphabetical order of unit names
7208 where a choice still remains.
7209
7210 @sp 1
7211 @cartouche
7212 @noindent
7213 @strong{35}.  Parameter passing and function return for the main
7214 subprogram.  See 10.2(21).
7215 @end cartouche
7216 @noindent
7217 The main program has no parameters.  It may be a procedure, or a function
7218 returning an integer type.  In the latter case, the returned integer
7219 value is the return code of the program (overriding any value that
7220 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7221
7222 @sp 1
7223 @cartouche
7224 @noindent
7225 @strong{36}.  The mechanisms for building and running partitions.  See
7226 10.2(24).
7227 @end cartouche
7228 @noindent
7229 GNAT itself supports programs with only a single partition.  The GNATDIST
7230 tool provided with the GLADE package (which also includes an implementation
7231 of the PCS) provides a completely flexible method for building and running
7232 programs consisting of multiple partitions.  See the separate GLADE manual
7233 for details.
7234
7235 @sp 1
7236 @cartouche
7237 @noindent
7238 @strong{37}.  The details of program execution, including program
7239 termination.  See 10.2(25).
7240 @end cartouche
7241 @noindent
7242 See separate section on compilation model.
7243
7244 @sp 1
7245 @cartouche
7246 @noindent
7247 @strong{38}.  The semantics of any non-active partitions supported by the
7248 implementation.  See 10.2(28).
7249 @end cartouche
7250 @noindent
7251 Passive partitions are supported on targets where shared memory is
7252 provided by the operating system.  See the GLADE reference manual for
7253 further details.
7254
7255 @sp 1
7256 @cartouche
7257 @noindent
7258 @strong{39}.  The information returned by @code{Exception_Message}.  See
7259 11.4.1(10).
7260 @end cartouche
7261 @noindent
7262 Exception message returns the null string unless a specific message has
7263 been passed by the program.
7264
7265 @sp 1
7266 @cartouche
7267 @noindent
7268 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7269 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7270 @end cartouche
7271 @noindent
7272 Blocks have implementation defined names of the form @code{B@var{nnn}}
7273 where @var{nnn} is an integer.
7274
7275 @sp 1
7276 @cartouche
7277 @noindent
7278 @strong{41}.  The information returned by
7279 @code{Exception_Information}.  See 11.4.1(13).
7280 @end cartouche
7281 @noindent
7282 @code{Exception_Information} returns a string in the following format:
7283
7284 @smallexample
7285 @emph{Exception_Name:} nnnnn
7286 @emph{Message:} mmmmm
7287 @emph{PID:} ppp
7288 @emph{Call stack traceback locations:}
7289 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7290 @end smallexample
7291
7292 @noindent
7293 where
7294
7295 @itemize @bullet
7296 @item
7297 @code{nnnn} is the fully qualified name of the exception in all upper
7298 case letters. This line is always present.
7299
7300 @item
7301 @code{mmmm} is the message (this line present only if message is non-null)
7302
7303 @item
7304 @code{ppp} is the Process Id value as a decimal integer (this line is
7305 present only if the Process Id is nonzero). Currently we are
7306 not making use of this field.
7307
7308 @item
7309 The Call stack traceback locations line and the following values
7310 are present only if at least one traceback location was recorded.
7311 The values are given in C style format, with lower case letters
7312 for a-f, and only as many digits present as are necessary.
7313 @end itemize
7314
7315 @noindent
7316 The line terminator sequence at the end of each line, including
7317 the last line is a single @code{LF} character (@code{16#0A#}).
7318
7319 @sp 1
7320 @cartouche
7321 @noindent
7322 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7323 @end cartouche
7324 @noindent
7325 No implementation-defined check names are supported.
7326
7327 @sp 1
7328 @cartouche
7329 @noindent
7330 @strong{43}.  The interpretation of each aspect of representation.  See
7331 13.1(20).
7332 @end cartouche
7333 @noindent
7334 See separate section on data representations.
7335
7336 @sp 1
7337 @cartouche
7338 @noindent
7339 @strong{44}.  Any restrictions placed upon representation items.  See
7340 13.1(20).
7341 @end cartouche
7342 @noindent
7343 See separate section on data representations.
7344
7345 @sp 1
7346 @cartouche
7347 @noindent
7348 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7349 13.3(48).
7350 @end cartouche
7351 @noindent
7352 Size for an indefinite subtype is the maximum possible size, except that
7353 for the case of a subprogram parameter, the size of the parameter object
7354 is the actual size.
7355
7356 @sp 1
7357 @cartouche
7358 @noindent
7359 @strong{46}.  The default external representation for a type tag.  See
7360 13.3(75).
7361 @end cartouche
7362 @noindent
7363 The default external representation for a type tag is the fully expanded
7364 name of the type in upper case letters.
7365
7366 @sp 1
7367 @cartouche
7368 @noindent
7369 @strong{47}.  What determines whether a compilation unit is the same in
7370 two different partitions.  See 13.3(76).
7371 @end cartouche
7372 @noindent
7373 A compilation unit is the same in two different partitions if and only
7374 if it derives from the same source file.
7375
7376 @sp 1
7377 @cartouche
7378 @noindent
7379 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7380 @end cartouche
7381 @noindent
7382 The only implementation defined component is the tag for a tagged type,
7383 which contains a pointer to the dispatching table.
7384
7385 @sp 1
7386 @cartouche
7387 @noindent
7388 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7389 ordering.  See 13.5.3(5).
7390 @end cartouche
7391 @noindent
7392 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7393 implementation, so no non-default bit ordering is supported.  The default
7394 bit ordering corresponds to the natural endianness of the target architecture.
7395
7396 @sp 1
7397 @cartouche
7398 @noindent
7399 @strong{50}.  The contents of the visible part of package @code{System}
7400 and its language-defined children.  See 13.7(2).
7401 @end cartouche
7402 @noindent
7403 See the definition of these packages in files @file{system.ads} and
7404 @file{s-stoele.ads}.
7405
7406 @sp 1
7407 @cartouche
7408 @noindent
7409 @strong{51}.  The contents of the visible part of package
7410 @code{System.Machine_Code}, and the meaning of
7411 @code{code_statements}.  See 13.8(7).
7412 @end cartouche
7413 @noindent
7414 See the definition and documentation in file @file{s-maccod.ads}.
7415
7416 @sp 1
7417 @cartouche
7418 @noindent
7419 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7420 @end cartouche
7421 @noindent
7422 Unchecked conversion between types of the same size
7423 results in an uninterpreted transmission of the bits from one type
7424 to the other.  If the types are of unequal sizes, then in the case of
7425 discrete types, a shorter source is first zero or sign extended as
7426 necessary, and a shorter target is simply truncated on the left.
7427 For all non-discrete types, the source is first copied if necessary
7428 to ensure that the alignment requirements of the target are met, then
7429 a pointer is constructed to the source value, and the result is obtained
7430 by dereferencing this pointer after converting it to be a pointer to the
7431 target type. Unchecked conversions where the target subtype is an
7432 unconstrained array are not permitted. If the target alignment is
7433 greater than the source alignment, then a copy of the result is
7434 made with appropriate alignment
7435
7436 @sp 1
7437 @cartouche
7438 @noindent
7439 @strong{53}.  The manner of choosing a storage pool for an access type
7440 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7441 @end cartouche
7442 @noindent
7443 There are 3 different standard pools used by the compiler when
7444 @code{Storage_Pool} is not specified depending whether the type is local
7445 to a subprogram or defined at the library level and whether
7446 @code{Storage_Size}is specified or not.  See documentation in the runtime
7447 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7448 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7449 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7450 default pools used.
7451
7452 @sp 1
7453 @cartouche
7454 @noindent
7455 @strong{54}.  Whether or not the implementation provides user-accessible
7456 names for the standard pool type(s).  See 13.11(17).
7457 @end cartouche
7458 @noindent
7459
7460 See documentation in the sources of the run time mentioned in paragraph
7461 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7462 these units.
7463
7464 @sp 1
7465 @cartouche
7466 @noindent
7467 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7468 @end cartouche
7469 @noindent
7470 @code{Storage_Size} is measured in storage units, and refers to the
7471 total space available for an access type collection, or to the primary
7472 stack space for a task.
7473
7474 @sp 1
7475 @cartouche
7476 @noindent
7477 @strong{56}.  Implementation-defined aspects of storage pools.  See
7478 13.11(22).
7479 @end cartouche
7480 @noindent
7481 See documentation in the sources of the run time mentioned in paragraph
7482 @strong{53} for details on GNAT-defined aspects of storage pools.
7483
7484 @sp 1
7485 @cartouche
7486 @noindent
7487 @strong{57}.  The set of restrictions allowed in a pragma
7488 @code{Restrictions}.  See 13.12(7).
7489 @end cartouche
7490 @noindent
7491 All RM defined Restriction identifiers are implemented.  The following
7492 additional restriction identifiers are provided.  There are two separate
7493 lists of implementation dependent restriction identifiers.  The first
7494 set requires consistency throughout a partition (in other words, if the
7495 restriction identifier is used for any compilation unit in the partition,
7496 then all compilation units in the partition must obey the restriction.
7497
7498 @table @code
7499
7500 @item Simple_Barriers
7501 @findex Simple_Barriers
7502 This restriction ensures at compile time that barriers in entry declarations
7503 for protected types are restricted to either static boolean expressions or
7504 references to simple boolean variables defined in the private part of the
7505 protected type.  No other form of entry barriers is permitted.  This is one
7506 of the restrictions of the Ravenscar profile for limited tasking (see also
7507 pragma @code{Profile (Ravenscar)}).
7508
7509 @item Max_Entry_Queue_Length => Expr
7510 @findex Max_Entry_Queue_Length
7511 This restriction is a declaration that any protected entry compiled in
7512 the scope of the restriction has at most the specified number of
7513 tasks waiting on the entry
7514 at any one time, and so no queue is required.  This restriction is not
7515 checked at compile time.  A program execution is erroneous if an attempt
7516 is made to queue more than the specified number of tasks on such an entry.
7517
7518 @item No_Calendar
7519 @findex No_Calendar
7520 This restriction ensures at compile time that there is no implicit or
7521 explicit dependence on the package @code{Ada.Calendar}.
7522
7523 @item No_Direct_Boolean_Operators
7524 @findex No_Direct_Boolean_Operators
7525 This restriction ensures that no logical (and/or/xor) or comparison
7526 operators are used on operands of type Boolean (or any type derived
7527 from Boolean). This is intended for use in safety critical programs
7528 where the certification protocol requires the use of short-circuit
7529 (and then, or else) forms for all composite boolean operations.
7530
7531 @item No_Dispatching_Calls
7532 @findex No_Dispatching_Calls
7533 This restriction ensures at compile time that the code generated by the
7534 compiler involves no dispatching calls. The use of this restriction allows the
7535 safe use of record extensions, classwide membership tests and other classwide
7536 features not involving implicit dispatching. This restriction ensures that
7537 the code contains no indirect calls through a dispatching mechanism. Note that
7538 this includes internally-generated calls created by the compiler, for example
7539 in the implementation of class-wide objects assignments. The
7540 membership test is allowed in the presence of this restriction, because its
7541 implementation requires no dispatching.
7542 This restriction is comparable to the official Ada restriction
7543 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7544 all classwide constructs that do not imply dispatching.
7545 The following example indicates constructs that violate this restriction.
7546
7547 @smallexample
7548 package Pkg is
7549   type T is tagged record
7550     Data : Natural;
7551   end record;
7552   procedure P (X : T);
7553
7554   type DT is new T with record
7555     More_Data : Natural;
7556   end record;
7557   procedure Q (X : DT);
7558 end Pkg;
7559
7560 with Pkg; use Pkg;
7561 procedure Example is
7562   procedure Test (O : T'Class) is
7563     N : Natural  := O'Size;--  Error: Dispatching call
7564     C : T'Class := O;      --  Error: implicit Dispatching Call
7565   begin
7566     if O in DT'Class then  --  OK   : Membership test
7567        Q (DT (O));         --  OK   : Type conversion plus direct call
7568     else
7569        P (O);              --  Error: Dispatching call
7570     end if;
7571   end Test;
7572
7573   Obj : DT;
7574 begin
7575   P (Obj);                 --  OK   : Direct call
7576   P (T (Obj));             --  OK   : Type conversion plus direct call
7577   P (T'Class (Obj));       --  Error: Dispatching call
7578
7579   Test (Obj);              --  OK   : Type conversion
7580
7581   if Obj in T'Class then   --  OK   : Membership test
7582      null;
7583   end if;
7584 end Example;
7585 @end smallexample
7586
7587 @item No_Dynamic_Attachment
7588 @findex No_Dynamic_Attachment
7589 This restriction ensures that there is no call to any of the operations
7590 defined in package Ada.Interrupts.
7591
7592 @item No_Enumeration_Maps
7593 @findex No_Enumeration_Maps
7594 This restriction ensures at compile time that no operations requiring
7595 enumeration maps are used (that is Image and Value attributes applied
7596 to enumeration types).
7597
7598 @item No_Entry_Calls_In_Elaboration_Code
7599 @findex No_Entry_Calls_In_Elaboration_Code
7600 This restriction ensures at compile time that no task or protected entry
7601 calls are made during elaboration code.  As a result of the use of this
7602 restriction, the compiler can assume that no code past an accept statement
7603 in a task can be executed at elaboration time.
7604
7605 @item No_Exception_Handlers
7606 @findex No_Exception_Handlers
7607 This restriction ensures at compile time that there are no explicit
7608 exception handlers. It also indicates that no exception propagation will
7609 be provided. In this mode, exceptions may be raised but will result in
7610 an immediate call to the last chance handler, a routine that the user
7611 must define with the following profile:
7612
7613    procedure Last_Chance_Handler
7614      (Source_Location : System.Address; Line : Integer);
7615    pragma Export (C, Last_Chance_Handler,
7616                   "__gnat_last_chance_handler");
7617
7618    The parameter is a C null-terminated string representing a message to be
7619    associated with the exception (typically the source location of the raise
7620    statement generated by the compiler). The Line parameter when nonzero
7621    represents the line number in the source program where the raise occurs.
7622
7623 @item No_Exception_Propagation
7624 @findex No_Exception_Propagation
7625 This restriction guarantees that exceptions are never propagated to an outer
7626 subprogram scope). The only case in which an exception may be raised is when
7627 the handler is statically in the same subprogram, so that the effect of a raise
7628 is essentially like a goto statement. Any other raise statement (implicit or
7629 explicit) will be considered unhandled. Exception handlers are allowed, but may
7630 not contain an exception occurrence identifier (exception choice). In addition
7631 use of the package GNAT.Current_Exception is not permitted, and reraise
7632 statements (raise with no operand) are not permitted.
7633
7634 @item No_Exception_Registration
7635 @findex No_Exception_Registration
7636 This restriction ensures at compile time that no stream operations for
7637 types Exception_Id or Exception_Occurrence are used. This also makes it
7638 impossible to pass exceptions to or from a partition with this restriction
7639 in a distributed environment. If this exception is active, then the generated
7640 code is simplified by omitting the otherwise-required global registration
7641 of exceptions when they are declared.
7642
7643 @item No_Implicit_Conditionals
7644 @findex No_Implicit_Conditionals
7645 This restriction ensures that the generated code does not contain any
7646 implicit conditionals, either by modifying the generated code where possible,
7647 or by rejecting any construct that would otherwise generate an implicit
7648 conditional. Note that this check does not include run time constraint
7649 checks, which on some targets may generate implicit conditionals as
7650 well. To control the latter, constraint checks can be suppressed in the
7651 normal manner. Constructs generating implicit conditionals include comparisons
7652 of composite objects and the Max/Min attributes.
7653
7654 @item No_Implicit_Dynamic_Code
7655 @findex No_Implicit_Dynamic_Code
7656 This restriction prevents the compiler from building ``trampolines''.
7657 This is a structure that is built on the stack and contains dynamic
7658 code to be executed at run time. A trampoline is needed to indirectly
7659 address a nested subprogram (that is a subprogram that is not at the
7660 library level). The restriction prevents the use of any of the
7661 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7662 being applied to a subprogram that is not at the library level.
7663
7664 @item No_Implicit_Loops
7665 @findex No_Implicit_Loops
7666 This restriction ensures that the generated code does not contain any
7667 implicit @code{for} loops, either by modifying
7668 the generated code where possible,
7669 or by rejecting any construct that would otherwise generate an implicit
7670 @code{for} loop.
7671
7672 @item No_Initialize_Scalars
7673 @findex No_Initialize_Scalars
7674 This restriction ensures that no unit in the partition is compiled with
7675 pragma Initialize_Scalars. This allows the generation of more efficient
7676 code, and in particular eliminates dummy null initialization routines that
7677 are otherwise generated for some record and array types.
7678
7679 @item No_Local_Protected_Objects
7680 @findex No_Local_Protected_Objects
7681 This restriction ensures at compile time that protected objects are
7682 only declared at the library level.
7683
7684 @item No_Protected_Type_Allocators
7685 @findex No_Protected_Type_Allocators
7686 This restriction ensures at compile time that there are no allocator
7687 expressions that attempt to allocate protected objects.
7688
7689 @item No_Secondary_Stack
7690 @findex No_Secondary_Stack
7691 This restriction ensures at compile time that the generated code does not
7692 contain any reference to the secondary stack.  The secondary stack is used
7693 to implement functions returning unconstrained objects (arrays or records)
7694 on some targets.
7695
7696 @item No_Select_Statements
7697 @findex No_Select_Statements
7698 This restriction ensures at compile time no select statements of any kind
7699 are permitted, that is the keyword @code{select} may not appear.
7700 This is one of the restrictions of the Ravenscar
7701 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7702
7703 @item No_Standard_Storage_Pools
7704 @findex No_Standard_Storage_Pools
7705 This restriction ensures at compile time that no access types
7706 use the standard default storage pool.  Any access type declared must
7707 have an explicit Storage_Pool attribute defined specifying a
7708 user-defined storage pool.
7709
7710 @item No_Streams
7711 @findex No_Streams
7712 This restriction ensures at compile/bind time that there are no
7713 stream objects created (and therefore no actual stream operations).
7714 This restriction does not forbid dependences on the package
7715 @code{Ada.Streams}. So it is permissible to with
7716 @code{Ada.Streams} (or another package that does so itself)
7717 as long as no actual stream objects are created.
7718
7719 @item No_Task_Attributes_Package
7720 @findex No_Task_Attributes_Package
7721 This restriction ensures at compile time that there are no implicit or
7722 explicit dependencies on the package @code{Ada.Task_Attributes}.
7723
7724 @item No_Task_Termination
7725 @findex No_Task_Termination
7726 This restriction ensures at compile time that no terminate alternatives
7727 appear in any task body.
7728
7729 @item No_Tasking
7730 @findex No_Tasking
7731 This restriction prevents the declaration of tasks or task types throughout
7732 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7733 except that violations are caught at compile time and cause an error message
7734 to be output either by the compiler or binder.
7735
7736 @item Static_Priorities
7737 @findex Static_Priorities
7738 This restriction ensures at compile time that all priority expressions
7739 are static, and that there are no dependencies on the package
7740 @code{Ada.Dynamic_Priorities}.
7741
7742 @item Static_Storage_Size
7743 @findex Static_Storage_Size
7744 This restriction ensures at compile time that any expression appearing
7745 in a Storage_Size pragma or attribute definition clause is static.
7746
7747 @end table
7748
7749 @noindent
7750 The second set of implementation dependent restriction identifiers
7751 does not require partition-wide consistency.
7752 The restriction may be enforced for a single
7753 compilation unit without any effect on any of the
7754 other compilation units in the partition.
7755
7756 @table @code
7757
7758 @item No_Elaboration_Code
7759 @findex No_Elaboration_Code
7760 This restriction ensures at compile time that no elaboration code is
7761 generated.  Note that this is not the same condition as is enforced
7762 by pragma @code{Preelaborate}.  There are cases in which pragma
7763 @code{Preelaborate} still permits code to be generated (e.g.@: code
7764 to initialize a large array to all zeroes), and there are cases of units
7765 which do not meet the requirements for pragma @code{Preelaborate},
7766 but for which no elaboration code is generated.  Generally, it is
7767 the case that preelaborable units will meet the restrictions, with
7768 the exception of large aggregates initialized with an others_clause,
7769 and exception declarations (which generate calls to a run-time
7770 registry procedure).  This restriction is enforced on
7771 a unit by unit basis, it need not be obeyed consistently
7772 throughout a partition.
7773
7774 In the case of aggregates with others, if the aggregate has a dynamic
7775 size, there is no way to eliminate the elaboration code (such dynamic
7776 bounds would be incompatible with @code{Preelaborate} in any case. If
7777 the bounds are static, then use of this restriction actually modifies
7778 the code choice of the compiler to avoid generating a loop, and instead
7779 generate the aggregate statically if possible, no matter how many times
7780 the data for the others clause must be repeatedly generated.
7781
7782 It is not possible to precisely document
7783 the constructs which are compatible with this restriction, since,
7784 unlike most other restrictions, this is not a restriction on the
7785 source code, but a restriction on the generated object code. For
7786 example, if the source contains a declaration:
7787
7788 @smallexample
7789    Val : constant Integer := X;
7790 @end smallexample
7791
7792 @noindent
7793 where X is not a static constant, it may be possible, depending
7794 on complex optimization circuitry, for the compiler to figure
7795 out the value of X at compile time, in which case this initialization
7796 can be done by the loader, and requires no initialization code. It
7797 is not possible to document the precise conditions under which the
7798 optimizer can figure this out.
7799
7800 Note that this the implementation of this restriction requires full
7801 code generation. If it is used in conjunction with "semantics only"
7802 checking, then some cases of violations may be missed.
7803
7804 @item No_Entry_Queue
7805 @findex No_Entry_Queue
7806 This restriction is a declaration that any protected entry compiled in
7807 the scope of the restriction has at most one task waiting on the entry
7808 at any one time, and so no queue is required.  This restriction is not
7809 checked at compile time.  A program execution is erroneous if an attempt
7810 is made to queue a second task on such an entry.
7811
7812 @item No_Implementation_Attributes
7813 @findex No_Implementation_Attributes
7814 This restriction checks at compile time that no GNAT-defined attributes
7815 are present.  With this restriction, the only attributes that can be used
7816 are those defined in the Ada Reference Manual.
7817
7818 @item No_Implementation_Pragmas
7819 @findex No_Implementation_Pragmas
7820 This restriction checks at compile time that no GNAT-defined pragmas
7821 are present.  With this restriction, the only pragmas that can be used
7822 are those defined in the Ada Reference Manual.
7823
7824 @item No_Implementation_Restrictions
7825 @findex No_Implementation_Restrictions
7826 This restriction checks at compile time that no GNAT-defined restriction
7827 identifiers (other than @code{No_Implementation_Restrictions} itself)
7828 are present.  With this restriction, the only other restriction identifiers
7829 that can be used are those defined in the Ada Reference Manual.
7830
7831 @item No_Wide_Characters
7832 @findex No_Wide_Characters
7833 This restriction ensures at compile time that no uses of the types
7834 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7835 wide types
7836 appear, and that no wide or wide wide string or character literals
7837 appear in the program (that is literals representing characters not in
7838 type @code{Character}.
7839
7840 @end table
7841
7842 @sp 1
7843 @cartouche
7844 @noindent
7845 @strong{58}.  The consequences of violating limitations on
7846 @code{Restrictions} pragmas.  See 13.12(9).
7847 @end cartouche
7848 @noindent
7849 Restrictions that can be checked at compile time result in illegalities
7850 if violated.  Currently there are no other consequences of violating
7851 restrictions.
7852
7853 @sp 1
7854 @cartouche
7855 @noindent
7856 @strong{59}.  The representation used by the @code{Read} and
7857 @code{Write} attributes of elementary types in terms of stream
7858 elements.  See 13.13.2(9).
7859 @end cartouche
7860 @noindent
7861 The representation is the in-memory representation of the base type of
7862 the type, using the number of bits corresponding to the
7863 @code{@var{type}'Size} value, and the natural ordering of the machine.
7864
7865 @sp 1
7866 @cartouche
7867 @noindent
7868 @strong{60}.  The names and characteristics of the numeric subtypes
7869 declared in the visible part of package @code{Standard}.  See A.1(3).
7870 @end cartouche
7871 @noindent
7872 See items describing the integer and floating-point types supported.
7873
7874 @sp 1
7875 @cartouche
7876 @noindent
7877 @strong{61}.  The accuracy actually achieved by the elementary
7878 functions.  See A.5.1(1).
7879 @end cartouche
7880 @noindent
7881 The elementary functions correspond to the functions available in the C
7882 library.  Only fast math mode is implemented.
7883
7884 @sp 1
7885 @cartouche
7886 @noindent
7887 @strong{62}.  The sign of a zero result from some of the operators or
7888 functions in @code{Numerics.Generic_Elementary_Functions}, when
7889 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7890 @end cartouche
7891 @noindent
7892 The sign of zeroes follows the requirements of the IEEE 754 standard on
7893 floating-point.
7894
7895 @sp 1
7896 @cartouche
7897 @noindent
7898 @strong{63}.  The value of
7899 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7900 @end cartouche
7901 @noindent
7902 Maximum image width is 649, see library file @file{a-numran.ads}.
7903
7904 @sp 1
7905 @cartouche
7906 @noindent
7907 @strong{64}.  The value of
7908 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7909 @end cartouche
7910 @noindent
7911 Maximum image width is 80, see library file @file{a-nudira.ads}.
7912
7913 @sp 1
7914 @cartouche
7915 @noindent
7916 @strong{65}.  The algorithms for random number generation.  See
7917 A.5.2(32).
7918 @end cartouche
7919 @noindent
7920 The algorithm is documented in the source files @file{a-numran.ads} and
7921 @file{a-numran.adb}.
7922
7923 @sp 1
7924 @cartouche
7925 @noindent
7926 @strong{66}.  The string representation of a random number generator's
7927 state.  See A.5.2(38).
7928 @end cartouche
7929 @noindent
7930 See the documentation contained in the file @file{a-numran.adb}.
7931
7932 @sp 1
7933 @cartouche
7934 @noindent
7935 @strong{67}.  The minimum time interval between calls to the
7936 time-dependent Reset procedure that are guaranteed to initiate different
7937 random number sequences.  See A.5.2(45).
7938 @end cartouche
7939 @noindent
7940 The minimum period between reset calls to guarantee distinct series of
7941 random numbers is one microsecond.
7942
7943 @sp 1
7944 @cartouche
7945 @noindent
7946 @strong{68}.  The values of the @code{Model_Mantissa},
7947 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7948 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7949 Annex is not supported.  See A.5.3(72).
7950 @end cartouche
7951 @noindent
7952 See the source file @file{ttypef.ads} for the values of all numeric
7953 attributes.
7954
7955 @sp 1
7956 @cartouche
7957 @noindent
7958 @strong{69}.  Any implementation-defined characteristics of the
7959 input-output packages.  See A.7(14).
7960 @end cartouche
7961 @noindent
7962 There are no special implementation defined characteristics for these
7963 packages.
7964
7965 @sp 1
7966 @cartouche
7967 @noindent
7968 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7969 A.9(10).
7970 @end cartouche
7971 @noindent
7972 All type representations are contiguous, and the @code{Buffer_Size} is
7973 the value of @code{@var{type}'Size} rounded up to the next storage unit
7974 boundary.
7975
7976 @sp 1
7977 @cartouche
7978 @noindent
7979 @strong{71}.  External files for standard input, standard output, and
7980 standard error See A.10(5).
7981 @end cartouche
7982 @noindent
7983 These files are mapped onto the files provided by the C streams
7984 libraries.  See source file @file{i-cstrea.ads} for further details.
7985
7986 @sp 1
7987 @cartouche
7988 @noindent
7989 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7990 A.10.9(36).
7991 @end cartouche
7992 @noindent
7993 If more digits are requested in the output than are represented by the
7994 precision of the value, zeroes are output in the corresponding least
7995 significant digit positions.
7996
7997 @sp 1
7998 @cartouche
7999 @noindent
8000 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8001 @code{Command_Name}.  See A.15(1).
8002 @end cartouche
8003 @noindent
8004 These are mapped onto the @code{argv} and @code{argc} parameters of the
8005 main program in the natural manner.
8006
8007 @sp 1
8008 @cartouche
8009 @noindent
8010 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8011 @end cartouche
8012 @noindent
8013 The following convention names are supported
8014
8015 @table @code
8016 @item  Ada
8017 Ada
8018 @item Assembler
8019 Assembly language
8020 @item Asm
8021 Synonym for Assembler
8022 @item Assembly
8023 Synonym for Assembler
8024 @item C
8025 C
8026 @item C_Pass_By_Copy
8027 Allowed only for record types, like C, but also notes that record
8028 is to be passed by copy rather than reference.
8029 @item COBOL
8030 COBOL
8031 @item C_Plus_Plus (or CPP)
8032 C++
8033 @item Default
8034 Treated the same as C
8035 @item External
8036 Treated the same as C
8037 @item Fortran
8038 Fortran
8039 @item Intrinsic
8040 For support of pragma @code{Import} with convention Intrinsic, see
8041 separate section on Intrinsic Subprograms.
8042 @item Stdcall
8043 Stdcall (used for Windows implementations only).  This convention correspond
8044 to the WINAPI (previously called Pascal convention) C/C++ convention under
8045 Windows.  A function with this convention cleans the stack before exit.
8046 @item DLL
8047 Synonym for Stdcall
8048 @item Win32
8049 Synonym for Stdcall
8050 @item Stubbed
8051 Stubbed is a special convention used to indicate that the body of the
8052 subprogram will be entirely ignored.  Any call to the subprogram
8053 is converted into a raise of the @code{Program_Error} exception.  If a
8054 pragma @code{Import} specifies convention @code{stubbed} then no body need
8055 be present at all.  This convention is useful during development for the
8056 inclusion of subprograms whose body has not yet been written.
8057
8058 @end table
8059 @noindent
8060 In addition, all otherwise unrecognized convention names are also
8061 treated as being synonymous with convention C@.  In all implementations
8062 except for VMS, use of such other names results in a warning.  In VMS
8063 implementations, these names are accepted silently.
8064
8065 @sp 1
8066 @cartouche
8067 @noindent
8068 @strong{75}.  The meaning of link names.  See B.1(36).
8069 @end cartouche
8070 @noindent
8071 Link names are the actual names used by the linker.
8072
8073 @sp 1
8074 @cartouche
8075 @noindent
8076 @strong{76}.  The manner of choosing link names when neither the link
8077 name nor the address of an imported or exported entity is specified.  See
8078 B.1(36).
8079 @end cartouche
8080 @noindent
8081 The default linker name is that which would be assigned by the relevant
8082 external language, interpreting the Ada name as being in all lower case
8083 letters.
8084
8085 @sp 1
8086 @cartouche
8087 @noindent
8088 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8089 @end cartouche
8090 @noindent
8091 The string passed to @code{Linker_Options} is presented uninterpreted as
8092 an argument to the link command, unless it contains Ascii.NUL characters.
8093 NUL characters if they appear act as argument separators, so for example
8094
8095 @smallexample @c ada
8096 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8097 @end smallexample
8098
8099 @noindent
8100 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8101 linker. The order of linker options is preserved for a given unit. The final
8102 list of options passed to the linker is in reverse order of the elaboration
8103 order. For example, linker options fo a body always appear before the options
8104 from the corresponding package spec.
8105
8106 @sp 1
8107 @cartouche
8108 @noindent
8109 @strong{78}.  The contents of the visible part of package
8110 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8111 @end cartouche
8112 @noindent
8113 See files with prefix @file{i-} in the distributed library.
8114
8115 @sp 1
8116 @cartouche
8117 @noindent
8118 @strong{79}.  Implementation-defined children of package
8119 @code{Interfaces}.  The contents of the visible part of package
8120 @code{Interfaces}.  See B.2(11).
8121 @end cartouche
8122 @noindent
8123 See files with prefix @file{i-} in the distributed library.
8124
8125 @sp 1
8126 @cartouche
8127 @noindent
8128 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8129 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8130 @code{COBOL_Character}; and the initialization of the variables
8131 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8132 @code{Interfaces.COBOL}.  See B.4(50).
8133 @end cartouche
8134 @noindent
8135 @table @code
8136 @item Floating
8137 Float
8138 @item Long_Floating
8139 (Floating) Long_Float
8140 @item Binary
8141 Integer
8142 @item Long_Binary
8143 Long_Long_Integer
8144 @item Decimal_Element
8145 Character
8146 @item COBOL_Character
8147 Character
8148 @end table
8149
8150 @noindent
8151 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8152
8153 @sp 1
8154 @cartouche
8155 @noindent
8156 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8157 @end cartouche
8158 @noindent
8159 See documentation in file @file{s-maccod.ads} in the distributed library.
8160
8161 @sp 1
8162 @cartouche
8163 @noindent
8164 @strong{82}.  Implementation-defined aspects of access to machine
8165 operations.  See C.1(9).
8166 @end cartouche
8167 @noindent
8168 See documentation in file @file{s-maccod.ads} in the distributed library.
8169
8170 @sp 1
8171 @cartouche
8172 @noindent
8173 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8174 @end cartouche
8175 @noindent
8176 Interrupts are mapped to signals or conditions as appropriate.  See
8177 definition of unit
8178 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8179 on the interrupts supported on a particular target.
8180
8181 @sp 1
8182 @cartouche
8183 @noindent
8184 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8185 C.4(13).
8186 @end cartouche
8187 @noindent
8188 GNAT does not permit a partition to be restarted without reloading,
8189 except under control of the debugger.
8190
8191 @sp 1
8192 @cartouche
8193 @noindent
8194 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8195 @end cartouche
8196 @noindent
8197 Pragma @code{Discard_Names} causes names of enumeration literals to
8198 be suppressed.  In the presence of this pragma, the Image attribute
8199 provides the image of the Pos of the literal, and Value accepts
8200 Pos values.
8201
8202 @sp 1
8203 @cartouche
8204 @noindent
8205 @strong{86}.  The result of the @code{Task_Identification.Image}
8206 attribute.  See C.7.1(7).
8207 @end cartouche
8208 @noindent
8209 The result of this attribute is a string that identifies
8210 the object or component that denotes a given task. If a variable Var has a task
8211 type, the image for this task will have the form Var_XXXXXXXX, where the
8212 suffix
8213 is the hexadecimal representation of the virtual address of the corresponding
8214 task control block. If the variable is an array of tasks, the image of each
8215 task will have the form of an indexed component indicating the position of a
8216 given task in the array, eg.  Group(5)_XXXXXXX. If the task is a
8217 component of a record, the image of the task will have the form of a selected
8218 component. These rules are fully recursive, so that the image of a task that
8219 is a subcomponent of a composite object corresponds to the expression that
8220 designates this task.
8221 @noindent
8222 If a task is created by an allocator, its image depends on the context. If the
8223 allocator is part of an object declaration, the rules described above are used
8224 to construct its image, and this image is not affected by subsequent
8225 assignments. If the allocator appears within an expression, the image
8226 includes only the name of the task type.
8227 @noindent
8228 If the configuration pragma Discard_Names is present, or if the restriction
8229 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8230 the numeric suffix, that is to say the hexadecimal representation of the
8231 virtual address of the control block of the task.
8232 @sp 1
8233 @cartouche
8234 @noindent
8235 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8236 or interrupt handler.  See C.7.1(17).
8237 @end cartouche
8238 @noindent
8239 Protected entries or interrupt handlers can be executed by any
8240 convenient thread, so the value of @code{Current_Task} is undefined.
8241
8242 @sp 1
8243 @cartouche
8244 @noindent
8245 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8246 body or interrupt handler.  See C.7.1(19).
8247 @end cartouche
8248 @noindent
8249 The effect of calling @code{Current_Task} from an entry body or
8250 interrupt handler is to return the identification of the task currently
8251 executing the code.
8252
8253 @sp 1
8254 @cartouche
8255 @noindent
8256 @strong{89}.  Implementation-defined aspects of
8257 @code{Task_Attributes}.  See C.7.2(19).
8258 @end cartouche
8259 @noindent
8260 There are no implementation-defined aspects of @code{Task_Attributes}.
8261
8262 @sp 1
8263 @cartouche
8264 @noindent
8265 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8266 @end cartouche
8267 @noindent
8268 The metrics information for GNAT depends on the performance of the
8269 underlying operating system.  The sources of the run-time for tasking
8270 implementation, together with the output from @code{-gnatG} can be
8271 used to determine the exact sequence of operating systems calls made
8272 to implement various tasking constructs.  Together with appropriate
8273 information on the performance of the underlying operating system,
8274 on the exact target in use, this information can be used to determine
8275 the required metrics.
8276
8277 @sp 1
8278 @cartouche
8279 @noindent
8280 @strong{91}.  The declarations of @code{Any_Priority} and
8281 @code{Priority}.  See D.1(11).
8282 @end cartouche
8283 @noindent
8284 See declarations in file @file{system.ads}.
8285
8286 @sp 1
8287 @cartouche
8288 @noindent
8289 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8290 @end cartouche
8291 @noindent
8292 There are no implementation-defined execution resources.
8293
8294 @sp 1
8295 @cartouche
8296 @noindent
8297 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8298 access to a protected object keeps its processor busy.  See D.2.1(3).
8299 @end cartouche
8300 @noindent
8301 On a multi-processor, a task that is waiting for access to a protected
8302 object does not keep its processor busy.
8303
8304 @sp 1
8305 @cartouche
8306 @noindent
8307 @strong{94}.  The affect of implementation defined execution resources
8308 on task dispatching.  See D.2.1(9).
8309 @end cartouche
8310 @noindent
8311 @c SGI info
8312 @ignore
8313 Tasks map to IRIX threads, and the dispatching policy is as defined by
8314 the IRIX implementation of threads.
8315 @end ignore
8316 Tasks map to threads in the threads package used by GNAT@.  Where possible
8317 and appropriate, these threads correspond to native threads of the
8318 underlying operating system.
8319
8320 @sp 1
8321 @cartouche
8322 @noindent
8323 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8324 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8325 @end cartouche
8326 @noindent
8327 There are no implementation-defined policy-identifiers allowed in this
8328 pragma.
8329
8330 @sp 1
8331 @cartouche
8332 @noindent
8333 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8334 D.2.2(16).
8335 @end cartouche
8336 @noindent
8337 Execution of a task cannot be preempted by the implementation processing
8338 of delay expirations for lower priority tasks.
8339
8340 @sp 1
8341 @cartouche
8342 @noindent
8343 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8344 @end cartouche
8345 @noindent
8346 @c SGI info:
8347 @ignore
8348 Tasks map to IRIX threads, and the dispatching policy is as defined by
8349 the IRIX implementation of threads.
8350 @end ignore
8351 The policy is the same as that of the underlying threads implementation.
8352
8353 @sp 1
8354 @cartouche
8355 @noindent
8356 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8357 in a pragma @code{Locking_Policy}.  See D.3(4).
8358 @end cartouche
8359 @noindent
8360 The only implementation defined policy permitted in GNAT is
8361 @code{Inheritance_Locking}.  On targets that support this policy, locking
8362 is implemented by inheritance, i.e.@: the task owning the lock operates
8363 at a priority equal to the highest priority of any task currently
8364 requesting the lock.
8365
8366 @sp 1
8367 @cartouche
8368 @noindent
8369 @strong{99}.  Default ceiling priorities.  See D.3(10).
8370 @end cartouche
8371 @noindent
8372 The ceiling priority of protected objects of the type
8373 @code{System.Interrupt_Priority'Last} as described in the Ada
8374 Reference Manual D.3(10),
8375
8376 @sp 1
8377 @cartouche
8378 @noindent
8379 @strong{100}.  The ceiling of any protected object used internally by
8380 the implementation.  See D.3(16).
8381 @end cartouche
8382 @noindent
8383 The ceiling priority of internal protected objects is
8384 @code{System.Priority'Last}.
8385
8386 @sp 1
8387 @cartouche
8388 @noindent
8389 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8390 @end cartouche
8391 @noindent
8392 There are no implementation-defined queuing policies.
8393
8394 @sp 1
8395 @cartouche
8396 @noindent
8397 @strong{102}.  On a multiprocessor, any conditions that cause the
8398 completion of an aborted construct to be delayed later than what is
8399 specified for a single processor.  See D.6(3).
8400 @end cartouche
8401 @noindent
8402 The semantics for abort on a multi-processor is the same as on a single
8403 processor, there are no further delays.
8404
8405 @sp 1
8406 @cartouche
8407 @noindent
8408 @strong{103}.  Any operations that implicitly require heap storage
8409 allocation.  See D.7(8).
8410 @end cartouche
8411 @noindent
8412 The only operation that implicitly requires heap storage allocation is
8413 task creation.
8414
8415 @sp 1
8416 @cartouche
8417 @noindent
8418 @strong{104}.  Implementation-defined aspects of pragma
8419 @code{Restrictions}.  See D.7(20).
8420 @end cartouche
8421 @noindent
8422 There are no such implementation-defined aspects.
8423
8424 @sp 1
8425 @cartouche
8426 @noindent
8427 @strong{105}.  Implementation-defined aspects of package
8428 @code{Real_Time}.  See D.8(17).
8429 @end cartouche
8430 @noindent
8431 There are no implementation defined aspects of package @code{Real_Time}.
8432
8433 @sp 1
8434 @cartouche
8435 @noindent
8436 @strong{106}.  Implementation-defined aspects of
8437 @code{delay_statements}.  See D.9(8).
8438 @end cartouche
8439 @noindent
8440 Any difference greater than one microsecond will cause the task to be
8441 delayed (see D.9(7)).
8442
8443 @sp 1
8444 @cartouche
8445 @noindent
8446 @strong{107}.  The upper bound on the duration of interrupt blocking
8447 caused by the implementation.  See D.12(5).
8448 @end cartouche
8449 @noindent
8450 The upper bound is determined by the underlying operating system.  In
8451 no cases is it more than 10 milliseconds.
8452
8453 @sp 1
8454 @cartouche
8455 @noindent
8456 @strong{108}.  The means for creating and executing distributed
8457 programs.  See E(5).
8458 @end cartouche
8459 @noindent
8460 The GLADE package provides a utility GNATDIST for creating and executing
8461 distributed programs.  See the GLADE reference manual for further details.
8462
8463 @sp 1
8464 @cartouche
8465 @noindent
8466 @strong{109}.  Any events that can result in a partition becoming
8467 inaccessible.  See E.1(7).
8468 @end cartouche
8469 @noindent
8470 See the GLADE reference manual for full details on such events.
8471
8472 @sp 1
8473 @cartouche
8474 @noindent
8475 @strong{110}.  The scheduling policies, treatment of priorities, and
8476 management of shared resources between partitions in certain cases.  See
8477 E.1(11).
8478 @end cartouche
8479 @noindent
8480 See the GLADE reference manual for full details on these aspects of
8481 multi-partition execution.
8482
8483 @sp 1
8484 @cartouche
8485 @noindent
8486 @strong{111}.  Events that cause the version of a compilation unit to
8487 change.  See E.3(5).
8488 @end cartouche
8489 @noindent
8490 Editing the source file of a compilation unit, or the source files of
8491 any units on which it is dependent in a significant way cause the version
8492 to change.  No other actions cause the version number to change.  All changes
8493 are significant except those which affect only layout, capitalization or
8494 comments.
8495
8496 @sp 1
8497 @cartouche
8498 @noindent
8499 @strong{112}.  Whether the execution of the remote subprogram is
8500 immediately aborted as a result of cancellation.  See E.4(13).
8501 @end cartouche
8502 @noindent
8503 See the GLADE reference manual for details on the effect of abort in
8504 a distributed application.
8505
8506 @sp 1
8507 @cartouche
8508 @noindent
8509 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8510 @end cartouche
8511 @noindent
8512 See the GLADE reference manual for a full description of all implementation
8513 defined aspects of the PCS@.
8514
8515 @sp 1
8516 @cartouche
8517 @noindent
8518 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8519 E.5(26).
8520 @end cartouche
8521 @noindent
8522 See the GLADE reference manual for a full description of all
8523 implementation defined interfaces.
8524
8525 @sp 1
8526 @cartouche
8527 @noindent
8528 @strong{115}.  The values of named numbers in the package
8529 @code{Decimal}.  See F.2(7).
8530 @end cartouche
8531 @noindent
8532 @table @code
8533 @item Max_Scale
8534 +18
8535 @item Min_Scale
8536 -18
8537 @item Min_Delta
8538 1.0E-18
8539 @item Max_Delta
8540 1.0E+18
8541 @item Max_Decimal_Digits
8542 18
8543 @end table
8544
8545 @sp 1
8546 @cartouche
8547 @noindent
8548 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8549 @code{Text_IO.Editing}.  See F.3.3(16).
8550 @end cartouche
8551 @noindent
8552 64
8553
8554 @sp 1
8555 @cartouche
8556 @noindent
8557 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8558 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8559 @end cartouche
8560 @noindent
8561 64
8562
8563 @sp 1
8564 @cartouche
8565 @noindent
8566 @strong{118}.  The accuracy actually achieved by the complex elementary
8567 functions and by other complex arithmetic operations.  See G.1(1).
8568 @end cartouche
8569 @noindent
8570 Standard library functions are used for the complex arithmetic
8571 operations.  Only fast math mode is currently supported.
8572
8573 @sp 1
8574 @cartouche
8575 @noindent
8576 @strong{119}.  The sign of a zero result (or a component thereof) from
8577 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8578 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8579 @end cartouche
8580 @noindent
8581 The signs of zero values are as recommended by the relevant
8582 implementation advice.
8583
8584 @sp 1
8585 @cartouche
8586 @noindent
8587 @strong{120}.  The sign of a zero result (or a component thereof) from
8588 any operator or function in
8589 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8590 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8591 @end cartouche
8592 @noindent
8593 The signs of zero values are as recommended by the relevant
8594 implementation advice.
8595
8596 @sp 1
8597 @cartouche
8598 @noindent
8599 @strong{121}.  Whether the strict mode or the relaxed mode is the
8600 default.  See G.2(2).
8601 @end cartouche
8602 @noindent
8603 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8604 provides a highly efficient implementation of strict mode.
8605
8606 @sp 1
8607 @cartouche
8608 @noindent
8609 @strong{122}.  The result interval in certain cases of fixed-to-float
8610 conversion.  See G.2.1(10).
8611 @end cartouche
8612 @noindent
8613 For cases where the result interval is implementation dependent, the
8614 accuracy is that provided by performing all operations in 64-bit IEEE
8615 floating-point format.
8616
8617 @sp 1
8618 @cartouche
8619 @noindent
8620 @strong{123}.  The result of a floating point arithmetic operation in
8621 overflow situations, when the @code{Machine_Overflows} attribute of the
8622 result type is @code{False}.  See G.2.1(13).
8623 @end cartouche
8624 @noindent
8625 Infinite and NaN values are produced as dictated by the IEEE
8626 floating-point standard.
8627
8628 Note that on machines that are not fully compliant with the IEEE
8629 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8630 must be used for achieving IEEE confirming behavior (although at the cost
8631 of a significant performance penalty), so infinite and NaN values are
8632 properly generated.
8633
8634 @sp 1
8635 @cartouche
8636 @noindent
8637 @strong{124}.  The result interval for division (or exponentiation by a
8638 negative exponent), when the floating point hardware implements division
8639 as multiplication by a reciprocal.  See G.2.1(16).
8640 @end cartouche
8641 @noindent
8642 Not relevant, division is IEEE exact.
8643
8644 @sp 1
8645 @cartouche
8646 @noindent
8647 @strong{125}.  The definition of close result set, which determines the
8648 accuracy of certain fixed point multiplications and divisions.  See
8649 G.2.3(5).
8650 @end cartouche
8651 @noindent
8652 Operations in the close result set are performed using IEEE long format
8653 floating-point arithmetic.  The input operands are converted to
8654 floating-point, the operation is done in floating-point, and the result
8655 is converted to the target type.
8656
8657 @sp 1
8658 @cartouche
8659 @noindent
8660 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8661 point multiplication or division for which the result shall be in the
8662 perfect result set.  See G.2.3(22).
8663 @end cartouche
8664 @noindent
8665 The result is only defined to be in the perfect result set if the result
8666 can be computed by a single scaling operation involving a scale factor
8667 representable in 64-bits.
8668
8669 @sp 1
8670 @cartouche
8671 @noindent
8672 @strong{127}.  The result of a fixed point arithmetic operation in
8673 overflow situations, when the @code{Machine_Overflows} attribute of the
8674 result type is @code{False}.  See G.2.3(27).
8675 @end cartouche
8676 @noindent
8677 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8678 types.
8679
8680 @sp 1
8681 @cartouche
8682 @noindent
8683 @strong{128}.  The result of an elementary function reference in
8684 overflow situations, when the @code{Machine_Overflows} attribute of the
8685 result type is @code{False}.  See G.2.4(4).
8686 @end cartouche
8687 @noindent
8688 IEEE infinite and Nan values are produced as appropriate.
8689
8690 @sp 1
8691 @cartouche
8692 @noindent
8693 @strong{129}.  The value of the angle threshold, within which certain
8694 elementary functions, complex arithmetic operations, and complex
8695 elementary functions yield results conforming to a maximum relative
8696 error bound.  See G.2.4(10).
8697 @end cartouche
8698 @noindent
8699 Information on this subject is not yet available.
8700
8701 @sp 1
8702 @cartouche
8703 @noindent
8704 @strong{130}.  The accuracy of certain elementary functions for
8705 parameters beyond the angle threshold.  See G.2.4(10).
8706 @end cartouche
8707 @noindent
8708 Information on this subject is not yet available.
8709
8710 @sp 1
8711 @cartouche
8712 @noindent
8713 @strong{131}.  The result of a complex arithmetic operation or complex
8714 elementary function reference in overflow situations, when the
8715 @code{Machine_Overflows} attribute of the corresponding real type is
8716 @code{False}.  See G.2.6(5).
8717 @end cartouche
8718 @noindent
8719 IEEE infinite and Nan values are produced as appropriate.
8720
8721 @sp 1
8722 @cartouche
8723 @noindent
8724 @strong{132}.  The accuracy of certain complex arithmetic operations and
8725 certain complex elementary functions for parameters (or components
8726 thereof) beyond the angle threshold.  See G.2.6(8).
8727 @end cartouche
8728 @noindent
8729 Information on those subjects is not yet available.
8730
8731 @sp 1
8732 @cartouche
8733 @noindent
8734 @strong{133}.  Information regarding bounded errors and erroneous
8735 execution.  See H.2(1).
8736 @end cartouche
8737 @noindent
8738 Information on this subject is not yet available.
8739
8740 @sp 1
8741 @cartouche
8742 @noindent
8743 @strong{134}.  Implementation-defined aspects of pragma
8744 @code{Inspection_Point}.  See H.3.2(8).
8745 @end cartouche
8746 @noindent
8747 Pragma @code{Inspection_Point} ensures that the variable is live and can
8748 be examined by the debugger at the inspection point.
8749
8750 @sp 1
8751 @cartouche
8752 @noindent
8753 @strong{135}.  Implementation-defined aspects of pragma
8754 @code{Restrictions}.  See H.4(25).
8755 @end cartouche
8756 @noindent
8757 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8758 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8759 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8760
8761 @sp 1
8762 @cartouche
8763 @noindent
8764 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8765 H.4(27).
8766 @end cartouche
8767 @noindent
8768 There are no restrictions on pragma @code{Restrictions}.
8769
8770 @node Intrinsic Subprograms
8771 @chapter Intrinsic Subprograms
8772 @cindex Intrinsic Subprograms
8773
8774 @menu
8775 * Intrinsic Operators::
8776 * Enclosing_Entity::
8777 * Exception_Information::
8778 * Exception_Message::
8779 * Exception_Name::
8780 * File::
8781 * Line::
8782 * Rotate_Left::
8783 * Rotate_Right::
8784 * Shift_Left::
8785 * Shift_Right::
8786 * Shift_Right_Arithmetic::
8787 * Source_Location::
8788 @end menu
8789
8790 @noindent
8791 GNAT allows a user application program to write the declaration:
8792
8793 @smallexample @c ada
8794    pragma Import (Intrinsic, name);
8795 @end smallexample
8796
8797 @noindent
8798 providing that the name corresponds to one of the implemented intrinsic
8799 subprograms in GNAT, and that the parameter profile of the referenced
8800 subprogram meets the requirements.  This chapter describes the set of
8801 implemented intrinsic subprograms, and the requirements on parameter profiles.
8802 Note that no body is supplied; as with other uses of pragma Import, the
8803 body is supplied elsewhere (in this case by the compiler itself).  Note
8804 that any use of this feature is potentially non-portable, since the
8805 Ada standard does not require Ada compilers to implement this feature.
8806
8807 @node Intrinsic Operators
8808 @section Intrinsic Operators
8809 @cindex Intrinsic operator
8810
8811 @noindent
8812 All the predefined numeric operators in package Standard
8813 in @code{pragma Import (Intrinsic,..)}
8814 declarations.  In the binary operator case, the operands must have the same
8815 size.  The operand or operands must also be appropriate for
8816 the operator.  For example, for addition, the operands must
8817 both be floating-point or both be fixed-point, and the
8818 right operand for @code{"**"} must have a root type of
8819 @code{Standard.Integer'Base}.
8820 You can use an intrinsic operator declaration as in the following example:
8821
8822 @smallexample @c ada
8823    type Int1 is new Integer;
8824    type Int2 is new Integer;
8825
8826    function "+" (X1 : Int1; X2 : Int2) return Int1;
8827    function "+" (X1 : Int1; X2 : Int2) return Int2;
8828    pragma Import (Intrinsic, "+");
8829 @end smallexample
8830
8831 @noindent
8832 This declaration would permit ``mixed mode'' arithmetic on items
8833 of the differing types @code{Int1} and @code{Int2}.
8834 It is also possible to specify such operators for private types, if the
8835 full views are appropriate arithmetic types.
8836
8837 @node Enclosing_Entity
8838 @section Enclosing_Entity
8839 @cindex Enclosing_Entity
8840 @noindent
8841 This intrinsic subprogram is used in the implementation of the
8842 library routine @code{GNAT.Source_Info}.  The only useful use of the
8843 intrinsic import in this case is the one in this unit, so an
8844 application program should simply call the function
8845 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8846 the current subprogram, package, task, entry, or protected subprogram.
8847
8848 @node Exception_Information
8849 @section Exception_Information
8850 @cindex Exception_Information'
8851 @noindent
8852 This intrinsic subprogram is used in the implementation of the
8853 library routine @code{GNAT.Current_Exception}.  The only useful
8854 use of the intrinsic import in this case is the one in this unit,
8855 so an application program should simply call the function
8856 @code{GNAT.Current_Exception.Exception_Information} to obtain
8857 the exception information associated with the current exception.
8858
8859 @node Exception_Message
8860 @section Exception_Message
8861 @cindex Exception_Message
8862 @noindent
8863 This intrinsic subprogram is used in the implementation of the
8864 library routine @code{GNAT.Current_Exception}.  The only useful
8865 use of the intrinsic import in this case is the one in this unit,
8866 so an application program should simply call the function
8867 @code{GNAT.Current_Exception.Exception_Message} to obtain
8868 the message associated with the current exception.
8869
8870 @node Exception_Name
8871 @section Exception_Name
8872 @cindex Exception_Name
8873 @noindent
8874 This intrinsic subprogram is used in the implementation of the
8875 library routine @code{GNAT.Current_Exception}.  The only useful
8876 use of the intrinsic import in this case is the one in this unit,
8877 so an application program should simply call the function
8878 @code{GNAT.Current_Exception.Exception_Name} to obtain
8879 the name of the current exception.
8880
8881 @node File
8882 @section File
8883 @cindex File
8884 @noindent
8885 This intrinsic subprogram is used in the implementation of the
8886 library routine @code{GNAT.Source_Info}.  The only useful use of the
8887 intrinsic import in this case is the one in this unit, so an
8888 application program should simply call the function
8889 @code{GNAT.Source_Info.File} to obtain the name of the current
8890 file.
8891
8892 @node Line
8893 @section Line
8894 @cindex Line
8895 @noindent
8896 This intrinsic subprogram is used in the implementation of the
8897 library routine @code{GNAT.Source_Info}.  The only useful use of the
8898 intrinsic import in this case is the one in this unit, so an
8899 application program should simply call the function
8900 @code{GNAT.Source_Info.Line} to obtain the number of the current
8901 source line.
8902
8903 @node Rotate_Left
8904 @section Rotate_Left
8905 @cindex Rotate_Left
8906 @noindent
8907 In standard Ada, the @code{Rotate_Left} function is available only
8908 for the predefined modular types in package @code{Interfaces}.  However, in
8909 GNAT it is possible to define a Rotate_Left function for a user
8910 defined modular type or any signed integer type as in this example:
8911
8912 @smallexample @c ada
8913    function Shift_Left
8914      (Value  : My_Modular_Type;
8915       Amount : Natural)
8916       return   My_Modular_Type;
8917 @end smallexample
8918
8919 @noindent
8920 The requirements are that the profile be exactly as in the example
8921 above.  The only modifications allowed are in the formal parameter
8922 names, and in the type of @code{Value} and the return type, which
8923 must be the same, and must be either a signed integer type, or
8924 a modular integer type with a binary modulus, and the size must
8925 be 8.  16, 32 or 64 bits.
8926
8927 @node Rotate_Right
8928 @section Rotate_Right
8929 @cindex Rotate_Right
8930 @noindent
8931 A @code{Rotate_Right} function can be defined for any user defined
8932 binary modular integer type, or signed integer type, as described
8933 above for @code{Rotate_Left}.
8934
8935 @node Shift_Left
8936 @section Shift_Left
8937 @cindex Shift_Left
8938 @noindent
8939 A @code{Shift_Left} function can be defined for any user defined
8940 binary modular integer type, or signed integer type, as described
8941 above for @code{Rotate_Left}.
8942
8943 @node Shift_Right
8944 @section Shift_Right
8945 @cindex Shift_Right
8946 @noindent
8947 A @code{Shift_Right} function can be defined for any user defined
8948 binary modular integer type, or signed integer type, as described
8949 above for @code{Rotate_Left}.
8950
8951 @node Shift_Right_Arithmetic
8952 @section Shift_Right_Arithmetic
8953 @cindex Shift_Right_Arithmetic
8954 @noindent
8955 A @code{Shift_Right_Arithmetic} function can be defined for any user
8956 defined binary modular integer type, or signed integer type, as described
8957 above for @code{Rotate_Left}.
8958
8959 @node Source_Location
8960 @section Source_Location
8961 @cindex Source_Location
8962 @noindent
8963 This intrinsic subprogram is used in the implementation of the
8964 library routine @code{GNAT.Source_Info}.  The only useful use of the
8965 intrinsic import in this case is the one in this unit, so an
8966 application program should simply call the function
8967 @code{GNAT.Source_Info.Source_Location} to obtain the current
8968 source file location.
8969
8970 @node Representation Clauses and Pragmas
8971 @chapter Representation Clauses and Pragmas
8972 @cindex Representation Clauses
8973
8974 @menu
8975 * Alignment Clauses::
8976 * Size Clauses::
8977 * Storage_Size Clauses::
8978 * Size of Variant Record Objects::
8979 * Biased Representation ::
8980 * Value_Size and Object_Size Clauses::
8981 * Component_Size Clauses::
8982 * Bit_Order Clauses::
8983 * Effect of Bit_Order on Byte Ordering::
8984 * Pragma Pack for Arrays::
8985 * Pragma Pack for Records::
8986 * Record Representation Clauses::
8987 * Enumeration Clauses::
8988 * Address Clauses::
8989 * Effect of Convention on Representation::
8990 * Determining the Representations chosen by GNAT::
8991 @end menu
8992
8993 @noindent
8994 @cindex Representation Clause
8995 @cindex Representation Pragma
8996 @cindex Pragma, representation
8997 This section describes the representation clauses accepted by GNAT, and
8998 their effect on the representation of corresponding data objects.
8999
9000 GNAT fully implements Annex C (Systems Programming).  This means that all
9001 the implementation advice sections in chapter 13 are fully implemented.
9002 However, these sections only require a minimal level of support for
9003 representation clauses.  GNAT provides much more extensive capabilities,
9004 and this section describes the additional capabilities provided.
9005
9006 @node Alignment Clauses
9007 @section Alignment Clauses
9008 @cindex Alignment Clause
9009
9010 @noindent
9011 GNAT requires that all alignment clauses specify a power of 2, and all
9012 default alignments are always a power of 2.  The default alignment
9013 values are as follows:
9014
9015 @itemize @bullet
9016 @item @emph{Primitive Types}.
9017 For primitive types, the alignment is the minimum of the actual size of
9018 objects of the type divided by @code{Storage_Unit},
9019 and the maximum alignment supported by the target.
9020 (This maximum alignment is given by the GNAT-specific attribute
9021 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9022 @cindex @code{Maximum_Alignment} attribute
9023 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9024 default alignment will be 8 on any target that supports alignments
9025 this large, but on some targets, the maximum alignment may be smaller
9026 than 8, in which case objects of type @code{Long_Float} will be maximally
9027 aligned.
9028
9029 @item @emph{Arrays}.
9030 For arrays, the alignment is equal to the alignment of the component type
9031 for the normal case where no packing or component size is given.  If the
9032 array is packed, and the packing is effective (see separate section on
9033 packed arrays), then the alignment will be one for long packed arrays,
9034 or arrays whose length is not known at compile time.  For short packed
9035 arrays, which are handled internally as modular types, the alignment
9036 will be as described for primitive types, e.g.@: a packed array of length
9037 31 bits will have an object size of four bytes, and an alignment of 4.
9038
9039 @item @emph{Records}.
9040 For the normal non-packed case, the alignment of a record is equal to
9041 the maximum alignment of any of its components.  For tagged records, this
9042 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
9043 used and all fields are packable (see separate section on pragma @code{Pack}),
9044 then the resulting alignment is 1.
9045
9046 A special case is when:
9047 @itemize @bullet
9048 @item
9049 the size of the record is given explicitly, or a
9050 full record representation clause is given, and
9051 @item
9052 the size of the record is 2, 4, or 8 bytes.
9053 @end itemize
9054 @noindent
9055 In this case, an alignment is chosen to match the
9056 size of the record. For example, if we have:
9057
9058 @smallexample @c ada
9059    type Small is record
9060       A, B : Character;
9061    end record;
9062    for Small'Size use 16;
9063 @end smallexample
9064
9065 @noindent
9066 then the default alignment of the record type @code{Small} is 2, not 1. This
9067 leads to more efficient code when the record is treated as a unit, and also
9068 allows the type to specified as @code{Atomic} on architectures requiring
9069 strict alignment.
9070
9071 @end itemize
9072
9073 @noindent
9074 An alignment clause may specify a larger alignment than the default value
9075 up to some maximum value dependent on the target (obtainable by using the
9076 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9077 a smaller alignment than the default value, for example
9078
9079 @smallexample @c ada
9080   type V is record
9081      A : Integer;
9082   end record;
9083
9084   for V'alignment use 1;
9085 @end smallexample
9086
9087 @noindent
9088 @cindex Alignment, default
9089 The default alignment for the type @code{V} is 4, as a result of the
9090 Integer field in the record, but it is permissible, as shown, to
9091 override the default alignment of the record with a smaller value.
9092
9093 @node Size Clauses
9094 @section Size Clauses
9095 @cindex Size Clause
9096
9097 @noindent
9098 The default size for a type @code{T} is obtainable through the
9099 language-defined attribute @code{T'Size} and also through the
9100 equivalent GNAT-defined attribute @code{T'Value_Size}.
9101 For objects of type @code{T}, GNAT will generally increase the type size
9102 so that the object size (obtainable through the GNAT-defined attribute
9103 @code{T'Object_Size})
9104 is a multiple of @code{T'Alignment * Storage_Unit}.
9105 For example
9106
9107 @smallexample @c ada
9108    type Smallint is range 1 .. 6;
9109
9110    type Rec is record
9111       Y1 : integer;
9112       Y2 : boolean;
9113    end record;
9114 @end smallexample
9115
9116 @noindent
9117 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9118 as specified by the RM rules,
9119 but objects of this type will have a size of 8
9120 (@code{Smallint'Object_Size} = 8),
9121 since objects by default occupy an integral number
9122 of storage units.  On some targets, notably older
9123 versions of the Digital Alpha, the size of stand
9124 alone objects of this type may be 32, reflecting
9125 the inability of the hardware to do byte load/stores.
9126
9127 Similarly, the size of type @code{Rec} is 40 bits
9128 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9129 the alignment is 4, so objects of this type will have
9130 their size increased to 64 bits so that it is a multiple
9131 of the alignment (in bits).  This decision is
9132 in accordance with the specific Implementation Advice in RM 13.3(43):
9133
9134 @quotation
9135 A @code{Size} clause should be supported for an object if the specified
9136 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9137 to a size in storage elements that is a multiple of the object's
9138 @code{Alignment} (if the @code{Alignment} is nonzero).
9139 @end quotation
9140
9141 @noindent
9142 An explicit size clause may be used to override the default size by
9143 increasing it.  For example, if we have:
9144
9145 @smallexample @c ada
9146    type My_Boolean is new Boolean;
9147    for My_Boolean'Size use 32;
9148 @end smallexample
9149
9150 @noindent
9151 then values of this type will always be 32 bits long.  In the case of
9152 discrete types, the size can be increased up to 64 bits, with the effect
9153 that the entire specified field is used to hold the value, sign- or
9154 zero-extended as appropriate.  If more than 64 bits is specified, then
9155 padding space is allocated after the value, and a warning is issued that
9156 there are unused bits.
9157
9158 Similarly the size of records and arrays may be increased, and the effect
9159 is to add padding bits after the value.  This also causes a warning message
9160 to be generated.
9161
9162 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9163 Size in bits, this corresponds to an object of size 256 megabytes (minus
9164 one).  This limitation is true on all targets.  The reason for this
9165 limitation is that it improves the quality of the code in many cases
9166 if it is known that a Size value can be accommodated in an object of
9167 type Integer.
9168
9169 @node Storage_Size Clauses
9170 @section Storage_Size Clauses
9171 @cindex Storage_Size Clause
9172
9173 @noindent
9174 For tasks, the @code{Storage_Size} clause specifies the amount of space
9175 to be allocated for the task stack.  This cannot be extended, and if the
9176 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9177 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9178 or a @code{Storage_Size} pragma in the task definition to set the
9179 appropriate required size.  A useful technique is to include in every
9180 task definition a pragma of the form:
9181
9182 @smallexample @c ada
9183    pragma Storage_Size (Default_Stack_Size);
9184 @end smallexample
9185
9186 @noindent
9187 Then @code{Default_Stack_Size} can be defined in a global package, and
9188 modified as required. Any tasks requiring stack sizes different from the
9189 default can have an appropriate alternative reference in the pragma.
9190
9191 You can also use the @code{-d} binder switch to modify the default stack
9192 size.
9193
9194 For access types, the @code{Storage_Size} clause specifies the maximum
9195 space available for allocation of objects of the type.  If this space is
9196 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9197 In the case where the access type is declared local to a subprogram, the
9198 use of a @code{Storage_Size} clause triggers automatic use of a special
9199 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9200 space for the pool is automatically reclaimed on exit from the scope in
9201 which the type is declared.
9202
9203 A special case recognized by the compiler is the specification of a
9204 @code{Storage_Size} of zero for an access type.  This means that no
9205 items can be allocated from the pool, and this is recognized at compile
9206 time, and all the overhead normally associated with maintaining a fixed
9207 size storage pool is eliminated.  Consider the following example:
9208
9209 @smallexample @c ada
9210    procedure p is
9211       type R is array (Natural) of Character;
9212       type P is access all R;
9213       for P'Storage_Size use 0;
9214       --  Above access type intended only for interfacing purposes
9215
9216       y : P;
9217
9218       procedure g (m : P);
9219       pragma Import (C, g);
9220
9221       --  @dots{}
9222
9223    begin
9224       --  @dots{}
9225       y := new R;
9226    end;
9227 @end smallexample
9228
9229 @noindent
9230 As indicated in this example, these dummy storage pools are often useful in
9231 connection with interfacing where no object will ever be allocated.  If you
9232 compile the above example, you get the warning:
9233
9234 @smallexample
9235    p.adb:16:09: warning: allocation from empty storage pool
9236    p.adb:16:09: warning: Storage_Error will be raised at run time
9237 @end smallexample
9238
9239 @noindent
9240 Of course in practice, there will not be any explicit allocators in the
9241 case of such an access declaration.
9242
9243 @node Size of Variant Record Objects
9244 @section Size of Variant Record Objects
9245 @cindex Size, variant record objects
9246 @cindex Variant record objects, size
9247
9248 @noindent
9249 In the case of variant record objects, there is a question whether Size gives
9250 information about a particular variant, or the maximum size required
9251 for any variant.  Consider the following program
9252
9253 @smallexample @c ada
9254 with Text_IO; use Text_IO;
9255 procedure q is
9256    type R1 (A : Boolean := False) is record
9257      case A is
9258        when True  => X : Character;
9259        when False => null;
9260      end case;
9261    end record;
9262
9263    V1 : R1 (False);
9264    V2 : R1;
9265
9266 begin
9267    Put_Line (Integer'Image (V1'Size));
9268    Put_Line (Integer'Image (V2'Size));
9269 end q;
9270 @end smallexample
9271
9272 @noindent
9273 Here we are dealing with a variant record, where the True variant
9274 requires 16 bits, and the False variant requires 8 bits.
9275 In the above example, both V1 and V2 contain the False variant,
9276 which is only 8 bits long.  However, the result of running the
9277 program is:
9278
9279 @smallexample
9280 8
9281 16
9282 @end smallexample
9283
9284 @noindent
9285 The reason for the difference here is that the discriminant value of
9286 V1 is fixed, and will always be False.  It is not possible to assign
9287 a True variant value to V1, therefore 8 bits is sufficient.  On the
9288 other hand, in the case of V2, the initial discriminant value is
9289 False (from the default), but it is possible to assign a True
9290 variant value to V2, therefore 16 bits must be allocated for V2
9291 in the general case, even fewer bits may be needed at any particular
9292 point during the program execution.
9293
9294 As can be seen from the output of this program, the @code{'Size}
9295 attribute applied to such an object in GNAT gives the actual allocated
9296 size of the variable, which is the largest size of any of the variants.
9297 The Ada Reference Manual is not completely clear on what choice should
9298 be made here, but the GNAT behavior seems most consistent with the
9299 language in the RM@.
9300
9301 In some cases, it may be desirable to obtain the size of the current
9302 variant, rather than the size of the largest variant.  This can be
9303 achieved in GNAT by making use of the fact that in the case of a
9304 subprogram parameter, GNAT does indeed return the size of the current
9305 variant (because a subprogram has no way of knowing how much space
9306 is actually allocated for the actual).
9307
9308 Consider the following modified version of the above program:
9309
9310 @smallexample @c ada
9311 with Text_IO; use Text_IO;
9312 procedure q is
9313    type R1 (A : Boolean := False) is record
9314      case A is
9315        when True  => X : Character;
9316        when False => null;
9317      end case;
9318    end record;
9319
9320    V2 : R1;
9321
9322    function Size (V : R1) return Integer is
9323    begin
9324       return V'Size;
9325    end Size;
9326
9327 begin
9328    Put_Line (Integer'Image (V2'Size));
9329    Put_Line (Integer'IMage (Size (V2)));
9330    V2 := (True, 'x');
9331    Put_Line (Integer'Image (V2'Size));
9332    Put_Line (Integer'IMage (Size (V2)));
9333 end q;
9334 @end smallexample
9335
9336 @noindent
9337 The output from this program is
9338
9339 @smallexample
9340 16
9341 8
9342 16
9343 16
9344 @end smallexample
9345
9346 @noindent
9347 Here we see that while the @code{'Size} attribute always returns
9348 the maximum size, regardless of the current variant value, the
9349 @code{Size} function does indeed return the size of the current
9350 variant value.
9351
9352 @node Biased Representation
9353 @section Biased Representation
9354 @cindex Size for biased representation
9355 @cindex Biased representation
9356
9357 @noindent
9358 In the case of scalars with a range starting at other than zero, it is
9359 possible in some cases to specify a size smaller than the default minimum
9360 value, and in such cases, GNAT uses an unsigned biased representation,
9361 in which zero is used to represent the lower bound, and successive values
9362 represent successive values of the type.
9363
9364 For example, suppose we have the declaration:
9365
9366 @smallexample @c ada
9367    type Small is range -7 .. -4;
9368    for Small'Size use 2;
9369 @end smallexample
9370
9371 @noindent
9372 Although the default size of type @code{Small} is 4, the @code{Size}
9373 clause is accepted by GNAT and results in the following representation
9374 scheme:
9375
9376 @smallexample
9377   -7 is represented as 2#00#
9378   -6 is represented as 2#01#
9379   -5 is represented as 2#10#
9380   -4 is represented as 2#11#
9381 @end smallexample
9382
9383 @noindent
9384 Biased representation is only used if the specified @code{Size} clause
9385 cannot be accepted in any other manner.  These reduced sizes that force
9386 biased representation can be used for all discrete types except for
9387 enumeration types for which a representation clause is given.
9388
9389 @node Value_Size and Object_Size Clauses
9390 @section Value_Size and Object_Size Clauses
9391 @findex Value_Size
9392 @findex Object_Size
9393 @cindex Size, of objects
9394
9395 @noindent
9396 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9397 number of bits required to hold values of type @code{T}.
9398 Although this interpretation was allowed in Ada 83, it was not required,
9399 and this requirement in practice can cause some significant difficulties.
9400 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9401 However, in Ada 95 and Ada 2005,
9402 @code{Natural'Size} is
9403 typically 31.  This means that code may change in behavior when moving
9404 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
9405
9406 @smallexample @c ada
9407    type Rec is record;
9408       A : Natural;
9409       B : Natural;
9410    end record;
9411
9412    for Rec use record
9413       at 0  range 0 .. Natural'Size - 1;
9414       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9415    end record;
9416 @end smallexample
9417
9418 @noindent
9419 In the above code, since the typical size of @code{Natural} objects
9420 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9421 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9422 there are cases where the fact that the object size can exceed the
9423 size of the type causes surprises.
9424
9425 To help get around this problem GNAT provides two implementation
9426 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9427 applied to a type, these attributes yield the size of the type
9428 (corresponding to the RM defined size attribute), and the size of
9429 objects of the type respectively.
9430
9431 The @code{Object_Size} is used for determining the default size of
9432 objects and components.  This size value can be referred to using the
9433 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9434 the basis of the determination of the size.  The backend is free to
9435 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9436 character might be stored in 32 bits on a machine with no efficient
9437 byte access instructions such as the Alpha.
9438
9439 The default rules for the value of @code{Object_Size} for
9440 discrete types are as follows:
9441
9442 @itemize @bullet
9443 @item
9444 The @code{Object_Size} for base subtypes reflect the natural hardware
9445 size in bits (run the compiler with @option{-gnatS} to find those values
9446 for numeric types). Enumeration types and fixed-point base subtypes have
9447 8, 16, 32 or 64 bits for this size, depending on the range of values
9448 to be stored.
9449
9450 @item
9451 The @code{Object_Size} of a subtype is the same as the
9452 @code{Object_Size} of
9453 the type from which it is obtained.
9454
9455 @item
9456 The @code{Object_Size} of a derived base type is copied from the parent
9457 base type, and the @code{Object_Size} of a derived first subtype is copied
9458 from the parent first subtype.
9459 @end itemize
9460
9461 @noindent
9462 The @code{Value_Size} attribute
9463 is the (minimum) number of bits required to store a value
9464 of the type.
9465 This value is used to determine how tightly to pack
9466 records or arrays with components of this type, and also affects
9467 the semantics of unchecked conversion (unchecked conversions where
9468 the @code{Value_Size} values differ generate a warning, and are potentially
9469 target dependent).
9470
9471 The default rules for the value of @code{Value_Size} are as follows:
9472
9473 @itemize @bullet
9474 @item
9475 The @code{Value_Size} for a base subtype is the minimum number of bits
9476 required to store all values of the type (including the sign bit
9477 only if negative values are possible).
9478
9479 @item
9480 If a subtype statically matches the first subtype of a given type, then it has
9481 by default the same @code{Value_Size} as the first subtype.  This is a
9482 consequence of RM 13.1(14) (``if two subtypes statically match,
9483 then their subtype-specific aspects are the same''.)
9484
9485 @item
9486 All other subtypes have a @code{Value_Size} corresponding to the minimum
9487 number of bits required to store all values of the subtype.  For
9488 dynamic bounds, it is assumed that the value can range down or up
9489 to the corresponding bound of the ancestor
9490 @end itemize
9491
9492 @noindent
9493 The RM defined attribute @code{Size} corresponds to the
9494 @code{Value_Size} attribute.
9495
9496 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9497 the @code{Value_Size} of
9498 the first-named subtype to the given value, and the
9499 @code{Object_Size} of this first-named subtype to the given value padded up
9500 to an appropriate boundary.  It is a consequence of the default rules
9501 above that this @code{Object_Size} will apply to all further subtypes.  On the
9502 other hand, @code{Value_Size} is affected only for the first subtype, any
9503 dynamic subtypes obtained from it directly, and any statically matching
9504 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9505
9506 @code{Value_Size} and
9507 @code{Object_Size} may be explicitly set for any subtype using
9508 an attribute definition clause.  Note that the use of these attributes
9509 can cause the RM 13.1(14) rule to be violated.  If two access types
9510 reference aliased objects whose subtypes have differing @code{Object_Size}
9511 values as a result of explicit attribute definition clauses, then it
9512 is erroneous to convert from one access subtype to the other.
9513
9514 At the implementation level, Esize stores the Object_Size and the
9515 RM_Size field stores the @code{Value_Size} (and hence the value of the
9516 @code{Size} attribute,
9517 which, as noted above, is equivalent to @code{Value_Size}).
9518
9519 To get a feel for the difference, consider the following examples (note
9520 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9521
9522 @smallexample
9523                                        Object_Size     Value_Size
9524
9525 type x1 is range 0 .. 5;                    8               3
9526
9527 type x2 is range 0 .. 5;
9528 for x2'size use 12;                        16              12
9529
9530 subtype x3 is x2 range 0 .. 3;             16               2
9531
9532 subtype x4 is x2'base range 0 .. 10;        8               4
9533
9534 subtype x5 is x2 range 0 .. dynamic;       16               3*
9535
9536 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9537
9538 @end smallexample
9539
9540 @noindent
9541 Note: the entries marked ``3*'' are not actually specified by the Ada
9542 Reference Manual, but it seems in the spirit of the RM rules to allocate
9543 the minimum number of bits (here 3, given the range for @code{x2})
9544 known to be large enough to hold the given range of values.
9545
9546 So far, so good, but GNAT has to obey the RM rules, so the question is
9547 under what conditions must the RM @code{Size} be used.
9548 The following is a list
9549 of the occasions on which the RM @code{Size} must be used:
9550
9551 @itemize @bullet
9552 @item
9553 Component size for packed arrays or records
9554
9555 @item
9556 Value of the attribute @code{Size} for a type
9557
9558 @item
9559 Warning about sizes not matching for unchecked conversion
9560 @end itemize
9561
9562 @noindent
9563 For record types, the @code{Object_Size} is always a multiple of the
9564 alignment of the type (this is true for all types). In some cases the
9565 @code{Value_Size} can be smaller. Consider:
9566
9567 @smallexample
9568    type R is record
9569      X : Integer;
9570      Y : Character;
9571    end record;
9572 @end smallexample
9573
9574 @noindent
9575 On a typical 32-bit architecture, the X component will be four bytes, and
9576 require four-byte alignment, and the Y component will be one byte. In this
9577 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9578 required to store a value of this type, and for example, it is permissible
9579 to have a component of type R in an outer record whose component size is
9580 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9581 since it must be rounded up so that this value is a multiple of the
9582 alignment (4 bytes = 32 bits).
9583
9584 @noindent
9585 For all other types, the @code{Object_Size}
9586 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9587 Only @code{Size} may be specified for such types.
9588
9589 @node Component_Size Clauses
9590 @section Component_Size Clauses
9591 @cindex Component_Size Clause
9592
9593 @noindent
9594 Normally, the value specified in a component size clause must be consistent
9595 with the subtype of the array component with regard to size and alignment.
9596 In other words, the value specified must be at least equal to the size
9597 of this subtype, and must be a multiple of the alignment value.
9598
9599 In addition, component size clauses are allowed which cause the array
9600 to be packed, by specifying a smaller value.  The cases in which this
9601 is allowed are for component size values in the range 1 through 63.  The value
9602 specified must not be smaller than the Size of the subtype.  GNAT will
9603 accurately honor all packing requests in this range.  For example, if
9604 we have:
9605
9606 @smallexample @c ada
9607 type r is array (1 .. 8) of Natural;
9608 for r'Component_Size use 31;
9609 @end smallexample
9610
9611 @noindent
9612 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9613 Of course access to the components of such an array is considerably
9614 less efficient than if the natural component size of 32 is used.
9615
9616 Note that there is no point in giving both a component size clause
9617 and a pragma Pack for the same array type. if such duplicate
9618 clauses are given, the pragma Pack will be ignored.
9619
9620 @node Bit_Order Clauses
9621 @section Bit_Order Clauses
9622 @cindex Bit_Order Clause
9623 @cindex bit ordering
9624 @cindex ordering, of bits
9625
9626 @noindent
9627 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9628 attribute.  The specification may either correspond to the default bit
9629 order for the target, in which case the specification has no effect and
9630 places no additional restrictions, or it may be for the non-standard
9631 setting (that is the opposite of the default).
9632
9633 In the case where the non-standard value is specified, the effect is
9634 to renumber bits within each byte, but the ordering of bytes is not
9635 affected.  There are certain
9636 restrictions placed on component clauses as follows:
9637
9638 @itemize @bullet
9639
9640 @item Components fitting within a single storage unit.
9641 @noindent
9642 These are unrestricted, and the effect is merely to renumber bits.  For
9643 example if we are on a little-endian machine with @code{Low_Order_First}
9644 being the default, then the following two declarations have exactly
9645 the same effect:
9646
9647 @smallexample @c ada
9648    type R1 is record
9649       A : Boolean;
9650       B : Integer range 1 .. 120;
9651    end record;
9652
9653    for R1 use record
9654       A at 0 range 0 .. 0;
9655       B at 0 range 1 .. 7;
9656    end record;
9657
9658    type R2 is record
9659       A : Boolean;
9660       B : Integer range 1 .. 120;
9661    end record;
9662
9663    for R2'Bit_Order use High_Order_First;
9664
9665    for R2 use record
9666       A at 0 range 7 .. 7;
9667       B at 0 range 0 .. 6;
9668    end record;
9669 @end smallexample
9670
9671 @noindent
9672 The useful application here is to write the second declaration with the
9673 @code{Bit_Order} attribute definition clause, and know that it will be treated
9674 the same, regardless of whether the target is little-endian or big-endian.
9675
9676 @item Components occupying an integral number of bytes.
9677 @noindent
9678 These are components that exactly fit in two or more bytes.  Such component
9679 declarations are allowed, but have no effect, since it is important to realize
9680 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9681 In particular, the following attempt at getting an endian-independent integer
9682 does not work:
9683
9684 @smallexample @c ada
9685    type R2 is record
9686       A : Integer;
9687    end record;
9688
9689    for R2'Bit_Order use High_Order_First;
9690
9691    for R2 use record
9692       A at 0 range 0 .. 31;
9693    end record;
9694 @end smallexample
9695
9696 @noindent
9697 This declaration will result in a little-endian integer on a
9698 little-endian machine, and a big-endian integer on a big-endian machine.
9699 If byte flipping is required for interoperability between big- and
9700 little-endian machines, this must be explicitly programmed.  This capability
9701 is not provided by @code{Bit_Order}.
9702
9703 @item Components that are positioned across byte boundaries
9704 @noindent
9705 but do not occupy an integral number of bytes.  Given that bytes are not
9706 reordered, such fields would occupy a non-contiguous sequence of bits
9707 in memory, requiring non-trivial code to reassemble.  They are for this
9708 reason not permitted, and any component clause specifying such a layout
9709 will be flagged as illegal by GNAT@.
9710
9711 @end itemize
9712
9713 @noindent
9714 Since the misconception that Bit_Order automatically deals with all
9715 endian-related incompatibilities is a common one, the specification of
9716 a component field that is an integral number of bytes will always
9717 generate a warning.  This warning may be suppressed using
9718 @code{pragma Suppress} if desired.  The following section contains additional
9719 details regarding the issue of byte ordering.
9720
9721 @node Effect of Bit_Order on Byte Ordering
9722 @section Effect of Bit_Order on Byte Ordering
9723 @cindex byte ordering
9724 @cindex ordering, of bytes
9725
9726 @noindent
9727 In this section we will review the effect of the @code{Bit_Order} attribute
9728 definition clause on byte ordering.  Briefly, it has no effect at all, but
9729 a detailed example will be helpful.  Before giving this
9730 example, let us review the precise
9731 definition of the effect of defining @code{Bit_Order}.  The effect of a
9732 non-standard bit order is described in section 15.5.3 of the Ada
9733 Reference Manual:
9734
9735 @quotation
9736 2   A bit ordering is a method of interpreting the meaning of
9737 the storage place attributes.
9738 @end quotation
9739
9740 @noindent
9741 To understand the precise definition of storage place attributes in
9742 this context, we visit section 13.5.1 of the manual:
9743
9744 @quotation
9745 13   A record_representation_clause (without the mod_clause)
9746 specifies the layout.  The storage place attributes (see 13.5.2)
9747 are taken from the values of the position, first_bit, and last_bit
9748 expressions after normalizing those values so that first_bit is
9749 less than Storage_Unit.
9750 @end quotation
9751
9752 @noindent
9753 The critical point here is that storage places are taken from
9754 the values after normalization, not before.  So the @code{Bit_Order}
9755 interpretation applies to normalized values.  The interpretation
9756 is described in the later part of the 15.5.3 paragraph:
9757
9758 @quotation
9759 2   A bit ordering is a method of interpreting the meaning of
9760 the storage place attributes.  High_Order_First (known in the
9761 vernacular as ``big endian'') means that the first bit of a
9762 storage element (bit 0) is the most significant bit (interpreting
9763 the sequence of bits that represent a component as an unsigned
9764 integer value).  Low_Order_First (known in the vernacular as
9765 ``little endian'') means the opposite: the first bit is the
9766 least significant.
9767 @end quotation
9768
9769 @noindent
9770 Note that the numbering is with respect to the bits of a storage
9771 unit.  In other words, the specification affects only the numbering
9772 of bits within a single storage unit.
9773
9774 We can make the effect clearer by giving an example.
9775
9776 Suppose that we have an external device which presents two bytes, the first
9777 byte presented, which is the first (low addressed byte) of the two byte
9778 record is called Master, and the second byte is called Slave.
9779
9780 The left most (most significant bit is called Control for each byte, and
9781 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9782 (least significant) bit.
9783
9784 On a big-endian machine, we can write the following representation clause
9785
9786 @smallexample @c ada
9787    type Data is record
9788       Master_Control : Bit;
9789       Master_V1      : Bit;
9790       Master_V2      : Bit;
9791       Master_V3      : Bit;
9792       Master_V4      : Bit;
9793       Master_V5      : Bit;
9794       Master_V6      : Bit;
9795       Master_V7      : Bit;
9796       Slave_Control  : Bit;
9797       Slave_V1       : Bit;
9798       Slave_V2       : Bit;
9799       Slave_V3       : Bit;
9800       Slave_V4       : Bit;
9801       Slave_V5       : Bit;
9802       Slave_V6       : Bit;
9803       Slave_V7       : Bit;
9804    end record;
9805
9806    for Data use record
9807       Master_Control at 0 range 0 .. 0;
9808       Master_V1      at 0 range 1 .. 1;
9809       Master_V2      at 0 range 2 .. 2;
9810       Master_V3      at 0 range 3 .. 3;
9811       Master_V4      at 0 range 4 .. 4;
9812       Master_V5      at 0 range 5 .. 5;
9813       Master_V6      at 0 range 6 .. 6;
9814       Master_V7      at 0 range 7 .. 7;
9815       Slave_Control  at 1 range 0 .. 0;
9816       Slave_V1       at 1 range 1 .. 1;
9817       Slave_V2       at 1 range 2 .. 2;
9818       Slave_V3       at 1 range 3 .. 3;
9819       Slave_V4       at 1 range 4 .. 4;
9820       Slave_V5       at 1 range 5 .. 5;
9821       Slave_V6       at 1 range 6 .. 6;
9822       Slave_V7       at 1 range 7 .. 7;
9823    end record;
9824 @end smallexample
9825
9826 @noindent
9827 Now if we move this to a little endian machine, then the bit ordering within
9828 the byte is backwards, so we have to rewrite the record rep clause as:
9829
9830 @smallexample @c ada
9831    for Data use record
9832       Master_Control at 0 range 7 .. 7;
9833       Master_V1      at 0 range 6 .. 6;
9834       Master_V2      at 0 range 5 .. 5;
9835       Master_V3      at 0 range 4 .. 4;
9836       Master_V4      at 0 range 3 .. 3;
9837       Master_V5      at 0 range 2 .. 2;
9838       Master_V6      at 0 range 1 .. 1;
9839       Master_V7      at 0 range 0 .. 0;
9840       Slave_Control  at 1 range 7 .. 7;
9841       Slave_V1       at 1 range 6 .. 6;
9842       Slave_V2       at 1 range 5 .. 5;
9843       Slave_V3       at 1 range 4 .. 4;
9844       Slave_V4       at 1 range 3 .. 3;
9845       Slave_V5       at 1 range 2 .. 2;
9846       Slave_V6       at 1 range 1 .. 1;
9847       Slave_V7       at 1 range 0 .. 0;
9848    end record;
9849 @end smallexample
9850
9851 @noindent
9852 It is a nuisance to have to rewrite the clause, especially if
9853 the code has to be maintained on both machines.  However,
9854 this is a case that we can handle with the
9855 @code{Bit_Order} attribute if it is implemented.
9856 Note that the implementation is not required on byte addressed
9857 machines, but it is indeed implemented in GNAT.
9858 This means that we can simply use the
9859 first record clause, together with the declaration
9860
9861 @smallexample @c ada
9862    for Data'Bit_Order use High_Order_First;
9863 @end smallexample
9864
9865 @noindent
9866 and the effect is what is desired, namely the layout is exactly the same,
9867 independent of whether the code is compiled on a big-endian or little-endian
9868 machine.
9869
9870 The important point to understand is that byte ordering is not affected.
9871 A @code{Bit_Order} attribute definition never affects which byte a field
9872 ends up in, only where it ends up in that byte.
9873 To make this clear, let us rewrite the record rep clause of the previous
9874 example as:
9875
9876 @smallexample @c ada
9877    for Data'Bit_Order use High_Order_First;
9878    for Data use record
9879       Master_Control at 0 range  0 .. 0;
9880       Master_V1      at 0 range  1 .. 1;
9881       Master_V2      at 0 range  2 .. 2;
9882       Master_V3      at 0 range  3 .. 3;
9883       Master_V4      at 0 range  4 .. 4;
9884       Master_V5      at 0 range  5 .. 5;
9885       Master_V6      at 0 range  6 .. 6;
9886       Master_V7      at 0 range  7 .. 7;
9887       Slave_Control  at 0 range  8 .. 8;
9888       Slave_V1       at 0 range  9 .. 9;
9889       Slave_V2       at 0 range 10 .. 10;
9890       Slave_V3       at 0 range 11 .. 11;
9891       Slave_V4       at 0 range 12 .. 12;
9892       Slave_V5       at 0 range 13 .. 13;
9893       Slave_V6       at 0 range 14 .. 14;
9894       Slave_V7       at 0 range 15 .. 15;
9895    end record;
9896 @end smallexample
9897
9898 @noindent
9899 This is exactly equivalent to saying (a repeat of the first example):
9900
9901 @smallexample @c ada
9902    for Data'Bit_Order use High_Order_First;
9903    for Data use record
9904       Master_Control at 0 range 0 .. 0;
9905       Master_V1      at 0 range 1 .. 1;
9906       Master_V2      at 0 range 2 .. 2;
9907       Master_V3      at 0 range 3 .. 3;
9908       Master_V4      at 0 range 4 .. 4;
9909       Master_V5      at 0 range 5 .. 5;
9910       Master_V6      at 0 range 6 .. 6;
9911       Master_V7      at 0 range 7 .. 7;
9912       Slave_Control  at 1 range 0 .. 0;
9913       Slave_V1       at 1 range 1 .. 1;
9914       Slave_V2       at 1 range 2 .. 2;
9915       Slave_V3       at 1 range 3 .. 3;
9916       Slave_V4       at 1 range 4 .. 4;
9917       Slave_V5       at 1 range 5 .. 5;
9918       Slave_V6       at 1 range 6 .. 6;
9919       Slave_V7       at 1 range 7 .. 7;
9920    end record;
9921 @end smallexample
9922
9923 @noindent
9924 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9925 field.  The storage place attributes are obtained by normalizing the
9926 values given so that the @code{First_Bit} value is less than 8.  After
9927 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9928 we specified in the other case.
9929
9930 Now one might expect that the @code{Bit_Order} attribute might affect
9931 bit numbering within the entire record component (two bytes in this
9932 case, thus affecting which byte fields end up in), but that is not
9933 the way this feature is defined, it only affects numbering of bits,
9934 not which byte they end up in.
9935
9936 Consequently it never makes sense to specify a starting bit number
9937 greater than 7 (for a byte addressable field) if an attribute
9938 definition for @code{Bit_Order} has been given, and indeed it
9939 may be actively confusing to specify such a value, so the compiler
9940 generates a warning for such usage.
9941
9942 If you do need to control byte ordering then appropriate conditional
9943 values must be used.  If in our example, the slave byte came first on
9944 some machines we might write:
9945
9946 @smallexample @c ada
9947    Master_Byte_First constant Boolean := @dots{};
9948
9949    Master_Byte : constant Natural :=
9950                    1 - Boolean'Pos (Master_Byte_First);
9951    Slave_Byte  : constant Natural :=
9952                    Boolean'Pos (Master_Byte_First);
9953
9954    for Data'Bit_Order use High_Order_First;
9955    for Data use record
9956       Master_Control at Master_Byte range 0 .. 0;
9957       Master_V1      at Master_Byte range 1 .. 1;
9958       Master_V2      at Master_Byte range 2 .. 2;
9959       Master_V3      at Master_Byte range 3 .. 3;
9960       Master_V4      at Master_Byte range 4 .. 4;
9961       Master_V5      at Master_Byte range 5 .. 5;
9962       Master_V6      at Master_Byte range 6 .. 6;
9963       Master_V7      at Master_Byte range 7 .. 7;
9964       Slave_Control  at Slave_Byte  range 0 .. 0;
9965       Slave_V1       at Slave_Byte  range 1 .. 1;
9966       Slave_V2       at Slave_Byte  range 2 .. 2;
9967       Slave_V3       at Slave_Byte  range 3 .. 3;
9968       Slave_V4       at Slave_Byte  range 4 .. 4;
9969       Slave_V5       at Slave_Byte  range 5 .. 5;
9970       Slave_V6       at Slave_Byte  range 6 .. 6;
9971       Slave_V7       at Slave_Byte  range 7 .. 7;
9972    end record;
9973 @end smallexample
9974
9975 @noindent
9976 Now to switch between machines, all that is necessary is
9977 to set the boolean constant @code{Master_Byte_First} in
9978 an appropriate manner.
9979
9980 @node Pragma Pack for Arrays
9981 @section Pragma Pack for Arrays
9982 @cindex Pragma Pack (for arrays)
9983
9984 @noindent
9985 Pragma @code{Pack} applied to an array has no effect unless the component type
9986 is packable.  For a component type to be packable, it must be one of the
9987 following cases:
9988
9989 @itemize @bullet
9990 @item
9991 Any scalar type
9992 @item
9993 Any type whose size is specified with a size clause
9994 @item
9995 Any packed array type with a static size
9996 @end itemize
9997
9998 @noindent
9999 For all these cases, if the component subtype size is in the range
10000 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10001 component size were specified giving the component subtype size.
10002 For example if we have:
10003
10004 @smallexample @c ada
10005    type r is range 0 .. 17;
10006
10007    type ar is array (1 .. 8) of r;
10008    pragma Pack (ar);
10009 @end smallexample
10010
10011 @noindent
10012 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10013 and the size of the array @code{ar} will be exactly 40 bits.
10014
10015 Note that in some cases this rather fierce approach to packing can produce
10016 unexpected effects.  For example, in Ada 95 and Ada 2005,
10017 subtype @code{Natural} typically has a size of 31, meaning that if you
10018 pack an array of @code{Natural}, you get 31-bit
10019 close packing, which saves a few bits, but results in far less efficient
10020 access.  Since many other Ada compilers will ignore such a packing request,
10021 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10022 might not be what is intended.  You can easily remove this warning by
10023 using an explicit @code{Component_Size} setting instead, which never generates
10024 a warning, since the intention of the programmer is clear in this case.
10025
10026 GNAT treats packed arrays in one of two ways.  If the size of the array is
10027 known at compile time and is less than 64 bits, then internally the array
10028 is represented as a single modular type, of exactly the appropriate number
10029 of bits.  If the length is greater than 63 bits, or is not known at compile
10030 time, then the packed array is represented as an array of bytes, and the
10031 length is always a multiple of 8 bits.
10032
10033 Note that to represent a packed array as a modular type, the alignment must
10034 be suitable for the modular type involved. For example, on typical machines
10035 a 32-bit packed array will be represented by a 32-bit modular integer with
10036 an alignment of four bytes. If you explicitly override the default alignment
10037 with an alignment clause that is too small, the modular representation
10038 cannot be used. For example, consider the following set of declarations:
10039
10040 @smallexample @c ada
10041    type R is range 1 .. 3;
10042    type S is array (1 .. 31) of R;
10043    for S'Component_Size use 2;
10044    for S'Size use 62;
10045    for S'Alignment use 1;
10046 @end smallexample
10047
10048 @noindent
10049 If the alignment clause were not present, then a 62-bit modular
10050 representation would be chosen (typically with an alignment of 4 or 8
10051 bytes depending on the target). But the default alignment is overridden
10052 with the explicit alignment clause. This means that the modular
10053 representation cannot be used, and instead the array of bytes
10054 representation must be used, meaning that the length must be a multiple
10055 of 8. Thus the above set of declarations will result in a diagnostic
10056 rejecting the size clause and noting that the minimum size allowed is 64.
10057
10058 @cindex Pragma Pack (for type Natural)
10059 @cindex Pragma Pack warning
10060
10061 One special case that is worth noting occurs when the base type of the
10062 component size is 8/16/32 and the subtype is one bit less. Notably this
10063 occurs with subtype @code{Natural}. Consider:
10064
10065 @smallexample @c ada
10066    type Arr is array (1 .. 32) of Natural;
10067    pragma Pack (Arr);
10068 @end smallexample
10069
10070 @noindent
10071 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10072 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10073 Ada 83 compilers did not attempt 31 bit packing.
10074
10075 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10076 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10077 substantial unintended performance penalty when porting legacy Ada 83 code.
10078 To help prevent this, GNAT generates a warning in such cases. If you really
10079 want 31 bit packing in a case like this, you can set the component size
10080 explicitly:
10081
10082 @smallexample @c ada
10083    type Arr is array (1 .. 32) of Natural;
10084    for Arr'Component_Size use 31;
10085 @end smallexample
10086
10087 @noindent
10088 Here 31-bit packing is achieved as required, and no warning is generated,
10089 since in this case the programmer intention is clear.
10090
10091 @node Pragma Pack for Records
10092 @section Pragma Pack for Records
10093 @cindex Pragma Pack (for records)
10094
10095 @noindent
10096 Pragma @code{Pack} applied to a record will pack the components to reduce
10097 wasted space from alignment gaps and by reducing the amount of space
10098 taken by components.  We distinguish between @emph{packable} components and
10099 @emph{non-packable} components.
10100 Components of the following types are considered packable:
10101 @itemize @bullet
10102 @item
10103 All primitive types are packable.
10104
10105 @item
10106 Small packed arrays, whose size does not exceed 64 bits, and where the
10107 size is statically known at compile time, are represented internally
10108 as modular integers, and so they are also packable.
10109
10110 @end itemize
10111
10112 @noindent
10113 All packable components occupy the exact number of bits corresponding to
10114 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10115 can start on an arbitrary bit boundary.
10116
10117 All other types are non-packable, they occupy an integral number of
10118 storage units, and
10119 are placed at a boundary corresponding to their alignment requirements.
10120
10121 For example, consider the record
10122
10123 @smallexample @c ada
10124    type Rb1 is array (1 .. 13) of Boolean;
10125    pragma Pack (rb1);
10126
10127    type Rb2 is array (1 .. 65) of Boolean;
10128    pragma Pack (rb2);
10129
10130    type x2 is record
10131       l1 : Boolean;
10132       l2 : Duration;
10133       l3 : Float;
10134       l4 : Boolean;
10135       l5 : Rb1;
10136       l6 : Rb2;
10137    end record;
10138    pragma Pack (x2);
10139 @end smallexample
10140
10141 @noindent
10142 The representation for the record x2 is as follows:
10143
10144 @smallexample @c ada
10145 for x2'Size use 224;
10146 for x2 use record
10147    l1 at  0 range  0 .. 0;
10148    l2 at  0 range  1 .. 64;
10149    l3 at 12 range  0 .. 31;
10150    l4 at 16 range  0 .. 0;
10151    l5 at 16 range  1 .. 13;
10152    l6 at 18 range  0 .. 71;
10153 end record;
10154 @end smallexample
10155
10156 @noindent
10157 Studying this example, we see that the packable fields @code{l1}
10158 and @code{l2} are
10159 of length equal to their sizes, and placed at specific bit boundaries (and
10160 not byte boundaries) to
10161 eliminate padding.  But @code{l3} is of a non-packable float type, so
10162 it is on the next appropriate alignment boundary.
10163
10164 The next two fields are fully packable, so @code{l4} and @code{l5} are
10165 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10166 array that is longer than 64 bits, so it is itself non-packable.  Thus
10167 the @code{l6} field is aligned to the next byte boundary, and takes an
10168 integral number of bytes, i.e.@: 72 bits.
10169
10170 @node Record Representation Clauses
10171 @section Record Representation Clauses
10172 @cindex Record Representation Clause
10173
10174 @noindent
10175 Record representation clauses may be given for all record types, including
10176 types obtained by record extension.  Component clauses are allowed for any
10177 static component.  The restrictions on component clauses depend on the type
10178 of the component.
10179
10180 @cindex Component Clause
10181 For all components of an elementary type, the only restriction on component
10182 clauses is that the size must be at least the 'Size value of the type
10183 (actually the Value_Size).  There are no restrictions due to alignment,
10184 and such components may freely cross storage boundaries.
10185
10186 Packed arrays with a size up to and including 64 bits are represented
10187 internally using a modular type with the appropriate number of bits, and
10188 thus the same lack of restriction applies.  For example, if you declare:
10189
10190 @smallexample @c ada
10191    type R is array (1 .. 49) of Boolean;
10192    pragma Pack (R);
10193    for R'Size use 49;
10194 @end smallexample
10195
10196 @noindent
10197 then a component clause for a component of type R may start on any
10198 specified bit boundary, and may specify a value of 49 bits or greater.
10199
10200 For packed bit arrays that are longer than 64 bits, there are two
10201 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10202 including the important case of single bits or boolean values, then
10203 there are no limitations on placement of such components, and they
10204 may start and end at arbitrary bit boundaries.
10205
10206 If the component size is not a power of 2 (e.g. 3 or 5), then
10207 an array of this type longer than 64 bits must always be placed on
10208 on a storage unit (byte) boundary and occupy an integral number
10209 of storage units (bytes). Any component clause that does not
10210 meet this requirement will be rejected.
10211
10212 Any aliased component, or component of an aliased type, must
10213 have its normal alignment and size. A component clause that
10214 does not meet this requirement will be rejected.
10215
10216 The tag field of a tagged type always occupies an address sized field at
10217 the start of the record.  No component clause may attempt to overlay this
10218 tag. When a tagged type appears as a component, the tag field must have
10219 proper alignment
10220
10221 In the case of a record extension T1, of a type T, no component clause applied
10222 to the type T1 can specify a storage location that would overlap the first
10223 T'Size bytes of the record.
10224
10225 For all other component types, including non-bit-packed arrays,
10226 the component can be placed at an arbitrary bit boundary,
10227 so for example, the following is permitted:
10228
10229 @smallexample @c ada
10230    type R is array (1 .. 10) of Boolean;
10231    for R'Size use 80;
10232
10233    type Q is record
10234       G, H : Boolean;
10235       L, M : R;
10236    end record;
10237
10238    for Q use record
10239       G at 0 range  0 ..   0;
10240       H at 0 range  1 ..   1;
10241       L at 0 range  2 ..  81;
10242       R at 0 range 82 .. 161;
10243    end record;
10244 @end smallexample
10245
10246 @noindent
10247 Note: the above rules apply to recent releases of GNAT 5.
10248 In GNAT 3, there are more severe restrictions on larger components.
10249 For non-primitive types, including packed arrays with a size greater than
10250 64 bits, component clauses must respect the alignment requirement of the
10251 type, in particular, always starting on a byte boundary, and the length
10252 must be a multiple of the storage unit.
10253
10254 @node Enumeration Clauses
10255 @section Enumeration Clauses
10256
10257 The only restriction on enumeration clauses is that the range of values
10258 must be representable.  For the signed case, if one or more of the
10259 representation values are negative, all values must be in the range:
10260
10261 @smallexample @c ada
10262    System.Min_Int .. System.Max_Int
10263 @end smallexample
10264
10265 @noindent
10266 For the unsigned case, where all values are non negative, the values must
10267 be in the range:
10268
10269 @smallexample @c ada
10270    0 .. System.Max_Binary_Modulus;
10271 @end smallexample
10272
10273 @noindent
10274 A @emph{confirming} representation clause is one in which the values range
10275 from 0 in sequence, i.e.@: a clause that confirms the default representation
10276 for an enumeration type.
10277 Such a confirming representation
10278 is permitted by these rules, and is specially recognized by the compiler so
10279 that no extra overhead results from the use of such a clause.
10280
10281 If an array has an index type which is an enumeration type to which an
10282 enumeration clause has been applied, then the array is stored in a compact
10283 manner.  Consider the declarations:
10284
10285 @smallexample @c ada
10286    type r is (A, B, C);
10287    for r use (A => 1, B => 5, C => 10);
10288    type t is array (r) of Character;
10289 @end smallexample
10290
10291 @noindent
10292 The array type t corresponds to a vector with exactly three elements and
10293 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10294 use of space, but means that accesses to elements of the array will incur
10295 the overhead of converting representation values to the corresponding
10296 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10297
10298 @node Address Clauses
10299 @section Address Clauses
10300 @cindex Address Clause
10301
10302 The reference manual allows a general restriction on representation clauses,
10303 as found in RM 13.1(22):
10304
10305 @quotation
10306 An implementation need not support representation
10307 items containing nonstatic expressions, except that
10308 an implementation should support a representation item
10309 for a given entity if each nonstatic expression in the
10310 representation item is a name that statically denotes
10311 a constant declared before the entity.
10312 @end quotation
10313
10314 @noindent
10315 In practice this is applicable only to address clauses, since this is the
10316 only case in which a non-static expression is permitted by the syntax.  As
10317 the AARM notes in sections 13.1 (22.a-22.h):
10318
10319 @display
10320   22.a   Reason: This is to avoid the following sort of thing:
10321
10322   22.b        X : Integer := F(@dots{});
10323               Y : Address := G(@dots{});
10324               for X'Address use Y;
10325
10326   22.c   In the above, we have to evaluate the
10327          initialization expression for X before we
10328          know where to put the result.  This seems
10329          like an unreasonable implementation burden.
10330
10331   22.d   The above code should instead be written
10332          like this:
10333
10334   22.e        Y : constant Address := G(@dots{});
10335               X : Integer := F(@dots{});
10336               for X'Address use Y;
10337
10338   22.f   This allows the expression ``Y'' to be safely
10339          evaluated before X is created.
10340
10341   22.g   The constant could be a formal parameter of mode in.
10342
10343   22.h   An implementation can support other nonstatic
10344          expressions if it wants to.  Expressions of type
10345          Address are hardly ever static, but their value
10346          might be known at compile time anyway in many
10347          cases.
10348 @end display
10349
10350 @noindent
10351 GNAT does indeed permit many additional cases of non-static expressions.  In
10352 particular, if the type involved is elementary there are no restrictions
10353 (since in this case, holding a temporary copy of the initialization value,
10354 if one is present, is inexpensive).  In addition, if there is no implicit or
10355 explicit initialization, then there are no restrictions.  GNAT will reject
10356 only the case where all three of these conditions hold:
10357
10358 @itemize @bullet
10359
10360 @item
10361 The type of the item is non-elementary (e.g.@: a record or array).
10362
10363 @item
10364 There is explicit or implicit initialization required for the object.
10365 Note that access values are always implicitly initialized, and also
10366 in GNAT, certain bit-packed arrays (those having a dynamic length or
10367 a length greater than 64) will also be implicitly initialized to zero.
10368
10369 @item
10370 The address value is non-static.  Here GNAT is more permissive than the
10371 RM, and allows the address value to be the address of a previously declared
10372 stand-alone variable, as long as it does not itself have an address clause.
10373
10374 @smallexample @c ada
10375            Anchor  : Some_Initialized_Type;
10376            Overlay : Some_Initialized_Type;
10377            for Overlay'Address use Anchor'Address;
10378 @end smallexample
10379
10380 @noindent
10381 However, the prefix of the address clause cannot be an array component, or
10382 a component of a discriminated record.
10383
10384 @end itemize
10385
10386 @noindent
10387 As noted above in section 22.h, address values are typically non-static.  In
10388 particular the To_Address function, even if applied to a literal value, is
10389 a non-static function call.  To avoid this minor annoyance, GNAT provides
10390 the implementation defined attribute 'To_Address.  The following two
10391 expressions have identical values:
10392
10393 @findex Attribute
10394 @findex To_Address
10395 @smallexample @c ada
10396    To_Address (16#1234_0000#)
10397    System'To_Address (16#1234_0000#);
10398 @end smallexample
10399
10400 @noindent
10401 except that the second form is considered to be a static expression, and
10402 thus when used as an address clause value is always permitted.
10403
10404 @noindent
10405 Additionally, GNAT treats as static an address clause that is an
10406 unchecked_conversion of a static integer value.  This simplifies the porting
10407 of legacy code, and provides a portable equivalent to the GNAT attribute
10408 @code{To_Address}.
10409
10410 Another issue with address clauses is the interaction with alignment
10411 requirements.  When an address clause is given for an object, the address
10412 value must be consistent with the alignment of the object (which is usually
10413 the same as the alignment of the type of the object).  If an address clause
10414 is given that specifies an inappropriately aligned address value, then the
10415 program execution is erroneous.
10416
10417 Since this source of erroneous behavior can have unfortunate effects, GNAT
10418 checks (at compile time if possible, generating a warning, or at execution
10419 time with a run-time check) that the alignment is appropriate.  If the
10420 run-time check fails, then @code{Program_Error} is raised.  This run-time
10421 check is suppressed if range checks are suppressed, or if the special GNAT
10422 check Alignment_Check is suppressed, or if
10423 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10424
10425 @findex Export
10426 An address clause cannot be given for an exported object.  More
10427 understandably the real restriction is that objects with an address
10428 clause cannot be exported.  This is because such variables are not
10429 defined by the Ada program, so there is no external object to export.
10430
10431 @findex Import
10432 It is permissible to give an address clause and a pragma Import for the
10433 same object.  In this case, the variable is not really defined by the
10434 Ada program, so there is no external symbol to be linked.  The link name
10435 and the external name are ignored in this case.  The reason that we allow this
10436 combination is that it provides a useful idiom to avoid unwanted
10437 initializations on objects with address clauses.
10438
10439 When an address clause is given for an object that has implicit or
10440 explicit initialization, then by default initialization takes place.  This
10441 means that the effect of the object declaration is to overwrite the
10442 memory at the specified address.  This is almost always not what the
10443 programmer wants, so GNAT will output a warning:
10444
10445 @smallexample
10446   with System;
10447   package G is
10448      type R is record
10449         M : Integer := 0;
10450      end record;
10451
10452      Ext : R;
10453      for Ext'Address use System'To_Address (16#1234_1234#);
10454          |
10455   >>> warning: implicit initialization of "Ext" may
10456       modify overlaid storage
10457   >>> warning: use pragma Import for "Ext" to suppress
10458       initialization (RM B(24))
10459
10460   end G;
10461 @end smallexample
10462
10463 @noindent
10464 As indicated by the warning message, the solution is to use a (dummy) pragma
10465 Import to suppress this initialization.  The pragma tell the compiler that the
10466 object is declared and initialized elsewhere.  The following package compiles
10467 without warnings (and the initialization is suppressed):
10468
10469 @smallexample @c ada
10470    with System;
10471    package G is
10472       type R is record
10473          M : Integer := 0;
10474       end record;
10475
10476       Ext : R;
10477       for Ext'Address use System'To_Address (16#1234_1234#);
10478       pragma Import (Ada, Ext);
10479    end G;
10480 @end smallexample
10481
10482 @noindent
10483 A final issue with address clauses involves their use for overlaying
10484 variables, as in the following example:
10485 @cindex Overlaying of objects
10486
10487 @smallexample @c ada
10488   A : Integer;
10489   B : Integer;
10490   for B'Address use A'Address;
10491 @end smallexample
10492
10493 @noindent
10494 or alternatively, using the form recommended by the RM:
10495
10496 @smallexample @c ada
10497   A    : Integer;
10498   Addr : constant Address := A'Address;
10499   B    : Integer;
10500   for B'Address use Addr;
10501 @end smallexample
10502
10503 @noindent
10504 In both of these cases, @code{A}
10505 and @code{B} become aliased to one another via the
10506 address clause. This use of address clauses to overlay
10507 variables, achieving an effect similar to unchecked
10508 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10509 the effect is implementation defined. Furthermore, the
10510 Ada RM specifically recommends that in a situation
10511 like this, @code{B} should be subject to the following
10512 implementation advice (RM 13.3(19)):
10513
10514 @quotation
10515 19  If the Address of an object is specified, or it is imported
10516     or exported, then the implementation should not perform
10517     optimizations based on assumptions of no aliases.
10518 @end quotation
10519
10520 @noindent
10521 GNAT follows this recommendation, and goes further by also applying
10522 this recommendation to the overlaid variable (@code{A}
10523 in the above example) in this case. This means that the overlay
10524 works "as expected", in that a modification to one of the variables
10525 will affect the value of the other.
10526
10527 @node Effect of Convention on Representation
10528 @section Effect of Convention on Representation
10529 @cindex Convention, effect on representation
10530
10531 @noindent
10532 Normally the specification of a foreign language convention for a type or
10533 an object has no effect on the chosen representation.  In particular, the
10534 representation chosen for data in GNAT generally meets the standard system
10535 conventions, and for example records are laid out in a manner that is
10536 consistent with C@.  This means that specifying convention C (for example)
10537 has no effect.
10538
10539 There are four exceptions to this general rule:
10540
10541 @itemize @bullet
10542
10543 @item Convention Fortran and array subtypes
10544 If pragma Convention Fortran is specified for an array subtype, then in
10545 accordance with the implementation advice in section 3.6.2(11) of the
10546 Ada Reference Manual, the array will be stored in a Fortran-compatible
10547 column-major manner, instead of the normal default row-major order.
10548
10549 @item Convention C and enumeration types
10550 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10551 to accommodate all values of the type.  For example, for the enumeration
10552 type declared by:
10553
10554 @smallexample @c ada
10555    type Color is (Red, Green, Blue);
10556 @end smallexample
10557
10558 @noindent
10559 8 bits is sufficient to store all values of the type, so by default, objects
10560 of type @code{Color} will be represented using 8 bits.  However, normal C
10561 convention is to use 32 bits for all enum values in C, since enum values
10562 are essentially of type int.  If pragma @code{Convention C} is specified for an
10563 Ada enumeration type, then the size is modified as necessary (usually to
10564 32 bits) to be consistent with the C convention for enum values.
10565
10566 Note that this treatment applies only to types. If Convention C is given for
10567 an enumeration object, where the enumeration type is not Convention C, then
10568 Object_Size bits are allocated. For example, for a normal enumeration type,
10569 with less than 256 elements, only 8 bits will be allocated for the object.
10570 Since this may be a surprise in terms of what C expects, GNAT will issue a
10571 warning in this situation. The warning can be suppressed by giving an explicit
10572 size clause specifying the desired size.
10573
10574 @item Convention C/Fortran and Boolean types
10575 In C, the usual convention for boolean values, that is values used for
10576 conditions, is that zero represents false, and nonzero values represent
10577 true.  In Ada, the normal convention is that two specific values, typically
10578 0/1, are used to represent false/true respectively.
10579
10580 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10581 value represents true).
10582
10583 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10584 C or Fortran convention for a derived Boolean, as in the following example:
10585
10586 @smallexample @c ada
10587    type C_Switch is new Boolean;
10588    pragma Convention (C, C_Switch);
10589 @end smallexample
10590
10591 @noindent
10592 then the GNAT generated code will treat any nonzero value as true.  For truth
10593 values generated by GNAT, the conventional value 1 will be used for True, but
10594 when one of these values is read, any nonzero value is treated as True.
10595
10596 @item Access types on OpenVMS
10597 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10598 arrays) are 64-bits long. An exception to this rule is for the case of
10599 C-convention access types where there is no explicit size clause present (or
10600 inherited for derived types). In this case, GNAT chooses to make these
10601 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10602 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10603
10604 @end itemize
10605
10606 @node Determining the Representations chosen by GNAT
10607 @section Determining the Representations chosen by GNAT
10608 @cindex Representation, determination of
10609 @cindex @code{-gnatR} switch
10610
10611 @noindent
10612 Although the descriptions in this section are intended to be complete, it is
10613 often easier to simply experiment to see what GNAT accepts and what the
10614 effect is on the layout of types and objects.
10615
10616 As required by the Ada RM, if a representation clause is not accepted, then
10617 it must be rejected as illegal by the compiler.  However, when a
10618 representation clause or pragma is accepted, there can still be questions
10619 of what the compiler actually does.  For example, if a partial record
10620 representation clause specifies the location of some components and not
10621 others, then where are the non-specified components placed? Or if pragma
10622 @code{Pack} is used on a record, then exactly where are the resulting
10623 fields placed? The section on pragma @code{Pack} in this chapter can be
10624 used to answer the second question, but it is often easier to just see
10625 what the compiler does.
10626
10627 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10628 with this option, then the compiler will output information on the actual
10629 representations chosen, in a format similar to source representation
10630 clauses.  For example, if we compile the package:
10631
10632 @smallexample @c ada
10633 package q is
10634    type r (x : boolean) is tagged record
10635       case x is
10636          when True => S : String (1 .. 100);
10637          when False => null;
10638       end case;
10639    end record;
10640
10641    type r2 is new r (false) with record
10642       y2 : integer;
10643    end record;
10644
10645    for r2 use record
10646       y2 at 16 range 0 .. 31;
10647    end record;
10648
10649    type x is record
10650       y : character;
10651    end record;
10652
10653    type x1 is array (1 .. 10) of x;
10654    for x1'component_size use 11;
10655
10656    type ia is access integer;
10657
10658    type Rb1 is array (1 .. 13) of Boolean;
10659    pragma Pack (rb1);
10660
10661    type Rb2 is array (1 .. 65) of Boolean;
10662    pragma Pack (rb2);
10663
10664    type x2 is record
10665       l1 : Boolean;
10666       l2 : Duration;
10667       l3 : Float;
10668       l4 : Boolean;
10669       l5 : Rb1;
10670       l6 : Rb2;
10671    end record;
10672    pragma Pack (x2);
10673 end q;
10674 @end smallexample
10675
10676 @noindent
10677 using the switch @code{-gnatR} we obtain the following output:
10678
10679 @smallexample
10680 Representation information for unit q
10681 -------------------------------------
10682
10683 for r'Size use ??;
10684 for r'Alignment use 4;
10685 for r use record
10686    x    at 4 range  0 .. 7;
10687    _tag at 0 range  0 .. 31;
10688    s    at 5 range  0 .. 799;
10689 end record;
10690
10691 for r2'Size use 160;
10692 for r2'Alignment use 4;
10693 for r2 use record
10694    x       at  4 range  0 .. 7;
10695    _tag    at  0 range  0 .. 31;
10696    _parent at  0 range  0 .. 63;
10697    y2      at 16 range  0 .. 31;
10698 end record;
10699
10700 for x'Size use 8;
10701 for x'Alignment use 1;
10702 for x use record
10703    y at 0 range  0 .. 7;
10704 end record;
10705
10706 for x1'Size use 112;
10707 for x1'Alignment use 1;
10708 for x1'Component_Size use 11;
10709
10710 for rb1'Size use 13;
10711 for rb1'Alignment use 2;
10712 for rb1'Component_Size use 1;
10713
10714 for rb2'Size use 72;
10715 for rb2'Alignment use 1;
10716 for rb2'Component_Size use 1;
10717
10718 for x2'Size use 224;
10719 for x2'Alignment use 4;
10720 for x2 use record
10721    l1 at  0 range  0 .. 0;
10722    l2 at  0 range  1 .. 64;
10723    l3 at 12 range  0 .. 31;
10724    l4 at 16 range  0 .. 0;
10725    l5 at 16 range  1 .. 13;
10726    l6 at 18 range  0 .. 71;
10727 end record;
10728 @end smallexample
10729
10730 @noindent
10731 The Size values are actually the Object_Size, i.e.@: the default size that
10732 will be allocated for objects of the type.
10733 The ?? size for type r indicates that we have a variant record, and the
10734 actual size of objects will depend on the discriminant value.
10735
10736 The Alignment values show the actual alignment chosen by the compiler
10737 for each record or array type.
10738
10739 The record representation clause for type r shows where all fields
10740 are placed, including the compiler generated tag field (whose location
10741 cannot be controlled by the programmer).
10742
10743 The record representation clause for the type extension r2 shows all the
10744 fields present, including the parent field, which is a copy of the fields
10745 of the parent type of r2, i.e.@: r1.
10746
10747 The component size and size clauses for types rb1 and rb2 show
10748 the exact effect of pragma @code{Pack} on these arrays, and the record
10749 representation clause for type x2 shows how pragma @code{Pack} affects
10750 this record type.
10751
10752 In some cases, it may be useful to cut and paste the representation clauses
10753 generated by the compiler into the original source to fix and guarantee
10754 the actual representation to be used.
10755
10756 @node Standard Library Routines
10757 @chapter Standard Library Routines
10758
10759 @noindent
10760 The Ada Reference Manual contains in Annex A a full description of an
10761 extensive set of standard library routines that can be used in any Ada
10762 program, and which must be provided by all Ada compilers.  They are
10763 analogous to the standard C library used by C programs.
10764
10765 GNAT implements all of the facilities described in annex A, and for most
10766 purposes the description in the Ada Reference Manual, or appropriate Ada
10767 text book, will be sufficient for making use of these facilities.
10768
10769 In the case of the input-output facilities,
10770 @xref{The Implementation of Standard I/O},
10771 gives details on exactly how GNAT interfaces to the
10772 file system.  For the remaining packages, the Ada Reference Manual
10773 should be sufficient.  The following is a list of the packages included,
10774 together with a brief description of the functionality that is provided.
10775
10776 For completeness, references are included to other predefined library
10777 routines defined in other sections of the Ada Reference Manual (these are
10778 cross-indexed from Annex A).
10779
10780 @table @code
10781 @item Ada (A.2)
10782 This is a parent package for all the standard library packages.  It is
10783 usually included implicitly in your program, and itself contains no
10784 useful data or routines.
10785
10786 @item Ada.Calendar (9.6)
10787 @code{Calendar} provides time of day access, and routines for
10788 manipulating times and durations.
10789
10790 @item Ada.Characters (A.3.1)
10791 This is a dummy parent package that contains no useful entities
10792
10793 @item Ada.Characters.Handling (A.3.2)
10794 This package provides some basic character handling capabilities,
10795 including classification functions for classes of characters (e.g.@: test
10796 for letters, or digits).
10797
10798 @item Ada.Characters.Latin_1 (A.3.3)
10799 This package includes a complete set of definitions of the characters
10800 that appear in type CHARACTER@.  It is useful for writing programs that
10801 will run in international environments.  For example, if you want an
10802 upper case E with an acute accent in a string, it is often better to use
10803 the definition of @code{UC_E_Acute} in this package.  Then your program
10804 will print in an understandable manner even if your environment does not
10805 support these extended characters.
10806
10807 @item Ada.Command_Line (A.15)
10808 This package provides access to the command line parameters and the name
10809 of the current program (analogous to the use of @code{argc} and @code{argv}
10810 in C), and also allows the exit status for the program to be set in a
10811 system-independent manner.
10812
10813 @item Ada.Decimal (F.2)
10814 This package provides constants describing the range of decimal numbers
10815 implemented, and also a decimal divide routine (analogous to the COBOL
10816 verb DIVIDE .. GIVING .. REMAINDER ..)
10817
10818 @item Ada.Direct_IO (A.8.4)
10819 This package provides input-output using a model of a set of records of
10820 fixed-length, containing an arbitrary definite Ada type, indexed by an
10821 integer record number.
10822
10823 @item Ada.Dynamic_Priorities (D.5)
10824 This package allows the priorities of a task to be adjusted dynamically
10825 as the task is running.
10826
10827 @item Ada.Exceptions (11.4.1)
10828 This package provides additional information on exceptions, and also
10829 contains facilities for treating exceptions as data objects, and raising
10830 exceptions with associated messages.
10831
10832 @item Ada.Finalization (7.6)
10833 This package contains the declarations and subprograms to support the
10834 use of controlled types, providing for automatic initialization and
10835 finalization (analogous to the constructors and destructors of C++)
10836
10837 @item Ada.Interrupts (C.3.2)
10838 This package provides facilities for interfacing to interrupts, which
10839 includes the set of signals or conditions that can be raised and
10840 recognized as interrupts.
10841
10842 @item Ada.Interrupts.Names (C.3.2)
10843 This package provides the set of interrupt names (actually signal
10844 or condition names) that can be handled by GNAT@.
10845
10846 @item Ada.IO_Exceptions (A.13)
10847 This package defines the set of exceptions that can be raised by use of
10848 the standard IO packages.
10849
10850 @item Ada.Numerics
10851 This package contains some standard constants and exceptions used
10852 throughout the numerics packages.  Note that the constants pi and e are
10853 defined here, and it is better to use these definitions than rolling
10854 your own.
10855
10856 @item Ada.Numerics.Complex_Elementary_Functions
10857 Provides the implementation of standard elementary functions (such as
10858 log and trigonometric functions) operating on complex numbers using the
10859 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10860 created by the package @code{Numerics.Complex_Types}.
10861
10862 @item Ada.Numerics.Complex_Types
10863 This is a predefined instantiation of
10864 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10865 build the type @code{Complex} and @code{Imaginary}.
10866
10867 @item Ada.Numerics.Discrete_Random
10868 This package provides a random number generator suitable for generating
10869 random integer values from a specified range.
10870
10871 @item Ada.Numerics.Float_Random
10872 This package provides a random number generator suitable for generating
10873 uniformly distributed floating point values.
10874
10875 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10876 This is a generic version of the package that provides the
10877 implementation of standard elementary functions (such as log and
10878 trigonometric functions) for an arbitrary complex type.
10879
10880 The following predefined instantiations of this package are provided:
10881
10882 @table @code
10883 @item Short_Float
10884 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10885 @item Float
10886 @code{Ada.Numerics.Complex_Elementary_Functions}
10887 @item Long_Float
10888 @code{Ada.Numerics.
10889  Long_Complex_Elementary_Functions}
10890 @end table
10891
10892 @item Ada.Numerics.Generic_Complex_Types
10893 This is a generic package that allows the creation of complex types,
10894 with associated complex arithmetic operations.
10895
10896 The following predefined instantiations of this package exist
10897 @table @code
10898 @item Short_Float
10899 @code{Ada.Numerics.Short_Complex_Complex_Types}
10900 @item Float
10901 @code{Ada.Numerics.Complex_Complex_Types}
10902 @item Long_Float
10903 @code{Ada.Numerics.Long_Complex_Complex_Types}
10904 @end table
10905
10906 @item Ada.Numerics.Generic_Elementary_Functions
10907 This is a generic package that provides the implementation of standard
10908 elementary functions (such as log an trigonometric functions) for an
10909 arbitrary float type.
10910
10911 The following predefined instantiations of this package exist
10912
10913 @table @code
10914 @item Short_Float
10915 @code{Ada.Numerics.Short_Elementary_Functions}
10916 @item Float
10917 @code{Ada.Numerics.Elementary_Functions}
10918 @item Long_Float
10919 @code{Ada.Numerics.Long_Elementary_Functions}
10920 @end table
10921
10922 @item Ada.Real_Time (D.8)
10923 This package provides facilities similar to those of @code{Calendar}, but
10924 operating with a finer clock suitable for real time control. Note that
10925 annex D requires that there be no backward clock jumps, and GNAT generally
10926 guarantees this behavior, but of course if the external clock on which
10927 the GNAT runtime depends is deliberately reset by some external event,
10928 then such a backward jump may occur.
10929
10930 @item Ada.Sequential_IO (A.8.1)
10931 This package provides input-output facilities for sequential files,
10932 which can contain a sequence of values of a single type, which can be
10933 any Ada type, including indefinite (unconstrained) types.
10934
10935 @item Ada.Storage_IO (A.9)
10936 This package provides a facility for mapping arbitrary Ada types to and
10937 from a storage buffer.  It is primarily intended for the creation of new
10938 IO packages.
10939
10940 @item Ada.Streams (13.13.1)
10941 This is a generic package that provides the basic support for the
10942 concept of streams as used by the stream attributes (@code{Input},
10943 @code{Output}, @code{Read} and @code{Write}).
10944
10945 @item Ada.Streams.Stream_IO (A.12.1)
10946 This package is a specialization of the type @code{Streams} defined in
10947 package @code{Streams} together with a set of operations providing
10948 Stream_IO capability.  The Stream_IO model permits both random and
10949 sequential access to a file which can contain an arbitrary set of values
10950 of one or more Ada types.
10951
10952 @item Ada.Strings (A.4.1)
10953 This package provides some basic constants used by the string handling
10954 packages.
10955
10956 @item Ada.Strings.Bounded (A.4.4)
10957 This package provides facilities for handling variable length
10958 strings.  The bounded model requires a maximum length.  It is thus
10959 somewhat more limited than the unbounded model, but avoids the use of
10960 dynamic allocation or finalization.
10961
10962 @item Ada.Strings.Fixed (A.4.3)
10963 This package provides facilities for handling fixed length strings.
10964
10965 @item Ada.Strings.Maps (A.4.2)
10966 This package provides facilities for handling character mappings and
10967 arbitrarily defined subsets of characters.  For instance it is useful in
10968 defining specialized translation tables.
10969
10970 @item Ada.Strings.Maps.Constants (A.4.6)
10971 This package provides a standard set of predefined mappings and
10972 predefined character sets.  For example, the standard upper to lower case
10973 conversion table is found in this package.  Note that upper to lower case
10974 conversion is non-trivial if you want to take the entire set of
10975 characters, including extended characters like E with an acute accent,
10976 into account.  You should use the mappings in this package (rather than
10977 adding 32 yourself) to do case mappings.
10978
10979 @item Ada.Strings.Unbounded (A.4.5)
10980 This package provides facilities for handling variable length
10981 strings.  The unbounded model allows arbitrary length strings, but
10982 requires the use of dynamic allocation and finalization.
10983
10984 @item Ada.Strings.Wide_Bounded (A.4.7)
10985 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10986 @itemx Ada.Strings.Wide_Maps (A.4.7)
10987 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10988 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10989 These packages provide analogous capabilities to the corresponding
10990 packages without @samp{Wide_} in the name, but operate with the types
10991 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10992 and @code{Character}.
10993
10994 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10995 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10996 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10997 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10998 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10999 These packages provide analogous capabilities to the corresponding
11000 packages without @samp{Wide_} in the name, but operate with the types
11001 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11002 of @code{String} and @code{Character}.
11003
11004 @item Ada.Synchronous_Task_Control (D.10)
11005 This package provides some standard facilities for controlling task
11006 communication in a synchronous manner.
11007
11008 @item Ada.Tags
11009 This package contains definitions for manipulation of the tags of tagged
11010 values.
11011
11012 @item Ada.Task_Attributes
11013 This package provides the capability of associating arbitrary
11014 task-specific data with separate tasks.
11015
11016 @item Ada.Text_IO
11017 This package provides basic text input-output capabilities for
11018 character, string and numeric data.  The subpackages of this
11019 package are listed next.
11020
11021 @item Ada.Text_IO.Decimal_IO
11022 Provides input-output facilities for decimal fixed-point types
11023
11024 @item Ada.Text_IO.Enumeration_IO
11025 Provides input-output facilities for enumeration types.
11026
11027 @item Ada.Text_IO.Fixed_IO
11028 Provides input-output facilities for ordinary fixed-point types.
11029
11030 @item Ada.Text_IO.Float_IO
11031 Provides input-output facilities for float types.  The following
11032 predefined instantiations of this generic package are available:
11033
11034 @table @code
11035 @item Short_Float
11036 @code{Short_Float_Text_IO}
11037 @item Float
11038 @code{Float_Text_IO}
11039 @item Long_Float
11040 @code{Long_Float_Text_IO}
11041 @end table
11042
11043 @item Ada.Text_IO.Integer_IO
11044 Provides input-output facilities for integer types.  The following
11045 predefined instantiations of this generic package are available:
11046
11047 @table @code
11048 @item Short_Short_Integer
11049 @code{Ada.Short_Short_Integer_Text_IO}
11050 @item Short_Integer
11051 @code{Ada.Short_Integer_Text_IO}
11052 @item Integer
11053 @code{Ada.Integer_Text_IO}
11054 @item Long_Integer
11055 @code{Ada.Long_Integer_Text_IO}
11056 @item Long_Long_Integer
11057 @code{Ada.Long_Long_Integer_Text_IO}
11058 @end table
11059
11060 @item Ada.Text_IO.Modular_IO
11061 Provides input-output facilities for modular (unsigned) types
11062
11063 @item Ada.Text_IO.Complex_IO (G.1.3)
11064 This package provides basic text input-output capabilities for complex
11065 data.
11066
11067 @item Ada.Text_IO.Editing (F.3.3)
11068 This package contains routines for edited output, analogous to the use
11069 of pictures in COBOL@.  The picture formats used by this package are a
11070 close copy of the facility in COBOL@.
11071
11072 @item Ada.Text_IO.Text_Streams (A.12.2)
11073 This package provides a facility that allows Text_IO files to be treated
11074 as streams, so that the stream attributes can be used for writing
11075 arbitrary data, including binary data, to Text_IO files.
11076
11077 @item Ada.Unchecked_Conversion (13.9)
11078 This generic package allows arbitrary conversion from one type to
11079 another of the same size, providing for breaking the type safety in
11080 special circumstances.
11081
11082 If the types have the same Size (more accurately the same Value_Size),
11083 then the effect is simply to transfer the bits from the source to the
11084 target type without any modification.  This usage is well defined, and
11085 for simple types whose representation is typically the same across
11086 all implementations, gives a portable method of performing such
11087 conversions.
11088
11089 If the types do not have the same size, then the result is implementation
11090 defined, and thus may be non-portable.  The following describes how GNAT
11091 handles such unchecked conversion cases.
11092
11093 If the types are of different sizes, and are both discrete types, then
11094 the effect is of a normal type conversion without any constraint checking.
11095 In particular if the result type has a larger size, the result will be
11096 zero or sign extended.  If the result type has a smaller size, the result
11097 will be truncated by ignoring high order bits.
11098
11099 If the types are of different sizes, and are not both discrete types,
11100 then the conversion works as though pointers were created to the source
11101 and target, and the pointer value is converted.  The effect is that bits
11102 are copied from successive low order storage units and bits of the source
11103 up to the length of the target type.
11104
11105 A warning is issued if the lengths differ, since the effect in this
11106 case is implementation dependent, and the above behavior may not match
11107 that of some other compiler.
11108
11109 A pointer to one type may be converted to a pointer to another type using
11110 unchecked conversion.  The only case in which the effect is undefined is
11111 when one or both pointers are pointers to unconstrained array types.  In
11112 this case, the bounds information may get incorrectly transferred, and in
11113 particular, GNAT uses double size pointers for such types, and it is
11114 meaningless to convert between such pointer types.  GNAT will issue a
11115 warning if the alignment of the target designated type is more strict
11116 than the alignment of the source designated type (since the result may
11117 be unaligned in this case).
11118
11119 A pointer other than a pointer to an unconstrained array type may be
11120 converted to and from System.Address.  Such usage is common in Ada 83
11121 programs, but note that Ada.Address_To_Access_Conversions is the
11122 preferred method of performing such conversions in Ada 95 and Ada 2005.
11123 Neither
11124 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11125 used in conjunction with pointers to unconstrained objects, since
11126 the bounds information cannot be handled correctly in this case.
11127
11128 @item Ada.Unchecked_Deallocation (13.11.2)
11129 This generic package allows explicit freeing of storage previously
11130 allocated by use of an allocator.
11131
11132 @item Ada.Wide_Text_IO (A.11)
11133 This package is similar to @code{Ada.Text_IO}, except that the external
11134 file supports wide character representations, and the internal types are
11135 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11136 and @code{String}.  It contains generic subpackages listed next.
11137
11138 @item Ada.Wide_Text_IO.Decimal_IO
11139 Provides input-output facilities for decimal fixed-point types
11140
11141 @item Ada.Wide_Text_IO.Enumeration_IO
11142 Provides input-output facilities for enumeration types.
11143
11144 @item Ada.Wide_Text_IO.Fixed_IO
11145 Provides input-output facilities for ordinary fixed-point types.
11146
11147 @item Ada.Wide_Text_IO.Float_IO
11148 Provides input-output facilities for float types.  The following
11149 predefined instantiations of this generic package are available:
11150
11151 @table @code
11152 @item Short_Float
11153 @code{Short_Float_Wide_Text_IO}
11154 @item Float
11155 @code{Float_Wide_Text_IO}
11156 @item Long_Float
11157 @code{Long_Float_Wide_Text_IO}
11158 @end table
11159
11160 @item Ada.Wide_Text_IO.Integer_IO
11161 Provides input-output facilities for integer types.  The following
11162 predefined instantiations of this generic package are available:
11163
11164 @table @code
11165 @item Short_Short_Integer
11166 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11167 @item Short_Integer
11168 @code{Ada.Short_Integer_Wide_Text_IO}
11169 @item Integer
11170 @code{Ada.Integer_Wide_Text_IO}
11171 @item Long_Integer
11172 @code{Ada.Long_Integer_Wide_Text_IO}
11173 @item Long_Long_Integer
11174 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11175 @end table
11176
11177 @item Ada.Wide_Text_IO.Modular_IO
11178 Provides input-output facilities for modular (unsigned) types
11179
11180 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11181 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11182 external file supports wide character representations.
11183
11184 @item Ada.Wide_Text_IO.Editing (F.3.4)
11185 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11186 types are @code{Wide_Character} and @code{Wide_String} instead of
11187 @code{Character} and @code{String}.
11188
11189 @item Ada.Wide_Text_IO.Streams (A.12.3)
11190 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11191 types are @code{Wide_Character} and @code{Wide_String} instead of
11192 @code{Character} and @code{String}.
11193
11194 @item Ada.Wide_Wide_Text_IO (A.11)
11195 This package is similar to @code{Ada.Text_IO}, except that the external
11196 file supports wide character representations, and the internal types are
11197 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11198 and @code{String}.  It contains generic subpackages listed next.
11199
11200 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11201 Provides input-output facilities for decimal fixed-point types
11202
11203 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11204 Provides input-output facilities for enumeration types.
11205
11206 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11207 Provides input-output facilities for ordinary fixed-point types.
11208
11209 @item Ada.Wide_Wide_Text_IO.Float_IO
11210 Provides input-output facilities for float types.  The following
11211 predefined instantiations of this generic package are available:
11212
11213 @table @code
11214 @item Short_Float
11215 @code{Short_Float_Wide_Wide_Text_IO}
11216 @item Float
11217 @code{Float_Wide_Wide_Text_IO}
11218 @item Long_Float
11219 @code{Long_Float_Wide_Wide_Text_IO}
11220 @end table
11221
11222 @item Ada.Wide_Wide_Text_IO.Integer_IO
11223 Provides input-output facilities for integer types.  The following
11224 predefined instantiations of this generic package are available:
11225
11226 @table @code
11227 @item Short_Short_Integer
11228 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11229 @item Short_Integer
11230 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11231 @item Integer
11232 @code{Ada.Integer_Wide_Wide_Text_IO}
11233 @item Long_Integer
11234 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11235 @item Long_Long_Integer
11236 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11237 @end table
11238
11239 @item Ada.Wide_Wide_Text_IO.Modular_IO
11240 Provides input-output facilities for modular (unsigned) types
11241
11242 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11243 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11244 external file supports wide character representations.
11245
11246 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11247 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11248 types are @code{Wide_Character} and @code{Wide_String} instead of
11249 @code{Character} and @code{String}.
11250
11251 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11252 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11253 types are @code{Wide_Character} and @code{Wide_String} instead of
11254 @code{Character} and @code{String}.
11255 @end table
11256
11257
11258
11259 @node The Implementation of Standard I/O
11260 @chapter The Implementation of Standard I/O
11261
11262 @noindent
11263 GNAT implements all the required input-output facilities described in
11264 A.6 through A.14.  These sections of the Ada Reference Manual describe the
11265 required behavior of these packages from the Ada point of view, and if
11266 you are writing a portable Ada program that does not need to know the
11267 exact manner in which Ada maps to the outside world when it comes to
11268 reading or writing external files, then you do not need to read this
11269 chapter.  As long as your files are all regular files (not pipes or
11270 devices), and as long as you write and read the files only from Ada, the
11271 description in the Ada Reference Manual is sufficient.
11272
11273 However, if you want to do input-output to pipes or other devices, such
11274 as the keyboard or screen, or if the files you are dealing with are
11275 either generated by some other language, or to be read by some other
11276 language, then you need to know more about the details of how the GNAT
11277 implementation of these input-output facilities behaves.
11278
11279 In this chapter we give a detailed description of exactly how GNAT
11280 interfaces to the file system.  As always, the sources of the system are
11281 available to you for answering questions at an even more detailed level,
11282 but for most purposes the information in this chapter will suffice.
11283
11284 Another reason that you may need to know more about how input-output is
11285 implemented arises when you have a program written in mixed languages
11286 where, for example, files are shared between the C and Ada sections of
11287 the same program.  GNAT provides some additional facilities, in the form
11288 of additional child library packages, that facilitate this sharing, and
11289 these additional facilities are also described in this chapter.
11290
11291 @menu
11292 * Standard I/O Packages::
11293 * FORM Strings::
11294 * Direct_IO::
11295 * Sequential_IO::
11296 * Text_IO::
11297 * Wide_Text_IO::
11298 * Wide_Wide_Text_IO::
11299 * Stream_IO::
11300 * Shared Files::
11301 * Filenames encoding::
11302 * Open Modes::
11303 * Operations on C Streams::
11304 * Interfacing to C Streams::
11305 @end menu
11306
11307 @node Standard I/O Packages
11308 @section Standard I/O Packages
11309
11310 @noindent
11311 The Standard I/O packages described in Annex A for
11312
11313 @itemize @bullet
11314 @item
11315 Ada.Text_IO
11316 @item
11317 Ada.Text_IO.Complex_IO
11318 @item
11319 Ada.Text_IO.Text_Streams
11320 @item
11321 Ada.Wide_Text_IO
11322 @item
11323 Ada.Wide_Text_IO.Complex_IO
11324 @item
11325 Ada.Wide_Text_IO.Text_Streams
11326 @item
11327 Ada.Wide_Wide_Text_IO
11328 @item
11329 Ada.Wide_Wide_Text_IO.Complex_IO
11330 @item
11331 Ada.Wide_Wide_Text_IO.Text_Streams
11332 @item
11333 Ada.Stream_IO
11334 @item
11335 Ada.Sequential_IO
11336 @item
11337 Ada.Direct_IO
11338 @end itemize
11339
11340 @noindent
11341 are implemented using the C
11342 library streams facility; where
11343
11344 @itemize @bullet
11345 @item
11346 All files are opened using @code{fopen}.
11347 @item
11348 All input/output operations use @code{fread}/@code{fwrite}.
11349 @end itemize
11350
11351 @noindent
11352 There is no internal buffering of any kind at the Ada library level. The only
11353 buffering is that provided at the system level in the implementation of the
11354 library routines that support streams. This facilitates shared use of these
11355 streams by mixed language programs. Note though that system level buffering is
11356 explicitly enabled at elaboration of the standard I/O packages and that can
11357 have an impact on mixed language programs, in particular those using I/O before
11358 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11359 the Ada elaboration routine before performing any I/O or when impractical,
11360 flush the common I/O streams and in particular Standard_Output before
11361 elaborating the Ada code.
11362
11363 @node FORM Strings
11364 @section FORM Strings
11365
11366 @noindent
11367 The format of a FORM string in GNAT is:
11368
11369 @smallexample
11370 "keyword=value,keyword=value,@dots{},keyword=value"
11371 @end smallexample
11372
11373 @noindent
11374 where letters may be in upper or lower case, and there are no spaces
11375 between values.  The order of the entries is not important.  Currently
11376 there are two keywords defined.
11377
11378 @smallexample
11379 SHARED=[YES|NO]
11380 WCEM=[n|h|u|s|e|8|b]
11381 @end smallexample
11382
11383 @noindent
11384 The use of these parameters is described later in this section.
11385
11386 @node Direct_IO
11387 @section Direct_IO
11388
11389 @noindent
11390 Direct_IO can only be instantiated for definite types.  This is a
11391 restriction of the Ada language, which means that the records are fixed
11392 length (the length being determined by @code{@var{type}'Size}, rounded
11393 up to the next storage unit boundary if necessary).
11394
11395 The records of a Direct_IO file are simply written to the file in index
11396 sequence, with the first record starting at offset zero, and subsequent
11397 records following.  There is no control information of any kind.  For
11398 example, if 32-bit integers are being written, each record takes
11399 4-bytes, so the record at index @var{K} starts at offset
11400 (@var{K}@minus{}1)*4.
11401
11402 There is no limit on the size of Direct_IO files, they are expanded as
11403 necessary to accommodate whatever records are written to the file.
11404
11405 @node Sequential_IO
11406 @section Sequential_IO
11407
11408 @noindent
11409 Sequential_IO may be instantiated with either a definite (constrained)
11410 or indefinite (unconstrained) type.
11411
11412 For the definite type case, the elements written to the file are simply
11413 the memory images of the data values with no control information of any
11414 kind.  The resulting file should be read using the same type, no validity
11415 checking is performed on input.
11416
11417 For the indefinite type case, the elements written consist of two
11418 parts.  First is the size of the data item, written as the memory image
11419 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11420 the data value.  The resulting file can only be read using the same
11421 (unconstrained) type.  Normal assignment checks are performed on these
11422 read operations, and if these checks fail, @code{Data_Error} is
11423 raised.  In particular, in the array case, the lengths must match, and in
11424 the variant record case, if the variable for a particular read operation
11425 is constrained, the discriminants must match.
11426
11427 Note that it is not possible to use Sequential_IO to write variable
11428 length array items, and then read the data back into different length
11429 arrays.  For example, the following will raise @code{Data_Error}:
11430
11431 @smallexample @c ada
11432  package IO is new Sequential_IO (String);
11433  F : IO.File_Type;
11434  S : String (1..4);
11435  @dots{}
11436  IO.Create (F)
11437  IO.Write (F, "hello!")
11438  IO.Reset (F, Mode=>In_File);
11439  IO.Read (F, S);
11440  Put_Line (S);
11441
11442 @end smallexample
11443
11444 @noindent
11445 On some Ada implementations, this will print @code{hell}, but the program is
11446 clearly incorrect, since there is only one element in the file, and that
11447 element is the string @code{hello!}.
11448
11449 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11450 using Stream_IO, and this is the preferred mechanism.  In particular, the
11451 above program fragment rewritten to use Stream_IO will work correctly.
11452
11453 @node Text_IO
11454 @section Text_IO
11455
11456 @noindent
11457 Text_IO files consist of a stream of characters containing the following
11458 special control characters:
11459
11460 @smallexample
11461 LF (line feed, 16#0A#) Line Mark
11462 FF (form feed, 16#0C#) Page Mark
11463 @end smallexample
11464
11465 @noindent
11466 A canonical Text_IO file is defined as one in which the following
11467 conditions are met:
11468
11469 @itemize @bullet
11470 @item
11471 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11472 of the line.
11473
11474 @item
11475 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11476 end of a page and consequently can appear only immediately following a
11477 @code{LF} (line mark) character.
11478
11479 @item
11480 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11481 (line mark, page mark).  In the former case, the page mark is implicitly
11482 assumed to be present.
11483 @end itemize
11484
11485 @noindent
11486 A file written using Text_IO will be in canonical form provided that no
11487 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11488 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11489 the file unless an explicit @code{New_Page} operation was performed
11490 before closing the file.
11491
11492 A canonical Text_IO file that is a regular file (i.e., not a device or a
11493 pipe) can be read using any of the routines in Text_IO@.  The
11494 semantics in this case will be exactly as defined in the Ada Reference
11495 Manual, and all the routines in Text_IO are fully implemented.
11496
11497 A text file that does not meet the requirements for a canonical Text_IO
11498 file has one of the following:
11499
11500 @itemize @bullet
11501 @item
11502 The file contains @code{FF} characters not immediately following a
11503 @code{LF} character.
11504
11505 @item
11506 The file contains @code{LF} or @code{FF} characters written by
11507 @code{Put} or @code{Put_Line}, which are not logically considered to be
11508 line marks or page marks.
11509
11510 @item
11511 The file ends in a character other than @code{LF} or @code{FF},
11512 i.e.@: there is no explicit line mark or page mark at the end of the file.
11513 @end itemize
11514
11515 @noindent
11516 Text_IO can be used to read such non-standard text files but subprograms
11517 to do with line or page numbers do not have defined meanings.  In
11518 particular, a @code{FF} character that does not follow a @code{LF}
11519 character may or may not be treated as a page mark from the point of
11520 view of page and line numbering.  Every @code{LF} character is considered
11521 to end a line, and there is an implied @code{LF} character at the end of
11522 the file.
11523
11524 @menu
11525 * Text_IO Stream Pointer Positioning::
11526 * Text_IO Reading and Writing Non-Regular Files::
11527 * Get_Immediate::
11528 * Treating Text_IO Files as Streams::
11529 * Text_IO Extensions::
11530 * Text_IO Facilities for Unbounded Strings::
11531 @end menu
11532
11533 @node Text_IO Stream Pointer Positioning
11534 @subsection Stream Pointer Positioning
11535
11536 @noindent
11537 @code{Ada.Text_IO} has a definition of current position for a file that
11538 is being read.  No internal buffering occurs in Text_IO, and usually the
11539 physical position in the stream used to implement the file corresponds
11540 to this logical position defined by Text_IO@.  There are two exceptions:
11541
11542 @itemize @bullet
11543 @item
11544 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11545 is positioned past the @code{LF} (line mark) that precedes the page
11546 mark.  Text_IO maintains an internal flag so that subsequent read
11547 operations properly handle the logical position which is unchanged by
11548 the @code{End_Of_Page} call.
11549
11550 @item
11551 After a call to @code{End_Of_File} that returns @code{True}, if the
11552 Text_IO file was positioned before the line mark at the end of file
11553 before the call, then the logical position is unchanged, but the stream
11554 is physically positioned right at the end of file (past the line mark,
11555 and past a possible page mark following the line mark.  Again Text_IO
11556 maintains internal flags so that subsequent read operations properly
11557 handle the logical position.
11558 @end itemize
11559
11560 @noindent
11561 These discrepancies have no effect on the observable behavior of
11562 Text_IO, but if a single Ada stream is shared between a C program and
11563 Ada program, or shared (using @samp{shared=yes} in the form string)
11564 between two Ada files, then the difference may be observable in some
11565 situations.
11566
11567 @node Text_IO Reading and Writing Non-Regular Files
11568 @subsection Reading and Writing Non-Regular Files
11569
11570 @noindent
11571 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11572 can be used for reading and writing.  Writing is not affected and the
11573 sequence of characters output is identical to the normal file case, but
11574 for reading, the behavior of Text_IO is modified to avoid undesirable
11575 look-ahead as follows:
11576
11577 An input file that is not a regular file is considered to have no page
11578 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11579 page mark) appearing in the file are considered to be data
11580 characters.  In particular:
11581
11582 @itemize @bullet
11583 @item
11584 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11585 following a line mark.  If a page mark appears, it will be treated as a
11586 data character.
11587
11588 @item
11589 This avoids the need to wait for an extra character to be typed or
11590 entered from the pipe to complete one of these operations.
11591
11592 @item
11593 @code{End_Of_Page} always returns @code{False}
11594
11595 @item
11596 @code{End_Of_File} will return @code{False} if there is a page mark at
11597 the end of the file.
11598 @end itemize
11599
11600 @noindent
11601 Output to non-regular files is the same as for regular files.  Page marks
11602 may be written to non-regular files using @code{New_Page}, but as noted
11603 above they will not be treated as page marks on input if the output is
11604 piped to another Ada program.
11605
11606 Another important discrepancy when reading non-regular files is that the end
11607 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11608 pressing the @key{EOT} key,
11609 then end of file
11610 is signaled once (i.e.@: the test @code{End_Of_File}
11611 will yield @code{True}, or a read will
11612 raise @code{End_Error}), but then reading can resume
11613 to read data past that end of
11614 file indication, until another end of file indication is entered.
11615
11616 @node Get_Immediate
11617 @subsection Get_Immediate
11618 @cindex Get_Immediate
11619
11620 @noindent
11621 Get_Immediate returns the next character (including control characters)
11622 from the input file.  In particular, Get_Immediate will return LF or FF
11623 characters used as line marks or page marks.  Such operations leave the
11624 file positioned past the control character, and it is thus not treated
11625 as having its normal function.  This means that page, line and column
11626 counts after this kind of Get_Immediate call are set as though the mark
11627 did not occur.  In the case where a Get_Immediate leaves the file
11628 positioned between the line mark and page mark (which is not normally
11629 possible), it is undefined whether the FF character will be treated as a
11630 page mark.
11631
11632 @node Treating Text_IO Files as Streams
11633 @subsection Treating Text_IO Files as Streams
11634 @cindex Stream files
11635
11636 @noindent
11637 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11638 as a stream.  Data written to a Text_IO file in this stream mode is
11639 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11640 16#0C# (@code{FF}), the resulting file may have non-standard
11641 format.  Similarly if read operations are used to read from a Text_IO
11642 file treated as a stream, then @code{LF} and @code{FF} characters may be
11643 skipped and the effect is similar to that described above for
11644 @code{Get_Immediate}.
11645
11646 @node Text_IO Extensions
11647 @subsection Text_IO Extensions
11648 @cindex Text_IO extensions
11649
11650 @noindent
11651 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11652 to the standard @code{Text_IO} package:
11653
11654 @itemize @bullet
11655 @item function File_Exists (Name : String) return Boolean;
11656 Determines if a file of the given name exists.
11657
11658 @item function Get_Line return String;
11659 Reads a string from the standard input file.  The value returned is exactly
11660 the length of the line that was read.
11661
11662 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11663 Similar, except that the parameter File specifies the file from which
11664 the string is to be read.
11665
11666 @end itemize
11667
11668 @node Text_IO Facilities for Unbounded Strings
11669 @subsection Text_IO Facilities for Unbounded Strings
11670 @cindex Text_IO for unbounded strings
11671 @cindex Unbounded_String, Text_IO operations
11672
11673 @noindent
11674 The package @code{Ada.Strings.Unbounded.Text_IO}
11675 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11676 subprograms useful for Text_IO operations on unbounded strings:
11677
11678 @itemize @bullet
11679
11680 @item function Get_Line (File : File_Type) return Unbounded_String;
11681 Reads a line from the specified file
11682 and returns the result as an unbounded string.
11683
11684 @item procedure Put (File : File_Type; U : Unbounded_String);
11685 Writes the value of the given unbounded string to the specified file
11686 Similar to the effect of
11687 @code{Put (To_String (U))} except that an extra copy is avoided.
11688
11689 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11690 Writes the value of the given unbounded string to the specified file,
11691 followed by a @code{New_Line}.
11692 Similar to the effect of @code{Put_Line (To_String (U))} except
11693 that an extra copy is avoided.
11694 @end itemize
11695
11696 @noindent
11697 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11698 and is optional.  If the parameter is omitted, then the standard input or
11699 output file is referenced as appropriate.
11700
11701 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11702 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11703 @code{Wide_Text_IO} functionality for unbounded wide strings.
11704
11705 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11706 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11707 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11708
11709 @node Wide_Text_IO
11710 @section Wide_Text_IO
11711
11712 @noindent
11713 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11714 both input and output files may contain special sequences that represent
11715 wide character values.  The encoding scheme for a given file may be
11716 specified using a FORM parameter:
11717
11718 @smallexample
11719 WCEM=@var{x}
11720 @end smallexample
11721
11722 @noindent
11723 as part of the FORM string (WCEM = wide character encoding method),
11724 where @var{x} is one of the following characters
11725
11726 @table @samp
11727 @item h
11728 Hex ESC encoding
11729 @item u
11730 Upper half encoding
11731 @item s
11732 Shift-JIS encoding
11733 @item e
11734 EUC Encoding
11735 @item 8
11736 UTF-8 encoding
11737 @item b
11738 Brackets encoding
11739 @end table
11740
11741 @noindent
11742 The encoding methods match those that
11743 can be used in a source
11744 program, but there is no requirement that the encoding method used for
11745 the source program be the same as the encoding method used for files,
11746 and different files may use different encoding methods.
11747
11748 The default encoding method for the standard files, and for opened files
11749 for which no WCEM parameter is given in the FORM string matches the
11750 wide character encoding specified for the main program (the default
11751 being brackets encoding if no coding method was specified with -gnatW).
11752
11753 @table @asis
11754 @item Hex Coding
11755 In this encoding, a wide character is represented by a five character
11756 sequence:
11757
11758 @smallexample
11759 ESC a b c d
11760 @end smallexample
11761
11762 @noindent
11763 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11764 characters (using upper case letters) of the wide character code.  For
11765 example, ESC A345 is used to represent the wide character with code
11766 16#A345#.  This scheme is compatible with use of the full
11767 @code{Wide_Character} set.
11768
11769 @item Upper Half Coding
11770 The wide character with encoding 16#abcd#, where the upper bit is on
11771 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11772 16#cd#.  The second byte may never be a format control character, but is
11773 not required to be in the upper half.  This method can be also used for
11774 shift-JIS or EUC where the internal coding matches the external coding.
11775
11776 @item Shift JIS Coding
11777 A wide character is represented by a two character sequence 16#ab# and
11778 16#cd#, with the restrictions described for upper half encoding as
11779 described above.  The internal character code is the corresponding JIS
11780 character according to the standard algorithm for Shift-JIS
11781 conversion.  Only characters defined in the JIS code set table can be
11782 used with this encoding method.
11783
11784 @item EUC Coding
11785 A wide character is represented by a two character sequence 16#ab# and
11786 16#cd#, with both characters being in the upper half.  The internal
11787 character code is the corresponding JIS character according to the EUC
11788 encoding algorithm.  Only characters defined in the JIS code set table
11789 can be used with this encoding method.
11790
11791 @item UTF-8 Coding
11792 A wide character is represented using
11793 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11794 10646-1/Am.2.  Depending on the character value, the representation
11795 is a one, two, or three byte sequence:
11796
11797 @smallexample
11798 16#0000#-16#007f#: 2#0xxxxxxx#
11799 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11800 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11801 @end smallexample
11802
11803 @noindent
11804 where the xxx bits correspond to the left-padded bits of the
11805 16-bit character value.  Note that all lower half ASCII characters
11806 are represented as ASCII bytes and all upper half characters and
11807 other wide characters are represented as sequences of upper-half
11808 (The full UTF-8 scheme allows for encoding 31-bit characters as
11809 6-byte sequences, but in this implementation, all UTF-8 sequences
11810 of four or more bytes length will raise a Constraint_Error, as
11811 will all invalid UTF-8 sequences.)
11812
11813 @item Brackets Coding
11814 In this encoding, a wide character is represented by the following eight
11815 character sequence:
11816
11817 @smallexample
11818 [ " a b c d " ]
11819 @end smallexample
11820
11821 @noindent
11822 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11823 characters (using uppercase letters) of the wide character code.  For
11824 example, @code{["A345"]} is used to represent the wide character with code
11825 @code{16#A345#}.
11826 This scheme is compatible with use of the full Wide_Character set.
11827 On input, brackets coding can also be used for upper half characters,
11828 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11829 is only used for wide characters with a code greater than @code{16#FF#}.
11830
11831 Note that brackets coding is not normally used in the context of
11832 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11833 a portable way of encoding source files. In the context of Wide_Text_IO
11834 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11835 any instance of the left bracket character other than to encode wide
11836 character values using the brackets encoding method. In practice it is
11837 expected that some standard wide character encoding method such
11838 as UTF-8 will be used for text input output.
11839
11840 If brackets notation is used, then any occurrence of a left bracket
11841 in the input file which is not the start of a valid wide character
11842 sequence will cause Constraint_Error to be raised. It is possible to
11843 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11844 input will interpret this as a left bracket.
11845
11846 However, when a left bracket is output, it will be output as a left bracket
11847 and not as ["5B"]. We make this decision because for normal use of
11848 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11849 brackets. For example, if we write:
11850
11851 @smallexample
11852    Put_Line ("Start of output [first run]");
11853 @end smallexample
11854
11855 @noindent
11856 we really do not want to have the left bracket in this message clobbered so
11857 that the output reads:
11858
11859 @smallexample
11860    Start of output ["5B"]first run]
11861 @end smallexample
11862
11863 @noindent
11864 In practice brackets encoding is reasonably useful for normal Put_Line use
11865 since we won't get confused between left brackets and wide character
11866 sequences in the output. But for input, or when files are written out
11867 and read back in, it really makes better sense to use one of the standard
11868 encoding methods such as UTF-8.
11869
11870 @end table
11871
11872 @noindent
11873 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
11874 not all wide character
11875 values can be represented.  An attempt to output a character that cannot
11876 be represented using the encoding scheme for the file causes
11877 Constraint_Error to be raised.  An invalid wide character sequence on
11878 input also causes Constraint_Error to be raised.
11879
11880 @menu
11881 * Wide_Text_IO Stream Pointer Positioning::
11882 * Wide_Text_IO Reading and Writing Non-Regular Files::
11883 @end menu
11884
11885 @node Wide_Text_IO Stream Pointer Positioning
11886 @subsection Stream Pointer Positioning
11887
11888 @noindent
11889 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11890 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11891 case:
11892
11893 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11894 normal lower ASCII set (i.e.@: a character in the range:
11895
11896 @smallexample @c ada
11897 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11898 @end smallexample
11899
11900 @noindent
11901 then although the logical position of the file pointer is unchanged by
11902 the @code{Look_Ahead} call, the stream is physically positioned past the
11903 wide character sequence.  Again this is to avoid the need for buffering
11904 or backup, and all @code{Wide_Text_IO} routines check the internal
11905 indication that this situation has occurred so that this is not visible
11906 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11907 can be observed if the wide text file shares a stream with another file.
11908
11909 @node Wide_Text_IO Reading and Writing Non-Regular Files
11910 @subsection Reading and Writing Non-Regular Files
11911
11912 @noindent
11913 As in the case of Text_IO, when a non-regular file is read, it is
11914 assumed that the file contains no page marks (any form characters are
11915 treated as data characters), and @code{End_Of_Page} always returns
11916 @code{False}.  Similarly, the end of file indication is not sticky, so
11917 it is possible to read beyond an end of file.
11918
11919 @node Wide_Wide_Text_IO
11920 @section Wide_Wide_Text_IO
11921
11922 @noindent
11923 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11924 both input and output files may contain special sequences that represent
11925 wide wide character values.  The encoding scheme for a given file may be
11926 specified using a FORM parameter:
11927
11928 @smallexample
11929 WCEM=@var{x}
11930 @end smallexample
11931
11932 @noindent
11933 as part of the FORM string (WCEM = wide character encoding method),
11934 where @var{x} is one of the following characters
11935
11936 @table @samp
11937 @item h
11938 Hex ESC encoding
11939 @item u
11940 Upper half encoding
11941 @item s
11942 Shift-JIS encoding
11943 @item e
11944 EUC Encoding
11945 @item 8
11946 UTF-8 encoding
11947 @item b
11948 Brackets encoding
11949 @end table
11950
11951 @noindent
11952 The encoding methods match those that
11953 can be used in a source
11954 program, but there is no requirement that the encoding method used for
11955 the source program be the same as the encoding method used for files,
11956 and different files may use different encoding methods.
11957
11958 The default encoding method for the standard files, and for opened files
11959 for which no WCEM parameter is given in the FORM string matches the
11960 wide character encoding specified for the main program (the default
11961 being brackets encoding if no coding method was specified with -gnatW).
11962
11963 @table @asis
11964
11965 @item UTF-8 Coding
11966 A wide character is represented using
11967 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11968 10646-1/Am.2.  Depending on the character value, the representation
11969 is a one, two, three, or four byte sequence:
11970
11971 @smallexample
11972 16#000000#-16#00007f#: 2#0xxxxxxx#
11973 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11974 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11975 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11976 @end smallexample
11977
11978 @noindent
11979 where the xxx bits correspond to the left-padded bits of the
11980 21-bit character value.  Note that all lower half ASCII characters
11981 are represented as ASCII bytes and all upper half characters and
11982 other wide characters are represented as sequences of upper-half
11983 characters.
11984
11985 @item Brackets Coding
11986 In this encoding, a wide wide character is represented by the following eight
11987 character sequence if is in wide character range
11988
11989 @smallexample
11990 [ " a b c d " ]
11991 @end smallexample
11992
11993 and by the following ten character sequence if not
11994
11995 @smallexample
11996 [ " a b c d e f " ]
11997 @end smallexample
11998
11999 @noindent
12000 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12001 are the four or six hexadecimal
12002 characters (using uppercase letters) of the wide wide character code.  For
12003 example, @code{["01A345"]} is used to represent the wide wide character
12004 with code @code{16#01A345#}.
12005
12006 This scheme is compatible with use of the full Wide_Wide_Character set.
12007 On input, brackets coding can also be used for upper half characters,
12008 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12009 is only used for wide characters with a code greater than @code{16#FF#}.
12010
12011 @end table
12012
12013 @noindent
12014 If is also possible to use the other Wide_Character encoding methods,
12015 such as Shift-JIS, but the other schemes cannot support the full range
12016 of wide wide characters.
12017 An attempt to output a character that cannot
12018 be represented using the encoding scheme for the file causes
12019 Constraint_Error to be raised.  An invalid wide character sequence on
12020 input also causes Constraint_Error to be raised.
12021
12022 @menu
12023 * Wide_Wide_Text_IO Stream Pointer Positioning::
12024 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12025 @end menu
12026
12027 @node Wide_Wide_Text_IO Stream Pointer Positioning
12028 @subsection Stream Pointer Positioning
12029
12030 @noindent
12031 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12032 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12033 case:
12034
12035 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12036 normal lower ASCII set (i.e.@: a character in the range:
12037
12038 @smallexample @c ada
12039 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12040 @end smallexample
12041
12042 @noindent
12043 then although the logical position of the file pointer is unchanged by
12044 the @code{Look_Ahead} call, the stream is physically positioned past the
12045 wide character sequence.  Again this is to avoid the need for buffering
12046 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12047 indication that this situation has occurred so that this is not visible
12048 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12049 can be observed if the wide text file shares a stream with another file.
12050
12051 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12052 @subsection Reading and Writing Non-Regular Files
12053
12054 @noindent
12055 As in the case of Text_IO, when a non-regular file is read, it is
12056 assumed that the file contains no page marks (any form characters are
12057 treated as data characters), and @code{End_Of_Page} always returns
12058 @code{False}.  Similarly, the end of file indication is not sticky, so
12059 it is possible to read beyond an end of file.
12060
12061 @node Stream_IO
12062 @section Stream_IO
12063
12064 @noindent
12065 A stream file is a sequence of bytes, where individual elements are
12066 written to the file as described in the Ada Reference Manual.  The type
12067 @code{Stream_Element} is simply a byte.  There are two ways to read or
12068 write a stream file.
12069
12070 @itemize @bullet
12071 @item
12072 The operations @code{Read} and @code{Write} directly read or write a
12073 sequence of stream elements with no control information.
12074
12075 @item
12076 The stream attributes applied to a stream file transfer data in the
12077 manner described for stream attributes.
12078 @end itemize
12079
12080 @node Shared Files
12081 @section Shared Files
12082
12083 @noindent
12084 Section A.14 of the Ada Reference Manual allows implementations to
12085 provide a wide variety of behavior if an attempt is made to access the
12086 same external file with two or more internal files.
12087
12088 To provide a full range of functionality, while at the same time
12089 minimizing the problems of portability caused by this implementation
12090 dependence, GNAT handles file sharing as follows:
12091
12092 @itemize @bullet
12093 @item
12094 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12095 to open two or more files with the same full name is considered an error
12096 and is not supported.  The exception @code{Use_Error} will be
12097 raised.  Note that a file that is not explicitly closed by the program
12098 remains open until the program terminates.
12099
12100 @item
12101 If the form parameter @samp{shared=no} appears in the form string, the
12102 file can be opened or created with its own separate stream identifier,
12103 regardless of whether other files sharing the same external file are
12104 opened.  The exact effect depends on how the C stream routines handle
12105 multiple accesses to the same external files using separate streams.
12106
12107 @item
12108 If the form parameter @samp{shared=yes} appears in the form string for
12109 each of two or more files opened using the same full name, the same
12110 stream is shared between these files, and the semantics are as described
12111 in Ada Reference Manual, Section A.14.
12112 @end itemize
12113
12114 @noindent
12115 When a program that opens multiple files with the same name is ported
12116 from another Ada compiler to GNAT, the effect will be that
12117 @code{Use_Error} is raised.
12118
12119 The documentation of the original compiler and the documentation of the
12120 program should then be examined to determine if file sharing was
12121 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12122 and @code{Create} calls as required.
12123
12124 When a program is ported from GNAT to some other Ada compiler, no
12125 special attention is required unless the @samp{shared=@var{xxx}} form
12126 parameter is used in the program.  In this case, you must examine the
12127 documentation of the new compiler to see if it supports the required
12128 file sharing semantics, and form strings modified appropriately.  Of
12129 course it may be the case that the program cannot be ported if the
12130 target compiler does not support the required functionality.  The best
12131 approach in writing portable code is to avoid file sharing (and hence
12132 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12133 completely.
12134
12135 One common use of file sharing in Ada 83 is the use of instantiations of
12136 Sequential_IO on the same file with different types, to achieve
12137 heterogeneous input-output.  Although this approach will work in GNAT if
12138 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12139 for this purpose (using the stream attributes)
12140
12141 @node Filenames encoding
12142 @section Filenames encoding
12143
12144 @noindent
12145 An encoding form parameter can be used to specify the filename
12146 encoding @samp{encoding=@var{xxx}}.
12147
12148 @itemize @bullet
12149 @item
12150 If the form parameter @samp{encoding=utf8} appears in the form string, the
12151 filename must be encoded in UTF-8.
12152
12153 @item
12154 If the form parameter @samp{encoding=8bits} appears in the form
12155 string, the filename must be a standard 8bits string.
12156 @end itemize
12157
12158 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12159 value UTF-8 is used. This encoding form parameter is only supported on
12160 the Windows platform. On the other Operating Systems the runtime is
12161 supporting UTF-8 natively.
12162
12163 @node Open Modes
12164 @section Open Modes
12165
12166 @noindent
12167 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12168 using the mode shown in the following table:
12169
12170 @sp 2
12171 @center @code{Open} and @code{Create} Call Modes
12172 @smallexample
12173                                @b{OPEN }           @b{CREATE}
12174 Append_File                    "r+"             "w+"
12175 In_File                        "r"              "w+"
12176 Out_File (Direct_IO)           "r+"             "w"
12177 Out_File (all other cases)     "w"              "w"
12178 Inout_File                     "r+"             "w+"
12179 @end smallexample
12180
12181 @noindent
12182 If text file translation is required, then either @samp{b} or @samp{t}
12183 is added to the mode, depending on the setting of Text.  Text file
12184 translation refers to the mapping of CR/LF sequences in an external file
12185 to LF characters internally.  This mapping only occurs in DOS and
12186 DOS-like systems, and is not relevant to other systems.
12187
12188 A special case occurs with Stream_IO@.  As shown in the above table, the
12189 file is initially opened in @samp{r} or @samp{w} mode for the
12190 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12191 subsequently requires switching from reading to writing or vice-versa,
12192 then the file is reopened in @samp{r+} mode to permit the required operation.
12193
12194 @node Operations on C Streams
12195 @section Operations on C Streams
12196 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12197 access to the C library functions for operations on C streams:
12198
12199 @smallexample @c adanocomment
12200 package Interfaces.C_Streams is
12201   -- Note: the reason we do not use the types that are in
12202   -- Interfaces.C is that we want to avoid dragging in the
12203   -- code in this unit if possible.
12204   subtype chars is System.Address;
12205   -- Pointer to null-terminated array of characters
12206   subtype FILEs is System.Address;
12207   -- Corresponds to the C type FILE*
12208   subtype voids is System.Address;
12209   -- Corresponds to the C type void*
12210   subtype int is Integer;
12211   subtype long is Long_Integer;
12212   -- Note: the above types are subtypes deliberately, and it
12213   -- is part of this spec that the above correspondences are
12214   -- guaranteed.  This means that it is legitimate to, for
12215   -- example, use Integer instead of int.  We provide these
12216   -- synonyms for clarity, but in some cases it may be
12217   -- convenient to use the underlying types (for example to
12218   -- avoid an unnecessary dependency of a spec on the spec
12219   -- of this unit).
12220   type size_t is mod 2 ** Standard'Address_Size;
12221   NULL_Stream : constant FILEs;
12222   -- Value returned (NULL in C) to indicate an
12223   -- fdopen/fopen/tmpfile error
12224   ----------------------------------
12225   -- Constants Defined in stdio.h --
12226   ----------------------------------
12227   EOF : constant int;
12228   -- Used by a number of routines to indicate error or
12229   -- end of file
12230   IOFBF : constant int;
12231   IOLBF : constant int;
12232   IONBF : constant int;
12233   -- Used to indicate buffering mode for setvbuf call
12234   SEEK_CUR : constant int;
12235   SEEK_END : constant int;
12236   SEEK_SET : constant int;
12237   -- Used to indicate origin for fseek call
12238   function stdin return FILEs;
12239   function stdout return FILEs;
12240   function stderr return FILEs;
12241   -- Streams associated with standard files
12242   --------------------------
12243   -- Standard C functions --
12244   --------------------------
12245   -- The functions selected below are ones that are
12246   -- available in DOS, OS/2, UNIX and Xenix (but not
12247   -- necessarily in ANSI C).  These are very thin interfaces
12248   -- which copy exactly the C headers.  For more
12249   -- documentation on these functions, see the Microsoft C
12250   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12251   -- ISBN 1-55615-225-6), which includes useful information
12252   -- on system compatibility.
12253   procedure clearerr (stream : FILEs);
12254   function fclose (stream : FILEs) return int;
12255   function fdopen (handle : int; mode : chars) return FILEs;
12256   function feof (stream : FILEs) return int;
12257   function ferror (stream : FILEs) return int;
12258   function fflush (stream : FILEs) return int;
12259   function fgetc (stream : FILEs) return int;
12260   function fgets (strng : chars; n : int; stream : FILEs)
12261       return chars;
12262   function fileno (stream : FILEs) return int;
12263   function fopen (filename : chars; Mode : chars)
12264       return FILEs;
12265   -- Note: to maintain target independence, use
12266   -- text_translation_required, a boolean variable defined in
12267   -- a-sysdep.c to deal with the target dependent text
12268   -- translation requirement.  If this variable is set,
12269   -- then  b/t should be appended to the standard mode
12270   -- argument to set the text translation mode off or on
12271   -- as required.
12272   function fputc (C : int; stream : FILEs) return int;
12273   function fputs (Strng : chars; Stream : FILEs) return int;
12274   function fread
12275      (buffer : voids;
12276       size : size_t;
12277       count : size_t;
12278       stream : FILEs)
12279       return size_t;
12280   function freopen
12281      (filename : chars;
12282       mode : chars;
12283       stream : FILEs)
12284       return FILEs;
12285   function fseek
12286      (stream : FILEs;
12287       offset : long;
12288       origin : int)
12289       return int;
12290   function ftell (stream : FILEs) return long;
12291   function fwrite
12292      (buffer : voids;
12293       size : size_t;
12294       count : size_t;
12295       stream : FILEs)
12296       return size_t;
12297   function isatty (handle : int) return int;
12298   procedure mktemp (template : chars);
12299   -- The return value (which is just a pointer to template)
12300   -- is discarded
12301   procedure rewind (stream : FILEs);
12302   function rmtmp return int;
12303   function setvbuf
12304      (stream : FILEs;
12305       buffer : chars;
12306       mode : int;
12307       size : size_t)
12308       return int;
12309
12310   function tmpfile return FILEs;
12311   function ungetc (c : int; stream : FILEs) return int;
12312   function unlink (filename : chars) return int;
12313   ---------------------
12314   -- Extra functions --
12315   ---------------------
12316   -- These functions supply slightly thicker bindings than
12317   -- those above.  They are derived from functions in the
12318   -- C Run-Time Library, but may do a bit more work than
12319   -- just directly calling one of the Library functions.
12320   function is_regular_file (handle : int) return int;
12321   -- Tests if given handle is for a regular file (result 1)
12322   -- or for a non-regular file (pipe or device, result 0).
12323   ---------------------------------
12324   -- Control of Text/Binary Mode --
12325   ---------------------------------
12326   -- If text_translation_required is true, then the following
12327   -- functions may be used to dynamically switch a file from
12328   -- binary to text mode or vice versa.  These functions have
12329   -- no effect if text_translation_required is false (i.e.  in
12330   -- normal UNIX mode).  Use fileno to get a stream handle.
12331   procedure set_binary_mode (handle : int);
12332   procedure set_text_mode (handle : int);
12333   ----------------------------
12334   -- Full Path Name support --
12335   ----------------------------
12336   procedure full_name (nam : chars; buffer : chars);
12337   -- Given a NUL terminated string representing a file
12338   -- name, returns in buffer a NUL terminated string
12339   -- representing the full path name for the file name.
12340   -- On systems where it is relevant the   drive is also
12341   -- part of the full path name.  It is the responsibility
12342   -- of the caller to pass an actual parameter for buffer
12343   -- that is big enough for any full path name.  Use
12344   -- max_path_len given below as the size of buffer.
12345   max_path_len : integer;
12346   -- Maximum length of an allowable full path name on the
12347   -- system, including a terminating NUL character.
12348 end Interfaces.C_Streams;
12349 @end smallexample
12350
12351 @node Interfacing to C Streams
12352 @section Interfacing to C Streams
12353
12354 @noindent
12355 The packages in this section permit interfacing Ada files to C Stream
12356 operations.
12357
12358 @smallexample @c ada
12359  with Interfaces.C_Streams;
12360  package Ada.Sequential_IO.C_Streams is
12361     function C_Stream (F : File_Type)
12362        return Interfaces.C_Streams.FILEs;
12363     procedure Open
12364       (File : in out File_Type;
12365        Mode : in File_Mode;
12366        C_Stream : in Interfaces.C_Streams.FILEs;
12367        Form : in String := "");
12368  end Ada.Sequential_IO.C_Streams;
12369
12370   with Interfaces.C_Streams;
12371   package Ada.Direct_IO.C_Streams is
12372      function C_Stream (F : File_Type)
12373         return Interfaces.C_Streams.FILEs;
12374      procedure Open
12375        (File : in out File_Type;
12376         Mode : in File_Mode;
12377         C_Stream : in Interfaces.C_Streams.FILEs;
12378         Form : in String := "");
12379   end Ada.Direct_IO.C_Streams;
12380
12381   with Interfaces.C_Streams;
12382   package Ada.Text_IO.C_Streams is
12383      function C_Stream (F : File_Type)
12384         return Interfaces.C_Streams.FILEs;
12385      procedure Open
12386        (File : in out File_Type;
12387         Mode : in File_Mode;
12388         C_Stream : in Interfaces.C_Streams.FILEs;
12389         Form : in String := "");
12390   end Ada.Text_IO.C_Streams;
12391
12392   with Interfaces.C_Streams;
12393   package Ada.Wide_Text_IO.C_Streams is
12394      function C_Stream (F : File_Type)
12395         return Interfaces.C_Streams.FILEs;
12396      procedure Open
12397        (File : in out File_Type;
12398         Mode : in File_Mode;
12399         C_Stream : in Interfaces.C_Streams.FILEs;
12400         Form : in String := "");
12401  end Ada.Wide_Text_IO.C_Streams;
12402
12403   with Interfaces.C_Streams;
12404   package Ada.Wide_Wide_Text_IO.C_Streams is
12405      function C_Stream (F : File_Type)
12406         return Interfaces.C_Streams.FILEs;
12407      procedure Open
12408        (File : in out File_Type;
12409         Mode : in File_Mode;
12410         C_Stream : in Interfaces.C_Streams.FILEs;
12411         Form : in String := "");
12412  end Ada.Wide_Wide_Text_IO.C_Streams;
12413
12414  with Interfaces.C_Streams;
12415  package Ada.Stream_IO.C_Streams is
12416     function C_Stream (F : File_Type)
12417        return Interfaces.C_Streams.FILEs;
12418     procedure Open
12419       (File : in out File_Type;
12420        Mode : in File_Mode;
12421        C_Stream : in Interfaces.C_Streams.FILEs;
12422        Form : in String := "");
12423  end Ada.Stream_IO.C_Streams;
12424 @end smallexample
12425
12426 @noindent
12427 In each of these six packages, the @code{C_Stream} function obtains the
12428 @code{FILE} pointer from a currently opened Ada file.  It is then
12429 possible to use the @code{Interfaces.C_Streams} package to operate on
12430 this stream, or the stream can be passed to a C program which can
12431 operate on it directly.  Of course the program is responsible for
12432 ensuring that only appropriate sequences of operations are executed.
12433
12434 One particular use of relevance to an Ada program is that the
12435 @code{setvbuf} function can be used to control the buffering of the
12436 stream used by an Ada file.  In the absence of such a call the standard
12437 default buffering is used.
12438
12439 The @code{Open} procedures in these packages open a file giving an
12440 existing C Stream instead of a file name.  Typically this stream is
12441 imported from a C program, allowing an Ada file to operate on an
12442 existing C file.
12443
12444 @node The GNAT Library
12445 @chapter The GNAT Library
12446
12447 @noindent
12448 The GNAT library contains a number of general and special purpose packages.
12449 It represents functionality that the GNAT developers have found useful, and
12450 which is made available to GNAT users.  The packages described here are fully
12451 supported, and upwards compatibility will be maintained in future releases,
12452 so you can use these facilities with the confidence that the same functionality
12453 will be available in future releases.
12454
12455 The chapter here simply gives a brief summary of the facilities available.
12456 The full documentation is found in the spec file for the package.  The full
12457 sources of these library packages, including both spec and body, are provided
12458 with all GNAT releases.  For example, to find out the full specifications of
12459 the SPITBOL pattern matching capability, including a full tutorial and
12460 extensive examples, look in the @file{g-spipat.ads} file in the library.
12461
12462 For each entry here, the package name (as it would appear in a @code{with}
12463 clause) is given, followed by the name of the corresponding spec file in
12464 parentheses.  The packages are children in four hierarchies, @code{Ada},
12465 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12466 GNAT-specific hierarchy.
12467
12468 Note that an application program should only use packages in one of these
12469 four hierarchies if the package is defined in the Ada Reference Manual,
12470 or is listed in this section of the GNAT Programmers Reference Manual.
12471 All other units should be considered internal implementation units and
12472 should not be directly @code{with}'ed by application code.  The use of
12473 a @code{with} statement that references one of these internal implementation
12474 units makes an application potentially dependent on changes in versions
12475 of GNAT, and will generate a warning message.
12476
12477 @menu
12478 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12479 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12480 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12481 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12482 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12483 * Ada.Command_Line.Remove (a-colire.ads)::
12484 * Ada.Command_Line.Environment (a-colien.ads)::
12485 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12486 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12487 * Ada.Exceptions.Traceback (a-exctra.ads)::
12488 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12489 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12490 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12491 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12492 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12493 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12494 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12495 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12496 * GNAT.Altivec (g-altive.ads)::
12497 * GNAT.Altivec.Conversions (g-altcon.ads)::
12498 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12499 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12500 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12501 * GNAT.Array_Split (g-arrspl.ads)::
12502 * GNAT.AWK (g-awk.ads)::
12503 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12504 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12505 * GNAT.Bubble_Sort (g-bubsor.ads)::
12506 * GNAT.Bubble_Sort_A (g-busora.ads)::
12507 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12508 * GNAT.Byte_Swapping (g-bytswa.ads)::
12509 * GNAT.Calendar (g-calend.ads)::
12510 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12511 * GNAT.CRC32 (g-crc32.ads)::
12512 * GNAT.Case_Util (g-casuti.ads)::
12513 * GNAT.CGI (g-cgi.ads)::
12514 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12515 * GNAT.CGI.Debug (g-cgideb.ads)::
12516 * GNAT.Command_Line (g-comlin.ads)::
12517 * GNAT.Compiler_Version (g-comver.ads)::
12518 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12519 * GNAT.Current_Exception (g-curexc.ads)::
12520 * GNAT.Debug_Pools (g-debpoo.ads)::
12521 * GNAT.Debug_Utilities (g-debuti.ads)::
12522 * GNAT.Directory_Operations (g-dirope.ads)::
12523 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12524 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12525 * GNAT.Exception_Actions (g-excact.ads)::
12526 * GNAT.Exception_Traces (g-exctra.ads)::
12527 * GNAT.Exceptions (g-except.ads)::
12528 * GNAT.Expect (g-expect.ads)::
12529 * GNAT.Float_Control (g-flocon.ads)::
12530 * GNAT.Heap_Sort (g-heasor.ads)::
12531 * GNAT.Heap_Sort_A (g-hesora.ads)::
12532 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12533 * GNAT.HTable (g-htable.ads)::
12534 * GNAT.IO (g-io.ads)::
12535 * GNAT.IO_Aux (g-io_aux.ads)::
12536 * GNAT.Lock_Files (g-locfil.ads)::
12537 * GNAT.MD5 (g-md5.ads)::
12538 * GNAT.Memory_Dump (g-memdum.ads)::
12539 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12540 * GNAT.OS_Lib (g-os_lib.ads)::
12541 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12542 * GNAT.Regexp (g-regexp.ads)::
12543 * GNAT.Registry (g-regist.ads)::
12544 * GNAT.Regpat (g-regpat.ads)::
12545 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12546 * GNAT.Semaphores (g-semaph.ads)::
12547 * GNAT.SHA1 (g-sha1.ads)::
12548 * GNAT.Signals (g-signal.ads)::
12549 * GNAT.Sockets (g-socket.ads)::
12550 * GNAT.Source_Info (g-souinf.ads)::
12551 * GNAT.Spell_Checker (g-speche.ads)::
12552 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12553 * GNAT.Spitbol (g-spitbo.ads)::
12554 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12555 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12556 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12557 * GNAT.Strings (g-string.ads)::
12558 * GNAT.String_Split (g-strspl.ads)::
12559 * GNAT.UTF_32 (g-utf_32.ads)::
12560 * GNAT.Table (g-table.ads)::
12561 * GNAT.Task_Lock (g-tasloc.ads)::
12562 * GNAT.Threads (g-thread.ads)::
12563 * GNAT.Traceback (g-traceb.ads)::
12564 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12565 * GNAT.Wide_String_Split (g-wistsp.ads)::
12566 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12567 * Interfaces.C.Extensions (i-cexten.ads)::
12568 * Interfaces.C.Streams (i-cstrea.ads)::
12569 * Interfaces.CPP (i-cpp.ads)::
12570 * Interfaces.Os2lib (i-os2lib.ads)::
12571 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12572 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12573 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12574 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12575 * Interfaces.VxWorks (i-vxwork.ads)::
12576 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12577 * System.Address_Image (s-addima.ads)::
12578 * System.Assertions (s-assert.ads)::
12579 * System.Memory (s-memory.ads)::
12580 * System.Partition_Interface (s-parint.ads)::
12581 * System.Restrictions (s-restri.ads)::
12582 * System.Rident (s-rident.ads)::
12583 * System.Task_Info (s-tasinf.ads)::
12584 * System.Wch_Cnv (s-wchcnv.ads)::
12585 * System.Wch_Con (s-wchcon.ads)::
12586 @end menu
12587
12588 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12589 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12590 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12591 @cindex Latin_9 constants for Character
12592
12593 @noindent
12594 This child of @code{Ada.Characters}
12595 provides a set of definitions corresponding to those in the
12596 RM-defined package @code{Ada.Characters.Latin_1} but with the
12597 few modifications required for @code{Latin-9}
12598 The provision of such a package
12599 is specifically authorized by the Ada Reference Manual
12600 (RM A.3.3(27)).
12601
12602 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12603 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12604 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12605 @cindex Latin_1 constants for Wide_Character
12606
12607 @noindent
12608 This child of @code{Ada.Characters}
12609 provides a set of definitions corresponding to those in the
12610 RM-defined package @code{Ada.Characters.Latin_1} but with the
12611 types of the constants being @code{Wide_Character}
12612 instead of @code{Character}.  The provision of such a package
12613 is specifically authorized by the Ada Reference Manual
12614 (RM A.3.3(27)).
12615
12616 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12617 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12618 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12619 @cindex Latin_9 constants for Wide_Character
12620
12621 @noindent
12622 This child of @code{Ada.Characters}
12623 provides a set of definitions corresponding to those in the
12624 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12625 types of the constants being @code{Wide_Character}
12626 instead of @code{Character}.  The provision of such a package
12627 is specifically authorized by the Ada Reference Manual
12628 (RM A.3.3(27)).
12629
12630 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12631 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12632 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12633 @cindex Latin_1 constants for Wide_Wide_Character
12634
12635 @noindent
12636 This child of @code{Ada.Characters}
12637 provides a set of definitions corresponding to those in the
12638 RM-defined package @code{Ada.Characters.Latin_1} but with the
12639 types of the constants being @code{Wide_Wide_Character}
12640 instead of @code{Character}.  The provision of such a package
12641 is specifically authorized by the Ada Reference Manual
12642 (RM A.3.3(27)).
12643
12644 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12645 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12646 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12647 @cindex Latin_9 constants for Wide_Wide_Character
12648
12649 @noindent
12650 This child of @code{Ada.Characters}
12651 provides a set of definitions corresponding to those in the
12652 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12653 types of the constants being @code{Wide_Wide_Character}
12654 instead of @code{Character}.  The provision of such a package
12655 is specifically authorized by the Ada Reference Manual
12656 (RM A.3.3(27)).
12657
12658 @node Ada.Command_Line.Remove (a-colire.ads)
12659 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12660 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12661 @cindex Removing command line arguments
12662 @cindex Command line, argument removal
12663
12664 @noindent
12665 This child of @code{Ada.Command_Line}
12666 provides a mechanism for logically removing
12667 arguments from the argument list.  Once removed, an argument is not visible
12668 to further calls on the subprograms in @code{Ada.Command_Line} will not
12669 see the removed argument.
12670
12671 @node Ada.Command_Line.Environment (a-colien.ads)
12672 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12673 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12674 @cindex Environment entries
12675
12676 @noindent
12677 This child of @code{Ada.Command_Line}
12678 provides a mechanism for obtaining environment values on systems
12679 where this concept makes sense.
12680
12681 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12682 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12683 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12684 @cindex C Streams, Interfacing with Direct_IO
12685
12686 @noindent
12687 This package provides subprograms that allow interfacing between
12688 C streams and @code{Direct_IO}.  The stream identifier can be
12689 extracted from a file opened on the Ada side, and an Ada file
12690 can be constructed from a stream opened on the C side.
12691
12692 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12693 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12694 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12695 @cindex Null_Occurrence, testing for
12696
12697 @noindent
12698 This child subprogram provides a way of testing for the null
12699 exception occurrence (@code{Null_Occurrence}) without raising
12700 an exception.
12701
12702 @node Ada.Exceptions.Traceback (a-exctra.ads)
12703 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12704 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12705 @cindex Traceback for Exception Occurrence
12706
12707 @noindent
12708 This child package provides the subprogram (@code{Tracebacks}) to
12709 give a traceback array of addresses based on an exception
12710 occurrence.
12711
12712 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12713 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12714 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12715 @cindex C Streams, Interfacing with Sequential_IO
12716
12717 @noindent
12718 This package provides subprograms that allow interfacing between
12719 C streams and @code{Sequential_IO}.  The stream identifier can be
12720 extracted from a file opened on the Ada side, and an Ada file
12721 can be constructed from a stream opened on the C side.
12722
12723 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12724 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12725 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12726 @cindex C Streams, Interfacing with Stream_IO
12727
12728 @noindent
12729 This package provides subprograms that allow interfacing between
12730 C streams and @code{Stream_IO}.  The stream identifier can be
12731 extracted from a file opened on the Ada side, and an Ada file
12732 can be constructed from a stream opened on the C side.
12733
12734 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12735 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12736 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12737 @cindex @code{Unbounded_String}, IO support
12738 @cindex @code{Text_IO}, extensions for unbounded strings
12739
12740 @noindent
12741 This package provides subprograms for Text_IO for unbounded
12742 strings, avoiding the necessity for an intermediate operation
12743 with ordinary strings.
12744
12745 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12746 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12747 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12748 @cindex @code{Unbounded_Wide_String}, IO support
12749 @cindex @code{Text_IO}, extensions for unbounded wide strings
12750
12751 @noindent
12752 This package provides subprograms for Text_IO for unbounded
12753 wide strings, avoiding the necessity for an intermediate operation
12754 with ordinary wide strings.
12755
12756 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12757 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12758 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12759 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12760 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12761
12762 @noindent
12763 This package provides subprograms for Text_IO for unbounded
12764 wide wide strings, avoiding the necessity for an intermediate operation
12765 with ordinary wide wide strings.
12766
12767 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12768 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12769 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12770 @cindex C Streams, Interfacing with @code{Text_IO}
12771
12772 @noindent
12773 This package provides subprograms that allow interfacing between
12774 C streams and @code{Text_IO}.  The stream identifier can be
12775 extracted from a file opened on the Ada side, and an Ada file
12776 can be constructed from a stream opened on the C side.
12777
12778 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12779 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12780 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12781 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12782
12783 @noindent
12784 This package provides subprograms that allow interfacing between
12785 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12786 extracted from a file opened on the Ada side, and an Ada file
12787 can be constructed from a stream opened on the C side.
12788
12789 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12790 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12791 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12792 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12793
12794 @noindent
12795 This package provides subprograms that allow interfacing between
12796 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12797 extracted from a file opened on the Ada side, and an Ada file
12798 can be constructed from a stream opened on the C side.
12799
12800 @node GNAT.Altivec (g-altive.ads)
12801 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12802 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12803 @cindex AltiVec
12804
12805 @noindent
12806 This is the root package of the GNAT AltiVec binding. It provides
12807 definitions of constants and types common to all the versions of the
12808 binding.
12809
12810 @node GNAT.Altivec.Conversions (g-altcon.ads)
12811 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12812 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12813 @cindex AltiVec
12814
12815 @noindent
12816 This package provides the Vector/View conversion routines.
12817
12818 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12819 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12820 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12821 @cindex AltiVec
12822
12823 @noindent
12824 This package exposes the Ada interface to the AltiVec operations on
12825 vector objects. A soft emulation is included by default in the GNAT
12826 library. The hard binding is provided as a separate package. This unit
12827 is common to both bindings.
12828
12829 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12830 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12831 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12832 @cindex AltiVec
12833
12834 @noindent
12835 This package exposes the various vector types part of the Ada binding
12836 to AltiVec facilities.
12837
12838 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12839 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12840 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12841 @cindex AltiVec
12842
12843 @noindent
12844 This package provides public 'View' data types from/to which private
12845 vector representations can be converted via
12846 GNAT.Altivec.Conversions. This allows convenient access to individual
12847 vector elements and provides a simple way to initialize vector
12848 objects.
12849
12850 @node GNAT.Array_Split (g-arrspl.ads)
12851 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12852 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12853 @cindex Array splitter
12854
12855 @noindent
12856 Useful array-manipulation routines: given a set of separators, split
12857 an array wherever the separators appear, and provide direct access
12858 to the resulting slices.
12859
12860 @node GNAT.AWK (g-awk.ads)
12861 @section @code{GNAT.AWK} (@file{g-awk.ads})
12862 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12863 @cindex Parsing
12864 @cindex AWK
12865
12866 @noindent
12867 Provides AWK-like parsing functions, with an easy interface for parsing one
12868 or more files containing formatted data.  The file is viewed as a database
12869 where each record is a line and a field is a data element in this line.
12870
12871 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12872 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12873 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12874 @cindex Parsing
12875 @cindex Bounded Buffers
12876
12877 @noindent
12878 Provides a concurrent generic bounded buffer abstraction.  Instances are
12879 useful directly or as parts of the implementations of other abstractions,
12880 such as mailboxes.
12881
12882 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12883 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12884 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12885 @cindex Parsing
12886 @cindex Mailboxes
12887
12888 @noindent
12889 Provides a thread-safe asynchronous intertask mailbox communication facility.
12890
12891 @node GNAT.Bubble_Sort (g-bubsor.ads)
12892 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12893 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12894 @cindex Sorting
12895 @cindex Bubble sort
12896
12897 @noindent
12898 Provides a general implementation of bubble sort usable for sorting arbitrary
12899 data items.  Exchange and comparison procedures are provided by passing
12900 access-to-procedure values.
12901
12902 @node GNAT.Bubble_Sort_A (g-busora.ads)
12903 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12904 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12905 @cindex Sorting
12906 @cindex Bubble sort
12907
12908 @noindent
12909 Provides a general implementation of bubble sort usable for sorting arbitrary
12910 data items.  Move and comparison procedures are provided by passing
12911 access-to-procedure values. This is an older version, retained for
12912 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12913
12914 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12915 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12916 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12917 @cindex Sorting
12918 @cindex Bubble sort
12919
12920 @noindent
12921 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12922 are provided as generic parameters, this improves efficiency, especially
12923 if the procedures can be inlined, at the expense of duplicating code for
12924 multiple instantiations.
12925
12926 @node GNAT.Byte_Swapping (g-bytswa.ads)
12927 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
12928 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
12929 @cindex Byte swapping
12930 @cindex Endian
12931
12932 @noindent
12933 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
12934 Machine-specific implementations are available in some cases.
12935
12936 @node GNAT.Calendar (g-calend.ads)
12937 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12938 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12939 @cindex @code{Calendar}
12940
12941 @noindent
12942 Extends the facilities provided by @code{Ada.Calendar} to include handling
12943 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12944 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12945 C @code{timeval} format.
12946
12947 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12948 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12949 @cindex @code{Calendar}
12950 @cindex Time
12951 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12952
12953 @node GNAT.CRC32 (g-crc32.ads)
12954 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12955 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12956 @cindex CRC32
12957 @cindex Cyclic Redundancy Check
12958
12959 @noindent
12960 This package implements the CRC-32 algorithm.  For a full description
12961 of this algorithm see
12962 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12963 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12964 Aug.@: 1988.  Sarwate, D.V@.
12965
12966 @node GNAT.Case_Util (g-casuti.ads)
12967 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12968 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12969 @cindex Casing utilities
12970 @cindex Character handling (@code{GNAT.Case_Util})
12971
12972 @noindent
12973 A set of simple routines for handling upper and lower casing of strings
12974 without the overhead of the full casing tables
12975 in @code{Ada.Characters.Handling}.
12976
12977 @node GNAT.CGI (g-cgi.ads)
12978 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12979 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12980 @cindex CGI (Common Gateway Interface)
12981
12982 @noindent
12983 This is a package for interfacing a GNAT program with a Web server via the
12984 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12985 parameters, which are a set of key/value pairs sent by the Web server.  It
12986 builds a table whose index is the key and provides some services to deal
12987 with this table.
12988
12989 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12990 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12991 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12992 @cindex CGI (Common Gateway Interface) cookie support
12993 @cindex Cookie support in CGI
12994
12995 @noindent
12996 This is a package to interface a GNAT program with a Web server via the
12997 Common Gateway Interface (CGI).  It exports services to deal with Web
12998 cookies (piece of information kept in the Web client software).
12999
13000 @node GNAT.CGI.Debug (g-cgideb.ads)
13001 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13002 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13003 @cindex CGI (Common Gateway Interface) debugging
13004
13005 @noindent
13006 This is a package to help debugging CGI (Common Gateway Interface)
13007 programs written in Ada.
13008
13009 @node GNAT.Command_Line (g-comlin.ads)
13010 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13011 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13012 @cindex Command line
13013
13014 @noindent
13015 Provides a high level interface to @code{Ada.Command_Line} facilities,
13016 including the ability to scan for named switches with optional parameters
13017 and expand file names using wild card notations.
13018
13019 @node GNAT.Compiler_Version (g-comver.ads)
13020 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13021 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13022 @cindex Compiler Version
13023 @cindex Version, of compiler
13024
13025 @noindent
13026 Provides a routine for obtaining the version of the compiler used to
13027 compile the program. More accurately this is the version of the binder
13028 used to bind the program (this will normally be the same as the version
13029 of the compiler if a consistent tool set is used to compile all units
13030 of a partition).
13031
13032 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13033 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13034 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13035 @cindex Interrupt
13036
13037 @noindent
13038 Provides a simple interface to handle Ctrl-C keyboard events.
13039
13040 @node GNAT.Current_Exception (g-curexc.ads)
13041 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13042 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13043 @cindex Current exception
13044 @cindex Exception retrieval
13045
13046 @noindent
13047 Provides access to information on the current exception that has been raised
13048 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13049 specification syntax.
13050 This is particularly useful in simulating typical facilities for
13051 obtaining information about exceptions provided by Ada 83 compilers.
13052
13053 @node GNAT.Debug_Pools (g-debpoo.ads)
13054 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13055 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13056 @cindex Debugging
13057 @cindex Debug pools
13058 @cindex Memory corruption debugging
13059
13060 @noindent
13061 Provide a debugging storage pools that helps tracking memory corruption
13062 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
13063 the @cite{GNAT User's Guide}.
13064
13065 @node GNAT.Debug_Utilities (g-debuti.ads)
13066 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13067 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13068 @cindex Debugging
13069
13070 @noindent
13071 Provides a few useful utilities for debugging purposes, including conversion
13072 to and from string images of address values. Supports both C and Ada formats
13073 for hexadecimal literals.
13074
13075 @node GNAT.Directory_Operations (g-dirope.ads)
13076 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13077 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13078 @cindex Directory operations
13079
13080 @noindent
13081 Provides a set of routines for manipulating directories, including changing
13082 the current directory, making new directories, and scanning the files in a
13083 directory.
13084
13085 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13086 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13087 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13088 @cindex Hash tables
13089
13090 @noindent
13091 A generic implementation of hash tables that can be used to hash arbitrary
13092 data.  Provided in two forms, a simple form with built in hash functions,
13093 and a more complex form in which the hash function is supplied.
13094
13095 @noindent
13096 This package provides a facility similar to that of @code{GNAT.HTable},
13097 except that this package declares a type that can be used to define
13098 dynamic instances of the hash table, while an instantiation of
13099 @code{GNAT.HTable} creates a single instance of the hash table.
13100
13101 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13102 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13103 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13104 @cindex Table implementation
13105 @cindex Arrays, extendable
13106
13107 @noindent
13108 A generic package providing a single dimension array abstraction where the
13109 length of the array can be dynamically modified.
13110
13111 @noindent
13112 This package provides a facility similar to that of @code{GNAT.Table},
13113 except that this package declares a type that can be used to define
13114 dynamic instances of the table, while an instantiation of
13115 @code{GNAT.Table} creates a single instance of the table type.
13116
13117 @node GNAT.Exception_Actions (g-excact.ads)
13118 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13119 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13120 @cindex Exception actions
13121
13122 @noindent
13123 Provides callbacks when an exception is raised. Callbacks can be registered
13124 for specific exceptions, or when any exception is raised. This
13125 can be used for instance to force a core dump to ease debugging.
13126
13127 @node GNAT.Exception_Traces (g-exctra.ads)
13128 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13129 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13130 @cindex Exception traces
13131 @cindex Debugging
13132
13133 @noindent
13134 Provides an interface allowing to control automatic output upon exception
13135 occurrences.
13136
13137 @node GNAT.Exceptions (g-except.ads)
13138 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13139 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13140 @cindex Exceptions, Pure
13141 @cindex Pure packages, exceptions
13142
13143 @noindent
13144 Normally it is not possible to raise an exception with
13145 a message from a subprogram in a pure package, since the
13146 necessary types and subprograms are in @code{Ada.Exceptions}
13147 which is not a pure unit. @code{GNAT.Exceptions} provides a
13148 facility for getting around this limitation for a few
13149 predefined exceptions, and for example allow raising
13150 @code{Constraint_Error} with a message from a pure subprogram.
13151
13152 @node GNAT.Expect (g-expect.ads)
13153 @section @code{GNAT.Expect} (@file{g-expect.ads})
13154 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13155
13156 @noindent
13157 Provides a set of subprograms similar to what is available
13158 with the standard Tcl Expect tool.
13159 It allows you to easily spawn and communicate with an external process.
13160 You can send commands or inputs to the process, and compare the output
13161 with some expected regular expression. Currently @code{GNAT.Expect}
13162 is implemented on all native GNAT ports except for OpenVMS@.
13163 It is not implemented for cross ports, and in particular is not
13164 implemented for VxWorks or LynxOS@.
13165
13166 @node GNAT.Float_Control (g-flocon.ads)
13167 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13168 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13169 @cindex Floating-Point Processor
13170
13171 @noindent
13172 Provides an interface for resetting the floating-point processor into the
13173 mode required for correct semantic operation in Ada.  Some third party
13174 library calls may cause this mode to be modified, and the Reset procedure
13175 in this package can be used to reestablish the required mode.
13176
13177 @node GNAT.Heap_Sort (g-heasor.ads)
13178 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13179 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13180 @cindex Sorting
13181
13182 @noindent
13183 Provides a general implementation of heap sort usable for sorting arbitrary
13184 data items. Exchange and comparison procedures are provided by passing
13185 access-to-procedure values.  The algorithm used is a modified heap sort
13186 that performs approximately N*log(N) comparisons in the worst case.
13187
13188 @node GNAT.Heap_Sort_A (g-hesora.ads)
13189 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13190 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13191 @cindex Sorting
13192
13193 @noindent
13194 Provides a general implementation of heap sort usable for sorting arbitrary
13195 data items. Move and comparison procedures are provided by passing
13196 access-to-procedure values.  The algorithm used is a modified heap sort
13197 that performs approximately N*log(N) comparisons in the worst case.
13198 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13199 interface, but may be slightly more efficient.
13200
13201 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13202 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13203 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13204 @cindex Sorting
13205
13206 @noindent
13207 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13208 are provided as generic parameters, this improves efficiency, especially
13209 if the procedures can be inlined, at the expense of duplicating code for
13210 multiple instantiations.
13211
13212 @node GNAT.HTable (g-htable.ads)
13213 @section @code{GNAT.HTable} (@file{g-htable.ads})
13214 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13215 @cindex Hash tables
13216
13217 @noindent
13218 A generic implementation of hash tables that can be used to hash arbitrary
13219 data.  Provides two approaches, one a simple static approach, and the other
13220 allowing arbitrary dynamic hash tables.
13221
13222 @node GNAT.IO (g-io.ads)
13223 @section @code{GNAT.IO} (@file{g-io.ads})
13224 @cindex @code{GNAT.IO} (@file{g-io.ads})
13225 @cindex Simple I/O
13226 @cindex Input/Output facilities
13227
13228 @noindent
13229 A simple preelaborable input-output package that provides a subset of
13230 simple Text_IO functions for reading characters and strings from
13231 Standard_Input, and writing characters, strings and integers to either
13232 Standard_Output or Standard_Error.
13233
13234 @node GNAT.IO_Aux (g-io_aux.ads)
13235 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13236 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13237 @cindex Text_IO
13238 @cindex Input/Output facilities
13239
13240 Provides some auxiliary functions for use with Text_IO, including a test
13241 for whether a file exists, and functions for reading a line of text.
13242
13243 @node GNAT.Lock_Files (g-locfil.ads)
13244 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13245 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13246 @cindex File locking
13247 @cindex Locking using files
13248
13249 @noindent
13250 Provides a general interface for using files as locks.  Can be used for
13251 providing program level synchronization.
13252
13253 @node GNAT.MD5 (g-md5.ads)
13254 @section @code{GNAT.MD5} (@file{g-md5.ads})
13255 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13256 @cindex Message Digest MD5
13257
13258 @noindent
13259 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13260
13261 @node GNAT.Memory_Dump (g-memdum.ads)
13262 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13263 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13264 @cindex Dump Memory
13265
13266 @noindent
13267 Provides a convenient routine for dumping raw memory to either the
13268 standard output or standard error files. Uses GNAT.IO for actual
13269 output.
13270
13271 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13272 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13273 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13274 @cindex Exception, obtaining most recent
13275
13276 @noindent
13277 Provides access to the most recently raised exception.  Can be used for
13278 various logging purposes, including duplicating functionality of some
13279 Ada 83 implementation dependent extensions.
13280
13281 @node GNAT.OS_Lib (g-os_lib.ads)
13282 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13283 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13284 @cindex Operating System interface
13285 @cindex Spawn capability
13286
13287 @noindent
13288 Provides a range of target independent operating system interface functions,
13289 including time/date management, file operations, subprocess management,
13290 including a portable spawn procedure, and access to environment variables
13291 and error return codes.
13292
13293 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13294 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13295 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13296 @cindex Hash functions
13297
13298 @noindent
13299 Provides a generator of static minimal perfect hash functions. No
13300 collisions occur and each item can be retrieved from the table in one
13301 probe (perfect property). The hash table size corresponds to the exact
13302 size of the key set and no larger (minimal property). The key set has to
13303 be know in advance (static property). The hash functions are also order
13304 preserving. If w2 is inserted after w1 in the generator, their
13305 hashcode are in the same order. These hashing functions are very
13306 convenient for use with realtime applications.
13307
13308 @node GNAT.Regexp (g-regexp.ads)
13309 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13310 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13311 @cindex Regular expressions
13312 @cindex Pattern matching
13313
13314 @noindent
13315 A simple implementation of regular expressions, using a subset of regular
13316 expression syntax copied from familiar Unix style utilities.  This is the
13317 simples of the three pattern matching packages provided, and is particularly
13318 suitable for ``file globbing'' applications.
13319
13320 @node GNAT.Registry (g-regist.ads)
13321 @section @code{GNAT.Registry} (@file{g-regist.ads})
13322 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13323 @cindex Windows Registry
13324
13325 @noindent
13326 This is a high level binding to the Windows registry.  It is possible to
13327 do simple things like reading a key value, creating a new key.  For full
13328 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13329 package provided with the Win32Ada binding
13330
13331 @node GNAT.Regpat (g-regpat.ads)
13332 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13333 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13334 @cindex Regular expressions
13335 @cindex Pattern matching
13336
13337 @noindent
13338 A complete implementation of Unix-style regular expression matching, copied
13339 from the original V7 style regular expression library written in C by
13340 Henry Spencer (and binary compatible with this C library).
13341
13342 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13343 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13344 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13345 @cindex Secondary Stack Info
13346
13347 @noindent
13348 Provide the capability to query the high water mark of the current task's
13349 secondary stack.
13350
13351 @node GNAT.Semaphores (g-semaph.ads)
13352 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13353 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13354 @cindex Semaphores
13355
13356 @noindent
13357 Provides classic counting and binary semaphores using protected types.
13358
13359 @node GNAT.SHA1 (g-sha1.ads)
13360 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13361 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13362 @cindex Secure Hash Algorithm SHA-1
13363
13364 @noindent
13365 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13366
13367 @node GNAT.Signals (g-signal.ads)
13368 @section @code{GNAT.Signals} (@file{g-signal.ads})
13369 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13370 @cindex Signals
13371
13372 @noindent
13373 Provides the ability to manipulate the blocked status of signals on supported
13374 targets.
13375
13376 @node GNAT.Sockets (g-socket.ads)
13377 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13378 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13379 @cindex Sockets
13380
13381 @noindent
13382 A high level and portable interface to develop sockets based applications.
13383 This package is based on the sockets thin binding found in
13384 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13385 on all native GNAT ports except for OpenVMS@.  It is not implemented
13386 for the LynxOS@ cross port.
13387
13388 @node GNAT.Source_Info (g-souinf.ads)
13389 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13390 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13391 @cindex Source Information
13392
13393 @noindent
13394 Provides subprograms that give access to source code information known at
13395 compile time, such as the current file name and line number.
13396
13397 @node GNAT.Spell_Checker (g-speche.ads)
13398 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13399 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13400 @cindex Spell checking
13401
13402 @noindent
13403 Provides a function for determining whether one string is a plausible
13404 near misspelling of another string.
13405
13406 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13407 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13408 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13409 @cindex SPITBOL pattern matching
13410 @cindex Pattern matching
13411
13412 @noindent
13413 A complete implementation of SNOBOL4 style pattern matching.  This is the
13414 most elaborate of the pattern matching packages provided.  It fully duplicates
13415 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13416 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13417
13418 @node GNAT.Spitbol (g-spitbo.ads)
13419 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13420 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13421 @cindex SPITBOL interface
13422
13423 @noindent
13424 The top level package of the collection of SPITBOL-style functionality, this
13425 package provides basic SNOBOL4 string manipulation functions, such as
13426 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13427 useful for constructing arbitrary mappings from strings in the style of
13428 the SNOBOL4 TABLE function.
13429
13430 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13431 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13432 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13433 @cindex Sets of strings
13434 @cindex SPITBOL Tables
13435
13436 @noindent
13437 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13438 for type @code{Standard.Boolean}, giving an implementation of sets of
13439 string values.
13440
13441 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13442 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13443 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13444 @cindex Integer maps
13445 @cindex Maps
13446 @cindex SPITBOL Tables
13447
13448 @noindent
13449 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13450 for type @code{Standard.Integer}, giving an implementation of maps
13451 from string to integer values.
13452
13453 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13454 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13455 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13456 @cindex String maps
13457 @cindex Maps
13458 @cindex SPITBOL Tables
13459
13460 @noindent
13461 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13462 a variable length string type, giving an implementation of general
13463 maps from strings to strings.
13464
13465 @node GNAT.Strings (g-string.ads)
13466 @section @code{GNAT.Strings} (@file{g-string.ads})
13467 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13468
13469 @noindent
13470 Common String access types and related subprograms. Basically it
13471 defines a string access and an array of string access types.
13472
13473 @node GNAT.String_Split (g-strspl.ads)
13474 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13475 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13476 @cindex String splitter
13477
13478 @noindent
13479 Useful string manipulation routines: given a set of separators, split
13480 a string wherever the separators appear, and provide direct access
13481 to the resulting slices. This package is instantiated from
13482 @code{GNAT.Array_Split}.
13483
13484 @node GNAT.UTF_32 (g-utf_32.ads)
13485 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13486 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13487 @cindex Wide character codes
13488
13489 @noindent
13490 This is a package intended to be used in conjunction with the
13491 @code{Wide_Character} type in Ada 95 and the
13492 @code{Wide_Wide_Character} type in Ada 2005 (available
13493 in @code{GNAT} in Ada 2005 mode). This package contains
13494 Unicode categorization routines, as well as lexical
13495 categorization routines corresponding to the Ada 2005
13496 lexical rules for identifiers and strings, and also a
13497 lower case to upper case fold routine corresponding to
13498 the Ada 2005 rules for identifier equivalence.
13499
13500 @node GNAT.Table (g-table.ads)
13501 @section @code{GNAT.Table} (@file{g-table.ads})
13502 @cindex @code{GNAT.Table} (@file{g-table.ads})
13503 @cindex Table implementation
13504 @cindex Arrays, extendable
13505
13506 @noindent
13507 A generic package providing a single dimension array abstraction where the
13508 length of the array can be dynamically modified.
13509
13510 @noindent
13511 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13512 except that this package declares a single instance of the table type,
13513 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13514 used to define dynamic instances of the table.
13515
13516 @node GNAT.Task_Lock (g-tasloc.ads)
13517 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13518 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13519 @cindex Task synchronization
13520 @cindex Task locking
13521 @cindex Locking
13522
13523 @noindent
13524 A very simple facility for locking and unlocking sections of code using a
13525 single global task lock.  Appropriate for use in situations where contention
13526 between tasks is very rarely expected.
13527
13528 @node GNAT.Threads (g-thread.ads)
13529 @section @code{GNAT.Threads} (@file{g-thread.ads})
13530 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13531 @cindex Foreign threads
13532 @cindex Threads, foreign
13533
13534 @noindent
13535 Provides facilities for creating and destroying threads with explicit calls.
13536 These threads are known to the GNAT run-time system.  These subprograms are
13537 exported C-convention procedures intended to be called from foreign code.
13538 By using these primitives rather than directly calling operating systems
13539 routines, compatibility with the Ada tasking run-time is provided.
13540
13541 @node GNAT.Traceback (g-traceb.ads)
13542 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13543 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13544 @cindex Trace back facilities
13545
13546 @noindent
13547 Provides a facility for obtaining non-symbolic traceback information, useful
13548 in various debugging situations.
13549
13550 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13551 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13552 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13553 @cindex Trace back facilities
13554
13555 @noindent
13556 Provides symbolic traceback information that includes the subprogram
13557 name and line number information. Note that this capability is not available
13558 on all targets, see g-trasym.ads for list of supported targets.
13559
13560 @node GNAT.Wide_String_Split (g-wistsp.ads)
13561 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13562 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13563 @cindex Wide_String splitter
13564
13565 @noindent
13566 Useful wide string manipulation routines: given a set of separators, split
13567 a wide string wherever the separators appear, and provide direct access
13568 to the resulting slices. This package is instantiated from
13569 @code{GNAT.Array_Split}.
13570
13571 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13572 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13573 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13574 @cindex Wide_Wide_String splitter
13575
13576 @noindent
13577 Useful wide wide string manipulation routines: given a set of separators, split
13578 a wide wide string wherever the separators appear, and provide direct access
13579 to the resulting slices. This package is instantiated from
13580 @code{GNAT.Array_Split}.
13581
13582 @node Interfaces.C.Extensions (i-cexten.ads)
13583 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13584 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13585
13586 @noindent
13587 This package contains additional C-related definitions, intended
13588 for use with either manually or automatically generated bindings
13589 to C libraries.
13590
13591 @node Interfaces.C.Streams (i-cstrea.ads)
13592 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13593 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13594 @cindex  C streams, interfacing
13595
13596 @noindent
13597 This package is a binding for the most commonly used operations
13598 on C streams.
13599
13600 @node Interfaces.CPP (i-cpp.ads)
13601 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13602 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13603 @cindex  C++ interfacing
13604 @cindex  Interfacing, to C++
13605
13606 @noindent
13607 This package provides facilities for use in interfacing to C++.  It
13608 is primarily intended to be used in connection with automated tools
13609 for the generation of C++ interfaces.
13610
13611 @node Interfaces.Os2lib (i-os2lib.ads)
13612 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13613 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13614 @cindex Interfacing, to OS/2
13615 @cindex OS/2 interfacing
13616
13617 @noindent
13618 This package provides interface definitions to the OS/2 library.
13619 It is a thin binding which is a direct translation of the
13620 various @file{<bse@.h>} files.
13621
13622 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13623 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13624 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13625 @cindex OS/2 Error codes
13626 @cindex Interfacing, to OS/2
13627 @cindex OS/2 interfacing
13628
13629 @noindent
13630 This package provides definitions of the OS/2 error codes.
13631
13632 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13633 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13634 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13635 @cindex Interfacing, to OS/2
13636 @cindex Synchronization, OS/2
13637 @cindex OS/2 synchronization primitives
13638
13639 @noindent
13640 This is a child package that provides definitions for interfacing
13641 to the @code{OS/2} synchronization primitives.
13642
13643 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13644 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13645 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13646 @cindex Interfacing, to OS/2
13647 @cindex Thread control, OS/2
13648 @cindex OS/2 thread interfacing
13649
13650 @noindent
13651 This is a child package that provides definitions for interfacing
13652 to the @code{OS/2} thread primitives.
13653
13654 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13655 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13656 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13657 @cindex  IBM Packed Format
13658 @cindex  Packed Decimal
13659
13660 @noindent
13661 This package provides a set of routines for conversions to and
13662 from a packed decimal format compatible with that used on IBM
13663 mainframes.
13664
13665 @node Interfaces.VxWorks (i-vxwork.ads)
13666 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13667 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13668 @cindex Interfacing to VxWorks
13669 @cindex VxWorks, interfacing
13670
13671 @noindent
13672 This package provides a limited binding to the VxWorks API.
13673 In particular, it interfaces with the
13674 VxWorks hardware interrupt facilities.
13675
13676 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13677 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13678 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13679 @cindex Interfacing to VxWorks' I/O
13680 @cindex VxWorks, I/O interfacing
13681 @cindex VxWorks, Get_Immediate
13682 @cindex Get_Immediate, VxWorks
13683
13684 @noindent
13685 This package provides a binding to the ioctl (IO/Control)
13686 function of VxWorks, defining a set of option values and
13687 function codes. A particular use of this package is
13688 to enable the use of Get_Immediate under VxWorks.
13689
13690 @node System.Address_Image (s-addima.ads)
13691 @section @code{System.Address_Image} (@file{s-addima.ads})
13692 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13693 @cindex Address image
13694 @cindex Image, of an address
13695
13696 @noindent
13697 This function provides a useful debugging
13698 function that gives an (implementation dependent)
13699 string which identifies an address.
13700
13701 @node System.Assertions (s-assert.ads)
13702 @section @code{System.Assertions} (@file{s-assert.ads})
13703 @cindex @code{System.Assertions} (@file{s-assert.ads})
13704 @cindex Assertions
13705 @cindex Assert_Failure, exception
13706
13707 @noindent
13708 This package provides the declaration of the exception raised
13709 by an run-time assertion failure, as well as the routine that
13710 is used internally to raise this assertion.
13711
13712 @node System.Memory (s-memory.ads)
13713 @section @code{System.Memory} (@file{s-memory.ads})
13714 @cindex @code{System.Memory} (@file{s-memory.ads})
13715 @cindex Memory allocation
13716
13717 @noindent
13718 This package provides the interface to the low level routines used
13719 by the generated code for allocation and freeing storage for the
13720 default storage pool (analogous to the C routines malloc and free.
13721 It also provides a reallocation interface analogous to the C routine
13722 realloc. The body of this unit may be modified to provide alternative
13723 allocation mechanisms for the default pool, and in addition, direct
13724 calls to this unit may be made for low level allocation uses (for
13725 example see the body of @code{GNAT.Tables}).
13726
13727 @node System.Partition_Interface (s-parint.ads)
13728 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13729 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13730 @cindex Partition interfacing functions
13731
13732 @noindent
13733 This package provides facilities for partition interfacing.  It
13734 is used primarily in a distribution context when using Annex E
13735 with @code{GLADE}.
13736
13737 @node System.Restrictions (s-restri.ads)
13738 @section @code{System.Restrictions} (@file{s-restri.ads})
13739 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13740 @cindex Run-time restrictions access
13741
13742 @noindent
13743 This package provides facilities for accessing at run-time
13744 the status of restrictions specified at compile time for
13745 the partition. Information is available both with regard
13746 to actual restrictions specified, and with regard to
13747 compiler determined information on which restrictions
13748 are violated by one or more packages in the partition.
13749
13750 @node System.Rident (s-rident.ads)
13751 @section @code{System.Rident} (@file{s-rident.ads})
13752 @cindex @code{System.Rident} (@file{s-rident.ads})
13753 @cindex Restrictions definitions
13754
13755 @noindent
13756 This package provides definitions of the restrictions
13757 identifiers supported by GNAT, and also the format of
13758 the restrictions provided in package System.Restrictions.
13759 It is not normally necessary to @code{with} this generic package
13760 since the necessary instantiation is included in
13761 package System.Restrictions.
13762
13763 @node System.Task_Info (s-tasinf.ads)
13764 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13765 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13766 @cindex Task_Info pragma
13767
13768 @noindent
13769 This package provides target dependent functionality that is used
13770 to support the @code{Task_Info} pragma
13771
13772 @node System.Wch_Cnv (s-wchcnv.ads)
13773 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13774 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13775 @cindex Wide Character, Representation
13776 @cindex Wide String, Conversion
13777 @cindex Representation of wide characters
13778
13779 @noindent
13780 This package provides routines for converting between
13781 wide and wide wide characters and a representation as a value of type
13782 @code{Standard.String}, using a specified wide character
13783 encoding method.  It uses definitions in
13784 package @code{System.Wch_Con}.
13785
13786 @node System.Wch_Con (s-wchcon.ads)
13787 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13788 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13789
13790 @noindent
13791 This package provides definitions and descriptions of
13792 the various methods used for encoding wide characters
13793 in ordinary strings.  These definitions are used by
13794 the package @code{System.Wch_Cnv}.
13795
13796 @node Interfacing to Other Languages
13797 @chapter Interfacing to Other Languages
13798 @noindent
13799 The facilities in annex B of the Ada Reference Manual are fully
13800 implemented in GNAT, and in addition, a full interface to C++ is
13801 provided.
13802
13803 @menu
13804 * Interfacing to C::
13805 * Interfacing to C++::
13806 * Interfacing to COBOL::
13807 * Interfacing to Fortran::
13808 * Interfacing to non-GNAT Ada code::
13809 @end menu
13810
13811 @node Interfacing to C
13812 @section Interfacing to C
13813
13814 @noindent
13815 Interfacing to C with GNAT can use one of two approaches:
13816
13817 @itemize @bullet
13818 @item
13819 The types in the package @code{Interfaces.C} may be used.
13820 @item
13821 Standard Ada types may be used directly.  This may be less portable to
13822 other compilers, but will work on all GNAT compilers, which guarantee
13823 correspondence between the C and Ada types.
13824 @end itemize
13825
13826 @noindent
13827 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13828 effect, since this is the default.  The following table shows the
13829 correspondence between Ada scalar types and the corresponding C types.
13830
13831 @table @code
13832 @item Integer
13833 @code{int}
13834 @item Short_Integer
13835 @code{short}
13836 @item Short_Short_Integer
13837 @code{signed char}
13838 @item Long_Integer
13839 @code{long}
13840 @item Long_Long_Integer
13841 @code{long long}
13842 @item Short_Float
13843 @code{float}
13844 @item Float
13845 @code{float}
13846 @item Long_Float
13847 @code{double}
13848 @item Long_Long_Float
13849 This is the longest floating-point type supported by the hardware.
13850 @end table
13851
13852 @noindent
13853 Additionally, there are the following general correspondences between Ada
13854 and C types:
13855 @itemize @bullet
13856 @item
13857 Ada enumeration types map to C enumeration types directly if pragma
13858 @code{Convention C} is specified, which causes them to have int
13859 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13860 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13861 @code{int}, respectively) depending on the number of values passed.
13862 This is the only case in which pragma @code{Convention C} affects the
13863 representation of an Ada type.
13864
13865 @item
13866 Ada access types map to C pointers, except for the case of pointers to
13867 unconstrained types in Ada, which have no direct C equivalent.
13868
13869 @item
13870 Ada arrays map directly to C arrays.
13871
13872 @item
13873 Ada records map directly to C structures.
13874
13875 @item
13876 Packed Ada records map to C structures where all members are bit fields
13877 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13878 @end itemize
13879
13880 @node Interfacing to C++
13881 @section Interfacing to C++
13882
13883 @noindent
13884 The interface to C++ makes use of the following pragmas, which are
13885 primarily intended to be constructed automatically using a binding generator
13886 tool, although it is possible to construct them by hand.  No suitable binding
13887 generator tool is supplied with GNAT though.
13888
13889 Using these pragmas it is possible to achieve complete
13890 inter-operability between Ada tagged types and C++ class definitions.
13891 See @ref{Implementation Defined Pragmas}, for more details.
13892
13893 @table @code
13894 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13895 The argument denotes an entity in the current declarative region that is
13896 declared as a tagged or untagged record type. It indicates that the type
13897 corresponds to an externally declared C++ class type, and is to be laid
13898 out the same way that C++ would lay out the type.
13899
13900 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
13901 for backward compatibility but its functionality is available
13902 using pragma @code{Import} with @code{Convention} = @code{CPP}.
13903
13904 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13905 This pragma identifies an imported function (imported in the usual way
13906 with pragma @code{Import}) as corresponding to a C++ constructor.
13907 @end table
13908
13909 @node Interfacing to COBOL
13910 @section Interfacing to COBOL
13911
13912 @noindent
13913 Interfacing to COBOL is achieved as described in section B.4 of
13914 the Ada Reference Manual.
13915
13916 @node Interfacing to Fortran
13917 @section Interfacing to Fortran
13918
13919 @noindent
13920 Interfacing to Fortran is achieved as described in section B.5 of the
13921 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
13922 multi-dimensional array causes the array to be stored in column-major
13923 order as required for convenient interface to Fortran.
13924
13925 @node Interfacing to non-GNAT Ada code
13926 @section Interfacing to non-GNAT Ada code
13927
13928 It is possible to specify the convention @code{Ada} in a pragma
13929 @code{Import} or pragma @code{Export}.  However this refers to
13930 the calling conventions used by GNAT, which may or may not be
13931 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
13932 compiler to allow interoperation.
13933
13934 If arguments types are kept simple, and if the foreign compiler generally
13935 follows system calling conventions, then it may be possible to integrate
13936 files compiled by other Ada compilers, provided that the elaboration
13937 issues are adequately addressed (for example by eliminating the
13938 need for any load time elaboration).
13939
13940 In particular, GNAT running on VMS is designed to
13941 be highly compatible with the DEC Ada 83 compiler, so this is one
13942 case in which it is possible to import foreign units of this type,
13943 provided that the data items passed are restricted to simple scalar
13944 values or simple record types without variants, or simple array
13945 types with fixed bounds.
13946
13947 @node Specialized Needs Annexes
13948 @chapter Specialized Needs Annexes
13949
13950 @noindent
13951 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
13952 required in all implementations.  However, as described in this chapter,
13953 GNAT implements all of these annexes:
13954
13955 @table @asis
13956 @item Systems Programming (Annex C)
13957 The Systems Programming Annex is fully implemented.
13958
13959 @item Real-Time Systems (Annex D)
13960 The Real-Time Systems Annex is fully implemented.
13961
13962 @item Distributed Systems (Annex E)
13963 Stub generation is fully implemented in the GNAT compiler.  In addition,
13964 a complete compatible PCS is available as part of the GLADE system,
13965 a separate product.  When the two
13966 products are used in conjunction, this annex is fully implemented.
13967
13968 @item Information Systems (Annex F)
13969 The Information Systems annex is fully implemented.
13970
13971 @item Numerics (Annex G)
13972 The Numerics Annex is fully implemented.
13973
13974 @item Safety and Security / High-Integrity Systems (Annex H)
13975 The Safety and Security Annex (termed the High-Integrity Systems Annex
13976 in Ada 2005) is fully implemented.
13977 @end table
13978
13979 @node Implementation of Specific Ada Features
13980 @chapter Implementation of Specific Ada Features
13981
13982 @noindent
13983 This chapter describes the GNAT implementation of several Ada language
13984 facilities.
13985
13986 @menu
13987 * Machine Code Insertions::
13988 * GNAT Implementation of Tasking::
13989 * GNAT Implementation of Shared Passive Packages::
13990 * Code Generation for Array Aggregates::
13991 * The Size of Discriminated Records with Default Discriminants::
13992 * Strict Conformance to the Ada Reference Manual::
13993 @end menu
13994
13995 @node Machine Code Insertions
13996 @section Machine Code Insertions
13997 @cindex Machine Code insertions
13998
13999 @noindent
14000 Package @code{Machine_Code} provides machine code support as described
14001 in the Ada Reference Manual in two separate forms:
14002 @itemize @bullet
14003 @item
14004 Machine code statements, consisting of qualified expressions that
14005 fit the requirements of RM section 13.8.
14006 @item
14007 An intrinsic callable procedure, providing an alternative mechanism of
14008 including machine instructions in a subprogram.
14009 @end itemize
14010
14011 @noindent
14012 The two features are similar, and both are closely related to the mechanism
14013 provided by the asm instruction in the GNU C compiler.  Full understanding
14014 and use of the facilities in this package requires understanding the asm
14015 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14016 by Richard Stallman. The relevant section is titled ``Extensions to the C
14017 Language Family'' @result{} ``Assembler Instructions with C Expression
14018 Operands''.
14019
14020 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14021 semantic restrictions and effects as described below.  Both are provided so
14022 that the procedure call can be used as a statement, and the function call
14023 can be used to form a code_statement.
14024
14025 The first example given in the GCC documentation is the C @code{asm}
14026 instruction:
14027 @smallexample
14028    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14029 @end smallexample
14030
14031 @noindent
14032 The equivalent can be written for GNAT as:
14033
14034 @smallexample @c ada
14035 Asm ("fsinx %1 %0",
14036      My_Float'Asm_Output ("=f", result),
14037      My_Float'Asm_Input  ("f",  angle));
14038 @end smallexample
14039
14040 @noindent
14041 The first argument to @code{Asm} is the assembler template, and is
14042 identical to what is used in GNU C@.  This string must be a static
14043 expression.  The second argument is the output operand list.  It is
14044 either a single @code{Asm_Output} attribute reference, or a list of such
14045 references enclosed in parentheses (technically an array aggregate of
14046 such references).
14047
14048 The @code{Asm_Output} attribute denotes a function that takes two
14049 parameters.  The first is a string, the second is the name of a variable
14050 of the type designated by the attribute prefix.  The first (string)
14051 argument is required to be a static expression and designates the
14052 constraint for the parameter (e.g.@: what kind of register is
14053 required).  The second argument is the variable to be updated with the
14054 result.  The possible values for constraint are the same as those used in
14055 the RTL, and are dependent on the configuration file used to build the
14056 GCC back end.  If there are no output operands, then this argument may
14057 either be omitted, or explicitly given as @code{No_Output_Operands}.
14058
14059 The second argument of @code{@var{my_float}'Asm_Output} functions as
14060 though it were an @code{out} parameter, which is a little curious, but
14061 all names have the form of expressions, so there is no syntactic
14062 irregularity, even though normally functions would not be permitted
14063 @code{out} parameters.  The third argument is the list of input
14064 operands.  It is either a single @code{Asm_Input} attribute reference, or
14065 a list of such references enclosed in parentheses (technically an array
14066 aggregate of such references).
14067
14068 The @code{Asm_Input} attribute denotes a function that takes two
14069 parameters.  The first is a string, the second is an expression of the
14070 type designated by the prefix.  The first (string) argument is required
14071 to be a static expression, and is the constraint for the parameter,
14072 (e.g.@: what kind of register is required).  The second argument is the
14073 value to be used as the input argument.  The possible values for the
14074 constant are the same as those used in the RTL, and are dependent on
14075 the configuration file used to built the GCC back end.
14076
14077 If there are no input operands, this argument may either be omitted, or
14078 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
14079 present in the above example, is a list of register names, called the
14080 @dfn{clobber} argument.  This argument, if given, must be a static string
14081 expression, and is a space or comma separated list of names of registers
14082 that must be considered destroyed as a result of the @code{Asm} call.  If
14083 this argument is the null string (the default value), then the code
14084 generator assumes that no additional registers are destroyed.
14085
14086 The fifth argument, not present in the above example, called the
14087 @dfn{volatile} argument, is by default @code{False}.  It can be set to
14088 the literal value @code{True} to indicate to the code generator that all
14089 optimizations with respect to the instruction specified should be
14090 suppressed, and that in particular, for an instruction that has outputs,
14091 the instruction will still be generated, even if none of the outputs are
14092 used.  See the full description in the GCC manual for further details.
14093 Generally it is strongly advisable to use Volatile for any ASM statement
14094 that is missing either input or output operands, or when two or more ASM
14095 statements appear in sequence, to avoid unwanted optimizations. A warning
14096 is generated if this advice is not followed.
14097
14098 The @code{Asm} subprograms may be used in two ways.  First the procedure
14099 forms can be used anywhere a procedure call would be valid, and
14100 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
14101 be used to intersperse machine instructions with other Ada statements.
14102 Second, the function forms, which return a dummy value of the limited
14103 private type @code{Asm_Insn}, can be used in code statements, and indeed
14104 this is the only context where such calls are allowed.  Code statements
14105 appear as aggregates of the form:
14106
14107 @smallexample @c ada
14108 Asm_Insn'(Asm (@dots{}));
14109 Asm_Insn'(Asm_Volatile (@dots{}));
14110 @end smallexample
14111
14112 @noindent
14113 In accordance with RM rules, such code statements are allowed only
14114 within subprograms whose entire body consists of such statements.  It is
14115 not permissible to intermix such statements with other Ada statements.
14116
14117 Typically the form using intrinsic procedure calls is more convenient
14118 and more flexible.  The code statement form is provided to meet the RM
14119 suggestion that such a facility should be made available.  The following
14120 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14121 is used, the arguments may be given in arbitrary order, following the
14122 normal rules for use of positional and named arguments)
14123
14124 @smallexample
14125 ASM_CALL ::= Asm (
14126                  [Template =>] static_string_EXPRESSION
14127                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14128                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14129                [,[Clobber  =>] static_string_EXPRESSION ]
14130                [,[Volatile =>] static_boolean_EXPRESSION] )
14131
14132 OUTPUT_OPERAND_LIST ::=
14133   [PREFIX.]No_Output_Operands
14134 | OUTPUT_OPERAND_ATTRIBUTE
14135 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14136
14137 OUTPUT_OPERAND_ATTRIBUTE ::=
14138   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14139
14140 INPUT_OPERAND_LIST ::=
14141   [PREFIX.]No_Input_Operands
14142 | INPUT_OPERAND_ATTRIBUTE
14143 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14144
14145 INPUT_OPERAND_ATTRIBUTE ::=
14146   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14147 @end smallexample
14148
14149 @noindent
14150 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14151 are declared in the package @code{Machine_Code} and must be referenced
14152 according to normal visibility rules. In particular if there is no
14153 @code{use} clause for this package, then appropriate package name
14154 qualification is required.
14155
14156 @node GNAT Implementation of Tasking
14157 @section GNAT Implementation of Tasking
14158
14159 @noindent
14160 This chapter outlines the basic GNAT approach to tasking (in particular,
14161 a multi-layered library for portability) and discusses issues related
14162 to compliance with the Real-Time Systems Annex.
14163
14164 @menu
14165 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14166 * Ensuring Compliance with the Real-Time Annex::
14167 @end menu
14168
14169 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14170 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14171
14172 @noindent
14173 GNAT's run-time support comprises two layers:
14174
14175 @itemize @bullet
14176 @item GNARL (GNAT Run-time Layer)
14177 @item GNULL (GNAT Low-level Library)
14178 @end itemize
14179
14180 @noindent
14181 In GNAT, Ada's tasking services rely on a platform and OS independent
14182 layer known as GNARL@.  This code is responsible for implementing the
14183 correct semantics of Ada's task creation, rendezvous, protected
14184 operations etc.
14185
14186 GNARL decomposes Ada's tasking semantics into simpler lower level
14187 operations such as create a thread, set the priority of a thread,
14188 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14189 operations constitutes GNULLI, the GNULL Interface.  This interface is
14190 directly inspired from the POSIX real-time API@.
14191
14192 If the underlying executive or OS implements the POSIX standard
14193 faithfully, the GNULL Interface maps as is to the services offered by
14194 the underlying kernel.  Otherwise, some target dependent glue code maps
14195 the services offered by the underlying kernel to the semantics expected
14196 by GNARL@.
14197
14198 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14199 key point is that each Ada task is mapped on a thread in the underlying
14200 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14201
14202 In addition Ada task priorities map onto the underlying thread priorities.
14203 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14204
14205 @itemize @bullet
14206 @item
14207 The underlying scheduler is used to schedule the Ada tasks.  This
14208 makes Ada tasks as efficient as kernel threads from a scheduling
14209 standpoint.
14210
14211 @item
14212 Interaction with code written in C containing threads is eased
14213 since at the lowest level Ada tasks and C threads map onto the same
14214 underlying kernel concept.
14215
14216 @item
14217 When an Ada task is blocked during I/O the remaining Ada tasks are
14218 able to proceed.
14219
14220 @item
14221 On multiprocessor systems Ada tasks can execute in parallel.
14222 @end itemize
14223
14224 @noindent
14225 Some threads libraries offer a mechanism to fork a new process, with the
14226 child process duplicating the threads from the parent.
14227 GNAT does not
14228 support this functionality when the parent contains more than one task.
14229 @cindex Forking a new process
14230
14231 @node Ensuring Compliance with the Real-Time Annex
14232 @subsection Ensuring Compliance with the Real-Time Annex
14233 @cindex Real-Time Systems Annex compliance
14234
14235 @noindent
14236 Although mapping Ada tasks onto
14237 the underlying threads has significant advantages, it does create some
14238 complications when it comes to respecting the scheduling semantics
14239 specified in the real-time annex (Annex D).
14240
14241 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14242 scheduling policy states:
14243
14244 @quotation
14245 @emph{When the active priority of a ready task that is not running
14246 changes, or the setting of its base priority takes effect, the
14247 task is removed from the ready queue for its old active priority
14248 and is added at the tail of the ready queue for its new active
14249 priority, except in the case where the active priority is lowered
14250 due to the loss of inherited priority, in which case the task is
14251 added at the head of the ready queue for its new active priority.}
14252 @end quotation
14253
14254 @noindent
14255 While most kernels do put tasks at the end of the priority queue when
14256 a task changes its priority, (which respects the main
14257 FIFO_Within_Priorities requirement), almost none keep a thread at the
14258 beginning of its priority queue when its priority drops from the loss
14259 of inherited priority.
14260
14261 As a result most vendors have provided incomplete Annex D implementations.
14262
14263 The GNAT run-time, has a nice cooperative solution to this problem
14264 which ensures that accurate FIFO_Within_Priorities semantics are
14265 respected.
14266
14267 The principle is as follows.  When an Ada task T is about to start
14268 running, it checks whether some other Ada task R with the same
14269 priority as T has been suspended due to the loss of priority
14270 inheritance.  If this is the case, T yields and is placed at the end of
14271 its priority queue.  When R arrives at the front of the queue it
14272 executes.
14273
14274 Note that this simple scheme preserves the relative order of the tasks
14275 that were ready to execute in the priority queue where R has been
14276 placed at the end.
14277
14278 @node GNAT Implementation of Shared Passive Packages
14279 @section GNAT Implementation of Shared Passive Packages
14280 @cindex Shared passive packages
14281
14282 @noindent
14283 GNAT fully implements the pragma @code{Shared_Passive} for
14284 @cindex pragma @code{Shared_Passive}
14285 the purpose of designating shared passive packages.
14286 This allows the use of passive partitions in the
14287 context described in the Ada Reference Manual; i.e. for communication
14288 between separate partitions of a distributed application using the
14289 features in Annex E.
14290 @cindex Annex E
14291 @cindex Distribution Systems Annex
14292
14293 However, the implementation approach used by GNAT provides for more
14294 extensive usage as follows:
14295
14296 @table @emph
14297 @item Communication between separate programs
14298
14299 This allows separate programs to access the data in passive
14300 partitions, using protected objects for synchronization where
14301 needed. The only requirement is that the two programs have a
14302 common shared file system. It is even possible for programs
14303 running on different machines with different architectures
14304 (e.g. different endianness) to communicate via the data in
14305 a passive partition.
14306
14307 @item Persistence between program runs
14308
14309 The data in a passive package can persist from one run of a
14310 program to another, so that a later program sees the final
14311 values stored by a previous run of the same program.
14312
14313 @end table
14314
14315 @noindent
14316 The implementation approach used is to store the data in files. A
14317 separate stream file is created for each object in the package, and
14318 an access to an object causes the corresponding file to be read or
14319 written.
14320
14321 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14322 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14323 set to the directory to be used for these files.
14324 The files in this directory
14325 have names that correspond to their fully qualified names. For
14326 example, if we have the package
14327
14328 @smallexample @c ada
14329 package X is
14330   pragma Shared_Passive (X);
14331   Y : Integer;
14332   Z : Float;
14333 end X;
14334 @end smallexample
14335
14336 @noindent
14337 and the environment variable is set to @code{/stemp/}, then the files created
14338 will have the names:
14339
14340 @smallexample
14341 /stemp/x.y
14342 /stemp/x.z
14343 @end smallexample
14344
14345 @noindent
14346 These files are created when a value is initially written to the object, and
14347 the files are retained until manually deleted. This provides the persistence
14348 semantics. If no file exists, it means that no partition has assigned a value
14349 to the variable; in this case the initial value declared in the package
14350 will be used. This model ensures that there are no issues in synchronizing
14351 the elaboration process, since elaboration of passive packages elaborates the
14352 initial values, but does not create the files.
14353
14354 The files are written using normal @code{Stream_IO} access.
14355 If you want to be able
14356 to communicate between programs or partitions running on different
14357 architectures, then you should use the XDR versions of the stream attribute
14358 routines, since these are architecture independent.
14359
14360 If active synchronization is required for access to the variables in the
14361 shared passive package, then as described in the Ada Reference Manual, the
14362 package may contain protected objects used for this purpose. In this case
14363 a lock file (whose name is @file{___lock} (three underscores)
14364 is created in the shared memory directory.
14365 @cindex @file{___lock} file (for shared passive packages)
14366 This is used to provide the required locking
14367 semantics for proper protected object synchronization.
14368
14369 As of January 2003, GNAT supports shared passive packages on all platforms
14370 except for OpenVMS.
14371
14372 @node Code Generation for Array Aggregates
14373 @section Code Generation for Array Aggregates
14374
14375 @menu
14376 * Static constant aggregates with static bounds::
14377 * Constant aggregates with unconstrained nominal types::
14378 * Aggregates with static bounds::
14379 * Aggregates with non-static bounds::
14380 * Aggregates in assignment statements::
14381 @end menu
14382
14383 @noindent
14384 Aggregates have a rich syntax and allow the user to specify the values of
14385 complex data structures by means of a single construct.  As a result, the
14386 code generated for aggregates can be quite complex and involve loops, case
14387 statements and multiple assignments.  In the simplest cases, however, the
14388 compiler will recognize aggregates whose components and constraints are
14389 fully static, and in those cases the compiler will generate little or no
14390 executable code.  The following is an outline of the code that GNAT generates
14391 for various aggregate constructs.  For further details, you will find it
14392 useful to examine the output produced by the -gnatG flag to see the expanded
14393 source that is input to the code generator.  You may also want to examine
14394 the assembly code generated at various levels of optimization.
14395
14396 The code generated for aggregates depends on the context, the component values,
14397 and the type.  In the context of an object declaration the code generated is
14398 generally simpler than in the case of an assignment.  As a general rule, static
14399 component values and static subtypes also lead to simpler code.
14400
14401 @node Static constant aggregates with static bounds
14402 @subsection Static constant aggregates with static bounds
14403
14404 @noindent
14405 For the declarations:
14406 @smallexample @c ada
14407     type One_Dim is array (1..10) of integer;
14408     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14409 @end smallexample
14410
14411 @noindent
14412 GNAT generates no executable code: the constant ar0 is placed in static memory.
14413 The same is true for constant aggregates with named associations:
14414
14415 @smallexample @c ada
14416     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14417     Cr3 : constant One_Dim := (others => 7777);
14418 @end smallexample
14419
14420 @noindent
14421 The same is true for multidimensional constant arrays such as:
14422
14423 @smallexample @c ada
14424     type two_dim is array (1..3, 1..3) of integer;
14425     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14426 @end smallexample
14427
14428 @noindent
14429 The same is true for arrays of one-dimensional arrays: the following are
14430 static:
14431
14432 @smallexample @c ada
14433 type ar1b  is array (1..3) of boolean;
14434 type ar_ar is array (1..3) of ar1b;
14435 None  : constant ar1b := (others => false);     --  fully static
14436 None2 : constant ar_ar := (1..3 => None);       --  fully static
14437 @end smallexample
14438
14439 @noindent
14440 However, for multidimensional aggregates with named associations, GNAT will
14441 generate assignments and loops, even if all associations are static.  The
14442 following two declarations generate a loop for the first dimension, and
14443 individual component assignments for the second dimension:
14444
14445 @smallexample @c ada
14446 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14447 Zero2: constant two_dim := (others => (others => 0));
14448 @end smallexample
14449
14450 @node Constant aggregates with unconstrained nominal types
14451 @subsection Constant aggregates with unconstrained nominal types
14452
14453 @noindent
14454 In such cases the aggregate itself establishes the subtype, so that
14455 associations with @code{others} cannot be used.  GNAT determines the
14456 bounds for the actual subtype of the aggregate, and allocates the
14457 aggregate statically as well.  No code is generated for the following:
14458
14459 @smallexample @c ada
14460     type One_Unc is array (natural range <>) of integer;
14461     Cr_Unc : constant One_Unc := (12,24,36);
14462 @end smallexample
14463
14464 @node Aggregates with static bounds
14465 @subsection Aggregates with static bounds
14466
14467 @noindent
14468 In all previous examples the aggregate was the initial (and immutable) value
14469 of a constant.  If the aggregate initializes a variable, then code is generated
14470 for it as a combination of individual assignments and loops over the target
14471 object.  The declarations
14472
14473 @smallexample @c ada
14474        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14475        Cr_Var2 : One_Dim := (others > -1);
14476 @end smallexample
14477
14478 @noindent
14479 generate the equivalent of
14480
14481 @smallexample @c ada
14482        Cr_Var1 (1) := 2;
14483        Cr_Var1 (2) := 3;
14484        Cr_Var1 (3) := 5;
14485        Cr_Var1 (4) := 11;
14486
14487        for I in Cr_Var2'range loop
14488           Cr_Var2 (I) := =-1;
14489        end loop;
14490 @end smallexample
14491
14492 @node Aggregates with non-static bounds
14493 @subsection Aggregates with non-static bounds
14494
14495 @noindent
14496 If the bounds of the aggregate are not statically compatible with the bounds
14497 of the nominal subtype  of the target, then constraint checks have to be
14498 generated on the bounds.  For a multidimensional array, constraint checks may
14499 have to be applied to sub-arrays individually, if they do not have statically
14500 compatible subtypes.
14501
14502 @node Aggregates in assignment statements
14503 @subsection Aggregates in assignment statements
14504
14505 @noindent
14506 In general, aggregate assignment requires the construction of a temporary,
14507 and a copy from the temporary to the target of the assignment.  This is because
14508 it is not always possible to convert the assignment into a series of individual
14509 component assignments.  For example, consider the simple case:
14510
14511 @smallexample @c ada
14512         A := (A(2), A(1));
14513 @end smallexample
14514
14515 @noindent
14516 This cannot be converted into:
14517
14518 @smallexample @c ada
14519         A(1) := A(2);
14520         A(2) := A(1);
14521 @end smallexample
14522
14523 @noindent
14524 So the aggregate has to be built first in a separate location, and then
14525 copied into the target.  GNAT recognizes simple cases where this intermediate
14526 step is not required, and the assignments can be performed in place, directly
14527 into the target.  The following sufficient criteria are applied:
14528
14529 @itemize @bullet
14530 @item
14531 The bounds of the aggregate are static, and the associations are static.
14532 @item
14533 The components of the aggregate are static constants, names of
14534 simple variables that are not renamings, or expressions not involving
14535 indexed components whose operands obey these rules.
14536 @end itemize
14537
14538 @noindent
14539 If any of these conditions are violated, the aggregate will be built in
14540 a temporary (created either by the front-end or the code generator) and then
14541 that temporary will be copied onto the target.
14542
14543
14544 @node The Size of Discriminated Records with Default Discriminants
14545 @section The Size of Discriminated Records with Default Discriminants
14546
14547 @noindent
14548 If a discriminated type @code{T} has discriminants with default values, it is
14549 possible to declare an object of this type without providing an explicit
14550 constraint:
14551
14552 @smallexample @c ada
14553 @group
14554 type Size is range 1..100;
14555
14556 type Rec (D : Size := 15) is record
14557    Name : String (1..D);
14558 end T;
14559
14560 Word : Rec;
14561 @end group
14562 @end smallexample
14563
14564 @noindent
14565 Such an object is said to be @emph{unconstrained}.
14566 The discriminant of the object
14567 can be modified by a full assignment to the object, as long as it preserves the
14568 relation between the value of the discriminant, and the value of the components
14569 that depend on it:
14570
14571 @smallexample @c ada
14572 @group
14573 Word := (3, "yes");
14574
14575 Word := (5, "maybe");
14576
14577 Word := (5, "no"); -- raises Constraint_Error
14578 @end group
14579 @end smallexample
14580
14581 @noindent
14582 In order to support this behavior efficiently, an unconstrained object is
14583 given the maximum size that any value of the type requires. In the case
14584 above, @code{Word} has storage for the discriminant and for
14585 a @code{String} of length 100.
14586 It is important to note that unconstrained objects do not require dynamic
14587 allocation. It would be an improper implementation to place on the heap those
14588 components whose size depends on discriminants. (This improper implementation
14589 was used by some Ada83 compilers, where the @code{Name} component above
14590 would have
14591 been stored as a pointer to a dynamic string). Following the principle that
14592 dynamic storage management should never be introduced implicitly,
14593 an Ada compiler should reserve the full size for an unconstrained declared
14594 object, and place it on the stack.
14595
14596 This maximum size approach
14597 has been a source of surprise to some users, who expect the default
14598 values of the discriminants to determine the size reserved for an
14599 unconstrained object: ``If the default is 15, why should the object occupy
14600 a larger size?''
14601 The answer, of course, is that the discriminant may be later modified,
14602 and its full range of values must be taken into account. This is why the
14603 declaration:
14604
14605 @smallexample
14606 @group
14607 type Rec (D : Positive := 15) is record
14608    Name : String (1..D);
14609 end record;
14610
14611 Too_Large : Rec;
14612 @end group
14613 @end smallexample
14614
14615 @noindent
14616 is flagged by the compiler with a warning:
14617 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14618 because the required size includes @code{Positive'Last}
14619 bytes. As the first example indicates, the proper approach is to declare an
14620 index type of ``reasonable'' range so that unconstrained objects are not too
14621 large.
14622
14623 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14624 created in the heap by means of an allocator, then it is @emph{not}
14625 unconstrained:
14626 it is constrained by the default values of the discriminants, and those values
14627 cannot be modified by full assignment. This is because in the presence of
14628 aliasing all views of the object (which may be manipulated by different tasks,
14629 say) must be consistent, so it is imperative that the object, once created,
14630 remain invariant.
14631
14632 @node Strict Conformance to the Ada Reference Manual
14633 @section Strict Conformance to the Ada Reference Manual
14634
14635 @noindent
14636 The dynamic semantics defined by the Ada Reference Manual impose a set of
14637 run-time checks to be generated. By default, the GNAT compiler will insert many
14638 run-time checks into the compiled code, including most of those required by the
14639 Ada Reference Manual. However, there are three checks that are not enabled
14640 in the default mode for efficiency reasons: arithmetic overflow checking for
14641 integer operations (including division by zero), checks for access before
14642 elaboration on subprogram calls, and stack overflow checking (most operating
14643 systems do not perform this check by default).
14644
14645 Strict conformance to the Ada Reference Manual can be achieved by adding
14646 three compiler options for overflow checking for integer operations
14647 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14648 calls and generic instantiations (@option{-gnatE}), and stack overflow
14649 checking (@option{-fstack-check}).
14650
14651 Note that the result of a floating point arithmetic operation in overflow and
14652 invalid situations, when the @code{Machine_Overflows} attribute of the result
14653 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14654 case for machines compliant with the IEEE floating-point standard, but on
14655 machines that are not fully compliant with this standard, such as Alpha, the
14656 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14657 behavior (although at the cost of a significant performance penalty), so
14658 infinite and and NaN values are properly generated.
14659
14660
14661 @node Project File Reference
14662 @chapter Project File Reference
14663
14664 @noindent
14665 This chapter describes the syntax and semantics of project files.
14666 Project files specify the options to be used when building a system.
14667 Project files can specify global settings for all tools,
14668 as well as tool-specific settings.
14669 See the chapter on project files in the GNAT Users guide for examples of use.
14670
14671 @menu
14672 * Reserved Words::
14673 * Lexical Elements::
14674 * Declarations::
14675 * Empty declarations::
14676 * Typed string declarations::
14677 * Variables::
14678 * Expressions::
14679 * Attributes::
14680 * Project Attributes::
14681 * Attribute References::
14682 * External Values::
14683 * Case Construction::
14684 * Packages::
14685 * Package Renamings::
14686 * Projects::
14687 * Project Extensions::
14688 * Project File Elaboration::
14689 @end menu
14690
14691 @node Reserved Words
14692 @section Reserved Words
14693
14694 @noindent
14695 All Ada reserved words are reserved in project files, and cannot be used
14696 as variable names or project names. In addition, the following are
14697 also reserved in project files:
14698
14699 @itemize
14700 @item @code{extends}
14701
14702 @item @code{external}
14703
14704 @item @code{project}
14705
14706 @end itemize
14707
14708 @node Lexical Elements
14709 @section Lexical Elements
14710
14711 @noindent
14712 Rules for identifiers are the same as in Ada. Identifiers
14713 are case-insensitive.  Strings are case sensitive, except where noted.
14714 Comments have the same form as in Ada.
14715
14716 @noindent
14717 Syntax:
14718
14719 @smallexample
14720 simple_name ::=
14721   identifier
14722
14723 name ::=
14724   simple_name @{. simple_name@}
14725 @end smallexample
14726
14727 @node Declarations
14728 @section Declarations
14729
14730 @noindent
14731 Declarations introduce new entities that denote types, variables, attributes,
14732 and packages. Some declarations can only appear immediately within a project
14733 declaration. Others can appear within a project or within a package.
14734
14735 Syntax:
14736 @smallexample
14737 declarative_item ::=
14738   simple_declarative_item |
14739   typed_string_declaration |
14740   package_declaration
14741
14742 simple_declarative_item ::=
14743   variable_declaration |
14744   typed_variable_declaration |
14745   attribute_declaration |
14746   case_construction |
14747   empty_declaration
14748 @end smallexample
14749
14750 @node Empty declarations
14751 @section Empty declarations
14752
14753 @smallexample
14754 empty_declaration ::=
14755   @b{null} ;
14756 @end smallexample
14757
14758 An empty declaration is allowed anywhere a declaration is allowed.
14759 It has no effect.
14760
14761 @node Typed string declarations
14762 @section Typed string declarations
14763
14764 @noindent
14765 Typed strings are sequences of string literals. Typed strings are the only
14766 named types in project files. They are used in case constructions, where they
14767 provide support for conditional attribute definitions.
14768
14769 Syntax:
14770 @smallexample
14771 typed_string_declaration ::=
14772   @b{type} <typed_string_>_simple_name @b{is}
14773    ( string_literal @{, string_literal@} );
14774 @end smallexample
14775
14776 @noindent
14777 A typed string declaration can only appear immediately within a project
14778 declaration.
14779
14780 All the string literals in a typed string declaration must be distinct.
14781
14782 @node Variables
14783 @section Variables
14784
14785 @noindent
14786 Variables denote values, and appear as constituents of expressions.
14787
14788 @smallexample
14789 typed_variable_declaration ::=
14790   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14791
14792 variable_declaration ::=
14793   <variable_>simple_name := expression;
14794 @end smallexample
14795
14796 @noindent
14797 The elaboration of a variable declaration introduces the variable and
14798 assigns to it the value of the expression. The name of the variable is
14799 available after the assignment symbol.
14800
14801 @noindent
14802 A typed_variable can only be declare once.
14803
14804 @noindent
14805 a non typed variable can be declared multiple times.
14806
14807 @noindent
14808 Before the completion of its first declaration, the value of variable
14809 is the null string.
14810
14811 @node Expressions
14812 @section Expressions
14813
14814 @noindent
14815 An expression is a formula that defines a computation or retrieval of a value.
14816 In a project file the value of an expression is either a string or a list
14817 of strings. A string value in an expression is either a literal, the current
14818 value of a variable, an external value, an attribute reference, or a
14819 concatenation operation.
14820
14821 Syntax:
14822
14823 @smallexample
14824 expression ::=
14825   term @{& term@}
14826
14827 term ::=
14828   string_literal |
14829   string_list |
14830   <variable_>name |
14831   external_value |
14832   attribute_reference
14833
14834 string_literal ::=
14835   (same as Ada)
14836
14837 string_list ::=
14838   ( <string_>expression @{ , <string_>expression @} )
14839 @end smallexample
14840
14841 @subsection Concatenation
14842 @noindent
14843 The following concatenation functions are defined:
14844
14845 @smallexample @c ada
14846   function "&" (X : String;      Y : String)      return String;
14847   function "&" (X : String_List; Y : String)      return String_List;
14848   function "&" (X : String_List; Y : String_List) return String_List;
14849 @end smallexample
14850
14851 @node Attributes
14852 @section Attributes
14853
14854 @noindent
14855 An attribute declaration defines a property of a project or package. This
14856 property can later be queried by means of an attribute reference.
14857 Attribute values are strings or string lists.
14858
14859 Some attributes are associative arrays. These attributes are mappings whose
14860 domain is a set of strings. These attributes are declared one association
14861 at a time, by specifying a point in the domain and the corresponding image
14862 of the attribute. They may also be declared as a full associative array,
14863 getting the same associations as the corresponding attribute in an imported
14864 or extended project.
14865
14866 Attributes that are not associative arrays are called simple attributes.
14867
14868 Syntax:
14869 @smallexample
14870 attribute_declaration ::=
14871   full_associative_array_declaration |
14872   @b{for} attribute_designator @b{use} expression ;
14873
14874 full_associative_array_declaration ::=
14875   @b{for} <associative_array_attribute_>simple_name @b{use}
14876   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14877
14878 attribute_designator ::=
14879   <simple_attribute_>simple_name |
14880   <associative_array_attribute_>simple_name ( string_literal )
14881 @end smallexample
14882
14883 @noindent
14884 Some attributes are project-specific, and can only appear immediately within
14885 a project declaration. Others are package-specific, and can only appear within
14886 the proper package.
14887
14888 The expression in an attribute definition must be a string or a string_list.
14889 The string literal appearing in the attribute_designator of an associative
14890 array attribute is case-insensitive.
14891
14892 @node Project Attributes
14893 @section Project Attributes
14894
14895 @noindent
14896 The following attributes apply to a project. All of them are simple
14897 attributes.
14898
14899 @table @code
14900 @item   Object_Dir
14901 Expression must be a path name. The attribute defines the
14902 directory in which the object files created by the build are to be placed. If
14903 not specified, object files are placed in the project directory.
14904
14905 @item   Exec_Dir
14906 Expression must be a path name. The attribute defines the
14907 directory in which the executables created by the build are to be placed.
14908 If not specified, executables are placed in the object directory.
14909
14910 @item  Source_Dirs
14911 Expression must be a list of path names. The attribute
14912 defines the directories in which the source files for the project are to be
14913 found. If not specified, source files are found in the project directory.
14914
14915 @item  Source_Files
14916 Expression must be a list of file names. The attribute
14917 defines the individual files, in the project directory, which are to be used
14918 as sources for the project. File names are path_names that contain no directory
14919 information. If the project has no sources the attribute must be declared
14920 explicitly with an empty list.
14921
14922 @item  Source_List_File
14923 Expression must a single path name. The attribute
14924 defines a text file that contains a list of source file names to be used
14925 as sources for the project
14926
14927 @item  Library_Dir
14928 Expression must be a path name. The attribute defines the
14929 directory in which a  library is to be built.  The directory must exist, must
14930 be distinct from the project's object directory, and must be writable.
14931
14932 @item  Library_Name
14933 Expression must be a string that is a legal file name,
14934 without extension. The attribute defines a string that is used to generate
14935 the name of the library to be built by the project.
14936
14937 @item  Library_Kind
14938 Argument must be a string value that must be one of the
14939 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14940 string is case-insensitive. If this attribute is not specified, the library is
14941 a static library. Otherwise, the library may be dynamic or relocatable. This
14942 distinction is operating-system dependent.
14943
14944 @item  Library_Version
14945 Expression must be a string value whose interpretation
14946 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14947 libraries as the internal name of the library (the @code{"soname"}). If the
14948 library file name (built from the @code{Library_Name}) is different from the
14949 @code{Library_Version}, then the library file will be a symbolic link to the
14950 actual file whose name will be @code{Library_Version}.
14951
14952 @item Library_Interface
14953 Expression must be a string list. Each element of the string list
14954 must designate a unit of the project.
14955 If this attribute is present in a Library Project File, then the project
14956 file is a Stand-alone Library_Project_File.
14957
14958 @item Library_Auto_Init
14959 Expression must be a single string "true" or "false", case-insensitive.
14960 If this attribute is present in a Stand-alone Library Project File,
14961 it indicates if initialization is automatic when the dynamic library
14962 is loaded.
14963
14964 @item Library_Options
14965 Expression must be a string list. Indicates additional switches that
14966 are to be used when building a shared library.
14967
14968 @item Library_GCC
14969 Expression must be a single string. Designates an alternative to "gcc"
14970 for building shared libraries.
14971
14972 @item  Library_Src_Dir
14973 Expression must be a path name. The attribute defines the
14974 directory in which the sources of the interfaces of a Stand-alone Library will
14975 be copied.  The directory must exist, must be distinct from the project's
14976 object directory and source directories of all projects in the project tree,
14977 and must be writable.
14978
14979 @item  Library_Src_Dir
14980 Expression must be a path name. The attribute defines the
14981 directory in which the ALI files of a Library will
14982 be copied.  The directory must exist, must be distinct from the project's
14983 object directory and source directories of all projects in the project tree,
14984 and must be writable.
14985
14986 @item  Library_Symbol_File
14987 Expression must be a single string. Its value is the single file name of a
14988 symbol file to be created when building a stand-alone library when the
14989 symbol policy is either "compliant", "controlled" or "restricted",
14990 on platforms that support symbol control, such as VMS. When symbol policy
14991 is "direct", then a file with this name must exist in the object directory.
14992
14993 @item   Library_Reference_Symbol_File
14994 Expression must be a single string. Its value is the path name of a
14995 reference symbol file that is read when the symbol policy is either
14996 "compliant" or "controlled", on platforms that support symbol control,
14997 such as VMS, when building a stand-alone library. The path may be an absolute
14998 path or a path relative to the project directory.
14999
15000 @item  Library_Symbol_Policy
15001 Expression must be a single string. Its case-insensitive value can only be
15002 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15003
15004 This attribute is not taken into account on all platforms. It controls the
15005 policy for exported symbols and, on some platforms (like VMS) that have the
15006 notions of major and minor IDs built in the library files, it controls
15007 the setting of these IDs.
15008
15009 "autonomous" or "default": exported symbols are not controlled.
15010
15011 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15012 it is equivalent to policy "autonomous". If there are exported symbols in
15013 the reference symbol file that are not in the object files of the interfaces,
15014 the major ID of the library is increased. If there are symbols in the
15015 object files of the interfaces that are not in the reference symbol file,
15016 these symbols are put at the end of the list in the newly created symbol file
15017 and the minor ID is increased.
15018
15019 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15020 The library will fail to build if the exported symbols in the object files of
15021 the interfaces do not match exactly the symbol in the symbol file.
15022
15023 "restricted": The attribute Library_Symbol_File must be defined. The library
15024 will fail to build if there are symbols in the symbol file that are not in
15025 the exported symbols of the object files of the interfaces. Additional symbols
15026 in the object files are not added to the symbol file.
15027
15028 "direct": The attribute Library_Symbol_File must be defined and must designate
15029 an existing file in the object directory. This symbol file is passed directly
15030 to the underlying linker without any symbol processing.
15031
15032 @item  Main
15033 Expression must be a list of strings that are legal file names.
15034 These file names designate existing compilation units in the source directory
15035 that are legal main subprograms.
15036
15037 When a project file is elaborated, as part of the execution of a gnatmake
15038 command, one or several executables are built and placed in the Exec_Dir.
15039 If the gnatmake command does not include explicit file names, the executables
15040 that are built correspond to the files specified by this attribute.
15041
15042 @item  Externally_Built
15043 Expression must be a single string. Its value must be either "true" of "false",
15044 case-insensitive. The default is "false". When the value of this attribute is
15045 "true", no attempt is made to compile the sources or to build the library,
15046 when the project is a library project.
15047
15048 @item Main_Language
15049 This is a simple attribute. Its value is a string that specifies the
15050 language of the main program.
15051
15052 @item  Languages
15053 Expression must be a string list. Each string designates
15054 a programming language that is known to GNAT. The strings are case-insensitive.
15055
15056 @item  Locally_Removed_Files
15057 This attribute is legal only in a project file that extends another.
15058 Expression must be a list of strings that are legal file names.
15059 Each file name must designate a source that would normally be inherited
15060 by the current project file. It cannot designate an immediate source that is
15061 not inherited. Each of the source files in the list are not considered to
15062 be sources of the project file: they are not inherited.
15063 @end table
15064
15065 @node Attribute References
15066 @section Attribute References
15067
15068 @noindent
15069 Attribute references are used to retrieve the value of previously defined
15070 attribute for a package or project.
15071 Syntax:
15072 @smallexample
15073 attribute_reference ::=
15074   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15075
15076 attribute_prefix ::=
15077   @b{project} |
15078   <project_simple_name | package_identifier |
15079   <project_>simple_name . package_identifier
15080 @end smallexample
15081
15082 @noindent
15083 If an attribute has not been specified for a given package or project, its
15084 value is the null string or the empty list.
15085
15086 @node External Values
15087 @section External Values
15088
15089 @noindent
15090 An external value is an expression whose value is obtained from the command
15091 that invoked the processing of the current project file (typically a
15092 gnatmake command).
15093
15094 Syntax:
15095 @smallexample
15096 external_value ::=
15097   @b{external} ( string_literal [, string_literal] )
15098 @end smallexample
15099
15100 @noindent
15101 The first string_literal is the string to be used on the command line or
15102 in the environment to specify the external value. The second string_literal,
15103 if present, is the default to use if there is no specification for this
15104 external value either on the command line or in the environment.
15105
15106 @node Case Construction
15107 @section Case Construction
15108
15109 @noindent
15110 A case construction supports attribute and variable declarations that depend
15111 on the value of a previously declared variable.
15112
15113 Syntax:
15114 @smallexample
15115 case_construction ::=
15116   @b{case} <typed_variable_>name @b{is}
15117     @{case_item@}
15118   @b{end case} ;
15119
15120 case_item ::=
15121   @b{when} discrete_choice_list =>
15122     @{case_construction |
15123       attribute_declaration |
15124       variable_declaration |
15125       empty_declaration@}
15126
15127 discrete_choice_list ::=
15128   string_literal @{| string_literal@} |
15129     @b{others}
15130 @end smallexample
15131
15132 @noindent
15133 Inside a case construction, variable declarations must be for variables that
15134 have already been declared before the case construction.
15135
15136 All choices in a choice list must be distinct. The choice lists of two
15137 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15138 alternatives do not need to include all values of the type. An @code{others}
15139 choice must appear last in the list of alternatives.
15140
15141 @node Packages
15142 @section Packages
15143
15144 @noindent
15145 A package provides a grouping of variable declarations and attribute
15146 declarations to be used when invoking various GNAT tools. The name of
15147 the package indicates the tool(s) to which it applies.
15148 Syntax:
15149
15150 @smallexample
15151 package_declaration ::=
15152   package_specification | package_renaming
15153
15154 package_specification ::=
15155   @b{package} package_identifier @b{is}
15156     @{simple_declarative_item@}
15157   @b{end} package_identifier ;
15158
15159 package_identifier ::=
15160   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15161   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15162   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15163 @end smallexample
15164
15165 @subsection Package Naming
15166
15167 @noindent
15168 The attributes of a @code{Naming} package specifies the naming conventions
15169 that apply to the source files in a project. When invoking other GNAT tools,
15170 they will use the sources in the source directories that satisfy these
15171 naming conventions.
15172
15173 The following attributes apply to a @code{Naming} package:
15174
15175 @table @code
15176 @item Casing
15177 This is a simple attribute whose value is a string. Legal values of this
15178 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15179 These strings are themselves case insensitive.
15180
15181 @noindent
15182 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15183
15184 @item Dot_Replacement
15185 This is a simple attribute whose string value satisfies the following
15186 requirements:
15187
15188 @itemize @bullet
15189 @item It must not be empty
15190 @item It cannot start or end with an alphanumeric character
15191 @item It cannot be a single underscore
15192 @item It cannot start with an underscore followed by an alphanumeric
15193 @item It cannot contain a dot @code{'.'} if longer than one character
15194 @end itemize
15195
15196 @noindent
15197 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15198
15199 @item Spec_Suffix
15200 This is an associative array attribute, defined on language names,
15201 whose image is a string that must satisfy the following
15202 conditions:
15203
15204 @itemize @bullet
15205 @item It must not be empty
15206 @item It cannot start with an alphanumeric character
15207 @item It cannot start with an underscore followed by an alphanumeric character
15208 @end itemize
15209
15210 @noindent
15211 For Ada, the attribute denotes the suffix used in file names that contain
15212 library unit declarations, that is to say units that are package and
15213 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15214 specified, then the default is @code{".ads"}.
15215
15216 For C and C++, the attribute denotes the suffix used in file names that
15217 contain prototypes.
15218
15219 @item Body_Suffix
15220 This is an associative array attribute defined on language names,
15221 whose image is a string that must satisfy the following
15222 conditions:
15223
15224 @itemize @bullet
15225 @item It must not be empty
15226 @item It cannot start with an alphanumeric character
15227 @item It cannot start with an underscore followed by an alphanumeric character
15228 @item It cannot be a suffix of @code{Spec_Suffix}
15229 @end itemize
15230
15231 @noindent
15232 For Ada, the attribute denotes the suffix used in file names that contain
15233 library bodies, that is to say units that are package and subprogram bodies.
15234 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15235 @code{".adb"}.
15236
15237 For C and C++, the attribute denotes the suffix used in file names that contain
15238 source code.
15239
15240 @item Separate_Suffix
15241 This is a simple attribute whose value satisfies the same conditions as
15242 @code{Body_Suffix}.
15243
15244 This attribute is specific to Ada. It denotes the suffix used in file names
15245 that contain separate bodies. If it is not specified, then it defaults to same
15246 value as @code{Body_Suffix ("Ada")}.
15247
15248 @item Spec
15249 This is an associative array attribute, specific to Ada, defined over
15250 compilation unit names. The image is a string that is the name of the file
15251 that contains that library unit. The file name is case sensitive if the
15252 conventions of the host operating system require it.
15253
15254 @item Body
15255 This is an associative array attribute, specific to Ada, defined over
15256 compilation unit names. The image is a string that is the name of the file
15257 that contains the library unit body for the named unit. The file name is case
15258 sensitive if the conventions of the host operating system require it.
15259
15260 @item Specification_Exceptions
15261 This is an associative array attribute defined on language names,
15262 whose value is a list of strings.
15263
15264 This attribute is not significant for Ada.
15265
15266 For C and C++, each string in the list denotes the name of a file that
15267 contains prototypes, but whose suffix is not necessarily the
15268 @code{Spec_Suffix} for the language.
15269
15270 @item Implementation_Exceptions
15271 This is an associative array attribute defined on language names,
15272 whose value is a list of strings.
15273
15274 This attribute is not significant for Ada.
15275
15276 For C and C++, each string in the list denotes the name of a file that
15277 contains source code, but whose suffix is not necessarily the
15278 @code{Body_Suffix} for the language.
15279 @end table
15280
15281 The following attributes of package @code{Naming} are obsolescent. They are
15282 kept as synonyms of other attributes for compatibility with previous versions
15283 of the Project Manager.
15284
15285 @table @code
15286 @item Specification_Suffix
15287 This is a synonym of @code{Spec_Suffix}.
15288
15289 @item Implementation_Suffix
15290 This is a synonym of @code{Body_Suffix}.
15291
15292 @item Specification
15293 This is a synonym of @code{Spec}.
15294
15295 @item Implementation
15296 This is a synonym of @code{Body}.
15297 @end table
15298
15299 @subsection package Compiler
15300
15301 @noindent
15302 The attributes of the @code{Compiler} package specify the compilation options
15303 to be used by the underlying compiler.
15304
15305 @table @code
15306 @item  Default_Switches
15307 This is an associative array attribute. Its
15308 domain is a set of language names. Its range is a string list that
15309 specifies the compilation options to be used when compiling a component
15310 written in that language, for which no file-specific switches have been
15311 specified.
15312
15313 @item  Switches
15314 This is an associative array attribute. Its domain is
15315 a set of file names. Its range is a string list that specifies the
15316 compilation options to be used when compiling the named file. If a file
15317 is not specified in the Switches attribute, it is compiled with the
15318 options specified by Default_Switches of its language, if defined.
15319
15320 @item  Local_Configuration_Pragmas.
15321 This is a simple attribute, whose
15322 value is a path name that designates a file containing configuration pragmas
15323 to be used for all invocations of the compiler for immediate sources of the
15324 project.
15325 @end table
15326
15327 @subsection package Builder
15328
15329 @noindent
15330 The attributes of package @code{Builder} specify the compilation, binding, and
15331 linking options to be used when building an executable for a project. The
15332 following attributes apply to package @code{Builder}:
15333
15334 @table @code
15335 @item Default_Switches
15336 This is an associative array attribute. Its
15337 domain is a set of language names. Its range is a string list that
15338 specifies options to be used when building a main
15339 written in that language, for which no file-specific switches have been
15340 specified.
15341
15342 @item Switches
15343 This is an associative array attribute. Its domain is
15344 a set of file names. Its range is a string list that specifies
15345 options to be used when building the named main file. If a main file
15346 is not specified in the Switches attribute, it is built with the
15347 options specified by Default_Switches of its language, if defined.
15348
15349 @item Global_Configuration_Pragmas
15350 This is a simple attribute, whose
15351 value is a path name that designates a file that contains configuration pragmas
15352 to be used in every build of an executable. If both local and global
15353 configuration pragmas are specified, a compilation makes use of both sets.
15354
15355
15356 @item Executable
15357 This is an associative array attribute. Its domain is
15358 a set of main source file names. Its range is a simple string that specifies
15359 the executable file name to be used when linking the specified main source.
15360 If a main source is not specified in the Executable attribute, the executable
15361 file name is deducted from the main source file name.
15362 This attribute has no effect if its value is the empty string.
15363
15364 @item Executable_Suffix
15365 This is a simple attribute whose value is the suffix to be added to
15366 the executables that don't have an attribute Executable specified.
15367 @end table
15368
15369 @subsection package Gnatls
15370
15371 @noindent
15372 The attributes of package @code{Gnatls} specify the tool options to be used
15373 when invoking the library browser @command{gnatls}.
15374 The following attributes apply to package @code{Gnatls}:
15375
15376 @table @code
15377 @item Switches
15378 This is a single attribute with a string list value. Each non empty string
15379 in the list is an option when invoking @code{gnatls}.
15380 @end table
15381
15382 @subsection package Binder
15383
15384 @noindent
15385 The attributes of package @code{Binder} specify the options to be used
15386 when invoking the binder in the construction of an executable.
15387 The following attributes apply to package @code{Binder}:
15388
15389 @table @code
15390 @item     Default_Switches
15391 This is an associative array attribute. Its
15392 domain is a set of language names. Its range is a string list that
15393 specifies options to be used when binding a main
15394 written in that language, for which no file-specific switches have been
15395 specified.
15396
15397 @item Switches
15398 This is an associative array attribute. Its domain is
15399 a set of file names. Its range is a string list that specifies
15400 options to be used when binding the named main file. If a main file
15401 is not specified in the Switches attribute, it is bound with the
15402 options specified by Default_Switches of its language, if defined.
15403 @end table
15404
15405 @subsection package Linker
15406
15407 @noindent
15408 The attributes of package @code{Linker} specify the options to be used when
15409 invoking the linker in the construction of an executable.
15410 The following attributes apply to package @code{Linker}:
15411
15412 @table @code
15413 @item     Default_Switches
15414 This is an associative array attribute. Its
15415 domain is a set of language names. Its range is a string list that
15416 specifies options to be used when linking a main
15417 written in that language, for which no file-specific switches have been
15418 specified.
15419
15420 @item Switches
15421 This is an associative array attribute. Its domain is
15422 a set of file names. Its range is a string list that specifies
15423 options to be used when linking the named main file. If a main file
15424 is not specified in the Switches attribute, it is linked with the
15425 options specified by Default_Switches of its language, if defined.
15426
15427 @item  Linker_Options
15428 This is a string list attribute. Its value specifies additional options that
15429 be given to the linker when linking an executable. This attribute is not
15430 used in the main project, only in projects imported directly or indirectly.
15431
15432 @end table
15433
15434 @subsection package Cross_Reference
15435
15436 @noindent
15437 The attributes of package @code{Cross_Reference} specify the tool options
15438 to be used
15439 when invoking the library tool @command{gnatxref}.
15440 The following attributes apply to package @code{Cross_Reference}:
15441
15442 @table @code
15443 @item     Default_Switches
15444 This is an associative array attribute. Its
15445 domain is a set of language names. Its range is a string list that
15446 specifies options to be used when calling @command{gnatxref} on a source
15447 written in that language, for which no file-specific switches have been
15448 specified.
15449
15450 @item Switches
15451 This is an associative array attribute. Its domain is
15452 a set of file names. Its range is a string list that specifies
15453 options to be used when calling @command{gnatxref} on the named main source.
15454 If a source is not specified in the Switches attribute, @command{gnatxref} will
15455 be called with the options specified by Default_Switches of its language,
15456 if defined.
15457 @end table
15458
15459 @subsection package   Finder
15460
15461 @noindent
15462 The attributes of package @code{Finder} specify the tool options to be used
15463 when invoking the search tool @command{gnatfind}.
15464 The following attributes apply to package @code{Finder}:
15465
15466 @table @code
15467 @item     Default_Switches
15468 This is an associative array attribute. Its
15469 domain is a set of language names. Its range is a string list that
15470 specifies options to be used when calling @command{gnatfind} on a source
15471 written in that language, for which no file-specific switches have been
15472 specified.
15473
15474 @item Switches
15475 This is an associative array attribute. Its domain is
15476 a set of file names. Its range is a string list that specifies
15477 options to be used when calling @command{gnatfind} on the named main source.
15478 If a source is not specified in the Switches attribute, @command{gnatfind} will
15479 be called with the options specified by Default_Switches of its language,
15480 if defined.
15481 @end table
15482
15483 @subsection package Pretty_Printer
15484
15485 @noindent
15486 The attributes of package @code{Pretty_Printer}
15487 specify the tool options to be used
15488 when invoking the formatting tool @command{gnatpp}.
15489 The following attributes apply to package @code{Pretty_Printer}:
15490
15491 @table @code
15492 @item     Default_switches
15493 This is an associative array attribute. Its
15494 domain is a set of language names. Its range is a string list that
15495 specifies options to be used when calling @command{gnatpp} on a source
15496 written in that language, for which no file-specific switches have been
15497 specified.
15498
15499 @item Switches
15500 This is an associative array attribute. Its domain is
15501 a set of file names. Its range is a string list that specifies
15502 options to be used when calling @command{gnatpp} on the named main source.
15503 If a source is not specified in the Switches attribute, @command{gnatpp} will
15504 be called with the options specified by Default_Switches of its language,
15505 if defined.
15506 @end table
15507
15508 @subsection package gnatstub
15509
15510 @noindent
15511 The attributes of package @code{gnatstub}
15512 specify the tool options to be used
15513 when invoking the tool @command{gnatstub}.
15514 The following attributes apply to package @code{gnatstub}:
15515
15516 @table @code
15517 @item     Default_switches
15518 This is an associative array attribute. Its
15519 domain is a set of language names. Its range is a string list that
15520 specifies options to be used when calling @command{gnatstub} on a source
15521 written in that language, for which no file-specific switches have been
15522 specified.
15523
15524 @item Switches
15525 This is an associative array attribute. Its domain is
15526 a set of file names. Its range is a string list that specifies
15527 options to be used when calling @command{gnatstub} on the named main source.
15528 If a source is not specified in the Switches attribute, @command{gnatpp} will
15529 be called with the options specified by Default_Switches of its language,
15530 if defined.
15531 @end table
15532
15533 @subsection package Eliminate
15534
15535 @noindent
15536 The attributes of package @code{Eliminate}
15537 specify the tool options to be used
15538 when invoking the tool @command{gnatelim}.
15539 The following attributes apply to package @code{Eliminate}:
15540
15541 @table @code
15542 @item     Default_switches
15543 This is an associative array attribute. Its
15544 domain is a set of language names. Its range is a string list that
15545 specifies options to be used when calling @command{gnatelim} on a source
15546 written in that language, for which no file-specific switches have been
15547 specified.
15548
15549 @item Switches
15550 This is an associative array attribute. Its domain is
15551 a set of file names. Its range is a string list that specifies
15552 options to be used when calling @command{gnatelim} on the named main source.
15553 If a source is not specified in the Switches attribute, @command{gnatelim} will
15554 be called with the options specified by Default_Switches of its language,
15555 if defined.
15556 @end table
15557
15558 @subsection package Metrics
15559
15560 @noindent
15561 The attributes of package @code{Metrics}
15562 specify the tool options to be used
15563 when invoking the tool @command{gnatmetric}.
15564 The following attributes apply to package @code{Metrics}:
15565
15566 @table @code
15567 @item     Default_switches
15568 This is an associative array attribute. Its
15569 domain is a set of language names. Its range is a string list that
15570 specifies options to be used when calling @command{gnatmetric} on a source
15571 written in that language, for which no file-specific switches have been
15572 specified.
15573
15574 @item Switches
15575 This is an associative array attribute. Its domain is
15576 a set of file names. Its range is a string list that specifies
15577 options to be used when calling @command{gnatmetric} on the named main source.
15578 If a source is not specified in the Switches attribute, @command{gnatmetric}
15579 will be called with the options specified by Default_Switches of its language,
15580 if defined.
15581 @end table
15582
15583 @subsection  package IDE
15584
15585 @noindent
15586 The attributes of package @code{IDE} specify the options to be used when using
15587 an Integrated Development Environment such as @command{GPS}.
15588
15589 @table @code
15590 @item Remote_Host
15591 This is a simple attribute. Its value is a string that designates the remote
15592 host in a cross-compilation environment, to be used for remote compilation and
15593 debugging. This field should not be specified when running on the local
15594 machine.
15595
15596 @item Program_Host
15597 This is a simple attribute. Its value is a string that specifies the
15598 name of IP address of the embedded target in a cross-compilation environment,
15599 on which the program should execute.
15600
15601 @item Communication_Protocol
15602 This is a simple string attribute. Its value is the name of the protocol
15603 to use to communicate with the target in a cross-compilation environment,
15604 e.g. @code{"wtx"} or @code{"vxworks"}.
15605
15606 @item Compiler_Command
15607 This is an associative array attribute, whose domain is a language name. Its
15608 value is  string that denotes the command to be used to invoke the compiler.
15609 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15610 gnatmake, in particular in the handling of switches.
15611
15612 @item Debugger_Command
15613 This is simple attribute, Its value is a string that specifies the name of
15614 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15615
15616 @item Default_Switches
15617 This is an associative array attribute. Its indexes are the name of the
15618 external tools that the GNAT Programming System (GPS) is supporting. Its
15619 value is a list of switches to use when invoking that tool.
15620
15621 @item  Gnatlist
15622 This is a simple attribute.  Its value is a string that specifies the name
15623 of the @command{gnatls} utility to be used to retrieve information about the
15624 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15625
15626 @item VCS_Kind
15627 This is a simple attribute. Its value is a string used to specify the
15628 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15629 ClearCase or Perforce.
15630
15631 @item VCS_File_Check
15632 This is a simple attribute. Its value is a string that specifies the
15633 command used by the VCS to check the validity of a file, either
15634 when the user explicitly asks for a check, or as a sanity check before
15635 doing the check-in.
15636
15637 @item VCS_Log_Check
15638 This is a simple attribute. Its value is a string that specifies
15639 the command used by the VCS to check the validity of a log file.
15640
15641 @end table
15642
15643 @node Package Renamings
15644 @section Package Renamings
15645
15646 @noindent
15647 A package can be defined by a renaming declaration. The new package renames
15648 a package declared in a different project file, and has the same attributes
15649 as the package it renames.
15650 Syntax:
15651 @smallexample
15652 package_renaming ::==
15653   @b{package} package_identifier @b{renames}
15654        <project_>simple_name.package_identifier ;
15655 @end smallexample
15656
15657 @noindent
15658 The package_identifier of the renamed package must be the same as the
15659 package_identifier. The project whose name is the prefix of the renamed
15660 package must contain a package declaration with this name. This project
15661 must appear in the context_clause of the enclosing project declaration,
15662 or be the parent project of the enclosing child project.
15663
15664 @node Projects
15665 @section Projects
15666
15667 @noindent
15668 A project file specifies a set of rules for constructing a software system.
15669 A project file can be self-contained, or depend on other project files.
15670 Dependencies are expressed through a context clause that names other projects.
15671
15672 Syntax:
15673
15674 @smallexample
15675 project ::=
15676   context_clause project_declaration
15677
15678 project_declaration ::=
15679   simple_project_declaration | project_extension
15680
15681 simple_project_declaration ::=
15682   @b{project} <project_>simple_name @b{is}
15683     @{declarative_item@}
15684   @b{end} <project_>simple_name;
15685
15686 context_clause ::=
15687   @{with_clause@}
15688
15689 with_clause ::=
15690   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15691
15692 path_name ::=
15693    string_literal
15694 @end smallexample
15695
15696 @noindent
15697 A path name denotes a project file. A path name can be absolute or relative.
15698 An absolute path name includes a sequence of directories, in the syntax of
15699 the host operating system, that identifies uniquely the project file in the
15700 file system. A relative path name identifies the project file, relative
15701 to the directory that contains the current project, or relative to a
15702 directory listed in the environment variable ADA_PROJECT_PATH.
15703 Path names are case sensitive if file names in the host operating system
15704 are case sensitive.
15705
15706 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15707 directory names separated by colons (semicolons on Windows).
15708
15709 A given project name can appear only once in a context_clause.
15710
15711 It is illegal for a project imported by a context clause to refer, directly
15712 or indirectly, to the project in which this context clause appears (the
15713 dependency graph cannot contain cycles), except when one of the with_clause
15714 in the cycle is a @code{limited with}.
15715
15716 @node Project Extensions
15717 @section Project Extensions
15718
15719 @noindent
15720 A project extension introduces a new project, which inherits the declarations
15721 of another project.
15722 Syntax:
15723 @smallexample
15724
15725 project_extension ::=
15726   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15727     @{declarative_item@}
15728   @b{end} <project_>simple_name;
15729 @end smallexample
15730
15731 @noindent
15732 The project extension declares a child project. The child project inherits
15733 all the declarations and all the files of the parent project, These inherited
15734 declaration can be overridden in the child project, by means of suitable
15735 declarations.
15736
15737 @node Project File Elaboration
15738 @section Project File Elaboration
15739
15740 @noindent
15741 A project file is processed as part of the invocation of a gnat tool that
15742 uses the project option. Elaboration of the process file consists in the
15743 sequential elaboration of all its declarations. The computed values of
15744 attributes and variables in the project are then used to establish the
15745 environment in which the gnat tool will execute.
15746
15747 @node Obsolescent Features
15748 @chapter Obsolescent Features
15749
15750 @noindent
15751 This chapter describes features that are provided by GNAT, but are
15752 considered obsolescent since there are preferred ways of achieving
15753 the same effect. These features are provided solely for historical
15754 compatibility purposes.
15755
15756 @menu
15757 * pragma No_Run_Time::
15758 * pragma Ravenscar::
15759 * pragma Restricted_Run_Time::
15760 @end menu
15761
15762 @node pragma No_Run_Time
15763 @section pragma No_Run_Time
15764
15765 The pragma @code{No_Run_Time} is used to achieve an affect similar
15766 to the use of the "Zero Foot Print" configurable run time, but without
15767 requiring a specially configured run time. The result of using this
15768 pragma, which must be used for all units in a partition, is to restrict
15769 the use of any language features requiring run-time support code. The
15770 preferred usage is to use an appropriately configured run-time that
15771 includes just those features that are to be made accessible.
15772
15773 @node pragma Ravenscar
15774 @section pragma Ravenscar
15775
15776 The pragma @code{Ravenscar} has exactly the same effect as pragma
15777 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15778 is part of the new Ada 2005 standard.
15779
15780 @node pragma Restricted_Run_Time
15781 @section pragma Restricted_Run_Time
15782
15783 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15784 pragma @code{Profile (Restricted)}. The latter usage is
15785 preferred since the Ada 2005 pragma @code{Profile} is intended for
15786 this kind of implementation dependent addition.
15787
15788 @include fdl.texi
15789 @c GNU Free Documentation License
15790
15791 @node Index,,GNU Free Documentation License, Top
15792 @unnumbered Index
15793
15794 @printindex cp
15795
15796 @contents
15797
15798 @bye